Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Thumshirn <jthumshirn@suse.de>2018-12-04 12:59:44 +0100
committerJohannes Thumshirn <jthumshirn@suse.de>2018-12-04 13:53:08 +0100
commit38cd972d931869e9c4507e2754a0e41010973efb (patch)
tree3b405cbcc2d49bb578dd181483fd63301ffc96e7
parent132ab569be570ee1d2e1111c1df486732648652f (diff)
Revert "Really drop the disabled DRM patches"
This reverts commit fd2445a0be3d59f45ae4921ed0d0bac1704a2b9d. Conflicts: series.conf
-rw-r--r--patches.drm/drm-Add-DRM-client-cap-for-aspect-ratio104
-rw-r--r--patches.drm/drm-Add-and-handle-new-aspect-ratios-in-DRM-layer107
-rw-r--r--patches.drm/drm-Add-aspect-ratio-parsing-in-DRM-layer146
-rw-r--r--patches.drm/drm-Expose-modes-with-aspect-ratio-only-if-requested157
-rw-r--r--patches.drm/drm-Handle-aspect-ratio-info-in-legacy-modeset-path72
-rw-r--r--series.conf7
6 files changed, 593 insertions, 0 deletions
diff --git a/patches.drm/drm-Add-DRM-client-cap-for-aspect-ratio b/patches.drm/drm-Add-DRM-client-cap-for-aspect-ratio
new file mode 100644
index 0000000000..35d0ead57d
--- /dev/null
+++ b/patches.drm/drm-Add-DRM-client-cap-for-aspect-ratio
@@ -0,0 +1,104 @@
+From 7595bda2fb4378ccbb8db1d0e8de56d15ea7f7fa Mon Sep 17 00:00:00 2001
+From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+Date: Tue, 8 May 2018 16:39:41 +0530
+Subject: [PATCH] drm: Add DRM client cap for aspect-ratio
+Git-commit: 7595bda2fb4378ccbb8db1d0e8de56d15ea7f7fa
+Patch-mainline: v4.18-rc1
+References: FATE#325208
+
+To enable aspect-ratio support in DRM, blindly exposing the aspect
+ratio information along with mode, can break things in existing
+non-atomic user-spaces which have no intention or support to use this
+aspect ratio information.
+
+To avoid this, a new drm client cap is required to enable a non-atomic
+user-space to advertise if it supports modes with aspect-ratio. Based
+on this cap value, the kernel will take a call on exposing the aspect
+ratio info in modes or not.
+
+This patch adds the client cap for aspect-ratio.
+
+Since no atomic-userspaces blow up on receiving aspect-ratio
+information, the client cap for aspect-ratio is always enabled
+for atomic clients.
+
+Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
+Cc: Shashank Sharma <shashank.sharma@intel.com>
+Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+
+V3: rebase
+V4: As suggested by Marteen Lankhorst modified the commit message explaining the need to use the DRM cap for aspect-ratio. Also, tweaked the comment lines in the code for better understanding and clarity, as recommended by Shashank Sharma.
+V5: rebase
+V6: rebase
+V7: rebase
+V8: rebase
+V9: rebase
+V10: rebase
+V11: rebase
+V12: As suggested by Daniel Vetter and Ville Syrjala, always enable aspect-ratio client cap for atomic userspaces, if no atomic userspace breaks on aspect-ratio bits.
+V13: rebase
+V14: rebase
+
+Reviewed-by: Shashank Sharma <shashank.sharma@intel.com>
+Reviewed-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-7-git-send-email-ankit.k.nautiyal@intel.com
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_ioctl.c | 9 +++++++++
+ include/drm/drm_file.h | 8 ++++++++
+ include/uapi/drm/drm.h | 7 +++++++
+ 3 files changed, 24 insertions(+)
+
+--- a/drivers/gpu/drm/drm_ioctl.c
++++ b/drivers/gpu/drm/drm_ioctl.c
+@@ -331,6 +331,15 @@ drm_setclientcap(struct drm_device *dev,
+ return -EINVAL;
+ file_priv->atomic = req->value;
+ file_priv->universal_planes = req->value;
++ /*
++ * No atomic user-space blows up on aspect ratio mode bits.
++ */
++ file_priv->aspect_ratio_allowed = req->value;
++ break;
++ case DRM_CLIENT_CAP_ASPECT_RATIO:
++ if (req->value > 1)
++ return -EINVAL;
++ file_priv->aspect_ratio_allowed = req->value;
+ break;
+ default:
+ return -EINVAL;
+--- a/include/drm/drm_file.h
++++ b/include/drm/drm_file.h
+@@ -182,6 +182,14 @@ struct drm_file {
+ unsigned atomic:1;
+
+ /**
++ * @aspect_ratio_allowed:
++ *
++ * True, if client can handle picture aspect ratios, and has requested
++ * to pass this information along with the mode.
++ */
++ unsigned aspect_ratio_allowed:1;
++
++ /**
+ * @is_master:
+ *
+ * This client is the creator of @master. Protected by struct
+--- a/include/uapi/drm/drm.h
++++ b/include/uapi/drm/drm.h
+@@ -680,6 +680,13 @@ struct drm_get_cap {
+ */
+ #define DRM_CLIENT_CAP_ATOMIC 3
+
++/**
++ * DRM_CLIENT_CAP_ASPECT_RATIO
++ *
++ * If set to 1, the DRM core will provide aspect ratio information in modes.
++ */
++#define DRM_CLIENT_CAP_ASPECT_RATIO 4
++
+ /** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
+ struct drm_set_client_cap {
+ __u64 capability;
diff --git a/patches.drm/drm-Add-and-handle-new-aspect-ratios-in-DRM-layer b/patches.drm/drm-Add-and-handle-new-aspect-ratios-in-DRM-layer
new file mode 100644
index 0000000000..a14cfaa671
--- /dev/null
+++ b/patches.drm/drm-Add-and-handle-new-aspect-ratios-in-DRM-layer
@@ -0,0 +1,107 @@
+From 900aa8ad21587e909603f471b6cd81fd5338ec45 Mon Sep 17 00:00:00 2001
+From: Shashank Sharma <shashank.sharma@intel.com>
+Date: Tue, 8 May 2018 16:39:45 +0530
+Subject: [PATCH] drm: Add and handle new aspect ratios in DRM layer
+Git-commit: 900aa8ad21587e909603f471b6cd81fd5338ec45
+Patch-mainline: v4.18-rc1
+References: FATE#325208
+
+HDMI 2.0/CEA-861-F introduces two new aspect ratios:
+- 64:27
+- 256:135
+
+This patch:
+- Adds new DRM flags for to represent these new aspect ratios.
+- Adds new cases to handle these aspect ratios while converting
+from user->kernel mode or vise versa.
+
+This patch was once reviewed and merged, and later reverted due
+to lack of DRM client protection, while adding aspect ratio bits
+in user modes. This is a re-spin of the series, with DRM client
+cap protection.
+
+The previous series can be found here:
+https://pw-emeril.freedesktop.org/series/10850/
+
+Signed-off-by: Shashank Sharma <shashank.sharma@intel.com>
+Reviewed-by: Sean Paul <seanpaul@chromium.org> (V2)
+Reviewed-by: Jose Abreu <Jose.Abreu@synopsys.com> (V2)
+
+Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
+Cc: Sean Paul <seanpaul@chromium.org>
+Cc: Jose Abreu <Jose.Abreu@synopsys.com>
+Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+
+V3: rebase
+V4: rebase
+V5: corrected the macro name for an aspect ratio, in a switch case.
+V6: rebase
+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-11-git-send-email-ankit.k.nautiyal@intel.com
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_modes.c | 12 ++++++++++++
+ include/uapi/drm/drm_mode.h | 6 ++++++
+ 2 files changed, 18 insertions(+)
+
+--- a/drivers/gpu/drm/drm_modes.c
++++ b/drivers/gpu/drm/drm_modes.c
+@@ -1630,6 +1630,12 @@ void drm_mode_convert_to_umode(struct dr
+ case HDMI_PICTURE_ASPECT_16_9:
+ out->flags |= DRM_MODE_FLAG_PIC_AR_16_9;
+ break;
++ case HDMI_PICTURE_ASPECT_64_27:
++ out->flags |= DRM_MODE_FLAG_PIC_AR_64_27;
++ break;
++ case HDMI_PICTURE_ASPECT_256_135:
++ out->flags |= DRM_MODE_FLAG_PIC_AR_256_135;
++ break;
+ case HDMI_PICTURE_ASPECT_RESERVED:
+ default:
+ out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
+@@ -1694,6 +1700,12 @@ int drm_mode_convert_umode(struct drm_di
+ case DRM_MODE_FLAG_PIC_AR_16_9:
+ out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
+ break;
++ case DRM_MODE_FLAG_PIC_AR_64_27:
++ out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_64_27;
++ break;
++ case DRM_MODE_FLAG_PIC_AR_256_135:
++ out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_256_135;
++ break;
+ default:
+ out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
+ break;
+--- a/include/uapi/drm/drm_mode.h
++++ b/include/uapi/drm/drm_mode.h
+@@ -89,6 +89,8 @@ extern "C" {
+ #define DRM_MODE_PICTURE_ASPECT_NONE 0
+ #define DRM_MODE_PICTURE_ASPECT_4_3 1
+ #define DRM_MODE_PICTURE_ASPECT_16_9 2
++#define DRM_MODE_PICTURE_ASPECT_64_27 3
++#define DRM_MODE_PICTURE_ASPECT_256_135 4
+
+ /* Aspect ratio flag bitmask (4 bits 22:19) */
+ #define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
+@@ -98,6 +100,10 @@ extern "C" {
+ (DRM_MODE_PICTURE_ASPECT_4_3<<19)
+ #define DRM_MODE_FLAG_PIC_AR_16_9 \
+ (DRM_MODE_PICTURE_ASPECT_16_9<<19)
++#define DRM_MODE_FLAG_PIC_AR_64_27 \
++ (DRM_MODE_PICTURE_ASPECT_64_27<<19)
++#define DRM_MODE_FLAG_PIC_AR_256_135 \
++ (DRM_MODE_PICTURE_ASPECT_256_135<<19)
+
+ /* DPMS flags */
+ /* bit compatible with the xorg definitions. */
diff --git a/patches.drm/drm-Add-aspect-ratio-parsing-in-DRM-layer b/patches.drm/drm-Add-aspect-ratio-parsing-in-DRM-layer
new file mode 100644
index 0000000000..a47ec817df
--- /dev/null
+++ b/patches.drm/drm-Add-aspect-ratio-parsing-in-DRM-layer
@@ -0,0 +1,146 @@
+From 222ec1618c3aceca1e61e1e73e559c647c2b946f Mon Sep 17 00:00:00 2001
+From: Shashank Sharma <shashank.sharma@intel.com>
+Date: Tue, 8 May 2018 16:39:44 +0530
+Subject: [PATCH] drm: Add aspect ratio parsing in DRM layer
+Git-commit: 222ec1618c3aceca1e61e1e73e559c647c2b946f
+Patch-mainline: v4.18-rc1
+References: FATE#325208
+
+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
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_fb_helper.c | 12 ++++++++++--
+ drivers/gpu/drm/drm_modes.c | 35 ++++++++++++++++++++++++++++++++++-
+ 2 files changed, 44 insertions(+), 3 deletions(-)
+
+--- a/drivers/gpu/drm/drm_fb_helper.c
++++ b/drivers/gpu/drm/drm_fb_helper.c
+@@ -2113,7 +2113,11 @@ static bool drm_target_cloned(struct drm
+ for (j = 0; j < i; j++) {
+ if (!enabled[j])
+ continue;
+- if (!drm_mode_equal(modes[j], modes[i]))
++ if (!drm_mode_match(modes[j], modes[i],
++ DRM_MODE_MATCH_TIMINGS |
++ DRM_MODE_MATCH_CLOCK |
++ DRM_MODE_MATCH_FLAGS |
++ DRM_MODE_MATCH_3D_FLAGS))
+ can_clone = false;
+ }
+ }
+@@ -2133,7 +2137,11 @@ static bool drm_target_cloned(struct drm
+
+ fb_helper_conn = fb_helper->connector_info[i];
+ list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) {
+- if (drm_mode_equal(mode, dmt_mode))
++ if (drm_mode_match(mode, dmt_mode,
++ DRM_MODE_MATCH_TIMINGS |
++ DRM_MODE_MATCH_CLOCK |
++ DRM_MODE_MATCH_FLAGS |
++ DRM_MODE_MATCH_3D_FLAGS))
+ modes[i] = mode;
+ }
+ if (!modes[i])
+--- a/drivers/gpu/drm/drm_modes.c
++++ b/drivers/gpu/drm/drm_modes.c
+@@ -1050,7 +1050,8 @@ bool drm_mode_equal(const struct drm_dis
+ DRM_MODE_MATCH_TIMINGS |
+ DRM_MODE_MATCH_CLOCK |
+ DRM_MODE_MATCH_FLAGS |
+- DRM_MODE_MATCH_3D_FLAGS);
++ DRM_MODE_MATCH_3D_FLAGS|
++ DRM_MODE_MATCH_ASPECT_RATIO);
+ }
+ EXPORT_SYMBOL(drm_mode_equal);
+
+@@ -1621,6 +1622,20 @@ void drm_mode_convert_to_umode(struct dr
+ out->vrefresh = in->vrefresh;
+ out->flags = in->flags;
+ out->type = in->type;
++
++ switch (in->picture_aspect_ratio) {
++ case HDMI_PICTURE_ASPECT_4_3:
++ out->flags |= DRM_MODE_FLAG_PIC_AR_4_3;
++ break;
++ case HDMI_PICTURE_ASPECT_16_9:
++ out->flags |= DRM_MODE_FLAG_PIC_AR_16_9;
++ break;
++ case HDMI_PICTURE_ASPECT_RESERVED:
++ default:
++ out->flags |= DRM_MODE_FLAG_PIC_AR_NONE;
++ break;
++ }
++
+ strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
+ out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
+ }
+@@ -1666,6 +1681,24 @@ int drm_mode_convert_umode(struct drm_di
+ strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
+ out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
+
++ /* Clearing picture aspect ratio bits from out flags,
++ * as the aspect-ratio information is not stored in
++ * flags for kernel-mode, but in picture_aspect_ratio.
++ */
++ out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
++
++ switch (in->flags & DRM_MODE_FLAG_PIC_AR_MASK) {
++ case DRM_MODE_FLAG_PIC_AR_4_3:
++ out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_4_3;
++ break;
++ case DRM_MODE_FLAG_PIC_AR_16_9:
++ out->picture_aspect_ratio |= HDMI_PICTURE_ASPECT_16_9;
++ break;
++ default:
++ out->picture_aspect_ratio = HDMI_PICTURE_ASPECT_NONE;
++ break;
++ }
++
+ out->status = drm_mode_validate_basic(out);
+ if (out->status != MODE_OK)
+ goto out;
diff --git a/patches.drm/drm-Expose-modes-with-aspect-ratio-only-if-requested b/patches.drm/drm-Expose-modes-with-aspect-ratio-only-if-requested
new file mode 100644
index 0000000000..6bb3e7cfef
--- /dev/null
+++ b/patches.drm/drm-Expose-modes-with-aspect-ratio-only-if-requested
@@ -0,0 +1,157 @@
+From c3ff0cdb354f89a5b877eee61af70e6ae51de50b Mon Sep 17 00:00:00 2001
+From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+Date: Tue, 8 May 2018 16:39:43 +0530
+Subject: [PATCH] drm: Expose modes with aspect ratio, only if requested
+Git-commit: c3ff0cdb354f89a5b877eee61af70e6ae51de50b
+Patch-mainline: v4.18-rc1
+References: FATE#325208
+
+We parse the EDID and add all the modes in the connector's modelist.
+This adds CEA modes with aspect ratio information too, regardless of
+whether user space requested this information or not.
+
+This patch:
+-prunes the modes with aspect-ratio information, from the
+ drm_mode_get_connector modelist supplied to the user, if the
+ user-space has not set the aspect ratio DRM client cap. However if
+ such a mode is unique in the list, it is kept in the list, with
+ aspect-ratio flags reset.
+-prepares a list of exposed modes, which is used to find unique modes
+ if aspect-ratio is not allowed.
+-adds a new list_head 'exposed_head' in drm_mode_display, to traverse
+ the list of exposed modes.
+
+Cc: Ville Syrjala <ville.syrjala@linux.intel.com>
+Cc: Shashank Sharma <shashank.sharma@intel.com>
+Cc: Jose Abreu <jose.abreu@synopsys.com>
+
+Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+
+V3: As suggested by Ville, modified the mechanism of pruning of modes with aspect-ratio, if the aspect-ratio is not supported. Instead of straight away pruning such a mode, the mode is retained with aspect ratio bits set to zero, provided it is unique.
+V4: rebase
+V5: Addressed review comments from Ville: -used a pointer to store last valid mode. -avoided, modifying of picture_aspect_ratio in kernel mode, instead only flags bits of user mode are reset (if aspect-ratio is not supported).
+V6: As suggested by Ville, corrected the mode pruning logic and elaborated the mode pruning logic and the assumptions taken.
+V7: rebase
+V8: rebase
+V9: rebase
+V10: rebase
+V11: Fixed the issue caused in kms_3d test, and enhanced the pruning logic to correctly identify and prune modes with aspect-ratio, if aspect-ratio cap is not set.
+V12: As suggested by Ville, added another list_head in drm_mode_display to traverse the list of exposed modes and avoided duplication of modes.
+V13: Minor modifications, as suggested by Ville.
+V14: As suggested by Daniel Vetter and Ville Syrjala, corrected the pruning logic to avoid any dependency in the order of mode with aspect-ratio.
+Reviewed-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-9-git-send-email-ankit.k.nautiyal@intel.com
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_connector.c | 44 +++++++++++++++++++++++++++++++++-------
+ include/drm/drm_modes.h | 13 +++++++++++
+ 2 files changed, 50 insertions(+), 7 deletions(-)
+
+--- a/drivers/gpu/drm/drm_connector.c
++++ b/drivers/gpu/drm/drm_connector.c
+@@ -1370,8 +1370,10 @@ static struct drm_encoder *drm_connector
+ return connector->encoder;
+ }
+
+-static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
+- const struct drm_file *file_priv)
++static bool
++drm_mode_expose_to_userspace(const struct drm_display_mode *mode,
++ const struct list_head *export_list,
++ const struct drm_file *file_priv)
+ {
+ /*
+ * If user-space hasn't configured the driver to expose the stereo 3D
+@@ -1379,6 +1381,23 @@ static bool drm_mode_expose_to_userspace
+ */
+ if (!file_priv->stereo_allowed && drm_mode_is_stereo(mode))
+ return false;
++ /*
++ * If user-space hasn't configured the driver to expose the modes
++ * with aspect-ratio, don't expose them. However if such a mode
++ * is unique, let it be exposed, but reset the aspect-ratio flags
++ * while preparing the list of user-modes.
++ */
++ if (!file_priv->aspect_ratio_allowed) {
++ struct drm_display_mode *mode_itr;
++
++ list_for_each_entry(mode_itr, export_list, export_head)
++ if (drm_mode_match(mode_itr, mode,
++ DRM_MODE_MATCH_TIMINGS |
++ DRM_MODE_MATCH_CLOCK |
++ DRM_MODE_MATCH_FLAGS |
++ DRM_MODE_MATCH_3D_FLAGS))
++ return false;
++ }
+
+ return true;
+ }
+@@ -1398,6 +1417,7 @@ int drm_mode_getconnector(struct drm_dev
+ struct drm_mode_modeinfo u_mode;
+ struct drm_mode_modeinfo __user *mode_ptr;
+ uint32_t __user *encoder_ptr;
++ LIST_HEAD(export_list);
+
+ if (!drm_core_check_feature(dev, DRIVER_MODESET))
+ return -EINVAL;
+@@ -1446,21 +1466,31 @@ int drm_mode_getconnector(struct drm_dev
+
+ /* delayed so we get modes regardless of pre-fill_modes state */
+ list_for_each_entry(mode, &connector->modes, head)
+- if (drm_mode_expose_to_userspace(mode, file_priv))
++ if (drm_mode_expose_to_userspace(mode, &export_list,
++ file_priv)) {
++ list_add_tail(&mode->export_head, &export_list);
+ mode_count++;
++ }
+
+ /*
+ * This ioctl is called twice, once to determine how much space is
+ * needed, and the 2nd time to fill it.
++ * The modes that need to be exposed to the user are maintained in the
++ * 'export_list'. When the ioctl is called first time to determine the,
++ * space, the export_list gets filled, to find the no.of modes. In the
++ * 2nd time, the user modes are filled, one by one from the export_list.
+ */
+ if ((out_resp->count_modes >= mode_count) && mode_count) {
+ copied = 0;
+ mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr;
+- list_for_each_entry(mode, &connector->modes, head) {
+- if (!drm_mode_expose_to_userspace(mode, file_priv))
+- continue;
+-
++ list_for_each_entry(mode, &export_list, export_head) {
+ drm_mode_convert_to_umode(&u_mode, mode);
++ /*
++ * Reset aspect ratio flags of user-mode, if modes with
++ * aspect-ratio are not supported.
++ */
++ if (!file_priv->aspect_ratio_allowed)
++ u_mode.flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
+ if (copy_to_user(mode_ptr + copied,
+ &u_mode, sizeof(u_mode))) {
+ ret = -EFAULT;
+--- a/include/drm/drm_modes.h
++++ b/include/drm/drm_modes.h
+@@ -415,6 +415,19 @@ struct drm_display_mode {
+ * Field for setting the HDMI picture aspect ratio of a mode.
+ */
+ enum hdmi_picture_aspect picture_aspect_ratio;
++
++ /**
++ * @export_head:
++ *
++ * struct list_head for modes to be exposed to the userspace.
++ * This is to maintain a list of exposed modes while preparing
++ * user-mode's list in drm_mode_getconnector ioctl. The purpose of this
++ * list_head only lies in the ioctl function, and is not expected to be
++ * used outside the function.
++ * Once used, the stale pointers are not reset, but left as it is, to
++ * avoid overhead of protecting it by mode_config.mutex.
++ */
++ struct list_head export_head;
+ };
+
+ /**
diff --git a/patches.drm/drm-Handle-aspect-ratio-info-in-legacy-modeset-path b/patches.drm/drm-Handle-aspect-ratio-info-in-legacy-modeset-path
new file mode 100644
index 0000000000..498466b657
--- /dev/null
+++ b/patches.drm/drm-Handle-aspect-ratio-info-in-legacy-modeset-path
@@ -0,0 +1,72 @@
+From ace5bf0e254b10585efa938d05e95ea05ae15326 Mon Sep 17 00:00:00 2001
+From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+Date: Tue, 8 May 2018 16:39:42 +0530
+Subject: [PATCH] drm: Handle aspect ratio info in legacy modeset path
+Git-commit: ace5bf0e254b10585efa938d05e95ea05ae15326
+Patch-mainline: v4.18-rc1
+References: FATE#325208
+
+If the user-space does not support aspect-ratio, and requests for a
+modeset with mode having aspect ratio bits set, then the given
+user-mode must be rejected. Secondly, while preparing a user-mode from
+kernel mode, the aspect-ratio info must not be given, if aspect-ratio
+is not supported by the user.
+
+This patch:
+1. rejects the modes with aspect-ratio info, during modeset, if the
+ user does not support aspect ratio.
+2. does not load the aspect-ratio info in user-mode structure, if
+ aspect ratio is not supported.
+3. adds helper functions for determining if aspect-ratio is expected
+ in user-mode and for allowing/disallowing the aspect-ratio, if its
+ not expected.
+
+Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
+
+V3: Addressed review comments from Ville: Do not corrupt the current crtc state by updating aspect-ratio on the fly.
+V4: rebase
+V5: As suggested by Ville, rejected the modeset calls for modes with aspect ratio, if the user does not set aspect-ratio cap.
+V6: Used the helper functions for determining if aspect-ratio is expected in the user-mode.
+V7: rebase
+V8: rebase
+V9: rebase
+V10: Modified the commit-message
+V11: rebase
+V12: Merged the patch for adding aspect-ratio helper functions with this patch.
+V13: Minor modifications as suggested by Ville.
+V14: Removed helper functions, as they were used only once in legacy modeset path, as suggested by Daniel Vetter.
+
+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-8-git-send-email-ankit.k.nautiyal@intel.com
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/gpu/drm/drm_crtc.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/drivers/gpu/drm/drm_crtc.c
++++ b/drivers/gpu/drm/drm_crtc.c
+@@ -442,6 +442,8 @@ int drm_mode_getcrtc(struct drm_device *
+ crtc_resp->mode_valid = 0;
+ }
+ }
++ if (!file_priv->aspect_ratio_allowed)
++ crtc_resp->mode.flags &= ~DRM_MODE_FLAG_PIC_AR_MASK;
+ drm_modeset_unlock(&crtc->mutex);
+
+ return 0;
+@@ -609,6 +611,13 @@ retry:
+ ret = -ENOMEM;
+ goto out;
+ }
++ if (!file_priv->aspect_ratio_allowed &&
++ (crtc_req->mode.flags & DRM_MODE_FLAG_PIC_AR_MASK) != DRM_MODE_FLAG_PIC_AR_NONE) {
++ DRM_DEBUG_KMS("Unexpected aspect-ratio flag bits\n");
++ ret = -EINVAL;
++ goto out;
++ }
++
+
+ ret = drm_mode_convert_umode(mode, &crtc_req->mode);
+ if (ret) {
diff --git a/series.conf b/series.conf
index fc7db68228..130cb04063 100644
--- a/series.conf
+++ b/series.conf
@@ -19664,6 +19664,13 @@
patches.drm/drm-nouveau-Don-t-disable-polling-in-fallback-mode.patch
patches.suse/drm-i915-CFL-NVMe-breakage-workaround.patch
+ patches.drm/drm-Add-DRM-client-cap-for-aspect-ratio
+ patches.drm/drm-Handle-aspect-ratio-info-in-legacy-modeset-path
+ patches.drm/drm-Expose-modes-with-aspect-ratio-only-if-requested
+ patches.drm/drm-Add-aspect-ratio-parsing-in-DRM-layer
+ patches.drm/drm-Add-and-handle-new-aspect-ratios-in-DRM-layer
+
+ ########################################################
# Out-of-tree networking
########################################################
patches.fixes/irda-Only-insert-new-objects-into-the-global-databas.patch