linux/include/drm/drm_edid.h

/*
 * Copyright © 2007-2008 Intel Corporation
 *   Jesse Barnes <[email protected]>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __DRM_EDID_H__
#define __DRM_EDID_H__

#include <linux/types.h>

enum hdmi_quantization_range;
struct drm_connector;
struct drm_device;
struct drm_display_mode;
struct drm_edid;
struct drm_printer;
struct hdmi_avi_infoframe;
struct hdmi_vendor_infoframe;
struct i2c_adapter;

#define EDID_LENGTH
#define DDC_ADDR
#define DDC_ADDR2

#define CEA_EXT
#define VTB_EXT
#define DI_EXT
#define LS_EXT
#define MI_EXT
#define DISPLAYID_EXT

struct est_timings {} __packed;

/* 00=16:10, 01=4:3, 10=5:4, 11=16:9 */
#define EDID_TIMING_ASPECT_SHIFT
#define EDID_TIMING_ASPECT_MASK

/* need to add 60 */
#define EDID_TIMING_VFREQ_SHIFT
#define EDID_TIMING_VFREQ_MASK

struct std_timing {} __packed;

#define DRM_EDID_PT_HSYNC_POSITIVE
#define DRM_EDID_PT_VSYNC_POSITIVE
#define DRM_EDID_PT_SEPARATE_SYNC
#define DRM_EDID_PT_STEREO
#define DRM_EDID_PT_INTERLACED

/* If detailed data is pixel timing */
struct detailed_pixel_timing {} __packed;

/* If it's not pixel timing, it'll be one of the below */
struct detailed_data_string {} __packed;

#define DRM_EDID_RANGE_OFFSET_MIN_VFREQ
#define DRM_EDID_RANGE_OFFSET_MAX_VFREQ
#define DRM_EDID_RANGE_OFFSET_MIN_HFREQ
#define DRM_EDID_RANGE_OFFSET_MAX_HFREQ

#define DRM_EDID_DEFAULT_GTF_SUPPORT_FLAG
#define DRM_EDID_RANGE_LIMITS_ONLY_FLAG
#define DRM_EDID_SECONDARY_GTF_SUPPORT_FLAG
#define DRM_EDID_CVT_SUPPORT_FLAG

#define DRM_EDID_CVT_FLAGS_STANDARD_BLANKING
#define DRM_EDID_CVT_FLAGS_REDUCED_BLANKING

struct detailed_data_monitor_range {} __packed;

struct detailed_data_wpindex {} __packed;

struct detailed_data_color_point {} __packed;

struct cvt_timing {} __packed;

struct detailed_non_pixel {} __packed;

#define EDID_DETAIL_EST_TIMINGS
#define EDID_DETAIL_CVT_3BYTE
#define EDID_DETAIL_COLOR_MGMT_DATA
#define EDID_DETAIL_STD_MODES
#define EDID_DETAIL_MONITOR_CPDATA
#define EDID_DETAIL_MONITOR_NAME
#define EDID_DETAIL_MONITOR_RANGE
#define EDID_DETAIL_MONITOR_STRING
#define EDID_DETAIL_MONITOR_SERIAL

struct detailed_timing {} __packed;

#define DRM_EDID_INPUT_SERRATION_VSYNC
#define DRM_EDID_INPUT_SYNC_ON_GREEN
#define DRM_EDID_INPUT_COMPOSITE_SYNC
#define DRM_EDID_INPUT_SEPARATE_SYNCS
#define DRM_EDID_INPUT_BLANK_TO_BLACK
#define DRM_EDID_INPUT_VIDEO_LEVEL
#define DRM_EDID_INPUT_DIGITAL
#define DRM_EDID_DIGITAL_DEPTH_MASK
#define DRM_EDID_DIGITAL_DEPTH_UNDEF
#define DRM_EDID_DIGITAL_DEPTH_6
#define DRM_EDID_DIGITAL_DEPTH_8
#define DRM_EDID_DIGITAL_DEPTH_10
#define DRM_EDID_DIGITAL_DEPTH_12
#define DRM_EDID_DIGITAL_DEPTH_14
#define DRM_EDID_DIGITAL_DEPTH_16
#define DRM_EDID_DIGITAL_DEPTH_RSVD
#define DRM_EDID_DIGITAL_TYPE_MASK
#define DRM_EDID_DIGITAL_TYPE_UNDEF
#define DRM_EDID_DIGITAL_TYPE_DVI
#define DRM_EDID_DIGITAL_TYPE_HDMI_A
#define DRM_EDID_DIGITAL_TYPE_HDMI_B
#define DRM_EDID_DIGITAL_TYPE_MDDI
#define DRM_EDID_DIGITAL_TYPE_DP
#define DRM_EDID_DIGITAL_DFP_1_X

#define DRM_EDID_FEATURE_DEFAULT_GTF
#define DRM_EDID_FEATURE_CONTINUOUS_FREQ
#define DRM_EDID_FEATURE_PREFERRED_TIMING
#define DRM_EDID_FEATURE_STANDARD_COLOR
/* If analog */
#define DRM_EDID_FEATURE_DISPLAY_TYPE
/* If digital */
#define DRM_EDID_FEATURE_COLOR_MASK
#define DRM_EDID_FEATURE_RGB
#define DRM_EDID_FEATURE_RGB_YCRCB444
#define DRM_EDID_FEATURE_RGB_YCRCB422
#define DRM_EDID_FEATURE_RGB_YCRCB

#define DRM_EDID_FEATURE_PM_ACTIVE_OFF
#define DRM_EDID_FEATURE_PM_SUSPEND
#define DRM_EDID_FEATURE_PM_STANDBY

#define DRM_EDID_HDMI_DC_48
#define DRM_EDID_HDMI_DC_36
#define DRM_EDID_HDMI_DC_30
#define DRM_EDID_HDMI_DC_Y444

/* YCBCR 420 deep color modes */
#define DRM_EDID_YCBCR420_DC_48
#define DRM_EDID_YCBCR420_DC_36
#define DRM_EDID_YCBCR420_DC_30
#define DRM_EDID_YCBCR420_DC_MASK

/* HDMI 2.1 additional fields */
#define DRM_EDID_MAX_FRL_RATE_MASK
#define DRM_EDID_FAPA_START_LOCATION
#define DRM_EDID_ALLM
#define DRM_EDID_FVA

/* Deep Color specific */
#define DRM_EDID_DC_30BIT_420
#define DRM_EDID_DC_36BIT_420
#define DRM_EDID_DC_48BIT_420

/* VRR specific */
#define DRM_EDID_CNMVRR
#define DRM_EDID_CINEMA_VRR
#define DRM_EDID_MDELTA
#define DRM_EDID_VRR_MAX_UPPER_MASK
#define DRM_EDID_VRR_MAX_LOWER_MASK
#define DRM_EDID_VRR_MIN_MASK

/* DSC specific */
#define DRM_EDID_DSC_10BPC
#define DRM_EDID_DSC_12BPC
#define DRM_EDID_DSC_16BPC
#define DRM_EDID_DSC_ALL_BPP
#define DRM_EDID_DSC_NATIVE_420
#define DRM_EDID_DSC_1P2
#define DRM_EDID_DSC_MAX_FRL_RATE_MASK
#define DRM_EDID_DSC_MAX_SLICES
#define DRM_EDID_DSC_TOTAL_CHUNK_KBYTES

struct drm_edid_product_id {} __packed;

struct edid {} __packed;

/* EDID matching */
struct drm_edid_ident {};

#define EDID_PRODUCT_ID(e)

/* Short Audio Descriptor */
struct cea_sad {};

int drm_edid_to_sad(const struct edid *edid, struct cea_sad **sads);
int drm_edid_to_speaker_allocation(const struct edid *edid, u8 **sadb);
int drm_av_sync_delay(struct drm_connector *connector,
		      const struct drm_display_mode *mode);

int
drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
					 const struct drm_connector *connector,
					 const struct drm_display_mode *mode);
int
drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
					    const struct drm_connector *connector,
					    const struct drm_display_mode *mode);

void
drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
				   const struct drm_connector *connector,
				   const struct drm_display_mode *mode,
				   enum hdmi_quantization_range rgb_quant_range);

/**
 * drm_edid_decode_mfg_id - Decode the manufacturer ID
 * @mfg_id: The manufacturer ID
 * @vend: A 4-byte buffer to store the 3-letter vendor string plus a '\0'
 *	  termination
 */
static inline const char *drm_edid_decode_mfg_id(u16 mfg_id, char vend[4])
{}

/**
 * drm_edid_encode_panel_id - Encode an ID for matching against drm_edid_get_panel_id()
 * @vend_chr_0: First character of the vendor string.
 * @vend_chr_1: Second character of the vendor string.
 * @vend_chr_2: Third character of the vendor string.
 * @product_id: The 16-bit product ID.
 *
 * This is a macro so that it can be calculated at compile time and used
 * as an initializer.
 *
 * For instance:
 *   drm_edid_encode_panel_id('B', 'O', 'E', 0x2d08) => 0x09e52d08
 *
 * Return: a 32-bit ID per panel.
 */
#define drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, product_id)

/**
 * drm_edid_decode_panel_id - Decode a panel ID from drm_edid_encode_panel_id()
 * @panel_id: The panel ID to decode.
 * @vend: A 4-byte buffer to store the 3-letter vendor string plus a '\0'
 *	  termination
 * @product_id: The product ID will be returned here.
 *
 * For instance, after:
 *   drm_edid_decode_panel_id(0x09e52d08, vend, &product_id)
 * These will be true:
 *   vend[0] = 'B'
 *   vend[1] = 'O'
 *   vend[2] = 'E'
 *   vend[3] = '\0'
 *   product_id = 0x2d08
 */
static inline void drm_edid_decode_panel_id(u32 panel_id, char vend[4], u16 *product_id)
{}

bool drm_probe_ddc(struct i2c_adapter *adapter);
struct edid *drm_get_edid(struct drm_connector *connector,
			  struct i2c_adapter *adapter);
struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
				     struct i2c_adapter *adapter);
struct edid *drm_edid_duplicate(const struct edid *edid);
int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid);
int drm_edid_override_connector_update(struct drm_connector *connector);

u8 drm_match_cea_mode(const struct drm_display_mode *to_match);
bool drm_detect_hdmi_monitor(const struct edid *edid);
bool drm_detect_monitor_audio(const struct edid *edid);
enum hdmi_quantization_range
drm_default_rgb_quant_range(const struct drm_display_mode *mode);
int drm_add_modes_noedid(struct drm_connector *connector,
			 int hdisplay, int vdisplay);

int drm_edid_header_is_valid(const void *edid);
bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
			  bool *edid_corrupt);
bool drm_edid_is_valid(struct edid *edid);
void drm_edid_get_monitor_name(const struct edid *edid, char *name,
			       int buflen);
struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
					   int hsize, int vsize, int fresh,
					   bool rb);
struct drm_display_mode *
drm_display_mode_from_cea_vic(struct drm_device *dev,
			      u8 video_code);

/* Interface based on struct drm_edid */
const struct drm_edid *drm_edid_alloc(const void *edid, size_t size);
const struct drm_edid *drm_edid_dup(const struct drm_edid *drm_edid);
void drm_edid_free(const struct drm_edid *drm_edid);
bool drm_edid_valid(const struct drm_edid *drm_edid);
const struct edid *drm_edid_raw(const struct drm_edid *drm_edid);
const struct drm_edid *drm_edid_read(struct drm_connector *connector);
const struct drm_edid *drm_edid_read_ddc(struct drm_connector *connector,
					 struct i2c_adapter *adapter);
const struct drm_edid *drm_edid_read_custom(struct drm_connector *connector,
					    int (*read_block)(void *context, u8 *buf, unsigned int block, size_t len),
					    void *context);
const struct drm_edid *drm_edid_read_base_block(struct i2c_adapter *adapter);
const struct drm_edid *drm_edid_read_switcheroo(struct drm_connector *connector,
						struct i2c_adapter *adapter);
int drm_edid_connector_update(struct drm_connector *connector,
			      const struct drm_edid *edid);
int drm_edid_connector_add_modes(struct drm_connector *connector);
bool drm_edid_is_digital(const struct drm_edid *drm_edid);
void drm_edid_get_product_id(const struct drm_edid *drm_edid,
			     struct drm_edid_product_id *id);
void drm_edid_print_product_id(struct drm_printer *p,
			       const struct drm_edid_product_id *id, bool raw);
u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid);
bool drm_edid_match(const struct drm_edid *drm_edid,
		    const struct drm_edid_ident *ident);

#endif /* __DRM_EDID_H__ */