Skip to content

Commit d4016e3

Browse files
author
Thomas Zimmermann
committed
drm/exynos-drm: 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 exynos-drm 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: Inki Dae <[email protected]> Cc: Seung-Woo Kim <[email protected]> Cc: Kyungmin Park <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 9f62b01 commit d4016e3

File tree

4 files changed

+20
-99
lines changed

4 files changed

+20
-99
lines changed

drivers/gpu/drm/exynos/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config DRM_EXYNOS
44
depends on OF && DRM && COMMON_CLK
55
depends on ARCH_S3C64XX || ARCH_S5PV210 || ARCH_EXYNOS || COMPILE_TEST
66
depends on MMU
7+
select DRM_CLIENT_SELECTION
78
select DRM_DISPLAY_HELPER if DRM_EXYNOS_DP
89
select DRM_KMS_HELPER
910
select VIDEOMODE_HELPERS

drivers/gpu/drm/exynos/exynos_drm_drv.c

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

1616
#include <drm/drm_atomic.h>
1717
#include <drm/drm_atomic_helper.h>
18+
#include <drm/drm_client_setup.h>
1819
#include <drm/drm_drv.h>
1920
#include <drm/drm_file.h>
2021
#include <drm/drm_fourcc.h>
@@ -111,6 +112,7 @@ static const struct drm_driver exynos_drm_driver = {
111112
.dumb_create = exynos_drm_gem_dumb_create,
112113
.gem_prime_import = exynos_drm_gem_prime_import,
113114
.gem_prime_import_sg_table = exynos_drm_gem_prime_import_sg_table,
115+
EXYNOS_DRM_FBDEV_DRIVER_OPS,
114116
.ioctls = exynos_ioctls,
115117
.num_ioctls = ARRAY_SIZE(exynos_ioctls),
116118
.fops = &exynos_drm_driver_fops,
@@ -288,7 +290,7 @@ static int exynos_drm_bind(struct device *dev)
288290
if (ret < 0)
289291
goto err_cleanup_poll;
290292

291-
exynos_drm_fbdev_setup(drm);
293+
drm_client_setup(drm, NULL);
292294

293295
return 0;
294296

drivers/gpu/drm/exynos/exynos_drm_fbdev.c

Lines changed: 6 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "exynos_drm_fbdev.h"
2424

2525
#define MAX_CONNECTOR 4
26-
#define PREFERRED_BPP 32
2726

2827
static int exynos_drm_fb_mmap(struct fb_info *info, struct vm_area_struct *vma)
2928
{
@@ -87,8 +86,11 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper,
8786
return 0;
8887
}
8988

90-
static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
91-
struct drm_fb_helper_surface_size *sizes)
89+
static const struct drm_fb_helper_funcs exynos_drm_fbdev_helper_funcs = {
90+
};
91+
92+
int exynos_drm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
93+
struct drm_fb_helper_surface_size *sizes)
9294
{
9395
struct exynos_drm_gem *exynos_gem;
9496
struct drm_device *dev = helper->dev;
@@ -120,6 +122,7 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
120122
ret = PTR_ERR(helper->fb);
121123
goto err_destroy_gem;
122124
}
125+
helper->funcs = &exynos_drm_fbdev_helper_funcs;
123126

124127
ret = exynos_drm_fbdev_update(helper, sizes, exynos_gem);
125128
if (ret < 0)
@@ -134,93 +137,3 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper,
134137
exynos_drm_gem_destroy(exynos_gem);
135138
return ret;
136139
}
137-
138-
static const struct drm_fb_helper_funcs exynos_drm_fb_helper_funcs = {
139-
.fb_probe = exynos_drm_fbdev_create,
140-
};
141-
142-
/*
143-
* struct drm_client
144-
*/
145-
146-
static void exynos_drm_fbdev_client_unregister(struct drm_client_dev *client)
147-
{
148-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
149-
150-
if (fb_helper->info) {
151-
drm_fb_helper_unregister_info(fb_helper);
152-
} else {
153-
drm_client_release(&fb_helper->client);
154-
drm_fb_helper_unprepare(fb_helper);
155-
kfree(fb_helper);
156-
}
157-
}
158-
159-
static int exynos_drm_fbdev_client_restore(struct drm_client_dev *client)
160-
{
161-
drm_fb_helper_lastclose(client->dev);
162-
163-
return 0;
164-
}
165-
166-
static int exynos_drm_fbdev_client_hotplug(struct drm_client_dev *client)
167-
{
168-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
169-
struct drm_device *dev = client->dev;
170-
int ret;
171-
172-
if (dev->fb_helper)
173-
return drm_fb_helper_hotplug_event(dev->fb_helper);
174-
175-
ret = drm_fb_helper_init(dev, fb_helper);
176-
if (ret)
177-
goto err_drm_err;
178-
179-
if (!drm_drv_uses_atomic_modeset(dev))
180-
drm_helper_disable_unused_functions(dev);
181-
182-
ret = drm_fb_helper_initial_config(fb_helper);
183-
if (ret)
184-
goto err_drm_fb_helper_fini;
185-
186-
return 0;
187-
188-
err_drm_fb_helper_fini:
189-
drm_fb_helper_fini(fb_helper);
190-
err_drm_err:
191-
drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret);
192-
return ret;
193-
}
194-
195-
static const struct drm_client_funcs exynos_drm_fbdev_client_funcs = {
196-
.owner = THIS_MODULE,
197-
.unregister = exynos_drm_fbdev_client_unregister,
198-
.restore = exynos_drm_fbdev_client_restore,
199-
.hotplug = exynos_drm_fbdev_client_hotplug,
200-
};
201-
202-
void exynos_drm_fbdev_setup(struct drm_device *dev)
203-
{
204-
struct drm_fb_helper *fb_helper;
205-
int ret;
206-
207-
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
208-
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
209-
210-
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
211-
if (!fb_helper)
212-
return;
213-
drm_fb_helper_prepare(dev, fb_helper, PREFERRED_BPP, &exynos_drm_fb_helper_funcs);
214-
215-
ret = drm_client_init(dev, &fb_helper->client, "fbdev", &exynos_drm_fbdev_client_funcs);
216-
if (ret)
217-
goto err_drm_client_init;
218-
219-
drm_client_register(&fb_helper->client);
220-
221-
return;
222-
223-
err_drm_client_init:
224-
drm_fb_helper_unprepare(fb_helper);
225-
kfree(fb_helper);
226-
}

drivers/gpu/drm/exynos/exynos_drm_fbdev.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
#ifndef _EXYNOS_DRM_FBDEV_H_
1212
#define _EXYNOS_DRM_FBDEV_H_
1313

14-
#ifdef CONFIG_DRM_FBDEV_EMULATION
15-
void exynos_drm_fbdev_setup(struct drm_device *dev);
14+
struct drm_fb_helper;
15+
struct drm_fb_helper_surface_size;
16+
17+
#if defined(CONFIG_DRM_FBDEV_EMULATION)
18+
int exynos_drm_fbdev_driver_fbdev_probe(struct drm_fb_helper *fbh,
19+
struct drm_fb_helper_surface_size *sizes);
20+
#define EXYNOS_DRM_FBDEV_DRIVER_OPS \
21+
.fbdev_probe = exynos_drm_fbdev_driver_fbdev_probe
1622
#else
17-
static inline void exynos_drm_fbdev_setup(struct drm_device *dev)
18-
{
19-
}
23+
#define EXYNOS_DRM_FBDEV_DRIVER_OPS \
24+
.fbdev_probe = NULL
2025
#endif
2126

2227
#endif

0 commit comments

Comments
 (0)