Aspect ratio support in DRM layer
Subsystems (2)
v3 cover Aspect ratio support in DRM layer
From: Ankit Nautiyal <[email protected]>
This patch series is a re-attempt to enable aspect ratio support in DRM layer. Currently the aspect ratio information gets lost in translation during a user->kernel mode or vice versa.
The old patch series (https://pw-emeril.freedesktop.org/series/10850/) had 4 patches, out of which 2 patches were reverted due to lack of drm client protection while loading the aspect information.
This patch series also includes 3 patches from Ville Syrjälä's series for 'Info-frame cleanup and fixes' https://patchwork.freedesktop.org/series/33730/
which fixes the mode matching mechanism via flags.
This patch series, adds a DRM client option for aspect ratio, and loads aspect ratio flags, only when the client sets this cap.
Also, to test this patch series there is a userspace implementation by Ankit Nautiyal in Wayland/weston layer:
https://patchwork.freedesktop.org/patch/188125/
(Which is already ACK'ed by wayland community.)
This, helps us in passing HDMI compliance test cases like 7-27, where the test equipment applies a CEA mode, and expects the exact VIC in the AVI infoframes.
Ankit Nautiyal (3):
drm: Add DRM client cap for aspect-ratio
drm: Handle aspect ratio info in atomic and legacy modeset paths
drm: Expose modes with aspect ratio, only if requested
Sharma, Shashank (2):
drm: Add aspect ratio parsing in DRM layer
drm: Add and handle new aspect ratios in DRM layer
Ville Syrjälä (3):
drm/modes: Introduce drm_mode_match()
drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy drm/edid: Fix cea mode aspect ratio handling
drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++- drivers/gpu/drm/drm_connector.c | 31 ++++++- drivers/gpu/drm/drm_crtc.c | 19 +++++ drivers/gpu/drm/drm_edid.c | 18 +++- drivers/gpu/drm/drm_ioctl.c | 5 ++ drivers/gpu/drm/drm_modes.c | 177 +++++++++++++++++++++++++++++++++------- include/drm/drm_atomic.h | 2 + include/drm/drm_file.h | 7 ++ include/drm/drm_modes.h | 9 ++ include/uapi/drm/drm.h | 7 ++ include/uapi/drm/drm_mode.h | 6 ++ 11 files changed, 300 insertions(+), 42 deletions(-)
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 1/8 drm/modes: Introduce drm_mode_match()
From: Ville Syrjälä <[email protected]>
Make mode matching less confusing by allowing the caller to specify which parts of the modes should match via some flags.
--- drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++---------- include/drm/drm_modes.h | 9 +++ 2 files changed, 112 insertions(+), 31 deletions(-)
drivers/gpu/drm/drm_modes.c +103 -31
@@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, }EXPORT_SYMBOL (drm_mode_duplicate); +static bool drm_mode_match_timings (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return mode1->hdisplay == mode2->hdisplay && + mode1->hsync_start == mode2->hsync_start && + mode1->hsync_end == mode2->hsync_end && + mode1->htotal == mode2->htotal && + mode1->hskew == mode2->hskew && + mode1->vdisplay == mode2->vdisplay && + mode1->vsync_start == mode2->vsync_start && + mode1->vsync_end == mode2->vsync_end && + mode1->vtotal == mode2->vtotal && + mode1->vscan == mode2->vscan; +} + +static bool drm_mode_match_clock (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +/* +* do clock check convert to PICOS +* so fb modes get matched the same +*/ +if (mode1->clock && mode2->clock) +return KHZ2PICOS (mode1->clock) ==KHZ2PICOS (mode2->clock); +else +return mode1->clock == mode2->clock; +} + +static bool drm_mode_match_flags (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags & ~DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_3d_flags (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return (mode1->flags &DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags &DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_aspect_ratio (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio; +} +/** -* drm_mode_equal - test modes for equality +* drm_mode_match - test modes for (partial) equality * @mode1: first mode * @mode2: second mode +* @match_flags: which parts need to match (DRM_MODE_MATCH_*) * * Check to see if @mode1 and @mode2 are equivalent. * * Returns: -* True if the modes are equal, false otherwise. +* True if the modes are (partially) equal, false otherwise. */ -bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_match (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2, +unsigned int match_flags) {if (!mode1 && !mode2)return true;
@@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displif (!mode1 || !mode2)return false; -/* do clock check convert to PICOS so fb modes get matched -* the same */ -if (mode1->clock && mode2->clock) { -if (KHZ2PICOS (mode1->clock) !=KHZ2PICOS (mode2->clock)) -return false; - }else if (mode1->clock != mode2->clock) +if (match_flags &DRM_MODE_MATCH_TIMINGS && + !drm_mode_match_timings (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_CLOCK && + !drm_mode_match_clock (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_FLAGS && + !drm_mode_match_flags (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_3D_FLAGS && + !drm_mode_match_3d_flags (mode1, mode2))return false; -return drm_mode_equal_no_clocks (mode1, mode2); +if (match_flags &DRM_MODE_MATCH_ASPECT_RATIO && + !drm_mode_match_aspect_ratio (mode1, mode2)) +return false; + +return true; +} +EXPORT_SYMBOL (drm_mode_match); + +/** +* drm_mode_equal - test modes for equality +* @mode1: first mode +* @mode2: second mode +* +* Check to see if @mode1 and @mode2 are equivalent. +* +* Returns: +* True if the modes are equal, false otherwise. +*/ +bool drm_mode_equal (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal);
@@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);* Returns: * True if the modes are equal, false otherwise. */ -bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) { -if ((mode1->flags &DRM_MODE_FLAG_3D_MASK ) != - (mode2->flags &DRM_MODE_FLAG_3D_MASK )) -return false; - -return drm_mode_equal_no_clocks_no_stereo (mode1, mode2); +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks);
@@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);bool drm_mode_equal_no_clocks_no_stereo (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) { -if (mode1->hdisplay == mode2->hdisplay && - mode1->hsync_start == mode2->hsync_start && - mode1->hsync_end == mode2->hsync_end && - mode1->htotal == mode2->htotal && - mode1->hskew == mode2->hskew && - mode1->vdisplay == mode2->vdisplay && - mode1->vsync_start == mode2->vsync_start && - mode1->vsync_end == mode2->vsync_end && - mode1->vtotal == mode2->vtotal && - mode1->vscan == mode2->vscan && - (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == - (mode2->flags & ~DRM_MODE_FLAG_3D_MASK )) -return true; - -return false; +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks_no_stereo);
include/drm/drm_modes.h +9 -0
@@ -150,6 +150,12 @@ enum drm_mode_status {#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF +#define DRM_MODE_MATCH_TIMINGS (1 << 0) +#define DRM_MODE_MATCH_CLOCK (1 << 1) +#define DRM_MODE_MATCH_FLAGS (1 << 2) +#define DRM_MODE_MATCH_3D_FLAGS (1 << 3) +#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4) +/** * struct drm_display_mode - DRM kernel-internal display mode structure * @hdisplay: horizontal display size
@@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);struct drm_display_mode *drm_mode_duplicate (struct drm_device *dev,const struct drm_display_mode *mode); +bool drm_mode_match (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2, +unsigned int match_flags);bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2); bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/8] drm/modes: Introduce drm_mode_match()
Quoted 16 lines · Ankit K
From: Ville Syrjälä <[email protected]>
Make mode matching less confusing by allowing the caller to specify which parts of the modes should match via some flags.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++---------- include/drm/drm_modes.h | 9 +++ 2 files changed, 112 insertions(+), 31 deletions(-)drivers/gpu/drm/drm_modes.c +0
-0
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 944
Quoted 5 lines
drivers/gpu/drm/drm_modes.c +2
-0@@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, }EXPORT_SYMBOL (drm_mode_duplicate); +static bool drm_mode_match_timings (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2)
Shouldn't the second parameter be aligned to next char after the opening bracket in above line (instead of being align to the bracket) ? I have this same comment for most of the functions in this patch.
Quoted 17 lines
drivers/gpu/drm/drm_modes.c +17
-0+{ +return mode1->hdisplay == mode2->hdisplay && + mode1->hsync_start == mode2->hsync_start && + mode1->hsync_end == mode2->hsync_end && + mode1->htotal == mode2->htotal && + mode1->hskew == mode2->hskew && + mode1->vdisplay == mode2->vdisplay && + mode1->vsync_start == mode2->vsync_start && + mode1->vsync_end == mode2->vsync_end && + mode1->vtotal == mode2->vtotal && + mode1->vscan == mode2->vscan; +} + +static bool drm_mode_match_clock (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +/*
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 971
Quoted 10 lines
drivers/gpu/drm/drm_modes.c +10
-0+* do clock check convert to PICOS +* so fb modes get matched the same +*/ +if (mode1->clock && mode2->clock) +return KHZ2PICOS (mode1->clock) ==KHZ2PICOS (mode2->clock); +else +return mode1->clock == mode2->clock; +} + +static bool drm_mode_match_flags(const struct drm_display_mode *mode1,
Should we call it drm_mode_match_flag_no_stereo ?
Quoted 158 lines
drivers/gpu/drm/drm_modes.c +74
-31+ const struct drm_display_mode *mode2) +{ +return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags & ~DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_3d_flags (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return (mode1->flags &DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags &DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_aspect_ratio (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio; +} +/** -* drm_mode_equal - test modes for equality +* drm_mode_match - test modes for (partial) equality * @mode1: first mode * @mode2: second mode +* @match_flags: which parts need to match (DRM_MODE_MATCH_*) * * Check to see if @mode1 and @mode2 are equivalent. * * Returns: -* True if the modes are equal, false otherwise. +* True if the modes are (partially) equal, false otherwise. */ -bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_match (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2, +unsigned int match_flags) {if (!mode1 && !mode2)return true;@@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displif (!mode1 || !mode2)return false; -/* do clock check convert to PICOS so fb modes get matched -* the same */ -if (mode1->clock && mode2->clock) { -if (KHZ2PICOS (mode1->clock) !=KHZ2PICOS (mode2->clock)) -return false; - }else if (mode1->clock != mode2->clock) +if (match_flags &DRM_MODE_MATCH_TIMINGS && + !drm_mode_match_timings (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_CLOCK && + !drm_mode_match_clock (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_FLAGS && + !drm_mode_match_flags (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_3D_FLAGS && + !drm_mode_match_3d_flags (mode1, mode2))return false; -return drm_mode_equal_no_clocks (mode1, mode2); +if (match_flags &DRM_MODE_MATCH_ASPECT_RATIO && + !drm_mode_match_aspect_ratio (mode1, mode2)) +return false; + +return true; +} +EXPORT_SYMBOL (drm_mode_match); + +/** +* drm_mode_equal - test modes for equality +* @mode1: first mode +* @mode2: second mode +* +* Check to see if @mode1 and @mode2 are equivalent. +* +* Returns: +* True if the modes are equal, false otherwise. +*/ +bool drm_mode_equal (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal);@@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);* Returns: * True if the modes are equal, false otherwise. */ -bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) { -if ((mode1->flags &DRM_MODE_FLAG_3D_MASK ) != - (mode2->flags &DRM_MODE_FLAG_3D_MASK )) -return false; - -return drm_mode_equal_no_clocks_no_stereo (mode1, mode2); +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks);@@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);bool drm_mode_equal_no_clocks_no_stereo (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) { -if (mode1->hdisplay == mode2->hdisplay && - mode1->hsync_start == mode2->hsync_start && - mode1->hsync_end == mode2->hsync_end && - mode1->htotal == mode2->htotal && - mode1->hskew == mode2->hskew && - mode1->vdisplay == mode2->vdisplay && - mode1->vsync_start == mode2->vsync_start && - mode1->vsync_end == mode2->vsync_end && - mode1->vtotal == mode2->vtotal && - mode1->vscan == mode2->vscan && - (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == - (mode2->flags & ~DRM_MODE_FLAG_3D_MASK )) -return true; - -return false; +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks_no_stereo);include/drm/drm_modes.h +6
-0@@ -150,6 +150,12 @@ enum drm_mode_status {#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF +#define DRM_MODE_MATCH_TIMINGS (1 << 0) +#define DRM_MODE_MATCH_CLOCK (1 << 1) +#define DRM_MODE_MATCH_FLAGS (1 << 2) +#define DRM_MODE_MATCH_3D_FLAGS (1 << 3) +#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4) +/** * struct drm_display_mode - DRM kernel-internal display mode structure * @hdisplay: horizontal display size
include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 503
Quoted 5 lines
include/drm/drm_modes.h +2
-0@@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);struct drm_display_mode *drm_mode_duplicate (struct drm_device *dev,const struct drm_display_mode *mode); +bool drm_mode_match(const struct drm_display_mode *mode1, + const struct drm_display_mode *mode2,
Same here for the alignment
include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 507
Quoted 4 lines
include/drm/drm_modes.h +1
-0+ unsigned int match_flags);bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2); bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,
With the minor comments above, please feel free to use
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/8] drm/modes: Introduce drm_mode_match()
Quoted 22 lines · Shashank
Quoted 19 lines · Ankit K
From: Ville Syrjälä <[email protected]>
Make mode matching less confusing by allowing the caller to specify which parts of the modes should match via some flags.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++---------- include/drm/drm_modes.h | 9 +++ 2 files changed, 112 insertions(+), 31 deletions(-)drivers/gpu/drm/drm_modes.c +0
-0@@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, }EXPORT_SYMBOL (drm_mode_duplicate);
Quoted 4 lines
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 944
Quoted 2 lines
drivers/gpu/drm/drm_modes.c +2
-0+static bool drm_mode_match_timings (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2)Shouldn't the second parameter be aligned to next char after the opening bracket in above line (instead of being align to the bracket) ?
It is. The extra junk at the start of the line is causing the alignment to look wrong when it's not because the tab stops are still aligned to the start of the line. This is one reason why I think that using tabs for alignment isn't a particularly great idea.
Quoted 21 lines
I have this same comment for most of the functions in this patch.
Quoted 20 lines
drivers/gpu/drm/drm_modes.c +20
-0+{ +return mode1->hdisplay == mode2->hdisplay && + mode1->hsync_start == mode2->hsync_start && + mode1->hsync_end == mode2->hsync_end && + mode1->htotal == mode2->htotal && + mode1->hskew == mode2->hskew && + mode1->vdisplay == mode2->vdisplay && + mode1->vsync_start == mode2->vsync_start && + mode1->vsync_end == mode2->vsync_end && + mode1->vtotal == mode2->vtotal && + mode1->vscan == mode2->vscan; +} + +static bool drm_mode_match_clock (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +/* +* do clock check convert to PICOS +* so fb modes get matched the same +*/
Quoted 8 lines
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 971
Quoted 7 lines
drivers/gpu/drm/drm_modes.c +7
-0+if (mode1->clock && mode2->clock) +return KHZ2PICOS (mode1->clock) ==KHZ2PICOS (mode2->clock); +else +return mode1->clock == mode2->clock; +} + +static bool drm_mode_match_flags(const struct drm_display_mode *mode1,Should we call it
drm_mode_match_flag_no_stereo?
It's not really "no stereo", rather it's "check all the flags not being checked by something more specific".
Quoted 170 lines
Quoted 158 lines
drivers/gpu/drm/drm_modes.c +74
-31+ const struct drm_display_mode *mode2) +{ +return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags & ~DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_3d_flags (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return (mode1->flags &DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags &DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_aspect_ratio (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio; +} +/** -* drm_mode_equal - test modes for equality +* drm_mode_match - test modes for (partial) equality * @mode1: first mode * @mode2: second mode +* @match_flags: which parts need to match (DRM_MODE_MATCH_*) * * Check to see if @mode1 and @mode2 are equivalent. * * Returns: -* True if the modes are equal, false otherwise. +* True if the modes are (partially) equal, false otherwise. */ -bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_match (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2, +unsigned int match_flags) {if (!mode1 && !mode2)return true;@@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displif (!mode1 || !mode2)return false; -/* do clock check convert to PICOS so fb modes get matched -* the same */ -if (mode1->clock && mode2->clock) { -if (KHZ2PICOS (mode1->clock) !=KHZ2PICOS (mode2->clock)) -return false; - }else if (mode1->clock != mode2->clock) +if (match_flags &DRM_MODE_MATCH_TIMINGS && + !drm_mode_match_timings (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_CLOCK && + !drm_mode_match_clock (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_FLAGS && + !drm_mode_match_flags (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_3D_FLAGS && + !drm_mode_match_3d_flags (mode1, mode2))return false; -return drm_mode_equal_no_clocks (mode1, mode2); +if (match_flags &DRM_MODE_MATCH_ASPECT_RATIO && + !drm_mode_match_aspect_ratio (mode1, mode2)) +return false; + +return true; +} +EXPORT_SYMBOL (drm_mode_match); + +/** +* drm_mode_equal - test modes for equality +* @mode1: first mode +* @mode2: second mode +* +* Check to see if @mode1 and @mode2 are equivalent. +* +* Returns: +* True if the modes are equal, false otherwise. +*/ +bool drm_mode_equal (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal);@@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);* Returns: * True if the modes are equal, false otherwise. */ -bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) { -if ((mode1->flags &DRM_MODE_FLAG_3D_MASK ) != - (mode2->flags &DRM_MODE_FLAG_3D_MASK )) -return false; - -return drm_mode_equal_no_clocks_no_stereo (mode1, mode2); +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks);@@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);bool drm_mode_equal_no_clocks_no_stereo (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) { -if (mode1->hdisplay == mode2->hdisplay && - mode1->hsync_start == mode2->hsync_start && - mode1->hsync_end == mode2->hsync_end && - mode1->htotal == mode2->htotal && - mode1->hskew == mode2->hskew && - mode1->vdisplay == mode2->vdisplay && - mode1->vsync_start == mode2->vsync_start && - mode1->vsync_end == mode2->vsync_end && - mode1->vtotal == mode2->vtotal && - mode1->vscan == mode2->vscan && - (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == - (mode2->flags & ~DRM_MODE_FLAG_3D_MASK )) -return true; - -return false; +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks_no_stereo);include/drm/drm_modes.h +6
-0@@ -150,6 +150,12 @@ enum drm_mode_status {#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF +#define DRM_MODE_MATCH_TIMINGS (1 << 0) +#define DRM_MODE_MATCH_CLOCK (1 << 1) +#define DRM_MODE_MATCH_FLAGS (1 << 2) +#define DRM_MODE_MATCH_3D_FLAGS (1 << 3) +#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4) +/** * struct drm_display_mode - DRM kernel-internal display mode structure * @hdisplay: horizontal display size include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 503
Quoted 5 lines
include/drm/drm_modes.h +2
-0@@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);struct drm_display_mode *drm_mode_duplicate (struct drm_device *dev,const struct drm_display_mode *mode); +bool drm_mode_match(const struct drm_display_mode *mode1, + const struct drm_display_mode *mode2,Same here for the alignment
include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 507
Quoted 4 lines
include/drm/drm_modes.h +1
-0+ unsigned int match_flags);bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2); bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,With the minor comments above, please feel free to use
Reviewed-by Shashank Sharma <[email protected]>
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 1/8] drm/modes: Introduce drm_mode_match()
Regards
Shashank
Quoted 60 lines · Ville Syrjälä
Quoted 21 lines · Shashank
Quoted 19 lines · Ankit K
From: Ville Syrjälä <[email protected]>
Make mode matching less confusing by allowing the caller to specify which parts of the modes should match via some flags.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_modes.c | 134 ++++++++++++++++++++++++++++++++++---------- include/drm/drm_modes.h | 9 +++ 2 files changed, 112 insertions(+), 31 deletions(-)drivers/gpu/drm/drm_modes.c +0
-0@@ -940,17 +940,68 @@ struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, }EXPORT_SYMBOL (drm_mode_duplicate);Quoted 4 lines
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 944
Quoted 2 lines
drivers/gpu/drm/drm_modes.c +2
-0+static bool drm_mode_match_timings (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2)Shouldn't the second parameter be aligned to next char after the opening bracket in above line (instead of being align to the bracket) ?
It is. The extra junk at the start of the line is causing the alignment to look wrong when it's not because the tab stops are still aligned to the start of the line. This is one reason why I think that using tabs for alignment isn't a particularly great idea.
Quoted 21 lines
I have this same comment for most of the functions in this patch.
Quoted 20 lines
drivers/gpu/drm/drm_modes.c +20
-0+{ +return mode1->hdisplay == mode2->hdisplay && + mode1->hsync_start == mode2->hsync_start && + mode1->hsync_end == mode2->hsync_end && + mode1->htotal == mode2->htotal && + mode1->hskew == mode2->hskew && + mode1->vdisplay == mode2->vdisplay && + mode1->vsync_start == mode2->vsync_start && + mode1->vsync_end == mode2->vsync_end && + mode1->vtotal == mode2->vtotal && + mode1->vscan == mode2->vscan; +} + +static bool drm_mode_match_clock (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +/* +* do clock check convert to PICOS +* so fb modes get matched the same +*/ Quoted 8 lines
drivers/gpu/drm/drm_modes.c struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, · line 971
Quoted 7 lines
drivers/gpu/drm/drm_modes.c +7
-0+if (mode1->clock && mode2->clock) +return KHZ2PICOS (mode1->clock) ==KHZ2PICOS (mode2->clock); +else +return mode1->clock == mode2->clock; +} + +static bool drm_mode_match_flags(const struct drm_display_mode *mode1,Should we call it
drm_mode_match_flag_no_stereo?
Quoted 2 lines
It's not really "no stereo", rather it's "check all the flags not being checked by something more specific".
Yeah, anyways no big deal. With or without, feel free to use my r-b
- Shashank
Quoted 164 lines
Quoted 164 lines
Quoted 158 lines
drivers/gpu/drm/drm_modes.c +74
-31+ const struct drm_display_mode *mode2) +{ +return (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags & ~DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_3d_flags (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return (mode1->flags &DRM_MODE_FLAG_3D_MASK ) == + (mode2->flags &DRM_MODE_FLAG_3D_MASK ); +} + +static bool drm_mode_match_aspect_ratio (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return mode1->picture_aspect_ratio == mode2->picture_aspect_ratio; +} +/** -* drm_mode_equal - test modes for equality +* drm_mode_match - test modes for (partial) equality * @mode1: first mode * @mode2: second mode +* @match_flags: which parts need to match (DRM_MODE_MATCH_*) * * Check to see if @mode1 and @mode2 are equivalent. * * Returns: -* True if the modes are equal, false otherwise. +* True if the modes are (partially) equal, false otherwise. */ -bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_match (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2, +unsigned int match_flags) {if (!mode1 && !mode2)return true;@@ -958,15 +1009,48 @@ bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_displif (!mode1 || !mode2)return false; -/* do clock check convert to PICOS so fb modes get matched -* the same */ -if (mode1->clock && mode2->clock) { -if (KHZ2PICOS (mode1->clock) !=KHZ2PICOS (mode2->clock)) -return false; - }else if (mode1->clock != mode2->clock) +if (match_flags &DRM_MODE_MATCH_TIMINGS && + !drm_mode_match_timings (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_CLOCK && + !drm_mode_match_clock (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_FLAGS && + !drm_mode_match_flags (mode1, mode2)) +return false; + +if (match_flags &DRM_MODE_MATCH_3D_FLAGS && + !drm_mode_match_3d_flags (mode1, mode2))return false; -return drm_mode_equal_no_clocks (mode1, mode2); +if (match_flags &DRM_MODE_MATCH_ASPECT_RATIO && + !drm_mode_match_aspect_ratio (mode1, mode2)) +return false; + +return true; +} +EXPORT_SYMBOL (drm_mode_match); + +/** +* drm_mode_equal - test modes for equality +* @mode1: first mode +* @mode2: second mode +* +* Check to see if @mode1 and @mode2 are equivalent. +* +* Returns: +* True if the modes are equal, false otherwise. +*/ +bool drm_mode_equal (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) +{ +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal);@@ -981,13 +1065,13 @@ EXPORT_SYMBOL(drm_mode_equal);* Returns: * True if the modes are equal, false otherwise. */ -bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) +bool drm_mode_equal_no_clocks (const struct drm_display_mode *mode1, +const struct drm_display_mode *mode2) { -if ((mode1->flags &DRM_MODE_FLAG_3D_MASK ) != - (mode2->flags &DRM_MODE_FLAG_3D_MASK )) -return false; - -return drm_mode_equal_no_clocks_no_stereo (mode1, mode2); +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks);@@ -1005,21 +1089,9 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks);bool drm_mode_equal_no_clocks_no_stereo (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2) { -if (mode1->hdisplay == mode2->hdisplay && - mode1->hsync_start == mode2->hsync_start && - mode1->hsync_end == mode2->hsync_end && - mode1->htotal == mode2->htotal && - mode1->hskew == mode2->hskew && - mode1->vdisplay == mode2->vdisplay && - mode1->vsync_start == mode2->vsync_start && - mode1->vsync_end == mode2->vsync_end && - mode1->vtotal == mode2->vtotal && - mode1->vscan == mode2->vscan && - (mode1->flags & ~DRM_MODE_FLAG_3D_MASK ) == - (mode2->flags & ~DRM_MODE_FLAG_3D_MASK )) -return true; - -return false; +return drm_mode_match (mode1, mode2, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_FLAGS ); }EXPORT_SYMBOL (drm_mode_equal_no_clocks_no_stereo);include/drm/drm_modes.h +6
-0@@ -150,6 +150,12 @@ enum drm_mode_status {#define DRM_MODE_FLAG_3D_MAX DRM_MODE_FLAG_3D_SIDE_BY_SIDE_HALF +#define DRM_MODE_MATCH_TIMINGS (1 << 0) +#define DRM_MODE_MATCH_CLOCK (1 << 1) +#define DRM_MODE_MATCH_FLAGS (1 << 2) +#define DRM_MODE_MATCH_3D_FLAGS (1 << 3) +#define DRM_MODE_MATCH_ASPECT_RATIO (1 << 4) +/** * struct drm_display_mode - DRM kernel-internal display mode structure * @hdisplay: horizontal display size include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 503
Quoted 5 lines
include/drm/drm_modes.h +2
-0@@ -493,6 +499,9 @@ void drm_mode_copy(struct drm_display_mode *dst, const struct drm_display_mode *src);struct drm_display_mode *drm_mode_duplicate (struct drm_device *dev,const struct drm_display_mode *mode); +bool drm_mode_match(const struct drm_display_mode *mode1, + const struct drm_display_mode *mode2,Same here for the alignment
Quoted 6 lines
Quoted 6 lines
include/drm/drm_modes.h void drm_mode_copy(struct drm_display_mode *dst, · line 507
Quoted 4 lines
include/drm/drm_modes.h +1
-0+ unsigned int match_flags);bool drm_mode_equal (const struct drm_display_mode *mode1,const struct drm_display_mode *mode2); bool drm_mode_equal_no_clocks(const struct drm_display_mode *mode1,With the minor comments above, please feel free to use
Reviewed-by Shashank Sharma <[email protected]>
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 2/8 drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy
In reply to Nautiyal, Ankit KFrom: Ville Syrjälä <[email protected]>
Use drm_mode_equal_no_clocks_no_stereo() in drm_match_hdmi_mode_clock_tolerance() for consistency as we also use it in drm_match_hdmi_mode() and the cea mode matching functions.
This doesn't actually change anything since the input mode comes from detailed timings and we match it against edid_4k_modes[] which. So none of those modes can have stereo flags set.
--- drivers/gpu/drm/drm_edid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_edid.c +1 -1
@@ -3025,7 +3025,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks (to_match, hdmi_mode)) +if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode))return vic; }
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 2/8] drm/edid: Use drm_mode_match_no_clocks_no_stereo() for consistentcy
Regards
Shashank
Quoted 22 lines · Ankit K
From: Ville Syrjälä <[email protected]>
Use
drm_mode_equal_no_clocks_no_stereo()indrm_match_hdmi_mode_clock_tolerance()for consistency as we also use it indrm_match_hdmi_mode()and the cea mode matching functions.This doesn't actually change anything since the input mode comes from detailed timings and we match it against edid_4k_modes[] which. So none of those modes can have stereo flags set.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_edid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/drm_edid.c +0
-0
drivers/gpu/drm/drm_edid.c static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ · line 3030
Quoted 7 lines
drivers/gpu/drm/drm_edid.c +1
-1@@ -3025,7 +3025,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks (to_match, hdmi_mode)) +if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode))return vic; }
Quoted 1 line
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 3/8 drm/edid: Fix cea mode aspect ratio handling
In reply to Nautiyal, Ankit KFrom: Ville Syrjälä <[email protected]>
commit 6dffd431e229 ("drm: Add aspect ratio parsing in DRM layer") cause us to not send out any VICs in the AVI infoframes. That commit was since reverted, but if and when we add aspect ratio handing back we need to be more careful.
Let's handle this by considering the aspect ratio as a requirement for cea mode matching only if the passed in mode actually has a non-zero aspect ratio field. This will keep userspace that doesn't provide an aspect ratio working as before by matching it to the first otherwise equal cea mode. And once userspace starts to provide the aspect ratio it will be considerd a hard requirement for the match.
Also change the hdmi mode matching to use drm_mode_match() for consistency, but we don't match on aspect ratio there since the spec doesn't list a specific aspect ratio for those modes.
--- drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_edid.c +14 -4
@@ -2908,11 +2908,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)static u8 drm_match_cea_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;
@@ -2926,7 +2930,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_mcontinue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }
@@ -2943,11 +2947,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m*/ u8 drm_match_cea_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;
@@ -2961,7 +2969,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)continue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }
@@ -3008,6 +3016,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)static u8 drm_match_hdmi_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)
@@ -3025,7 +3034,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +if (drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }
@@ -3042,6 +3051,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_*/ static u8 drm_match_hdmi_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)
@@ -3057,7 +3067,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)if ((KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock1) ||KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock2)) && -drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }return 0 ;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/8] drm/edid: Fix cea mode aspect ratio handling
Regards
Shashank
Quoted 63 lines · Ankit K
From: Ville Syrjälä <[email protected]>
commit
6dffd431e229("drm: Add aspect ratio parsing in DRM layer") cause us to not send out any VICs in the AVI infoframes. That commit was since reverted, but if and when we add aspect ratio handing back we need to be more careful.Let's handle this by considering the aspect ratio as a requirement for cea mode matching only if the passed in mode actually has a non-zero aspect ratio field. This will keep userspace that doesn't provide an aspect ratio working as before by matching it to the first otherwise equal cea mode. And once userspace starts to provide the aspect ratio it will be considerd a hard requirement for the match.
Also change the hdmi mode matching to use
drm_mode_match()for consistency, but we don't match on aspect ratio there since the spec doesn't list a specific aspect ratio for those modes.Cc Shashank Sharma <[email protected]>Cc "Lin, Jia" <[email protected]>Cc Akashdeep Sharma <[email protected]>Cc Jim Bride <[email protected]>Cc Jose Abreu <[email protected]>Cc Daniel Vetter <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_edid.c +5
-1@@ -2908,11 +2908,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)static u8 drm_match_cea_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2926,7 +2930,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_mcontinue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -2943,11 +2947,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m*/ u8 drm_match_cea_mode (const struct drm_display_mode *to_match)
drivers/gpu/drm/drm_edid.c static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m · line 2958
Quoted 10 lines
drivers/gpu/drm/drm_edid.c +4
-0{ +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +
How about stereo flags ? CEA modes can be 3d and in that case we might want to add DRM_MODE_MATCH_3D_FLAGS here
- Shashank
Quoted 38 lines
drivers/gpu/drm/drm_edid.c +4
-2for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2961,7 +2969,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)continue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -3008,6 +3016,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)static u8 drm_match_hdmi_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)@@ -3025,7 +3034,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +if (drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }@@ -3042,6 +3051,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_*/ static u8 drm_match_hdmi_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)
drivers/gpu/drm/drm_edid.c static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) · line 3073
Quoted 8 lines
drivers/gpu/drm/drm_edid.c +1
-1@@ -3057,7 +3067,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)if ((KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock1) ||KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock2)) && -drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }return 0 ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 3/8] drm/edid: Fix cea mode aspect ratio handling
Quoted 73 lines · Shashank
Regards
Shashank
Quoted 67 lines · Ankit K
From: Ville Syrjälä <[email protected]>
commit
6dffd431e229("drm: Add aspect ratio parsing in DRM layer") cause us to not send out any VICs in the AVI infoframes. That commit was since reverted, but if and when we add aspect ratio handing back we need to be more careful.Let's handle this by considering the aspect ratio as a requirement for cea mode matching only if the passed in mode actually has a non-zero aspect ratio field. This will keep userspace that doesn't provide an aspect ratio working as before by matching it to the first otherwise equal cea mode. And once userspace starts to provide the aspect ratio it will be considerd a hard requirement for the match.
Also change the hdmi mode matching to use
drm_mode_match()for consistency, but we don't match on aspect ratio there since the spec doesn't list a specific aspect ratio for those modes.Cc Shashank Sharma <[email protected]>Cc "Lin, Jia" <[email protected]>Cc Akashdeep Sharma <[email protected]>Cc Jim Bride <[email protected]>Cc Jose Abreu <[email protected]>Cc Daniel Vetter <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_edid.c +6
-1@@ -2908,11 +2908,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)static u8 drm_match_cea_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2926,7 +2930,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_mcontinue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -2943,11 +2947,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m*/ u8 drm_match_cea_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;
Quoted 8 lines
drivers/gpu/drm/drm_edid.c cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode) · line 2919
Quoted 6 lines
drivers/gpu/drm/drm_edid.c +3
-0if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +How about stereo flags ? CEA modes can be 3d and in that case we might want to add
DRM_MODE_MATCH_3D_FLAGShere
There are no separate VICs for stereo vs. no stereo. So ignoring the stereo flags here seems like the correct thing to do.
Quoted 48 lines
- Shashank
Quoted 46 lines
drivers/gpu/drm/drm_edid.c +5
-3for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2961,7 +2969,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)continue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -3008,6 +3016,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)static u8 drm_match_hdmi_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)@@ -3025,7 +3034,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +if (drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }@@ -3042,6 +3051,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_*/ static u8 drm_match_hdmi_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)@@ -3057,7 +3067,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)if ((KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock1) ||KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock2)) && -drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }return 0 ;
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sharma, Shashank
Reviewed-byRe: [PATCH v3 3/8] drm/edid: Fix cea mode aspect ratio handling
Regards
Shashank
Quoted 77 lines · Ville Syrjälä
Quoted 76 lines · Shashank
Regards
Shashank
Quoted 70 lines · Ankit K
From: Ville Syrjälä <[email protected]>
commit
6dffd431e229("drm: Add aspect ratio parsing in DRM layer") cause us to not send out any VICs in the AVI infoframes. That commit was since reverted, but if and when we add aspect ratio handing back we need to be more careful.Let's handle this by considering the aspect ratio as a requirement for cea mode matching only if the passed in mode actually has a non-zero aspect ratio field. This will keep userspace that doesn't provide an aspect ratio working as before by matching it to the first otherwise equal cea mode. And once userspace starts to provide the aspect ratio it will be considerd a hard requirement for the match.
Also change the hdmi mode matching to use
drm_mode_match()for consistency, but we don't match on aspect ratio there since the spec doesn't list a specific aspect ratio for those modes.Cc Shashank Sharma <[email protected]>Cc "Lin, Jia" <[email protected]>Cc Akashdeep Sharma <[email protected]>Cc Jim Bride <[email protected]>Cc Jose Abreu <[email protected]>Cc Daniel Vetter <[email protected]>Cc Emil Velikov <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_edid.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_edid.c +6
-1@@ -2908,11 +2908,15 @@ cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode)static u8 drm_match_cea_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ; +if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2926,7 +2930,7 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_mcontinue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -2943,11 +2947,15 @@ static u8 drm_match_cea_mode_clock_tolerance(const struct drm_display_mode *to_m*/ u8 drm_match_cea_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)return 0 ;
Quoted 7 lines
Quoted 5 lines
drivers/gpu/drm/drm_edid.c cea_mode_alternate_timings(u8 vic, struct drm_display_mode *mode) · line 2919
Quoted 3 lines
drivers/gpu/drm/drm_edid.c +3
-0+if (to_match->picture_aspect_ratio) + match_flags |=DRM_MODE_MATCH_ASPECT_RATIO ; +How about stereo flags ? CEA modes can be 3d and in that case we might want to add
DRM_MODE_MATCH_3D_FLAGShereThere are no separate VICs for stereo vs. no stereo. So ignoring the stereo flags here seems like the correct thing to do.
Agree,
Quoted 40 lines
Quoted 40 lines
- Shashank
Quoted 39 lines
drivers/gpu/drm/drm_edid.c +4
-2for (vic =1 ; vic <ARRAY_SIZE (edid_cea_modes); vic++) {struct drm_display_mode cea_mode = edid_cea_modes[vic];unsigned int clock1, clock2;@@ -2961,7 +2969,7 @@ u8 drm_match_cea_mode(const struct drm_display_mode *to_match)continue ;do { -if (drm_mode_equal_no_clocks_no_stereo (to_match, &cea_mode)) +if (drm_mode_match (to_match, &cea_mode, match_flags))return vic; }while (cea_mode_alternate_timings (vic, &cea_mode)); }@@ -3008,6 +3016,7 @@ hdmi_mode_alternate_clock(const struct drm_display_mode *hdmi_mode)static u8 drm_match_hdmi_mode_clock_tolerance (const struct drm_display_mode *to_match,unsigned int clock_tolerance) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)@@ -3025,7 +3034,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_ abs(to_match->clock - clock2) > clock_tolerance) continue; -if (drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +if (drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }@@ -3042,6 +3051,7 @@ static u8 drm_match_hdmi_mode_clock_tolerance(const struct drm_display_mode *to_*/ static u8 drm_match_hdmi_mode (const struct drm_display_mode *to_match) { +unsigned int match_flags =DRM_MODE_MATCH_TIMINGS |DRM_MODE_MATCH_FLAGS ;u8 vic;if (!to_match->clock)@@ -3057,7 +3067,7 @@ static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match)
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/drm_edid.c static u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match) · line 3073
Quoted 7 lines
drivers/gpu/drm/drm_edid.c +1
-1if ((KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock1) ||KHZ2PICOS (to_match->clock) ==KHZ2PICOS (clock2)) && -drm_mode_equal_no_clocks_no_stereo (to_match, hdmi_mode)) +drm_mode_match (to_match, hdmi_mode, match_flags))return vic; }return 0 ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 4/8 drm: Add DRM client cap for aspect-ratio
In reply to Nautiyal, Ankit KFrom: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
This patch adds the client cap for aspect-ratio.
V3: rebase
--- drivers/gpu/drm/drm_ioctl.c | 5 +++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 7 +++++++ 3 files changed, 19 insertions(+)
drivers/gpu/drm/drm_ioctl.c +5 -0
@@ -325,6 +325,11 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) file_priv->atomic = req->value; file_priv->universal_planes = 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 ; }
include/drm/drm_file.h +7 -0
@@ -182,6 +182,13 @@ struct drm_file { unsigned atomic:1;/** +* @aspect_ratio_allowed: +* +* True if client has asked to expose the aspect-ratio flags with mode. +*/ + unsigned aspect_ratio_allowed:1; + +/** * @is_master: * * This client is the creator of @master. Protected by struct
include/uapi/drm/drm.h +7 -0
@@ -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 expose aspect ratio flags to userspace. +*/ +#define DRM_CLIENT_CAP_ASPECT_RATIO 4 +/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap {__u64 capability;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio
Regards
Shashank
Quoted 41 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
This patch adds the client cap for aspect-ratio.
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>V3: rebase
--- drivers/gpu/drm/drm_ioctl.c | 5 +++++ include/drm/drm_file.h | 7 +++++++ include/uapi/drm/drm.h | 7 +++++++ 3 files changed, 19 insertions(+)drivers/gpu/drm/drm_ioctl.c +5
-0@@ -325,6 +325,11 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) file_priv->atomic = req->value; file_priv->universal_planes = 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 ; }include/drm/drm_file.h +0
-0
include/drm/drm_file.h struct drm_file { · line 187
Quoted 6 lines
include/drm/drm_file.h +3
-0@@ -182,6 +182,13 @@ struct drm_file { unsigned atomic:1;/** +* @aspect_ratio_allowed: +* +* True if client has asked to expose the aspect-ratio flags with mode.
Minor reword, may be "True if client can handle picture aspect ratios, and has requested to pass this information along with the mode"
Quoted 12 lines
include/drm/drm_file.h +4
-0+*/ + unsigned aspect_ratio_allowed:1; + +/** * @is_master: * * This client is the creator of @master. Protected by struct include/uapi/drm/drm.h +0
-0
include/uapi/drm/drm.h struct drm_get_cap { · line 687
Quoted 8 lines
include/uapi/drm/drm.h +5
-0@@ -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 expose aspect ratio flags to userspace. +*/
Again "If set to 1, the DRM core will provide aspect ratio information in modes"
include/uapi/drm/drm.h struct drm_get_cap { · line 692
Quoted 5 lines
include/uapi/drm/drm.h +2
-0+#define DRM_CLIENT_CAP_ASPECT_RATIO 4 +/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */ struct drm_set_client_cap {__u64 capability;
With these optional review comments, please feel free to use
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Maarten Lankhorst
maintainerRe: [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio
In reply to Nautiyal, Ankit KOp 12-01-18 om 07:21 schreef Nautiyal, Ankit K:
Quoted 7 lines
From: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
Quoted 5 lines
This patch adds the client cap for aspect-ratio.
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>
What's missing from the commit message is why this needs to be a flag that userspace needs to enable, instead of something that only counts as an informative query.
I gathered from danvet that blindly exposing things breaks existing userspace, so could that information be added to the commit?
Also missing IGT tests, would be nice we at least get some verification things work as expected.
~Maarten
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio
Hi Marteen,
Thanks for the review comments. Please find my comments in-line.
Quoted 10 lines · Maarten Lankhorst
Op 12-01-18 om 07:21 schreef Nautiyal, Ankit K:
Quoted 9 lines
From: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
This patch adds the client cap for aspect-ratio.
Quoted 7 lines
Quoted 3 lines
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>What's missing from the commit message is why this needs to be a flag that userspace needs to enable, instead of something that only counts as an informative query.
I gathered from danvet that blindly exposing things breaks existing userspace, so could that information be added to the commit?
Agreed. This information indeed brings out the real reason for the patch. Will add the details in the commit message in the next patch-set.
Quoted 2 lines
Also missing IGT tests, would be nice we at least get some verification things work as expected.
Currently this is being tested with the corresponding userspace changes in weston compositor, but a simple IGT on the same lines of kms_3d can be prepared. Will work on that and include the reference in this series. I hope in the meanwhile, the other patches of the series would be continued to be reviewed.
Quoted 2 lines
~Maarten
Thanks & regards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio
Quoted 28 lines · On Thu, Jan 18, 2018 at 09:11:19PM +0530, [email protected] wrote:
Hi Marteen,
Thanks for the review comments. Please find my comments in-line.
Quoted 10 lines · Maarten Lankhorst
Op 12-01-18 om 07:21 schreef Nautiyal, Ankit K:
Quoted 9 lines
From: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
This patch adds the client cap for aspect-ratio.
Quoted 7 lines
Quoted 3 lines
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>What's missing from the commit message is why this needs to be a flag that userspace needs to enable, instead of something that only counts as an informative query.
I gathered from danvet that blindly exposing things breaks existing userspace, so could that information be added to the commit?
Agreed. This information indeed brings out the real reason for the patch. Will add the details in the commit message in the next patch-set.
Quoted 1 line
Quoted 5 lines
Quoted 1 line
Also missing IGT tests, would be nice we at least get some verification things work as expected.
Currently this is being tested with the corresponding userspace changes in weston compositor, but a simple IGT on the same lines of
kms_3dcan be prepared.
A separate test to check that the different aspect ratio modes are correctly enumerated, and filtered out when the cap is not set seems like a good idea.
As for actaully testing different aspect ratio modes, maybe just intergrate that into testdisplay?
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 4/8] drm: Add DRM client cap for aspect-ratio
Quoted 31 lines · Ville Syrjälä
Quoted 22 lines · On Thu, Jan 18, 2018 at 09:11:19PM +0530, [email protected] wrote:
Hi Marteen,
Thanks for the review comments. Please find my comments in-line.
Quoted 16 lines · Maarten Lankhorst
Op 12-01-18 om 07:21 schreef Nautiyal, Ankit K:
Quoted 7 lines
From: Ankit Nautiyal <[email protected]>
A new drm client cap is required to enable 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 information in modes or not.
Quoted 5 lines
This patch adds the client cap for aspect-ratio.
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>What's missing from the commit message is why this needs to be a flag that userspace needs to enable, instead of something that only counts as an informative query.
Quoted 8 lines
Quoted 1 line
I gathered from danvet that blindly exposing things breaks existing userspace, so could that information be added to the commit?
Agreed. This information indeed brings out the real reason for the patch. Will add the details in the commit message in the next patch-set.
Quoted 1 line
Also missing IGT tests, would be nice we at least get some verification things work as expected.
Currently this is being tested with the corresponding userspace changes in weston compositor, but a simple IGT on the same lines of
kms_3dcan be prepared.
Quoted 6 lines
A separate test to check that the different aspect ratio modes are correctly enumerated, and filtered out when the cap is not set seems like a good idea.
As for actaully testing different aspect ratio modes, maybe just intergrate that into testdisplay?
Alright. Will modify the testdisplay to have a "test_aspect_ratio_modes", which will just set the aspect ratio modes from the connector modelist, to verify the basic functionality.kms_aspect_ratio to do detailed testing will be taken later.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v4 4/8 drm: Add DRM client cap for aspect-ratio
In reply to Maarten LankhorstFrom: Ankit Nautiyal <[email protected]>
To enable aspect-ratio support in DRM, blindly exposing the aspect-ratio information along with mode, can break things in existing 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 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 information in modes or not.
This patch adds the client cap for aspect-ratio.
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.
--- drivers/gpu/drm/drm_ioctl.c | 5 +++++ include/drm/drm_file.h | 8 ++++++++ include/uapi/drm/drm.h | 7 +++++++ 3 files changed, 20 insertions(+)
drivers/gpu/drm/drm_ioctl.c +5 -0
@@ -325,6 +325,11 @@ drm_setclientcap(struct drm_device *dev, void *data, struct drm_file *file_priv) file_priv->atomic = req->value; file_priv->universal_planes = 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 ; }
include/drm/drm_file.h +8 -0
@@ -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
include/uapi/drm/drm.h +7 -0
@@ -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;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 5/8 drm: Handle aspect ratio info in atomic and legacy modeset paths
In reply to Nautiyal, Ankit KFrom: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit field aspect_ratio_allowed in drm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.
V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.
--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_atomic.c +58 -3
@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC
@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode); state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),
@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;
@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;
drivers/gpu/drm/drm_crtc.c +19 -0
@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;
@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;
@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );
include/drm/drm_atomic.h +2 -0
@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data
@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC
drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);
This still looks sketchy.
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
And for checking the user input I think we should probably just stick that into drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.
I *think* those three places should be sufficient to cover everything.
Quoted 58 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;
These would still clobber the current crtc state. So definitely don't want to do this.
Quoted 56 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 81 lines · Ville Syrjälä
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob. Is there any way to check from blob id (or by any other means),
if the data is for the mode, or edid, or gamma etc.
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode, and the aspect ratio is not supported.
Quoted 7 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the file_priv which has the aspect ratio capability information is not supplied to the drm_mode_convert_umode() or the functions calling, drm_mode_conver_umode(). At best we have drm_crtc_state.
I have added an aspect ratio allowed flag in drm_crtc_state->state so that its available in the functions calling drm_mode_convert_umode.
I am open to suggestion to avoid adding a new flag in drm_atomic_state, if there is a better way to let the drm_mode_convert_umode( ) know that user supports aspect ratio capability.
Quoted 63 lines
Quoted 63 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +1
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/*
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 6 lines
drivers/gpu/drm/drm_crtc.c +6
-0+* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Alright, so alternative way of doing this will be:
Avoid changing the crtc->state->mode.picture_aspect_ratio i.e kernel mode structure, but set the aspect ratio flags in the usermode to none, after calling the drm_mode_convert_to_umode().
Will take care of this in the next patchset.
Quoted 53 lines
Quoted 53 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 84 lines · Ankit K
Quoted 81 lines · Ville Syrjälä
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 8 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.
I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace I think a simple flag should do. If we come up with more uses like this then it might make sense to introduce some kind of optional filter function for blobs.
Quoted 11 lines
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 6 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.
Quoted 7 lines
Quoted 1 line
I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.
Simply passing the file_priv down would seem like the most obvious solution.
Quoted 146 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state, if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect ratio capability.Quoted 63 lines
Quoted 63 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +1
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 6 lines
drivers/gpu/drm/drm_crtc.c +6
-0+* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
Quoted 57 lines
Quoted 57 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:
Quoted 91 lines · Ville Syrjälä
Quoted 83 lines · Ankit K
Quoted 81 lines · Ville Syrjälä
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.
Quoted 5 lines
I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace I think a simple flag should do. If we come up with more uses like this then it might make sense to introduce some kind of optional filter function for blobs.
If my understanding is correct,
1. To be able to do this, we need to change in uapi.
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 10 lines
Quoted 10 lines
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 6 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Quoted 8 lines
Quoted 6 lines
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Simply passing the
file_privdown would seem like the most obvious solution.
This means we have to make change in various drivers and we have to pull the file_priv parameter three levels down. Should we think of a better way for doing this?
Quoted 78 lines
Quoted 78 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state, if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect ratio capability.Quoted 70 lines
Quoted 58 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Quoted 7 lines
Quoted 7 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that get_crtc is one of the place where the user mode aspect ratio flags must be filtered out, is this what you have in mind. I hope I did not misunderstand.
Changing the usermode aspect ratio flag bits, without change in the picture_aspect_ratio kernel mode will not result in both structures out of sync?
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
Quoted 53 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Regards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 97 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 91 lines · Ville Syrjälä
Quoted 90 lines · Ankit K
Quoted 81 lines · Ville Syrjälä
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.
Quoted 7 lines
Quoted 5 lines
I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace I think a simple flag should do. If we come up with more uses like this then it might make sense to introduce some kind of optional filter function for blobs.
If my understanding is correct,
1. To be able to do this, we need to change in uapi.
We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
Quoted 20 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 16 lines
Quoted 16 lines
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 6 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.
Quoted 6 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull the
file_priv
parameter three levels down. Should we think of a better way for doing this?
Coccinelle is pretty good at modifying function parameters.
Quoted 93 lines
Quoted 79 lines
Quoted 79 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state, if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect ratio capability.Quoted 70 lines
Quoted 58 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Quoted 7 lines
Quoted 7 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.
Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?
I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 102 lines · Ville Syrjälä
Quoted 101 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 95 lines · Ville Syrjälä
Quoted 82 lines · Ankit K
Quoted 81 lines · Ville Syrjälä
Quoted 70 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +29
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state,return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is +* supported. +* +* RETURNS: +* kernel-internal mode with updated picture aspect ratio value. +*/ + +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode (struct drm_crtc_state *state, +const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as +* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, · line 376
Quoted 8 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace I think a simple flag should do. If we come up with more uses like this then it might make sense to introduce some kind of optional filter function for blobs.
Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something). As per my understanding:
If a userspace needs to set a mode, it will just create a blob with drm_mode_mode_info, and get the blob-id. This blob-id would be supplied to drm_mode_atomic_ioctl as a crtc property mode_id.
At the kernel side, the crtc property mode_id is set by looking-up for mode blob from blob id. I am doing the change in the user mode aspect-ratio flags at this junction.
As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from the blob id, it will receive the same mode blob, with same aspect ratio info which the user had created using create blob ioctl. If it does want to use the blob, it has to come through the drm_mode_atomic_ioctl way, where aspect ratio flags are handled.
Quoted 20 lines
Quoted 20 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 16 lines
Quoted 16 lines
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 6 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull the
file_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the file_priv from drm_mode_atomic_ioctl --> drm_mode_atomic_set_property --> drm_atomic_crtc_set_property --> drm_mode_set_mode_prop_for_crtc--> drm_mode_convert_umode.
Instead, I tried to add a new field (allow_aspect_ratio) in drm_crtc_state which is already passed from the drm_mode_atomic_ioctl all the way to drm_mode_convert_umode.
-Regards
Ankit
Quoted 92 lines
Quoted 92 lines
Quoted 79 lines
Quoted 79 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state, if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect ratio capability.Quoted 70 lines
Quoted 58 lines
drivers/gpu/drm/drm_atomic.c +25
-2state->mode_blob = drm_property_create_blob(state->crtc->dev, sizeof(umode),@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state,if (IS_ERR (state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated. +* +* Allow the aspect ratio info in the userspace mode only if aspect ratio is +* supported. +*/ +void +drm_atomic_allow_aspect_ratio_for_umode (struct drm_crtc_state *state, +struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */ +if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value @@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc,else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Quoted 7 lines
Quoted 7 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.
Quoted 67 lines
Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 58 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
Quoted 52 lines
drivers/gpu/drm/drm_crtc.c +12
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ;@@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device *dev, crtc_resp->x = crtc->x; crtc_resp->y = crtc->y;if (crtc->enabled) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid =1 ;@@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } +/* If the user does not ask for aspect ratio, reset the aspect +* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +2
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state {* @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset +* @allow_aspect_ratio: allow the aspect ratio info to be passes to user * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics * @async_update: hint for asynchronous plane update * @planes: pointer to array of structures with per-plane data @@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Hi Ville,
As per our last discussion, following points were discussed:
1. To suppress the aspect-ratio info from getblob ioctl to a user that does not support it:
i. A new flag must be added to drm_blob_property to mark if the
blob has mode data.
ii. This flag must be set when the user tries do an atomic modeset.
iii. In the getblob ioctl, based on the above flag, it can be
determined that if the blob
has mode data, and the aspect ratio info can be suppressed in
getblob ioctl, if user does not support it.
2. Instead of adding aspect ratio capabilities in drm_atomic_state, pass on the file_priv which already has
the required information to the function drm_mode_convert_umode.
It will require addition of an new argument file_priv to several functions, but that is right thing to do,
as file_priv is the correct structure for the capability information.
3. Changing the usermode aspect ratio flag bits, without change in the picture_aspect_ratio would not matter, and does not need to be handled in this patch.
I just have one query here. We have agreed to modify drm_mode_convert_umode, to filter out the aspect-ratio
info if user has not set aspect-ratio capability, but do we need a similar change the drm_mode_convert_to_umode?
If we do, I am not sure if it would be possible to have the file_priv to /drm_atomic_set_mode_for_crtc/, which calls
drm_mode_convert_to_umode. The function /drm_atomic_set_mode_for_crtc/ is used to set mode, originating by kernel,
and make a blob from the kernel mode, which it saves in crtc_state.
This function /: drm_atomic_set_mode_for_crtc, /is called by several helper functions and driver functions, and passing
file_priv from all these functions does not seem to be plausible.
Any suggestions on how to handle this situation?
Regards,
Ankit
Quoted 168 lines · Ankit K
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 107 lines · Ville Syrjälä
Quoted 106 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 100 lines · Ville Syrjälä
Quoted 87 lines · Ankit K
Quoted 86 lines · Ville Syrjälä
Quoted 74 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +7
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state, return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is
+ * supported.
+ *
+ * RETURNS:
+ * kernel-internal mode with updated picture aspect ratio value.
+ */drivers/gpu/drm/drm_atomic.c +3
-0+ +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +8
-0+ const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as
drivers/gpu/drm/drm_atomic.c +6
-0+* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct · line 377
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace I think a simple flag should do. If we come up with more uses like this then it might make sense to introduce some kind of optional filter function for blobs.
Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something). As per my understanding:
If a userspace needs to set a mode, it will just create a blob withdrm_mode_mode_info, and get the blob-id. This blob-id would be supplied todrm_mode_atomic_ioctlas a crtc propertymode_id.
At the kernel side, the crtc propertymode_idis set by looking-up for mode blob from blob id. I am doing the change in the user mode aspect-ratio flags at this junction.As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from the blob id, it will receive the same mode blob, with same aspect ratio info which the user had created using create blob ioctl. If it does want to use the blob, it has to come through the
drm_mode_atomic_ioctlway, where aspect ratio flags are handled.Quoted 20 lines
Quoted 20 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 16 lines
Quoted 16 lines
If we can check that, I can make sure that aspect-ratio flags are taken care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 6 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Quoted 6 lines
Quoted 5 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull the
file_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the
file_privfromdrm_mode_atomic_ioctl-->drm_mode_atomic_set_property-->drm_atomic_crtc_set_property--> drm_mode_set_mode_prop_for_crtc-->drm_mode_convert_umode.
Quoted 175 lines
Instead, I tried to add a new field (
allow_aspect_ratio) indrm_crtc_statewhich is already passed from thedrm_mode_atomic_ioctlall the way todrm_mode_convert_umode.-Regards
AnkitQuoted 167 lines
Quoted 98 lines
Quoted 85 lines
Quoted 85 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state, if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect ratio capability.Quoted 76 lines
Quoted 64 lines
drivers/gpu/drm/drm_atomic.c +0
-0state->mode_blob = drm_property_create_blob(state->crtc->dev,sizeof(umode),
drivers/gpu/drm/drm_atomic.c +6
-1@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, if (IS_ERR(state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated.
+ *
+ * Allow the aspect ratio info in the userspace mode only if aspect ratio is
+ * supported.
+ */drivers/gpu/drm/drm_atomic.c +2
-0+void +drm_atomic_allow_aspect_ratio_for_umode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +5
-0+ struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */
drivers/gpu/drm/drm_atomic.c +5
-0+if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
drivers/gpu/drm/drm_atomic.c +3
-0@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't want to do this.
Quoted 7 lines
Quoted 7 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +0
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; @@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device*dev,
crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; if (crtc->enabled) {drivers/gpu/drm/drm_crtc.c +7
-0+/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; @@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } + /* If the user does not ask for aspect ratio, resetthe aspect
drivers/gpu/drm/drm_crtc.c +4
-0+* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +1
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state { * @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset + * @allow_aspect_ratio: allow the aspect ratio info to bepasses to user
* @legacy_cursor_update: hint to enforce legacy cursor
IOCTL semantics
* @async_update: hint for asynchronous plane update
* @planes: pointer to array of structures with per-plane datainclude/drm/drm_atomic.h +1
-0@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 33 lines · Ankit K
Hi Ville,
As per our last discussion, following points were discussed:
1. To suppress the aspect-ratio info from getblob ioctl to a user that does not support it:
i. A new flag must be added to
drm_blob_propertyto mark if the
blob has mode data.ii. This flag must be set when the user tries do an atomic modeset.
iii. In the getblob ioctl, based on the above flag, it can be
determined that if the blobhas mode data, and the aspect ratio info can be suppressed in
getblob ioctl, if user does not support it.2. Instead of adding aspect ratio capabilities in
drm_atomic_state, pass on thefile_privwhich already hasthe required information to the function
drm_mode_convert_umode.It will require addition of an new argument
file_privto several functions, but that is right thing to do,as
file_privis the correct structure for the capability information.3. Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratiowould not matter, and does not need to be handled in this patch.
Quoted 5 lines
I just have one query here. We have agreed to modify
drm_mode_convert_umode, to filter out the aspect-ratioinfo if user has not set aspect-ratio capability, but do we need a similar change the
drm_mode_convert_to_umode?
I think you maybe had those backwards.
drm_mode_convert_umode(), or more likely its relevant callers setcrtc and setproperty, need to reject the mode if the client cap is not set.
drm_mode_convert_to_umode(), or rather its callers getblob and getcrtc, need to filter out the flags.
Quoted 7 lines
If we do, I am not sure if it would be possible to have the
file_privto /drm_atomic_set_mode_for_crtc/, which calls
drm_mode_convert_to_umode. The function /drm_atomic_set_mode_for_crtc/ is used to set mode, originating by kernel,
Quoted 6 lines
and make a blob from the kernel mode, which it saves in
crtc_state.This function /:
drm_atomic_set_mode_for_crtc, /is called by several helper functions and driver functions, and passing
file_privfrom all these functions does not seem to be plausible.
I don't think we need to plumb it quite that deep. Doing the check in drm_atomic_crtc_set_property() should be sufficient.
Quoted 378 lines
Any suggestions on how to handle this situation?
Regards,
Ankit
Quoted 367 lines · Ankit K
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 110 lines · Ville Syrjälä
Quoted 109 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 103 lines · Ville Syrjälä
Quoted 88 lines · Ankit K
Quoted 87 lines · Ville Syrjälä
Quoted 75 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +7
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state, return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is
+ * supported.
+ *
+ * RETURNS:
+ * kernel-internal mode with updated picture aspect ratio value.
+ */drivers/gpu/drm/drm_atomic.c +3
-0+ +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +8
-0+ const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as
drivers/gpu/drm/drm_atomic.c +6
-0+* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct · line 377
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace
I think a simple flag should do. If we come up with more uses like this
then it might make sense to introduce some kind of optional filter function for blobs.Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something).
As per my understanding:
If a userspace needs to set a mode, it will just create a blob withdrm_mode_mode_info,
and get the blob-id. This blob-id would be supplied todrm_mode_atomic_ioctlas a crtc
propertymode_id.
At the kernel side, the crtc propertymode_idis set by looking-up for mode blob from blob id.
I am doing the change in the user mode aspect-ratio flags at this junction.As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from
the blob id, it will receive the same mode blob, with same aspect ratio info which the user had
created using create blob ioctl. If it does want to use the blob, it has to come through thedrm_mode_atomic_ioctlway, where aspect ratio flags are handled.Quoted 23 lines
Quoted 23 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 19 lines
Quoted 19 lines
If we can check that, I can make sure that aspect-ratio flags are taken
care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 7 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull
thefile_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the
file_privfromdrm_mode_atomic_ioctl-->drm_mode_atomic_set_property-->drm_atomic_crtc_set_property--> drm_mode_set_mode_prop_for_crtc-->drm_mode_convert_umode.Instead, I tried to add a new field (
allow_aspect_ratio) indrm_crtc_statewhich is
already passed from thedrm_mode_atomic_ioctlall the way todrm_mode_convert_umode.-Regards
AnkitQuoted 173 lines
Quoted 104 lines
Quoted 90 lines
Quoted 90 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso
that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state,
if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect
ratio capability.Quoted 78 lines
Quoted 65 lines
drivers/gpu/drm/drm_atomic.c +0
-0state->mode_blob = drm_property_create_blob(state->crtc->dev,sizeof(umode),
drivers/gpu/drm/drm_atomic.c +6
-1@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, if (IS_ERR(state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated.
+ *
+ * Allow the aspect ratio info in the userspace mode only if aspect ratio is
+ * supported.
+ */drivers/gpu/drm/drm_atomic.c +2
-0+void +drm_atomic_allow_aspect_ratio_for_umode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +5
-0+ struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */
drivers/gpu/drm/drm_atomic.c +5
-0+if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
drivers/gpu/drm/drm_atomic.c +3
-0@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't
want to do this.Quoted 8 lines
Quoted 8 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +0
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; @@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device*dev,
crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; if (crtc->enabled) {drivers/gpu/drm/drm_crtc.c +7
-0+/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; @@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } + /* If the user does not ask for aspect ratio, resetthe aspect
drivers/gpu/drm/drm_crtc.c +4
-0+* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +1
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state { * @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset + * @allow_aspect_ratio: allow the aspect ratio info to bepasses to user
* @legacy_cursor_update: hint to enforce legacy cursor
IOCTL semantics
* @async_update: hint for asynchronous plane update
* @planes: pointer to array of structures with per-plane datainclude/drm/drm_atomic.h +1
-0@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Hi Ville,
Thanks yet again to look into this.
I am still skeptical about rejecting the mode, if aspect ratio cap is not set. Perhaps I am not aware with the userspace expectations.
Please find my response inline:
Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Ankit K
Hi Ville,
As per our last discussion, following points were discussed:
1. To suppress the aspect-ratio info from getblob ioctl to a user that does not support it:
i. A new flag must be added to
drm_blob_propertyto mark if the
blob has mode data.ii. This flag must be set when the user tries do an atomic modeset.
iii. In the getblob ioctl, based on the above flag, it can be
determined that if the blobhas mode data, and the aspect ratio info can be suppressed in
getblob ioctl, if user does not support it.2. Instead of adding aspect ratio capabilities in
drm_atomic_state, pass on thefile_privwhich already hasthe required information to the function
drm_mode_convert_umode.It will require addition of an new argument
file_privto several functions, but that is right thing to do,as
file_privis the correct structure for the capability information.3. Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratiowould not matter, and does not need to be handled in this patch.I just have one query here. We have agreed to modify
drm_mode_convert_umode, to filter out the aspect-ratio
Quoted 6 lines
Quoted 2 lines
info if user has not set aspect-ratio capability, but do we need a similar change the
drm_mode_convert_to_umode?I think you maybe had those backwards.
drm_mode_convert_umode(), or more likely its relevant callers setcrtc and setproperty, need to reject the mode if the client cap is not set.
I guess, rejecting the mode, altogether can break the existing user-spaces.
Current user-spaces, oblivious of the aspect-ratio capability in drm, will not set the aspect-ratio capability. Some of them, might have some garbage value in the aspect ratio bits of the user mode. If we reject such modes, the user-spaces that were earlier working will break.
(But if we are sure, that the aspect ratio flag bits will all be reset, then it makes sense to reject the mode.)
Instead of rejecting such modes, if we just only ignore the aspect ratio bits in such cases, and carry on with the modeset for the given user mode, the behaviour would be intact, just as prior to the aspect ratio changes.
Quoted 2 lines
drm_mode_convert_to_umode(), or rather its callers getblob and getcrtc, need to filter out the flags.
Yes right. I'll be filtering out the flags in the getblob and getcrtc functions.
Thanks & Regards,
Ankit
Quoted 6 lines
Quoted 6 lines
If we do, I am not sure if it would be possible to have the
file_privto /drm_atomic_set_mode_for_crtc/, which calls
drm_mode_convert_to_umode. The function /drm_atomic_set_mode_for_crtc/ is used to set mode, originating by kernel,
Quoted 381 lines
Quoted 6 lines
and make a blob from the kernel mode, which it saves in
crtc_state.This function /:
drm_atomic_set_mode_for_crtc, /is called by several helper functions and driver functions, and passing
file_privfrom all these functions does not seem to be plausible.I don't think we need to plumb it quite that deep. Doing the check in
drm_atomic_crtc_set_property()should be sufficient.Quoted 372 lines
Any suggestions on how to handle this situation?
Regards,
Ankit
Quoted 363 lines · Ankit K
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 110 lines · Ville Syrjälä
Quoted 109 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 103 lines · Ville Syrjälä
Quoted 88 lines · Ankit K
Quoted 87 lines · Ville Syrjälä
Quoted 75 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +7
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state, return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is
+ * supported.
+ *
+ * RETURNS:
+ * kernel-internal mode with updated picture aspect ratio value.
+ */drivers/gpu/drm/drm_atomic.c +3
-0+ +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +8
-0+ const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as
drivers/gpu/drm/drm_atomic.c +6
-0+* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct · line 377
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace
I think a simple flag should do. If we come up with more uses like this
then it might make sense to introduce some kind of optional filter function for blobs.Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something).
As per my understanding:
If a userspace needs to set a mode, it will just create a blob withdrm_mode_mode_info,
and get the blob-id. This blob-id would be supplied todrm_mode_atomic_ioctlas a crtc
propertymode_id.
At the kernel side, the crtc propertymode_idis set by looking-up for mode blob from blob id.
I am doing the change in the user mode aspect-ratio flags at this junction.As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from
the blob id, it will receive the same mode blob, with same aspect ratio info which the user had
created using create blob ioctl. If it does want to use the blob, it has to come through thedrm_mode_atomic_ioctlway, where aspect ratio flags are handled.Quoted 23 lines
Quoted 23 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 19 lines
Quoted 19 lines
If we can check that, I can make sure that aspect-ratio flags are taken
care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 7 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull
thefile_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the
file_privfromdrm_mode_atomic_ioctl-->drm_mode_atomic_set_property-->drm_atomic_crtc_set_property--> drm_mode_set_mode_prop_for_crtc-->drm_mode_convert_umode.Instead, I tried to add a new field (
allow_aspect_ratio) indrm_crtc_statewhich is
already passed from thedrm_mode_atomic_ioctlall the way todrm_mode_convert_umode.-Regards
AnkitQuoted 172 lines
Quoted 103 lines
Quoted 89 lines
Quoted 89 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso
that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state,
if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect
ratio capability.Quoted 78 lines
Quoted 65 lines
drivers/gpu/drm/drm_atomic.c +0
-0state->mode_blob = drm_property_create_blob(state->crtc->dev,sizeof(umode),
drivers/gpu/drm/drm_atomic.c +6
-1@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, if (IS_ERR(state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated.
+ *
+ * Allow the aspect ratio info in the userspace mode only if aspect ratio is
+ * supported.
+ */drivers/gpu/drm/drm_atomic.c +2
-0+void +drm_atomic_allow_aspect_ratio_for_umode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +5
-0+ struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */
drivers/gpu/drm/drm_atomic.c +5
-0+if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
drivers/gpu/drm/drm_atomic.c +3
-0@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't
want to do this.Quoted 8 lines
Quoted 8 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +0
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; @@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device*dev,
crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; if (crtc->enabled) {drivers/gpu/drm/drm_crtc.c +7
-0+/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; @@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } + /* If the user does not ask for aspect ratio, resetthe aspect
drivers/gpu/drm/drm_crtc.c +4
-0+* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +1
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state { * @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset + * @allow_aspect_ratio: allow the aspect ratio info to bepasses to user
* @legacy_cursor_update: hint to enforce legacy cursor
IOCTL semantics
* @async_update: hint for asynchronous plane update
* @planes: pointer to array of structures with per-plane datainclude/drm/drm_atomic.h +1
-0@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Quoted 54 lines · Ankit K
Hi Ville,
Thanks yet again to look into this.
I am still skeptical about rejecting the mode, if aspect ratio cap is not set.
Perhaps I am not aware with the userspace expectations.Please find my response inline:
Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Ankit K
Hi Ville,
As per our last discussion, following points were discussed:
1. To suppress the aspect-ratio info from getblob ioctl to a user that does not support it:
i. A new flag must be added to
drm_blob_propertyto mark if the
blob has mode data.ii. This flag must be set when the user tries do an atomic modeset.
iii. In the getblob ioctl, based on the above flag, it can be
determined that if the blobhas mode data, and the aspect ratio info can be suppressed in
getblob ioctl, if user does not support it.2. Instead of adding aspect ratio capabilities in
drm_atomic_state, pass on thefile_privwhich already hasthe required information to the function
drm_mode_convert_umode.It will require addition of an new argument
file_privto several functions, but that is right thing to do,as
file_privis the correct structure for the capability information.3. Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratiowould not matter, and does not need to be handled in this patch.I just have one query here. We have agreed to modify
drm_mode_convert_umode, to filter out the aspect-ratioQuoted 6 lines
Quoted 2 lines
info if user has not set aspect-ratio capability, but do we need a similar change the
drm_mode_convert_to_umode?I think you maybe had those backwards.
drm_mode_convert_umode(), or more likely its relevant callers setcrtc and setproperty, need to reject the mode if the client cap is not set.
Quoted 8 lines
I guess, rejecting the mode, altogether can break the existing user-spaces. Current user-spaces, oblivious of the aspect-ratio capability in drm, will not set the aspect-ratio capability.
Some of them, might have some garbage value in the aspect ratio bits of the user mode. If we reject such
modes, the user-spaces that were earlier working will break. (But if we are sure, that the aspect ratio flag bits will all be reset, then it makes sense to reject the mode.)
We already reject all unspecified flags.
Quoted 402 lines
Instead of rejecting such modes, if we just only ignore the aspect ratio bits in such cases, and carry on with the
modeset for the given user mode, the behaviour would be intact, just as prior to the aspect ratio changes.Quoted 2 lines
drm_mode_convert_to_umode(), or rather its callers getblob and getcrtc, need to filter out the flags.Yes right. I'll be filtering out the flags in the getblob and getcrtc functions.
Thanks & Regards,
AnkitQuoted 387 lines
Quoted 6 lines
If we do, I am not sure if it would be possible to have the
file_privto /drm_atomic_set_mode_for_crtc/, which calls
drm_mode_convert_to_umode. The function /drm_atomic_set_mode_for_crtc/ is used to set mode, originating by kernel,Quoted 6 lines
and make a blob from the kernel mode, which it saves in
crtc_state.This function /:
drm_atomic_set_mode_for_crtc, /is called by several helper functions and driver functions, and passing
file_privfrom all these functions does not seem to be plausible.I don't think we need to plumb it quite that deep. Doing the check in
drm_atomic_crtc_set_property()should be sufficient.Quoted 372 lines
Any suggestions on how to handle this situation?
Regards,
Ankit
Quoted 363 lines · Ankit K
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 110 lines · Ville Syrjälä
Quoted 109 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 103 lines · Ville Syrjälä
Quoted 88 lines · Ankit K
Quoted 87 lines · Ville Syrjälä
Quoted 75 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +7
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state, return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is
+ * supported.
+ *
+ * RETURNS:
+ * kernel-internal mode with updated picture aspect ratio value.
+ */drivers/gpu/drm/drm_atomic.c +3
-0+ +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +8
-0+ const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as
drivers/gpu/drm/drm_atomic.c +6
-0+* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct · line 377
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace
I think a simple flag should do. If we come up with more uses like this
then it might make sense to introduce some kind of optional filter function for blobs.Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something).
As per my understanding:
If a userspace needs to set a mode, it will just create a blob withdrm_mode_mode_info,
and get the blob-id. This blob-id would be supplied todrm_mode_atomic_ioctlas a crtc
propertymode_id.
At the kernel side, the crtc propertymode_idis set by looking-up for mode blob from blob id.
I am doing the change in the user mode aspect-ratio flags at this junction.As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from
the blob id, it will receive the same mode blob, with same aspect ratio info which the user had
created using create blob ioctl. If it does want to use the blob, it has to come through thedrm_mode_atomic_ioctlway, where aspect ratio flags are handled.Quoted 23 lines
Quoted 23 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 19 lines
Quoted 19 lines
If we can check that, I can make sure that aspect-ratio flags are taken
care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 7 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull
thefile_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the
file_privfromdrm_mode_atomic_ioctl-->drm_mode_atomic_set_property-->drm_atomic_crtc_set_property--> drm_mode_set_mode_prop_for_crtc-->drm_mode_convert_umode.Instead, I tried to add a new field (
allow_aspect_ratio) indrm_crtc_statewhich is
already passed from thedrm_mode_atomic_ioctlall the way todrm_mode_convert_umode.-Regards
AnkitQuoted 172 lines
Quoted 103 lines
Quoted 89 lines
Quoted 89 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso
that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state,
if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect
ratio capability.Quoted 78 lines
Quoted 65 lines
drivers/gpu/drm/drm_atomic.c +0
-0state->mode_blob = drm_property_create_blob(state->crtc->dev,sizeof(umode),
drivers/gpu/drm/drm_atomic.c +6
-1@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, if (IS_ERR(state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated.
+ *
+ * Allow the aspect ratio info in the userspace mode only if aspect ratio is
+ * supported.
+ */drivers/gpu/drm/drm_atomic.c +2
-0+void +drm_atomic_allow_aspect_ratio_for_umode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +5
-0+ struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */
drivers/gpu/drm/drm_atomic.c +5
-0+if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
drivers/gpu/drm/drm_atomic.c +3
-0@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't
want to do this.Quoted 8 lines
Quoted 8 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +0
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; @@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device*dev,
crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; if (crtc->enabled) {drivers/gpu/drm/drm_crtc.c +7
-0+/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; @@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } + /* If the user does not ask for aspect ratio, resetthe aspect
drivers/gpu/drm/drm_crtc.c +4
-0+* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +1
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state { * @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset + * @allow_aspect_ratio: allow the aspect ratio info to bepasses to user
* @legacy_cursor_update: hint to enforce legacy cursor
IOCTL semantics
* @async_update: hint for asynchronous plane update
* @planes: pointer to array of structures with per-plane datainclude/drm/drm_atomic.h +1
-0@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 5/8] drm: Handle aspect ratio info in atomic and legacy modeset paths
Hi Ville,
I have addressed your review comments (including the policy regarding, rejection of mode with aspect ratio, if no aspect ratio cap)
and other suggestions in the next patch-set. I will be sending the next patch-set, shortly.
Regards,
Ankit
Quoted 63 lines · Ville Syrjälä
Quoted 54 lines · Ankit K
Hi Ville,
Thanks yet again to look into this.
I am still skeptical about rejecting the mode, if aspect ratio cap is not set.
Perhaps I am not aware with the userspace expectations.Please find my response inline:
Quoted 37 lines · Ville Syrjälä
Quoted 36 lines · Ankit K
Hi Ville,
As per our last discussion, following points were discussed:
1. To suppress the aspect-ratio info from getblob ioctl to a user that does not support it:
i. A new flag must be added to
drm_blob_propertyto mark if the
blob has mode data.ii. This flag must be set when the user tries do an atomic modeset.
iii. In the getblob ioctl, based on the above flag, it can be
determined that if the blobhas mode data, and the aspect ratio info can be suppressed in
getblob ioctl, if user does not support it.2. Instead of adding aspect ratio capabilities in
drm_atomic_state, pass on thefile_privwhich already hasthe required information to the function
drm_mode_convert_umode.It will require addition of an new argument
file_privto several functions, but that is right thing to do,as
file_privis the correct structure for the capability information.3. Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratiowould not matter, and does not need to be handled in this patch.I just have one query here. We have agreed to modify
drm_mode_convert_umode, to filter out the aspect-ratioQuoted 6 lines
Quoted 2 lines
info if user has not set aspect-ratio capability, but do we need a similar change the
drm_mode_convert_to_umode?I think you maybe had those backwards.
drm_mode_convert_umode(), or more likely its relevant callers setcrtc and setproperty, need to reject the mode if the client cap is not set.Quoted 8 lines
I guess, rejecting the mode, altogether can break the existing user-spaces. Current user-spaces, oblivious of the aspect-ratio capability in drm, will not set the aspect-ratio capability.
Some of them, might have some garbage value in the aspect ratio bits of the user mode. If we reject such
modes, the user-spaces that were earlier working will break. (But if we are sure, that the aspect ratio flag bits will all be reset, then it makes sense to reject the mode.)
Quoted 401 lines
We already reject all unspecified flags.
Quoted 399 lines
Instead of rejecting such modes, if we just only ignore the aspect ratio bits in such cases, and carry on with the
modeset for the given user mode, the behaviour would be intact, just as prior to the aspect ratio changes.Quoted 2 lines
drm_mode_convert_to_umode(), or rather its callers getblob and getcrtc, need to filter out the flags.Yes right. I'll be filtering out the flags in the getblob and getcrtc functions.
Thanks & Regards,
AnkitQuoted 387 lines
Quoted 6 lines
If we do, I am not sure if it would be possible to have the
file_privto /drm_atomic_set_mode_for_crtc/, which calls
drm_mode_convert_to_umode. The function /drm_atomic_set_mode_for_crtc/ is used to set mode, originating by kernel,Quoted 6 lines
and make a blob from the kernel mode, which it saves in
crtc_state.This function /:
drm_atomic_set_mode_for_crtc, /is called by several helper functions and driver functions, and passing
file_privfrom all these functions does not seem to be plausible.I don't think we need to plumb it quite that deep. Doing the check in
drm_atomic_crtc_set_property()should be sufficient.Quoted 372 lines
Any suggestions on how to handle this situation?
Regards,
Ankit
Quoted 363 lines · Ankit K
Hi Ville,
I still have some queries regarding the handling of aspect ratio flags in getblob ioctl.
Please find below my responses inline.
Quoted 110 lines · Ville Syrjälä
Quoted 109 lines · Ankit K
Hi Ville,
Appreciate your time and the suggestions.
Please find my response inline:Quoted 103 lines · Ville Syrjälä
Quoted 88 lines · Ankit K
Quoted 87 lines · Ville Syrjälä
Quoted 75 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
If the user mode does not support aspect-ratio, and requests for a modeset, then the flag bits representing aspect ratio in the given user-mode must be rejected.
Similarly, 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. adds a new bit fieldaspect_ratio_allowedindrm_atomic_state, which is set only if the aspect-ratio is supported by the user.
2. discards the aspect-ratio info from the user mode while preparing kernel mode structure, during modeset, if the user does not support aspect ratio.
3. avoids setting the aspect-ratio info in user-mode, while converting user-mode from the kernel-mode.Signed-off-by Ankit Nautiyal <[email protected]>V3: Addressed review comments from Ville:
-Do not corrupt the current crtc state by updating aspect ratio on the fly.--- drivers/gpu/drm/drm_atomic.c | 61 +++++++++++++++++++++++++++++++++++++++++--- drivers/gpu/drm/drm_crtc.c | 19 ++++++++++++++ include/drm/drm_atomic.h | 2 ++ 3 files changed, 79 insertions(+), 3 deletions(-)drivers/gpu/drm/drm_atomic.c +7
-0@@ -316,6 +316,35 @@ static s32 __user *get_out_fence_for_crtc(struct drm_atomic_state *state, return fence_ptr; } +/** +* drm_atomic_allow_aspect_ratio_for_kmode +* @state: the crtc state +* @mode: kernel-internal mode, which is used to create a duplicate mode, +* with updated picture aspect ratio. +* +* Allow the aspect ratio info in the kernel mode only if aspect ratio is
+ * supported.
+ *
+ * RETURNS:
+ * kernel-internal mode with updated picture aspect ratio value.
+ */drivers/gpu/drm/drm_atomic.c +3
-0+ +struct drm_display_mode * +drm_atomic_allow_aspect_ratio_for_kmode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +8
-0+ const struct drm_display_mode *mode) +{ +struct drm_atomic_state *atomic_state = state->state; +struct drm_display_mode *ar_kmode; + + ar_kmode =drm_mode_duplicate (state->crtc->dev, mode); +/* +* If aspect ratio is not supported, set the picture aspect ratio as
drivers/gpu/drm/drm_atomic.c +6
-0+* NONE. +*/ +if (atomic_state && !atomic_state->allow_aspect_ratio) + ar_kmode->picture_aspect_ratio =HDMI_PICTURE_ASPECT_NONE ; +return ar_kmode; +}/** * drm_atomic_set_mode_for_crtc - set mode for CRTC drivers/gpu/drm/drm_atomic.c int drm_atomic_set_mode_for_crtc(struct · line 377
Quoted 9 lines
drivers/gpu/drm/drm_atomic.c +4
-1@@ -341,7 +370,10 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, state->mode_blob =NULL ;if (mode) { -drm_mode_convert_to_umode (&umode, mode); +struct drm_display_mode *ar_mode; + + ar_mode =drm_atomic_allow_aspect_ratio_for_kmode (state, mode); +drm_mode_convert_to_umode (&umode, ar_mode);This still looks sketchy.
Quoted 7 lines
Quoted 3 lines
I believe there are just two places where we need to filter out the aspect ratio flags from the umode, namely the getblob and getcrtc ioctls.
AFAIK The getblob ioctl can be called for edid blob, gamma, ctm blob, etc. apart from the mode blob.
Is there any way to check from blob id (or by any other means), if the data is for the mode, or edid, or gamma etc.I think we'd have to somehow mark the mode blobs as special. Until we have more need for cleaning up blobs before returning them to userspace
I think a simple flag should do. If we come up with more uses like this
then it might make sense to introduce some kind of optional filter function for blobs.Quoted 6 lines
Quoted 2 lines
If my understanding is correct,
1. To be able to do this, we need to change in uapi.We should be fine with an internal flag. Obviously it won't be set for blobs freshly created by userspace, but that's fine because we do no other error checking for them either. The error checking will happen when the user tries to actually use the blob.
I am not sure why getblob ioctl should even come into picture. (Perhaps I am missing something).
As per my understanding:
If a userspace needs to set a mode, it will just create a blob withdrm_mode_mode_info,
and get the blob-id. This blob-id would be supplied todrm_mode_atomic_ioctlas a crtc
propertymode_id.
At the kernel side, the crtc propertymode_idis set by looking-up for mode blob from blob id.
I am doing the change in the user mode aspect-ratio flags at this junction.As far as getblob ioctl is concerned, if the user does call getblob ioctl for getting mode blob from
the blob id, it will receive the same mode blob, with same aspect ratio info which the user had
created using create blob ioctl. If it does want to use the blob, it has to come through thedrm_mode_atomic_ioctlway, where aspect ratio flags are handled.Quoted 23 lines
Quoted 23 lines
2. Whenever the userspace creates a blob for mode, the new flag/class for blob type needs to be set.
Do you think that it's worth the effort?
Quoted 19 lines
Quoted 19 lines
If we can check that, I can make sure that aspect-ratio flags are taken
care of, if the blob is for mode,
and the aspect ratio is not supported.Quoted 7 lines
And for checking the user input I think we should probably just stick that into
drm_mode_convert_umode(). Looks like we never call that from anywhere but the atomic/setprop and setcrtc paths with a non-NULL argument.I *think* those three places should be sufficient to cover everything.
Agreed. Infact I tried to do that first, but the only problem we have here, is that, the
file_priv
which has the aspect ratio capability information is not supplied to thedrm_mode_convert_umode()
or the functions calling,drm_mode_conver_umode(). At best we havedrm_crtc_state.Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Simply passing the
file_privdown would seem like the most obvious solution.This means we have to make change in various drivers and we have to pull
thefile_priv
parameter three levels down. Should we think of a better way for doing this?Coccinelle is pretty good at modifying function parameters.
Thanks for pointing out Coccinelle, will defintely try that out. But my question here is whether we really want to drag the
file_privfromdrm_mode_atomic_ioctl-->drm_mode_atomic_set_property-->drm_atomic_crtc_set_property--> drm_mode_set_mode_prop_for_crtc-->drm_mode_convert_umode.Instead, I tried to add a new field (
allow_aspect_ratio) indrm_crtc_statewhich is
already passed from thedrm_mode_atomic_ioctlall the way todrm_mode_convert_umode.-Regards
AnkitQuoted 172 lines
Quoted 103 lines
Quoted 89 lines
Quoted 89 lines
I have added an aspect ratio allowed flag in
drm_crtc_state->stateso
that its available in the
functions callingdrm_mode_convert_umode.I am open to suggestion to avoid adding a new flag in
drm_atomic_state,
if there is a better
way to let thedrm_mode_convert_umode( )know that user supports aspect
ratio capability.Quoted 78 lines
Quoted 65 lines
drivers/gpu/drm/drm_atomic.c +0
-0state->mode_blob = drm_property_create_blob(state->crtc->dev,sizeof(umode),
drivers/gpu/drm/drm_atomic.c +6
-1@@ -349,10 +381,11 @@ int drm_atomic_set_mode_for_crtc(struct drm_crtc_state *state, if (IS_ERR(state->mode_blob))return PTR_ERR (state->mode_blob); -drm_mode_copy (&state->mode, mode); +drm_mode_copy (&state->mode, ar_mode); state->enable = true;DRM_DEBUG_ATOMIC ("Set [MODE:%s] for CRTC state %p\n" , - mode->name, state); + ar_mode->name, state); +drm_mode_destroy (state->crtc->dev, ar_mode); }else {memset (&state->mode,0 ,sizeof (state->mode)); state->enable = false;@@ -436,6 +469,25 @@ drm_atomic_replace_property_blob_from_id(struct drm_device *dev, }/** +* drm_atomic_allow_aspect_ratio_for_umode +* @state: the crtc state +* @umode: userspace mode, whose aspect ratio flag bits are to be updated.
+ *
+ * Allow the aspect ratio info in the userspace mode only if aspect ratio is
+ * supported.
+ */drivers/gpu/drm/drm_atomic.c +2
-0+void +drm_atomic_allow_aspect_ratio_for_umode(struct drm_crtc_state*state,
drivers/gpu/drm/drm_atomic.c +5
-0+ struct drm_mode_modeinfo *umode) +{ +struct drm_atomic_state *atomic_state = state->state; + +/* Reset the aspect ratio flags if aspect ratio is not supported */
drivers/gpu/drm/drm_atomic.c +5
-0+if (atomic_state && !atomic_state->allow_aspect_ratio) + umode->flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); +} + +/** * drm_atomic_crtc_set_property - set property on CRTC * @crtc: the drm CRTC to set a property on * @state: the state object to update with the new property value
drivers/gpu/drm/drm_atomic.c +3
-0@@ -464,6 +516,9 @@ int drm_atomic_crtc_set_property(struct drm_crtc *crtc, else if (property == config->prop_mode_id) {struct drm_property_blob *mode =drm_property_lookup_blob (dev, val); +drm_atomic_allow_aspect_ratio_for_umode (state, + (struct drm_mode_modeinfo *) + mode->data); ret =drm_atomic_set_mode_prop_for_crtc (state, mode);drm_property_blob_put (mode);return ret;drivers/gpu/drm/drm_crtc.c +0
-0drivers/gpu/drm/drm_crtc.c int drm_mode_getcrtc(struct drm_device *dev, · line 434
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0@@ -425,6 +425,13 @@ int drm_mode_getcrtc(struct drm_device *dev,drm_modeset_lock (&crtc->mutex,NULL );if (crtc->state) {if (crtc->state->enable) { +/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->state->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;These would still clobber the current crtc state. So definitely don't
want to do this.Quoted 8 lines
Quoted 8 lines
Alright, so alternative way of doing this will be:
Avoid changing thecrtc->state->mode.picture_aspect_ratioi.e kernel mode structure,
but set the aspect ratio flags in the usermode to none, after calling thedrm_mode_convert_to_umode().Will take care of this in the next patchset.
I gave a thought about it again. As you have mentioned earlier that
get_crtcis one of the
place where the user mode aspect ratio flags must be filtered out, is this what you have
in mind. I hope I did not misunderstand.Quoted 3 lines
Changing the usermode aspect ratio flag bits, without change in the
picture_aspect_ratio
kernel mode will not result in both structures out of sync?I don't think that should really matter. I suppose we might get one extra modeset when the user feeds that mode back via setcrtc/atomic, but meh. And actually the aspect ratio should only affect the infoframe, so we should be able to eventually eliminate that extra modeset and just update the infoframe instead.
Quoted 60 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/drm_crtc.c +0
-0drm_mode_convert_to_umode (&crtc_resp->mode, &crtc->state->mode); crtc_resp->mode_valid =1 ; @@ -435,6 +442,13 @@ int drm_mode_getcrtc(struct drm_device*dev,
crtc_resp->x = crtc->x; crtc_resp->y = crtc->y; if (crtc->enabled) {drivers/gpu/drm/drm_crtc.c +7
-0+/* +* If the aspect-ratio is not required by the, +* userspace, do not set the aspect-ratio flags. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc->mode.picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;drm_mode_convert_to_umode(&crtc_resp->mode, &crtc->mode); crtc_resp->mode_valid = 1; @@ -610,6 +624,11 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data, goto out; } + /* If the user does not ask for aspect ratio, resetthe aspect
drivers/gpu/drm/drm_crtc.c +4
-0+* ratio bits in the usermode. +*/ +if (!file_priv->aspect_ratio_allowed) + crtc_req->mode.flags &= (~DRM_MODE_FLAG_PIC_AR_MASK ); ret =drm_mode_convert_umode (mode, &crtc_req->mode);if (ret) {DRM_DEBUG_KMS ("Invalid mode\n" );include/drm/drm_atomic.h +1
-0@@ -237,6 +237,7 @@ struct __drm_private_objs_state { * @ref: count of all references to this state (will not be freed until zero) * @dev: parent DRM device * @allow_modeset: allow full modeset + * @allow_aspect_ratio: allow the aspect ratio info to bepasses to user
* @legacy_cursor_update: hint to enforce legacy cursor
IOCTL semantics
* @async_update: hint for asynchronous plane update
* @planes: pointer to array of structures with per-plane datainclude/drm/drm_atomic.h +1
-0@@ -256,6 +257,7 @@ struct drm_atomic_state {struct drm_device *dev; bool allow_modeset : 1; + bool allow_aspect_ratio : 1; bool legacy_cursor_update : 1; bool async_update : 1;struct __drm_planes_state *planes;Signature · 1 line
2.7.4Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-develRegards,
Ankit
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 6/8 drm: Expose modes with aspect ratio, only if requested
In reply to Nautiyal, Ankit KFrom: Ankit Nautiyal <[email protected]>
We parse the EDID and add all the modes in the connector's modelist. This adds CEA modes with aspect ratio information too, regadless of if user space requested this information or not.
This patch prunes the modes with aspect-ratio information, from a connector's modelist, if the user-space has not set the aspect ratio DRM client cap.
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.
--- drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_connector.c +27 -4
@@ -1502,7 +1502,8 @@ static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connereturn connector->encoder; } -static bool drm_mode_expose_to_userspace (const struct drm_display_mode *mode, +static bool drm_mode_expose_to_userspace (const struct drm_display_mode *last_mode, +const struct drm_display_mode *mode,const struct drm_file *file_priv) {/*
@@ -1511,6 +1512,18 @@ static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,*/ 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. +*/ +if (!file_priv->aspect_ratio_allowed && + mode->picture_aspect_ratio !=HDMI_PICTURE_ASPECT_NONE && +drm_mode_match (mode, last_mode, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS )) +return false;return true; }
@@ -1522,6 +1535,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,struct drm_connector *connector;struct drm_encoder *encoder;struct drm_display_mode *mode; +struct drm_display_mode last_valid_mode;int mode_count =0 ;int encoders_count =0 ;int ret =0 ;
@@ -1577,9 +1591,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, out_resp->connection = connector->status;/* delayed so we get modes regardless of pre-fill_modes state */ +memset (&last_valid_mode,0 ,sizeof (struct drm_display_mode ));list_for_each_entry (mode, &connector->modes, head) -if (drm_mode_expose_to_userspace (mode, file_priv)) +if (drm_mode_expose_to_userspace (&last_valid_mode, mode, file_priv)) { mode_count++; +drm_mode_copy (&last_valid_mode, mode); + }/* * This ioctl is called twice, once to determine how much space is
@@ -1588,10 +1605,16 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,if ((out_resp->count_modes >= mode_count) && mode_count) { copied =0 ; mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long )out_resp->modes_ptr; +memset (&last_valid_mode,0 ,sizeof (struct drm_display_mode ));list_for_each_entry (mode, &connector->modes, head) { -if (!drm_mode_expose_to_userspace (mode, file_priv)) +if (!drm_mode_expose_to_userspace (&last_valid_mode, + mode, + file_priv))continue ; - +if (!file_priv->aspect_ratio_allowed) + mode->picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ; +drm_mode_copy (&last_valid_mode, mode);drm_mode_convert_to_umode (&u_mode, mode);if (copy_to_user (mode_ptr + copied, &u_mode,sizeof (u_mode))) {
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 6/8] drm: Expose modes with aspect ratio, only if requested
Quoted 60 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
We parse the EDID and add all the modes in the connector's modelist. This adds CEA modes with aspect ratio information too, regadless of if user space requested this information or not.
This patch prunes the modes with aspect-ratio information, from a connector's modelist, if the user-space has not set the aspect ratio DRM client cap.
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Cc Jose Abreu <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>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.
--- drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_connector.c +14
-1@@ -1502,7 +1502,8 @@ static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connereturn connector->encoder; } -static bool drm_mode_expose_to_userspace (const struct drm_display_mode *mode, +static bool drm_mode_expose_to_userspace (const struct drm_display_mode *last_mode, +const struct drm_display_mode *mode,const struct drm_file *file_priv) {/* @@ -1511,6 +1512,18 @@ static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,*/ 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. +*/ +if (!file_priv->aspect_ratio_allowed && + mode->picture_aspect_ratio !=HDMI_PICTURE_ASPECT_NONE && +drm_mode_match (mode, last_mode, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS )) +return false;return true; }
drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1538
Quoted 4 lines
drivers/gpu/drm/drm_connector.c +1
-0@@ -1522,6 +1535,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,struct drm_connector *connector;struct drm_encoder *encoder;struct drm_display_mode *mode; +struct drm_display_mode last_valid_mode;
A pointer should be sufficient.
Quoted 22 lines
drivers/gpu/drm/drm_connector.c +5
-1int mode_count =0 ;int encoders_count =0 ;int ret =0 ;@@ -1577,9 +1591,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, out_resp->connection = connector->status;/* delayed so we get modes regardless of pre-fill_modes state */ +memset (&last_valid_mode,0 ,sizeof (struct drm_display_mode ));list_for_each_entry (mode, &connector->modes, head) -if (drm_mode_expose_to_userspace (mode, file_priv)) +if (drm_mode_expose_to_userspace (&last_valid_mode, mode, file_priv)) { mode_count++; +drm_mode_copy (&last_valid_mode, mode); + }/* * This ioctl is called twice, once to determine how much space is @@ -1588,10 +1605,16 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,if ((out_resp->count_modes >= mode_count) && mode_count) { copied =0 ; mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long )out_resp->modes_ptr; +memset (&last_valid_mode,0 ,sizeof (struct drm_display_mode ));
drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1616
Quoted 10 lines
drivers/gpu/drm/drm_connector.c +6
-2list_for_each_entry (mode, &connector->modes, head) { -if (!drm_mode_expose_to_userspace (mode, file_priv)) +if (!drm_mode_expose_to_userspace (&last_valid_mode, + mode, + file_priv))continue ; - +if (!file_priv->aspect_ratio_allowed) + mode->picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;
Here you're clobbering the internal mode structure. That's not acceptable.
Quoted 6 lines
drivers/gpu/drm/drm_connector.c +1
-0+drm_mode_copy (&last_valid_mode, mode);drm_mode_convert_to_umode (&u_mode, mode);if (copy_to_user (mode_ptr + copied, &u_mode,sizeof (u_mode))) {Signature · 1 line
2.7.4
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v3 6/8] drm: Expose modes with aspect ratio, only if requested
Hi Ville,
Thanks for the comments and suggestions.
Please find my response inline:
Quoted 58 lines · Ville Syrjälä
Quoted 57 lines · Ankit K
From: Ankit Nautiyal <[email protected]>
We parse the EDID and add all the modes in the connector's modelist. This adds CEA modes with aspect ratio information too, regadless of if user space requested this information or not.
This patch prunes the modes with aspect-ratio information, from a connector's modelist, if the user-space has not set the aspect ratio DRM client cap.
Cc Ville Syrjala <[email protected]>Cc Shashank Sharma <[email protected]>Cc Jose Abreu <[email protected]>Signed-off-by Ankit Nautiyal <[email protected]>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.
--- drivers/gpu/drm/drm_connector.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_connector.c +14
-1@@ -1502,7 +1502,8 @@ static struct drm_encoder *drm_connector_get_encoder(struct drm_connector *connereturn connector->encoder; } -static bool drm_mode_expose_to_userspace (const struct drm_display_mode *mode, +static bool drm_mode_expose_to_userspace (const struct drm_display_mode *last_mode, +const struct drm_display_mode *mode,const struct drm_file *file_priv) {/* @@ -1511,6 +1512,18 @@ static bool drm_mode_expose_to_userspace(const struct drm_display_mode *mode,*/ 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. +*/ +if (!file_priv->aspect_ratio_allowed && + mode->picture_aspect_ratio !=HDMI_PICTURE_ASPECT_NONE && +drm_mode_match (mode, last_mode, +DRM_MODE_MATCH_TIMINGS | +DRM_MODE_MATCH_CLOCK | +DRM_MODE_MATCH_FLAGS | +DRM_MODE_MATCH_3D_FLAGS )) +return false;
Quoted 8 lines
drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1538
Quoted 7 lines
drivers/gpu/drm/drm_connector.c +1
-0return true; }@@ -1522,6 +1535,7 @@ int drm_mode_getconnector(struct drm_device *dev, void *data,struct drm_connector *connector;struct drm_encoder *encoder;struct drm_display_mode *mode; +struct drm_display_mode last_valid_mode;A pointer should be sufficient.
Thanks for pointing that out, will just save the address of last valid mode.
Quoted 27 lines
Quoted 27 lines
drivers/gpu/drm/drm_connector.c +7
-2int mode_count =0 ;int encoders_count =0 ;int ret =0 ;@@ -1577,9 +1591,12 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, out_resp->connection = connector->status;/* delayed so we get modes regardless of pre-fill_modes state */ +memset (&last_valid_mode,0 ,sizeof (struct drm_display_mode ));list_for_each_entry (mode, &connector->modes, head) -if (drm_mode_expose_to_userspace (mode, file_priv)) +if (drm_mode_expose_to_userspace (&last_valid_mode, mode, file_priv)) { mode_count++; +drm_mode_copy (&last_valid_mode, mode); + }/* * This ioctl is called twice, once to determine how much space is @@ -1588,10 +1605,16 @@ int drm_mode_getconnector(struct drm_device *dev, void *data, if ((out_resp->count_modes >= mode_count) && mode_count) { copied = 0; mode_ptr = (struct drm_mode_modeinfo __user *)(unsigned long)out_resp->modes_ptr; + memset(&last_valid_mode, 0, sizeof(struct drm_display_mode)); list_for_each_entry(mode, &connector->modes, head) { -if (!drm_mode_expose_to_userspace (mode, file_priv)) + if (!drm_mode_expose_to_userspace(&last_valid_mode, + mode,
Quoted 8 lines
drivers/gpu/drm/drm_connector.c int drm_mode_getconnector(struct drm_device *dev, void *data, · line 1616
Quoted 6 lines
drivers/gpu/drm/drm_connector.c +4
-1+ file_priv))continue ; - +if (!file_priv->aspect_ratio_allowed) + mode->picture_aspect_ratio = +HDMI_PICTURE_ASPECT_NONE ;Here you're clobbering the internal mode structure. That's not acceptable.
I assumed, that the usermode, and the internal mode structure both should have aspect ratio info as none, if the user does not support aspect ratio.
If that's not required, I can set the aspect ratio flags in usermode after the call to drm_mode_convert_to_umode().
-Ankit
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/drm_connector.c +1
-0+drm_mode_copy (&last_valid_mode, mode);drm_mode_convert_to_umode (&u_mode, mode);if (copy_to_user (mode_ptr + copied, &u_mode,sizeof (u_mode))) {Signature · 1 line
2.7.4
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 7/8 drm: Add aspect ratio parsing in DRM layer
In reply to Nautiyal, Ankit KFrom: "Sharma, Shashank" <[email protected]>
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/
V3: modified the aspect-ratio check in drm_mode_equal as per new flags provided by Ville.
https://patchwork.freedesktop.org/patch/188043/
--- drivers/gpu/drm/drm_modes.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_modes.c +32 -1
@@ -1050,7 +1050,8 @@ bool drm_mode_equal(const struct drm_display_mode *mode1,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,21 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out, out->vrefresh = in->vrefresh; out->flags = in->flags; out->type = in->type; + out->flags &= ~DRM_MODE_FLAG_PIC_AR_MASK ; + +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 +1682,21 @@ int drm_mode_convert_umode(struct drm_display_mode *out,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 */ + 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;
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v3 8/8 drm: Add and handle new aspect ratios in DRM layer
In reply to Nautiyal, Ankit KFrom: "Sharma, Shashank" <[email protected]>
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/
V3: rebase
--- drivers/gpu/drm/drm_modes.c | 12 ++++++++++++ include/uapi/drm/drm_mode.h | 6 ++++++ 2 files changed, 18 insertions(+)
drivers/gpu/drm/drm_modes.c +12 -0
@@ -1631,6 +1631,12 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,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 DRM_MODE_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 ;
@@ -1692,6 +1698,12 @@ int drm_mode_convert_umode(struct drm_display_mode *out,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 ;
include/uapi/drm/drm_mode.h +6 -0
@@ -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. */
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel