Skip to content

Commit d382095

Browse files
committed
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
1 parent bdecd83 commit d382095

6 files changed

Lines changed: 11 additions & 43 deletions

File tree

‎Documentation/gpu/todo.rst‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,6 @@ those drivers as simple as possible, so lots of room for refactoring:
395395
one of the ideas for having a shared dsi/dbi helper, abstracting away the
396396
transport details more.
397397

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-
403398
- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
404399
helpers, as a _vmapped variant (since not every driver needs the vmap).
405400
And tinydrm_gem_cma_free_object could the be merged into

‎drivers/gpu/drm/tinydrm/core/tinydrm-core.c‎

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <drm/drm_atomic.h>
1111
#include <drm/drm_atomic_helper.h>
1212
#include <drm/drm_crtc_helper.h>
13+
#include <drm/drm_fb_helper.h>
1314
#include <drm/drm_gem_framebuffer_helper.h>
1415
#include <drm/tinydrm/tinydrm.h>
1516
#include <linux/device.h>
@@ -35,23 +36,6 @@
3536
* and registers the DRM device using devm_tinydrm_register().
3637
*/
3738

38-
/**
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-
*/
46-
void 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-
}
53-
EXPORT_SYMBOL(tinydrm_lastclose);
54-
5539
/**
5640
* tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
5741
* another driver's scatter/gather table of pinned pages
@@ -214,35 +198,24 @@ EXPORT_SYMBOL(devm_tinydrm_init);
214198
static int tinydrm_register(struct tinydrm_device *tdev)
215199
{
216200
struct drm_device *drm = tdev->drm;
217-
int bpp = drm->mode_config.preferred_depth;
218-
struct drm_fbdev_cma *fbdev;
219201
int ret;
220202

221203
ret = drm_dev_register(tdev->drm, 0);
222204
if (ret)
223205
return ret;
224206

225-
fbdev = drm_fbdev_cma_init_with_funcs(drm, bpp ? bpp : 32,
226-
drm->mode_config.num_connector,
227-
tdev->fb_funcs);
228-
if (IS_ERR(fbdev))
229-
DRM_ERROR("Failed to initialize fbdev: %ld\n", PTR_ERR(fbdev));
230-
else
231-
tdev->fbdev_cma = fbdev;
207+
ret = drm_fb_cma_fbdev_init_with_funcs(drm, 0, 0, tdev->fb_funcs);
208+
if (ret)
209+
DRM_ERROR("Failed to initialize fbdev: %d\n", ret);
232210

233211
return 0;
234212
}
235213

236214
static void tinydrm_unregister(struct tinydrm_device *tdev)
237215
{
238-
struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma;
239-
240216
drm_atomic_helper_shutdown(tdev->drm);
241-
/* don't restore fbdev in lastclose, keep pipeline disabled */
242-
tdev->fbdev_cma = NULL;
217+
drm_fb_cma_fbdev_fini(tdev->drm);
243218
drm_dev_unregister(tdev->drm);
244-
if (fbdev_cma)
245-
drm_fbdev_cma_fini(fbdev_cma);
246219
}
247220

248221
static void devm_tinydrm_register_release(void *data)

‎drivers/gpu/drm/tinydrm/ili9225.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/spi/spi.h>
2121
#include <video/mipi_display.h>
2222

23+
#include <drm/drm_fb_helper.h>
2324
#include <drm/drm_gem_framebuffer_helper.h>
2425
#include <drm/tinydrm/mipi-dbi.h>
2526
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -381,7 +382,7 @@ static struct drm_driver ili9225_driver = {
381382
DRIVER_ATOMIC,
382383
.fops = &ili9225_fops,
383384
TINYDRM_GEM_DRIVER_OPS,
384-
.lastclose = tinydrm_lastclose,
385+
.lastclose = drm_fb_helper_lastclose,
385386
.name = "ili9225",
386387
.desc = "Ilitek ILI9225",
387388
.date = "20171106",

‎drivers/gpu/drm/tinydrm/mi0283qt.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* (at your option) any later version.
1010
*/
1111

12+
#include <drm/drm_fb_helper.h>
1213
#include <drm/drm_modeset_helper.h>
1314
#include <drm/tinydrm/ili9341.h>
1415
#include <drm/tinydrm/mipi-dbi.h>
@@ -140,7 +141,7 @@ static struct drm_driver mi0283qt_driver = {
140141
DRIVER_ATOMIC,
141142
.fops = &mi0283qt_fops,
142143
TINYDRM_GEM_DRIVER_OPS,
143-
.lastclose = tinydrm_lastclose,
144+
.lastclose = drm_fb_helper_lastclose,
144145
.debugfs_init = mipi_dbi_debugfs_init,
145146
.name = "mi0283qt",
146147
.desc = "Multi-Inno MI0283QT",

‎drivers/gpu/drm/tinydrm/st7586.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/spi/spi.h>
1818
#include <video/mipi_display.h>
1919

20+
#include <drm/drm_fb_helper.h>
2021
#include <drm/drm_gem_framebuffer_helper.h>
2122
#include <drm/tinydrm/mipi-dbi.h>
2223
#include <drm/tinydrm/tinydrm-helpers.h>
@@ -320,7 +321,7 @@ static struct drm_driver st7586_driver = {
320321
DRIVER_ATOMIC,
321322
.fops = &st7586_fops,
322323
TINYDRM_GEM_DRIVER_OPS,
323-
.lastclose = tinydrm_lastclose,
324+
.lastclose = drm_fb_helper_lastclose,
324325
.debugfs_init = mipi_dbi_debugfs_init,
325326
.name = "st7586",
326327
.desc = "Sitronix ST7586",

‎include/drm/tinydrm/tinydrm.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
* @drm: DRM device
2020
* @pipe: Display pipe structure
2121
* @dirty_lock: Serializes framebuffer flushing
22-
* @fbdev_cma: CMA fbdev structure
2322
* @fb_funcs: Framebuffer functions used when creating framebuffers
2423
*/
2524
struct tinydrm_device {
2625
struct drm_device *drm;
2726
struct drm_simple_display_pipe pipe;
2827
struct mutex dirty_lock;
29-
struct drm_fbdev_cma *fbdev_cma;
3028
const struct drm_framebuffer_funcs *fb_funcs;
3129
};
3230

@@ -80,7 +78,6 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
8078
.type = DRM_MODE_TYPE_DRIVER, \
8179
.clock = 1 /* pass validation */
8280

83-
void tinydrm_lastclose(struct drm_device *drm);
8481
void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
8582
struct drm_gem_object *
8683
tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,

0 commit comments

Comments
 (0)