Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <shashank.sharma@intel.com>
Signed-off-by: Lin, Jia <lin.a.jia@intel.com>
Signed-off-by: Akashdeep Sharma <akashdeep.sharma@intel.com>
Reviewed-by: Jim Bride <jim.bride@linux.intel.com>
Reviewed-by: Jose Abreu <Jose.Abreu@synopsys.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1476705880-15600-3-git-send-email-shashank.sharma@intel.com

authored by

Shashank Sharma and committed by
Daniel Vetter
6dffd431 876f43c0

+31
+31
drivers/gpu/drm/drm_modes.c
··· 997 997 mode1->vsync_end == mode2->vsync_end && 998 998 mode1->vtotal == mode2->vtotal && 999 999 mode1->vscan == mode2->vscan && 1000 + mode1->picture_aspect_ratio == mode2->picture_aspect_ratio && 1000 1001 (mode1->flags & ~DRM_MODE_FLAG_3D_MASK) == 1001 1002 (mode2->flags & ~DRM_MODE_FLAG_3D_MASK)) 1002 1003 return true; ··· 1500 1499 out->vrefresh = in->vrefresh; 1501 1500 out->flags = in->flags; 1502 1501 out->type = in->type; 1502 + out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK; 1503 + 1504 + switch (in->picture_aspect_ratio) { 1505 + case HDMI_PICTURE_ASPECT_4_3: 1506 + out->flags |= DRM_MODE_FLAG_PIC_AR_4_3; 1507 + break; 1508 + case HDMI_PICTURE_ASPECT_16_9: 1509 + out->flags |= DRM_MODE_FLAG_PIC_AR_16_9; 1510 + break; 1511 + case HDMI_PICTURE_ASPECT_RESERVED: 1512 + default: 1513 + out->flags |= DRM_MODE_FLAG_PIC_AR_NONE; 1514 + break; 1515 + } 1516 + 1503 1517 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); 1504 1518 out->name[DRM_DISPLAY_MODE_LEN-1] = 0; 1505 1519 } ··· 1559 1543 out->type = in->type; 1560 1544 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); 1561 1545 out->name[DRM_DISPLAY_MODE_LEN-1] = 0; 1546 + 1547 + /* Clearing picture aspect ratio bits from out flags */ 1548 + out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK; 1549 + 1550 + switch (in->flags & DRM_MODE_FLAG_PIC_AR_MASK) { 1551 + case DRM_MODE_FLAG_PIC_AR_4_3: 1552 + out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_4_3; 1553 + break; 1554 + case DRM_MODE_FLAG_PIC_AR_16_9: 1555 + out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9; 1556 + break; 1557 + default: 1558 + out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE; 1559 + break; 1560 + } 1562 1561 1563 1562 out->status = drm_mode_validate_basic(out); 1564 1563 if (out->status != MODE_OK)