Skip to content

Commit 25998ed

Browse files
Thomas Zimmermanngregkh
authored andcommitted
drm/fbdev-dma: Support struct drm_driver.fbdev_probe
commit 8998eed upstream. Rework fbdev probing to support fbdev_probe in struct drm_driver and reimplement the old fb_probe callback on top of it. Provide an initializer macro for struct drm_driver that sets the callback according to the kernel configuration. This change allows the common fbdev client to run on top of DMA- based DRM drivers. Signed-off-by: Thomas Zimmermann <[email protected]> Reviewed-by: Javier Martinez Canillas <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Fabio Estevam <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d22496d commit 25998ed

File tree

2 files changed

+48
-24
lines changed

2 files changed

+48
-24
lines changed

drivers/gpu/drm/drm_fbdev_dma.c

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,40 @@ static const struct fb_ops drm_fbdev_dma_deferred_fb_ops = {
105105

106106
static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper,
107107
struct drm_fb_helper_surface_size *sizes)
108+
{
109+
return drm_fbdev_dma_driver_fbdev_probe(fb_helper, sizes);
110+
}
111+
112+
static int drm_fbdev_dma_helper_fb_dirty(struct drm_fb_helper *helper,
113+
struct drm_clip_rect *clip)
114+
{
115+
struct drm_device *dev = helper->dev;
116+
int ret;
117+
118+
/* Call damage handlers only if necessary */
119+
if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
120+
return 0;
121+
122+
if (helper->fb->funcs->dirty) {
123+
ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
124+
if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
125+
return ret;
126+
}
127+
128+
return 0;
129+
}
130+
131+
static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
132+
.fb_probe = drm_fbdev_dma_helper_fb_probe,
133+
.fb_dirty = drm_fbdev_dma_helper_fb_dirty,
134+
};
135+
136+
/*
137+
* struct drm_fb_helper
138+
*/
139+
140+
int drm_fbdev_dma_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
141+
struct drm_fb_helper_surface_size *sizes)
108142
{
109143
struct drm_client_dev *client = &fb_helper->client;
110144
struct drm_device *dev = fb_helper->dev;
@@ -148,6 +182,7 @@ static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper,
148182
goto err_drm_client_buffer_delete;
149183
}
150184

185+
fb_helper->funcs = &drm_fbdev_dma_helper_funcs;
151186
fb_helper->buffer = buffer;
152187
fb_helper->fb = fb;
153188

@@ -211,30 +246,7 @@ static int drm_fbdev_dma_helper_fb_probe(struct drm_fb_helper *fb_helper,
211246
drm_client_framebuffer_delete(buffer);
212247
return ret;
213248
}
214-
215-
static int drm_fbdev_dma_helper_fb_dirty(struct drm_fb_helper *helper,
216-
struct drm_clip_rect *clip)
217-
{
218-
struct drm_device *dev = helper->dev;
219-
int ret;
220-
221-
/* Call damage handlers only if necessary */
222-
if (!(clip->x1 < clip->x2 && clip->y1 < clip->y2))
223-
return 0;
224-
225-
if (helper->fb->funcs->dirty) {
226-
ret = helper->fb->funcs->dirty(helper->fb, NULL, 0, 0, clip, 1);
227-
if (drm_WARN_ONCE(dev, ret, "Dirty helper failed: ret=%d\n", ret))
228-
return ret;
229-
}
230-
231-
return 0;
232-
}
233-
234-
static const struct drm_fb_helper_funcs drm_fbdev_dma_helper_funcs = {
235-
.fb_probe = drm_fbdev_dma_helper_fb_probe,
236-
.fb_dirty = drm_fbdev_dma_helper_fb_dirty,
237-
};
249+
EXPORT_SYMBOL(drm_fbdev_dma_driver_fbdev_probe);
238250

239251
/*
240252
* struct drm_client_funcs

include/drm/drm_fbdev_dma.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,24 @@
44
#define DRM_FBDEV_DMA_H
55

66
struct drm_device;
7+
struct drm_fb_helper;
8+
struct drm_fb_helper_surface_size;
79

810
#ifdef CONFIG_DRM_FBDEV_EMULATION
11+
int drm_fbdev_dma_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
12+
struct drm_fb_helper_surface_size *sizes);
13+
14+
#define DRM_FBDEV_DMA_DRIVER_OPS \
15+
.fbdev_probe = drm_fbdev_dma_driver_fbdev_probe
16+
917
void drm_fbdev_dma_setup(struct drm_device *dev, unsigned int preferred_bpp);
1018
#else
1119
static inline void drm_fbdev_dma_setup(struct drm_device *dev, unsigned int preferred_bpp)
1220
{ }
21+
22+
#define DRM_FBDEV_DMA_DRIVER_OPS \
23+
.fbdev_probe = NULL
24+
1325
#endif
1426

1527
#endif

0 commit comments

Comments
 (0)