drm/kms: allocate framebuffer cmap
authorClemens Ladisch <clemens@ladisch.de>
Wed, 4 Nov 2009 08:43:00 +0000 (09:43 +0100)
committerDave Airlie <airlied@redhat.com>
Thu, 19 Nov 2009 03:02:53 +0000 (13:02 +1000)
Without an allocated colormap, FBIOGETCMAP fails.  This would make
programs restore an all-black colormap ("links -g") or fail to work
altogether ("mplayer -vo fbdev2").

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/drm_fb_helper.c

index e812babe2122d694e477b9c6ea1f3456e276fe12..515b838006d2886301583ecc306e8dfc70776c7b 100644 (file)
@@ -908,8 +908,13 @@ int drm_fb_helper_single_fb_probe(struct drm_device *dev,
 
        if (new_fb) {
                info->var.pixclock = 0;
-               if (register_framebuffer(info) < 0)
+               ret = fb_alloc_cmap(&info->cmap, crtc->gamma_size, 0);
+               if (ret)
+                       return ret;
+               if (register_framebuffer(info) < 0) {
+                       fb_dealloc_cmap(&info->cmap);
                        return -EINVAL;
+               }
        } else {
                drm_fb_helper_set_par(info);
        }
@@ -939,6 +944,7 @@ void drm_fb_helper_free(struct drm_fb_helper *helper)
                unregister_sysrq_key('v', &sysrq_drm_fb_helper_restore_op);
        }
        drm_fb_helper_crtc_free(helper);
+       fb_dealloc_cmap(&helper->fb->fbdev->cmap);
 }
 EXPORT_SYMBOL(drm_fb_helper_free);