13
13
#include <drm/drm_fourcc.h>
14
14
#include <drm/drm_framebuffer.h>
15
15
#include <drm/drm_gem_framebuffer_helper.h>
16
+ #include <drm/drm_managed.h>
16
17
#include <drm/drm_util.h>
17
18
18
19
#include "omap_drv.h"
@@ -26,10 +27,8 @@ module_param_named(ywrap, ywrap_enabled, bool, 0644);
26
27
* fbdev funcs, to implement legacy fbdev interface on top of drm driver
27
28
*/
28
29
29
- #define to_omap_fbdev (x ) container_of(x, struct omap_fbdev, base)
30
-
31
30
struct omap_fbdev {
32
- struct drm_fb_helper base ;
31
+ struct drm_device * dev ;
33
32
bool ywrap_enabled ;
34
33
35
34
/* 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);
41
40
static void pan_worker (struct work_struct * work )
42
41
{
43
42
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 ;
45
44
struct fb_info * fbi = helper -> info ;
46
45
struct drm_gem_object * bo = drm_gem_fb_get_obj (helper -> fb , 0 );
47
46
int npages ;
@@ -55,24 +54,25 @@ FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS(omap_fbdev,
55
54
drm_fb_helper_damage_range ,
56
55
drm_fb_helper_damage_area )
57
56
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 )
60
58
{
61
59
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 ;
63
62
64
63
if (!helper )
65
64
goto fallback ;
66
65
66
+ priv = helper -> dev -> dev_private ;
67
+ fbdev = priv -> fbdev ;
68
+
67
69
if (!fbdev -> ywrap_enabled )
68
70
goto fallback ;
69
71
70
- if (drm_can_sleep ()) {
72
+ if (drm_can_sleep ())
71
73
pan_worker (& fbdev -> work );
72
- } else {
73
- struct omap_drm_private * priv = helper -> dev -> dev_private ;
74
+ else
74
75
queue_work (priv -> wq , & fbdev -> work );
75
- }
76
76
77
77
return 0 ;
78
78
@@ -92,7 +92,6 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
92
92
struct drm_fb_helper * helper = info -> par ;
93
93
struct drm_framebuffer * fb = helper -> fb ;
94
94
struct drm_gem_object * bo = drm_gem_fb_get_obj (fb , 0 );
95
- struct omap_fbdev * fbdev = to_omap_fbdev (helper );
96
95
97
96
DBG ();
98
97
@@ -104,7 +103,7 @@ static void omap_fbdev_fb_destroy(struct fb_info *info)
104
103
105
104
drm_client_release (& helper -> client );
106
105
drm_fb_helper_unprepare (helper );
107
- kfree (fbdev );
106
+ kfree (helper );
108
107
}
109
108
110
109
/*
@@ -128,9 +127,9 @@ static const struct fb_ops omap_fb_ops = {
128
127
static int omap_fbdev_create (struct drm_fb_helper * helper ,
129
128
struct drm_fb_helper_surface_size * sizes )
130
129
{
131
- struct omap_fbdev * fbdev = to_omap_fbdev (helper );
132
130
struct drm_device * dev = helper -> dev ;
133
131
struct omap_drm_private * priv = dev -> dev_private ;
132
+ struct omap_fbdev * fbdev = priv -> fbdev ;
134
133
struct drm_framebuffer * fb = NULL ;
135
134
union omap_gem_size gsize ;
136
135
struct fb_info * fbi = NULL ;
@@ -338,31 +337,36 @@ static const struct drm_client_funcs omap_fbdev_client_funcs = {
338
337
339
338
void omap_fbdev_setup (struct drm_device * dev )
340
339
{
340
+ struct omap_drm_private * priv = dev -> dev_private ;
341
341
struct omap_fbdev * fbdev ;
342
342
struct drm_fb_helper * helper ;
343
343
int ret ;
344
344
345
345
drm_WARN (dev , !dev -> registered , "Device has not been registered.\n" );
346
346
drm_WARN (dev , dev -> fb_helper , "fb_helper is already set!\n" );
347
347
348
- fbdev = kzalloc ( sizeof (* fbdev ), GFP_KERNEL );
348
+ fbdev = drmm_kzalloc ( dev , sizeof (* fbdev ), GFP_KERNEL );
349
349
if (!fbdev )
350
350
return ;
351
- helper = & fbdev -> base ;
351
+ fbdev -> dev = dev ;
352
+ INIT_WORK (& fbdev -> work , pan_worker );
353
+
354
+ priv -> fbdev = fbdev ;
352
355
356
+ helper = kzalloc (sizeof (* helper ), GFP_KERNEL );
357
+ if (!helper )
358
+ return ;
353
359
drm_fb_helper_prepare (dev , helper , 32 , & omap_fb_helper_funcs );
354
360
355
361
ret = drm_client_init (dev , & helper -> client , "fbdev" , & omap_fbdev_client_funcs );
356
362
if (ret )
357
363
goto err_drm_client_init ;
358
364
359
- INIT_WORK (& fbdev -> work , pan_worker );
360
-
361
365
drm_client_register (& helper -> client );
362
366
363
367
return ;
364
368
365
369
err_drm_client_init :
366
370
drm_fb_helper_unprepare (helper );
367
- kfree (fbdev );
371
+ kfree (helper );
368
372
}
0 commit comments