Skip to content

Commit aecdbfe

Browse files
author
Thomas Zimmermann
committed
drm/gma500: 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. v5: - select DRM_CLIENT_SELECTION Signed-off-by: Thomas Zimmermann <[email protected]> Cc: Patrik Jakobsson <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent d4016e3 commit aecdbfe

File tree

4 files changed

+20
-97
lines changed

4 files changed

+20
-97
lines changed

drivers/gpu/drm/gma500/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config DRM_GMA500
33
tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
44
depends on DRM && PCI && X86 && MMU
5+
select DRM_CLIENT_SELECTION
56
select DRM_KMS_HELPER
67
select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
78
select I2C

drivers/gpu/drm/gma500/fbdev.c

Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,15 @@ static const struct fb_ops psb_fbdev_fb_ops = {
143143
.fb_destroy = psb_fbdev_fb_destroy,
144144
};
145145

146+
static const struct drm_fb_helper_funcs psb_fbdev_fb_helper_funcs = {
147+
};
148+
146149
/*
147-
* struct drm_fb_helper_funcs
150+
* struct drm_driver
148151
*/
149152

150-
static int psb_fbdev_fb_probe(struct drm_fb_helper *fb_helper,
151-
struct drm_fb_helper_surface_size *sizes)
153+
int psb_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
154+
struct drm_fb_helper_surface_size *sizes)
152155
{
153156
struct drm_device *dev = fb_helper->dev;
154157
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
@@ -206,6 +209,7 @@ static int psb_fbdev_fb_probe(struct drm_fb_helper *fb_helper,
206209
goto err_drm_gem_object_put;
207210
}
208211

212+
fb_helper->funcs = &psb_fbdev_fb_helper_funcs;
209213
fb_helper->fb = fb;
210214

211215
info = drm_fb_helper_alloc_info(fb_helper);
@@ -246,93 +250,3 @@ static int psb_fbdev_fb_probe(struct drm_fb_helper *fb_helper,
246250
drm_gem_object_put(obj);
247251
return ret;
248252
}
249-
250-
static const struct drm_fb_helper_funcs psb_fbdev_fb_helper_funcs = {
251-
.fb_probe = psb_fbdev_fb_probe,
252-
};
253-
254-
/*
255-
* struct drm_client_funcs and setup code
256-
*/
257-
258-
static void psb_fbdev_client_unregister(struct drm_client_dev *client)
259-
{
260-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
261-
262-
if (fb_helper->info) {
263-
drm_fb_helper_unregister_info(fb_helper);
264-
} else {
265-
drm_fb_helper_unprepare(fb_helper);
266-
drm_client_release(&fb_helper->client);
267-
kfree(fb_helper);
268-
}
269-
}
270-
271-
static int psb_fbdev_client_restore(struct drm_client_dev *client)
272-
{
273-
drm_fb_helper_lastclose(client->dev);
274-
275-
return 0;
276-
}
277-
278-
static int psb_fbdev_client_hotplug(struct drm_client_dev *client)
279-
{
280-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
281-
struct drm_device *dev = client->dev;
282-
int ret;
283-
284-
if (dev->fb_helper)
285-
return drm_fb_helper_hotplug_event(dev->fb_helper);
286-
287-
ret = drm_fb_helper_init(dev, fb_helper);
288-
if (ret)
289-
goto err_drm_err;
290-
291-
if (!drm_drv_uses_atomic_modeset(dev))
292-
drm_helper_disable_unused_functions(dev);
293-
294-
ret = drm_fb_helper_initial_config(fb_helper);
295-
if (ret)
296-
goto err_drm_fb_helper_fini;
297-
298-
return 0;
299-
300-
err_drm_fb_helper_fini:
301-
drm_fb_helper_fini(fb_helper);
302-
err_drm_err:
303-
drm_err(dev, "Failed to setup gma500 fbdev emulation (ret=%d)\n", ret);
304-
return ret;
305-
}
306-
307-
static const struct drm_client_funcs psb_fbdev_client_funcs = {
308-
.owner = THIS_MODULE,
309-
.unregister = psb_fbdev_client_unregister,
310-
.restore = psb_fbdev_client_restore,
311-
.hotplug = psb_fbdev_client_hotplug,
312-
};
313-
314-
void psb_fbdev_setup(struct drm_psb_private *dev_priv)
315-
{
316-
struct drm_device *dev = &dev_priv->dev;
317-
struct drm_fb_helper *fb_helper;
318-
int ret;
319-
320-
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
321-
if (!fb_helper)
322-
return;
323-
drm_fb_helper_prepare(dev, fb_helper, 32, &psb_fbdev_fb_helper_funcs);
324-
325-
ret = drm_client_init(dev, &fb_helper->client, "fbdev-gma500", &psb_fbdev_client_funcs);
326-
if (ret) {
327-
drm_err(dev, "Failed to register client: %d\n", ret);
328-
goto err_drm_fb_helper_unprepare;
329-
}
330-
331-
drm_client_register(&fb_helper->client);
332-
333-
return;
334-
335-
err_drm_fb_helper_unprepare:
336-
drm_fb_helper_unprepare(fb_helper);
337-
kfree(fb_helper);
338-
}

drivers/gpu/drm/gma500/psb_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <acpi/video.h>
2121

2222
#include <drm/drm.h>
23+
#include <drm/drm_client_setup.h>
2324
#include <drm/drm_drv.h>
2425
#include <drm/drm_file.h>
2526
#include <drm/drm_ioctl.h>
@@ -475,7 +476,7 @@ static int psb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
475476
if (ret)
476477
return ret;
477478

478-
psb_fbdev_setup(dev_priv);
479+
drm_client_setup(dev, NULL);
479480

480481
return 0;
481482
}
@@ -506,6 +507,7 @@ static const struct drm_driver driver = {
506507
.num_ioctls = ARRAY_SIZE(psb_ioctls),
507508

508509
.dumb_create = psb_gem_dumb_create,
510+
PSB_FBDEV_DRIVER_OPS,
509511
.ioctls = psb_ioctls,
510512
.fops = &psb_gem_fops,
511513
.name = DRIVER_NAME,

drivers/gpu/drm/gma500/psb_drv.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@
184184
#define KSEL_BYPASS_25 6
185185
#define KSEL_BYPASS_83_100 7
186186

187+
struct drm_fb_helper;
188+
struct drm_fb_helper_surface_size;
189+
187190
struct opregion_header;
188191
struct opregion_acpi;
189192
struct opregion_swsci;
@@ -597,10 +600,13 @@ struct drm_framebuffer *psb_framebuffer_create(struct drm_device *dev,
597600

598601
/* fbdev */
599602
#if defined(CONFIG_DRM_FBDEV_EMULATION)
600-
void psb_fbdev_setup(struct drm_psb_private *dev_priv);
603+
int psb_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
604+
struct drm_fb_helper_surface_size *sizes);
605+
#define PSB_FBDEV_DRIVER_OPS \
606+
.fbdev_probe = psb_fbdev_driver_fbdev_probe
601607
#else
602-
static inline void psb_fbdev_setup(struct drm_psb_private *dev_priv)
603-
{ }
608+
#define PSB_FBDEV_DRIVER_OPS \
609+
.fbdev_probe = NULL
604610
#endif
605611

606612
/* backlight.c */

0 commit comments

Comments
 (0)