drm plane fixes and additional checks
Subsystems (2)
This set has a bunch of fixes and additional checks on top of Jesse's drm plane series.
Jesse, feel free to squash some or all of these with your patches.
PATCH 1/7 drm: Zero initialize drm_mode_fb_cmd2 in legacy addfb ioctl handler
From: Ville Syrjälä <[email protected]>
Avoids having junk in offsets[] and pitches[] arrays.
--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -1
@@ -1967,7 +1967,7 @@ int drm_mode_addfb(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_fb_cmd *or = data; -struct drm_mode_fb_cmd2 r; +struct drm_mode_fb_cmd2 r = {};struct drm_mode_config *config = &dev->mode_config;struct drm_framebuffer *fb;int ret =0 ;
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 1/7] drm: Zero initialize drm_mode_fb_cmd2 in legacy addfb ioctl handler
Quoted 14 lines · On Fri, 11 Nov 2011 18:04:01 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Avoids having junk in offsets[] and pitches[] arrays.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c int drm_mode_addfb(struct drm_device *dev, · line 1973
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +1
-1@@ -1967,7 +1967,7 @@ int drm_mode_addfb(struct drm_device *dev, void *data, struct drm_file *file_priv) { struct drm_mode_fb_cmd *or = data; -struct drm_mode_fb_cmd2 r; +struct drm_mode_fb_cmd2 r = {};struct drm_mode_config *config = &dev->mode_config;struct drm_framebuffer *fb;int ret =0 ;
Yep, doesn't hurt...
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/7 drm: plane: Fix size of formats memcpy()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -1
@@ -563,7 +563,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,return -ENOMEM ; } -memcpy (plane->format_types, formats, format_count); +memcpy (plane->format_types, formats,sizeof (uint32_t ) * format_count); plane->format_count = format_count; plane->possible_crtcs = possible_crtcs;
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 2/7] drm: plane: Fix size of formats memcpy()
Quoted 12 lines · On Fri, 11 Nov 2011 18:04:02 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c int drm_plane_init(struct drm_device *dev, struct drm_plane *plane, · line 569
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +1
-1@@ -563,7 +563,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,return -ENOMEM ; } -memcpy (plane->format_types, formats, format_count); +memcpy (plane->format_types, formats,sizeof (uint32_t ) * format_count); plane->format_count = format_count; plane->possible_crtcs = possible_crtcs;
Duh thank you.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/7 drm: plane: Clear plane.crtc and plane.fb after disable_plane()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
These are the only indication to user space that the plane was disabled.
--- drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +2 -0
@@ -1677,6 +1677,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,/* No fb means shut it down */ if (!plane_req->fb_id) { plane->funcs->disable_plane (plane); + plane->crtc =NULL ; + plane->fb =NULL ; goto out; }
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 3/7] drm: plane: Clear plane.crtc and plane.fb after disable_plane()
Quoted 14 lines · On Fri, 11 Nov 2011 18:04:03 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
These are the only indication to user space that the plane was disabled.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +0
-0
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1684
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c +2
-0@@ -1677,6 +1677,8 @@ int drm_mode_setplane(struct drm_device *dev, void *data,/* No fb means shut it down */ if (!plane_req->fb_id) { plane->funcs->disable_plane (plane); + plane->crtc =NULL ; + plane->fb =NULL ; goto out; }
A 0 return code should also indicate that the function succeeded, but this doesn't hurt.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/7 drm: plane: Check source coordinates
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Make sure the source coordinates stay within the buffer.
--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +23 -0
@@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_crtc *crtc;struct drm_framebuffer *fb;int ret =0 ; +unsigned int fb_width, fb_height;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); + fb_width = fb->width <<16 ; + fb_height = fb->height <<16 ; + +/* Make sure source coordinates are inside the fb. */ +if (plane_req->src_w > fb_width || + plane_req->src_x > fb_width - plane_req->src_w || + plane_req->src_h > fb_height || + plane_req->src_y > fb_height - plane_req->src_h) { +DRM_DEBUG_KMS ("Invalid source coordinates " +"%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n" , + plane_req->src_w >>16 , + ((plane_req->src_w &0xffff ) *15625 ) >>10 , + plane_req->src_h >>16 , + ((plane_req->src_h &0xffff ) *15625 ) >>10 , + plane_req->src_x >>16 , + ((plane_req->src_x &0xffff ) *15625 ) >>10 , + plane_req->src_y >>16 , + ((plane_req->src_y &0xffff ) *15625 ) >>10 ); + ret = -EINVAL ; + goto out; + } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/7] drm: plane: Check source coordinates
Quoted 40 lines · On Fri, 11 Nov 2011 18:04:04 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Make sure the source coordinates stay within the buffer.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +16
-0@@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_crtc *crtc;struct drm_framebuffer *fb;int ret =0 ; +unsigned int fb_width, fb_height;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); + fb_width = fb->width <<16 ; + fb_height = fb->height <<16 ; + +/* Make sure source coordinates are inside the fb. */ +if (plane_req->src_w > fb_width || + plane_req->src_x > fb_width - plane_req->src_w || + plane_req->src_h > fb_height || + plane_req->src_y > fb_height - plane_req->src_h) { + DRM_DEBUG_KMS("Invalid source coordinates " + "%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n", + plane_req->src_w >> 16, + ((plane_req->src_w & 0xffff) * 15625) >> 10, + plane_req->src_h >> 16, + ((plane_req->src_h & 0xffff) * 15625) >> 10, + plane_req->src_x >> 16,
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1730
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0+ ((plane_req->src_x &0xffff ) *15625 ) >>10 , + plane_req->src_y >>16 , + ((plane_req->src_y & 0xffff) * 15625) >> 10); + ret = -EINVAL ; + goto out; + } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,
Good sanity check (saves the drivers from having to do it), but I wonder if we can use a better return value like ENOSPC or something to make it easier for userspace to figure out.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 4/7] drm: plane: Check source coordinates
Quoted 49 lines · Jesse Barnes
Quoted 46 lines · On Fri, 11 Nov 2011 18:04:04 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Make sure the source coordinates stay within the buffer.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +22
-0@@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_crtc *crtc;struct drm_framebuffer *fb;int ret =0 ; +unsigned int fb_width, fb_height;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); + fb_width = fb->width <<16 ; + fb_height = fb->height <<16 ; + +/* Make sure source coordinates are inside the fb. */ +if (plane_req->src_w > fb_width || + plane_req->src_x > fb_width - plane_req->src_w || + plane_req->src_h > fb_height || + plane_req->src_y > fb_height - plane_req->src_h) { +DRM_DEBUG_KMS ("Invalid source coordinates " +"%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n" , + plane_req->src_w >>16 , + ((plane_req->src_w &0xffff ) *15625 ) >>10 , + plane_req->src_h >>16 , + ((plane_req->src_h &0xffff ) *15625 ) >>10 , + plane_req->src_x >>16 , + ((plane_req->src_x &0xffff ) *15625 ) >>10 , + plane_req->src_y >>16 , + ((plane_req->src_y &0xffff ) *15625 ) >>10 ); + ret = -EINVAL ; + goto out; + }
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1730
Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +1
-0+ ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,Good sanity check (saves the drivers from having to do it), but I wonder if we can use a better return value like ENOSPC or something to make it easier for userspace to figure out.
Yeah, getting EINVAL for every kind of failure is rather annoying. The only issue I have with ENOSPC is the strerror() output. It doesn't exactly fit this use case. But if there's nothing better I'm OK with ENOSPC.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 4/7] drm: plane: Check source coordinates
Quoted 59 lines · On Fri, 11 Nov 2011 19:18:52 +0200 Ville Syrjälä…
Quoted 49 lines · Jesse Barnes
Quoted 46 lines · On Fri, 11 Nov 2011 18:04:04 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Make sure the source coordinates stay within the buffer.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +22
-0@@ -1654,6 +1654,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_crtc *crtc;struct drm_framebuffer *fb;int ret =0 ; +unsigned int fb_width, fb_height;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -1702,6 +1703,28 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); + fb_width = fb->width <<16 ; + fb_height = fb->height <<16 ; + +/* Make sure source coordinates are inside the fb. */ +if (plane_req->src_w > fb_width || + plane_req->src_x > fb_width - plane_req->src_w || + plane_req->src_h > fb_height || + plane_req->src_y > fb_height - plane_req->src_h) { +DRM_DEBUG_KMS ("Invalid source coordinates " +"%01u.%06ux%01u.%06u+%01u.%06u+%01u.%06u\n" , + plane_req->src_w >>16 , + ((plane_req->src_w &0xffff ) *15625 ) >>10 , + plane_req->src_h >>16 , + ((plane_req->src_h &0xffff ) *15625 ) >>10 , + plane_req->src_x >>16 , + ((plane_req->src_x &0xffff ) *15625 ) >>10 , + plane_req->src_y >>16 , + ((plane_req->src_y &0xffff ) *15625 ) >>10 ); + ret = -EINVAL ; + goto out; + }Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1730
Quoted 4 lines
drivers/gpu/drm/drm_crtc.c +1
-0+ ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,Good sanity check (saves the drivers from having to do it), but I wonder if we can use a better return value like ENOSPC or something to make it easier for userspace to figure out.
Quoted 4 lines
Yeah, getting EINVAL for every kind of failure is rather annoying. The only issue I have with ENOSPC is the
strerror()output. It doesn't exactly fit this use case. But if there's nothing better I'm OK with ENOSPC.
Yeah, dunno what's best. Check out include/asm-generic/errno-base.h and errno.h; maybe you'll find a better fit.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/7 drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Help drivers a little by guaranteeing that crtc_x+crtc_w and crtc_y+crtc_h don't overflow.
--- drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +12 -0
@@ -1725,6 +1725,18 @@ int drm_mode_setplane(struct drm_device *dev, void *data, goto out; } +/* Give drivers some help against integer overflows */ +if (plane_req->crtc_w >INT_MAX || + plane_req->crtc_x >INT_MAX - (int32_t ) plane_req->crtc_w || + plane_req->crtc_h >INT_MAX || + plane_req->crtc_y >INT_MAX - (int32_t ) plane_req->crtc_h) { +DRM_DEBUG_KMS ("Invalid CRTC coordinates %ux%u+%d+%d\n" , + plane_req->crtc_w, plane_req->crtc_h, + plane_req->crtc_x, plane_req->crtc_y); + ret = -EINVAL ; + goto out; + } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl
Quoted 23 lines · On Fri, 11 Nov 2011 18:04:05 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Help drivers a little by guaranteeing that crtc_x+crtc_w and crtc_y+crtc_h don't overflow.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +5
-0@@ -1725,6 +1725,18 @@ int drm_mode_setplane(struct drm_device *dev, void *data, goto out; } +/* Give drivers some help against integer overflows */ +if (plane_req->crtc_w >INT_MAX || + plane_req->crtc_x >INT_MAX - (int32_t ) plane_req->crtc_w || + plane_req->crtc_h >INT_MAX || + plane_req->crtc_y >INT_MAX - (int32_t ) plane_req->crtc_h) {
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1742
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0+DRM_DEBUG_KMS ("Invalid CRTC coordinates %ux%u+%d+%d\n" , + plane_req->crtc_w, plane_req->crtc_h, + plane_req->crtc_x, plane_req->crtc_y); + ret = -EINVAL ; + goto out; + } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,
Not sure this helps much in practice, since the drivers will have to validate the target CRTC rect against the actual pipe dimensions anyway.
But it doesn't hurt either, so:
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl
Quoted 31 lines · Jesse Barnes
Quoted 28 lines · On Fri, 11 Nov 2011 18:04:05 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Help drivers a little by guaranteeing that crtc_x+crtc_w and crtc_y+crtc_h don't overflow.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +10
-0@@ -1725,6 +1725,18 @@ int drm_mode_setplane(struct drm_device *dev, void *data, goto out; } +/* Give drivers some help against integer overflows */ +if (plane_req->crtc_w >INT_MAX || + plane_req->crtc_x >INT_MAX - (int32_t ) plane_req->crtc_w || + plane_req->crtc_h >INT_MAX || + plane_req->crtc_y >INT_MAX - (int32_t ) plane_req->crtc_h) { +DRM_DEBUG_KMS ("Invalid CRTC coordinates %ux%u+%d+%d\n" , + plane_req->crtc_w, plane_req->crtc_h, + plane_req->crtc_x, plane_req->crtc_y); + ret = -EINVAL ; + goto out;
Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1742
Quoted 5 lines
drivers/gpu/drm/drm_crtc.c +2
-0+ } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,Not sure this helps much in practice, since the drivers will have to validate the target CRTC rect against the actual pipe dimensions anyway.
My master plan is that drivers would just stick these into a drm_region (introduced in my other patchset) and clip that to the pipe dimensions.
Signature · 2 lines
Ville Syrjälä Intel OTC
Re: [PATCH 5/7] drm: plane: Check crtc coodrinates against integer overflows in setplane ioctl
Quoted 41 lines · On Fri, 11 Nov 2011 19:11:39 +0200 Ville Syrjälä…
Quoted 31 lines · Jesse Barnes
Quoted 28 lines · On Fri, 11 Nov 2011 18:04:05 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Help drivers a little by guaranteeing that crtc_x+crtc_w and crtc_y+crtc_h don't overflow.
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 12 ++++++++++++ 1 files changed, 12 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +10
-0@@ -1725,6 +1725,18 @@ int drm_mode_setplane(struct drm_device *dev, void *data, goto out; } +/* Give drivers some help against integer overflows */ +if (plane_req->crtc_w >INT_MAX || + plane_req->crtc_x >INT_MAX - (int32_t ) plane_req->crtc_w || + plane_req->crtc_h >INT_MAX || + plane_req->crtc_y >INT_MAX - (int32_t ) plane_req->crtc_h) { +DRM_DEBUG_KMS ("Invalid CRTC coordinates %ux%u+%d+%d\n" , + plane_req->crtc_w, plane_req->crtc_h, + plane_req->crtc_x, plane_req->crtc_y); + ret = -EINVAL ; + goto out;Quoted 8 lines
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1742
Quoted 5 lines
drivers/gpu/drm/drm_crtc.c +2
-0+ } + ret = plane->funcs->update_plane(plane, crtc, fb, plane_req->crtc_x, plane_req->crtc_y, plane_req->crtc_w, plane_req->crtc_h,Not sure this helps much in practice, since the drivers will have to validate the target CRTC rect against the actual pipe dimensions anyway.
Quoted 2 lines
My master plan is that drivers would just stick these into a
drm_region(introduced in my other patchset) and clip that to the pipe dimensions.
Ok that makes sense. The new patchset looks really nice; having helpers to support new chipsets and for regions should make things a lot cleaner.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/7 drm: plane: Make 'formats' parameter to drm_plane_init() const
In reply to [email protected]From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc.c | 2 +- include/drm/drm_crtc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_crtc.c +1 -1
@@ -548,7 +548,7 @@ EXPORT_SYMBOL(drm_encoder_cleanup);int drm_plane_init (struct drm_device *dev,struct drm_plane *plane,unsigned long possible_crtcs,const struct drm_plane_funcs *funcs, -uint32_t *formats,uint32_t format_count) +const uint32_t *formats,uint32_t format_count) {mutex_lock (&dev->mode_config.mutex);
include/drm/drm_crtc.h +1 -1
@@ -727,7 +727,7 @@ extern int drm_plane_init(struct drm_device *dev,struct drm_plane *plane, unsigned long possible_crtcs, const struct drm_plane_funcs *funcs, - uint32_t *formats, uint32_t format_count); + const uint32_t *formats, uint32_t format_count);extern void drm_plane_cleanup (struct drm_plane *plane);extern void drm_encoder_cleanup (struct drm_encoder *encoder);
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/7] drm: plane: Make 'formats' parameter to drm_plane_init() const
Quoted 26 lines · On Fri, 11 Nov 2011 18:04:06 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 2 +- include/drm/drm_crtc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_crtc.c +1
-1@@ -548,7 +548,7 @@ EXPORT_SYMBOL(drm_encoder_cleanup);int drm_plane_init (struct drm_device *dev,struct drm_plane *plane,unsigned long possible_crtcs,const struct drm_plane_funcs *funcs, -uint32_t *formats,uint32_t format_count) +const uint32_t *formats,uint32_t format_count) {mutex_lock (&dev->mode_config.mutex);include/drm/drm_crtc.h +0
-0
include/drm/drm_crtc.h extern int drm_plane_init(struct drm_device *dev, · line 733
Quoted 8 lines
include/drm/drm_crtc.h +1
-1@@ -727,7 +727,7 @@ extern int drm_plane_init(struct drm_device *dev,struct drm_plane *plane, unsigned long possible_crtcs, const struct drm_plane_funcs *funcs, - uint32_t *formats, uint32_t format_count); + const uint32_t *formats, uint32_t format_count);extern void drm_plane_cleanup (struct drm_plane *plane);extern void drm_encoder_cleanup (struct drm_encoder *encoder);
Yeah good fix. I made the structure const at ickle's request (once I stopped assigning it directly) but didn't update the prototype.
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 7/7 drm: plane: Check that the fb pixel format is supported by the plane
In reply to [email protected]From: Ville Syrjälä <[email protected]>
--- drivers/gpu/drm/drm_crtc.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
drivers/gpu/drm/drm_crtc.c +11 -0
@@ -1655,6 +1655,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_framebuffer *fb;int ret =0 ;unsigned int fb_width, fb_height; +int i;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;
@@ -1703,6 +1704,16 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); +/* Check whether this plane supports the fb pixel format. */ +for (i =0 ; i < plane->format_count; i++) +if (fb->pixel_format == plane->format_types[i]) +break ; +if (i == plane->format_count) { +DRM_DEBUG_KMS ("Invalid pixel format %x\n" , fb->pixel_format); + ret = -EINVAL ; + goto out; + } + fb_width = fb->width <<16 ; fb_height = fb->height <<16 ;
Signature · 6 lines
1.7.3.4 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 7/7] drm: plane: Check that the fb pixel format is supported by the plane
Quoted 26 lines · On Fri, 11 Nov 2011 18:04:07 +0200 [email protected] wrote:
From: Ville Syrjälä <[email protected]>
Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_crtc.c | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)drivers/gpu/drm/drm_crtc.c +4
-0@@ -1655,6 +1655,7 @@ int drm_mode_setplane(struct drm_device *dev, void *data,struct drm_framebuffer *fb;int ret =0 ;unsigned int fb_width, fb_height; +int i;if (!drm_core_check_feature (dev,DRIVER_MODESET ))return -EINVAL ;@@ -1703,6 +1704,16 @@ int drm_mode_setplane(struct drm_device *dev, void *data, } fb =obj_to_fb (obj); +/* Check whether this plane supports the fb pixel format. */ +for (i =0 ; i < plane->format_count; i++) +if (fb->pixel_format == plane->format_types[i])
drivers/gpu/drm/drm_crtc.c int drm_mode_setplane(struct drm_device *dev, void *data, · line 1719
Quoted 10 lines
drivers/gpu/drm/drm_crtc.c +7
-0+break ; +if (i == plane->format_count) { +DRM_DEBUG_KMS ("Invalid pixel format %x\n" , fb->pixel_format); + ret = -EINVAL ; + goto out; + } + fb_width = fb->width <<16 ; fb_height = fb->height <<16 ;
Yeah it's reasonable to hoist this up into generic code.
Thanks,
Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel