Skip to content

Commit eae9b54

Browse files
author
Thomas Zimmermann
committed
drm/omapdrm: Remove struct drm_fb_helper from struct omap_fbdev.
Store instances of drm_fb_helper and struct omap_fbdev separately. This will allow omapdrm to use the common fbdev client, which allocates its own instance of struct drm_fb_helper. There is at most one instance of each per DRM device, so both can be referenced directly from the omap and DRM device structures. A later patchset might rework the common fbdev client to allow for storing both, drm_fb_helper and omap_fbdev, together in the same place. Signed-off-by: Thomas Zimmermann <[email protected]> Cc: Tomi Valkeinen <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 5208989 commit eae9b54

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

drivers/gpu/drm/omapdrm/omap_drv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#define MODULE_NAME "omapdrm"
3333

3434
struct omap_drm_usergart;
35+
struct omap_fbdev;
3536

3637
struct omap_drm_pipeline {
3738
struct drm_crtc *crtc;
@@ -97,6 +98,8 @@ struct omap_drm_private {
9798

9899
/* memory bandwidth limit if it is needed on the platform */
99100
unsigned int max_bandwidth;
101+
102+
struct omap_fbdev *fbdev;
100103
};
101104

102105

drivers/gpu/drm/omapdrm/omap_fbdev.c

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <drm/drm_fourcc.h>
1414
#include <drm/drm_framebuffer.h>
1515
#include <drm/drm_gem_framebuffer_helper.h>
16+
#include <drm/drm_managed.h>
1617
#include <drm/drm_util.h>
1718

1819
#include "omap_drv.h"
@@ -26,10 +27,8 @@ module_param_named(ywrap, ywrap_enabled, bool, 0644);
2627
* fbdev funcs, to implement legacy fbdev interface on top of drm driver
2728
*/
2829

29-
#define to_omap_fbdev(x) container_of(x, struct omap_fbdev, base)
30-
3130
struct omap_fbdev {
32-
struct drm_fb_helper base;
31+
struct drm_device *dev;
3332
bool ywrap_enabled;
3433

3534
/* for deferred dmm roll when getting called in atomic ctx */
@@ -41,7 +40,7 @@ static struct drm_fb_helper *get_fb(struct fb_info *fbi);
4140
static void pan_worker(struct work_struct *work)
4241
{
4342
struct omap_fbdev *fbdev = container_of(work, struct omap_fbdev, work);
44-
struct drm_fb_helper *helper = &fbdev->base;
43+
struct drm_fb_helper *helper = fbdev->dev->fb_helper;
4544
struct fb_info *fbi = helper->info;
4645
struct drm_gem_object *bo = drm_gem_fb_get_obj(helper->fb, 0);
4746
int npages;
@@ -55,24 +54,25 @@ FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS(omap_fbdev,
5554
drm_fb_helper_damage_range,
5655
drm_fb_helper_damage_area)
5756

58-
static int omap_fbdev_pan_display(struct fb_var_screeninfo *var,
59-
struct fb_info *fbi)
57+
static int omap_fbdev_pan_display(struct fb_var_screeninfo *var, struct fb_info *fbi)
6058
{
6159
struct drm_fb_helper *helper = get_fb(fbi);
62-
struct omap_fbdev *fbdev = to_omap_fbdev(helper);
60+
struct omap_drm_private *priv;
61+
struct omap_fbdev *fbdev;
6362

6463
if (!helper)
6564
goto fallback;
6665

66+
priv = helper->dev->dev_private;
67+
fbdev = priv->fbdev;
68+
6769
if (!fbdev->ywrap_enabled)
6870
goto fallback;
6971

70-
if (drm_can_sleep()) {
72+
if (drm_can_sleep())
7173
pan_worker(&fbdev->work);
72-
} else {
73-
struct omap_drm_private *priv = helper->dev->dev_private;
74+
else
7475
queue_work(priv->wq, &fbdev->work);
75-
}
7676

7777
return 0;
7878

@@ -92,7 +92,6 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
9292
struct drm_fb_helper *helper = info->par;
9393
struct drm_framebuffer *fb = helper->fb;
9494
struct drm_gem_object *bo = drm_gem_fb_get_obj(fb, 0);
95-
struct omap_fbdev *fbdev = to_omap_fbdev(helper);
9695

9796
DBG();
9897

@@ -104,7 +103,7 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
104103

105104
drm_client_release(&helper->client);
106105
drm_fb_helper_unprepare(helper);
107-
kfree(fbdev);
106+
kfree(helper);
108107
}
109108

110109
/*
@@ -128,9 +127,9 @@ static const struct fb_ops omap_fb_ops = {
128127
static int omap_fbdev_create(struct drm_fb_helper *helper,
129128
struct drm_fb_helper_surface_size *sizes)
130129
{
131-
struct omap_fbdev *fbdev = to_omap_fbdev(helper);
132130
struct drm_device *dev = helper->dev;
133131
struct omap_drm_private *priv = dev->dev_private;
132+
struct omap_fbdev *fbdev = priv->fbdev;
134133
struct drm_framebuffer *fb = NULL;
135134
union omap_gem_size gsize;
136135
struct fb_info *fbi = NULL;
@@ -338,31 +337,36 @@ static const struct drm_client_funcs omap_fbdev_client_funcs = {
338337

339338
void omap_fbdev_setup(struct drm_device *dev)
340339
{
340+
struct omap_drm_private *priv = dev->dev_private;
341341
struct omap_fbdev *fbdev;
342342
struct drm_fb_helper *helper;
343343
int ret;
344344

345345
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
346346
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
347347

348-
fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
348+
fbdev = drmm_kzalloc(dev, sizeof(*fbdev), GFP_KERNEL);
349349
if (!fbdev)
350350
return;
351-
helper = &fbdev->base;
351+
fbdev->dev = dev;
352+
INIT_WORK(&fbdev->work, pan_worker);
353+
354+
priv->fbdev = fbdev;
352355

356+
helper = kzalloc(sizeof(*helper), GFP_KERNEL);
357+
if (!helper)
358+
return;
353359
drm_fb_helper_prepare(dev, helper, 32, &omap_fb_helper_funcs);
354360

355361
ret = drm_client_init(dev, &helper->client, "fbdev", &omap_fbdev_client_funcs);
356362
if (ret)
357363
goto err_drm_client_init;
358364

359-
INIT_WORK(&fbdev->work, pan_worker);
360-
361365
drm_client_register(&helper->client);
362366

363367
return;
364368

365369
err_drm_client_init:
366370
drm_fb_helper_unprepare(helper);
367-
kfree(fbdev);
371+
kfree(helper);
368372
}

0 commit comments

Comments
 (0)