aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoralf Trønnes <noralf@tronnes.org>2017-12-08 14:37:42 -0500
committerNoralf Trønnes <noralf@tronnes.org>2017-12-10 09:37:07 -0500
commitd3820952ea1b49f46e340e2d366b080d3ddeea65 (patch)
tree1960034959bdbcac43838f12f4940c8d24385289
parentbdecd83546352e0cdf54f64d8d6206f1fef32d75 (diff)
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
-rw-r--r--Documentation/gpu/todo.rst5
-rw-r--r--drivers/gpu/drm/tinydrm/core/tinydrm-core.c37
-rw-r--r--drivers/gpu/drm/tinydrm/ili9225.c3
-rw-r--r--drivers/gpu/drm/tinydrm/mi0283qt.c3
-rw-r--r--drivers/gpu/drm/tinydrm/st7586.c3
-rw-r--r--include/drm/tinydrm/tinydrm.h3
6 files changed, 11 insertions, 43 deletions
diff --git a/Documentation/gpu/todo.rst b/Documentation/gpu/todo.rst
index af614746d9c5..f421a54527d2 100644
--- a/Documentation/gpu/todo.rst
+++ b/Documentation/gpu/todo.rst
@@ -395,11 +395,6 @@ those drivers as simple as possible, so lots of room for refactoring:
395 one of the ideas for having a shared dsi/dbi helper, abstracting away the 395 one of the ideas for having a shared dsi/dbi helper, abstracting away the
396 transport details more. 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- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma 398- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
404 helpers, as a _vmapped variant (since not every driver needs the vmap). 399 helpers, as a _vmapped variant (since not every driver needs the vmap).
405 And tinydrm_gem_cma_free_object could the be merged into 400 And tinydrm_gem_cma_free_object could the be merged into
diff --git a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
index bd7b82824a34..4c6616278c48 100644
--- a/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
+++ b/drivers/gpu/drm/tinydrm/core/tinydrm-core.c
@@ -10,6 +10,7 @@
10#include <drm/drm_atomic.h> 10#include <drm/drm_atomic.h>
11#include <drm/drm_atomic_helper.h> 11#include <drm/drm_atomic_helper.h>
12#include <drm/drm_crtc_helper.h> 12#include <drm/drm_crtc_helper.h>
13#include <drm/drm_fb_helper.h>
13#include <drm/drm_gem_framebuffer_helper.h> 14#include <drm/drm_gem_framebuffer_helper.h>
14#include <drm/tinydrm/tinydrm.h> 15#include <drm/tinydrm/tinydrm.h>
15#include <linux/device.h> 16#include <linux/device.h>
@@ -36,23 +37,6 @@
36 */ 37 */
37 38
38/** 39/**
39 * tinydrm_lastclose - DRM lastclose helper
40 * @drm: DRM device
41 *
42 * This function ensures that fbdev is restored when drm_lastclose() is called
43 * on the last drm_release(). Drivers can use this as their
44 * &drm_driver->lastclose callback.
45 */
46void tinydrm_lastclose(struct drm_device *drm)
47{
48 struct tinydrm_device *tdev = drm->dev_private;
49
50 DRM_DEBUG_KMS("\n");
51 drm_fbdev_cma_restore_mode(tdev->fbdev_cma);
52}
53EXPORT_SYMBOL(tinydrm_lastclose);
54
55/**
56 * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from 40 * tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
57 * another driver's scatter/gather table of pinned pages 41 * another driver's scatter/gather table of pinned pages
58 * @drm: DRM device to import into 42 * @drm: DRM device to import into
@@ -214,35 +198,24 @@ EXPORT_SYMBOL(devm_tinydrm_init);
214static int tinydrm_register(struct tinydrm_device *tdev) 198static int tinydrm_register(struct tinydrm_device *tdev)
215{ 199{
216 struct drm_device *drm = tdev->drm; 200 struct drm_device *drm = tdev->drm;
217 int bpp = drm->mode_config.preferred_depth;
218 struct drm_fbdev_cma *fbdev;
219 int ret; 201 int ret;
220 202
221 ret = drm_dev_register(tdev->drm, 0); 203 ret = drm_dev_register(tdev->drm, 0);
222 if (ret) 204 if (ret)
223 return ret; 205 return ret;
224 206
225 fbdev = drm_fbdev_cma_init_with_funcs(drm, bpp ? bpp : 32, 207 ret = drm_fb_cma_fbdev_init_with_funcs(drm, 0, 0, tdev->fb_funcs);
226 drm->mode_config.num_connector, 208 if (ret)
227 tdev->fb_funcs); 209 DRM_ERROR("Failed to initialize fbdev: %d\n", ret);
228 if (IS_ERR(fbdev))
229 DRM_ERROR("Failed to initialize fbdev: %ld\n", PTR_ERR(fbdev));
230 else
231 tdev->fbdev_cma = fbdev;
232 210
233 return 0; 211 return 0;
234} 212}
235 213
236static void tinydrm_unregister(struct tinydrm_device *tdev) 214static void tinydrm_unregister(struct tinydrm_device *tdev)
237{ 215{
238 struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma;
239
240 drm_atomic_helper_shutdown(tdev->drm); 216 drm_atomic_helper_shutdown(tdev->drm);
241 /* don't restore fbdev in lastclose, keep pipeline disabled */ 217 drm_fb_cma_fbdev_fini(tdev->drm);
242 tdev->fbdev_cma = NULL;
243 drm_dev_unregister(tdev->drm); 218 drm_dev_unregister(tdev->drm);
244 if (fbdev_cma)
245 drm_fbdev_cma_fini(fbdev_cma);
246} 219}
247 220
248static void devm_tinydrm_register_release(void *data) 221static void devm_tinydrm_register_release(void *data)
diff --git a/drivers/gpu/drm/tinydrm/ili9225.c b/drivers/gpu/drm/tinydrm/ili9225.c
index 3b766a26aa61..e8f1b3af3852 100644
--- a/drivers/gpu/drm/tinydrm/ili9225.c
+++ b/drivers/gpu/drm/tinydrm/ili9225.c
@@ -20,6 +20,7 @@
20#include <linux/spi/spi.h> 20#include <linux/spi/spi.h>
21#include <video/mipi_display.h> 21#include <video/mipi_display.h>
22 22
23#include <drm/drm_fb_helper.h>
23#include <drm/drm_gem_framebuffer_helper.h> 24#include <drm/drm_gem_framebuffer_helper.h>
24#include <drm/tinydrm/mipi-dbi.h> 25#include <drm/tinydrm/mipi-dbi.h>
25#include <drm/tinydrm/tinydrm-helpers.h> 26#include <drm/tinydrm/tinydrm-helpers.h>
@@ -381,7 +382,7 @@ static struct drm_driver ili9225_driver = {
381 DRIVER_ATOMIC, 382 DRIVER_ATOMIC,
382 .fops = &ili9225_fops, 383 .fops = &ili9225_fops,
383 TINYDRM_GEM_DRIVER_OPS, 384 TINYDRM_GEM_DRIVER_OPS,
384 .lastclose = tinydrm_lastclose, 385 .lastclose = drm_fb_helper_lastclose,
385 .name = "ili9225", 386 .name = "ili9225",
386 .desc = "Ilitek ILI9225", 387 .desc = "Ilitek ILI9225",
387 .date = "20171106", 388 .date = "20171106",
diff --git a/drivers/gpu/drm/tinydrm/mi0283qt.c b/drivers/gpu/drm/tinydrm/mi0283qt.c
index 70ae4f76f455..674d407640be 100644
--- a/drivers/gpu/drm/tinydrm/mi0283qt.c
+++ b/drivers/gpu/drm/tinydrm/mi0283qt.c
@@ -9,6 +9,7 @@
9 * (at your option) any later version. 9 * (at your option) any later version.
10 */ 10 */
11 11
12#include <drm/drm_fb_helper.h>
12#include <drm/drm_modeset_helper.h> 13#include <drm/drm_modeset_helper.h>
13#include <drm/tinydrm/ili9341.h> 14#include <drm/tinydrm/ili9341.h>
14#include <drm/tinydrm/mipi-dbi.h> 15#include <drm/tinydrm/mipi-dbi.h>
@@ -140,7 +141,7 @@ static struct drm_driver mi0283qt_driver = {
140 DRIVER_ATOMIC, 141 DRIVER_ATOMIC,
141 .fops = &mi0283qt_fops, 142 .fops = &mi0283qt_fops,
142 TINYDRM_GEM_DRIVER_OPS, 143 TINYDRM_GEM_DRIVER_OPS,
143 .lastclose = tinydrm_lastclose, 144 .lastclose = drm_fb_helper_lastclose,
144 .debugfs_init = mipi_dbi_debugfs_init, 145 .debugfs_init = mipi_dbi_debugfs_init,
145 .name = "mi0283qt", 146 .name = "mi0283qt",
146 .desc = "Multi-Inno MI0283QT", 147 .desc = "Multi-Inno MI0283QT",
diff --git a/drivers/gpu/drm/tinydrm/st7586.c b/drivers/gpu/drm/tinydrm/st7586.c
index 0a2c60da5c0e..5aebfceb740e 100644
--- a/drivers/gpu/drm/tinydrm/st7586.c
+++ b/drivers/gpu/drm/tinydrm/st7586.c
@@ -17,6 +17,7 @@
17#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
18#include <video/mipi_display.h> 18#include <video/mipi_display.h>
19 19
20#include <drm/drm_fb_helper.h>
20#include <drm/drm_gem_framebuffer_helper.h> 21#include <drm/drm_gem_framebuffer_helper.h>
21#include <drm/tinydrm/mipi-dbi.h> 22#include <drm/tinydrm/mipi-dbi.h>
22#include <drm/tinydrm/tinydrm-helpers.h> 23#include <drm/tinydrm/tinydrm-helpers.h>
@@ -320,7 +321,7 @@ static struct drm_driver st7586_driver = {
320 DRIVER_ATOMIC, 321 DRIVER_ATOMIC,
321 .fops = &st7586_fops, 322 .fops = &st7586_fops,
322 TINYDRM_GEM_DRIVER_OPS, 323 TINYDRM_GEM_DRIVER_OPS,
323 .lastclose = tinydrm_lastclose, 324 .lastclose = drm_fb_helper_lastclose,
324 .debugfs_init = mipi_dbi_debugfs_init, 325 .debugfs_init = mipi_dbi_debugfs_init,
325 .name = "st7586", 326 .name = "st7586",
326 .desc = "Sitronix ST7586", 327 .desc = "Sitronix ST7586",
diff --git a/include/drm/tinydrm/tinydrm.h b/include/drm/tinydrm/tinydrm.h
index 03cd9d72308c..07a9a11fe19d 100644
--- a/include/drm/tinydrm/tinydrm.h
+++ b/include/drm/tinydrm/tinydrm.h
@@ -19,14 +19,12 @@
19 * @drm: DRM device 19 * @drm: DRM device
20 * @pipe: Display pipe structure 20 * @pipe: Display pipe structure
21 * @dirty_lock: Serializes framebuffer flushing 21 * @dirty_lock: Serializes framebuffer flushing
22 * @fbdev_cma: CMA fbdev structure
23 * @fb_funcs: Framebuffer functions used when creating framebuffers 22 * @fb_funcs: Framebuffer functions used when creating framebuffers
24 */ 23 */
25struct tinydrm_device { 24struct tinydrm_device {
26 struct drm_device *drm; 25 struct drm_device *drm;
27 struct drm_simple_display_pipe pipe; 26 struct drm_simple_display_pipe pipe;
28 struct mutex dirty_lock; 27 struct mutex dirty_lock;
29 struct drm_fbdev_cma *fbdev_cma;
30 const struct drm_framebuffer_funcs *fb_funcs; 28 const struct drm_framebuffer_funcs *fb_funcs;
31}; 29};
32 30
@@ -80,7 +78,6 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
80 .type = DRM_MODE_TYPE_DRIVER, \ 78 .type = DRM_MODE_TYPE_DRIVER, \
81 .clock = 1 /* pass validation */ 79 .clock = 1 /* pass validation */
82 80
83void tinydrm_lastclose(struct drm_device *drm);
84void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj); 81void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
85struct drm_gem_object * 82struct drm_gem_object *
86tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm, 83tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,