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.
Unified · Split
| @@ -34,7 +34,6 @@ static struct drm_driver sun4i_drv_driver = { · 33 unmodified lines | ||
| 34 | 34 | .driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_PRIME | DRIVER_ATOMIC, |
| 35 | 35 | |
| 36 | 36 | /* Generic Operations */ |
| 37 | − .lastclose = drm_fb_helper_lastclose, | |
| 38 | 37 | .fops = &sun4i_drv_fops, |
| 39 | 38 | .name = "sun4i-drm", |
| 40 | 39 | .desc = "Allwinner sun4i Display Engine", |
| @@ -105,12 +104,7 @@ static int sun4i_drv_bind(struct device *dev) · 64 unmodified lines | ||
| 105 | 104 | /* Remove early framebuffers (ie. simplefb) */ |
| 106 | 105 | drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false); |
| 107 | 106 | |
| 108 | − /* Create our framebuffer */ | |
| 109 | − ret = sun4i_framebuffer_init(drm); | |
| 110 | − if (ret) { | |
| 111 | − dev_err(drm->dev, "Couldn't create our framebuffer\n"); | |
| 112 | − goto cleanup_mode_config; | |
| 113 | − } | |
| 107 | + sun4i_framebuffer_init(drm); | |
| 114 | 108 | |
| 115 | 109 | /* Enable connectors polling */ |
| 116 | 110 | drm_kms_helper_poll_init(drm); |
| @@ -119,11 +113,12 @@ static int sun4i_drv_bind(struct device *dev) · 2 unmodified lines | ||
| 119 | 113 | if (ret) |
| 120 | 114 | goto finish_poll; |
| 121 | 115 | |
| 116 | + drm_fbdev_generic_setup(drm, 32); | |
| 117 | + | |
| 122 | 118 | return 0; |
| 123 | 119 | |
| 124 | 120 | finish_poll: |
| 125 | 121 | drm_kms_helper_poll_fini(drm); |
| 126 | − sun4i_framebuffer_free(drm); | |
| 127 | 122 | cleanup_mode_config: |
| 128 | 123 | drm_mode_config_cleanup(drm); |
| 129 | 124 | of_reserved_mem_device_release(dev); |
| @@ -138,7 +133,6 @@ static void sun4i_drv_unbind(struct device *dev) · 8 unmodified lines | ||
| 138 | 133 | |
| 139 | 134 | drm_dev_unregister(drm); |
| 140 | 135 | drm_kms_helper_poll_fini(drm); |
| 141 | − sun4i_framebuffer_free(drm); | |
| 142 | 136 | drm_mode_config_cleanup(drm); |
| 143 | 137 | of_reserved_mem_device_release(dev); |
| 144 | 138 | drm_dev_put(drm); |
| @@ -12,8 +12,6 @@ · 11 unmodified lines | ||
| 12 | 12 | |
| 13 | 13 | #include <drm/drm_atomic.h> |
| 14 | 14 | #include <drm/drm_atomic_helper.h> |
| 15 | −#include <drm/drm_fb_helper.h> | |
| 16 | −#include <drm/drm_fb_cma_helper.h> | |
| 17 | 15 | #include <drm/drm_gem_framebuffer_helper.h> |
| 18 | 16 | #include <drm/drmP.h> |
| 19 | 17 | |
| @@ -37,7 +35,6 @@ static int sun4i_de_atomic_check(struct drm_device *dev, · 17 unmodified lines | ||
| 37 | 35 | } |
| 38 | 36 | |
| 39 | 37 | static const struct drm_mode_config_funcs sun4i_de_mode_config_funcs = { |
| 40 | − .output_poll_changed = drm_fb_helper_output_poll_changed, | |
| 41 | 38 | .atomic_check = sun4i_de_atomic_check, |
| 42 | 39 | .atomic_commit = drm_atomic_helper_commit, |
| 43 | 40 | .fb_create = drm_gem_fb_create, |
| @@ -47,7 +44,7 @@ static struct drm_mode_config_helper_funcs sun4i_de_mode_config_helpers = { · 3 unmodified lines | ||
| 47 | 44 | .atomic_commit_tail = drm_atomic_helper_commit_tail_rpm, |
| 48 | 45 | }; |
| 49 | 46 | |
| 50 | −int sun4i_framebuffer_init(struct drm_device *drm) | |
| 47 | +void sun4i_framebuffer_init(struct drm_device *drm) | |
| 51 | 48 | { |
| 52 | 49 | drm_mode_config_reset(drm); |
| 53 | 50 | |
| @@ -56,11 +53,4 @@ int sun4i_framebuffer_init(struct drm_device *drm) · 2 unmodified lines | ||
| 56 | 53 | |
| 57 | 54 | drm->mode_config.funcs = &sun4i_de_mode_config_funcs; |
| 58 | 55 | drm->mode_config.helper_private = &sun4i_de_mode_config_helpers; |
| 59 | − | |
| 60 | − return drm_fb_cma_fbdev_init(drm, 32, 0); | |
| 61 | −} | |
| 62 | − | |
| 63 | −void sun4i_framebuffer_free(struct drm_device *drm) | |
| 64 | −{ | |
| 65 | − drm_fb_cma_fbdev_fini(drm); | |
| 66 | 56 | } |
| @@ -13,7 +13,6 @@ · 12 unmodified lines | ||
| 13 | 13 | #ifndef _SUN4I_FRAMEBUFFER_H_ |
| 14 | 14 | #define _SUN4I_FRAMEBUFFER_H_ |
| 15 | 15 | |
| 16 | −int sun4i_framebuffer_init(struct drm_device *drm); | |
| 17 | −void sun4i_framebuffer_free(struct drm_device *drm); | |
| 16 | +void sun4i_framebuffer_init(struct drm_device *drm); | |
| 18 | 17 | |
| 19 | 18 | #endif /* _SUN4I_FRAMEBUFFER_H_ */ |