1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef __SAMSUNG_DRM_H__ 3 #define __SAMSUNG_DRM_H__ 4 5 #if defined(__linux__) 6 #include <linux/types.h> 7 #endif 8 9 #include <drm/drm.h> 10 #include <drm/drm_fourcc_gs101.h> 11 12 #if defined(__cplusplus) 13 extern "C" { 14 #endif 15 16 #define DRM_SAMSUNG_HDR_EOTF_LUT_LEN 129 17 #define DRM_SAMSUNG_HDR_EOTF_V2P2_LUT_LEN 20 18 19 /** 20 * struct hdr_eotf_lut - HDR EOTF look up table to set by user-space 21 * 22 * @posx: x coordinate of the boundaries between segments in EOTF 23 * @posy: y coordinate of the boundaries between segments in EOTF 24 * 25 * A hdr_eotf_lut represents a look up table of EOTF(Electro-Optical Transfer 26 * Function). It is used for eotf_lut blob property of a plane object if 27 * a plane supports HDR10 feature. 28 */ 29 struct hdr_eotf_lut { 30 __u16 posx[DRM_SAMSUNG_HDR_EOTF_LUT_LEN]; 31 __u32 posy[DRM_SAMSUNG_HDR_EOTF_LUT_LEN]; 32 }; 33 34 struct hdr_v2p2_element { 35 __u16 even; 36 __u16 odd; 37 }; 38 39 struct hdr_eotf_lut_v2p2 { 40 struct hdr_v2p2_element ts[DRM_SAMSUNG_HDR_EOTF_V2P2_LUT_LEN]; 41 struct hdr_v2p2_element vs[DRM_SAMSUNG_HDR_EOTF_V2P2_LUT_LEN]; 42 __u16 scaler; 43 bool lut_en; 44 }; 45 46 #define DRM_SAMSUNG_HDR_OETF_LUT_LEN 33 47 #define DRM_SAMSUNG_HDR_OETF_V2P2_LUT_LEN 24 48 49 /** 50 * struct hdr_oetf_lut - HDR OETF look up table to set by user-space 51 * 52 * @posx: x coordinate of the boundaries between segments in OETF 53 * @posy: y coordinate of the boundaries between segments in OETF 54 * 55 * A hdr_oetf_lut represents a look up table of OETF(Optical-Electro Transfer 56 * Function). It is used for oetf_lut blob property of a plane object if 57 * a plane supports HDR10 feature. 58 */ 59 struct hdr_oetf_lut { 60 __u16 posx[DRM_SAMSUNG_HDR_OETF_LUT_LEN]; 61 __u16 posy[DRM_SAMSUNG_HDR_OETF_LUT_LEN]; 62 }; 63 64 struct hdr_oetf_lut_v2p2 { 65 struct hdr_v2p2_element ts[DRM_SAMSUNG_HDR_OETF_V2P2_LUT_LEN]; 66 struct hdr_v2p2_element vs[DRM_SAMSUNG_HDR_OETF_V2P2_LUT_LEN]; 67 }; 68 69 #define DRM_SAMSUNG_HDR_GM_DIMENS 3 70 71 /** 72 * struct hdr_gm_data - HDR gammut matrix data to set by user-space 73 * 74 * @coeffs: coefficients of a gammut matrix 75 * @offsets: offsets of a gammut matrix 76 * 77 * A hdr_gm_data represents coefficients and offsets of a gammut matrix. 78 * It is used to set a plane property for calculating a gammut matrix 79 * if a plane supports HDR10 feature. 80 */ 81 struct hdr_gm_data { 82 __u32 coeffs[DRM_SAMSUNG_HDR_GM_DIMENS * DRM_SAMSUNG_HDR_GM_DIMENS]; 83 __u32 offsets[DRM_SAMSUNG_HDR_GM_DIMENS]; 84 }; 85 86 #define DRM_SAMSUNG_HDR_TM_LUT_LEN 33 87 #define DRM_SAMSUNG_HDR_TM_V2P2_LUT_LEN 24 88 89 /** 90 * struct hdr_tm_data - HDR tone mapping data and look up table to set 91 * by user-space. 92 * 93 * @coeff_r: coefficient to be multiplied with R to convert RGB to Y 94 * @coeff_g: coefficient to be multiplied with G to convert RGB to Y 95 * @coeff_b: coefficient to be multiplied with B to convert RGB to Y 96 * @rng_x_min: left boundary of the decreasing range of the ratio function 97 * for adaptive mixing 98 * @rng_x_max: right boundary of the decreasing range of the ratio function 99 * for adaptive mixing 100 * @rng_y_min: minimum ratio for adaptive mixing. 101 * @rng_y_max: maximum ratio for adaptive mixing. 102 * @posx: x coordinate of the boundaries between segments in tone mapping 103 * gain function. 104 * @posy: y coordinate of the boundaries between segments in tone mapping 105 * gain function. 106 * 107 * A hdr_tm_data represents tone mapping data. It is used to set a plane 108 * property for calculating tone mapping if a plane supports HDR10+ feature. 109 */ 110 struct hdr_tm_data { 111 __u16 coeff_r; 112 __u16 coeff_g; 113 __u16 coeff_b; 114 __u16 rng_x_min; 115 __u16 rng_x_max; 116 __u16 rng_y_min; 117 __u16 rng_y_max; 118 __u16 posx[DRM_SAMSUNG_HDR_TM_LUT_LEN]; 119 __u32 posy[DRM_SAMSUNG_HDR_TM_LUT_LEN]; 120 }; 121 122 struct hdr_tm_data_v2p2 { 123 __u16 coeff_00; 124 __u16 coeff_01; 125 __u16 coeff_02; 126 __u16 ymix_tf; 127 __u16 ymix_vf; 128 __u16 ymix_slope; 129 __u16 ymix_dv; 130 struct hdr_v2p2_element ts[DRM_SAMSUNG_HDR_TM_V2P2_LUT_LEN]; 131 struct hdr_v2p2_element vs[DRM_SAMSUNG_HDR_TM_V2P2_LUT_LEN]; 132 }; 133 134 #define DRM_SAMSUNG_CGC_LUT_REG_CNT 2457 135 136 /** 137 * struct cgc_lut - color gammut control look up table to set by user-space 138 * 139 * @r_values: values for red color 140 * @g_values: values for green color 141 * @b_values: values for blue color 142 * 143 * A cgc_lut represents a look up table of color gammut control. It is used 144 * for cgc_lut blob property of a crtc object if a crtc support color gammut 145 * control. 146 */ 147 struct cgc_lut { 148 __u32 r_values[DRM_SAMSUNG_CGC_LUT_REG_CNT]; 149 __u32 g_values[DRM_SAMSUNG_CGC_LUT_REG_CNT]; 150 __u32 b_values[DRM_SAMSUNG_CGC_LUT_REG_CNT]; 151 }; 152 153 #define DRM_SAMSUNG_CGC_DMA_LUT_ENTRY_CNT 4913 154 /** 155 * struct cgc_dma_lut - color gammut control format for cgc dma to set by user-space 156 * 157 * @r_value: value for red color 158 * @g_value: value for green color 159 * @b_value: value for blue color 160 * 161 * A cgc_dma_lut represents a format to support cgc dma. cgc coefficients should be 162 * located in dram according to this format. 163 */ 164 struct cgc_dma_lut { 165 __u16 r_value; 166 __u16 g_value; 167 __u16 b_value; 168 }; 169 170 #define DRM_SAMSUNG_MATRIX_DIMENS 3 171 172 /** 173 * struct exynos_matrix - a matrix data to set by user-space 174 * 175 * @coeffs: coefficients of a matrix 176 * @offsets: offsets of a matrix 177 * 178 * A exynos_matrix represents coefficients and offsets of a matrix. 179 * It is used to set a property for calculating a matrix. 180 */ 181 struct exynos_matrix { 182 __u16 coeffs[DRM_SAMSUNG_MATRIX_DIMENS * DRM_SAMSUNG_MATRIX_DIMENS]; 183 __u16 offsets[DRM_SAMSUNG_MATRIX_DIMENS]; 184 }; 185 186 struct dpp_size_range { 187 __u32 min; 188 __u32 max; 189 __u32 align; 190 }; 191 192 struct dpp_restriction { 193 struct dpp_size_range src_f_w; 194 struct dpp_size_range src_f_h; 195 struct dpp_size_range src_w; 196 struct dpp_size_range src_h; 197 __u32 src_x_align; 198 __u32 src_y_align; 199 200 struct dpp_size_range dst_f_w; 201 struct dpp_size_range dst_f_h; 202 struct dpp_size_range dst_w; 203 struct dpp_size_range dst_h; 204 __u32 dst_x_align; 205 __u32 dst_y_align; 206 207 struct dpp_size_range blk_w; 208 struct dpp_size_range blk_h; 209 __u32 blk_x_align; 210 __u32 blk_y_align; 211 212 __u32 src_h_rot_max; /* limit of source img height in case of rotation */ 213 214 __u32 scale_down; 215 __u32 scale_up; 216 }; 217 218 struct dpp_ch_restriction { 219 __s32 id; 220 __u64 attr; 221 struct dpp_restriction restriction; 222 }; 223 224 /** 225 * struct dither_config - a dither configuration data to set by user-space 226 * 227 * @en: enable or disable a dither 228 * @mode: 0 for dither, 1 for 2bits shift 229 * @frame_con: If frame control is on, the temporal dither is used. Otherwise, 230 * the spatial dither is used. If temporal dither is used, a 231 * different dither mask can be used for each frame counter. 232 * @frame_offset: The dithers in DQE use same frame counter. However, if two 233 * dithers set a different frame offsets, each dither can select 234 * a different dither mask according to the different frame 235 * counter + offset. 236 * @table_sel_r/g/b: It can select a different dither mask for each channel. 237 * 238 * A dither_config represents the information necessary for setting up the 239 * dither in DQE. It is used to set a property of a crtc for dither 240 * configuration. 241 */ 242 struct dither_config { 243 __u8 en:1; 244 __u8 mode:1; 245 __u8 frame_con:1; 246 __u8 frame_offset:2; 247 __u8 table_sel_r:1; 248 __u8 table_sel_g:1; 249 __u8 table_sel_b:1; 250 __u32 reserved:24; 251 }; 252 253 struct attribute_range { 254 __u32 min; 255 __u32 max; 256 }; 257 258 /** 259 * struct brightness_attribute - brightness attribute data 260 * 261 * @nits: value represents brightness nits range 262 * @level: value represents panel brightness level range 263 * @percentage: value must be between 0 and 100 and be non-decreasing. 264 * This percentage must comply with display configuration 265 * file. 266 * 267 * A brightness_attribute represents brightness attribute data. 268 */ 269 struct brightness_attribute { 270 struct attribute_range nits; 271 struct attribute_range level; 272 struct attribute_range percentage; 273 }; 274 275 /** 276 * struct brightness_capability - brightness capability query by user-space 277 * 278 * @normal: normal rerepresents the normal brightness attribute. 279 * @hbm: hbm represents the hbm brightness attribute 280 * 281 * A brightness_capability represents normal/hbm brightness attribute. It is 282 * used to query connector property. 283 */ 284 struct brightness_capability { 285 struct brightness_attribute normal; 286 struct brightness_attribute hbm; 287 }; 288 289 /** 290 * struct tui_hw_buffer - buffer allocation query by user-space 291 * 292 * @fb_physical: the physical address of the buffer allocated 293 * @fb_size: the size of the buffer allocated 294 * 295 * The structure is used to return the parameter of the allocated buffer. 296 */ 297 struct tui_hw_buffer { 298 __u64 fb_physical; 299 __u64 fb_size; 300 } __attribute__((packed)); 301 302 #define EXYNOS_START_TUI 0x10 303 #define EXYNOS_FINISH_TUI 0x11 304 #define EXYNOS_TUI_REQUEST_BUFFER 0x20 305 #define EXYNOS_TUI_RELEASE_BUFFER 0x21 306 307 /** 308 * struct histogram_roi - region of interest for histogram to set by user-space 309 * 310 * @start_x: upper left x position of ROI 311 * @start_y: upper left y position of ROI 312 * @hsize: horizontal size of image 313 * @vsize: vertical size of image 314 * 315 * A histogram_roi sets region of interest on image for gathering histogram 316 * data. It is used to set a property of a crtc. 317 */ 318 struct histogram_roi { 319 __u16 start_x; 320 __u16 start_y; 321 __u16 hsize; 322 __u16 vsize; 323 }; 324 325 /** 326 * struct histogram_weights - weight for each color component to set by user-space 327 * 328 * @weight_r: histogram weight for red 329 * @weight_g: histogram weight for green 330 * @weight_b: histogram weight for blue 331 * 332 * A histogram_weights sets a weight of each color component for calculating 333 * histogram data. It is used to set a property of a crtc. 334 */ 335 struct histogram_weights { 336 __u16 weight_r; 337 __u16 weight_g; 338 __u16 weight_b; 339 }; 340 341 #define HISTOGRAM_BIN_COUNT 256 342 struct histogram_bins { 343 __u16 data[HISTOGRAM_BIN_COUNT]; 344 }; 345 346 /** 347 * enum histogram_prog_pos - defines programmable positions 348 * 349 * For example, histogram position and writeback path could be 350 * programmable. This enum defines positions for it. 351 */ 352 enum histogram_prog_pos { 353 POST_DQE, 354 PRE_DQE, 355 }; 356 357 /** 358 * enum histogram_flags - defines control masks for optional features 359 */ 360 enum histogram_flags { 361 HISTOGRAM_FLAGS_BLOCKED_ROI = 0x20, /* blocked roi configuration is valid */ 362 }; 363 364 /** 365 * struct histogram_channel_config - histogram channel configuration 366 * 367 * @roi: histogram roi 368 * @weights: histogram weights 369 * @threshold: histogram threshold 370 * @pos: histogram position (before or after DQE) 371 * @blocked_roi: histogram blocked roi (ignored if h/w does not support it) 372 * @flags: histogram optional configuration flags 373 * 374 * It is used to set a property of a crtc. 375 */ 376 struct histogram_channel_config { 377 struct histogram_roi roi; 378 struct histogram_weights weights; 379 enum histogram_prog_pos pos; 380 __u32 threshold; 381 struct histogram_roi blocked_roi; 382 __u32 flags; 383 }; 384 385 #define EXYNOS_DRM_HISTOGRAM_EVENT 0x80000000 386 #define EXYNOS_DRM_HISTOGRAM_CHANNEL_EVENT 0x80000001 387 #define EXYNOS_DRM_CONTEXT_HISTOGRAM_EVENT 0x80000002 388 389 /** 390 * struct exynos_drm_histogram_event - histogram event to wait for user-space 391 * 392 * @base: event header which informs user space event type and length. 393 * @bins: histogram bin data to be sent to user space through using read() 394 * @crtcid: crtc id 395 * 396 * User space waits for POLLIN event using like poll() or select(). If event 397 * type is EXYNOS_DRM_HISTOGRAM_EVENT, user space can try to read histogram 398 * bin data through "bins". 399 */ 400 struct exynos_drm_histogram_event { 401 struct drm_event base; 402 struct histogram_bins bins; 403 __u32 crtc_id; 404 }; 405 406 /** 407 * struct exynos_drm_histogram_channel_event - histogram channel event to wait for user-space 408 * 409 * @base: event header which informs user space event type and length. 410 * @bins: histogram bin data to be sent to user space through using read() 411 * @crtcid: crtc id 412 * @histid: histogram channel id 413 * 414 * User space waits for POLLIN event using like poll() or select(). If event 415 * type is EXYNOS_DRM_HISTOGRAM_CHANNEL_EVENT, user space can try to read histogram 416 * bin data through "bins". 417 */ 418 struct exynos_drm_histogram_channel_event { 419 struct drm_event base; 420 struct histogram_bins bins; 421 __u16 crtc_id; 422 __u16 hist_id; 423 }; 424 425 /** 426 * struct exynos_drm_context_histogram_event - context histogram event to wait for user-space 427 * 428 * @base: event header which informs user space event type and length. 429 * @bins: histogram bin data to be sent to user space through using read() 430 * @crtc_id: crtc id 431 * @user_handle: user-space histogram context (ex. blob id of config) 432 * 433 * User space waits for POLLIN event using like poll() or select(). If event 434 * type is EXYNOS_DRM_CONTEXT_HISTOGRAM_EVENT, user space can try to read histogram 435 * bin data through "bins". 436 */ 437 struct exynos_drm_context_histogram_event { 438 struct drm_event base; 439 struct histogram_bins bins; 440 __u32 crtc_id; 441 __u32 user_handle; 442 }; 443 444 #define EXYNOS_HISTOGRAM_REQUEST 0x0 445 #define EXYNOS_HISTOGRAM_CANCEL 0x1 446 #define EXYNOS_HISTOGRAM_CHANNEL_REQUEST 0x20 447 #define EXYNOS_HISTOGRAM_CHANNEL_CANCEL 0x21 448 #define EXYNOS_HISTOGRAM_CHANNEL_DATA_REQUEST 0x30 /* histogram data is returned via ioctl */ 449 #define EXYNOS_CONTEXT_HISTOGRAM_EVENT_REQUEST 0x40 450 #define EXYNOS_CONTEXT_HISTOGRAM_EVENT_CANCEL 0x41 451 452 /** 453 * struct exynos_drm_histogram_channel_request - histogram channel query control structure 454 * 455 * @crtcid: crtc id 456 * @histid: histogram channel id 457 * 458 * User space sends an IOCTL 459 * DRM_EXYNOS_HISTOGRAM_CHANNEL_REQUEST 460 * DRM_EXYNOS_HISTOGRAM_CHANNEL_CANCEL 461 * with struct exynos_drm_histogram_channel_request data type. 462 */ 463 struct exynos_drm_histogram_channel_request { 464 __u32 crtc_id; /* crtc id */ 465 __u32 hist_id; /* histogram channel id */ 466 }; 467 468 /** 469 * struct exynos_histogram_channel_request - histogram channel request 470 * 471 * @crtcid: in: crtc id 472 * @histid: in : histogram channel id 473 * @bins: out: histogram bin data to be sent to user space through using read() 474 * 475 * User space sends an IOCTL 476 * EXYNOS_HISTOGRAM_CHANNEL_SYNC_REQUEST 477 * with struct exynos_drm_histogram_channel_data_request data type 478 */ 479 struct exynos_drm_histogram_channel_data_request { 480 __u16 crtc_id; /* in: crtc id */ 481 __u16 hist_id; /* in: histogram channel id */ 482 struct histogram_bins *bins; /* out: histogram data */ 483 }; 484 485 /** 486 * struct exynos_drm_context_histogram_arg - histogram query control structure 487 * 488 * @crtc_id: crtc id 489 * @user_handle: user-space histogram context (ex. blob id of config) 490 * @flags: histogram query optional flags 491 * 492 * User space sends an IOCTL 493 * EXYNOS_CONTEXT_HISTOGRAM_EVENT_REQUEST 494 * EXYNOS_CONTEXT_HISTOGRAM_EVENT_CANCEL 495 * with struct exynos_drm_context_histogram_arg data type. 496 */ 497 struct exynos_drm_context_histogram_arg { 498 __u32 crtc_id; /* crtc id */ 499 __u32 user_handle; 500 __u32 flags; 501 }; 502 503 #define DRM_IOCTL_EXYNOS_HISTOGRAM_REQUEST \ 504 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_HISTOGRAM_REQUEST, __u32) 505 #define DRM_IOCTL_EXYNOS_HISTOGRAM_CANCEL \ 506 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_HISTOGRAM_CANCEL, __u32) 507 #define DRM_IOCTL_EXYNOS_HISTOGRAM_CHANNEL_REQUEST \ 508 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_HISTOGRAM_CHANNEL_REQUEST, \ 509 struct exynos_drm_histogram_channel_request) 510 #define DRM_IOCTL_EXYNOS_HISTOGRAM_CHANNEL_CANCEL \ 511 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_HISTOGRAM_CHANNEL_CANCEL, \ 512 struct exynos_drm_histogram_channel_request) 513 #define DRM_IOCTL_EXYNOS_HISTOGRAM_CHANNEL_DATA_REQUEST \ 514 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_HISTOGRAM_CHANNEL_DATA_REQUEST, \ 515 struct exynos_drm_histogram_channel_data_request) 516 #define DRM_IOCTL_EXYNOS_CONTEXT_HISTOGRAM_EVENT_REQUEST \ 517 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_CONTEXT_HISTOGRAM_EVENT_REQUEST, \ 518 struct exynos_drm_context_histogram_arg) 519 #define DRM_IOCTL_EXYNOS_CONTEXT_HISTOGRAM_EVENT_CANCEL \ 520 DRM_IOW(DRM_COMMAND_BASE + EXYNOS_CONTEXT_HISTOGRAM_EVENT_CANCEL, \ 521 struct exynos_drm_context_histogram_arg) 522 523 #if defined(__cplusplus) 524 } 525 #endif 526 527 #endif /* __SAMSUNG_DRM_H__ */ 528