diff mbox

[2/5] drm: Remove fb hsub/vsub alignment requirement

Message ID 20170321181218.10042-3-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ville Syrjälä March 21, 2017, 6:12 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Allow framebuffers dimesions to be misaligned w.r.t. the subsampling
factors. No real reason the core should have to enforce this, and
it definitely starts to cause us issues with the i915 CCS support.
So let's just lift the restriction.

Let's start to round up when computing the color plane dimesions
so that we'll not end up with too low an estimate for the memory
requirements and whatnot.

Cc: Ben Widawsky <ben@bwidawsk.net>
Cc: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Ben Widawsky March 21, 2017, 8:26 p.m. UTC | #1
On 17-03-21 20:12:15, Ville Syrjälä wrote:
>From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
>Allow framebuffers dimesions to be misaligned w.r.t. the subsampling
>factors. No real reason the core should have to enforce this, and
>it definitely starts to cause us issues with the i915 CCS support.
>So let's just lift the restriction.
>
>Let's start to round up when computing the color plane dimesions
>so that we'll not end up with too low an estimate for the memory
>requirements and whatnot.
>
>Cc: Ben Widawsky <ben@bwidawsk.net>
>Cc: Jason Ekstrand <jason@jlekstrand.net>
>Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Both 1 and 2 are:
Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

>---
> drivers/gpu/drm/drm_framebuffer.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
>index 1138f90a7d5d..69e4c1487420 100644
>--- a/drivers/gpu/drm/drm_framebuffer.c
>+++ b/drivers/gpu/drm/drm_framebuffer.c
>@@ -132,7 +132,7 @@ static int fb_plane_width(int width,
> 	if (plane == 0)
> 		return width;
>
>-	return width / format->hsub;
>+	return DIV_ROUND_UP(width, format->hsub);
> }
>
> static int fb_plane_height(int height,
>@@ -141,7 +141,7 @@ static int fb_plane_height(int height,
> 	if (plane == 0)
> 		return height;
>
>-	return height / format->vsub;
>+	return DIV_ROUND_UP(height, format->vsub);
> }
>
> static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
>@@ -158,12 +158,12 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> 		return -EINVAL;
> 	}
>
>-	if (r->width == 0 || r->width % info->hsub) {
>+	if (r->width == 0) {
> 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
> 		return -EINVAL;
> 	}
>
>-	if (r->height == 0 || r->height % info->vsub) {
>+	if (r->height == 0) {
> 		DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
> 		return -EINVAL;
> 	}
>-- 
>2.10.2
>
Ville Syrjälä March 22, 2017, 6:33 p.m. UTC | #2
On Tue, Mar 21, 2017 at 01:26:23PM -0700, Ben Widawsky wrote:
> On 17-03-21 20:12:15, Ville Syrjälä wrote:
> >From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> >Allow framebuffers dimesions to be misaligned w.r.t. the subsampling
> >factors. No real reason the core should have to enforce this, and
> >it definitely starts to cause us issues with the i915 CCS support.
> >So let's just lift the restriction.
> >
> >Let's start to round up when computing the color plane dimesions
> >so that we'll not end up with too low an estimate for the memory
> >requirements and whatnot.
> >
> >Cc: Ben Widawsky <ben@bwidawsk.net>
> >Cc: Jason Ekstrand <jason@jlekstrand.net>
> >Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Both 1 and 2 are:
> Reviewed-by: Ben Widawsky <ben@bwidawsk.net>

Thanks. I've pushed patches 1-3 to drm-misc-next. That just leaves
us with the i915 stuff to deal with.

> 
> >---
> > drivers/gpu/drm/drm_framebuffer.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> >diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> >index 1138f90a7d5d..69e4c1487420 100644
> >--- a/drivers/gpu/drm/drm_framebuffer.c
> >+++ b/drivers/gpu/drm/drm_framebuffer.c
> >@@ -132,7 +132,7 @@ static int fb_plane_width(int width,
> > 	if (plane == 0)
> > 		return width;
> >
> >-	return width / format->hsub;
> >+	return DIV_ROUND_UP(width, format->hsub);
> > }
> >
> > static int fb_plane_height(int height,
> >@@ -141,7 +141,7 @@ static int fb_plane_height(int height,
> > 	if (plane == 0)
> > 		return height;
> >
> >-	return height / format->vsub;
> >+	return DIV_ROUND_UP(height, format->vsub);
> > }
> >
> > static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> >@@ -158,12 +158,12 @@ static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
> > 		return -EINVAL;
> > 	}
> >
> >-	if (r->width == 0 || r->width % info->hsub) {
> >+	if (r->width == 0) {
> > 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
> > 		return -EINVAL;
> > 	}
> >
> >-	if (r->height == 0 || r->height % info->vsub) {
> >+	if (r->height == 0) {
> > 		DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
> > 		return -EINVAL;
> > 	}
> >-- 
> >2.10.2
> >
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
index 1138f90a7d5d..69e4c1487420 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -132,7 +132,7 @@  static int fb_plane_width(int width,
 	if (plane == 0)
 		return width;
 
-	return width / format->hsub;
+	return DIV_ROUND_UP(width, format->hsub);
 }
 
 static int fb_plane_height(int height,
@@ -141,7 +141,7 @@  static int fb_plane_height(int height,
 	if (plane == 0)
 		return height;
 
-	return height / format->vsub;
+	return DIV_ROUND_UP(height, format->vsub);
 }
 
 static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
@@ -158,12 +158,12 @@  static int framebuffer_check(const struct drm_mode_fb_cmd2 *r)
 		return -EINVAL;
 	}
 
-	if (r->width == 0 || r->width % info->hsub) {
+	if (r->width == 0) {
 		DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
 		return -EINVAL;
 	}
 
-	if (r->height == 0 || r->height % info->vsub) {
+	if (r->height == 0) {
 		DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
 		return -EINVAL;
 	}