History

drm/sun4i: 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.

Noralf Trønnes committed 8 years ago

Commit 94ebfc01 parent da6a5123 files · +5 −22Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t