18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright © 2007-2008 Intel Corporation 38c2ecf20Sopenharmony_ci * Jesse Barnes <jesse.barnes@intel.com> 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 68c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 78c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 88c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 98c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 108c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 138c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 188c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 198c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 208c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 218c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#ifndef __DRM_EDID_H__ 248c2ecf20Sopenharmony_ci#define __DRM_EDID_H__ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#include <linux/types.h> 278c2ecf20Sopenharmony_ci#include <linux/hdmi.h> 288c2ecf20Sopenharmony_ci#include <drm/drm_mode.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_cistruct drm_device; 318c2ecf20Sopenharmony_cistruct i2c_adapter; 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci#define EDID_LENGTH 128 348c2ecf20Sopenharmony_ci#define DDC_ADDR 0x50 358c2ecf20Sopenharmony_ci#define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define CEA_EXT 0x02 388c2ecf20Sopenharmony_ci#define VTB_EXT 0x10 398c2ecf20Sopenharmony_ci#define DI_EXT 0x40 408c2ecf20Sopenharmony_ci#define LS_EXT 0x50 418c2ecf20Sopenharmony_ci#define MI_EXT 0x60 428c2ecf20Sopenharmony_ci#define DISPLAYID_EXT 0x70 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_cistruct est_timings { 458c2ecf20Sopenharmony_ci u8 t1; 468c2ecf20Sopenharmony_ci u8 t2; 478c2ecf20Sopenharmony_ci u8 mfg_rsvd; 488c2ecf20Sopenharmony_ci} __attribute__((packed)); 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */ 518c2ecf20Sopenharmony_ci#define EDID_TIMING_ASPECT_SHIFT 6 528c2ecf20Sopenharmony_ci#define EDID_TIMING_ASPECT_MASK (0x3 << EDID_TIMING_ASPECT_SHIFT) 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci/* need to add 60 */ 558c2ecf20Sopenharmony_ci#define EDID_TIMING_VFREQ_SHIFT 0 568c2ecf20Sopenharmony_ci#define EDID_TIMING_VFREQ_MASK (0x3f << EDID_TIMING_VFREQ_SHIFT) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_cistruct std_timing { 598c2ecf20Sopenharmony_ci u8 hsize; /* need to multiply by 8 then add 248 */ 608c2ecf20Sopenharmony_ci u8 vfreq_aspect; 618c2ecf20Sopenharmony_ci} __attribute__((packed)); 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci#define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1) 648c2ecf20Sopenharmony_ci#define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2) 658c2ecf20Sopenharmony_ci#define DRM_EDID_PT_SEPARATE_SYNC (3 << 3) 668c2ecf20Sopenharmony_ci#define DRM_EDID_PT_STEREO (1 << 5) 678c2ecf20Sopenharmony_ci#define DRM_EDID_PT_INTERLACED (1 << 7) 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci/* If detailed data is pixel timing */ 708c2ecf20Sopenharmony_cistruct detailed_pixel_timing { 718c2ecf20Sopenharmony_ci u8 hactive_lo; 728c2ecf20Sopenharmony_ci u8 hblank_lo; 738c2ecf20Sopenharmony_ci u8 hactive_hblank_hi; 748c2ecf20Sopenharmony_ci u8 vactive_lo; 758c2ecf20Sopenharmony_ci u8 vblank_lo; 768c2ecf20Sopenharmony_ci u8 vactive_vblank_hi; 778c2ecf20Sopenharmony_ci u8 hsync_offset_lo; 788c2ecf20Sopenharmony_ci u8 hsync_pulse_width_lo; 798c2ecf20Sopenharmony_ci u8 vsync_offset_pulse_width_lo; 808c2ecf20Sopenharmony_ci u8 hsync_vsync_offset_pulse_width_hi; 818c2ecf20Sopenharmony_ci u8 width_mm_lo; 828c2ecf20Sopenharmony_ci u8 height_mm_lo; 838c2ecf20Sopenharmony_ci u8 width_height_mm_hi; 848c2ecf20Sopenharmony_ci u8 hborder; 858c2ecf20Sopenharmony_ci u8 vborder; 868c2ecf20Sopenharmony_ci u8 misc; 878c2ecf20Sopenharmony_ci} __attribute__((packed)); 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci/* If it's not pixel timing, it'll be one of the below */ 908c2ecf20Sopenharmony_cistruct detailed_data_string { 918c2ecf20Sopenharmony_ci u8 str[13]; 928c2ecf20Sopenharmony_ci} __attribute__((packed)); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG 0x00 958c2ecf20Sopenharmony_ci#define DRM_EDID_RANGE_LIMITS_ONLY_FLAG 0x01 968c2ecf20Sopenharmony_ci#define DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG 0x02 978c2ecf20Sopenharmony_ci#define DRM_EDID_CVT_SUPPORT_FLAG 0x04 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_cistruct detailed_data_monitor_range { 1008c2ecf20Sopenharmony_ci u8 min_vfreq; 1018c2ecf20Sopenharmony_ci u8 max_vfreq; 1028c2ecf20Sopenharmony_ci u8 min_hfreq_khz; 1038c2ecf20Sopenharmony_ci u8 max_hfreq_khz; 1048c2ecf20Sopenharmony_ci u8 pixel_clock_mhz; /* need to multiply by 10 */ 1058c2ecf20Sopenharmony_ci u8 flags; 1068c2ecf20Sopenharmony_ci union { 1078c2ecf20Sopenharmony_ci struct { 1088c2ecf20Sopenharmony_ci u8 reserved; 1098c2ecf20Sopenharmony_ci u8 hfreq_start_khz; /* need to multiply by 2 */ 1108c2ecf20Sopenharmony_ci u8 c; /* need to divide by 2 */ 1118c2ecf20Sopenharmony_ci __le16 m; 1128c2ecf20Sopenharmony_ci u8 k; 1138c2ecf20Sopenharmony_ci u8 j; /* need to divide by 2 */ 1148c2ecf20Sopenharmony_ci } __attribute__((packed)) gtf2; 1158c2ecf20Sopenharmony_ci struct { 1168c2ecf20Sopenharmony_ci u8 version; 1178c2ecf20Sopenharmony_ci u8 data1; /* high 6 bits: extra clock resolution */ 1188c2ecf20Sopenharmony_ci u8 data2; /* plus low 2 of above: max hactive */ 1198c2ecf20Sopenharmony_ci u8 supported_aspects; 1208c2ecf20Sopenharmony_ci u8 flags; /* preferred aspect and blanking support */ 1218c2ecf20Sopenharmony_ci u8 supported_scalings; 1228c2ecf20Sopenharmony_ci u8 preferred_refresh; 1238c2ecf20Sopenharmony_ci } __attribute__((packed)) cvt; 1248c2ecf20Sopenharmony_ci } __attribute__((packed)) formula; 1258c2ecf20Sopenharmony_ci} __attribute__((packed)); 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_cistruct detailed_data_wpindex { 1288c2ecf20Sopenharmony_ci u8 white_yx_lo; /* Lower 2 bits each */ 1298c2ecf20Sopenharmony_ci u8 white_x_hi; 1308c2ecf20Sopenharmony_ci u8 white_y_hi; 1318c2ecf20Sopenharmony_ci u8 gamma; /* need to divide by 100 then add 1 */ 1328c2ecf20Sopenharmony_ci} __attribute__((packed)); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_cistruct detailed_data_color_point { 1358c2ecf20Sopenharmony_ci u8 windex1; 1368c2ecf20Sopenharmony_ci u8 wpindex1[3]; 1378c2ecf20Sopenharmony_ci u8 windex2; 1388c2ecf20Sopenharmony_ci u8 wpindex2[3]; 1398c2ecf20Sopenharmony_ci} __attribute__((packed)); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_cistruct cvt_timing { 1428c2ecf20Sopenharmony_ci u8 code[3]; 1438c2ecf20Sopenharmony_ci} __attribute__((packed)); 1448c2ecf20Sopenharmony_ci 1458c2ecf20Sopenharmony_cistruct detailed_non_pixel { 1468c2ecf20Sopenharmony_ci u8 pad1; 1478c2ecf20Sopenharmony_ci u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name 1488c2ecf20Sopenharmony_ci fb=color point data, fa=standard timing data, 1498c2ecf20Sopenharmony_ci f9=undefined, f8=mfg. reserved */ 1508c2ecf20Sopenharmony_ci u8 pad2; 1518c2ecf20Sopenharmony_ci union { 1528c2ecf20Sopenharmony_ci struct detailed_data_string str; 1538c2ecf20Sopenharmony_ci struct detailed_data_monitor_range range; 1548c2ecf20Sopenharmony_ci struct detailed_data_wpindex color; 1558c2ecf20Sopenharmony_ci struct std_timing timings[6]; 1568c2ecf20Sopenharmony_ci struct cvt_timing cvt[4]; 1578c2ecf20Sopenharmony_ci } __attribute__((packed)) data; 1588c2ecf20Sopenharmony_ci} __attribute__((packed)); 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci#define EDID_DETAIL_EST_TIMINGS 0xf7 1618c2ecf20Sopenharmony_ci#define EDID_DETAIL_CVT_3BYTE 0xf8 1628c2ecf20Sopenharmony_ci#define EDID_DETAIL_COLOR_MGMT_DATA 0xf9 1638c2ecf20Sopenharmony_ci#define EDID_DETAIL_STD_MODES 0xfa 1648c2ecf20Sopenharmony_ci#define EDID_DETAIL_MONITOR_CPDATA 0xfb 1658c2ecf20Sopenharmony_ci#define EDID_DETAIL_MONITOR_NAME 0xfc 1668c2ecf20Sopenharmony_ci#define EDID_DETAIL_MONITOR_RANGE 0xfd 1678c2ecf20Sopenharmony_ci#define EDID_DETAIL_MONITOR_STRING 0xfe 1688c2ecf20Sopenharmony_ci#define EDID_DETAIL_MONITOR_SERIAL 0xff 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_cistruct detailed_timing { 1718c2ecf20Sopenharmony_ci __le16 pixel_clock; /* need to multiply by 10 KHz */ 1728c2ecf20Sopenharmony_ci union { 1738c2ecf20Sopenharmony_ci struct detailed_pixel_timing pixel_data; 1748c2ecf20Sopenharmony_ci struct detailed_non_pixel other_data; 1758c2ecf20Sopenharmony_ci } __attribute__((packed)) data; 1768c2ecf20Sopenharmony_ci} __attribute__((packed)); 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0) 1798c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_SYNC_ON_GREEN (1 << 1) 1808c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_COMPOSITE_SYNC (1 << 2) 1818c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_SEPARATE_SYNCS (1 << 3) 1828c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_BLANK_TO_BLACK (1 << 4) 1838c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_VIDEO_LEVEL (3 << 5) 1848c2ecf20Sopenharmony_ci#define DRM_EDID_INPUT_DIGITAL (1 << 7) 1858c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_MASK (7 << 4) /* 1.4 */ 1868c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_UNDEF (0 << 4) /* 1.4 */ 1878c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_6 (1 << 4) /* 1.4 */ 1888c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_8 (2 << 4) /* 1.4 */ 1898c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_10 (3 << 4) /* 1.4 */ 1908c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_12 (4 << 4) /* 1.4 */ 1918c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_14 (5 << 4) /* 1.4 */ 1928c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_16 (6 << 4) /* 1.4 */ 1938c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DEPTH_RSVD (7 << 4) /* 1.4 */ 1948c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_MASK (7 << 0) /* 1.4 */ 1958c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_UNDEF (0 << 0) /* 1.4 */ 1968c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_DVI (1 << 0) /* 1.4 */ 1978c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_HDMI_A (2 << 0) /* 1.4 */ 1988c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_HDMI_B (3 << 0) /* 1.4 */ 1998c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_MDDI (4 << 0) /* 1.4 */ 2008c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_TYPE_DP (5 << 0) /* 1.4 */ 2018c2ecf20Sopenharmony_ci#define DRM_EDID_DIGITAL_DFP_1_X (1 << 0) /* 1.3 */ 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_DEFAULT_GTF (1 << 0) 2048c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1) 2058c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_STANDARD_COLOR (1 << 2) 2068c2ecf20Sopenharmony_ci/* If analog */ 2078c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_DISPLAY_TYPE (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */ 2088c2ecf20Sopenharmony_ci/* If digital */ 2098c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_COLOR_MASK (3 << 3) 2108c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_RGB (0 << 3) 2118c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_RGB_YCRCB444 (1 << 3) 2128c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_RGB_YCRCB422 (2 << 3) 2138c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_RGB_YCRCB (3 << 3) /* both 4:4:4 and 4:2:2 */ 2148c2ecf20Sopenharmony_ci 2158c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_PM_ACTIVE_OFF (1 << 5) 2168c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_PM_SUSPEND (1 << 6) 2178c2ecf20Sopenharmony_ci#define DRM_EDID_FEATURE_PM_STANDBY (1 << 7) 2188c2ecf20Sopenharmony_ci 2198c2ecf20Sopenharmony_ci#define DRM_EDID_HDMI_DC_48 (1 << 6) 2208c2ecf20Sopenharmony_ci#define DRM_EDID_HDMI_DC_36 (1 << 5) 2218c2ecf20Sopenharmony_ci#define DRM_EDID_HDMI_DC_30 (1 << 4) 2228c2ecf20Sopenharmony_ci#define DRM_EDID_HDMI_DC_Y444 (1 << 3) 2238c2ecf20Sopenharmony_ci 2248c2ecf20Sopenharmony_ci/* YCBCR 420 deep color modes */ 2258c2ecf20Sopenharmony_ci#define DRM_EDID_YCBCR420_DC_48 (1 << 2) 2268c2ecf20Sopenharmony_ci#define DRM_EDID_YCBCR420_DC_36 (1 << 1) 2278c2ecf20Sopenharmony_ci#define DRM_EDID_YCBCR420_DC_30 (1 << 0) 2288c2ecf20Sopenharmony_ci#define DRM_EDID_YCBCR420_DC_MASK (DRM_EDID_YCBCR420_DC_48 | \ 2298c2ecf20Sopenharmony_ci DRM_EDID_YCBCR420_DC_36 | \ 2308c2ecf20Sopenharmony_ci DRM_EDID_YCBCR420_DC_30) 2318c2ecf20Sopenharmony_ci 2328c2ecf20Sopenharmony_ci/* ELD Header Block */ 2338c2ecf20Sopenharmony_ci#define DRM_ELD_HEADER_BLOCK_SIZE 4 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci#define DRM_ELD_VER 0 2368c2ecf20Sopenharmony_ci# define DRM_ELD_VER_SHIFT 3 2378c2ecf20Sopenharmony_ci# define DRM_ELD_VER_MASK (0x1f << 3) 2388c2ecf20Sopenharmony_ci# define DRM_ELD_VER_CEA861D (2 << 3) /* supports 861D or below */ 2398c2ecf20Sopenharmony_ci# define DRM_ELD_VER_CANNED (0x1f << 3) 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci#define DRM_ELD_BASELINE_ELD_LEN 2 /* in dwords! */ 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci/* ELD Baseline Block for ELD_Ver == 2 */ 2448c2ecf20Sopenharmony_ci#define DRM_ELD_CEA_EDID_VER_MNL 4 2458c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_SHIFT 5 2468c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_MASK (7 << 5) 2478c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_NONE (0 << 5) 2488c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_CEA861 (1 << 5) 2498c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_CEA861A (2 << 5) 2508c2ecf20Sopenharmony_ci# define DRM_ELD_CEA_EDID_VER_CEA861BCD (3 << 5) 2518c2ecf20Sopenharmony_ci# define DRM_ELD_MNL_SHIFT 0 2528c2ecf20Sopenharmony_ci# define DRM_ELD_MNL_MASK (0x1f << 0) 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci#define DRM_ELD_SAD_COUNT_CONN_TYPE 5 2558c2ecf20Sopenharmony_ci# define DRM_ELD_SAD_COUNT_SHIFT 4 2568c2ecf20Sopenharmony_ci# define DRM_ELD_SAD_COUNT_MASK (0xf << 4) 2578c2ecf20Sopenharmony_ci# define DRM_ELD_CONN_TYPE_SHIFT 2 2588c2ecf20Sopenharmony_ci# define DRM_ELD_CONN_TYPE_MASK (3 << 2) 2598c2ecf20Sopenharmony_ci# define DRM_ELD_CONN_TYPE_HDMI (0 << 2) 2608c2ecf20Sopenharmony_ci# define DRM_ELD_CONN_TYPE_DP (1 << 2) 2618c2ecf20Sopenharmony_ci# define DRM_ELD_SUPPORTS_AI (1 << 1) 2628c2ecf20Sopenharmony_ci# define DRM_ELD_SUPPORTS_HDCP (1 << 0) 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci#define DRM_ELD_AUD_SYNCH_DELAY 6 /* in units of 2 ms */ 2658c2ecf20Sopenharmony_ci# define DRM_ELD_AUD_SYNCH_DELAY_MAX 0xfa /* 500 ms */ 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci#define DRM_ELD_SPEAKER 7 2688c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_MASK 0x7f 2698c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_RLRC (1 << 6) 2708c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_FLRC (1 << 5) 2718c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_RC (1 << 4) 2728c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_RLR (1 << 3) 2738c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_FC (1 << 2) 2748c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_LFE (1 << 1) 2758c2ecf20Sopenharmony_ci# define DRM_ELD_SPEAKER_FLR (1 << 0) 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci#define DRM_ELD_PORT_ID 8 /* offsets 8..15 inclusive */ 2788c2ecf20Sopenharmony_ci# define DRM_ELD_PORT_ID_LEN 8 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci#define DRM_ELD_MANUFACTURER_NAME0 16 2818c2ecf20Sopenharmony_ci#define DRM_ELD_MANUFACTURER_NAME1 17 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define DRM_ELD_PRODUCT_CODE0 18 2848c2ecf20Sopenharmony_ci#define DRM_ELD_PRODUCT_CODE1 19 2858c2ecf20Sopenharmony_ci 2868c2ecf20Sopenharmony_ci#define DRM_ELD_MONITOR_NAME_STRING 20 /* offsets 20..(20+mnl-1) inclusive */ 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci#define DRM_ELD_CEA_SAD(mnl, sad) (20 + (mnl) + 3 * (sad)) 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_cistruct edid { 2918c2ecf20Sopenharmony_ci u8 header[8]; 2928c2ecf20Sopenharmony_ci /* Vendor & product info */ 2938c2ecf20Sopenharmony_ci u8 mfg_id[2]; 2948c2ecf20Sopenharmony_ci u8 prod_code[2]; 2958c2ecf20Sopenharmony_ci u32 serial; /* FIXME: byte order */ 2968c2ecf20Sopenharmony_ci u8 mfg_week; 2978c2ecf20Sopenharmony_ci u8 mfg_year; 2988c2ecf20Sopenharmony_ci /* EDID version */ 2998c2ecf20Sopenharmony_ci u8 version; 3008c2ecf20Sopenharmony_ci u8 revision; 3018c2ecf20Sopenharmony_ci /* Display info: */ 3028c2ecf20Sopenharmony_ci u8 input; 3038c2ecf20Sopenharmony_ci u8 width_cm; 3048c2ecf20Sopenharmony_ci u8 height_cm; 3058c2ecf20Sopenharmony_ci u8 gamma; 3068c2ecf20Sopenharmony_ci u8 features; 3078c2ecf20Sopenharmony_ci /* Color characteristics */ 3088c2ecf20Sopenharmony_ci u8 red_green_lo; 3098c2ecf20Sopenharmony_ci u8 black_white_lo; 3108c2ecf20Sopenharmony_ci u8 red_x; 3118c2ecf20Sopenharmony_ci u8 red_y; 3128c2ecf20Sopenharmony_ci u8 green_x; 3138c2ecf20Sopenharmony_ci u8 green_y; 3148c2ecf20Sopenharmony_ci u8 blue_x; 3158c2ecf20Sopenharmony_ci u8 blue_y; 3168c2ecf20Sopenharmony_ci u8 white_x; 3178c2ecf20Sopenharmony_ci u8 white_y; 3188c2ecf20Sopenharmony_ci /* Est. timings and mfg rsvd timings*/ 3198c2ecf20Sopenharmony_ci struct est_timings established_timings; 3208c2ecf20Sopenharmony_ci /* Standard timings 1-8*/ 3218c2ecf20Sopenharmony_ci struct std_timing standard_timings[8]; 3228c2ecf20Sopenharmony_ci /* Detailing timings 1-4 */ 3238c2ecf20Sopenharmony_ci struct detailed_timing detailed_timings[4]; 3248c2ecf20Sopenharmony_ci /* Number of 128 byte ext. blocks */ 3258c2ecf20Sopenharmony_ci u8 extensions; 3268c2ecf20Sopenharmony_ci /* Checksum */ 3278c2ecf20Sopenharmony_ci u8 checksum; 3288c2ecf20Sopenharmony_ci} __attribute__((packed)); 3298c2ecf20Sopenharmony_ci 3308c2ecf20Sopenharmony_ci#define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci/* Short Audio Descriptor */ 3338c2ecf20Sopenharmony_cistruct cea_sad { 3348c2ecf20Sopenharmony_ci u8 format; 3358c2ecf20Sopenharmony_ci u8 channels; /* max number of channels - 1 */ 3368c2ecf20Sopenharmony_ci u8 freq; 3378c2ecf20Sopenharmony_ci u8 byte2; /* meaning depends on format */ 3388c2ecf20Sopenharmony_ci}; 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_cistruct drm_encoder; 3418c2ecf20Sopenharmony_cistruct drm_connector; 3428c2ecf20Sopenharmony_cistruct drm_connector_state; 3438c2ecf20Sopenharmony_cistruct drm_display_mode; 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ciint drm_edid_to_sad(struct edid *edid, struct cea_sad **sads); 3468c2ecf20Sopenharmony_ciint drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb); 3478c2ecf20Sopenharmony_ciint drm_av_sync_delay(struct drm_connector *connector, 3488c2ecf20Sopenharmony_ci const struct drm_display_mode *mode); 3498c2ecf20Sopenharmony_ci 3508c2ecf20Sopenharmony_ci#ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE 3518c2ecf20Sopenharmony_cistruct edid *drm_load_edid_firmware(struct drm_connector *connector); 3528c2ecf20Sopenharmony_ciint __drm_set_edid_firmware_path(const char *path); 3538c2ecf20Sopenharmony_ciint __drm_get_edid_firmware_path(char *buf, size_t bufsize); 3548c2ecf20Sopenharmony_ci#else 3558c2ecf20Sopenharmony_cistatic inline struct edid * 3568c2ecf20Sopenharmony_cidrm_load_edid_firmware(struct drm_connector *connector) 3578c2ecf20Sopenharmony_ci{ 3588c2ecf20Sopenharmony_ci return ERR_PTR(-ENOENT); 3598c2ecf20Sopenharmony_ci} 3608c2ecf20Sopenharmony_ci#endif 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_cibool drm_edid_are_equal(const struct edid *edid1, const struct edid *edid2); 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ciint 3658c2ecf20Sopenharmony_cidrm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame, 3668c2ecf20Sopenharmony_ci const struct drm_connector *connector, 3678c2ecf20Sopenharmony_ci const struct drm_display_mode *mode); 3688c2ecf20Sopenharmony_ciint 3698c2ecf20Sopenharmony_cidrm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame, 3708c2ecf20Sopenharmony_ci const struct drm_connector *connector, 3718c2ecf20Sopenharmony_ci const struct drm_display_mode *mode); 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_civoid 3748c2ecf20Sopenharmony_cidrm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame, 3758c2ecf20Sopenharmony_ci const struct drm_connector_state *conn_state); 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_civoid 3788c2ecf20Sopenharmony_cidrm_hdmi_avi_infoframe_bars(struct hdmi_avi_infoframe *frame, 3798c2ecf20Sopenharmony_ci const struct drm_connector_state *conn_state); 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_civoid 3828c2ecf20Sopenharmony_cidrm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame, 3838c2ecf20Sopenharmony_ci const struct drm_connector *connector, 3848c2ecf20Sopenharmony_ci const struct drm_display_mode *mode, 3858c2ecf20Sopenharmony_ci enum hdmi_quantization_range rgb_quant_range); 3868c2ecf20Sopenharmony_ci 3878c2ecf20Sopenharmony_ciint 3888c2ecf20Sopenharmony_cidrm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame, 3898c2ecf20Sopenharmony_ci const struct drm_connector_state *conn_state); 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci/** 3928c2ecf20Sopenharmony_ci * drm_eld_mnl - Get ELD monitor name length in bytes. 3938c2ecf20Sopenharmony_ci * @eld: pointer to an eld memory structure with mnl set 3948c2ecf20Sopenharmony_ci */ 3958c2ecf20Sopenharmony_cistatic inline int drm_eld_mnl(const uint8_t *eld) 3968c2ecf20Sopenharmony_ci{ 3978c2ecf20Sopenharmony_ci return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT; 3988c2ecf20Sopenharmony_ci} 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci/** 4018c2ecf20Sopenharmony_ci * drm_eld_sad - Get ELD SAD structures. 4028c2ecf20Sopenharmony_ci * @eld: pointer to an eld memory structure with sad_count set 4038c2ecf20Sopenharmony_ci */ 4048c2ecf20Sopenharmony_cistatic inline const uint8_t *drm_eld_sad(const uint8_t *eld) 4058c2ecf20Sopenharmony_ci{ 4068c2ecf20Sopenharmony_ci unsigned int ver, mnl; 4078c2ecf20Sopenharmony_ci 4088c2ecf20Sopenharmony_ci ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT; 4098c2ecf20Sopenharmony_ci if (ver != 2 && ver != 31) 4108c2ecf20Sopenharmony_ci return NULL; 4118c2ecf20Sopenharmony_ci 4128c2ecf20Sopenharmony_ci mnl = drm_eld_mnl(eld); 4138c2ecf20Sopenharmony_ci if (mnl > 16) 4148c2ecf20Sopenharmony_ci return NULL; 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_ci return eld + DRM_ELD_CEA_SAD(mnl, 0); 4178c2ecf20Sopenharmony_ci} 4188c2ecf20Sopenharmony_ci 4198c2ecf20Sopenharmony_ci/** 4208c2ecf20Sopenharmony_ci * drm_eld_sad_count - Get ELD SAD count. 4218c2ecf20Sopenharmony_ci * @eld: pointer to an eld memory structure with sad_count set 4228c2ecf20Sopenharmony_ci */ 4238c2ecf20Sopenharmony_cistatic inline int drm_eld_sad_count(const uint8_t *eld) 4248c2ecf20Sopenharmony_ci{ 4258c2ecf20Sopenharmony_ci return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >> 4268c2ecf20Sopenharmony_ci DRM_ELD_SAD_COUNT_SHIFT; 4278c2ecf20Sopenharmony_ci} 4288c2ecf20Sopenharmony_ci 4298c2ecf20Sopenharmony_ci/** 4308c2ecf20Sopenharmony_ci * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes 4318c2ecf20Sopenharmony_ci * @eld: pointer to an eld memory structure with mnl and sad_count set 4328c2ecf20Sopenharmony_ci * 4338c2ecf20Sopenharmony_ci * This is a helper for determining the payload size of the baseline block, in 4348c2ecf20Sopenharmony_ci * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block. 4358c2ecf20Sopenharmony_ci */ 4368c2ecf20Sopenharmony_cistatic inline int drm_eld_calc_baseline_block_size(const uint8_t *eld) 4378c2ecf20Sopenharmony_ci{ 4388c2ecf20Sopenharmony_ci return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE + 4398c2ecf20Sopenharmony_ci drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3; 4408c2ecf20Sopenharmony_ci} 4418c2ecf20Sopenharmony_ci 4428c2ecf20Sopenharmony_ci/** 4438c2ecf20Sopenharmony_ci * drm_eld_size - Get ELD size in bytes 4448c2ecf20Sopenharmony_ci * @eld: pointer to a complete eld memory structure 4458c2ecf20Sopenharmony_ci * 4468c2ecf20Sopenharmony_ci * The returned value does not include the vendor block. It's vendor specific, 4478c2ecf20Sopenharmony_ci * and comprises of the remaining bytes in the ELD memory buffer after 4488c2ecf20Sopenharmony_ci * drm_eld_size() bytes of header and baseline block. 4498c2ecf20Sopenharmony_ci * 4508c2ecf20Sopenharmony_ci * The returned value is guaranteed to be a multiple of 4. 4518c2ecf20Sopenharmony_ci */ 4528c2ecf20Sopenharmony_cistatic inline int drm_eld_size(const uint8_t *eld) 4538c2ecf20Sopenharmony_ci{ 4548c2ecf20Sopenharmony_ci return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4; 4558c2ecf20Sopenharmony_ci} 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci/** 4588c2ecf20Sopenharmony_ci * drm_eld_get_spk_alloc - Get speaker allocation 4598c2ecf20Sopenharmony_ci * @eld: pointer to an ELD memory structure 4608c2ecf20Sopenharmony_ci * 4618c2ecf20Sopenharmony_ci * The returned value is the speakers mask. User has to use %DRM_ELD_SPEAKER 4628c2ecf20Sopenharmony_ci * field definitions to identify speakers. 4638c2ecf20Sopenharmony_ci */ 4648c2ecf20Sopenharmony_cistatic inline u8 drm_eld_get_spk_alloc(const uint8_t *eld) 4658c2ecf20Sopenharmony_ci{ 4668c2ecf20Sopenharmony_ci return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK; 4678c2ecf20Sopenharmony_ci} 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci/** 4708c2ecf20Sopenharmony_ci * drm_eld_get_conn_type - Get device type hdmi/dp connected 4718c2ecf20Sopenharmony_ci * @eld: pointer to an ELD memory structure 4728c2ecf20Sopenharmony_ci * 4738c2ecf20Sopenharmony_ci * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or %DRM_ELD_CONN_TYPE_DP to 4748c2ecf20Sopenharmony_ci * identify the display type connected. 4758c2ecf20Sopenharmony_ci */ 4768c2ecf20Sopenharmony_cistatic inline u8 drm_eld_get_conn_type(const uint8_t *eld) 4778c2ecf20Sopenharmony_ci{ 4788c2ecf20Sopenharmony_ci return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK; 4798c2ecf20Sopenharmony_ci} 4808c2ecf20Sopenharmony_ci 4818c2ecf20Sopenharmony_cibool drm_probe_ddc(struct i2c_adapter *adapter); 4828c2ecf20Sopenharmony_cistruct edid *drm_do_get_edid(struct drm_connector *connector, 4838c2ecf20Sopenharmony_ci int (*get_edid_block)(void *data, u8 *buf, unsigned int block, 4848c2ecf20Sopenharmony_ci size_t len), 4858c2ecf20Sopenharmony_ci void *data); 4868c2ecf20Sopenharmony_cistruct edid *drm_get_edid(struct drm_connector *connector, 4878c2ecf20Sopenharmony_ci struct i2c_adapter *adapter); 4888c2ecf20Sopenharmony_cistruct edid *drm_get_edid_switcheroo(struct drm_connector *connector, 4898c2ecf20Sopenharmony_ci struct i2c_adapter *adapter); 4908c2ecf20Sopenharmony_cistruct edid *drm_edid_duplicate(const struct edid *edid); 4918c2ecf20Sopenharmony_ciint drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); 4928c2ecf20Sopenharmony_ciint drm_add_override_edid_modes(struct drm_connector *connector); 4938c2ecf20Sopenharmony_ci 4948c2ecf20Sopenharmony_ciu8 drm_match_cea_mode(const struct drm_display_mode *to_match); 4958c2ecf20Sopenharmony_cibool drm_detect_hdmi_monitor(struct edid *edid); 4968c2ecf20Sopenharmony_cibool drm_detect_monitor_audio(struct edid *edid); 4978c2ecf20Sopenharmony_cienum hdmi_quantization_range 4988c2ecf20Sopenharmony_cidrm_default_rgb_quant_range(const struct drm_display_mode *mode); 4998c2ecf20Sopenharmony_ciint drm_add_modes_noedid(struct drm_connector *connector, 5008c2ecf20Sopenharmony_ci int hdisplay, int vdisplay); 5018c2ecf20Sopenharmony_civoid drm_set_preferred_mode(struct drm_connector *connector, 5028c2ecf20Sopenharmony_ci int hpref, int vpref); 5038c2ecf20Sopenharmony_ci 5048c2ecf20Sopenharmony_ciint drm_edid_header_is_valid(const u8 *raw_edid); 5058c2ecf20Sopenharmony_cibool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, 5068c2ecf20Sopenharmony_ci bool *edid_corrupt); 5078c2ecf20Sopenharmony_cibool drm_edid_is_valid(struct edid *edid); 5088c2ecf20Sopenharmony_civoid drm_edid_get_monitor_name(struct edid *edid, char *name, 5098c2ecf20Sopenharmony_ci int buflen); 5108c2ecf20Sopenharmony_cistruct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, 5118c2ecf20Sopenharmony_ci int hsize, int vsize, int fresh, 5128c2ecf20Sopenharmony_ci bool rb); 5138c2ecf20Sopenharmony_cistruct drm_display_mode * 5148c2ecf20Sopenharmony_cidrm_display_mode_from_cea_vic(struct drm_device *dev, 5158c2ecf20Sopenharmony_ci u8 video_code); 5168c2ecf20Sopenharmony_ci 5178c2ecf20Sopenharmony_ci#endif /* __DRM_EDID_H__ */ 518