<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 7, 2014 at 12:49 PM, Zach Reizner <span dir="ltr"><<a href="mailto:zachr@google.com" target="_blank">zachr@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This patch allows framebuffers for cirrus to be created with<br>
32bpp pixel formats provided that they do not violate certain<br>
restrictions of the cirrus hardware.<br>
<br>
Signed-off-by: Zach Reizner <<a href="mailto:zachr@google.com" target="_blank">zachr@google.com</a>><br></blockquote><div><br></div><div>Reviewed-by: Stéphane Marchesin <<a href="mailto:marcheu@chromium.org">marcheu@chromium.org</a>></div><div><br></div><div>Dave, Adam: are you ok with this patch?</div><div><br></div><div>Stéphane</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
---<br>
 drivers/gpu/drm/cirrus/cirrus_drv.h   |  2 ++<br>
 drivers/gpu/drm/cirrus/cirrus_fbdev.c |  4 +++-<br>
 drivers/gpu/drm/cirrus/cirrus_main.c  | 22 ++++++++++++++++++++--<br>
 3 files changed, 25 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.h b/drivers/gpu/drm/cirrus/cirrus_drv.h<br>
index 401c890..fac475c 100644<br>
--- a/drivers/gpu/drm/cirrus/cirrus_drv.h<br>
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.h<br>
@@ -208,6 +208,8 @@ int cirrus_framebuffer_init(struct drm_device *dev,<br>
                            struct drm_mode_fb_cmd2 *mode_cmd,<br>
                            struct drm_gem_object *obj);<br>
<br>
+bool cirrus_check_framebuffer(int width, int height, int bpp, int pitch);<br>
+<br>
                                /* cirrus_display.c */<br>
 int cirrus_modeset_init(struct cirrus_device *cdev);<br>
 void cirrus_modeset_fini(struct cirrus_device *cdev);<br>
diff --git a/drivers/gpu/drm/cirrus/cirrus_fbdev.c b/drivers/gpu/drm/cirrus/cirrus_fbdev.c<br>
index 2a135f2..4a0756c 100644<br>
--- a/drivers/gpu/drm/cirrus/cirrus_fbdev.c<br>
+++ b/drivers/gpu/drm/cirrus/cirrus_fbdev.c<br>
@@ -146,8 +146,10 @@ static int cirrusfb_create_object(struct cirrus_fbdev *afbdev,<br>
        int ret = 0;<br>
        drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);<br>
<br>
-       if (bpp > 24)<br>
+       if (!cirrus_check_framebuffer(mode_cmd->width, mode_cmd->height, bpp,<br>
+                                     mode_cmd->pitches[0]))<br>
                return -EINVAL;<br>
+<br>
        size = mode_cmd->pitches[0] * mode_cmd->height;<br>
        ret = cirrus_gem_create(dev, size, true, &gobj);<br>
        if (ret)<br>
diff --git a/drivers/gpu/drm/cirrus/cirrus_main.c b/drivers/gpu/drm/cirrus/cirrus_main.c<br>
index 99c1983..029f9e9 100644<br>
--- a/drivers/gpu/drm/cirrus/cirrus_main.c<br>
+++ b/drivers/gpu/drm/cirrus/cirrus_main.c<br>
@@ -55,8 +55,9 @@ cirrus_user_framebuffer_create(struct drm_device *dev,<br>
        u32 bpp, depth;<br>
<br>
        drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp);<br>
-       /* cirrus can't handle > 24bpp framebuffers at all */<br>
-       if (bpp > 24)<br>
+<br>
+       if (!cirrus_check_framebuffer(mode_cmd->width, mode_cmd->height,<br>
+                                     bpp, mode_cmd->pitches[0]))<br>
                return ERR_PTR(-EINVAL);<br>
<br>
        obj = drm_gem_object_lookup(dev, filp, mode_cmd->handles[0]);<br>
@@ -307,3 +308,20 @@ out_unlock:<br>
        return ret;<br>
<br>
 }<br>
+<br>
+bool cirrus_check_framebuffer(int width, int height, int bpp, int pitch)<br>
+{<br>
+       const int max_pitch = 0x1FF << 3; /* (4096 - 1) & ~111b bytes */<br>
+       const int max_size = 0x400000; /* 4MB */<br>
+<br>
+       if (bpp > 32)<br>
+               return false;<br>
+<br>
+       if (pitch > max_pitch)<br>
+               return false;<br>
+<br>
+       if (pitch * height > max_size)<br>
+               return false;<br>
+<br>
+       return true;<br>
+}<br>
<span><font color="#888888">--<br>
2.1.0.rc2.206.gedb03e5<br>
<br>
_______________________________________________<br>
dri-devel mailing list<br>
<a href="mailto:dri-devel@lists.freedesktop.org" target="_blank">dri-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/dri-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/dri-devel</a><br>
</font></span></blockquote></div><br></div></div>