diff options
author | Joonyoung Shim <jy0922.shim@samsung.com> | 2011-12-13 00:46:57 -0500 |
---|---|---|
committer | Inki Dae <inki.dae@samsung.com> | 2011-12-28 21:21:41 -0500 |
commit | e1533c086fc882474fb339953082072bec8c4e71 (patch) | |
tree | 2881b0bea84ab83258bbb4b2ade5e2d4c8b9da3b /drivers/gpu/drm/exynos/exynos_drm_fbdev.c | |
parent | 2364839a1aca677842b0dfd7ed0449acda3c3175 (diff) |
drm/exynos: remove buffer creation of fbdev from drm framebuffer creation
The fbdev fb and the user fb is created from same function -
exynos_drm_fb_create, but this function creates not only drm framebuffer
but buffer of fbdev. Remove it because it complicates codes and use
exynos_drm_gem_create() than exynos_drm_buf_create() to create buffer of
fbdev, it give better consistency of codes and more clear
implementation.
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
Signed-off-by: Inki Dae <inki.dae@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_drm_fbdev.c')
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 62 |
1 files changed, 41 insertions, 21 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index c8b278447c4f..26992d3e970f 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c | |||
@@ -43,8 +43,8 @@ | |||
43 | drm_fb_helper) | 43 | drm_fb_helper) |
44 | 44 | ||
45 | struct exynos_drm_fbdev { | 45 | struct exynos_drm_fbdev { |
46 | struct drm_fb_helper drm_fb_helper; | 46 | struct drm_fb_helper drm_fb_helper; |
47 | struct drm_framebuffer *fb; | 47 | struct exynos_drm_gem_obj *exynos_gem_obj; |
48 | }; | 48 | }; |
49 | 49 | ||
50 | static int exynos_drm_fbdev_set_par(struct fb_info *info) | 50 | static int exynos_drm_fbdev_set_par(struct fb_info *info) |
@@ -90,15 +90,12 @@ static int exynos_drm_fbdev_update(struct drm_fb_helper *helper, | |||
90 | { | 90 | { |
91 | struct fb_info *fbi = helper->fbdev; | 91 | struct fb_info *fbi = helper->fbdev; |
92 | struct drm_device *dev = helper->dev; | 92 | struct drm_device *dev = helper->dev; |
93 | struct exynos_drm_fbdev *exynos_fb = to_exynos_fbdev(helper); | ||
94 | struct exynos_drm_gem_buf *buffer; | 93 | struct exynos_drm_gem_buf *buffer; |
95 | unsigned int size = fb->width * fb->height * (fb->bits_per_pixel >> 3); | 94 | unsigned int size = fb->width * fb->height * (fb->bits_per_pixel >> 3); |
96 | unsigned long offset; | 95 | unsigned long offset; |
97 | 96 | ||
98 | DRM_DEBUG_KMS("%s\n", __FILE__); | 97 | DRM_DEBUG_KMS("%s\n", __FILE__); |
99 | 98 | ||
100 | exynos_fb->fb = fb; | ||
101 | |||
102 | drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); | 99 | drm_fb_helper_fill_fix(fbi, fb->pitches[0], fb->depth); |
103 | drm_fb_helper_fill_var(fbi, helper, fb->width, fb->height); | 100 | drm_fb_helper_fill_var(fbi, helper, fb->width, fb->height); |
104 | 101 | ||
@@ -124,10 +121,12 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, | |||
124 | struct drm_fb_helper_surface_size *sizes) | 121 | struct drm_fb_helper_surface_size *sizes) |
125 | { | 122 | { |
126 | struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); | 123 | struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); |
124 | struct exynos_drm_gem_obj *exynos_gem_obj; | ||
127 | struct drm_device *dev = helper->dev; | 125 | struct drm_device *dev = helper->dev; |
128 | struct fb_info *fbi; | 126 | struct fb_info *fbi; |
129 | struct drm_mode_fb_cmd2 mode_cmd = { 0 }; | 127 | struct drm_mode_fb_cmd2 mode_cmd = { 0 }; |
130 | struct platform_device *pdev = dev->platformdev; | 128 | struct platform_device *pdev = dev->platformdev; |
129 | unsigned long size; | ||
131 | int ret; | 130 | int ret; |
132 | 131 | ||
133 | DRM_DEBUG_KMS("%s\n", __FILE__); | 132 | DRM_DEBUG_KMS("%s\n", __FILE__); |
@@ -151,14 +150,23 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, | |||
151 | goto out; | 150 | goto out; |
152 | } | 151 | } |
153 | 152 | ||
154 | exynos_fbdev->fb = exynos_drm_fb_create(dev, NULL, &mode_cmd); | 153 | size = mode_cmd.pitches[0] * mode_cmd.height; |
155 | if (IS_ERR_OR_NULL(exynos_fbdev->fb)) { | 154 | exynos_gem_obj = exynos_drm_gem_create(dev, size); |
155 | if (IS_ERR(exynos_gem_obj)) { | ||
156 | ret = PTR_ERR(exynos_gem_obj); | ||
157 | goto out; | ||
158 | } | ||
159 | |||
160 | exynos_fbdev->exynos_gem_obj = exynos_gem_obj; | ||
161 | |||
162 | helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd, | ||
163 | &exynos_gem_obj->base); | ||
164 | if (IS_ERR_OR_NULL(helper->fb)) { | ||
156 | DRM_ERROR("failed to create drm framebuffer.\n"); | 165 | DRM_ERROR("failed to create drm framebuffer.\n"); |
157 | ret = PTR_ERR(exynos_fbdev->fb); | 166 | ret = PTR_ERR(helper->fb); |
158 | goto out; | 167 | goto out; |
159 | } | 168 | } |
160 | 169 | ||
161 | helper->fb = exynos_fbdev->fb; | ||
162 | helper->fbdev = fbi; | 170 | helper->fbdev = fbi; |
163 | 171 | ||
164 | fbi->par = helper; | 172 | fbi->par = helper; |
@@ -172,8 +180,10 @@ static int exynos_drm_fbdev_create(struct drm_fb_helper *helper, | |||
172 | } | 180 | } |
173 | 181 | ||
174 | ret = exynos_drm_fbdev_update(helper, helper->fb); | 182 | ret = exynos_drm_fbdev_update(helper, helper->fb); |
175 | if (ret < 0) | 183 | if (ret < 0) { |
176 | fb_dealloc_cmap(&fbi->cmap); | 184 | fb_dealloc_cmap(&fbi->cmap); |
185 | goto out; | ||
186 | } | ||
177 | 187 | ||
178 | /* | 188 | /* |
179 | * if failed, all resources allocated above would be released by | 189 | * if failed, all resources allocated above would be released by |
@@ -206,16 +216,13 @@ static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper, | |||
206 | { | 216 | { |
207 | struct drm_device *dev = helper->dev; | 217 | struct drm_device *dev = helper->dev; |
208 | struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); | 218 | struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); |
209 | struct drm_framebuffer *fb = exynos_fbdev->fb; | 219 | struct exynos_drm_gem_obj *exynos_gem_obj; |
220 | struct drm_framebuffer *fb = helper->fb; | ||
210 | struct drm_mode_fb_cmd2 mode_cmd = { 0 }; | 221 | struct drm_mode_fb_cmd2 mode_cmd = { 0 }; |
222 | unsigned long size; | ||
211 | 223 | ||
212 | DRM_DEBUG_KMS("%s\n", __FILE__); | 224 | DRM_DEBUG_KMS("%s\n", __FILE__); |
213 | 225 | ||
214 | if (helper->fb != fb) { | ||
215 | DRM_ERROR("drm framebuffer is different\n"); | ||
216 | return -EINVAL; | ||
217 | } | ||
218 | |||
219 | if (exynos_drm_fbdev_is_samefb(fb, sizes)) | 226 | if (exynos_drm_fbdev_is_samefb(fb, sizes)) |
220 | return 0; | 227 | return 0; |
221 | 228 | ||
@@ -225,16 +232,26 @@ static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper, | |||
225 | mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, | 232 | mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, |
226 | sizes->surface_depth); | 233 | sizes->surface_depth); |
227 | 234 | ||
235 | if (exynos_fbdev->exynos_gem_obj) | ||
236 | exynos_drm_gem_destroy(exynos_fbdev->exynos_gem_obj); | ||
237 | |||
228 | if (fb->funcs->destroy) | 238 | if (fb->funcs->destroy) |
229 | fb->funcs->destroy(fb); | 239 | fb->funcs->destroy(fb); |
230 | 240 | ||
231 | exynos_fbdev->fb = exynos_drm_fb_create(dev, NULL, &mode_cmd); | 241 | size = mode_cmd.pitches[0] * mode_cmd.height; |
232 | if (IS_ERR(exynos_fbdev->fb)) { | 242 | exynos_gem_obj = exynos_drm_gem_create(dev, size); |
233 | DRM_ERROR("failed to allocate fb.\n"); | 243 | if (IS_ERR(exynos_gem_obj)) |
234 | return PTR_ERR(exynos_fbdev->fb); | 244 | return PTR_ERR(exynos_gem_obj); |
245 | |||
246 | exynos_fbdev->exynos_gem_obj = exynos_gem_obj; | ||
247 | |||
248 | helper->fb = exynos_drm_framebuffer_init(dev, &mode_cmd, | ||
249 | &exynos_gem_obj->base); | ||
250 | if (IS_ERR_OR_NULL(helper->fb)) { | ||
251 | DRM_ERROR("failed to create drm framebuffer.\n"); | ||
252 | return PTR_ERR(helper->fb); | ||
235 | } | 253 | } |
236 | 254 | ||
237 | helper->fb = exynos_fbdev->fb; | ||
238 | return exynos_drm_fbdev_update(helper, helper->fb); | 255 | return exynos_drm_fbdev_update(helper, helper->fb); |
239 | } | 256 | } |
240 | 257 | ||
@@ -368,6 +385,9 @@ void exynos_drm_fbdev_fini(struct drm_device *dev) | |||
368 | 385 | ||
369 | fbdev = to_exynos_fbdev(private->fb_helper); | 386 | fbdev = to_exynos_fbdev(private->fb_helper); |
370 | 387 | ||
388 | if (fbdev->exynos_gem_obj) | ||
389 | exynos_drm_gem_destroy(fbdev->exynos_gem_obj); | ||
390 | |||
371 | exynos_drm_fbdev_destroy(dev, private->fb_helper); | 391 | exynos_drm_fbdev_destroy(dev, private->fb_helper); |
372 | kfree(fbdev); | 392 | kfree(fbdev); |
373 | private->fb_helper = NULL; | 393 | private->fb_helper = NULL; |