Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/edid: split out drm_eld.h from drm_edid.h

The drm_edid.[ch] files are starting to be a bit crowded, and with plans
to add more ELD related functionality, it's perhaps cleanest to split
the ELD code out to a header of its own.

Include drm_eld.h from drm_edid.h for starters, and leave it to
follow-up work to only include drm_eld.h where needed.

Cc: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Reviewed-by: Mitul Golani <mitulkumar.ajitkumar.golani@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/0c6d631fa1058036d72dd25d1cabc90a7c52490e.1698747331.git.jani.nikula@intel.com

+163 -148
+3
Documentation/gpu/drm-kms-helpers.rst
··· 363 363 .. kernel-doc:: drivers/gpu/drm/drm_edid.c 364 364 :export: 365 365 366 + .. kernel-doc:: include/drm/drm_eld.h 367 + :internal: 368 + 366 369 SCDC Helper Functions Reference 367 370 =============================== 368 371
+1 -148
include/drm/drm_edid.h
··· 25 25 26 26 #include <linux/types.h> 27 27 #include <linux/hdmi.h> 28 + #include <drm/drm_eld.h> /* FIXME: remove this, include directly where needed */ 28 29 #include <drm/drm_mode.h> 29 30 30 31 struct drm_device; ··· 270 269 #define DRM_EDID_DSC_MAX_SLICES 0xf 271 270 #define DRM_EDID_DSC_TOTAL_CHUNK_KBYTES 0x3f 272 271 273 - /* ELD Header Block */ 274 - #define DRM_ELD_HEADER_BLOCK_SIZE 4 275 - 276 - #define DRM_ELD_VER 0 277 - # define DRM_ELD_VER_SHIFT 3 278 - # define DRM_ELD_VER_MASK (0x1f << 3) 279 - # define DRM_ELD_VER_CEA861D (2 << 3) /* supports 861D or below */ 280 - # define DRM_ELD_VER_CANNED (0x1f << 3) 281 - 282 - #define DRM_ELD_BASELINE_ELD_LEN 2 /* in dwords! */ 283 - 284 - /* ELD Baseline Block for ELD_Ver == 2 */ 285 - #define DRM_ELD_CEA_EDID_VER_MNL 4 286 - # define DRM_ELD_CEA_EDID_VER_SHIFT 5 287 - # define DRM_ELD_CEA_EDID_VER_MASK (7 << 5) 288 - # define DRM_ELD_CEA_EDID_VER_NONE (0 << 5) 289 - # define DRM_ELD_CEA_EDID_VER_CEA861 (1 << 5) 290 - # define DRM_ELD_CEA_EDID_VER_CEA861A (2 << 5) 291 - # define DRM_ELD_CEA_EDID_VER_CEA861BCD (3 << 5) 292 - # define DRM_ELD_MNL_SHIFT 0 293 - # define DRM_ELD_MNL_MASK (0x1f << 0) 294 - 295 - #define DRM_ELD_SAD_COUNT_CONN_TYPE 5 296 - # define DRM_ELD_SAD_COUNT_SHIFT 4 297 - # define DRM_ELD_SAD_COUNT_MASK (0xf << 4) 298 - # define DRM_ELD_CONN_TYPE_SHIFT 2 299 - # define DRM_ELD_CONN_TYPE_MASK (3 << 2) 300 - # define DRM_ELD_CONN_TYPE_HDMI (0 << 2) 301 - # define DRM_ELD_CONN_TYPE_DP (1 << 2) 302 - # define DRM_ELD_SUPPORTS_AI (1 << 1) 303 - # define DRM_ELD_SUPPORTS_HDCP (1 << 0) 304 - 305 - #define DRM_ELD_AUD_SYNCH_DELAY 6 /* in units of 2 ms */ 306 - # define DRM_ELD_AUD_SYNCH_DELAY_MAX 0xfa /* 500 ms */ 307 - 308 - #define DRM_ELD_SPEAKER 7 309 - # define DRM_ELD_SPEAKER_MASK 0x7f 310 - # define DRM_ELD_SPEAKER_RLRC (1 << 6) 311 - # define DRM_ELD_SPEAKER_FLRC (1 << 5) 312 - # define DRM_ELD_SPEAKER_RC (1 << 4) 313 - # define DRM_ELD_SPEAKER_RLR (1 << 3) 314 - # define DRM_ELD_SPEAKER_FC (1 << 2) 315 - # define DRM_ELD_SPEAKER_LFE (1 << 1) 316 - # define DRM_ELD_SPEAKER_FLR (1 << 0) 317 - 318 - #define DRM_ELD_PORT_ID 8 /* offsets 8..15 inclusive */ 319 - # define DRM_ELD_PORT_ID_LEN 8 320 - 321 - #define DRM_ELD_MANUFACTURER_NAME0 16 322 - #define DRM_ELD_MANUFACTURER_NAME1 17 323 - 324 - #define DRM_ELD_PRODUCT_CODE0 18 325 - #define DRM_ELD_PRODUCT_CODE1 19 326 - 327 - #define DRM_ELD_MONITOR_NAME_STRING 20 /* offsets 20..(20+mnl-1) inclusive */ 328 - 329 - #define DRM_ELD_CEA_SAD(mnl, sad) (20 + (mnl) + 3 * (sad)) 330 - 331 272 struct edid { 332 273 u8 header[8]; 333 274 /* Vendor & product info */ ··· 351 408 const struct drm_connector *connector, 352 409 const struct drm_display_mode *mode, 353 410 enum hdmi_quantization_range rgb_quant_range); 354 - 355 - /** 356 - * drm_eld_mnl - Get ELD monitor name length in bytes. 357 - * @eld: pointer to an eld memory structure with mnl set 358 - */ 359 - static inline int drm_eld_mnl(const uint8_t *eld) 360 - { 361 - return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; 362 - } 363 - 364 - /** 365 - * drm_eld_sad - Get ELD SAD structures. 366 - * @eld: pointer to an eld memory structure with sad_count set 367 - */ 368 - static inline const uint8_t *drm_eld_sad(const uint8_t *eld) 369 - { 370 - unsigned int ver, mnl; 371 - 372 - ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT; 373 - if (ver != 2 && ver != 31) 374 - return NULL; 375 - 376 - mnl = drm_eld_mnl(eld); 377 - if (mnl > 16) 378 - return NULL; 379 - 380 - return eld + DRM_ELD_CEA_SAD(mnl, 0); 381 - } 382 - 383 - /** 384 - * drm_eld_sad_count - Get ELD SAD count. 385 - * @eld: pointer to an eld memory structure with sad_count set 386 - */ 387 - static inline int drm_eld_sad_count(const uint8_t *eld) 388 - { 389 - return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >> 390 - DRM_ELD_SAD_COUNT_SHIFT; 391 - } 392 - 393 - /** 394 - * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes 395 - * @eld: pointer to an eld memory structure with mnl and sad_count set 396 - * 397 - * This is a helper for determining the payload size of the baseline block, in 398 - * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block. 399 - */ 400 - static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld) 401 - { 402 - return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE + 403 - drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; 404 - } 405 - 406 - /** 407 - * drm_eld_size - Get ELD size in bytes 408 - * @eld: pointer to a complete eld memory structure 409 - * 410 - * The returned value does not include the vendor block. It's vendor specific, 411 - * and comprises of the remaining bytes in the ELD memory buffer after 412 - * drm_eld_size() bytes of header and baseline block. 413 - * 414 - * The returned value is guaranteed to be a multiple of 4. 415 - */ 416 - static inline int drm_eld_size(const uint8_t *eld) 417 - { 418 - return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4; 419 - } 420 - 421 - /** 422 - * drm_eld_get_spk_alloc - Get speaker allocation 423 - * @eld: pointer to an ELD memory structure 424 - * 425 - * The returned value is the speakers mask. User has to use %DRM_ELD_SPEAKER 426 - * field definitions to identify speakers. 427 - */ 428 - static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) 429 - { 430 - return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK; 431 - } 432 - 433 - /** 434 - * drm_eld_get_conn_type - Get device type hdmi/dp connected 435 - * @eld: pointer to an ELD memory structure 436 - * 437 - * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or %DRM_ELD_CONN_TYPE_DP to 438 - * identify the display type connected. 439 - */ 440 - static inline u8 drm_eld_get_conn_type(const uint8_t *eld) 441 - { 442 - return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK; 443 - } 444 411 445 412 /** 446 413 * drm_edid_decode_mfg_id - Decode the manufacturer ID
+159
include/drm/drm_eld.h
··· 1 + /* SPDX-License-Identifier: MIT */ 2 + /* 3 + * Copyright © 2023 Intel Corporation 4 + */ 5 + 6 + #ifndef __DRM_ELD_H__ 7 + #define __DRM_ELD_H__ 8 + 9 + #include <linux/types.h> 10 + 11 + /* ELD Header Block */ 12 + #define DRM_ELD_HEADER_BLOCK_SIZE 4 13 + 14 + #define DRM_ELD_VER 0 15 + # define DRM_ELD_VER_SHIFT 3 16 + # define DRM_ELD_VER_MASK (0x1f << 3) 17 + # define DRM_ELD_VER_CEA861D (2 << 3) /* supports 861D or below */ 18 + # define DRM_ELD_VER_CANNED (0x1f << 3) 19 + 20 + #define DRM_ELD_BASELINE_ELD_LEN 2 /* in dwords! */ 21 + 22 + /* ELD Baseline Block for ELD_Ver == 2 */ 23 + #define DRM_ELD_CEA_EDID_VER_MNL 4 24 + # define DRM_ELD_CEA_EDID_VER_SHIFT 5 25 + # define DRM_ELD_CEA_EDID_VER_MASK (7 << 5) 26 + # define DRM_ELD_CEA_EDID_VER_NONE (0 << 5) 27 + # define DRM_ELD_CEA_EDID_VER_CEA861 (1 << 5) 28 + # define DRM_ELD_CEA_EDID_VER_CEA861A (2 << 5) 29 + # define DRM_ELD_CEA_EDID_VER_CEA861BCD (3 << 5) 30 + # define DRM_ELD_MNL_SHIFT 0 31 + # define DRM_ELD_MNL_MASK (0x1f << 0) 32 + 33 + #define DRM_ELD_SAD_COUNT_CONN_TYPE 5 34 + # define DRM_ELD_SAD_COUNT_SHIFT 4 35 + # define DRM_ELD_SAD_COUNT_MASK (0xf << 4) 36 + # define DRM_ELD_CONN_TYPE_SHIFT 2 37 + # define DRM_ELD_CONN_TYPE_MASK (3 << 2) 38 + # define DRM_ELD_CONN_TYPE_HDMI (0 << 2) 39 + # define DRM_ELD_CONN_TYPE_DP (1 << 2) 40 + # define DRM_ELD_SUPPORTS_AI (1 << 1) 41 + # define DRM_ELD_SUPPORTS_HDCP (1 << 0) 42 + 43 + #define DRM_ELD_AUD_SYNCH_DELAY 6 /* in units of 2 ms */ 44 + # define DRM_ELD_AUD_SYNCH_DELAY_MAX 0xfa /* 500 ms */ 45 + 46 + #define DRM_ELD_SPEAKER 7 47 + # define DRM_ELD_SPEAKER_MASK 0x7f 48 + # define DRM_ELD_SPEAKER_RLRC (1 << 6) 49 + # define DRM_ELD_SPEAKER_FLRC (1 << 5) 50 + # define DRM_ELD_SPEAKER_RC (1 << 4) 51 + # define DRM_ELD_SPEAKER_RLR (1 << 3) 52 + # define DRM_ELD_SPEAKER_FC (1 << 2) 53 + # define DRM_ELD_SPEAKER_LFE (1 << 1) 54 + # define DRM_ELD_SPEAKER_FLR (1 << 0) 55 + 56 + #define DRM_ELD_PORT_ID 8 /* offsets 8..15 inclusive */ 57 + # define DRM_ELD_PORT_ID_LEN 8 58 + 59 + #define DRM_ELD_MANUFACTURER_NAME0 16 60 + #define DRM_ELD_MANUFACTURER_NAME1 17 61 + 62 + #define DRM_ELD_PRODUCT_CODE0 18 63 + #define DRM_ELD_PRODUCT_CODE1 19 64 + 65 + #define DRM_ELD_MONITOR_NAME_STRING 20 /* offsets 20..(20+mnl-1) inclusive */ 66 + 67 + #define DRM_ELD_CEA_SAD(mnl, sad) (20 + (mnl) + 3 * (sad)) 68 + 69 + /** 70 + * drm_eld_mnl - Get ELD monitor name length in bytes. 71 + * @eld: pointer to an eld memory structure with mnl set 72 + */ 73 + static inline int drm_eld_mnl(const uint8_t *eld) 74 + { 75 + return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; 76 + } 77 + 78 + /** 79 + * drm_eld_sad - Get ELD SAD structures. 80 + * @eld: pointer to an eld memory structure with sad_count set 81 + */ 82 + static inline const uint8_t *drm_eld_sad(const uint8_t *eld) 83 + { 84 + unsigned int ver, mnl; 85 + 86 + ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT; 87 + if (ver != 2 && ver != 31) 88 + return NULL; 89 + 90 + mnl = drm_eld_mnl(eld); 91 + if (mnl > 16) 92 + return NULL; 93 + 94 + return eld + DRM_ELD_CEA_SAD(mnl, 0); 95 + } 96 + 97 + /** 98 + * drm_eld_sad_count - Get ELD SAD count. 99 + * @eld: pointer to an eld memory structure with sad_count set 100 + */ 101 + static inline int drm_eld_sad_count(const uint8_t *eld) 102 + { 103 + return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >> 104 + DRM_ELD_SAD_COUNT_SHIFT; 105 + } 106 + 107 + /** 108 + * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes 109 + * @eld: pointer to an eld memory structure with mnl and sad_count set 110 + * 111 + * This is a helper for determining the payload size of the baseline block, in 112 + * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block. 113 + */ 114 + static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld) 115 + { 116 + return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE + 117 + drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; 118 + } 119 + 120 + /** 121 + * drm_eld_size - Get ELD size in bytes 122 + * @eld: pointer to a complete eld memory structure 123 + * 124 + * The returned value does not include the vendor block. It's vendor specific, 125 + * and comprises of the remaining bytes in the ELD memory buffer after 126 + * drm_eld_size() bytes of header and baseline block. 127 + * 128 + * The returned value is guaranteed to be a multiple of 4. 129 + */ 130 + static inline int drm_eld_size(const uint8_t *eld) 131 + { 132 + return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4; 133 + } 134 + 135 + /** 136 + * drm_eld_get_spk_alloc - Get speaker allocation 137 + * @eld: pointer to an ELD memory structure 138 + * 139 + * The returned value is the speakers mask. User has to use %DRM_ELD_SPEAKER 140 + * field definitions to identify speakers. 141 + */ 142 + static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) 143 + { 144 + return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK; 145 + } 146 + 147 + /** 148 + * drm_eld_get_conn_type - Get device type hdmi/dp connected 149 + * @eld: pointer to an ELD memory structure 150 + * 151 + * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or %DRM_ELD_CONN_TYPE_DP to 152 + * identify the display type connected. 153 + */ 154 + static inline u8 drm_eld_get_conn_type(const uint8_t *eld) 155 + { 156 + return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK; 157 + } 158 + 159 + #endif /* __DRM_ELD_H__ */