diff mbox

adv7511: Set picture aspect ratio

Message ID 6291bd2d7940b78d0c476ab7ec28696c923dca4c.1458743880.git.joabreu@synopsys.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jose Abreu March 23, 2016, 4:07 p.m. UTC
As of current version the picture aspect ratio and active
aspect ratio are not being set when the video mode changes.
This patch fixes this problem by setting the picture aspect
ratio according to the current video mode and also sets the
active aspect ratio to be the same as picture aspect ratio.

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/gpu/drm/i2c/adv7511.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index a02112b..c9aa83a 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -672,7 +672,7 @@  static void adv7511_encoder_mode_set(struct drm_encoder *encoder,
 				     struct drm_display_mode *adj_mode)
 {
 	struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-	unsigned int low_refresh_rate;
+	unsigned int low_refresh_rate, picture_aspect;
 	unsigned int hsync_polarity = 0;
 	unsigned int vsync_polarity = 0;
 
@@ -754,6 +754,26 @@  static void adv7511_encoder_mode_set(struct drm_encoder *encoder,
 	regmap_update_bits(adv7511->regmap, 0x17,
 		0x60, (vsync_polarity << 6) | (hsync_polarity << 5));
 
+	switch (adj_mode->picture_aspect_ratio) {
+	case HDMI_PICTURE_ASPECT_NONE:
+		picture_aspect = 0x0;
+		break;
+	case HDMI_PICTURE_ASPECT_4_3:
+		picture_aspect = 0x1;
+		break;
+	case HDMI_PICTURE_ASPECT_16_9:
+		picture_aspect = 0x2;
+		break;
+	default:
+		picture_aspect = 0x3;
+		break;
+	}
+
+	regmap_update_bits(adv7511->regmap, ADV7511_REG_AVI_INFOFRAME(1),
+		0x30, (picture_aspect << 4));
+	regmap_update_bits(adv7511->regmap, ADV7511_REG_AVI_INFOFRAME(1),
+		0x0F, 0x08);
+
 	/*
 	 * TODO Test first order 4:2:2 to 4:4:4 up conversion method, which is
 	 * supposed to give better results.