diff mbox

[3/5] drm/radeon: Setup HDMI_CONTROL for hdmi deep color gcp's.

Message ID 1400627871-18107-3-git-send-email-alexander.deucher@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Deucher May 20, 2014, 11:17 p.m. UTC
From: Mario Kleiner <mario.kleiner.de@gmail.com>

Program HDMI_CONTROL to send general control packets
for hdmi deep color mode signalling at every video
frame if bpc > 8.

This is only supported on evergreen / DCE-4 and later.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/radeon/evergreen_hdmi.c | 38 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/radeon/evergreend.h     |  3 ++-
 2 files changed, 40 insertions(+), 1 deletion(-)

Comments

Rafał Miłecki May 21, 2014, 5:58 a.m. UTC | #1
On 21 May 2014 01:17, Alex Deucher <alexdeucher@gmail.com> wrote:
> +       val = RREG32(HDMI_CONTROL + offset);
> +       val &= ~HDMI_DEEP_COLOR_ENABLE;
> +       val &= ~HDMI_DEEP_COLOR_DEPTH_MASK;
> +

> +       switch (bpc) {
> (...)
> +       }
> +
> +       WREG32(HDMI_CONTROL + offset, val);

What about using helper:

WREG32_P(HDMI_CONTROL + offset,
val,
~(HDMI_DEEP_COLOR_ENABLE | HDMI_DEEP_COLOR_DEPTH_MASK));
Alex Deucher May 21, 2014, 1:51 p.m. UTC | #2
On Wed, May 21, 2014 at 1:58 AM, Rafa? Mi?ecki <zajec5@gmail.com> wrote:
> On 21 May 2014 01:17, Alex Deucher <alexdeucher@gmail.com> wrote:
>> +       val = RREG32(HDMI_CONTROL + offset);
>> +       val &= ~HDMI_DEEP_COLOR_ENABLE;
>> +       val &= ~HDMI_DEEP_COLOR_DEPTH_MASK;
>> +
>
>> +       switch (bpc) {
>> (...)
>> +       }
>> +
>> +       WREG32(HDMI_CONTROL + offset, val);
>
> What about using helper:
>
> WREG32_P(HDMI_CONTROL + offset,
> val,
> ~(HDMI_DEEP_COLOR_ENABLE | HDMI_DEEP_COLOR_DEPTH_MASK));

We could.  I don't think it really makes much difference one way or
the other though.  I don't really have a strong preference.

Alex
Rafał Miłecki May 21, 2014, 1:58 p.m. UTC | #3
On 21 May 2014 15:51, Alex Deucher <alexdeucher@gmail.com> wrote:
> On Wed, May 21, 2014 at 1:58 AM, Rafa? Mi?ecki <zajec5@gmail.com> wrote:
>> What about using helper:
>>
>> WREG32_P(HDMI_CONTROL + offset,
>> val,
>> ~(HDMI_DEEP_COLOR_ENABLE | HDMI_DEEP_COLOR_DEPTH_MASK));
>
> We could.  I don't think it really makes much difference one way or
> the other though.  I don't really have a strong preference.

OK. It's up to you.
diff mbox

Patch

diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c
index 05b0c95..f9842ae 100644
--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c
+++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c
@@ -293,10 +293,13 @@  void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
 	struct radeon_device *rdev = dev->dev_private;
 	struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 	struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
+	struct drm_connector *connector = radeon_get_connector_for_encoder(encoder);
 	u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE];
 	struct hdmi_avi_infoframe frame;
 	uint32_t offset;
 	ssize_t err;
+	uint32_t val;
+	int bpc = 8;
 
 	if (!dig || !dig->afmt)
 		return;
@@ -322,6 +325,41 @@  void evergreen_hdmi_setmode(struct drm_encoder *encoder, struct drm_display_mode
 
 	WREG32(AFMT_AUDIO_CRC_CONTROL + offset, 0x1000);
 
+	/* hdmi deep color mode general control packets setup, if bpc > 8 */
+	if (encoder->crtc) {
+		struct radeon_crtc *radeon_crtc = to_radeon_crtc(encoder->crtc);
+		bpc = radeon_crtc->bpc;
+	}
+
+	val = RREG32(HDMI_CONTROL + offset);
+	val &= ~HDMI_DEEP_COLOR_ENABLE;
+	val &= ~HDMI_DEEP_COLOR_DEPTH_MASK;
+
+	switch (bpc) {
+		case 0:
+		case 6:
+		case 8:
+		case 16:
+		default:
+			DRM_DEBUG("%s: Disabling hdmi deep color for %d bpc.\n",
+					 drm_get_connector_name(connector), bpc);
+			break;
+		case 10:
+			val |= HDMI_DEEP_COLOR_ENABLE;
+			val |= HDMI_DEEP_COLOR_DEPTH(HDMI_30BIT_DEEP_COLOR);
+			DRM_DEBUG("%s: Enabling hdmi deep color 30 for 10 bpc.\n",
+					 drm_get_connector_name(connector));
+			break;
+		case 12:
+			val |= HDMI_DEEP_COLOR_ENABLE;
+			val |= HDMI_DEEP_COLOR_DEPTH(HDMI_36BIT_DEEP_COLOR);
+			DRM_DEBUG("%s: Enabling hdmi deep color 36 for 12 bpc.\n",
+					 drm_get_connector_name(connector));
+			break;
+	}
+
+	WREG32(HDMI_CONTROL + offset, val);
+
 	WREG32(HDMI_VBI_PACKET_CONTROL + offset,
 	       HDMI_NULL_SEND | /* send null packets when required */
 	       HDMI_GC_SEND | /* send general control packets */
diff --git a/drivers/gpu/drm/radeon/evergreend.h b/drivers/gpu/drm/radeon/evergreend.h
index f9c7963..b066d67 100644
--- a/drivers/gpu/drm/radeon/evergreend.h
+++ b/drivers/gpu/drm/radeon/evergreend.h
@@ -517,10 +517,11 @@ 
 #       define HDMI_ERROR_ACK                (1 << 8)
 #       define HDMI_ERROR_MASK               (1 << 9)
 #       define HDMI_DEEP_COLOR_ENABLE        (1 << 24)
-#       define HDMI_DEEP_COLOR_DEPTH         (((x) & 3) << 28)
+#       define HDMI_DEEP_COLOR_DEPTH(x)      (((x) & 3) << 28)
 #       define HDMI_24BIT_DEEP_COLOR         0
 #       define HDMI_30BIT_DEEP_COLOR         1
 #       define HDMI_36BIT_DEEP_COLOR         2
+#       define HDMI_DEEP_COLOR_DEPTH_MASK    (3 << 28)
 #define HDMI_STATUS                          0x7034
 #       define HDMI_ACTIVE_AVMUTE            (1 << 0)
 #       define HDMI_AUDIO_PACKET_ERROR       (1 << 16)