From: Ville Syrjälä <ville.syrj...@linux.intel.com>

hsub and vsub are used to indicate format subsampling, and currently
framebuffers cannot be allocated with a width not aligned to this value.
However, for auxiliary compressed planes this is undesirable: the
generic userspace does not know to quantise width/height, but the
non-generic allocator can pad the stride/size in an acceptable way.

Add explicit halign/valign members which allow a particular format to
have more loose (or strict) alignment requirements than its subsampling.

Signed-off-by: Ville Syrjälä <ville.syrj...@linux.intel.com>
Signed-off-by: Daniel Stone <dani...@collabora.com>
---
 drivers/gpu/drm/drm_framebuffer.c | 7 +++++--
 include/drm/drm_fourcc.h          | 2 ++
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_framebuffer.c 
b/drivers/gpu/drm/drm_framebuffer.c
index fc8ef42203ec..7ab8ea7f7a9f 100644
--- a/drivers/gpu/drm/drm_framebuffer.c
+++ b/drivers/gpu/drm/drm_framebuffer.c
@@ -149,6 +149,7 @@ static int framebuffer_check(struct drm_device *dev,
                             const struct drm_mode_fb_cmd2 *r)
 {
        const struct drm_format_info *info;
+       int halign, valign;
        int i;
 
        /* check if the format is supported at all */
@@ -164,12 +165,14 @@ static int framebuffer_check(struct drm_device *dev,
        /* now let the driver pick its own format info */
        info = drm_get_format_info(dev, r);
 
-       if (r->width == 0) {
+       halign = info->halign ? : info->hsub;
+       if (r->width == 0 || r->width % halign){
                DRM_DEBUG_KMS("bad framebuffer width %u\n", r->width);
                return -EINVAL;
        }
 
-       if (r->height == 0) {
+       valign = info->valign ? : info->vsub;
+       if (r->height == 0 || r->height % valign) {
                DRM_DEBUG_KMS("bad framebuffer height %u\n", r->height);
                return -EINVAL;
        }
diff --git a/include/drm/drm_fourcc.h b/include/drm/drm_fourcc.h
index 6942e84b6edd..a6aff4d091e8 100644
--- a/include/drm/drm_fourcc.h
+++ b/include/drm/drm_fourcc.h
@@ -46,6 +46,8 @@ struct drm_format_info {
        u8 cpp[3];
        u8 hsub;
        u8 vsub;
+       u8 halign; /* specified only if != hsub */
+       u8 valign; /* specified only if != vsub */
 };
 
 /**
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to