6
6
7
7
#include <linux/fb.h>
8
8
9
+ #include <drm/drm_client_setup.h>
9
10
#include <drm/drm_drv.h>
10
11
#include <drm/drm_crtc_helper.h>
11
12
#include <drm/drm_fb_helper.h>
@@ -124,8 +125,32 @@ static const struct fb_ops omap_fb_ops = {
124
125
.fb_destroy = omap_fbdev_fb_destroy ,
125
126
};
126
127
127
- static int omap_fbdev_create (struct drm_fb_helper * helper ,
128
- struct drm_fb_helper_surface_size * sizes )
128
+ static int omap_fbdev_dirty (struct drm_fb_helper * helper , struct drm_clip_rect * clip )
129
+ {
130
+ if (!(clip -> x1 < clip -> x2 && clip -> y1 < clip -> y2 ))
131
+ return 0 ;
132
+
133
+ if (helper -> fb -> funcs -> dirty )
134
+ return helper -> fb -> funcs -> dirty (helper -> fb , NULL , 0 , 0 , clip , 1 );
135
+
136
+ return 0 ;
137
+ }
138
+
139
+ static const struct drm_fb_helper_funcs omap_fbdev_helper_funcs = {
140
+ .fb_dirty = omap_fbdev_dirty ,
141
+ };
142
+
143
+ static struct drm_fb_helper * get_fb (struct fb_info * fbi )
144
+ {
145
+ if (!fbi || strcmp (fbi -> fix .id , MODULE_NAME )) {
146
+ /* these are not the fb's you're looking for */
147
+ return NULL ;
148
+ }
149
+ return fbi -> par ;
150
+ }
151
+
152
+ int omap_fbdev_driver_fbdev_probe (struct drm_fb_helper * helper ,
153
+ struct drm_fb_helper_surface_size * sizes )
129
154
{
130
155
struct drm_device * dev = helper -> dev ;
131
156
struct omap_drm_private * priv = dev -> dev_private ;
@@ -207,6 +232,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
207
232
208
233
DBG ("fbi=%p, dev=%p" , fbi , dev );
209
234
235
+ helper -> funcs = & omap_fbdev_helper_funcs ;
210
236
helper -> fb = fb ;
211
237
212
238
fbi -> fbops = & omap_fb_ops ;
@@ -253,94 +279,10 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
253
279
return ret ;
254
280
}
255
281
256
- static int omap_fbdev_dirty (struct drm_fb_helper * helper , struct drm_clip_rect * clip )
257
- {
258
- if (!(clip -> x1 < clip -> x2 && clip -> y1 < clip -> y2 ))
259
- return 0 ;
260
-
261
- if (helper -> fb -> funcs -> dirty )
262
- return helper -> fb -> funcs -> dirty (helper -> fb , NULL , 0 , 0 , clip , 1 );
263
-
264
- return 0 ;
265
- }
266
-
267
- static const struct drm_fb_helper_funcs omap_fb_helper_funcs = {
268
- .fb_probe = omap_fbdev_create ,
269
- .fb_dirty = omap_fbdev_dirty ,
270
- };
271
-
272
- static struct drm_fb_helper * get_fb (struct fb_info * fbi )
273
- {
274
- if (!fbi || strcmp (fbi -> fix .id , MODULE_NAME )) {
275
- /* these are not the fb's you're looking for */
276
- return NULL ;
277
- }
278
- return fbi -> par ;
279
- }
280
-
281
- /*
282
- * struct drm_client
283
- */
284
-
285
- static void omap_fbdev_client_unregister (struct drm_client_dev * client )
286
- {
287
- struct drm_fb_helper * fb_helper = drm_fb_helper_from_client (client );
288
-
289
- if (fb_helper -> info ) {
290
- drm_fb_helper_unregister_info (fb_helper );
291
- } else {
292
- drm_client_release (& fb_helper -> client );
293
- drm_fb_helper_unprepare (fb_helper );
294
- kfree (fb_helper );
295
- }
296
- }
297
-
298
- static int omap_fbdev_client_restore (struct drm_client_dev * client )
299
- {
300
- drm_fb_helper_lastclose (client -> dev );
301
-
302
- return 0 ;
303
- }
304
-
305
- static int omap_fbdev_client_hotplug (struct drm_client_dev * client )
306
- {
307
- struct drm_fb_helper * fb_helper = drm_fb_helper_from_client (client );
308
- struct drm_device * dev = client -> dev ;
309
- int ret ;
310
-
311
- if (dev -> fb_helper )
312
- return drm_fb_helper_hotplug_event (dev -> fb_helper );
313
-
314
- ret = drm_fb_helper_init (dev , fb_helper );
315
- if (ret )
316
- goto err_drm_err ;
317
-
318
- ret = drm_fb_helper_initial_config (fb_helper );
319
- if (ret )
320
- goto err_drm_fb_helper_fini ;
321
-
322
- return 0 ;
323
-
324
- err_drm_fb_helper_fini :
325
- drm_fb_helper_fini (fb_helper );
326
- err_drm_err :
327
- drm_err (dev , "Failed to setup fbdev emulation (ret=%d)\n" , ret );
328
- return ret ;
329
- }
330
-
331
- static const struct drm_client_funcs omap_fbdev_client_funcs = {
332
- .owner = THIS_MODULE ,
333
- .unregister = omap_fbdev_client_unregister ,
334
- .restore = omap_fbdev_client_restore ,
335
- .hotplug = omap_fbdev_client_hotplug ,
336
- };
337
-
338
282
void omap_fbdev_setup (struct drm_device * dev )
339
283
{
340
284
struct omap_drm_private * priv = dev -> dev_private ;
341
285
struct omap_fbdev * fbdev ;
342
- struct drm_fb_helper * helper ;
343
- int ret ;
344
286
345
287
drm_WARN (dev , !dev -> registered , "Device has not been registered.\n" );
346
288
drm_WARN (dev , dev -> fb_helper , "fb_helper is already set!\n" );
@@ -353,20 +295,5 @@ void omap_fbdev_setup(struct drm_device *dev)
353
295
354
296
priv -> fbdev = fbdev ;
355
297
356
- helper = kzalloc (sizeof (* helper ), GFP_KERNEL );
357
- if (!helper )
358
- return ;
359
- drm_fb_helper_prepare (dev , helper , 32 , & omap_fb_helper_funcs );
360
-
361
- ret = drm_client_init (dev , & helper -> client , "fbdev" , & omap_fbdev_client_funcs );
362
- if (ret )
363
- goto err_drm_client_init ;
364
-
365
- drm_client_register (& helper -> client );
366
-
367
- return ;
368
-
369
- err_drm_client_init :
370
- drm_fb_helper_unprepare (helper );
371
- kfree (helper );
298
+ drm_client_setup (dev , NULL );
372
299
}
0 commit comments