diff options
Diffstat (limited to 'drivers/gpu/drm/exynos/exynos_drm_fbdev.c')
| -rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_fbdev.c | 70 |
1 files changed, 4 insertions, 66 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c index d7ae29d2f3d6..3508700e529b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fbdev.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fbdev.c | |||
| @@ -195,66 +195,6 @@ out: | |||
| 195 | return ret; | 195 | return ret; |
| 196 | } | 196 | } |
| 197 | 197 | ||
| 198 | static bool | ||
| 199 | exynos_drm_fbdev_is_samefb(struct drm_framebuffer *fb, | ||
| 200 | struct drm_fb_helper_surface_size *sizes) | ||
| 201 | { | ||
| 202 | if (fb->width != sizes->surface_width) | ||
| 203 | return false; | ||
| 204 | if (fb->height != sizes->surface_height) | ||
| 205 | return false; | ||
| 206 | if (fb->bits_per_pixel != sizes->surface_bpp) | ||
| 207 | return false; | ||
| 208 | if (fb->depth != sizes->surface_depth) | ||
| 209 | return false; | ||
| 210 | |||
| 211 | return true; | ||
| 212 | } | ||
| 213 | |||
| 214 | static int exynos_drm_fbdev_recreate(struct drm_fb_helper *helper, | ||
| 215 | struct drm_fb_helper_surface_size *sizes) | ||
| 216 | { | ||
| 217 | struct drm_device *dev = helper->dev; | ||
| 218 | struct exynos_drm_fbdev *exynos_fbdev = to_exynos_fbdev(helper); | ||
| 219 | struct exynos_drm_gem_obj *exynos_gem_obj; | ||
| 220 | struct drm_framebuffer *fb = helper->fb; | ||
| 221 | struct drm_mode_fb_cmd2 mode_cmd = { 0 }; | ||
| 222 | unsigned long size; | ||
| 223 | |||
| 224 | DRM_DEBUG_KMS("%s\n", __FILE__); | ||
| 225 | |||
| 226 | if (exynos_drm_fbdev_is_samefb(fb, sizes)) | ||
| 227 | return 0; | ||
| 228 | |||
| 229 | mode_cmd.width = sizes->surface_width; | ||
| 230 | mode_cmd.height = sizes->surface_height; | ||
| 231 | mode_cmd.pitches[0] = sizes->surface_width * (sizes->surface_bpp >> 3); | ||
| 232 | mode_cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, | ||
| 233 | sizes->surface_depth); | ||
| 234 | |||
| 235 | if (exynos_fbdev->exynos_gem_obj) | ||
| 236 | exynos_drm_gem_destroy(exynos_fbdev->exynos_gem_obj); | ||
| 237 | |||
| 238 | if (fb->funcs->destroy) | ||
| 239 | fb->funcs->destroy(fb); | ||
| 240 | |||
| 241 | size = mode_cmd.pitches[0] * mode_cmd.height; | ||
| 242 | exynos_gem_obj = exynos_drm_gem_create(dev, size); | ||
| 243 | if (IS_ERR(exynos_gem_obj)) | ||
| 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); | ||
| 253 | } | ||
| 254 | |||
| 255 | return exynos_drm_fbdev_update(helper, helper->fb); | ||
| 256 | } | ||
| 257 | |||
| 258 | static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper, | 198 | static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper, |
| 259 | struct drm_fb_helper_surface_size *sizes) | 199 | struct drm_fb_helper_surface_size *sizes) |
| 260 | { | 200 | { |
| @@ -262,6 +202,10 @@ static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper, | |||
| 262 | 202 | ||
| 263 | DRM_DEBUG_KMS("%s\n", __FILE__); | 203 | DRM_DEBUG_KMS("%s\n", __FILE__); |
| 264 | 204 | ||
| 205 | /* | ||
| 206 | * with !helper->fb, it means that this funcion is called first time | ||
| 207 | * and after that, the helper->fb would be used as clone mode. | ||
| 208 | */ | ||
| 265 | if (!helper->fb) { | 209 | if (!helper->fb) { |
| 266 | ret = exynos_drm_fbdev_create(helper, sizes); | 210 | ret = exynos_drm_fbdev_create(helper, sizes); |
| 267 | if (ret < 0) { | 211 | if (ret < 0) { |
| @@ -274,12 +218,6 @@ static int exynos_drm_fbdev_probe(struct drm_fb_helper *helper, | |||
| 274 | * because register_framebuffer() should be called. | 218 | * because register_framebuffer() should be called. |
| 275 | */ | 219 | */ |
| 276 | ret = 1; | 220 | ret = 1; |
| 277 | } else { | ||
| 278 | ret = exynos_drm_fbdev_recreate(helper, sizes); | ||
| 279 | if (ret < 0) { | ||
| 280 | DRM_ERROR("failed to reconfigure fbdev\n"); | ||
| 281 | return ret; | ||
| 282 | } | ||
| 283 | } | 221 | } |
| 284 | 222 | ||
| 285 | return ret; | 223 | return ret; |
