[2/4] drm/edid: Extract drm_mode_cea_vic()
diff mbox series

Message ID 20191004141914.20600-2-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • [1/4] drm/edid: Make drm_get_cea_aspect_ratio() static
Related show

Commit Message

Ville Syrjälä Oct. 4, 2019, 2:19 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Extract the logic to compute the final CEA VIC to a small helper.
We'll reorder it a bit to make future modifications more
straightforward. No function changes.

Cc: Wayne Lin <waynelin@amd.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 53 +++++++++++++++++++++-----------------
 1 file changed, 30 insertions(+), 23 deletions(-)

Comments

Shankar, Uma Oct. 18, 2019, 12:51 p.m. UTC | #1
>-----Original Message-----
>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjala
>Sent: Friday, October 4, 2019 7:49 PM
>To: dri-devel@lists.freedesktop.org
>Cc: intel-gfx@lists.freedesktop.org; Wayne Lin <waynelin@amd.com>
>Subject: [Intel-gfx] [PATCH 2/4] drm/edid: Extract drm_mode_cea_vic()
>
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>Extract the logic to compute the final CEA VIC to a small helper.
>We'll reorder it a bit to make future modifications more straightforward. No function
>changes.

Changes look good to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

>Cc: Wayne Lin <waynelin@amd.com>
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>---
> drivers/gpu/drm/drm_edid.c | 53 +++++++++++++++++++++-----------------
> 1 file changed, 30 insertions(+), 23 deletions(-)
>
>diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
>3df8267adab9..495b7fb4d9ef 100644
>--- a/drivers/gpu/drm/drm_edid.c
>+++ b/drivers/gpu/drm/drm_edid.c
>@@ -5160,6 +5160,35 @@ drm_hdmi_infoframe_set_hdr_metadata(struct
>hdmi_drm_infoframe *frame,  }
>EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
>
>+static u8 drm_mode_cea_vic(struct drm_connector *connector,
>+			   const struct drm_display_mode *mode) {
>+	u8 vendor_if_vic = drm_match_hdmi_mode(mode);
>+	bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
>+	u8 vic;
>+
>+	/*
>+	 * HDMI spec says if a mode is found in HDMI 1.4b 4K modes
>+	 * we should send its VIC in vendor infoframes, else send the
>+	 * VIC in AVI infoframes. Lets check if this mode is present in
>+	 * HDMI 1.4b 4K modes
>+	 */
>+	if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
>+		return 0;
>+
>+	vic = drm_match_cea_mode(mode);
>+
>+	/*
>+	 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
>+	 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
>+	 * have to make sure we dont break HDMI 1.4 sinks.
>+	 */
>+	if (!is_hdmi2_sink(connector) && vic > 64)
>+		return 0;
>+
>+	return vic;
>+}
>+
> /**
>  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
>  *                                              data from a DRM display mode
>@@ -5187,29 +5216,7 @@ drm_hdmi_avi_infoframe_from_display_mode(struct
>hdmi_avi_infoframe *frame,
> 	if (mode->flags & DRM_MODE_FLAG_DBLCLK)
> 		frame->pixel_repeat = 1;
>
>-	frame->video_code = drm_match_cea_mode(mode);
>-
>-	/*
>-	 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
>-	 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
>-	 * have to make sure we dont break HDMI 1.4 sinks.
>-	 */
>-	if (!is_hdmi2_sink(connector) && frame->video_code > 64)
>-		frame->video_code = 0;
>-
>-	/*
>-	 * HDMI spec says if a mode is found in HDMI 1.4b 4K modes
>-	 * we should send its VIC in vendor infoframes, else send the
>-	 * VIC in AVI infoframes. Lets check if this mode is present in
>-	 * HDMI 1.4b 4K modes
>-	 */
>-	if (frame->video_code) {
>-		u8 vendor_if_vic = drm_match_hdmi_mode(mode);
>-		bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
>-
>-		if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
>-			frame->video_code = 0;
>-	}
>+	frame->video_code = drm_mode_cea_vic(connector, mode);
>
> 	frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;
>
>--
>2.21.0
>
>_______________________________________________
>Intel-gfx mailing list
>Intel-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Patch
diff mbox series

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 3df8267adab9..495b7fb4d9ef 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -5160,6 +5160,35 @@  drm_hdmi_infoframe_set_hdr_metadata(struct hdmi_drm_infoframe *frame,
 }
 EXPORT_SYMBOL(drm_hdmi_infoframe_set_hdr_metadata);
 
+static u8 drm_mode_cea_vic(struct drm_connector *connector,
+			   const struct drm_display_mode *mode)
+{
+	u8 vendor_if_vic = drm_match_hdmi_mode(mode);
+	bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
+	u8 vic;
+
+	/*
+	 * HDMI spec says if a mode is found in HDMI 1.4b 4K modes
+	 * we should send its VIC in vendor infoframes, else send the
+	 * VIC in AVI infoframes. Lets check if this mode is present in
+	 * HDMI 1.4b 4K modes
+	 */
+	if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
+		return 0;
+
+	vic = drm_match_cea_mode(mode);
+
+	/*
+	 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
+	 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
+	 * have to make sure we dont break HDMI 1.4 sinks.
+	 */
+	if (!is_hdmi2_sink(connector) && vic > 64)
+		return 0;
+
+	return vic;
+}
+
 /**
  * drm_hdmi_avi_infoframe_from_display_mode() - fill an HDMI AVI infoframe with
  *                                              data from a DRM display mode
@@ -5187,29 +5216,7 @@  drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
 	if (mode->flags & DRM_MODE_FLAG_DBLCLK)
 		frame->pixel_repeat = 1;
 
-	frame->video_code = drm_match_cea_mode(mode);
-
-	/*
-	 * HDMI 1.4 VIC range: 1 <= VIC <= 64 (CEA-861-D) but
-	 * HDMI 2.0 VIC range: 1 <= VIC <= 107 (CEA-861-F). So we
-	 * have to make sure we dont break HDMI 1.4 sinks.
-	 */
-	if (!is_hdmi2_sink(connector) && frame->video_code > 64)
-		frame->video_code = 0;
-
-	/*
-	 * HDMI spec says if a mode is found in HDMI 1.4b 4K modes
-	 * we should send its VIC in vendor infoframes, else send the
-	 * VIC in AVI infoframes. Lets check if this mode is present in
-	 * HDMI 1.4b 4K modes
-	 */
-	if (frame->video_code) {
-		u8 vendor_if_vic = drm_match_hdmi_mode(mode);
-		bool is_s3d = mode->flags & DRM_MODE_FLAG_3D_MASK;
-
-		if (drm_valid_hdmi_vic(vendor_if_vic) && !is_s3d)
-			frame->video_code = 0;
-	}
+	frame->video_code = drm_mode_cea_vic(connector, mode);
 
 	frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;