diff options
Diffstat (limited to 'drivers/gpu/drm/drm_fb_cma_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_fb_cma_helper.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index 5075fae3c4e2..1fd6eac1400c 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <drm/drm_crtc_helper.h> | 23 | #include <drm/drm_crtc_helper.h> |
24 | #include <drm/drm_gem_cma_helper.h> | 24 | #include <drm/drm_gem_cma_helper.h> |
25 | #include <drm/drm_fb_cma_helper.h> | 25 | #include <drm/drm_fb_cma_helper.h> |
26 | #include <linux/dma-mapping.h> | ||
26 | #include <linux/module.h> | 27 | #include <linux/module.h> |
27 | 28 | ||
28 | #define DEFAULT_FBDEFIO_DELAY_MS 50 | 29 | #define DEFAULT_FBDEFIO_DELAY_MS 50 |
@@ -52,7 +53,7 @@ struct drm_fbdev_cma { | |||
52 | * will be set up automatically. dirty() is called by | 53 | * will be set up automatically. dirty() is called by |
53 | * drm_fb_helper_deferred_io() in process context (struct delayed_work). | 54 | * drm_fb_helper_deferred_io() in process context (struct delayed_work). |
54 | * | 55 | * |
55 | * Example fbdev deferred io code: | 56 | * Example fbdev deferred io code:: |
56 | * | 57 | * |
57 | * static int driver_fbdev_fb_dirty(struct drm_framebuffer *fb, | 58 | * static int driver_fbdev_fb_dirty(struct drm_framebuffer *fb, |
58 | * struct drm_file *file_priv, | 59 | * struct drm_file *file_priv, |
@@ -162,6 +163,10 @@ static struct drm_fb_cma *drm_fb_cma_alloc(struct drm_device *dev, | |||
162 | * drm_fb_cma_create_with_funcs() - helper function for the | 163 | * drm_fb_cma_create_with_funcs() - helper function for the |
163 | * &drm_mode_config_funcs ->fb_create | 164 | * &drm_mode_config_funcs ->fb_create |
164 | * callback function | 165 | * callback function |
166 | * @dev: DRM device | ||
167 | * @file_priv: drm file for the ioctl call | ||
168 | * @mode_cmd: metadata from the userspace fb creation request | ||
169 | * @funcs: vtable to be used for the new framebuffer object | ||
165 | * | 170 | * |
166 | * This can be used to set &drm_framebuffer_funcs for drivers that need the | 171 | * This can be used to set &drm_framebuffer_funcs for drivers that need the |
167 | * dirty() callback. Use drm_fb_cma_create() if you don't need to change | 172 | * dirty() callback. Use drm_fb_cma_create() if you don't need to change |
@@ -223,6 +228,9 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_create_with_funcs); | |||
223 | 228 | ||
224 | /** | 229 | /** |
225 | * drm_fb_cma_create() - &drm_mode_config_funcs ->fb_create callback function | 230 | * drm_fb_cma_create() - &drm_mode_config_funcs ->fb_create callback function |
231 | * @dev: DRM device | ||
232 | * @file_priv: drm file for the ioctl call | ||
233 | * @mode_cmd: metadata from the userspace fb creation request | ||
226 | * | 234 | * |
227 | * If your hardware has special alignment or pitch requirements these should be | 235 | * If your hardware has special alignment or pitch requirements these should be |
228 | * checked before calling this function. Use drm_fb_cma_create_with_funcs() if | 236 | * checked before calling this function. Use drm_fb_cma_create_with_funcs() if |
@@ -246,7 +254,7 @@ EXPORT_SYMBOL_GPL(drm_fb_cma_create); | |||
246 | * This function will usually be called from the CRTC callback functions. | 254 | * This function will usually be called from the CRTC callback functions. |
247 | */ | 255 | */ |
248 | struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, | 256 | struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, |
249 | unsigned int plane) | 257 | unsigned int plane) |
250 | { | 258 | { |
251 | struct drm_fb_cma *fb_cma = to_fb_cma(fb); | 259 | struct drm_fb_cma *fb_cma = to_fb_cma(fb); |
252 | 260 | ||
@@ -258,10 +266,6 @@ struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb, | |||
258 | EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); | 266 | EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj); |
259 | 267 | ||
260 | #ifdef CONFIG_DEBUG_FS | 268 | #ifdef CONFIG_DEBUG_FS |
261 | /* | ||
262 | * drm_fb_cma_describe() - Helper to dump information about a single | ||
263 | * CMA framebuffer object | ||
264 | */ | ||
265 | static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) | 269 | static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) |
266 | { | 270 | { |
267 | struct drm_fb_cma *fb_cma = to_fb_cma(fb); | 271 | struct drm_fb_cma *fb_cma = to_fb_cma(fb); |
@@ -279,7 +283,9 @@ static void drm_fb_cma_describe(struct drm_framebuffer *fb, struct seq_file *m) | |||
279 | 283 | ||
280 | /** | 284 | /** |
281 | * drm_fb_cma_debugfs_show() - Helper to list CMA framebuffer objects | 285 | * drm_fb_cma_debugfs_show() - Helper to list CMA framebuffer objects |
282 | * in debugfs. | 286 | * in debugfs. |
287 | * @m: output file | ||
288 | * @arg: private data for the callback | ||
283 | */ | 289 | */ |
284 | int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg) | 290 | int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg) |
285 | { | 291 | { |
@@ -297,6 +303,12 @@ int drm_fb_cma_debugfs_show(struct seq_file *m, void *arg) | |||
297 | EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show); | 303 | EXPORT_SYMBOL_GPL(drm_fb_cma_debugfs_show); |
298 | #endif | 304 | #endif |
299 | 305 | ||
306 | static int drm_fb_cma_mmap(struct fb_info *info, struct vm_area_struct *vma) | ||
307 | { | ||
308 | return dma_mmap_writecombine(info->device, vma, info->screen_base, | ||
309 | info->fix.smem_start, info->fix.smem_len); | ||
310 | } | ||
311 | |||
300 | static struct fb_ops drm_fbdev_cma_ops = { | 312 | static struct fb_ops drm_fbdev_cma_ops = { |
301 | .owner = THIS_MODULE, | 313 | .owner = THIS_MODULE, |
302 | .fb_fillrect = drm_fb_helper_sys_fillrect, | 314 | .fb_fillrect = drm_fb_helper_sys_fillrect, |
@@ -307,6 +319,7 @@ static struct fb_ops drm_fbdev_cma_ops = { | |||
307 | .fb_blank = drm_fb_helper_blank, | 319 | .fb_blank = drm_fb_helper_blank, |
308 | .fb_pan_display = drm_fb_helper_pan_display, | 320 | .fb_pan_display = drm_fb_helper_pan_display, |
309 | .fb_setcmap = drm_fb_helper_setcmap, | 321 | .fb_setcmap = drm_fb_helper_setcmap, |
322 | .fb_mmap = drm_fb_cma_mmap, | ||
310 | }; | 323 | }; |
311 | 324 | ||
312 | static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info, | 325 | static int drm_fbdev_cma_deferred_io_mmap(struct fb_info *info, |
@@ -333,6 +346,7 @@ static int drm_fbdev_cma_defio_init(struct fb_info *fbi, | |||
333 | fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); | 346 | fbops = kzalloc(sizeof(*fbops), GFP_KERNEL); |
334 | if (!fbdefio || !fbops) { | 347 | if (!fbdefio || !fbops) { |
335 | kfree(fbdefio); | 348 | kfree(fbdefio); |
349 | kfree(fbops); | ||
336 | return -ENOMEM; | 350 | return -ENOMEM; |
337 | } | 351 | } |
338 | 352 | ||
@@ -582,3 +596,18 @@ void drm_fbdev_cma_hotplug_event(struct drm_fbdev_cma *fbdev_cma) | |||
582 | drm_fb_helper_hotplug_event(&fbdev_cma->fb_helper); | 596 | drm_fb_helper_hotplug_event(&fbdev_cma->fb_helper); |
583 | } | 597 | } |
584 | EXPORT_SYMBOL_GPL(drm_fbdev_cma_hotplug_event); | 598 | EXPORT_SYMBOL_GPL(drm_fbdev_cma_hotplug_event); |
599 | |||
600 | /** | ||
601 | * drm_fbdev_cma_set_suspend - wrapper around drm_fb_helper_set_suspend | ||
602 | * @fbdev_cma: The drm_fbdev_cma struct, may be NULL | ||
603 | * @state: desired state, zero to resume, non-zero to suspend | ||
604 | * | ||
605 | * Calls drm_fb_helper_set_suspend, which is a wrapper around | ||
606 | * fb_set_suspend implemented by fbdev core. | ||
607 | */ | ||
608 | void drm_fbdev_cma_set_suspend(struct drm_fbdev_cma *fbdev_cma, int state) | ||
609 | { | ||
610 | if (fbdev_cma) | ||
611 | drm_fb_helper_set_suspend(&fbdev_cma->fb_helper, state); | ||
612 | } | ||
613 | EXPORT_SYMBOL(drm_fbdev_cma_set_suspend); | ||