Home | History | Annotate | Line # | Download | only in drm
      1  1.4  riastrad /*	$NetBSD: drm_edid.h,v 1.4 2021/12/19 00:46:15 riastradh Exp $	*/
      2  1.2  riastrad 
      3  1.1  riastrad /*
      4  1.1  riastrad  * Copyright  2007-2008 Intel Corporation
      5  1.1  riastrad  *   Jesse Barnes <jesse.barnes (at) intel.com>
      6  1.1  riastrad  *
      7  1.1  riastrad  * Permission is hereby granted, free of charge, to any person obtaining a
      8  1.1  riastrad  * copy of this software and associated documentation files (the "Software"),
      9  1.1  riastrad  * to deal in the Software without restriction, including without limitation
     10  1.1  riastrad  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
     11  1.1  riastrad  * and/or sell copies of the Software, and to permit persons to whom the
     12  1.1  riastrad  * Software is furnished to do so, subject to the following conditions:
     13  1.1  riastrad  *
     14  1.1  riastrad  * The above copyright notice and this permission notice shall be included in
     15  1.1  riastrad  * all copies or substantial portions of the Software.
     16  1.1  riastrad  *
     17  1.1  riastrad  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     18  1.1  riastrad  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     19  1.1  riastrad  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     20  1.1  riastrad  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
     21  1.1  riastrad  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
     22  1.1  riastrad  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
     23  1.1  riastrad  * OTHER DEALINGS IN THE SOFTWARE.
     24  1.1  riastrad  */
     25  1.1  riastrad #ifndef __DRM_EDID_H__
     26  1.1  riastrad #define __DRM_EDID_H__
     27  1.1  riastrad 
     28  1.1  riastrad #include <linux/types.h>
     29  1.3  riastrad #include <linux/hdmi.h>
     30  1.3  riastrad #include <drm/drm_mode.h>
     31  1.3  riastrad 
     32  1.3  riastrad struct drm_device;
     33  1.3  riastrad struct i2c_adapter;
     34  1.1  riastrad 
     35  1.1  riastrad #define EDID_LENGTH 128
     36  1.1  riastrad #define DDC_ADDR 0x50
     37  1.2  riastrad #define DDC_ADDR2 0x52 /* E-DDC 1.2 - where DisplayID can hide */
     38  1.1  riastrad 
     39  1.1  riastrad #define CEA_EXT	    0x02
     40  1.1  riastrad #define VTB_EXT	    0x10
     41  1.1  riastrad #define DI_EXT	    0x40
     42  1.1  riastrad #define LS_EXT	    0x50
     43  1.1  riastrad #define MI_EXT	    0x60
     44  1.2  riastrad #define DISPLAYID_EXT 0x70
     45  1.1  riastrad 
     46  1.1  riastrad struct est_timings {
     47  1.1  riastrad 	u8 t1;
     48  1.1  riastrad 	u8 t2;
     49  1.1  riastrad 	u8 mfg_rsvd;
     50  1.1  riastrad } __attribute__((packed));
     51  1.1  riastrad 
     52  1.1  riastrad /* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
     53  1.1  riastrad #define EDID_TIMING_ASPECT_SHIFT 6
     54  1.1  riastrad #define EDID_TIMING_ASPECT_MASK  (0x3 << EDID_TIMING_ASPECT_SHIFT)
     55  1.1  riastrad 
     56  1.1  riastrad /* need to add 60 */
     57  1.1  riastrad #define EDID_TIMING_VFREQ_SHIFT  0
     58  1.1  riastrad #define EDID_TIMING_VFREQ_MASK   (0x3f << EDID_TIMING_VFREQ_SHIFT)
     59  1.1  riastrad 
     60  1.1  riastrad struct std_timing {
     61  1.1  riastrad 	u8 hsize; /* need to multiply by 8 then add 248 */
     62  1.1  riastrad 	u8 vfreq_aspect;
     63  1.1  riastrad } __attribute__((packed));
     64  1.1  riastrad 
     65  1.1  riastrad #define DRM_EDID_PT_HSYNC_POSITIVE (1 << 1)
     66  1.1  riastrad #define DRM_EDID_PT_VSYNC_POSITIVE (1 << 2)
     67  1.1  riastrad #define DRM_EDID_PT_SEPARATE_SYNC  (3 << 3)
     68  1.1  riastrad #define DRM_EDID_PT_STEREO         (1 << 5)
     69  1.1  riastrad #define DRM_EDID_PT_INTERLACED     (1 << 7)
     70  1.1  riastrad 
     71  1.1  riastrad /* If detailed data is pixel timing */
     72  1.1  riastrad struct detailed_pixel_timing {
     73  1.1  riastrad 	u8 hactive_lo;
     74  1.1  riastrad 	u8 hblank_lo;
     75  1.1  riastrad 	u8 hactive_hblank_hi;
     76  1.1  riastrad 	u8 vactive_lo;
     77  1.1  riastrad 	u8 vblank_lo;
     78  1.1  riastrad 	u8 vactive_vblank_hi;
     79  1.1  riastrad 	u8 hsync_offset_lo;
     80  1.1  riastrad 	u8 hsync_pulse_width_lo;
     81  1.1  riastrad 	u8 vsync_offset_pulse_width_lo;
     82  1.1  riastrad 	u8 hsync_vsync_offset_pulse_width_hi;
     83  1.1  riastrad 	u8 width_mm_lo;
     84  1.1  riastrad 	u8 height_mm_lo;
     85  1.1  riastrad 	u8 width_height_mm_hi;
     86  1.1  riastrad 	u8 hborder;
     87  1.1  riastrad 	u8 vborder;
     88  1.1  riastrad 	u8 misc;
     89  1.1  riastrad } __attribute__((packed));
     90  1.1  riastrad 
     91  1.1  riastrad /* If it's not pixel timing, it'll be one of the below */
     92  1.1  riastrad struct detailed_data_string {
     93  1.1  riastrad 	u8 str[13];
     94  1.1  riastrad } __attribute__((packed));
     95  1.1  riastrad 
     96  1.1  riastrad struct detailed_data_monitor_range {
     97  1.1  riastrad 	u8 min_vfreq;
     98  1.1  riastrad 	u8 max_vfreq;
     99  1.1  riastrad 	u8 min_hfreq_khz;
    100  1.1  riastrad 	u8 max_hfreq_khz;
    101  1.1  riastrad 	u8 pixel_clock_mhz; /* need to multiply by 10 */
    102  1.1  riastrad 	u8 flags;
    103  1.1  riastrad 	union {
    104  1.1  riastrad 		struct {
    105  1.1  riastrad 			u8 reserved;
    106  1.1  riastrad 			u8 hfreq_start_khz; /* need to multiply by 2 */
    107  1.1  riastrad 			u8 c; /* need to divide by 2 */
    108  1.1  riastrad 			__le16 m;
    109  1.1  riastrad 			u8 k;
    110  1.1  riastrad 			u8 j; /* need to divide by 2 */
    111  1.1  riastrad 		} __attribute__((packed)) gtf2;
    112  1.1  riastrad 		struct {
    113  1.1  riastrad 			u8 version;
    114  1.1  riastrad 			u8 data1; /* high 6 bits: extra clock resolution */
    115  1.1  riastrad 			u8 data2; /* plus low 2 of above: max hactive */
    116  1.1  riastrad 			u8 supported_aspects;
    117  1.1  riastrad 			u8 flags; /* preferred aspect and blanking support */
    118  1.1  riastrad 			u8 supported_scalings;
    119  1.1  riastrad 			u8 preferred_refresh;
    120  1.1  riastrad 		} __attribute__((packed)) cvt;
    121  1.1  riastrad 	} formula;
    122  1.1  riastrad } __attribute__((packed));
    123  1.1  riastrad 
    124  1.1  riastrad struct detailed_data_wpindex {
    125  1.1  riastrad 	u8 white_yx_lo; /* Lower 2 bits each */
    126  1.1  riastrad 	u8 white_x_hi;
    127  1.1  riastrad 	u8 white_y_hi;
    128  1.1  riastrad 	u8 gamma; /* need to divide by 100 then add 1 */
    129  1.1  riastrad } __attribute__((packed));
    130  1.1  riastrad 
    131  1.1  riastrad struct detailed_data_color_point {
    132  1.1  riastrad 	u8 windex1;
    133  1.1  riastrad 	u8 wpindex1[3];
    134  1.1  riastrad 	u8 windex2;
    135  1.1  riastrad 	u8 wpindex2[3];
    136  1.1  riastrad } __attribute__((packed));
    137  1.1  riastrad 
    138  1.1  riastrad struct cvt_timing {
    139  1.1  riastrad 	u8 code[3];
    140  1.1  riastrad } __attribute__((packed));
    141  1.1  riastrad 
    142  1.1  riastrad struct detailed_non_pixel {
    143  1.1  riastrad 	u8 pad1;
    144  1.1  riastrad 	u8 type; /* ff=serial, fe=string, fd=monitor range, fc=monitor name
    145  1.1  riastrad 		    fb=color point data, fa=standard timing data,
    146  1.1  riastrad 		    f9=undefined, f8=mfg. reserved */
    147  1.1  riastrad 	u8 pad2;
    148  1.1  riastrad 	union {
    149  1.1  riastrad 		struct detailed_data_string str;
    150  1.1  riastrad 		struct detailed_data_monitor_range range;
    151  1.1  riastrad 		struct detailed_data_wpindex color;
    152  1.1  riastrad 		struct std_timing timings[6];
    153  1.1  riastrad 		struct cvt_timing cvt[4];
    154  1.1  riastrad 	} data;
    155  1.1  riastrad } __attribute__((packed));
    156  1.1  riastrad 
    157  1.1  riastrad #define EDID_DETAIL_EST_TIMINGS 0xf7
    158  1.1  riastrad #define EDID_DETAIL_CVT_3BYTE 0xf8
    159  1.1  riastrad #define EDID_DETAIL_COLOR_MGMT_DATA 0xf9
    160  1.1  riastrad #define EDID_DETAIL_STD_MODES 0xfa
    161  1.1  riastrad #define EDID_DETAIL_MONITOR_CPDATA 0xfb
    162  1.1  riastrad #define EDID_DETAIL_MONITOR_NAME 0xfc
    163  1.1  riastrad #define EDID_DETAIL_MONITOR_RANGE 0xfd
    164  1.1  riastrad #define EDID_DETAIL_MONITOR_STRING 0xfe
    165  1.1  riastrad #define EDID_DETAIL_MONITOR_SERIAL 0xff
    166  1.1  riastrad 
    167  1.1  riastrad struct detailed_timing {
    168  1.1  riastrad 	__le16 pixel_clock; /* need to multiply by 10 KHz */
    169  1.1  riastrad 	union {
    170  1.1  riastrad 		struct detailed_pixel_timing pixel_data;
    171  1.1  riastrad 		struct detailed_non_pixel other_data;
    172  1.1  riastrad 	} data;
    173  1.1  riastrad } __attribute__((packed));
    174  1.1  riastrad 
    175  1.1  riastrad #define DRM_EDID_INPUT_SERRATION_VSYNC (1 << 0)
    176  1.1  riastrad #define DRM_EDID_INPUT_SYNC_ON_GREEN   (1 << 1)
    177  1.1  riastrad #define DRM_EDID_INPUT_COMPOSITE_SYNC  (1 << 2)
    178  1.1  riastrad #define DRM_EDID_INPUT_SEPARATE_SYNCS  (1 << 3)
    179  1.1  riastrad #define DRM_EDID_INPUT_BLANK_TO_BLACK  (1 << 4)
    180  1.1  riastrad #define DRM_EDID_INPUT_VIDEO_LEVEL     (3 << 5)
    181  1.1  riastrad #define DRM_EDID_INPUT_DIGITAL         (1 << 7)
    182  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_MASK    (7 << 4) /* 1.4 */
    183  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_UNDEF   (0 << 4) /* 1.4 */
    184  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_6       (1 << 4) /* 1.4 */
    185  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_8       (2 << 4) /* 1.4 */
    186  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_10      (3 << 4) /* 1.4 */
    187  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_12      (4 << 4) /* 1.4 */
    188  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_14      (5 << 4) /* 1.4 */
    189  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_16      (6 << 4) /* 1.4 */
    190  1.3  riastrad #define DRM_EDID_DIGITAL_DEPTH_RSVD    (7 << 4) /* 1.4 */
    191  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_MASK     (7 << 0) /* 1.4 */
    192  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_UNDEF    (0 << 0) /* 1.4 */
    193  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_DVI      (1 << 0) /* 1.4 */
    194  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_HDMI_A   (2 << 0) /* 1.4 */
    195  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_HDMI_B   (3 << 0) /* 1.4 */
    196  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_MDDI     (4 << 0) /* 1.4 */
    197  1.3  riastrad #define DRM_EDID_DIGITAL_TYPE_DP       (5 << 0) /* 1.4 */
    198  1.3  riastrad #define DRM_EDID_DIGITAL_DFP_1_X       (1 << 0) /* 1.3 */
    199  1.1  riastrad 
    200  1.1  riastrad #define DRM_EDID_FEATURE_DEFAULT_GTF      (1 << 0)
    201  1.1  riastrad #define DRM_EDID_FEATURE_PREFERRED_TIMING (1 << 1)
    202  1.1  riastrad #define DRM_EDID_FEATURE_STANDARD_COLOR   (1 << 2)
    203  1.1  riastrad /* If analog */
    204  1.1  riastrad #define DRM_EDID_FEATURE_DISPLAY_TYPE     (3 << 3) /* 00=mono, 01=rgb, 10=non-rgb, 11=unknown */
    205  1.1  riastrad /* If digital */
    206  1.1  riastrad #define DRM_EDID_FEATURE_COLOR_MASK	  (3 << 3)
    207  1.1  riastrad #define DRM_EDID_FEATURE_RGB		  (0 << 3)
    208  1.1  riastrad #define DRM_EDID_FEATURE_RGB_YCRCB444	  (1 << 3)
    209  1.1  riastrad #define DRM_EDID_FEATURE_RGB_YCRCB422	  (2 << 3)
    210  1.1  riastrad #define DRM_EDID_FEATURE_RGB_YCRCB	  (3 << 3) /* both 4:4:4 and 4:2:2 */
    211  1.1  riastrad 
    212  1.1  riastrad #define DRM_EDID_FEATURE_PM_ACTIVE_OFF    (1 << 5)
    213  1.1  riastrad #define DRM_EDID_FEATURE_PM_SUSPEND       (1 << 6)
    214  1.1  riastrad #define DRM_EDID_FEATURE_PM_STANDBY       (1 << 7)
    215  1.1  riastrad 
    216  1.2  riastrad #define DRM_EDID_HDMI_DC_48               (1 << 6)
    217  1.2  riastrad #define DRM_EDID_HDMI_DC_36               (1 << 5)
    218  1.2  riastrad #define DRM_EDID_HDMI_DC_30               (1 << 4)
    219  1.2  riastrad #define DRM_EDID_HDMI_DC_Y444             (1 << 3)
    220  1.2  riastrad 
    221  1.3  riastrad /* YCBCR 420 deep color modes */
    222  1.3  riastrad #define DRM_EDID_YCBCR420_DC_48		  (1 << 2)
    223  1.3  riastrad #define DRM_EDID_YCBCR420_DC_36		  (1 << 1)
    224  1.3  riastrad #define DRM_EDID_YCBCR420_DC_30		  (1 << 0)
    225  1.3  riastrad #define DRM_EDID_YCBCR420_DC_MASK (DRM_EDID_YCBCR420_DC_48 | \
    226  1.3  riastrad 				    DRM_EDID_YCBCR420_DC_36 | \
    227  1.3  riastrad 				    DRM_EDID_YCBCR420_DC_30)
    228  1.3  riastrad 
    229  1.2  riastrad /* ELD Header Block */
    230  1.2  riastrad #define DRM_ELD_HEADER_BLOCK_SIZE	4
    231  1.2  riastrad 
    232  1.2  riastrad #define DRM_ELD_VER			0
    233  1.2  riastrad # define DRM_ELD_VER_SHIFT		3
    234  1.2  riastrad # define DRM_ELD_VER_MASK		(0x1f << 3)
    235  1.2  riastrad # define DRM_ELD_VER_CEA861D		(2 << 3) /* supports 861D or below */
    236  1.2  riastrad # define DRM_ELD_VER_CANNED		(0x1f << 3)
    237  1.2  riastrad 
    238  1.2  riastrad #define DRM_ELD_BASELINE_ELD_LEN	2	/* in dwords! */
    239  1.2  riastrad 
    240  1.2  riastrad /* ELD Baseline Block for ELD_Ver == 2 */
    241  1.2  riastrad #define DRM_ELD_CEA_EDID_VER_MNL	4
    242  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_SHIFT	5
    243  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_MASK	(7 << 5)
    244  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_NONE	(0 << 5)
    245  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_CEA861	(1 << 5)
    246  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_CEA861A	(2 << 5)
    247  1.2  riastrad # define DRM_ELD_CEA_EDID_VER_CEA861BCD	(3 << 5)
    248  1.2  riastrad # define DRM_ELD_MNL_SHIFT		0
    249  1.2  riastrad # define DRM_ELD_MNL_MASK		(0x1f << 0)
    250  1.2  riastrad 
    251  1.2  riastrad #define DRM_ELD_SAD_COUNT_CONN_TYPE	5
    252  1.2  riastrad # define DRM_ELD_SAD_COUNT_SHIFT	4
    253  1.2  riastrad # define DRM_ELD_SAD_COUNT_MASK		(0xf << 4)
    254  1.2  riastrad # define DRM_ELD_CONN_TYPE_SHIFT	2
    255  1.2  riastrad # define DRM_ELD_CONN_TYPE_MASK		(3 << 2)
    256  1.2  riastrad # define DRM_ELD_CONN_TYPE_HDMI		(0 << 2)
    257  1.2  riastrad # define DRM_ELD_CONN_TYPE_DP		(1 << 2)
    258  1.2  riastrad # define DRM_ELD_SUPPORTS_AI		(1 << 1)
    259  1.2  riastrad # define DRM_ELD_SUPPORTS_HDCP		(1 << 0)
    260  1.2  riastrad 
    261  1.2  riastrad #define DRM_ELD_AUD_SYNCH_DELAY		6	/* in units of 2 ms */
    262  1.2  riastrad # define DRM_ELD_AUD_SYNCH_DELAY_MAX	0xfa	/* 500 ms */
    263  1.2  riastrad 
    264  1.2  riastrad #define DRM_ELD_SPEAKER			7
    265  1.3  riastrad # define DRM_ELD_SPEAKER_MASK		0x7f
    266  1.2  riastrad # define DRM_ELD_SPEAKER_RLRC		(1 << 6)
    267  1.2  riastrad # define DRM_ELD_SPEAKER_FLRC		(1 << 5)
    268  1.2  riastrad # define DRM_ELD_SPEAKER_RC		(1 << 4)
    269  1.2  riastrad # define DRM_ELD_SPEAKER_RLR		(1 << 3)
    270  1.2  riastrad # define DRM_ELD_SPEAKER_FC		(1 << 2)
    271  1.2  riastrad # define DRM_ELD_SPEAKER_LFE		(1 << 1)
    272  1.2  riastrad # define DRM_ELD_SPEAKER_FLR		(1 << 0)
    273  1.2  riastrad 
    274  1.2  riastrad #define DRM_ELD_PORT_ID			8	/* offsets 8..15 inclusive */
    275  1.2  riastrad # define DRM_ELD_PORT_ID_LEN		8
    276  1.2  riastrad 
    277  1.2  riastrad #define DRM_ELD_MANUFACTURER_NAME0	16
    278  1.2  riastrad #define DRM_ELD_MANUFACTURER_NAME1	17
    279  1.2  riastrad 
    280  1.2  riastrad #define DRM_ELD_PRODUCT_CODE0		18
    281  1.2  riastrad #define DRM_ELD_PRODUCT_CODE1		19
    282  1.2  riastrad 
    283  1.2  riastrad #define DRM_ELD_MONITOR_NAME_STRING	20	/* offsets 20..(20+mnl-1) inclusive */
    284  1.2  riastrad 
    285  1.2  riastrad #define DRM_ELD_CEA_SAD(mnl, sad)	(20 + (mnl) + 3 * (sad))
    286  1.2  riastrad 
    287  1.1  riastrad struct edid {
    288  1.1  riastrad 	u8 header[8];
    289  1.1  riastrad 	/* Vendor & product info */
    290  1.1  riastrad 	u8 mfg_id[2];
    291  1.1  riastrad 	u8 prod_code[2];
    292  1.1  riastrad 	u32 serial; /* FIXME: byte order */
    293  1.1  riastrad 	u8 mfg_week;
    294  1.1  riastrad 	u8 mfg_year;
    295  1.1  riastrad 	/* EDID version */
    296  1.1  riastrad 	u8 version;
    297  1.1  riastrad 	u8 revision;
    298  1.1  riastrad 	/* Display info: */
    299  1.1  riastrad 	u8 input;
    300  1.1  riastrad 	u8 width_cm;
    301  1.1  riastrad 	u8 height_cm;
    302  1.1  riastrad 	u8 gamma;
    303  1.1  riastrad 	u8 features;
    304  1.1  riastrad 	/* Color characteristics */
    305  1.1  riastrad 	u8 red_green_lo;
    306  1.1  riastrad 	u8 black_white_lo;
    307  1.1  riastrad 	u8 red_x;
    308  1.1  riastrad 	u8 red_y;
    309  1.1  riastrad 	u8 green_x;
    310  1.1  riastrad 	u8 green_y;
    311  1.1  riastrad 	u8 blue_x;
    312  1.1  riastrad 	u8 blue_y;
    313  1.1  riastrad 	u8 white_x;
    314  1.1  riastrad 	u8 white_y;
    315  1.1  riastrad 	/* Est. timings and mfg rsvd timings*/
    316  1.1  riastrad 	struct est_timings established_timings;
    317  1.1  riastrad 	/* Standard timings 1-8*/
    318  1.1  riastrad 	struct std_timing standard_timings[8];
    319  1.1  riastrad 	/* Detailing timings 1-4 */
    320  1.1  riastrad 	struct detailed_timing detailed_timings[4];
    321  1.1  riastrad 	/* Number of 128 byte ext. blocks */
    322  1.1  riastrad 	u8 extensions;
    323  1.1  riastrad 	/* Checksum */
    324  1.1  riastrad 	u8 checksum;
    325  1.1  riastrad } __attribute__((packed));
    326  1.1  riastrad 
    327  1.1  riastrad #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8))
    328  1.1  riastrad 
    329  1.2  riastrad /* Short Audio Descriptor */
    330  1.2  riastrad struct cea_sad {
    331  1.2  riastrad 	u8 format;
    332  1.2  riastrad 	u8 channels; /* max number of channels - 1 */
    333  1.2  riastrad 	u8 freq;
    334  1.2  riastrad 	u8 byte2; /* meaning depends on format */
    335  1.2  riastrad };
    336  1.2  riastrad 
    337  1.1  riastrad struct drm_encoder;
    338  1.1  riastrad struct drm_connector;
    339  1.3  riastrad struct drm_connector_state;
    340  1.1  riastrad struct drm_display_mode;
    341  1.2  riastrad 
    342  1.2  riastrad int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads);
    343  1.2  riastrad int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb);
    344  1.1  riastrad int drm_av_sync_delay(struct drm_connector *connector,
    345  1.2  riastrad 		      const struct drm_display_mode *mode);
    346  1.3  riastrad 
    347  1.3  riastrad #ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE
    348  1.3  riastrad struct edid *drm_load_edid_firmware(struct drm_connector *connector);
    349  1.3  riastrad int __drm_set_edid_firmware_path(const char *path);
    350  1.3  riastrad int __drm_get_edid_firmware_path(char *buf, size_t bufsize);
    351  1.3  riastrad #else
    352  1.4  riastrad #include <linux/err.h>
    353  1.3  riastrad static inline struct edid *
    354  1.3  riastrad drm_load_edid_firmware(struct drm_connector *connector)
    355  1.3  riastrad {
    356  1.3  riastrad 	return ERR_PTR(-ENOENT);
    357  1.3  riastrad }
    358  1.3  riastrad #endif
    359  1.1  riastrad 
    360  1.2  riastrad int
    361  1.2  riastrad drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
    362  1.3  riastrad 					 struct drm_connector *connector,
    363  1.2  riastrad 					 const struct drm_display_mode *mode);
    364  1.2  riastrad int
    365  1.2  riastrad drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
    366  1.3  riastrad 					    struct drm_connector *connector,
    367  1.2  riastrad 					    const struct drm_display_mode *mode);
    368  1.2  riastrad 
    369  1.3  riastrad void
    370  1.3  riastrad drm_hdmi_avi_infoframe_colorspace(struct hdmi_avi_infoframe *frame,
    371  1.3  riastrad 				  const struct drm_connector_state *conn_state);
    372  1.3  riastrad 
    373  1.3  riastrad void
    374  1.3  riastrad drm_hdmi_avi_infoframe_bars(struct hdmi_avi_infoframe *frame,
    375  1.3  riastrad 			    const struct drm_connector_state *conn_state);
    376  1.3  riastrad 
    377  1.3  riastrad void
    378  1.3  riastrad drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
    379  1.3  riastrad 				   struct drm_connector *connector,
    380  1.3  riastrad 				   const struct drm_display_mode *mode,
    381  1.3  riastrad 				   enum hdmi_quantization_range rgb_quant_range);
    382  1.3  riastrad 
    383  1.3  riastrad int
    384  1.3  riastrad drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
    385  1.3  riastrad 				    const struct drm_connector_state *conn_state);
    386  1.3  riastrad 
    387  1.2  riastrad /**
    388  1.2  riastrad  * drm_eld_mnl - Get ELD monitor name length in bytes.
    389  1.2  riastrad  * @eld: pointer to an eld memory structure with mnl set
    390  1.2  riastrad  */
    391  1.2  riastrad static inline int drm_eld_mnl(const uint8_t *eld)
    392  1.2  riastrad {
    393  1.2  riastrad 	return (eld[DRM_ELD_CEA_EDID_VER_MNL] & DRM_ELD_MNL_MASK) >> DRM_ELD_MNL_SHIFT;
    394  1.2  riastrad }
    395  1.2  riastrad 
    396  1.2  riastrad /**
    397  1.2  riastrad  * drm_eld_sad - Get ELD SAD structures.
    398  1.2  riastrad  * @eld: pointer to an eld memory structure with sad_count set
    399  1.2  riastrad  */
    400  1.2  riastrad static inline const uint8_t *drm_eld_sad(const uint8_t *eld)
    401  1.2  riastrad {
    402  1.2  riastrad 	unsigned int ver, mnl;
    403  1.2  riastrad 
    404  1.2  riastrad 	ver = (eld[DRM_ELD_VER] & DRM_ELD_VER_MASK) >> DRM_ELD_VER_SHIFT;
    405  1.2  riastrad 	if (ver != 2 && ver != 31)
    406  1.2  riastrad 		return NULL;
    407  1.2  riastrad 
    408  1.2  riastrad 	mnl = drm_eld_mnl(eld);
    409  1.2  riastrad 	if (mnl > 16)
    410  1.2  riastrad 		return NULL;
    411  1.2  riastrad 
    412  1.2  riastrad 	return eld + DRM_ELD_CEA_SAD(mnl, 0);
    413  1.2  riastrad }
    414  1.2  riastrad 
    415  1.2  riastrad /**
    416  1.2  riastrad  * drm_eld_sad_count - Get ELD SAD count.
    417  1.2  riastrad  * @eld: pointer to an eld memory structure with sad_count set
    418  1.2  riastrad  */
    419  1.2  riastrad static inline int drm_eld_sad_count(const uint8_t *eld)
    420  1.2  riastrad {
    421  1.2  riastrad 	return (eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_SAD_COUNT_MASK) >>
    422  1.2  riastrad 		DRM_ELD_SAD_COUNT_SHIFT;
    423  1.2  riastrad }
    424  1.2  riastrad 
    425  1.2  riastrad /**
    426  1.2  riastrad  * drm_eld_calc_baseline_block_size - Calculate baseline block size in bytes
    427  1.2  riastrad  * @eld: pointer to an eld memory structure with mnl and sad_count set
    428  1.2  riastrad  *
    429  1.2  riastrad  * This is a helper for determining the payload size of the baseline block, in
    430  1.2  riastrad  * bytes, for e.g. setting the Baseline_ELD_Len field in the ELD header block.
    431  1.2  riastrad  */
    432  1.2  riastrad static inline int drm_eld_calc_baseline_block_size(const uint8_t *eld)
    433  1.2  riastrad {
    434  1.2  riastrad 	return DRM_ELD_MONITOR_NAME_STRING - DRM_ELD_HEADER_BLOCK_SIZE +
    435  1.2  riastrad 		drm_eld_mnl(eld) + drm_eld_sad_count(eld) * 3;
    436  1.2  riastrad }
    437  1.2  riastrad 
    438  1.2  riastrad /**
    439  1.2  riastrad  * drm_eld_size - Get ELD size in bytes
    440  1.2  riastrad  * @eld: pointer to a complete eld memory structure
    441  1.2  riastrad  *
    442  1.2  riastrad  * The returned value does not include the vendor block. It's vendor specific,
    443  1.2  riastrad  * and comprises of the remaining bytes in the ELD memory buffer after
    444  1.2  riastrad  * drm_eld_size() bytes of header and baseline block.
    445  1.2  riastrad  *
    446  1.2  riastrad  * The returned value is guaranteed to be a multiple of 4.
    447  1.2  riastrad  */
    448  1.2  riastrad static inline int drm_eld_size(const uint8_t *eld)
    449  1.2  riastrad {
    450  1.2  riastrad 	return DRM_ELD_HEADER_BLOCK_SIZE + eld[DRM_ELD_BASELINE_ELD_LEN] * 4;
    451  1.2  riastrad }
    452  1.2  riastrad 
    453  1.3  riastrad /**
    454  1.3  riastrad  * drm_eld_get_spk_alloc - Get speaker allocation
    455  1.3  riastrad  * @eld: pointer to an ELD memory structure
    456  1.3  riastrad  *
    457  1.3  riastrad  * The returned value is the speakers mask. User has to use %DRM_ELD_SPEAKER
    458  1.3  riastrad  * field definitions to identify speakers.
    459  1.3  riastrad  */
    460  1.3  riastrad static inline u8 drm_eld_get_spk_alloc(const uint8_t *eld)
    461  1.3  riastrad {
    462  1.3  riastrad 	return eld[DRM_ELD_SPEAKER] & DRM_ELD_SPEAKER_MASK;
    463  1.3  riastrad }
    464  1.3  riastrad 
    465  1.3  riastrad /**
    466  1.3  riastrad  * drm_eld_get_conn_type - Get device type hdmi/dp connected
    467  1.3  riastrad  * @eld: pointer to an ELD memory structure
    468  1.3  riastrad  *
    469  1.3  riastrad  * The caller need to use %DRM_ELD_CONN_TYPE_HDMI or %DRM_ELD_CONN_TYPE_DP to
    470  1.3  riastrad  * identify the display type connected.
    471  1.3  riastrad  */
    472  1.3  riastrad static inline u8 drm_eld_get_conn_type(const uint8_t *eld)
    473  1.3  riastrad {
    474  1.3  riastrad 	return eld[DRM_ELD_SAD_COUNT_CONN_TYPE] & DRM_ELD_CONN_TYPE_MASK;
    475  1.3  riastrad }
    476  1.3  riastrad 
    477  1.3  riastrad bool drm_probe_ddc(struct i2c_adapter *adapter);
    478  1.2  riastrad struct edid *drm_do_get_edid(struct drm_connector *connector,
    479  1.2  riastrad 	int (*get_edid_block)(void *data, u8 *buf, unsigned int block,
    480  1.2  riastrad 			      size_t len),
    481  1.2  riastrad 	void *data);
    482  1.3  riastrad struct edid *drm_get_edid(struct drm_connector *connector,
    483  1.3  riastrad 			  struct i2c_adapter *adapter);
    484  1.3  riastrad struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
    485  1.3  riastrad 				     struct i2c_adapter *adapter);
    486  1.3  riastrad struct edid *drm_edid_duplicate(const struct edid *edid);
    487  1.3  riastrad int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
    488  1.3  riastrad int drm_add_override_edid_modes(struct drm_connector *connector);
    489  1.3  riastrad 
    490  1.3  riastrad u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
    491  1.3  riastrad bool drm_detect_hdmi_monitor(struct edid *edid);
    492  1.3  riastrad bool drm_detect_monitor_audio(struct edid *edid);
    493  1.3  riastrad enum hdmi_quantization_range
    494  1.3  riastrad drm_default_rgb_quant_range(const struct drm_display_mode *mode);
    495  1.3  riastrad int drm_add_modes_noedid(struct drm_connector *connector,
    496  1.3  riastrad 			 int hdisplay, int vdisplay);
    497  1.3  riastrad void drm_set_preferred_mode(struct drm_connector *connector,
    498  1.3  riastrad 			    int hpref, int vpref);
    499  1.3  riastrad 
    500  1.3  riastrad int drm_edid_header_is_valid(const u8 *raw_edid);
    501  1.3  riastrad bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
    502  1.3  riastrad 			  bool *edid_corrupt);
    503  1.3  riastrad bool drm_edid_is_valid(struct edid *edid);
    504  1.3  riastrad void drm_edid_get_monitor_name(struct edid *edid, char *name,
    505  1.3  riastrad 			       int buflen);
    506  1.3  riastrad struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
    507  1.3  riastrad 					   int hsize, int vsize, int fresh,
    508  1.3  riastrad 					   bool rb);
    509  1.1  riastrad #endif /* __DRM_EDID_H__ */
    510