Skip to content

Commit 1549974

Browse files
author
Thomas Zimmermann
committed
drm/omapdrm: Run DRM default client setup
Rework fbdev probing to support fbdev_probe in struct drm_driver and remove the old fb_probe callback. Provide an initializer macro for struct drm_driver that sets the callback according to the kernel configuration. Call drm_client_setup() to run the kernel's default client setup for DRM. Set fbdev_probe in struct drm_driver, so that the client setup can start the common fbdev client. The omapdrm driver specifies a preferred color mode of 32. As this is the default if no format has been given, leave it out entirely. v5: - select DRM_CLIENT_SELECTION 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 eae9b54 commit 1549974

File tree

4 files changed

+39
-102
lines changed

4 files changed

+39
-102
lines changed

drivers/gpu/drm/omapdrm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config DRM_OMAP
44
depends on MMU
55
depends on DRM && OF
66
depends on ARCH_OMAP2PLUS || (COMPILE_TEST && PAGE_SIZE_LESS_THAN_64KB)
7+
select DRM_CLIENT_SELECTION
78
select DRM_KMS_HELPER
89
select DRM_DISPLAY_HELPER
910
select DRM_BRIDGE_CONNECTOR

drivers/gpu/drm/omapdrm/omap_drv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,7 @@ static const struct drm_driver omap_drm_driver = {
647647
.gem_prime_import = omap_gem_prime_import,
648648
.dumb_create = omap_gem_dumb_create,
649649
.dumb_map_offset = omap_gem_dumb_map_offset,
650+
OMAP_FBDEV_DRIVER_OPS,
650651
.ioctls = ioctls,
651652
.num_ioctls = DRM_OMAP_NUM_IOCTLS,
652653
.fops = &omapdriver_fops,

drivers/gpu/drm/omapdrm/omap_fbdev.c

Lines changed: 29 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/fb.h>
88

9+
#include <drm/drm_client_setup.h>
910
#include <drm/drm_drv.h>
1011
#include <drm/drm_crtc_helper.h>
1112
#include <drm/drm_fb_helper.h>
@@ -124,8 +125,32 @@ static const struct fb_ops omap_fb_ops = {
124125
.fb_destroy = omap_fbdev_fb_destroy,
125126
};
126127

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)
129154
{
130155
struct drm_device *dev = helper->dev;
131156
struct omap_drm_private *priv = dev->dev_private;
@@ -207,6 +232,7 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
207232

208233
DBG("fbi=%p, dev=%p", fbi, dev);
209234

235+
helper->funcs = &omap_fbdev_helper_funcs;
210236
helper->fb = fb;
211237

212238
fbi->fbops = &omap_fb_ops;
@@ -253,94 +279,10 @@ static int omap_fbdev_create(struct drm_fb_helper *helper,
253279
return ret;
254280
}
255281

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-
338282
void omap_fbdev_setup(struct drm_device *dev)
339283
{
340284
struct omap_drm_private *priv = dev->dev_private;
341285
struct omap_fbdev *fbdev;
342-
struct drm_fb_helper *helper;
343-
int ret;
344286

345287
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
346288
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
@@ -353,20 +295,5 @@ void omap_fbdev_setup(struct drm_device *dev)
353295

354296
priv->fbdev = fbdev;
355297

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);
372299
}

drivers/gpu/drm/omapdrm/omap_fbdev.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@
1010
#define __OMAPDRM_FBDEV_H__
1111

1212
struct drm_device;
13+
struct drm_fb_helper;
14+
struct drm_fb_helper_surface_size;
1315

1416
#ifdef CONFIG_DRM_FBDEV_EMULATION
17+
int omap_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
18+
struct drm_fb_helper_surface_size *sizes);
19+
#define OMAP_FBDEV_DRIVER_OPS \
20+
.fbdev_probe = omap_fbdev_driver_fbdev_probe
1521
void omap_fbdev_setup(struct drm_device *dev);
1622
#else
23+
#define OMAP_FBDEV_DRIVER_OPS \
24+
.fbdev_probe = NULL
1725
static inline void omap_fbdev_setup(struct drm_device *dev)
1826
{
1927
}

0 commit comments

Comments
 (0)