Re: [PATCH 08/18] drm/vc4: hdmi: Use full range helper in csc functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





Am 17.03.21 um 16:43 schrieb Maxime Ripard:
The CSC callbacks takes a boolean as an argument to tell whether we're
using the full range or limited range RGB.

However, with the upcoming YUV support, the logic will be a bit more
complex. In order to address this, let's make the callbacks take the
entire mode, and call our new helper to tell whether the full or limited
range RGB should be used.

Signed-off-by: Maxime Ripard <maxime@xxxxxxxxxx>

Acked-by: Thomas Zimmermann <tzimmermann@xxxxxxx>

---
  drivers/gpu/drm/vc4/vc4_hdmi.c | 14 ++++++++------
  drivers/gpu/drm/vc4/vc4_hdmi.h |  3 ++-
  2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index fc545072b173..bb2fffa2d495 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -494,14 +494,15 @@ static void vc4_hdmi_encoder_disable(struct drm_encoder *encoder)
  {
  }
-static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable)
+static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi,
+			       const struct drm_display_mode *mode)
  {
  	u32 csc_ctl;
csc_ctl = VC4_SET_FIELD(VC4_HD_CSC_CTL_ORDER_BGR,
  				VC4_HD_CSC_CTL_ORDER);
- if (enable) {
+	if (!vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode)) {
  		/* CEA VICs other than #1 requre limited range RGB
  		 * output unless overridden by an AVI infoframe.
  		 * Apply a colorspace conversion to squash 0-255 down
@@ -529,13 +530,14 @@ static void vc4_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable)
  	HDMI_WRITE(HDMI_CSC_CTL, csc_ctl);
  }
-static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi, bool enable)
+static void vc5_hdmi_csc_setup(struct vc4_hdmi *vc4_hdmi,
+			       const struct drm_display_mode *mode)
  {
  	u32 csc_ctl;
csc_ctl = 0x07; /* RGB_CONVERT_MODE = custom matrix, || USE_RGB_TO_YCBCR */ - if (enable) {
+	if (vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode)) {
  		/* CEA VICs other than #1 requre limited range RGB
  		 * output unless overridden by an AVI infoframe.
  		 * Apply a colorspace conversion to squash 0-255 down
@@ -844,12 +846,12 @@ static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
if (vc4_hdmi_is_full_range_rgb(vc4_hdmi, mode) {
  		if (vc4_hdmi->variant->csc_setup)
-			vc4_hdmi->variant->csc_setup(vc4_hdmi, true);
+			vc4_hdmi->variant->csc_setup(vc4_hdmi, mode);
vc4_encoder->limited_rgb_range = true;
  	} else {
  		if (vc4_hdmi->variant->csc_setup)
-			vc4_hdmi->variant->csc_setup(vc4_hdmi, false);
+			vc4_hdmi->variant->csc_setup(vc4_hdmi, mode);
vc4_encoder->limited_rgb_range = false;
  	}
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.h b/drivers/gpu/drm/vc4/vc4_hdmi.h
index 3cebd1fd00fc..3d88261d463e 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.h
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
@@ -77,7 +77,8 @@ struct vc4_hdmi_variant {
  	void (*reset)(struct vc4_hdmi *vc4_hdmi);
/* Callback to enable / disable the CSC */
-	void (*csc_setup)(struct vc4_hdmi *vc4_hdmi, bool enable);
+	void (*csc_setup)(struct vc4_hdmi *vc4_hdmi,
+			  const struct drm_display_mode *mode);
/* Callback to configure the video timings in the HDMI block */
  	void (*set_timings)(struct vc4_hdmi *vc4_hdmi,


--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel

[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux