diff mbox

drm/exynos: set the active aspect ratio as per mode

Message ID 1394688508-5429-2-git-send-email-s.shirish@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Shirish S March 13, 2014, 5:28 a.m. UTC
Now that the drm_display_mode also provides aspect
ratio for all resolutions, this patch adds its usage
to set the active aspect ratio of AVI info frame
packets as per CEA-861-D standard's Table 9.

This is also needed to abide by the 7-27
compliance test of HDMI.

Signed-off-by: Shirish S <s.shirish@samsung.com>
---
V2: rebased on new branch
V3: Incorporated review comments

 drivers/gpu/drm/exynos/exynos_hdmi.c |   35 +++++++++++++++++++++++++++-------
 1 file changed, 28 insertions(+), 7 deletions(-)

Comments

Tomasz Figa March 18, 2014, 1:04 p.m. UTC | #1
Hi Shirish,

On 13.03.2014 06:28, Shirish S wrote:
> Now that the drm_display_mode also provides aspect
> ratio for all resolutions, this patch adds its usage
> to set the active aspect ratio of AVI info frame
> packets as per CEA-861-D standard's Table 9.
>
> This is also needed to abide by the 7-27
> compliance test of HDMI.
>
> Signed-off-by: Shirish S <s.shirish@samsung.com>
> ---
> V2: rebased on new branch
> V3: Incorporated review comments
>
>   drivers/gpu/drm/exynos/exynos_hdmi.c |   35 +++++++++++++++++++++++++++-------
>   1 file changed, 28 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
> index 12fdf55..9b0b617 100644
> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
> @@ -53,12 +53,13 @@
>   /* AVI header and aspect ratio */
>   #define HDMI_AVI_VERSION		0x02
>   #define HDMI_AVI_LENGTH		0x0D
> -#define AVI_PIC_ASPECT_RATIO_16_9	(2 << 4)
> -#define AVI_SAME_AS_PIC_ASPECT_RATIO	8
>
>   /* AUI header info */
>   #define HDMI_AUI_VERSION	0x01
>   #define HDMI_AUI_LENGTH	0x0A
> +#define	AVI_SAME_AS_PIC_ASPECT_RATIO 0x8
> +#define	AVI_4_3_CENTER_RATIO	0x9
> +#define	AVI_16_9_CENTER_RATIO	0xa

One minor nitpick: Please don't use tabs between #define and macro name.

After fixing this issue feel free to add my:

Reviewed-by: Tomasz Figa <t.figa@samsung.com>

Best regards,
Tomasz
Inki Dae March 19, 2014, 8:25 a.m. UTC | #2
2014-03-18 22:04 GMT+09:00 Tomasz Figa <t.figa@samsung.com>:
> Hi Shirish,
>
>
> On 13.03.2014 06:28, Shirish S wrote:
>>
>> Now that the drm_display_mode also provides aspect
>> ratio for all resolutions, this patch adds its usage
>> to set the active aspect ratio of AVI info frame
>> packets as per CEA-861-D standard's Table 9.
>>
>> This is also needed to abide by the 7-27
>> compliance test of HDMI.
>>
>> Signed-off-by: Shirish S <s.shirish@samsung.com>
>> ---
>> V2: rebased on new branch
>> V3: Incorporated review comments
>>
>>   drivers/gpu/drm/exynos/exynos_hdmi.c |   35
>> +++++++++++++++++++++++++++-------
>>   1 file changed, 28 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c
>> b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> index 12fdf55..9b0b617 100644
>> --- a/drivers/gpu/drm/exynos/exynos_hdmi.c
>> +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
>> @@ -53,12 +53,13 @@
>>   /* AVI header and aspect ratio */
>>   #define HDMI_AVI_VERSION              0x02
>>   #define HDMI_AVI_LENGTH               0x0D
>> -#define AVI_PIC_ASPECT_RATIO_16_9      (2 << 4)
>> -#define AVI_SAME_AS_PIC_ASPECT_RATIO   8
>>
>>   /* AUI header info */
>>   #define HDMI_AUI_VERSION      0x01
>>   #define HDMI_AUI_LENGTH       0x0A
>> +#define        AVI_SAME_AS_PIC_ASPECT_RATIO 0x8
>> +#define        AVI_4_3_CENTER_RATIO    0x9
>> +#define        AVI_16_9_CENTER_RATIO   0xa
>
>
> One minor nitpick: Please don't use tabs between #define and macro name.
>

Fixed and applied.

Thanks,
Inki Dae

> After fixing this issue feel free to add my:
>
> Reviewed-by: Tomasz Figa <t.figa@samsung.com>
>
> Best regards,
> Tomasz
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c
index 12fdf55..9b0b617 100644
--- a/drivers/gpu/drm/exynos/exynos_hdmi.c
+++ b/drivers/gpu/drm/exynos/exynos_hdmi.c
@@ -53,12 +53,13 @@ 
 /* AVI header and aspect ratio */
 #define HDMI_AVI_VERSION		0x02
 #define HDMI_AVI_LENGTH		0x0D
-#define AVI_PIC_ASPECT_RATIO_16_9	(2 << 4)
-#define AVI_SAME_AS_PIC_ASPECT_RATIO	8
 
 /* AUI header info */
 #define HDMI_AUI_VERSION	0x01
 #define HDMI_AUI_LENGTH	0x0A
+#define	AVI_SAME_AS_PIC_ASPECT_RATIO 0x8
+#define	AVI_4_3_CENTER_RATIO	0x9
+#define	AVI_16_9_CENTER_RATIO	0xa
 
 enum hdmi_type {
 	HDMI_TYPE13,
@@ -162,6 +163,7 @@  struct hdmi_v14_conf {
 struct hdmi_conf_regs {
 	int pixel_clock;
 	int cea_video_id;
+	enum hdmi_picture_aspect aspect_ratio;
 	union {
 		struct hdmi_v13_conf v13_conf;
 		struct hdmi_v14_conf v14_conf;
@@ -669,7 +671,6 @@  static void hdmi_reg_infoframe(struct hdmi_context *hdata,
 {
 	u32 hdr_sum;
 	u8 chksum;
-	u32 aspect_ratio;
 	u32 mod;
 	u32 vic;
 
@@ -698,10 +699,28 @@  static void hdmi_reg_infoframe(struct hdmi_context *hdata,
 			AVI_ACTIVE_FORMAT_VALID |
 			AVI_UNDERSCANNED_DISPLAY_VALID);
 
-		aspect_ratio = AVI_PIC_ASPECT_RATIO_16_9;
-
-		hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2), aspect_ratio |
-				AVI_SAME_AS_PIC_ASPECT_RATIO);
+		/*
+		 * Set the aspect ratio as per the mode, mentioned in
+		 * Table 9 AVI InfoFrame Data Byte 2 of CEA-861-D Standard
+		 */
+		switch (hdata->mode_conf.aspect_ratio) {
+		case HDMI_PICTURE_ASPECT_4_3:
+			hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+					hdata->mode_conf.aspect_ratio |
+					AVI_4_3_CENTER_RATIO);
+			break;
+		case HDMI_PICTURE_ASPECT_16_9:
+			hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+					hdata->mode_conf.aspect_ratio |
+					AVI_16_9_CENTER_RATIO);
+			break;
+		case HDMI_PICTURE_ASPECT_NONE:
+		default:
+			hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(2),
+					hdata->mode_conf.aspect_ratio |
+					AVI_SAME_AS_PIC_ASPECT_RATIO);
+			break;
+		}
 
 		vic = hdata->mode_conf.cea_video_id;
 		hdmi_reg_writeb(hdata, HDMI_AVI_BYTE(4), vic);
@@ -1519,6 +1538,7 @@  static void hdmi_v13_mode_set(struct hdmi_context *hdata,
 	hdata->mode_conf.cea_video_id =
 		drm_match_cea_mode((struct drm_display_mode *)m);
 	hdata->mode_conf.pixel_clock = m->clock * 1000;
+	hdata->mode_conf.aspect_ratio = m->picture_aspect_ratio;
 
 	hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay);
 	hdmi_set_reg(core->h_v_line, 3, (m->htotal << 12) | m->vtotal);
@@ -1615,6 +1635,7 @@  static void hdmi_v14_mode_set(struct hdmi_context *hdata,
 	hdata->mode_conf.cea_video_id =
 		drm_match_cea_mode((struct drm_display_mode *)m);
 	hdata->mode_conf.pixel_clock = m->clock * 1000;
+	hdata->mode_conf.aspect_ratio = m->picture_aspect_ratio;
 
 	hdmi_set_reg(core->h_blank, 2, m->htotal - m->hdisplay);
 	hdmi_set_reg(core->v_line, 2, m->vtotal);