aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShashank Sharma <shashank.sharma@intel.com>2018-05-08 07:09:44 -0400
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>2018-05-11 03:23:41 -0400
commit222ec1618c3aceca1e61e1e73e559c647c2b946f (patch)
treeb9b51618aae2e0181365d242aecf0d8bedbd1434
parentc3ff0cdb354f89a5b877eee61af70e6ae51de50b (diff)
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). Background: This patch was once reviewed and merged, and later reverted due to lack of DRM cap protection. This is a re-spin of this patch, this time with DRM cap protection, to avoid aspect ratio information, when the client doesn't request for it. Review link: https://pw-emeril.freedesktop.org/patch/104068/ Background discussion: https://patchwork.kernel.org/patch/9379057/ 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> (V2) Reviewed-by: Jose Abreu <Jose.Abreu@synopsys.com> (V4) Cc: Ville Syrjala <ville.syrjala@linux.intel.com> Cc: Jim Bride <jim.bride@linux.intel.com> Cc: Jose Abreu <Jose.Abreu@synopsys.com> Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com> V3: modified the aspect-ratio check in drm_mode_equal as per new flags provided by Ville. https://patchwork.freedesktop.org/patch/188043/ V4: rebase V5: rebase V6: As recommended by Ville, avoided matching of aspect-ratio in drm_fb_helper, while trying to find a common mode among connectors for the target clone mode. V7: rebase V8: rebase V9: rebase V10: rebase V11: rebase V12: rebase V13: rebase V14: rebase Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/1525777785-9740-10-git-send-email-ankit.k.nautiyal@intel.com
-rw-r--r--drivers/gpu/drm/drm_fb_helper.c12
-rw-r--r--drivers/gpu/drm/drm_modes.c35
2 files changed, 44 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c
index 0646b108030b..2ee1eaa66188 100644
--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -2183,7 +2183,11 @@ static bool drm_target_cloned(struct drm_fb_helper *fb_helper,
2183 for (j = 0; j < i; j++) { 2183 for (j = 0; j < i; j++) {
2184 if (!enabled[j]) 2184 if (!enabled[j])
2185 continue; 2185 continue;
2186 if (!drm_mode_equal(modes[j], modes[i])) 2186 if (!drm_mode_match(modes[j], modes[i],
2187 DRM_MODE_MATCH_TIMINGS |
2188 DRM_MODE_MATCH_CLOCK |
2189 DRM_MODE_MATCH_FLAGS |
2190 DRM_MODE_MATCH_3D_FLAGS))
2187 can_clone = false; 2191 can_clone = false;
2188 } 2192 }
2189 } 2193 }
@@ -2203,7 +2207,11 @@ static bool drm_target_cloned(struct drm_fb_helper *fb_helper,
2203 2207
2204 fb_helper_conn = fb_helper->connector_info[i]; 2208 fb_helper_conn = fb_helper->connector_info[i];
2205 list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) { 2209 list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) {
2206 if (drm_mode_equal(mode, dmt_mode)) 2210 if (drm_mode_match(mode, dmt_mode,
2211 DRM_MODE_MATCH_TIMINGS |
2212 DRM_MODE_MATCH_CLOCK |
2213 DRM_MODE_MATCH_FLAGS |
2214 DRM_MODE_MATCH_3D_FLAGS))
2207 modes[i] = mode; 2215 modes[i] = mode;
2208 } 2216 }
2209 if (!modes[i]) 2217 if (!modes[i])
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index c395a244f665..7dfabdd6bcc8 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1049,7 +1049,8 @@ bool drm_mode_equal(const struct drm_display_mode *mode1,
1049 DRM_MODE_MATCH_TIMINGS | 1049 DRM_MODE_MATCH_TIMINGS |
1050 DRM_MODE_MATCH_CLOCK | 1050 DRM_MODE_MATCH_CLOCK |
1051 DRM_MODE_MATCH_FLAGS | 1051 DRM_MODE_MATCH_FLAGS |
1052 DRM_MODE_MATCH_3D_FLAGS); 1052 DRM_MODE_MATCH_3D_FLAGS|
1053 DRM_MODE_MATCH_ASPECT_RATIO);
1053} 1054}
1054EXPORT_SYMBOL(drm_mode_equal); 1055EXPORT_SYMBOL(drm_mode_equal);
1055 1056
@@ -1647,6 +1648,20 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,
1647 out->vrefresh = in->vrefresh; 1648 out->vrefresh = in->vrefresh;
1648 out->flags = in->flags; 1649 out->flags = in->flags;
1649 out->type = in->type; 1650 out->type = in->type;
1651
1652 switch (in->picture_aspect_ratio) {
1653 case HDMI_PICTURE_ASPECT_4_3:
1654 out->flags |= DRM_MODE_FLAG_PIC_AR_4_3;
1655 break;
1656 case HDMI_PICTURE_ASPECT_16_9:
1657 out->flags |= DRM_MODE_FLAG_PIC_AR_16_9;
1658 break;
1659 case HDMI_PICTURE_ASPECT_RESERVED:
1660 default:
1661 out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
1662 break;
1663 }
1664
1650 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); 1665 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
1651 out->name[DRM_DISPLAY_MODE_LEN-1] = 0; 1666 out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
1652} 1667}
@@ -1693,6 +1708,24 @@ int drm_mode_convert_umode(struct drm_device *dev,
1693 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN); 1708 strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
1694 out->name[DRM_DISPLAY_MODE_LEN-1] = 0; 1709 out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
1695 1710
1711 /* Clearing picture aspect ratio bits from out flags,
1712 * as the aspect-ratio information is not stored in
1713 * flags for kernel-mode, but in picture_aspect_ratio.
1714 */
1715 out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
1716
1717 switch (in->flags & DRM_MODE_FLAG_PIC_AR_MASK) {
1718 case DRM_MODE_FLAG_PIC_AR_4_3:
1719 out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_4_3;
1720 break;
1721 case DRM_MODE_FLAG_PIC_AR_16_9:
1722 out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
1723 break;
1724 default:
1725 out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
1726 break;
1727 }
1728
1696 out->status = drm_mode_validate_driver(dev, out); 1729 out->status = drm_mode_validate_driver(dev, out);
1697 if (out->status != MODE_OK) 1730 if (out->status != MODE_OK)
1698 return -EINVAL; 1731 return -EINVAL;