1 /** 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef __CMD_H__ 18 #define __CMD_H__ 19 #endif 20 21 #define _IOC_NRBITS 8 22 #define _IOC_TYPEBITS 8 23 24 /* 25 * Let any architecture override either of the following before 26 * including this file. 27 */ 28 29 #ifndef _IOC_SIZEBITS 30 #define _IOC_SIZEBITS 14 31 #endif 32 33 #ifndef _IOC_DIRBITS 34 #define _IOC_DIRBITS 2 35 #endif 36 37 #define _IOC_NRMASK ((1 << _IOC_NRBITS) - 1) 38 #define _IOC_TYPEMASK ((1 << _IOC_TYPEBITS) - 1) 39 #define _IOC_SIZEMASK ((1 << _IOC_SIZEBITS) - 1) 40 #define _IOC_DIRMASK ((1 << _IOC_DIRBITS) - 1) 41 42 #define _IOC_NRSHIFT 0 43 #define _IOC_TYPESHIFT (_IOC_NRSHIFT + _IOC_NRBITS) 44 #define _IOC_SIZESHIFT (_IOC_TYPESHIFT + _IOC_TYPEBITS) 45 #define _IOC_DIRSHIFT (_IOC_SIZESHIFT + _IOC_SIZEBITS) 46 47 /* 48 * Direction bits, which any architecture can choose to override 49 * before including this file. 50 */ 51 52 #ifndef _IOC_NONE 53 #define _IOC_NONE 0U 54 #endif 55 56 #ifndef _IOC_WRITE 57 #define _IOC_WRITE 1U 58 #endif 59 60 #ifndef _IOC_READ 61 #define _IOC_READ 2U 62 #endif 63 64 #define _IOC_TYPECHECK(t) (sizeof(t)) 65 #define _IOC(dir, type, nr, size) \ 66 (((dir) << _IOC_DIRSHIFT) | ((type) << _IOC_TYPESHIFT) | \ 67 ((nr) << _IOC_NRSHIFT) | ((size) << _IOC_SIZESHIFT)) 68 69 /* used to create numbers */ 70 #define _IO(type, nr) _IOC(_IOC_NONE, (type), (nr), 0) 71 #define _IOR(type, nr, size) \ 72 _IOC(_IOC_READ, (type), (nr), (_IOC_TYPECHECK(size))) 73 #define _IOW(type, nr, size) \ 74 _IOC(_IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size))) 75 #define _IOWR(type, nr, size) \ 76 _IOC(_IOC_READ | _IOC_WRITE, (type), (nr), (_IOC_TYPECHECK(size))) 77 78 #define MSMFB_IOCTL_MAGIC 'm' 79 80 struct mdp_pp_feature_version { 81 uint32_t pp_feature; 82 uint32_t version_info; 83 }; 84 #define MSMFB_MDP_PP_GET_FEATURE_VERSION \ 85 _IOWR(MSMFB_IOCTL_MAGIC, 171, struct mdp_pp_feature_version) 86 87 struct fb_cmap_user { 88 __u32 start; /* First entry */ 89 __u32 len; /* Number of entries */ 90 __u16 *red; /* Red values */ 91 __u16 *green; 92 __u16 *blue; 93 __u16 *transp; /* transparency, can be NULL */ 94 }; 95 #define FBIOPUTCMAP 0x4605 96 97 /* QSEED3 LUT sizes */ 98 #define DIR_LUT_IDX 1 99 #define DIR_LUT_COEFFS 200 100 #define CIR_LUT_IDX 9 101 #define CIR_LUT_COEFFS 60 102 #define SEP_LUT_IDX 10 103 #define SEP_LUT_COEFFS 60 104 105 struct mdp_scale_luts_info { 106 uint64_t dir_lut; 107 uint64_t cir_lut; 108 uint64_t sep_lut; 109 uint32_t dir_lut_size; 110 uint32_t cir_lut_size; 111 uint32_t sep_lut_size; 112 }; 113 114 struct mdp_set_cfg { 115 uint64_t flags; 116 uint32_t len; 117 uint64_t payload; 118 }; 119 #define MDP_QSEED3_LUT_CFG 0x1 120 121 #define MDP_IOCTL_MAGIC 'S' 122 #define MSMFB_MDP_SET_CFG _IOW(MDP_IOCTL_MAGIC, 130, struct mdp_set_cfg) 123 124 #define MDP_LAYER_COMMIT_V1_PAD 4 125 126 struct mdp_rect { 127 uint32_t x; 128 uint32_t y; 129 uint32_t w; 130 uint32_t h; 131 }; 132 133 enum mdss_mdp_blend_op { 134 BLEND_OP_NOT_DEFINED = 0, 135 BLEND_OP_OPAQUE, 136 BLEND_OP_PREMULTIPLIED, 137 BLEND_OP_COVERAGE, 138 BLEND_OP_MAX, 139 }; 140 141 enum mdp_color_space { 142 MDP_CSC_ITU_R_601, 143 MDP_CSC_ITU_R_601_FR, 144 MDP_CSC_ITU_R_709, 145 }; 146 147 struct mdp_layer_plane { 148 /* DMA buffer file descriptor information. */ 149 int fd; 150 151 /* Pixel offset in the dma buffer. */ 152 uint32_t offset; 153 154 /* Number of bytes in one scan line including padding bytes. */ 155 uint32_t stride; 156 }; 157 158 #define MAX_PLANES 4 159 160 struct mult_factor { 161 uint32_t numer; 162 uint32_t denom; 163 }; 164 struct mdp_layer_buffer { 165 uint32_t width; 166 uint32_t height; 167 uint32_t format; 168 169 /* plane to hold the fd, offset, etc for all color components */ 170 struct mdp_layer_plane planes[MAX_PLANES]; 171 172 /* valid planes count in layer planes list */ 173 uint32_t plane_count; 174 175 /* compression ratio factor, value depends on the pixel format */ 176 struct mult_factor comp_ratio; 177 178 /* 179 * SyncFence associated with this buffer. It is used in two ways. 180 * 181 * 1. Driver waits to consume the buffer till producer signals in case 182 * of primary and external display. 183 * 184 * 2. Writeback device uses buffer structure for output buffer where 185 * driver is producer. However, client sends the fence with buffer to 186 * indicate that consumer is still using the buffer and it is not ready 187 * for new content. 188 */ 189 int fence; 190 191 /* 32bits reserved value for future usage. */ 192 uint32_t reserved; 193 }; 194 195 struct mdp_input_layer { 196 uint32_t flags; 197 uint32_t pipe_ndx; 198 uint8_t horz_deci; 199 uint8_t vert_deci; 200 uint8_t alpha; 201 uint16_t z_order; 202 uint32_t transp_mask; 203 uint32_t bg_color; 204 205 /* blend operation defined in "mdss_mdp_blend_op" enum. */ 206 enum mdss_mdp_blend_op blend_op; 207 208 /* color space of the source */ 209 enum mdp_color_space color_space; 210 211 struct mdp_rect src_rect; 212 213 /* 214 * Destination rectangle, the position and size of image on screen. 215 * This should always be within panel boundaries. 216 */ 217 struct mdp_rect dst_rect; 218 219 /* Scaling parameters. */ 220 void __user *scale; 221 222 /* Buffer attached with each layer. Device uses it for commit call. */ 223 struct mdp_layer_buffer buffer; 224 225 void __user *pp_info; 226 int error_code; 227 uint32_t reserved[6]; 228 }; 229 230 struct mdp_output_layer { 231 /* 232 * Flag to enable/disable properties for layer configuration. Refer 233 * layer flag config section for all possible flags. 234 */ 235 uint32_t flags; 236 237 /* 238 * Writeback destination selection for output. Client provides the index 239 * in validate and commit call. 240 */ 241 uint32_t writeback_ndx; 242 243 /* Buffer attached with output layer. Device uses it for commit call */ 244 struct mdp_layer_buffer buffer; 245 246 /* color space of the destination */ 247 enum mdp_color_space color_space; 248 249 /* 32bits reserved value for future usage. */ 250 uint32_t reserved[5]; 251 }; 252 253 struct mdp_layer_commit_v1 { 254 uint32_t flags; 255 int release_fence; 256 struct mdp_rect left_roi; 257 struct mdp_rect right_roi; 258 struct mdp_input_layer __user *input_layers; 259 260 /* Input layer count present in input list */ 261 uint32_t input_layer_cnt; 262 263 struct mdp_output_layer __user *output_layer; 264 265 int retire_fence; 266 void __user *dest_scaler; 267 uint32_t dest_scaler_cnt; 268 269 uint32_t reserved[MDP_LAYER_COMMIT_V1_PAD]; 270 }; 271 272 struct mdp_layer_commit { 273 /* 274 * 32bit version indicates the commit structure selection 275 * from union. Lower 16bits indicates the minor version while 276 * higher 16bits indicates the major version. It selects the 277 * commit structure based on major version selection. Minor version 278 * indicates that reserved fields are in use. 279 * 280 * Current supported version is 1.0 (Major:1 Minor:0) 281 */ 282 uint32_t version; 283 union { 284 /* Layer commit/validate definition for V1 */ 285 struct mdp_layer_commit_v1 commit_v1; 286 }; 287 }; 288 289 #define MDP_IOCTL_MAGIC 'S' 290 /* atomic commit ioctl used for validate and commit request */ 291 #define MSMFB_ATOMIC_COMMIT _IOWR(MDP_IOCTL_MAGIC, 128, void *) 292 293 #define MISR_CRC_BATCH_SIZE 32 294 struct mdp_misr { 295 uint32_t block_id; 296 uint32_t frame_count; 297 uint32_t crc_op_mode; 298 uint32_t crc_value[MISR_CRC_BATCH_SIZE]; 299 }; 300 301 struct mdp_blend_cfg { 302 uint32_t is_premultiplied; 303 }; 304 305 struct mdp_mixer_cfg { 306 uint32_t writeback_format; 307 uint32_t alpha; 308 }; 309 310 struct mdss_hw_caps { 311 uint32_t mdp_rev; 312 uint8_t rgb_pipes; 313 uint8_t vig_pipes; 314 uint8_t dma_pipes; 315 uint8_t max_smp_cnt; 316 uint8_t smp_per_pipe; 317 uint32_t features; 318 }; 319 320 enum { 321 metadata_op_none, 322 metadata_op_base_blend, 323 metadata_op_frame_rate, 324 metadata_op_vic, 325 metadata_op_wb_format, 326 metadata_op_wb_secure, 327 metadata_op_get_caps, 328 metadata_op_crc, 329 metadata_op_get_ion_fd, 330 metadata_op_max 331 }; 332 333 struct msmfb_metadata { 334 uint32_t op; 335 uint32_t flags; 336 union { 337 struct mdp_misr misr_request; 338 struct mdp_blend_cfg blend_cfg; 339 struct mdp_mixer_cfg mixer_cfg; 340 uint32_t panel_frame_rate; 341 uint32_t video_info_code; 342 struct mdss_hw_caps caps; 343 uint8_t secure_en; 344 int fbmem_ionfd; 345 } data; 346 }; 347 348 #define MSMFB_METADATA_GET _IOW(MSMFB_IOCTL_MAGIC, 166, struct msmfb_metadata) 349 350