Skip to content

Commit 6dffd43

Browse files
contactshashanksharmadanvet
authored andcommitted
drm: Add aspect ratio parsing in DRM layer
Current DRM layer functions don't parse aspect ratio information while converting a user mode->kernel mode or vice versa. This causes modeset to pick mode with wrong aspect ratio, eventually causing failures in HDMI compliance test cases, due to wrong VIC. This patch adds aspect ratio information in DRM's mode conversion and mode comparision functions, to make sure kernel picks mode with right aspect ratio (as per the VIC). V2: Addressed review comments from Sean: - Fix spellings/typo - No need to handle aspect ratio none - Add a break, for default case too V3: Rebase V4: Added r-b from Jose Signed-off-by: Shashank Sharma <[email protected]> Signed-off-by: Lin, Jia <[email protected]> Signed-off-by: Akashdeep Sharma <[email protected]> Reviewed-by: Jim Bride <[email protected]> Reviewed-by: Jose Abreu <[email protected]> Cc: Daniel Vetter <[email protected]> Cc: Emil Velikov <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 876f43c commit 6dffd43

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

drivers/gpu/drm/drm_modes.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1,
997997
mode1->vsync_end == mode2->vsync_end &&
998998
mode1->vtotal == mode2->vtotal &&
999999
mode1->vscan == mode2->vscan &&
1000+
mode1->picture_aspect_ratio == mode2->picture_aspect_ratio &&
10001001
(mode1->flags & ~DRM_MODE_FLAG_3D_MASK) ==
10011002
(mode2->flags & ~DRM_MODE_FLAG_3D_MASK))
10021003
return true;
@@ -1499,6 +1500,21 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
14991500
out->vrefresh = in->vrefresh;
15001501
out->flags = in->flags;
15011502
out->type = in->type;
1503+
out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
1504+
1505+
switch (in->picture_aspect_ratio) {
1506+
case HDMI_PICTURE_ASPECT_4_3:
1507+
out->flags |= DRM_MODE_FLAG_PIC_AR_4_3;
1508+
break;
1509+
case HDMI_PICTURE_ASPECT_16_9:
1510+
out->flags |= DRM_MODE_FLAG_PIC_AR_16_9;
1511+
break;
1512+
case HDMI_PICTURE_ASPECT_RESERVED:
1513+
default:
1514+
out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
1515+
break;
1516+
}
1517+
15021518
strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
15031519
out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
15041520
}
@@ -1544,6 +1560,21 @@ int drm_mode_convert_umode(struct drm_display_mode *out,
15441560
strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
15451561
out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
15461562

1563+
/* Clearing picture aspect ratio bits from out flags */
1564+
out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
1565+
1566+
switch (in->flags & DRM_MODE_FLAG_PIC_AR_MASK) {
1567+
case DRM_MODE_FLAG_PIC_AR_4_3:
1568+
out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_4_3;
1569+
break;
1570+
case DRM_MODE_FLAG_PIC_AR_16_9:
1571+
out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
1572+
break;
1573+
default:
1574+
out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
1575+
break;
1576+
}
1577+
15471578
out->status = drm_mode_validate_basic(out);
15481579
if (out->status != MODE_OK)
15491580
goto out;

0 commit comments

Comments
 (0)