Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2965321 authored by Abhinav Kumar's avatar Abhinav Kumar
Browse files

drm/edid: add colorimetry block parsing support



Add support for parsing the colorimetry data block of EDID to get
information about the supported encoding formats of the sink.

This information is needed to use the appropriate color encoding scheme
before transmitting the video stream to the sink.

Change-Id: I1cf9cf75288070ea5a7bd73e15cfbd527199f04c
Signed-off-by: default avatarAbhinav Kumar <abhinavk@codeaurora.org>
parent dda7c740
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -2848,6 +2848,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
#define VSVDB_HDR10_PLUS_IEEE_CODE 0x90848b
#define VSVDB_HDR10_PLUS_APP_VER_MASK 0x3
#define HDR_STATIC_METADATA_EXTENDED_DATA_BLOCK 0x06
#define COLORIMETRY_EXTENDED_DATA_BLOCK 0x05
#define USE_EXTENDED_TAG 0x07
#define EXT_VIDEO_CAPABILITY_BLOCK 0x00
#define EXT_VIDEO_DATA_BLOCK_420	0x0E
@@ -3906,6 +3907,53 @@ u32 block_length, enum luminance_value value)
	return block_length > NO_LUMINANCE_DATA && value <= block_length;
}

/*
 * drm_extract_clrmetry_db - Parse the HDMI colorimetry extended block
 * @connector: connector corresponding to the HDMI sink
 * @db: start of the HDMI colorimetry extended block
 *
 * Parses the HDMI colorimetry block to extract sink info for @connector.
 */
static void
drm_extract_clrmetry_db(struct drm_connector *connector, const u8 *db)
{

	if (!db) {
		DRM_ERROR("invalid db\n");
		return;
	}

	/* Byte 3 Bit 0: xvYCC_601 */
	if (db[2] & BIT(0))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_xvYCC_601;
	/* Byte 3 Bit 1: xvYCC_709 */
	if (db[2] & BIT(1))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_xvYCC_709;
	/* Byte 3 Bit 2: sYCC_601 */
	if (db[2] & BIT(2))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_sYCC_601;
	/* Byte 3 Bit 3: ADBYCC_601 */
	if (db[2] & BIT(3))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_ADBYCC_601;
	/* Byte 3 Bit 4: ADB_RGB */
	if (db[2] & BIT(4))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_ADB_RGB;
	/* Byte 3 Bit 5: BT2020_CYCC */
	if (db[2] & BIT(5))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_BT2020_CYCC;
	/* Byte 3 Bit 6: BT2020_YCC */
	if (db[2] & BIT(6))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_BT2020_YCC;
	/* Byte 3 Bit 7: BT2020_RGB */
	if (db[2] & BIT(7))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_BT2020_RGB;
	/* Byte 4 Bit 7: DCI-P3 */
	if (db[3] & BIT(7))
		connector->color_enc_fmt |= DRM_EDID_CLRMETRY_DCI_P3;

	DRM_DEBUG_KMS("colorimetry fmts = 0x%x\n", connector->color_enc_fmt);
}

/*
 * drm_extract_hdr_db - Parse the HDMI HDR extended block
 * @connector: connector corresponding to the HDMI sink
@@ -3987,6 +4035,9 @@ drm_hdmi_extract_extended_blk_info(struct drm_connector *connector,
				case HDR_STATIC_METADATA_EXTENDED_DATA_BLOCK:
					drm_extract_hdr_db(connector, db);
					break;
				case COLORIMETRY_EXTENDED_DATA_BLOCK:
					drm_extract_clrmetry_db(connector, db);
					break;
				default:
					break;
				}
+2 −0
Original line number Diff line number Diff line
@@ -1052,6 +1052,7 @@ struct drm_connector {
	 * @pt_scan_info: PT scan info obtained from the VCDB of EDID
	 * @it_scan_info: IT scan info obtained from the VCDB of EDID
	 * @ce_scan_info: CE scan info obtained from the VCDB of EDID
	 * @color_enc_fmt: Colorimetry encoding formats of sink
	 * @hdr_eotf: Electro optical transfer function obtained from HDR block
	 * @hdr_metadata_type_one: Metadata type one obtained from HDR block
	 * @hdr_max_luminance: desired max luminance obtained from HDR block
@@ -1070,6 +1071,7 @@ struct drm_connector {
	u8 pt_scan_info;
	u8 it_scan_info;
	u8 ce_scan_info;
	u32 color_enc_fmt;
	u32 hdr_eotf;
	bool hdr_metadata_type_one;
	u32 hdr_max_luminance;
+10 −0
Original line number Diff line number Diff line
@@ -221,6 +221,16 @@ struct detailed_timing {
				    DRM_EDID_YCBCR420_DC_36 | \
				    DRM_EDID_YCBCR420_DC_30)

#define DRM_EDID_CLRMETRY_xvYCC_601   (1 << 0)
#define DRM_EDID_CLRMETRY_xvYCC_709   (1 << 1)
#define DRM_EDID_CLRMETRY_sYCC_601    (1 << 2)
#define DRM_EDID_CLRMETRY_ADBYCC_601  (1 << 3)
#define DRM_EDID_CLRMETRY_ADB_RGB     (1 << 4)
#define DRM_EDID_CLRMETRY_BT2020_CYCC (1 << 5)
#define DRM_EDID_CLRMETRY_BT2020_YCC  (1 << 6)
#define DRM_EDID_CLRMETRY_BT2020_RGB  (1 << 7)
#define DRM_EDID_CLRMETRY_DCI_P3      (1 << 15)

/* ELD Header Block */
#define DRM_ELD_HEADER_BLOCK_SIZE	4