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
This commit is contained in:
parent
bdecd83546
commit
d3820952ea
@ -395,11 +395,6 @@ those drivers as simple as possible, so lots of room for refactoring:
|
|||||||
one of the ideas for having a shared dsi/dbi helper, abstracting away the
|
one of the ideas for having a shared dsi/dbi helper, abstracting away the
|
||||||
transport details more.
|
transport details more.
|
||||||
|
|
||||||
- tinydrm_lastclose could be drm_fb_helper_lastclose. Only thing we need
|
|
||||||
for that is to store the drm_fb_helper pointer somewhere in
|
|
||||||
drm_device->mode_config. And then we could roll that out to all the
|
|
||||||
drivers.
|
|
||||||
|
|
||||||
- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
|
- tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
|
||||||
helpers, as a _vmapped variant (since not every driver needs the vmap).
|
helpers, as a _vmapped variant (since not every driver needs the vmap).
|
||||||
And tinydrm_gem_cma_free_object could the be merged into
|
And tinydrm_gem_cma_free_object could the be merged into
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <drm/drm_atomic.h>
|
#include <drm/drm_atomic.h>
|
||||||
#include <drm/drm_atomic_helper.h>
|
#include <drm/drm_atomic_helper.h>
|
||||||
#include <drm/drm_crtc_helper.h>
|
#include <drm/drm_crtc_helper.h>
|
||||||
|
#include <drm/drm_fb_helper.h>
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/tinydrm/tinydrm.h>
|
#include <drm/tinydrm/tinydrm.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
@ -35,23 +36,6 @@
|
|||||||
* and registers the DRM device using devm_tinydrm_register().
|
* and registers the DRM device using devm_tinydrm_register().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* tinydrm_lastclose - DRM lastclose helper
|
|
||||||
* @drm: DRM device
|
|
||||||
*
|
|
||||||
* This function ensures that fbdev is restored when drm_lastclose() is called
|
|
||||||
* on the last drm_release(). Drivers can use this as their
|
|
||||||
* &drm_driver->lastclose callback.
|
|
||||||
*/
|
|
||||||
void tinydrm_lastclose(struct drm_device *drm)
|
|
||||||
{
|
|
||||||
struct tinydrm_device *tdev = drm->dev_private;
|
|
||||||
|
|
||||||
DRM_DEBUG_KMS("\n");
|
|
||||||
drm_fbdev_cma_restore_mode(tdev->fbdev_cma);
|
|
||||||
}
|
|
||||||
EXPORT_SYMBOL(tinydrm_lastclose);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
|
* tinydrm_gem_cma_prime_import_sg_table - Produce a CMA GEM object from
|
||||||
* another driver's scatter/gather table of pinned pages
|
* another driver's scatter/gather table of pinned pages
|
||||||
@ -214,35 +198,24 @@ EXPORT_SYMBOL(devm_tinydrm_init);
|
|||||||
static int tinydrm_register(struct tinydrm_device *tdev)
|
static int tinydrm_register(struct tinydrm_device *tdev)
|
||||||
{
|
{
|
||||||
struct drm_device *drm = tdev->drm;
|
struct drm_device *drm = tdev->drm;
|
||||||
int bpp = drm->mode_config.preferred_depth;
|
|
||||||
struct drm_fbdev_cma *fbdev;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = drm_dev_register(tdev->drm, 0);
|
ret = drm_dev_register(tdev->drm, 0);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
fbdev = drm_fbdev_cma_init_with_funcs(drm, bpp ? bpp : 32,
|
ret = drm_fb_cma_fbdev_init_with_funcs(drm, 0, 0, tdev->fb_funcs);
|
||||||
drm->mode_config.num_connector,
|
if (ret)
|
||||||
tdev->fb_funcs);
|
DRM_ERROR("Failed to initialize fbdev: %d\n", ret);
|
||||||
if (IS_ERR(fbdev))
|
|
||||||
DRM_ERROR("Failed to initialize fbdev: %ld\n", PTR_ERR(fbdev));
|
|
||||||
else
|
|
||||||
tdev->fbdev_cma = fbdev;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tinydrm_unregister(struct tinydrm_device *tdev)
|
static void tinydrm_unregister(struct tinydrm_device *tdev)
|
||||||
{
|
{
|
||||||
struct drm_fbdev_cma *fbdev_cma = tdev->fbdev_cma;
|
|
||||||
|
|
||||||
drm_atomic_helper_shutdown(tdev->drm);
|
drm_atomic_helper_shutdown(tdev->drm);
|
||||||
/* don't restore fbdev in lastclose, keep pipeline disabled */
|
drm_fb_cma_fbdev_fini(tdev->drm);
|
||||||
tdev->fbdev_cma = NULL;
|
|
||||||
drm_dev_unregister(tdev->drm);
|
drm_dev_unregister(tdev->drm);
|
||||||
if (fbdev_cma)
|
|
||||||
drm_fbdev_cma_fini(fbdev_cma);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void devm_tinydrm_register_release(void *data)
|
static void devm_tinydrm_register_release(void *data)
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
#include <video/mipi_display.h>
|
#include <video/mipi_display.h>
|
||||||
|
|
||||||
|
#include <drm/drm_fb_helper.h>
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/tinydrm/mipi-dbi.h>
|
#include <drm/tinydrm/mipi-dbi.h>
|
||||||
#include <drm/tinydrm/tinydrm-helpers.h>
|
#include <drm/tinydrm/tinydrm-helpers.h>
|
||||||
@ -381,7 +382,7 @@ static struct drm_driver ili9225_driver = {
|
|||||||
DRIVER_ATOMIC,
|
DRIVER_ATOMIC,
|
||||||
.fops = &ili9225_fops,
|
.fops = &ili9225_fops,
|
||||||
TINYDRM_GEM_DRIVER_OPS,
|
TINYDRM_GEM_DRIVER_OPS,
|
||||||
.lastclose = tinydrm_lastclose,
|
.lastclose = drm_fb_helper_lastclose,
|
||||||
.name = "ili9225",
|
.name = "ili9225",
|
||||||
.desc = "Ilitek ILI9225",
|
.desc = "Ilitek ILI9225",
|
||||||
.date = "20171106",
|
.date = "20171106",
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <drm/drm_fb_helper.h>
|
||||||
#include <drm/drm_modeset_helper.h>
|
#include <drm/drm_modeset_helper.h>
|
||||||
#include <drm/tinydrm/ili9341.h>
|
#include <drm/tinydrm/ili9341.h>
|
||||||
#include <drm/tinydrm/mipi-dbi.h>
|
#include <drm/tinydrm/mipi-dbi.h>
|
||||||
@ -140,7 +141,7 @@ static struct drm_driver mi0283qt_driver = {
|
|||||||
DRIVER_ATOMIC,
|
DRIVER_ATOMIC,
|
||||||
.fops = &mi0283qt_fops,
|
.fops = &mi0283qt_fops,
|
||||||
TINYDRM_GEM_DRIVER_OPS,
|
TINYDRM_GEM_DRIVER_OPS,
|
||||||
.lastclose = tinydrm_lastclose,
|
.lastclose = drm_fb_helper_lastclose,
|
||||||
.debugfs_init = mipi_dbi_debugfs_init,
|
.debugfs_init = mipi_dbi_debugfs_init,
|
||||||
.name = "mi0283qt",
|
.name = "mi0283qt",
|
||||||
.desc = "Multi-Inno MI0283QT",
|
.desc = "Multi-Inno MI0283QT",
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <linux/spi/spi.h>
|
#include <linux/spi/spi.h>
|
||||||
#include <video/mipi_display.h>
|
#include <video/mipi_display.h>
|
||||||
|
|
||||||
|
#include <drm/drm_fb_helper.h>
|
||||||
#include <drm/drm_gem_framebuffer_helper.h>
|
#include <drm/drm_gem_framebuffer_helper.h>
|
||||||
#include <drm/tinydrm/mipi-dbi.h>
|
#include <drm/tinydrm/mipi-dbi.h>
|
||||||
#include <drm/tinydrm/tinydrm-helpers.h>
|
#include <drm/tinydrm/tinydrm-helpers.h>
|
||||||
@ -320,7 +321,7 @@ static struct drm_driver st7586_driver = {
|
|||||||
DRIVER_ATOMIC,
|
DRIVER_ATOMIC,
|
||||||
.fops = &st7586_fops,
|
.fops = &st7586_fops,
|
||||||
TINYDRM_GEM_DRIVER_OPS,
|
TINYDRM_GEM_DRIVER_OPS,
|
||||||
.lastclose = tinydrm_lastclose,
|
.lastclose = drm_fb_helper_lastclose,
|
||||||
.debugfs_init = mipi_dbi_debugfs_init,
|
.debugfs_init = mipi_dbi_debugfs_init,
|
||||||
.name = "st7586",
|
.name = "st7586",
|
||||||
.desc = "Sitronix ST7586",
|
.desc = "Sitronix ST7586",
|
||||||
|
@ -19,14 +19,12 @@
|
|||||||
* @drm: DRM device
|
* @drm: DRM device
|
||||||
* @pipe: Display pipe structure
|
* @pipe: Display pipe structure
|
||||||
* @dirty_lock: Serializes framebuffer flushing
|
* @dirty_lock: Serializes framebuffer flushing
|
||||||
* @fbdev_cma: CMA fbdev structure
|
|
||||||
* @fb_funcs: Framebuffer functions used when creating framebuffers
|
* @fb_funcs: Framebuffer functions used when creating framebuffers
|
||||||
*/
|
*/
|
||||||
struct tinydrm_device {
|
struct tinydrm_device {
|
||||||
struct drm_device *drm;
|
struct drm_device *drm;
|
||||||
struct drm_simple_display_pipe pipe;
|
struct drm_simple_display_pipe pipe;
|
||||||
struct mutex dirty_lock;
|
struct mutex dirty_lock;
|
||||||
struct drm_fbdev_cma *fbdev_cma;
|
|
||||||
const struct drm_framebuffer_funcs *fb_funcs;
|
const struct drm_framebuffer_funcs *fb_funcs;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -80,7 +78,6 @@ pipe_to_tinydrm(struct drm_simple_display_pipe *pipe)
|
|||||||
.type = DRM_MODE_TYPE_DRIVER, \
|
.type = DRM_MODE_TYPE_DRIVER, \
|
||||||
.clock = 1 /* pass validation */
|
.clock = 1 /* pass validation */
|
||||||
|
|
||||||
void tinydrm_lastclose(struct drm_device *drm);
|
|
||||||
void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
|
void tinydrm_gem_cma_free_object(struct drm_gem_object *gem_obj);
|
||||||
struct drm_gem_object *
|
struct drm_gem_object *
|
||||||
tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
|
tinydrm_gem_cma_prime_import_sg_table(struct drm_device *drm,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user