Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/arc: Use drm_fbdev_generic_setup()

The CMA helper is already using the drm_fb_helper_generic_probe part of
the generic fbdev emulation. This patch makes full use of the generic
fbdev emulation by using its drm_client callbacks. This means that
drm_mode_config_funcs->output_poll_changed and drm_driver->lastclose are
now handled by the emulation code. Additionally fbdev unregister happens
automatically on drm_dev_unregister().

The drm_fbdev_generic_setup() call is put after drm_dev_register() in the
driver. This is done to highlight the fact that fbdev emulation is an
internal client that makes use of the driver, it is not part of the
driver as such. If fbdev setup fails, an error is printed, but the driver
succeeds probing.

Cc: Alexey Brodkin <abrodkin@synopsys.com>
Signed-off-by: Noralf Trønnes <noralf@tronnes.org>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Alexey Brodkin <abrodkin@synopsys.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181025201340.34227-2-noralf@tronnes.org

+3 -34
-4
drivers/gpu/drm/arc/arcpgu.h
··· 20 20 struct arcpgu_drm_private { 21 21 void __iomem *regs; 22 22 struct clk *clk; 23 - struct drm_fbdev_cma *fbdev; 24 23 struct drm_framebuffer *fb; 25 24 struct drm_crtc crtc; 26 25 struct drm_plane *plane; ··· 42 43 int arc_pgu_setup_crtc(struct drm_device *dev); 43 44 int arcpgu_drm_hdmi_init(struct drm_device *drm, struct device_node *np); 44 45 int arcpgu_drm_sim_init(struct drm_device *drm, struct device_node *np); 45 - struct drm_fbdev_cma *arcpgu_fbdev_cma_init(struct drm_device *dev, 46 - unsigned int preferred_bpp, unsigned int num_crtc, 47 - unsigned int max_conn_count); 48 46 49 47 #endif
+3 -30
drivers/gpu/drm/arc/arcpgu_drv.c
··· 17 17 #include <linux/clk.h> 18 18 #include <drm/drm_crtc_helper.h> 19 19 #include <drm/drm_fb_cma_helper.h> 20 + #include <drm/drm_fb_helper.h> 20 21 #include <drm/drm_gem_cma_helper.h> 21 22 #include <drm/drm_gem_framebuffer_helper.h> 22 23 #include <drm/drm_atomic_helper.h> ··· 26 25 #include "arcpgu.h" 27 26 #include "arcpgu_regs.h" 28 27 29 - static void arcpgu_fb_output_poll_changed(struct drm_device *dev) 30 - { 31 - struct arcpgu_drm_private *arcpgu = dev->dev_private; 32 - 33 - drm_fbdev_cma_hotplug_event(arcpgu->fbdev); 34 - } 35 - 36 28 static const struct drm_mode_config_funcs arcpgu_drm_modecfg_funcs = { 37 29 .fb_create = drm_gem_fb_create, 38 - .output_poll_changed = arcpgu_fb_output_poll_changed, 39 30 .atomic_check = drm_atomic_helper_check, 40 31 .atomic_commit = drm_atomic_helper_commit, 41 32 }; ··· 43 50 } 44 51 45 52 DEFINE_DRM_GEM_CMA_FOPS(arcpgu_drm_ops); 46 - 47 - static void arcpgu_lastclose(struct drm_device *drm) 48 - { 49 - struct arcpgu_drm_private *arcpgu = drm->dev_private; 50 - 51 - drm_fbdev_cma_restore_mode(arcpgu->fbdev); 52 - } 53 53 54 54 static int arcpgu_load(struct drm_device *drm) 55 55 { ··· 99 113 drm_mode_config_reset(drm); 100 114 drm_kms_helper_poll_init(drm); 101 115 102 - arcpgu->fbdev = drm_fbdev_cma_init(drm, 16, 103 - drm->mode_config.num_connector); 104 - if (IS_ERR(arcpgu->fbdev)) { 105 - ret = PTR_ERR(arcpgu->fbdev); 106 - arcpgu->fbdev = NULL; 107 - return -ENODEV; 108 - } 109 - 110 116 platform_set_drvdata(pdev, drm); 111 117 return 0; 112 118 } 113 119 114 120 static int arcpgu_unload(struct drm_device *drm) 115 121 { 116 - struct arcpgu_drm_private *arcpgu = drm->dev_private; 117 - 118 - if (arcpgu->fbdev) { 119 - drm_fbdev_cma_fini(arcpgu->fbdev); 120 - arcpgu->fbdev = NULL; 121 - } 122 122 drm_kms_helper_poll_fini(drm); 123 123 drm_atomic_helper_shutdown(drm); 124 124 drm_mode_config_cleanup(drm); ··· 140 168 static struct drm_driver arcpgu_drm_driver = { 141 169 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME | 142 170 DRIVER_ATOMIC, 143 - .lastclose = arcpgu_lastclose, 144 171 .name = "arcpgu", 145 172 .desc = "ARC PGU Controller", 146 173 .date = "20160219", ··· 181 210 ret = drm_dev_register(drm, 0); 182 211 if (ret) 183 212 goto err_unload; 213 + 214 + drm_fbdev_generic_setup(drm, 16); 184 215 185 216 return 0; 186 217