Skip to content

Commit 41d48e5

Browse files
author
Thomas Zimmermann
committed
drm/radeon: 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 radeon driver specifies a preferred color mode depending on the available video memory, with a default of 32. Adapt this for the new client interface. v5: - select DRM_CLIENT_SELECTION v2: - style changes Signed-off-by: Thomas Zimmermann <[email protected]> Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Cc: Xinhui Pan <[email protected]> Acked-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent fe96a73 commit 41d48e5

File tree

4 files changed

+28
-113
lines changed

4 files changed

+28
-113
lines changed

drivers/gpu/drm/radeon/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ config DRM_RADEON
55
depends on DRM && PCI && MMU
66
depends on AGP || !AGP
77
select FW_LOADER
8+
select DRM_CLIENT_SELECTION
89
select DRM_DISPLAY_DP_HELPER
910
select DRM_DISPLAY_HELPER
1011
select DRM_KMS_HELPER

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
#include <linux/pci.h>
3939

4040
#include <drm/drm_aperture.h>
41+
#include <drm/drm_client_setup.h>
4142
#include <drm/drm_drv.h>
4243
#include <drm/drm_file.h>
44+
#include <drm/drm_fourcc.h>
4345
#include <drm/drm_gem.h>
4446
#include <drm/drm_ioctl.h>
4547
#include <drm/drm_pciids.h>
@@ -261,6 +263,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
261263
unsigned long flags = 0;
262264
struct drm_device *ddev;
263265
struct radeon_device *rdev;
266+
const struct drm_format_info *format;
264267
int ret;
265268

266269
if (!ent)
@@ -324,7 +327,14 @@ static int radeon_pci_probe(struct pci_dev *pdev,
324327
if (ret)
325328
goto err_agp;
326329

327-
radeon_fbdev_setup(ddev->dev_private);
330+
if (rdev->mc.real_vram_size <= (8 * 1024 * 1024))
331+
format = drm_format_info(DRM_FORMAT_C8);
332+
else if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32 * 1024 * 1024))
333+
format = drm_format_info(DRM_FORMAT_RGB565);
334+
else
335+
format = NULL;
336+
337+
drm_client_setup(ddev, format);
328338

329339
return 0;
330340

@@ -590,6 +600,8 @@ static const struct drm_driver kms_driver = {
590600

591601
.gem_prime_import_sg_table = radeon_gem_prime_import_sg_table,
592602

603+
RADEON_FBDEV_DRIVER_OPS,
604+
593605
.name = DRIVER_NAME,
594606
.desc = DRIVER_DESC,
595607
.date = DRIVER_DATE,

drivers/gpu/drm/radeon/radeon_fbdev.c

Lines changed: 5 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,11 @@ static const struct fb_ops radeon_fbdev_fb_ops = {
198198
.fb_destroy = radeon_fbdev_fb_destroy,
199199
};
200200

201-
/*
202-
* Fbdev helpers and struct drm_fb_helper_funcs
203-
*/
201+
static const struct drm_fb_helper_funcs radeon_fbdev_fb_helper_funcs = {
202+
};
204203

205-
static int radeon_fbdev_fb_helper_fb_probe(struct drm_fb_helper *fb_helper,
206-
struct drm_fb_helper_surface_size *sizes)
204+
int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
205+
struct drm_fb_helper_surface_size *sizes)
207206
{
208207
struct radeon_device *rdev = fb_helper->dev->dev_private;
209208
struct drm_mode_fb_cmd2 mode_cmd = { };
@@ -243,6 +242,7 @@ static int radeon_fbdev_fb_helper_fb_probe(struct drm_fb_helper *fb_helper,
243242
}
244243

245244
/* setup helper */
245+
fb_helper->funcs = &radeon_fbdev_fb_helper_funcs;
246246
fb_helper->fb = fb;
247247

248248
/* okay we have an object now allocate the framebuffer */
@@ -288,110 +288,6 @@ static int radeon_fbdev_fb_helper_fb_probe(struct drm_fb_helper *fb_helper,
288288
return ret;
289289
}
290290

291-
static const struct drm_fb_helper_funcs radeon_fbdev_fb_helper_funcs = {
292-
.fb_probe = radeon_fbdev_fb_helper_fb_probe,
293-
};
294-
295-
/*
296-
* Fbdev client and struct drm_client_funcs
297-
*/
298-
299-
static void radeon_fbdev_client_unregister(struct drm_client_dev *client)
300-
{
301-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
302-
struct drm_device *dev = fb_helper->dev;
303-
struct radeon_device *rdev = dev->dev_private;
304-
305-
if (fb_helper->info) {
306-
vga_switcheroo_client_fb_set(rdev->pdev, NULL);
307-
drm_helper_force_disable_all(dev);
308-
drm_fb_helper_unregister_info(fb_helper);
309-
} else {
310-
drm_client_release(&fb_helper->client);
311-
drm_fb_helper_unprepare(fb_helper);
312-
kfree(fb_helper);
313-
}
314-
}
315-
316-
static int radeon_fbdev_client_restore(struct drm_client_dev *client)
317-
{
318-
drm_fb_helper_lastclose(client->dev);
319-
vga_switcheroo_process_delayed_switch();
320-
321-
return 0;
322-
}
323-
324-
static int radeon_fbdev_client_hotplug(struct drm_client_dev *client)
325-
{
326-
struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
327-
struct drm_device *dev = client->dev;
328-
struct radeon_device *rdev = dev->dev_private;
329-
int ret;
330-
331-
if (dev->fb_helper)
332-
return drm_fb_helper_hotplug_event(dev->fb_helper);
333-
334-
ret = drm_fb_helper_init(dev, fb_helper);
335-
if (ret)
336-
goto err_drm_err;
337-
338-
if (!drm_drv_uses_atomic_modeset(dev))
339-
drm_helper_disable_unused_functions(dev);
340-
341-
ret = drm_fb_helper_initial_config(fb_helper);
342-
if (ret)
343-
goto err_drm_fb_helper_fini;
344-
345-
vga_switcheroo_client_fb_set(rdev->pdev, fb_helper->info);
346-
347-
return 0;
348-
349-
err_drm_fb_helper_fini:
350-
drm_fb_helper_fini(fb_helper);
351-
err_drm_err:
352-
drm_err(dev, "Failed to setup radeon fbdev emulation (ret=%d)\n", ret);
353-
return ret;
354-
}
355-
356-
static const struct drm_client_funcs radeon_fbdev_client_funcs = {
357-
.owner = THIS_MODULE,
358-
.unregister = radeon_fbdev_client_unregister,
359-
.restore = radeon_fbdev_client_restore,
360-
.hotplug = radeon_fbdev_client_hotplug,
361-
};
362-
363-
void radeon_fbdev_setup(struct radeon_device *rdev)
364-
{
365-
struct drm_fb_helper *fb_helper;
366-
int bpp_sel = 32;
367-
int ret;
368-
369-
if (rdev->mc.real_vram_size <= (8 * 1024 * 1024))
370-
bpp_sel = 8;
371-
else if (ASIC_IS_RN50(rdev) || rdev->mc.real_vram_size <= (32 * 1024 * 1024))
372-
bpp_sel = 16;
373-
374-
fb_helper = kzalloc(sizeof(*fb_helper), GFP_KERNEL);
375-
if (!fb_helper)
376-
return;
377-
drm_fb_helper_prepare(rdev_to_drm(rdev), fb_helper, bpp_sel, &radeon_fbdev_fb_helper_funcs);
378-
379-
ret = drm_client_init(rdev_to_drm(rdev), &fb_helper->client, "radeon-fbdev",
380-
&radeon_fbdev_client_funcs);
381-
if (ret) {
382-
drm_err(rdev_to_drm(rdev), "Failed to register client: %d\n", ret);
383-
goto err_drm_client_init;
384-
}
385-
386-
drm_client_register(&fb_helper->client);
387-
388-
return;
389-
390-
err_drm_client_init:
391-
drm_fb_helper_unprepare(fb_helper);
392-
kfree(fb_helper);
393-
}
394-
395291
void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state)
396292
{
397293
if (rdev_to_drm(rdev)->fb_helper)

drivers/gpu/drm/radeon/radeon_mode.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@
3838
#include <linux/i2c.h>
3939
#include <linux/i2c-algo-bit.h>
4040

41+
struct drm_fb_helper;
42+
struct drm_fb_helper_surface_size;
43+
4144
struct edid;
4245
struct drm_edid;
4346
struct radeon_bo;
@@ -935,12 +938,15 @@ void dce8_program_fmt(struct drm_encoder *encoder);
935938

936939
/* fbdev layer */
937940
#if defined(CONFIG_DRM_FBDEV_EMULATION)
938-
void radeon_fbdev_setup(struct radeon_device *rdev);
941+
int radeon_fbdev_driver_fbdev_probe(struct drm_fb_helper *fb_helper,
942+
struct drm_fb_helper_surface_size *sizes);
943+
#define RADEON_FBDEV_DRIVER_OPS \
944+
.fbdev_probe = radeon_fbdev_driver_fbdev_probe
939945
void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state);
940946
bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj);
941947
#else
942-
static inline void radeon_fbdev_setup(struct radeon_device *rdev)
943-
{ }
948+
#define RADEON_FBDEV_DRIVER_OPS \
949+
.fbdev_probe = NULL
944950
static inline void radeon_fbdev_set_suspend(struct radeon_device *rdev, int state)
945951
{ }
946952
static inline bool radeon_fbdev_robj_is_fb(struct radeon_device *rdev, struct radeon_bo *robj)

0 commit comments

Comments
 (0)