Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/tinydrm: Use drm_fb_cma_fbdev_init_with_funcs/fini()

Use drm_fb_cma_fbdev_init_with_funcs() and drm_fb_cma_fbdev_fini() which
relies on the fact that drm_device holds a pointer to the drm_fb_helper
structure. This means that the driver doesn't have to keep track of that.
Also use the drm_fb_helper functions directly.
Remove todo entry.

Cc: David Lechner <david@lechnology.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: David Lechner <david@lechnology.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Tested-by: David Lechner <david@lechnolgy.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20171208193743.34450-11-noralf@tronnes.org

+11 -43
-5
Documentation/gpu/todo.rst
··· 395 395 one of the ideas for having a shared dsi/dbi helper, abstracting away the 396 396 transport details more. 397 397 398 - - tinydrm_lastclose could be drm_fb_helper_lastclose. Only thing we need 399 - for that is to store the drm_fb_helper pointer somewhere in 400 - drm_device->mode_config. And then we could roll that out to all the 401 - drivers. 402 - 403 398 - tinydrm_gem_cma_prime_import_sg_table should probably go into the cma 404 399 helpers, as a _vmapped variant (since not every driver needs the vmap). 405 400 And tinydrm_gem_cma_free_object could the be merged into
+5 -32
drivers/gpu/drm/tinydrm/core/tinydrm-core.c
··· 10 10 #include <drm/drm_atomic.h> 11 11 #include <drm/drm_atomic_helper.h> 12 12 #include <drm/drm_crtc_helper.h> 13 + #include <drm/drm_fb_helper.h> 13 14 #include <drm/drm_gem_framebuffer_helper.h> 14 15 #include <drm/tinydrm/tinydrm.h> 15 16 #include <linux/device.h> ··· 35 34 * devm_tinydrm_init(), sets up the pipeline using tinydrm_display_pipe_init() 36 35 * and registers the DRM device using devm_tinydrm_register(). 37 36 */ 38 - 39 - /** 40 - * tinydrm_lastclose - DRM lastclose helper 41 - * @drm: DRM device 42 - * 43 - * This function ensures that fbdev is restored when drm_lastclose() is called 44 - * on the last drm_release(). Drivers can use this as their 45 - * &drm_driver->lastclose callback. 46 - */ 47 - void tinydrm_lastclose(struct drm_device *drm) 48 - { 49 - struct tinydrm_device *tdev = drm->dev_private; 50 - 51 - DRM_DEBUG_KMS("\n"); 52 - drm_fbdev_cma_restore_mode(tdev->fbdev_cma); 53 - } 54 - EXPORT_SYMBOL(tinydrm_lastclose); 55 37 56 38 /** 57 39 * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from ··· 198 214 static int tinydrm_register(struct tinydrm_device *tdev) 199 215 { 200 216 struct drm_device *drm = tdev->drm; 201 - int bpp = drm->mode_config.preferred_depth; 202 - struct drm_fbdev_cma *fbdev; 203 217 int ret; 204 218 205 219 ret = drm_dev_register(tdev->drm, 0); 206 220 if (ret) 207 221 return ret; 208 222 209 - fbdev = drm_fbdev_cma_init_with_funcs(drm, bpp ? bpp : 32, 210 - drm->mode_config.num_connector, 211 - tdev->fb_funcs); 212 - if (IS_ERR(fbdev)) 213 - DRM_ERROR("Failed to initialize fbdev: %ld\n", PTR_ERR(fbdev)); 214 - else 215 - tdev->fbdev_cma = fbdev; 223 + ret = drm_fb_cma_fbdev_init_with_funcs(drm, 0, 0, tdev->fb_funcs); 224 + if (ret) 225 + DRM_ERROR("Failed to initialize fbdev: %d\n", ret); 216 226 217 227 return 0; 218 228 } 219 229 220 230 static void tinydrm_unregister(struct tinydrm_device *tdev) 221 231 { 222 - struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma; 223 - 224 232 drm_atomic_helper_shutdown(tdev->drm); 225 - /* don't restore fbdev in lastclose, keep pipeline disabled */ 226 - tdev->fbdev_cma = NULL; 233 + drm_fb_cma_fbdev_fini(tdev->drm); 227 234 drm_dev_unregister(tdev->drm); 228 - if (fbdev_cma) 229 - drm_fbdev_cma_fini(fbdev_cma); 230 235 } 231 236 232 237 static void devm_tinydrm_register_release(void *data)
+2 -1
drivers/gpu/drm/tinydrm/ili9225.c
··· 20 20 #include <linux/spi/spi.h> 21 21 #include <video/mipi_display.h> 22 22 23 + #include <drm/drm_fb_helper.h> 23 24 #include <drm/drm_gem_framebuffer_helper.h> 24 25 #include <drm/tinydrm/mipi-dbi.h> 25 26 #include <drm/tinydrm/tinydrm-helpers.h> ··· 382 381 DRIVER_ATOMIC, 383 382 .fops = &ili9225_fops, 384 383 TINYDRM_GEM_DRIVER_OPS, 385 - .lastclose = tinydrm_lastclose, 384 + .lastclose = drm_fb_helper_lastclose, 386 385 .name = "ili9225", 387 386 .desc = "Ilitek ILI9225", 388 387 .date = "20171106",
+2 -1
drivers/gpu/drm/tinydrm/mi0283qt.c
··· 9 9 * (at your option) any later version. 10 10 */ 11 11 12 + #include <drm/drm_fb_helper.h> 12 13 #include <drm/drm_modeset_helper.h> 13 14 #include <drm/tinydrm/ili9341.h> 14 15 #include <drm/tinydrm/mipi-dbi.h> ··· 141 140 DRIVER_ATOMIC, 142 141 .fops = &mi0283qt_fops, 143 142 TINYDRM_GEM_DRIVER_OPS, 144 - .lastclose = tinydrm_lastclose, 143 + .lastclose = drm_fb_helper_lastclose, 145 144 .debugfs_init = mipi_dbi_debugfs_init, 146 145 .name = "mi0283qt", 147 146 .desc = "Multi-Inno MI0283QT",
+2 -1
drivers/gpu/drm/tinydrm/st7586.c
··· 17 17 #include <linux/spi/spi.h> 18 18 #include <video/mipi_display.h> 19 19 20 + #include <drm/drm_fb_helper.h> 20 21 #include <drm/drm_gem_framebuffer_helper.h> 21 22 #include <drm/tinydrm/mipi-dbi.h> 22 23 #include <drm/tinydrm/tinydrm-helpers.h> ··· 321 320 DRIVER_ATOMIC, 322 321 .fops = &st7586_fops, 323 322 TINYDRM_GEM_DRIVER_OPS, 324 - .lastclose = tinydrm_lastclose, 323 + .lastclose = drm_fb_helper_lastclose, 325 324 .debugfs_init = mipi_dbi_debugfs_init, 326 325 .name = "st7586", 327 326 .desc = "Sitronix ST7586",
-3
include/drm/tinydrm/tinydrm.h
··· 19 19 * @drm: DRM device 20 20 * @pipe: Display pipe structure 21 21 * @dirty_lock: Serializes framebuffer flushing 22 - * @fbdev_cma: CMA fbdev structure 23 22 * @fb_funcs: Framebuffer functions used when creating framebuffers 24 23 */ 25 24 struct tinydrm_device { 26 25 struct drm_device *drm; 27 26 struct drm_simple_display_pipe pipe; 28 27 struct mutex dirty_lock; 29 - struct drm_fbdev_cma *fbdev_cma; 30 28 const struct drm_framebuffer_funcs *fb_funcs; 31 29 }; 32 30 ··· 78 80 .type = DRM_MODE_TYPE_DRIVER, \ 79 81 .clock = 1 /* pass validation */ 80 82 81 - void tinydrm_lastclose(struct drm_device *drm); 82 83 void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj); 83 84 struct drm_gem_object * 84 85 tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,