Skip to content

Commit fe96a73

Browse files
author
Thomas Zimmermann
committed
drm/msm: 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 msm 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: Rob Clark <[email protected]> Cc: Abhinav Kumar <[email protected]> Cc: Dmitry Baryshkov <[email protected]> Cc: Sean Paul <[email protected]> Cc: Marijn Suijten <[email protected]> Acked-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Dmitry Baryshkov <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent aecdbfe commit fe96a73

File tree

4 files changed

+39
-123
lines changed

4 files changed

+39
-123
lines changed

drivers/gpu/drm/msm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ config DRM_MSM
1414
select IOMMU_IO_PGTABLE
1515
select QCOM_MDT_LOADER if ARCH_QCOM
1616
select REGULATOR
17+
select DRM_CLIENT_SELECTION
1718
select DRM_DISPLAY_DP_AUX_BUS
1819
select DRM_DISPLAY_DP_HELPER
1920
select DRM_DISPLAY_HELPER

drivers/gpu/drm/msm/msm_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/of_address.h>
1111
#include <linux/uaccess.h>
1212

13+
#include <drm/drm_client_setup.h>
1314
#include <drm/drm_drv.h>
1415
#include <drm/drm_file.h>
1516
#include <drm/drm_ioctl.h>
@@ -292,7 +293,7 @@ static int msm_drm_init(struct device *dev, const struct drm_driver *drv)
292293

293294
if (priv->kms_init) {
294295
drm_kms_helper_poll_init(ddev);
295-
msm_fbdev_setup(ddev);
296+
drm_client_setup(ddev, NULL);
296297
}
297298

298299
return 0;
@@ -903,6 +904,7 @@ static const struct drm_driver msm_driver = {
903904
#ifdef CONFIG_DEBUG_FS
904905
.debugfs_init = msm_debugfs_init,
905906
#endif
907+
MSM_FBDEV_DRIVER_OPS,
906908
.show_fdinfo = msm_show_fdinfo,
907909
.ioctls = msm_ioctls,
908910
.num_ioctls = ARRAY_SIZE(msm_ioctls),

drivers/gpu/drm/msm/msm_drv.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ extern struct fault_attr fail_gem_iova;
4040
# define should_fail(attr, size) 0
4141
#endif
4242

43+
struct drm_fb_helper;
44+
struct drm_fb_helper_surface_size;
45+
4346
struct msm_kms;
4447
struct msm_gpu;
4548
struct msm_mmu;
@@ -294,11 +297,13 @@ struct drm_framebuffer * msm_alloc_stolen_fb(struct drm_device *dev,
294297
int w, int h, int p, uint32_t format);
295298

296299
#ifdef CONFIG_DRM_FBDEV_EMULATION
297-
void msm_fbdev_setup(struct drm_device *dev);
300+
int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
301+
struct drm_fb_helper_surface_size *sizes);
302+
#define MSM_FBDEV_DRIVER_OPS \
303+
.fbdev_probe = msm_fbdev_driver_fbdev_probe
298304
#else
299-
static inline void msm_fbdev_setup(struct drm_device *dev)
300-
{
301-
}
305+
#define MSM_FBDEV_DRIVER_OPS \
306+
.fbdev_probe = NULL
302307
#endif
303308

304309
struct hdmi;

drivers/gpu/drm/msm/msm_fbdev.c

Lines changed: 26 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,31 @@ static const struct fb_ops msm_fb_ops = {
6565
.fb_destroy = msm_fbdev_fb_destroy,
6666
};
6767

68-
static int msm_fbdev_create(struct drm_fb_helper *helper,
69-
struct drm_fb_helper_surface_size *sizes)
68+
static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
69+
struct drm_clip_rect *clip)
70+
{
71+
struct drm_device *dev = helper->dev;
72+
int ret;
73+
74+
/* Call damage handlers only if necessary */
75+
if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
76+
return 0;
77+
78+
if (helper->fb->funcs->dirty) {
79+
ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
80+
if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
81+
return ret;
82+
}
83+
84+
return 0;
85+
}
86+
87+
static const struct drm_fb_helper_funcs msm_fbdev_helper_funcs = {
88+
.fb_dirty = msm_fbdev_fb_dirty,
89+
};
90+
91+
int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
92+
struct drm_fb_helper_surface_size *sizes)
7093
{
7194
struct drm_device *dev = helper->dev;
7295
struct msm_drm_private *priv = dev->dev_private;
@@ -114,6 +137,7 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
114137

115138
DBG("fbi=%p, dev=%p", fbi, dev);
116139

140+
helper->funcs = &msm_fbdev_helper_funcs;
117141
helper->fb = fb;
118142

119143
fbi->fbops = &msm_fb_ops;
@@ -138,119 +162,3 @@ static int msm_fbdev_create(struct drm_fb_helper *helper,
138162
drm_framebuffer_remove(fb);
139163
return ret;
140164
}
141-
142-
static int msm_fbdev_fb_dirty(struct drm_fb_helper *helper,
143-
struct drm_clip_rect *clip)
144-
{
145-
struct drm_device *dev = helper->dev;
146-
int ret;
147-
148-
/* Call damage handlers only if necessary */
149-
if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
150-
return 0;
151-
152-
if (helper->fb->funcs->dirty) {
153-
ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
154-
if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
155-
return ret;
156-
}
157-
158-
return 0;
159-
}
160-
161-
static const struct drm_fb_helper_funcs msm_fb_helper_funcs = {
162-
.fb_probe = msm_fbdev_create,
163-
.fb_dirty = msm_fbdev_fb_dirty,
164-
};
165-
166-
/*
167-
* struct drm_client
168-
*/
169-
170-
static void msm_fbdev_client_unregister(struct drm_client_dev *client)
171-
{
172-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
173-
174-
if (fb_helper->info) {
175-
drm_fb_helper_unregister_info(fb_helper);
176-
} else {
177-
drm_client_release(&fb_helper->client);
178-
drm_fb_helper_unprepare(fb_helper);
179-
kfree(fb_helper);
180-
}
181-
}
182-
183-
static int msm_fbdev_client_restore(struct drm_client_dev *client)
184-
{
185-
drm_fb_helper_lastclose(client->dev);
186-
187-
return 0;
188-
}
189-
190-
static int msm_fbdev_client_hotplug(struct drm_client_dev *client)
191-
{
192-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
193-
struct drm_device *dev = client->dev;
194-
int ret;
195-
196-
if (dev->fb_helper)
197-
return drm_fb_helper_hotplug_event(dev->fb_helper);
198-
199-
ret = drm_fb_helper_init(dev, fb_helper);
200-
if (ret)
201-
goto err_drm_err;
202-
203-
if (!drm_drv_uses_atomic_modeset(dev))
204-
drm_helper_disable_unused_functions(dev);
205-
206-
ret = drm_fb_helper_initial_config(fb_helper);
207-
if (ret)
208-
goto err_drm_fb_helper_fini;
209-
210-
return 0;
211-
212-
err_drm_fb_helper_fini:
213-
drm_fb_helper_fini(fb_helper);
214-
err_drm_err:
215-
drm_err(dev, "Failed to setup fbdev emulation (ret=%d)\n", ret);
216-
return ret;
217-
}
218-
219-
static const struct drm_client_funcs msm_fbdev_client_funcs = {
220-
.owner = THIS_MODULE,
221-
.unregister = msm_fbdev_client_unregister,
222-
.restore = msm_fbdev_client_restore,
223-
.hotplug = msm_fbdev_client_hotplug,
224-
};
225-
226-
/* initialize fbdev helper */
227-
void msm_fbdev_setup(struct drm_device *dev)
228-
{
229-
struct drm_fb_helper *helper;
230-
int ret;
231-
232-
if (!fbdev)
233-
return;
234-
235-
drm_WARN(dev, !dev->registered, "Device has not been registered.\n");
236-
drm_WARN(dev, dev->fb_helper, "fb_helper is already set!\n");
237-
238-
helper = kzalloc(sizeof(*helper), GFP_KERNEL);
239-
if (!helper)
240-
return;
241-
drm_fb_helper_prepare(dev, helper, 32, &msm_fb_helper_funcs);
242-
243-
ret = drm_client_init(dev, &helper->client, "fbdev", &msm_fbdev_client_funcs);
244-
if (ret) {
245-
drm_err(dev, "Failed to register client: %d\n", ret);
246-
goto err_drm_fb_helper_unprepare;
247-
}
248-
249-
drm_client_register(&helper->client);
250-
251-
return;
252-
253-
err_drm_fb_helper_unprepare:
254-
drm_fb_helper_unprepare(helper);
255-
kfree(helper);
256-
}

0 commit comments

Comments
 (0)