]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
drm: xlnx: fb: Prefer the current format depth over depth from fb helper
authorHyun Kwon <hyun.kwon@xilinx.com>
Wed, 11 Apr 2018 16:36:33 +0000 (09:36 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 2 May 2018 06:29:56 +0000 (08:29 +0200)
The drm fb helper has specific preference of bpp and depth. For example,
for 32bit bpp, the depth is hard-coded to be 24. If it's not aligned
with the supported format of a drm device, it fails to initialize fbdev.
So override the depth value from fb helper with the current format
of the drm device. This will allow to initialize the fbdev with
preferred format that matches with actual format.

Signed-off-by: Hyun Kwon <hyun.kwon@xilinx.com>
Reviewed-by: Saurabh Sengar <saurabhs@xilinx.com>
Tested-by: Anil Kumar Mamidala <amamidal@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/gpu/drm/xlnx/xlnx_fb.c

index e72087dbf47fdb6bb84fc96f18fc9250facedb59..e83983d0fe19ae43e4d9726b48b2e9fee4d945c3 100644 (file)
@@ -27,6 +27,7 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 
+#include "xlnx_crtc.h"
 #include "xlnx_drv.h"
 #include "xlnx_fb.h"
 
@@ -110,6 +111,8 @@ static int xlnx_fbdev_create(struct drm_fb_helper *fb_helper,
        unsigned int bytes_per_pixel;
        unsigned long offset;
        struct fb_info *fbi;
+       u32 format;
+       const struct drm_format_info *info;
        size_t bytes;
        int ret;
 
@@ -132,6 +135,12 @@ static int xlnx_fbdev_create(struct drm_fb_helper *fb_helper,
                goto err_drm_gem_cma_free_object;
        }
 
+       /* Override the depth given by fb helper with current format value */
+       format = xlnx_get_format(drm);
+       info = drm_format_info(format);
+       if (size->surface_bpp == info->cpp[0] * 8)
+               size->surface_depth = info->depth;
+
        fbdev->fb = drm_gem_fbdev_fb_create(drm, size, fbdev->align, &obj->base,
                                            &xlnx_fb_funcs);
        if (IS_ERR(fbdev->fb)) {