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

Commit b3cb441e authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge changes I25685463,Iae92de79,I018cfefe into dev/msm-4.14-display

* changes:
  drm/msm: update flag for seamless dynamic framerates
  drm: edid: add support for parsing additional EDID blocks
  drm: edid: HDMI 2.0 HF-VSDB block parsing
parents 0f3855d7 89f20338
Loading
Loading
Loading
Loading
+195 −1
Original line number Diff line number Diff line
@@ -2787,7 +2787,7 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,

	return closure.modes;
}

#define VIDEO_CAPABILITY_EXTENDED_DATA_BLOCK 0x0
#define AUDIO_BLOCK	0x01
#define VIDEO_BLOCK     0x02
#define VENDOR_BLOCK    0x03
@@ -3846,6 +3846,161 @@ add_YCbCr420VDB_modes(struct drm_connector *connector, struct edid *edid)
	return modes;
}

/*
 * drm_extract_vcdb_info - Parse the HDMI Video Capability Data Block
 * @connector: connector corresponding to the HDMI sink
 * @db: start of the CEA vendor specific block
 *
 * Parses the HDMI VCDB to extract sink info for @connector.
 */
static void
drm_extract_vcdb_info(struct drm_connector *connector, const u8 *db)
{
	/*
	 * Check if the sink specifies underscan
	 * support for:
	 * BIT 5: preferred video format
	 * BIT 3: IT video format
	 * BIT 1: CE video format
	 */

	connector->pt_scan_info =
		(db[2] & (BIT(4) | BIT(5))) >> 4;
	connector->it_scan_info =
		(db[2] & (BIT(3) | BIT(2))) >> 2;
	connector->ce_scan_info =
		db[2] & (BIT(1) | BIT(0));

	DRM_DEBUG_KMS("Scan Info (pt|it|ce): (%d|%d|%d)",
			  (int) connector->pt_scan_info,
			  (int) connector->it_scan_info,
			  (int) connector->ce_scan_info);
}

static bool drm_edid_is_luminance_value_present(
u32 block_length, enum luminance_value value)
{
	return block_length > NO_LUMINANCE_DATA && value <= block_length;
}

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

	u8 len = 0;

	if (!db)
		return;

	len = db[0] & 0x1f;
	/* Byte 3: Electro-Optical Transfer Functions */
	connector->hdr_eotf = db[2] & 0x3F;

	/* Byte 4: Static Metadata Descriptor Type 1 */
	connector->hdr_metadata_type_one = (db[3] & BIT(0));

	/* Byte 5: Desired Content Maximum Luminance */
	if (drm_edid_is_luminance_value_present(len, MAXIMUM_LUMINANCE))
		connector->hdr_max_luminance =
			db[MAXIMUM_LUMINANCE];

	/* Byte 6: Desired Content Max Frame-average Luminance */
	if (drm_edid_is_luminance_value_present(len, FRAME_AVERAGE_LUMINANCE))
		connector->hdr_avg_luminance =
			db[FRAME_AVERAGE_LUMINANCE];

	/* Byte 7: Desired Content Min Luminance */
	if (drm_edid_is_luminance_value_present(len, MINIMUM_LUMINANCE))
		connector->hdr_min_luminance =
			db[MINIMUM_LUMINANCE];

	connector->hdr_supported = true;

	DRM_DEBUG_KMS("HDR electro-optical %d\n", connector->hdr_eotf);
	DRM_DEBUG_KMS("metadata desc 1 %d\n", connector->hdr_metadata_type_one);
	DRM_DEBUG_KMS("max luminance %d\n", connector->hdr_max_luminance);
	DRM_DEBUG_KMS("avg luminance %d\n", connector->hdr_avg_luminance);
	DRM_DEBUG_KMS("min luminance %d\n", connector->hdr_min_luminance);
}

/*
 * drm_hdmi_extract_extended_blk_info - Parse the HDMI extended tag blocks
 * @connector: connector corresponding to the HDMI sink
 * @edid: handle to the EDID structure
 * Parses the all extended tag blocks extract sink info for @connector.
 */
static void
drm_hdmi_extract_extended_blk_info(struct drm_connector *connector,
		struct edid *edid)
{
	const u8 *cea = drm_find_cea_extension(edid);
	const u8 *db = NULL;

	if (cea && cea_revision(cea) >= 3) {
		int i, start, end;

		if (cea_db_offsets(cea, &start, &end))
			return;

		for_each_cea_db(cea, i, start, end) {
			db = &cea[i];

			if (cea_db_tag(db) == USE_EXTENDED_TAG) {
				DRM_DEBUG_KMS("found extended tag block = %d\n",
						db[1]);
				switch (db[1]) {
				case VIDEO_CAPABILITY_EXTENDED_DATA_BLOCK:
					drm_extract_vcdb_info(connector, db);
					break;
				case HDR_STATIC_METADATA_EXTENDED_DATA_BLOCK:
					drm_extract_hdr_db(connector, db);
					break;
				default:
					break;
				}
			}
		}
	}
}

static void
parse_hdmi_hf_vsdb(struct drm_connector *connector, const u8 *db)
{
	u8 len = cea_db_payload_len(db);

	if (len < 7)
		return;

	if (db[4] != 1)
		return; /* invalid version */

	connector->max_tmds_char = db[5] * 5;
	connector->scdc_present = db[6] & (1 << 7);
	connector->rr_capable = db[6] & (1 << 6);
	connector->flags_3d = db[6] & 0x7;
	connector->supports_scramble = connector->scdc_present &&
			(db[6] & (1 << 3));

	DRM_DEBUG_KMS("HDMI v2: max TMDS char %d, "
			"scdc %s, "
			"rr %s, "
			"3D flags 0x%x, "
			"scramble %s\n",
			connector->max_tmds_char,
			connector->scdc_present ? "available" : "not available",
			connector->rr_capable ? "capable" : "not capable",
			connector->flags_3d,
			connector->supports_scramble ?
				"supported" : "not supported");
}

static void
monitor_name(struct detailed_timing *t, void *data)
{
@@ -3972,6 +4127,9 @@ void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
				/* HDMI Vendor-Specific Data Block */
				if (cea_db_is_hdmi_vsdb(db))
					drm_parse_hdmi_vsdb_audio(connector, db);
				/* HDMI Forum Vendor-Specific Data Block */
				else if (cea_db_is_hdmi_forum_vsdb(db))
					parse_hdmi_hf_vsdb(connector, db);
				break;
			default:
				break;
@@ -4461,6 +4619,37 @@ static void drm_parse_cea_ext(struct drm_connector *connector,
	}
}

static void
drm_hdmi_extract_vsdbs_info(struct drm_connector *connector, struct edid *edid)
{
	const u8 *cea = drm_find_cea_extension(edid);
	const u8 *db = NULL;

	if (cea && cea_revision(cea) >= 3) {
		int i, start, end;

		if (cea_db_offsets(cea, &start, &end))
			return;

		for_each_cea_db(cea, i, start, end) {
			db = &cea[i];

			if (cea_db_tag(db) == VENDOR_BLOCK) {
				/* HDMI Vendor-Specific Data Block */
				if (cea_db_is_hdmi_vsdb(db)) {
					drm_parse_hdmi_vsdb_video(
						connector, db);
					drm_parse_hdmi_vsdb_audio(
						connector, db);
				}
				/* HDMI Forum Vendor-Specific Data Block */
				else if (cea_db_is_hdmi_forum_vsdb(db))
					parse_hdmi_hf_vsdb(connector, db);
			}
		}
	}
}

static void drm_add_display_info(struct drm_connector *connector,
				 struct edid *edid)
{
@@ -4498,6 +4687,11 @@ static void drm_add_display_info(struct drm_connector *connector,
			  connector->name, info->bpc);
	}

	/* Extract audio and video latency fields for the sink */
	drm_hdmi_extract_vsdbs_info(connector, edid);
	/* Extract info from extended tag blocks */
	drm_hdmi_extract_extended_blk_info(connector, edid);

	/* Only defined for 1.4 with digital displays */
	if (edid->revision < 4)
		return;
+12 −0
Original line number Diff line number Diff line
@@ -708,6 +708,11 @@ struct drm_cmdline_mode {
 * @hdr_avg_luminance: desired avg luminance obtained from HDR block
 * @hdr_min_luminance: desired min luminance obtained from HDR block
 * @hdr_supported: does the sink support HDR content
 * @max_tmds_char: indicates the maximum TMDS Character Rate supported
 * @scdc_present: when set the sink supports SCDC functionality
 * @rr_capable: when set the sink is capable of initiating an SCDC read request
 * @supports_scramble: when set the sink supports less than 340Mcsc scrambling
 * @flags_3d: 3D view(s) supported by the sink, see drm_edid.h (DRM_EDID_3D_*)
 * @edid_corrupt: indicates whether the last read EDID was corrupt
 * @debugfs_entry: debugfs directory for this connector
 * @has_tile: is this connector connected to a tiled monitor
@@ -892,6 +897,13 @@ struct drm_connector {
	u32 hdr_min_luminance;
	bool hdr_supported;

	/* EDID bits HDMI 2.0 */
	int max_tmds_char;	/* in Mcsc */
	bool scdc_present;
	bool rr_capable;
	bool supports_scramble;
	int flags_3d;

	/* Flag for raw EDID header corruption - used in Displayport
	 * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
	 */
+5 −0
Original line number Diff line number Diff line
@@ -279,6 +279,11 @@ struct detailed_timing {

#define DRM_ELD_CEA_SAD(mnl, sad)	(20 + (mnl) + 3 * (sad))

/* HDMI 2.0 */
#define DRM_EDID_3D_INDEPENDENT_VIEW	(1 << 2)
#define DRM_EDID_3D_DUAL_VIEW		(1 << 1)
#define DRM_EDID_3D_OSD_DISPARITY	(1 << 0)

struct edid {
	u8 header[8];
	/* Vendor & product info */
+1 −1
Original line number Diff line number Diff line
@@ -84,7 +84,6 @@ extern "C" {
#define  DRM_MODE_FLAG_3D_L_DEPTH_GFX_GFX_DEPTH	(6<<14)
#define  DRM_MODE_FLAG_3D_TOP_AND_BOTTOM	(7<<14)
#define  DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF	(8<<14)
#define  DRM_MODE_FLAG_SEAMLESS			(1<<19)

/* Picture aspect ratio options */
#define DRM_MODE_PICTURE_ASPECT_NONE		0
@@ -102,6 +101,7 @@ extern "C" {

#define  DRM_MODE_FLAG_SUPPORTS_RGB		(1<<23)
#define  DRM_MODE_FLAG_SUPPORTS_YUV		(1<<24)
#define  DRM_MODE_FLAG_SEAMLESS			(1<<31)

/* DPMS flags */
/* bit compatible with the xorg definitions. */