Skip to content

Commit 5208989

Browse files
author
Thomas Zimmermann
committed
drm/tegra: 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 tegra 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: Thierry Reding <[email protected]> Cc: Mikko Perttunen <[email protected]> Cc: Jonathan Hunter <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 41d48e5 commit 5208989

File tree

4 files changed

+20
-96
lines changed

4 files changed

+20
-96
lines changed

drivers/gpu/drm/tegra/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config DRM_TEGRA
55
depends on COMMON_CLK
66
depends on DRM
77
depends on OF
8+
select DRM_CLIENT_SELECTION
89
select DRM_DISPLAY_DP_HELPER
910
select DRM_DISPLAY_HDMI_HELPER
1011
select DRM_DISPLAY_HELPER

drivers/gpu/drm/tegra/drm.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <drm/drm_aperture.h>
1616
#include <drm/drm_atomic.h>
1717
#include <drm/drm_atomic_helper.h>
18+
#include <drm/drm_client_setup.h>
1819
#include <drm/drm_debugfs.h>
1920
#include <drm/drm_drv.h>
2021
#include <drm/drm_fourcc.h>
@@ -891,6 +892,8 @@ static const struct drm_driver tegra_drm_driver = {
891892

892893
.dumb_create = tegra_bo_dumb_create,
893894

895+
TEGRA_FBDEV_DRIVER_OPS,
896+
894897
.ioctls = tegra_drm_ioctls,
895898
.num_ioctls = ARRAY_SIZE(tegra_drm_ioctls),
896899
.fops = &tegra_drm_fops,
@@ -1268,7 +1271,7 @@ static int host1x_drm_probe(struct host1x_device *dev)
12681271
if (err < 0)
12691272
goto hub;
12701273

1271-
tegra_fbdev_setup(drm);
1274+
drm_client_setup(drm, NULL);
12721275

12731276
return 0;
12741277

drivers/gpu/drm/tegra/drm.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
/* XXX move to include/uapi/drm/drm_fourcc.h? */
2626
#define DRM_FORMAT_MOD_NVIDIA_SECTOR_LAYOUT BIT_ULL(22)
2727

28+
struct drm_fb_helper;
29+
struct drm_fb_helper_surface_size;
30+
2831
struct edid;
2932
struct reset_control;
3033

@@ -190,10 +193,13 @@ struct drm_framebuffer *tegra_fb_create(struct drm_device *drm,
190193
const struct drm_mode_fb_cmd2 *cmd);
191194

192195
#ifdef CONFIG_DRM_FBDEV_EMULATION
193-
void tegra_fbdev_setup(struct drm_device *drm);
196+
int tegra_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
197+
struct drm_fb_helper_surface_size *sizes);
198+
#define TEGRA_FBDEV_DRIVER_OPS \
199+
.fbdev_probe = tegra_fbdev_driver_fbdev_probe
194200
#else
195-
static inline void tegra_fbdev_setup(struct drm_device *drm)
196-
{ }
201+
#define TEGRA_FBDEV_DRIVER_OPS \
202+
.fbdev_probe = NULL
197203
#endif
198204

199205
extern struct platform_driver tegra_display_hub_driver;

drivers/gpu/drm/tegra/fbdev.c

Lines changed: 6 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ static const struct fb_ops tegra_fb_ops = {
6666
.fb_destroy = tegra_fbdev_fb_destroy,
6767
};
6868

69-
static int tegra_fbdev_probe(struct drm_fb_helper *helper,
70-
struct drm_fb_helper_surface_size *sizes)
69+
static const struct drm_fb_helper_funcs tegra_fbdev_helper_funcs = {
70+
};
71+
72+
int tegra_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
73+
struct drm_fb_helper_surface_size *sizes)
7174
{
7275
struct tegra_drm *tegra = helper->dev->dev_private;
7376
struct drm_device *drm = helper->dev;
@@ -112,6 +115,7 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
112115
return PTR_ERR(fb);
113116
}
114117

118+
helper->funcs = &tegra_fbdev_helper_funcs;
115119
helper->fb = fb;
116120
helper->info = info;
117121

@@ -144,93 +148,3 @@ static int tegra_fbdev_probe(struct drm_fb_helper *helper,
144148
drm_framebuffer_remove(fb);
145149
return err;
146150
}
147-
148-
static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = {
149-
.fb_probe = tegra_fbdev_probe,
150-
};
151-
152-
/*
153-
* struct drm_client
154-
*/
155-
156-
static void tegra_fbdev_client_unregister(struct drm_client_dev *client)
157-
{
158-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
159-
160-
if (fb_helper->info) {
161-
drm_fb_helper_unregister_info(fb_helper);
162-
} else {
163-
drm_client_release(&fb_helper->client);
164-
drm_fb_helper_unprepare(fb_helper);
165-
kfree(fb_helper);
166-
}
167-
}
168-
169-
static int tegra_fbdev_client_restore(struct drm_client_dev *client)
170-
{
171-
drm_fb_helper_lastclose(client->dev);
172-
173-
return 0;
174-
}
175-
176-
static int tegra_fbdev_client_hotplug(struct drm_client_dev *client)
177-
{
178-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
179-
struct drm_device *dev = client->dev;
180-
int ret;
181-
182-
if (dev->fb_helper)
183-
return drm_fb_helper_hotplug_event(dev->fb_helper);
184-
185-
ret = drm_fb_helper_init(dev, fb_helper);
186-
if (ret)
187-
goto err_drm_err;
188-
189-
if (!drm_drv_uses_atomic_modeset(dev))
190-
drm_helper_disable_unused_functions(dev);
191-
192-
ret = drm_fb_helper_initial_config(fb_helper);
193-
if (ret)
194-
goto err_drm_fb_helper_fini;
195-
196-
return 0;
197-
198-
err_drm_fb_helper_fini:
199-
drm_fb_helper_fini(fb_helper);
200-
err_drm_err:
201-
drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret);
202-
return ret;
203-
}
204-
205-
static const struct drm_client_funcs tegra_fbdev_client_funcs = {
206-
.owner = THIS_MODULE,
207-
.unregister = tegra_fbdev_client_unregister,
208-
.restore = tegra_fbdev_client_restore,
209-
.hotplug = tegra_fbdev_client_hotplug,
210-
};
211-
212-
void tegra_fbdev_setup(struct drm_device *dev)
213-
{
214-
struct drm_fb_helper *helper;
215-
int ret;
216-
217-
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
218-
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
219-
220-
helper = kzalloc(sizeof(*helper), GFP_KERNEL);
221-
if (!helper)
222-
return;
223-
drm_fb_helper_prepare(dev, helper, 32, &tegra_fb_helper_funcs);
224-
225-
ret = drm_client_init(dev, &helper->client, "fbdev", &tegra_fbdev_client_funcs);
226-
if (ret)
227-
goto err_drm_client_init;
228-
229-
drm_client_register(&helper->client);
230-
231-
return;
232-
233-
err_drm_client_init:
234-
drm_fb_helper_unprepare(helper);
235-
kfree(helper);
236-
}

0 commit comments

Comments
 (0)