Skip to content

Commit 9f62b01

Browse files
author
Thomas Zimmermann
committed
drm/armada: 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 armada 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 v4: - revert an unrelated cleanup (Javier) Signed-off-by: Thomas Zimmermann <[email protected]> Cc: Russell King <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1000634 commit 9f62b01

File tree

4 files changed

+17
-112
lines changed

4 files changed

+17
-112
lines changed

drivers/gpu/drm/armada/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config DRM_ARMADA
33
tristate "DRM support for Marvell Armada SoCs"
44
depends on DRM && HAVE_CLK && ARM && MMU
5+
select DRM_CLIENT_SELECTION
56
select DRM_KMS_HELPER
67
select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
78
help

drivers/gpu/drm/armada/armada_drm.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ struct armada_crtc;
1616
struct armada_gem_object;
1717
struct clk;
1818
struct drm_display_mode;
19+
struct drm_fb_helper;
20+
struct drm_fb_helper_surface_size;
1921

2022
static inline void
2123
armada_updatel(uint32_t val, uint32_t mask, void __iomem *ptr)
@@ -74,10 +76,13 @@ struct armada_private {
7476
#define drm_to_armada_dev(dev) container_of(dev, struct armada_private, drm)
7577

7678
#if defined(CONFIG_DRM_FBDEV_EMULATION)
77-
void armada_fbdev_setup(struct drm_device *dev);
79+
int armada_fbdev_driver_fbdev_probe(struct drm_fb_helper *fbh,
80+
struct drm_fb_helper_surface_size *sizes);
81+
#define ARMADA_FBDEV_DRIVER_OPS \
82+
.fbdev_probe = armada_fbdev_driver_fbdev_probe
7883
#else
79-
static inline void armada_fbdev_setup(struct drm_device *dev)
80-
{ }
84+
#define ARMADA_FBDEV_DRIVER_OPS \
85+
.fbdev_probe = NULL
8186
#endif
8287

8388
int armada_overlay_plane_create(struct drm_device *, unsigned long);

drivers/gpu/drm/armada/armada_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <drm/drm_aperture.h>
1414
#include <drm/drm_atomic_helper.h>
15+
#include <drm/drm_client_setup.h>
1516
#include <drm/drm_drv.h>
1617
#include <drm/drm_ioctl.h>
1718
#include <drm/drm_managed.h>
@@ -39,6 +40,7 @@ DEFINE_DRM_GEM_FOPS(armada_drm_fops);
3940
static const struct drm_driver armada_drm_driver = {
4041
.gem_prime_import = armada_gem_prime_import,
4142
.dumb_create = armada_gem_dumb_create,
43+
ARMADA_FBDEV_DRIVER_OPS,
4244
.major = 1,
4345
.minor = 0,
4446
.name = "armada-drm",
@@ -137,7 +139,7 @@ static int armada_drm_bind(struct device *dev)
137139
armada_drm_debugfs_init(priv->drm.primary);
138140
#endif
139141

140-
armada_fbdev_setup(&priv->drm);
142+
drm_client_setup(&priv->drm, NULL);
141143

142144
return 0;
143145

drivers/gpu/drm/armada/armada_fbdev.c

Lines changed: 5 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ static const struct fb_ops armada_fb_ops = {
3939
.fb_destroy = armada_fbdev_fb_destroy,
4040
};
4141

42-
static int armada_fbdev_create(struct drm_fb_helper *fbh,
43-
struct drm_fb_helper_surface_size *sizes)
42+
static const struct drm_fb_helper_funcs armada_fbdev_helper_funcs;
43+
44+
int armada_fbdev_driver_fbdev_probe(struct drm_fb_helper *fbh,
45+
struct drm_fb_helper_surface_size *sizes)
4446
{
4547
struct drm_device *dev = fbh->dev;
4648
struct drm_mode_fb_cmd2 mode;
@@ -98,6 +100,7 @@ static int armada_fbdev_create(struct drm_fb_helper *fbh,
98100
info->fix.smem_len = obj->obj.size;
99101
info->screen_size = obj->obj.size;
100102
info->screen_base = ptr;
103+
fbh->funcs = &armada_fbdev_helper_funcs;
101104
fbh->fb = &dfb->fb;
102105

103106
drm_fb_helper_fill_info(info, fbh, sizes);
@@ -112,109 +115,3 @@ static int armada_fbdev_create(struct drm_fb_helper *fbh,
112115
dfb->fb.funcs->destroy(&dfb->fb);
113116
return ret;
114117
}
115-
116-
static int armada_fb_probe(struct drm_fb_helper *fbh,
117-
struct drm_fb_helper_surface_size *sizes)
118-
{
119-
int ret = 0;
120-
121-
if (!fbh->fb) {
122-
ret = armada_fbdev_create(fbh, sizes);
123-
if (ret == 0)
124-
ret = 1;
125-
}
126-
return ret;
127-
}
128-
129-
static const struct drm_fb_helper_funcs armada_fb_helper_funcs = {
130-
.fb_probe = armada_fb_probe,
131-
};
132-
133-
/*
134-
* Fbdev client and struct drm_client_funcs
135-
*/
136-
137-
static void armada_fbdev_client_unregister(struct drm_client_dev *client)
138-
{
139-
struct drm_fb_helper *fbh = drm_fb_helper_from_client(client);
140-
141-
if (fbh->info) {
142-
drm_fb_helper_unregister_info(fbh);
143-
} else {
144-
drm_client_release(&fbh->client);
145-
drm_fb_helper_unprepare(fbh);
146-
kfree(fbh);
147-
}
148-
}
149-
150-
static int armada_fbdev_client_restore(struct drm_client_dev *client)
151-
{
152-
drm_fb_helper_lastclose(client->dev);
153-
154-
return 0;
155-
}
156-
157-
static int armada_fbdev_client_hotplug(struct drm_client_dev *client)
158-
{
159-
struct drm_fb_helper *fbh = drm_fb_helper_from_client(client);
160-
struct drm_device *dev = client->dev;
161-
int ret;
162-
163-
if (dev->fb_helper)
164-
return drm_fb_helper_hotplug_event(dev->fb_helper);
165-
166-
ret = drm_fb_helper_init(dev, fbh);
167-
if (ret)
168-
goto err_drm_err;
169-
170-
if (!drm_drv_uses_atomic_modeset(dev))
171-
drm_helper_disable_unused_functions(dev);
172-
173-
ret = drm_fb_helper_initial_config(fbh);
174-
if (ret)
175-
goto err_drm_fb_helper_fini;
176-
177-
return 0;
178-
179-
err_drm_fb_helper_fini:
180-
drm_fb_helper_fini(fbh);
181-
err_drm_err:
182-
drm_err(dev, "armada: Failed to setup fbdev emulation (ret=%d)\n", ret);
183-
return ret;
184-
}
185-
186-
static const struct drm_client_funcs armada_fbdev_client_funcs = {
187-
.owner = THIS_MODULE,
188-
.unregister = armada_fbdev_client_unregister,
189-
.restore = armada_fbdev_client_restore,
190-
.hotplug = armada_fbdev_client_hotplug,
191-
};
192-
193-
void armada_fbdev_setup(struct drm_device *dev)
194-
{
195-
struct drm_fb_helper *fbh;
196-
int ret;
197-
198-
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
199-
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
200-
201-
fbh = kzalloc(sizeof(*fbh), GFP_KERNEL);
202-
if (!fbh)
203-
return;
204-
drm_fb_helper_prepare(dev, fbh, 32, &armada_fb_helper_funcs);
205-
206-
ret = drm_client_init(dev, &fbh->client, "fbdev", &armada_fbdev_client_funcs);
207-
if (ret) {
208-
drm_err(dev, "Failed to register client: %d\n", ret);
209-
goto err_drm_client_init;
210-
}
211-
212-
drm_client_register(&fbh->client);
213-
214-
return;
215-
216-
err_drm_client_init:
217-
drm_fb_helper_unprepare(fbh);
218-
kfree(fbh);
219-
return;
220-
}

0 commit comments

Comments
 (0)