[PATCH 4/4] drm/edid: Add display_info.rgb_quant_range_selectable

2019-01-08 Thread Ville Syrjala
From: Ville Syrjälä 

Move the CEA-861 QS bit handling entirely into the edid code. No
need to bother the drivers with this.

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: "David (ChunMing) Zhou" 
Cc: amd-gfx@lists.freedesktop.org
Cc: Eric Anholt  (supporter:DRM DRIVERS FOR VC4)
Signed-off-by: Ville Syrjälä 
Acked-by: Alex Deucher 
Acked-by: Eric Anholt 
---
 drivers/gpu/drm/drm_edid.c| 70 ---
 drivers/gpu/drm/i915/intel_drv.h  |  1 -
 drivers/gpu/drm/i915/intel_hdmi.c |  8 +--
 drivers/gpu/drm/i915/intel_lspcon.c   |  3 +-
 drivers/gpu/drm/i915/intel_sdvo.c |  7 +--
 drivers/gpu/drm/radeon/radeon_audio.c |  3 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c|  9 +---
 include/drm/drm_connector.h   |  6 +++
 include/drm/drm_edid.h|  4 +-
 9 files changed, 43 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index cd25bd08bf53..990b1909f9d7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3641,6 +3641,20 @@ static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
return oui == HDMI_FORUM_IEEE_OUI;
 }
 
+static bool cea_db_is_vcdb(const u8 *db)
+{
+   if (cea_db_tag(db) != USE_EXTENDED_TAG)
+   return false;
+
+   if (cea_db_payload_len(db) != 2)
+   return false;
+
+   if (cea_db_extended_tag(db) != EXT_VIDEO_CAPABILITY_BLOCK)
+   return false;
+
+   return true;
+}
+
 static bool cea_db_is_y420cmdb(const u8 *db)
 {
if (cea_db_tag(db) != USE_EXTENDED_TAG)
@@ -4223,41 +4237,6 @@ bool drm_detect_monitor_audio(struct edid *edid)
 }
 EXPORT_SYMBOL(drm_detect_monitor_audio);
 
-/**
- * drm_rgb_quant_range_selectable - is RGB quantization range selectable?
- * @edid: EDID block to scan
- *
- * Check whether the monitor reports the RGB quantization range selection
- * as supported. The AVI infoframe can then be used to inform the monitor
- * which quantization range (full or limited) is used.
- *
- * Return: True if the RGB quantization range is selectable, false otherwise.
- */
-bool drm_rgb_quant_range_selectable(struct edid *edid)
-{
-   u8 *edid_ext;
-   int i, start, end;
-
-   edid_ext = drm_find_cea_extension(edid);
-   if (!edid_ext)
-   return false;
-
-   if (cea_db_offsets(edid_ext, , ))
-   return false;
-
-   for_each_cea_db(edid_ext, i, start, end) {
-   if (cea_db_tag(_ext[i]) == USE_EXTENDED_TAG &&
-   cea_db_payload_len(_ext[i]) == 2 &&
-   cea_db_extended_tag(_ext[i]) ==
-   EXT_VIDEO_CAPABILITY_BLOCK) {
-   DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", edid_ext[i + 2]);
-   return edid_ext[i + 2] & EDID_CEA_VCDB_QS;
-   }
-   }
-
-   return false;
-}
-EXPORT_SYMBOL(drm_rgb_quant_range_selectable);
 
 /**
  * drm_default_rgb_quant_range - default RGB quantization range
@@ -4278,6 +4257,16 @@ drm_default_rgb_quant_range(const struct 
drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_default_rgb_quant_range);
 
+static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db)
+{
+   struct drm_display_info *info = >display_info;
+
+   DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", db[2]);
+
+   if (db[2] & EDID_CEA_VCDB_QS)
+   info->rgb_quant_range_selectable = true;
+}
+
 static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector,
   const u8 *db)
 {
@@ -4452,6 +4441,8 @@ static void drm_parse_cea_ext(struct drm_connector 
*connector,
drm_parse_hdmi_forum_vsdb(connector, db);
if (cea_db_is_y420cmdb(db))
drm_parse_y420cmdb_bitmap(connector, db);
+   if (cea_db_is_vcdb(db))
+   drm_parse_vcdb(connector, db);
}
 }
 
@@ -4472,6 +4463,7 @@ drm_reset_display_info(struct drm_connector *connector)
info->max_tmds_clock = 0;
info->dvi_dual = false;
info->has_hdmi_infoframe = false;
+   info->rgb_quant_range_selectable = false;
memset(>hdmi, 0, sizeof(info->hdmi));
 
info->non_desktop = 0;
@@ -4939,15 +4931,15 @@ EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
  * @connector: the connector
  * @mode: DRM display mode
  * @rgb_quant_range: RGB quantization range (Q)
- * @rgb_quant_range_selectable: Sink support selectable RGB quantization range 
(QS)
  */
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
   struct drm_connector *connector,
   const struct drm_display_mode *mode,
-  enum hdmi_quantization_range rgb_quant_range,
-  bool rgb_quant_range_selectable)
+  enum hdmi_quantization_range rgb_quant_range)
 {
+   const 

Re: [PATCH 4/4] drm/edid: Add display_info.rgb_quant_range_selectable

2018-11-28 Thread Alex Deucher
On Wed, Nov 28, 2018 at 12:19 PM Eric Anholt  wrote:
>
> Ville Syrjala  writes:
>
> > From: Ville Syrjälä 
> >
> > Move the CEA-861 QS bit handling entirely into the edid code. No
> > need to bother the drivers with this.
> >
> > Cc: Alex Deucher 
> > Cc: "Christian König" 
> > Cc: "David (ChunMing) Zhou" 
> > Cc: amd-gfx@lists.freedesktop.org
> > Cc: Eric Anholt  (supporter:DRM DRIVERS FOR VC4)
> > Signed-off-by: Ville Syrjälä 
>
> For vc4,
> Acked-by: Eric Anholt 
>
> Looks like a nice cleanup!

for radeon:
Acked-by: Alex Deucher 
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


Re: [PATCH 4/4] drm/edid: Add display_info.rgb_quant_range_selectable

2018-11-28 Thread Eric Anholt
Ville Syrjala  writes:

> From: Ville Syrjälä 
>
> Move the CEA-861 QS bit handling entirely into the edid code. No
> need to bother the drivers with this.
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: "David (ChunMing) Zhou" 
> Cc: amd-gfx@lists.freedesktop.org
> Cc: Eric Anholt  (supporter:DRM DRIVERS FOR VC4)
> Signed-off-by: Ville Syrjälä 

For vc4,
Acked-by: Eric Anholt 

Looks like a nice cleanup!


signature.asc
Description: PGP signature
___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[PATCH 4/4] drm/edid: Add display_info.rgb_quant_range_selectable

2018-11-20 Thread Ville Syrjala
From: Ville Syrjälä 

Move the CEA-861 QS bit handling entirely into the edid code. No
need to bother the drivers with this.

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: "David (ChunMing) Zhou" 
Cc: amd-gfx@lists.freedesktop.org
Cc: Eric Anholt  (supporter:DRM DRIVERS FOR VC4)
Signed-off-by: Ville Syrjälä 
---
 drivers/gpu/drm/drm_edid.c| 70 ---
 drivers/gpu/drm/i915/intel_drv.h  |  1 -
 drivers/gpu/drm/i915/intel_hdmi.c |  8 +--
 drivers/gpu/drm/i915/intel_lspcon.c   |  3 +-
 drivers/gpu/drm/i915/intel_sdvo.c |  7 +--
 drivers/gpu/drm/radeon/radeon_audio.c |  3 +-
 drivers/gpu/drm/vc4/vc4_hdmi.c|  9 +---
 include/drm/drm_connector.h   |  6 +++
 include/drm/drm_edid.h|  4 +-
 9 files changed, 43 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 501ac05ba7da..cbee2f745548 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3641,6 +3641,20 @@ static bool cea_db_is_hdmi_forum_vsdb(const u8 *db)
return oui == HDMI_FORUM_IEEE_OUI;
 }
 
+static bool cea_db_is_vcdb(const u8 *db)
+{
+   if (cea_db_tag(db) != USE_EXTENDED_TAG)
+   return false;
+
+   if (cea_db_payload_len(db) != 2)
+   return false;
+
+   if (cea_db_extended_tag(db) != EXT_VIDEO_CAPABILITY_BLOCK)
+   return false;
+
+   return true;
+}
+
 static bool cea_db_is_y420cmdb(const u8 *db)
 {
if (cea_db_tag(db) != USE_EXTENDED_TAG)
@@ -4223,41 +4237,6 @@ bool drm_detect_monitor_audio(struct edid *edid)
 }
 EXPORT_SYMBOL(drm_detect_monitor_audio);
 
-/**
- * drm_rgb_quant_range_selectable - is RGB quantization range selectable?
- * @edid: EDID block to scan
- *
- * Check whether the monitor reports the RGB quantization range selection
- * as supported. The AVI infoframe can then be used to inform the monitor
- * which quantization range (full or limited) is used.
- *
- * Return: True if the RGB quantization range is selectable, false otherwise.
- */
-bool drm_rgb_quant_range_selectable(struct edid *edid)
-{
-   u8 *edid_ext;
-   int i, start, end;
-
-   edid_ext = drm_find_cea_extension(edid);
-   if (!edid_ext)
-   return false;
-
-   if (cea_db_offsets(edid_ext, , ))
-   return false;
-
-   for_each_cea_db(edid_ext, i, start, end) {
-   if (cea_db_tag(_ext[i]) == USE_EXTENDED_TAG &&
-   cea_db_payload_len(_ext[i]) == 2 &&
-   cea_db_extended_tag(_ext[i]) ==
-   EXT_VIDEO_CAPABILITY_BLOCK) {
-   DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", edid_ext[i + 2]);
-   return edid_ext[i + 2] & EDID_CEA_VCDB_QS;
-   }
-   }
-
-   return false;
-}
-EXPORT_SYMBOL(drm_rgb_quant_range_selectable);
 
 /**
  * drm_default_rgb_quant_range - default RGB quantization range
@@ -4278,6 +4257,16 @@ drm_default_rgb_quant_range(const struct 
drm_display_mode *mode)
 }
 EXPORT_SYMBOL(drm_default_rgb_quant_range);
 
+static void drm_parse_vcdb(struct drm_connector *connector, const u8 *db)
+{
+   struct drm_display_info *info = >display_info;
+
+   DRM_DEBUG_KMS("CEA VCDB 0x%02x\n", db[2]);
+
+   if (db[2] & EDID_CEA_VCDB_QS)
+   info->rgb_quant_range_selectable = true;
+}
+
 static void drm_parse_ycbcr420_deep_color_info(struct drm_connector *connector,
   const u8 *db)
 {
@@ -4452,6 +4441,8 @@ static void drm_parse_cea_ext(struct drm_connector 
*connector,
drm_parse_hdmi_forum_vsdb(connector, db);
if (cea_db_is_y420cmdb(db))
drm_parse_y420cmdb_bitmap(connector, db);
+   if (cea_db_is_vcdb(db))
+   drm_parse_vcdb(connector, db);
}
 }
 
@@ -4472,6 +4463,7 @@ drm_reset_display_info(struct drm_connector *connector)
info->max_tmds_clock = 0;
info->dvi_dual = false;
info->has_hdmi_infoframe = false;
+   info->rgb_quant_range_selectable = false;
memset(>hdmi, 0, sizeof(info->hdmi));
 
info->non_desktop = 0;
@@ -4939,15 +4931,15 @@ EXPORT_SYMBOL(drm_hdmi_avi_infoframe_from_display_mode);
  * @connector: the connector
  * @mode: DRM display mode
  * @rgb_quant_range: RGB quantization range (Q)
- * @rgb_quant_range_selectable: Sink support selectable RGB quantization range 
(QS)
  */
 void
 drm_hdmi_avi_infoframe_quant_range(struct hdmi_avi_infoframe *frame,
   struct drm_connector *connector,
   const struct drm_display_mode *mode,
-  enum hdmi_quantization_range rgb_quant_range,
-  bool rgb_quant_range_selectable)
+  enum hdmi_quantization_range rgb_quant_range)
 {
+   const struct drm_display_info *info = >display_info;
+