Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Shankar, Uma" <uma.shankar@intel.com>
To: "Modem, Bhanuprakash" <bhanuprakash.modem@intel.com>,
	"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Subject: Re: [igt-dev] [v6 i-g-t 1/3] tests/kms_color_helper: Read deep-color capability from EDID
Date: Wed, 16 Mar 2022 05:53:14 +0000	[thread overview]
Message-ID: <199dc02afa77449799b80f29c8f712df@intel.com> (raw)
In-Reply-To: <20220217155457.2427855-1-bhanuprakash.modem@intel.com>



> -----Original Message-----
> From: Modem, Bhanuprakash <bhanuprakash.modem@intel.com>
> Sent: Thursday, February 17, 2022 9:25 PM
> To: igt-dev@lists.freedesktop.org; Shankar, Uma <uma.shankar@intel.com>
> Cc: Modem, Bhanuprakash <bhanuprakash.modem@intel.com>
> Subject: [v6 i-g-t 1/3] tests/kms_color_helper: Read deep-color capability from EDID
> 
> Add a helper function to read the panel's deep-color capability from EDID.
> 
> For EDID 1.3, we need to read deep color capability from Vendor Specific Data
> Block, and for EDID 1.4 read bit depth from Video Input Definition.
> 
> Vendor Specific Data Block for "HDMI Licensing LLC":
> ---------------------------------------------------------
> | Byte|  Bit  |        Description                      |
> ---------------------------------------------------------
> |     | Bit 6 |   16-bit-per-channel deep color (48-bit)|
> |  6  | Bit 5 |   12-bit-per-channel deep color (36-bit)|
> |     | Bit 4 |   10-bit-per-channel deep color (30-bit)|
> ---------------------------------------------------------
> 
> Video Input Definition (1-byte):
>     * Video Signal Interface: Bit 7 (1:Digital, 0:Analog)
>     * Color Bit Depth: Bits 6 → 4
> -----------------------------------------------------
> | 7 | 6 5 4 | 3 2 1 0 | Color Bit Depth: Bits 6 → 4 |
> |---|-------|---------|-----------------------------|
> | 1 | 0 0 0 | x x x x | Color Bit Depth is undefined|
> | 1 | 0 0 1 | x x x x | 6 Bits per Primary Color    |
> | 1 | 0 1 0 | x x x x | 8 Bits per Primary Color    |
> | 1 | 0 1 1 | x x x x | 10 Bits per Primary Color   |
> | 1 | 1 0 0 | x x x x | 12 Bits per Primary Color   |
> | 1 | 1 0 1 | x x x x | 14 Bits per Primary Color   |
> | 1 | 1 1 0 | x x x x | 16 Bits per Primary Color   |
> | 1 | 1 1 1 | x x x x | Reserved (Do Not Use)       |
> -----------------------------------------------------
> For deep-color we need atleast 10-bits.
> 
> V2:
> * Add EDID 1.3 support
> V3:
> * Fix reading VSDB flags1 for deep-color
> V4:
> * Separate functions for EDID 1.3 & EDID 1.4
> * Other minor cleanups
> V5:
> * Fine tune the logic to identify DC support for RGB format
> V6:
> * Cleanup
> 
> Cc: Uma Shankar <uma.shankar@intel.com>
> Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
> ---
>  lib/igt_edid.c           | 66 ++++++++++++++++++++++++++++++++++++++++
>  lib/igt_edid.h           |  2 ++
>  tests/kms_color_helper.c | 52 +++++++++++++++++++++++++++++++
> tests/kms_color_helper.h |  3 ++
>  4 files changed, 123 insertions(+)
> 
> diff --git a/lib/igt_edid.c b/lib/igt_edid.c index df346c4c8c..cb31a34b7b 100644
> --- a/lib/igt_edid.c
> +++ b/lib/igt_edid.c
> @@ -349,6 +349,72 @@ size_t edid_get_size(const struct edid *edid)
>  	       edid->extensions_len * sizeof(struct edid_ext);  }
> 
> +static int ieee_oui(uint8_t oui[CEA_VSDB_HEADER_SIZE]) {
> +         return (oui[2] << 16) | (oui[1] << 8) | oui[0]; }
> +
> +/**
> + * edid_get_deep_color_from_vsdb: return the Deep Color info from
> +Vender

Typo in vendor.

> + * Specific Data Block (VSDB), if VSDB not found then return zero.
> + */
> +uint8_t edid_get_deep_color_from_vsdb(const struct edid *edid) {
> +	const struct edid_ext *edid_ext;
> +	const struct edid_cea *edid_cea;
> +	const char *cea_data;
> +	uint8_t deep_color = 0;
> +	int offset, i, j;
> +
> +	/* Read from vendor specific data block first, if vsdb not found

Fix multi line comment style.

> +	 * return 0.
> +	 */
> +	for (i = 0; i < edid->extensions_len; i++) {
> +		edid_ext = &edid->extensions[i];
> +		edid_cea = &edid_ext->data.cea;
> +
> +		if ((edid_ext->tag != EDID_EXT_CEA) ||
> +		    (edid_cea->revision != 3))
> +			continue;
> +
> +		offset = edid_cea->dtd_start;
> +		cea_data = edid_cea->data;
> +
> +		for (j = 0; j < offset; j += (cea_data[j] & 0x1F) + 1) {
> +			struct edid_cea_data_block *vsdb =
> +				(struct edid_cea_data_block *)(cea_data + j);
> +
> +			if (((vsdb->type_len & 0xE0) >> 5) !=
> EDID_CEA_DATA_VENDOR_SPECIFIC)
> +				continue;
> +
> +			if (ieee_oui(vsdb->data.vsdbs->ieee_oui) == 0x000C03)
> +				deep_color = vsdb->data.vsdbs->data.hdmi.flags1;
> +
> +			if (deep_color & (7 << 4))
> +				return deep_color;
> +
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +/**
> + * edid_get_bit_depth: Read from the Video Input Definition and return
> +the
> + * Color Bit Depth if Input is a Digital Video, else return zero.
> + */
> +uint8_t edid_get_bit_depth_from_vid(const struct edid *edid) {
> +	/*
> +	 * Video Signal Interface: Bit 7 (1:Digital, 0:Analog)
> +	 * Color Bit Depth: Bits 6 → 4
> +	 */
> +	if (!(edid->input & (1 << 7)))
> +		return 0;
> +
> +	return ((edid->input & (7 << 4)) >> 4); }
> +
>  /**
>   * cea_sad_init_pcm:
>   * @channels: the number of supported channels (max. 8) diff --git a/lib/igt_edid.h
> b/lib/igt_edid.h index aac2f4a208..a9251d689e 100644
> --- a/lib/igt_edid.h
> +++ b/lib/igt_edid.h
> @@ -377,6 +377,8 @@ void edid_update_checksum(struct edid *edid);  void
> base_edid_update_checksum(struct edid *edid);  size_t edid_get_size(const struct
> edid *edid);  void edid_get_mfg(const struct edid *edid, char out[static 3]);
> +uint8_t edid_get_deep_color_from_vsdb(const struct edid *edid); uint8_t
> +edid_get_bit_depth_from_vid(const struct edid *edid);
>  void detailed_timing_set_mode(struct detailed_timing *dt, drmModeModeInfo
> *mode,
>  			      int width_mm, int height_mm);
>  void detailed_timing_set_monitor_range_mode(struct detailed_timing *dt, diff --git
> a/tests/kms_color_helper.c b/tests/kms_color_helper.c index
> d71e7bb2e6..6b3af02b00 100644
> --- a/tests/kms_color_helper.c
> +++ b/tests/kms_color_helper.c
> @@ -24,6 +24,58 @@
> 
>  #include "kms_color_helper.h"
> 
> +bool
> +is_panel_supports_deep_color(int fd, drmModeConnector *connector) {
> +	uint64_t edid_blob_id;
> +	uint8_t bit_depth, rev;
> +	const struct edid *edid;
> +	bool result;
> +	drmModePropertyBlobPtr edid_blob = NULL;
> +
> +	igt_assert(kmstest_get_property(fd, connector->connector_id,
> +					DRM_MODE_OBJECT_CONNECTOR,
> "EDID", NULL,
> +					&edid_blob_id, NULL));
> +	edid_blob = drmModeGetPropertyBlob(fd, edid_blob_id);
> +	igt_require_f(edid_blob, "EDID blob is NULL\n");
> +
> +	edid = (const struct edid *) edid_blob->data;
> +	rev = edid->revision;
> +
> +	if (rev >= 4) {
> +		bit_depth = edid_get_bit_depth_from_vid(edid);
> +
> +		if (bit_depth > 0 && bit_depth < 7)
> +			igt_info("Max supported bit depth: %d\n", ((bit_depth << 1)
> + 4));
> +		else
> +			igt_info("Max supported bit depth: Undefined\n");
> +
> +		result = (bit_depth >= 3) && (bit_depth < 7);
> +	} else {
> +		bit_depth = edid_get_deep_color_from_vsdb(edid);
> +
> +		if (bit_depth &	HDMI_VSDB_DC_48BIT)
> +			igt_info("Max supported bit depth: 16\n");
> +		else if (bit_depth & HDMI_VSDB_DC_36BIT)
> +			igt_info("Max supported bit depth: 12\n");
> +		else if (bit_depth & HDMI_VSDB_DC_30BIT)
> +			igt_info("Max supported bit depth: 10\n");
> +		else
> +			igt_info("Max supported bit depth: Undefined\n");
> +
> +		result = !!(bit_depth & (7 << 4));
> +	}
> +	drmModeFreePropertyBlob(edid_blob);
> +
> +	return result;
> +}
> +
> +bool is_max_bpc_supported(igt_output_t *output) {
> +	return igt_output_has_prop(output, IGT_CONNECTOR_MAX_BPC) &&
> +		igt_output_get_prop(output, IGT_CONNECTOR_MAX_BPC); }
> +
>  void paint_gradient_rectangles(data_t *data,
>  			       drmModeModeInfo *mode,
>  			       color_t *colors,
> diff --git a/tests/kms_color_helper.h b/tests/kms_color_helper.h index
> bb6f0054f3..992087ac9c 100644
> --- a/tests/kms_color_helper.h
> +++ b/tests/kms_color_helper.h
> @@ -36,6 +36,7 @@
>  #include "drm.h"
>  #include "drmtest.h"
>  #include "igt.h"
> +#include "igt_edid.h"
> 
> 
>  /* Internal */
> @@ -64,6 +65,8 @@ typedef struct {
>  	color_t coeffs[];
>  } gamma_lut_t;
> 
> +bool is_panel_supports_deep_color(int fd, drmModeConnector *connector);

Fix this naming as suggested by Petri.

Also with other nits fixed, this is
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> +bool is_max_bpc_supported(igt_output_t *output);
>  void paint_gradient_rectangles(data_t *data,
>  			       drmModeModeInfo *mode,
>  			       color_t *colors,
> --
> 2.35.0


  parent reply	other threads:[~2022-03-16  5:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 11:23 [igt-dev] [PATCH i-g-t 0/3] New subtests for deep color Bhanuprakash Modem
2022-01-24 11:23 ` [igt-dev] [PATCH i-g-t 1/3] tests/kms_color_helper: Read deep-color capability from EDID Bhanuprakash Modem
2022-01-26 13:15   ` [igt-dev] [v2 " Bhanuprakash Modem
2022-01-27  6:44     ` [igt-dev] [v3 " Bhanuprakash Modem
2022-02-01  9:05       ` [igt-dev] [v4 " Bhanuprakash Modem
2022-02-08  4:11         ` [igt-dev] [v5 " Bhanuprakash Modem
2022-02-17 15:54           ` [igt-dev] [v6 " Bhanuprakash Modem
2022-02-18  9:49             ` Petri Latvala
2022-03-16  5:53             ` Shankar, Uma [this message]
2022-01-24 11:23 ` [igt-dev] [PATCH i-g-t 2/3] tests/kms_color: Add support for Deep-Color Bhanuprakash Modem
2022-01-26 13:15   ` [igt-dev] [v2 " Bhanuprakash Modem
2022-02-08  4:12     ` [igt-dev] [v3 " Bhanuprakash Modem
2022-02-17 15:54       ` [igt-dev] [v4 " Bhanuprakash Modem
2022-03-16  5:59         ` Shankar, Uma
2022-01-24 11:23 ` [igt-dev] [PATCH i-g-t 3/3] HAX: Add deep-color tests to BAT Bhanuprakash Modem
2022-01-26 13:15   ` [igt-dev] [v2 " Bhanuprakash Modem
2022-01-24 14:35 ` [igt-dev] ✓ Fi.CI.BAT: success for New subtests for deep color Patchwork
2022-01-24 17:36 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-01-26 13:15 ` [igt-dev] [v2 i-g-t 0/3] " Bhanuprakash Modem
2022-01-26 17:40 ` [igt-dev] ✗ Fi.CI.BAT: failure for New subtests for deep color (rev4) Patchwork
2022-01-27  4:54   ` Modem, Bhanuprakash
2022-01-27  4:58     ` Modem, Bhanuprakash
2022-01-27  7:32 ` [igt-dev] ✓ Fi.CI.BAT: success for New subtests for deep color (rev5) Patchwork
2022-01-27 10:37 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-01-30 20:47 ` [igt-dev] ✓ Fi.CI.IGT: success " Patchwork
2022-02-01 12:41 ` [igt-dev] ✓ Fi.CI.BAT: success for New subtests for deep color (rev6) Patchwork
2022-02-01 16:55 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2022-02-08  4:42 ` [igt-dev] ✓ Fi.CI.BAT: success for New subtests for deep color (rev8) Patchwork
2022-02-08  6:27 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork
2022-02-17 17:04 ` [igt-dev] ✓ Fi.CI.BAT: success for New subtests for deep color (rev10) Patchwork
2022-02-18  3:04 ` [igt-dev] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199dc02afa77449799b80f29c8f712df@intel.com \
    --to=uma.shankar@intel.com \
    --cc=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox