Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[deliverable/linux.git] / drivers / gpu / drm / drm_fb_cma_helper.c
index 72db38ef4f11dd2c5b37417ffba36f1000d10283..5075fae3c4e207da059773cb8bd57f70746bfccd 100644 (file)
@@ -133,7 +133,7 @@ static struct drm_framebuffer_funcs drm_fb_cma_funcs = {
 static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev,
        const struct drm_mode_fb_cmd2 *mode_cmd,
        struct drm_gem_cma_object **obj,
-       unsigned int num_planes, struct drm_framebuffer_funcs *funcs)
+       unsigned int num_planes, const struct drm_framebuffer_funcs *funcs)
 {
        struct drm_fb_cma *fb_cma;
        int ret;
@@ -159,13 +159,17 @@ static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev,
 }
 
 /**
- * drm_fb_cma_create() - (struct drm_mode_config_funcs *)->fb_create callback function
+ * drm_fb_cma_create_with_funcs() - helper function for the
+ *                                  &drm_mode_config_funcs ->fb_create
+ *                                  callback function
  *
- * If your hardware has special alignment or pitch requirements these should be
- * checked before calling this function.
+ * This can be used to set &drm_framebuffer_funcs for drivers that need the
+ * dirty() callback. Use drm_fb_cma_create() if you don't need to change
+ * &drm_framebuffer_funcs.
  */
-struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev,
-       struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd)
+struct drm_framebuffer *drm_fb_cma_create_with_funcs(struct drm_device *dev,
+       struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd,
+       const struct drm_framebuffer_funcs *funcs)
 {
        struct drm_fb_cma *fb_cma;
        struct drm_gem_cma_object *objs[4];
@@ -202,7 +206,7 @@ struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev,
                objs[i] = to_drm_gem_cma_obj(obj);
        }
 
-       fb_cma = drm_fb_cma_alloc(dev, mode_cmd, objs, i, &drm_fb_cma_funcs);
+       fb_cma = drm_fb_cma_alloc(dev, mode_cmd, objs, i, funcs);
        if (IS_ERR(fb_cma)) {
                ret = PTR_ERR(fb_cma);
                goto err_gem_object_unreference;
@@ -215,6 +219,21 @@ err_gem_object_unreference:
                drm_gem_object_unreference_unlocked(&objs[i]->base);
        return ERR_PTR(ret);
 }
+EXPORT_SYMBOL_GPL(drm_fb_cma_create_with_funcs);
+
+/**
+ * drm_fb_cma_create() - &drm_mode_config_funcs ->fb_create callback function
+ *
+ * If your hardware has special alignment or pitch requirements these should be
+ * checked before calling this function. Use drm_fb_cma_create_with_funcs() if
+ * you need to set &drm_framebuffer_funcs ->dirty.
+ */
+struct drm_framebuffer *drm_fb_cma_create(struct drm_device *dev,
+       struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd)
+{
+       return drm_fb_cma_create_with_funcs(dev, file_priv, mode_cmd,
+                                           &drm_fb_cma_funcs);
+}
 EXPORT_SYMBOL_GPL(drm_fb_cma_create);
 
 /**
@@ -350,7 +369,7 @@ static void drm_fbdev_cma_defio_fini(struct fb_info *fbi)
  */
 int drm_fbdev_cma_create_with_funcs(struct drm_fb_helper *helper,
        struct drm_fb_helper_surface_size *sizes,
-       struct drm_framebuffer_funcs *funcs)
+       const struct drm_framebuffer_funcs *funcs)
 {
        struct drm_fbdev_cma *fbdev_cma = to_fbdev_cma(helper);
        struct drm_mode_fb_cmd2 mode_cmd = { 0 };
@@ -426,7 +445,7 @@ err_cma_destroy:
 err_fb_info_destroy:
        drm_fb_helper_release_fbi(helper);
 err_gem_free_object:
-       dev->driver->gem_free_object(&obj->base);
+       drm_gem_object_unreference_unlocked(&obj->base);
        return ret;
 }
 EXPORT_SYMBOL(drm_fbdev_cma_create_with_funcs);
This page took 0.026842 seconds and 5 git commands to generate.