Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 1 | /* |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 2 | * Copyright (C) 2012-2013 Avionic Design GmbH |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 3 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. |
| 4 | * |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 5 | * Based on the KMS/FB CMA helpers |
| 6 | * Copyright (C) 2012 Analog Device Inc. |
| 7 | * |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
| 11 | */ |
| 12 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 13 | #include "drm.h" |
| 14 | #include "gem.h" |
| 15 | |
| 16 | static inline struct tegra_fb *to_tegra_fb(struct drm_framebuffer *fb) |
| 17 | { |
| 18 | return container_of(fb, struct tegra_fb, base); |
| 19 | } |
| 20 | |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 21 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 22 | static inline struct tegra_fbdev *to_tegra_fbdev(struct drm_fb_helper *helper) |
| 23 | { |
| 24 | return container_of(helper, struct tegra_fbdev, base); |
| 25 | } |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 26 | #endif |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 27 | |
| 28 | struct tegra_bo *tegra_fb_get_plane(struct drm_framebuffer *framebuffer, |
| 29 | unsigned int index) |
| 30 | { |
| 31 | struct tegra_fb *fb = to_tegra_fb(framebuffer); |
| 32 | |
| 33 | if (index >= drm_format_num_planes(framebuffer->pixel_format)) |
| 34 | return NULL; |
| 35 | |
| 36 | return fb->planes[index]; |
| 37 | } |
| 38 | |
Thierry Reding | db7fbdf | 2013-10-07 09:47:58 +0200 | [diff] [blame] | 39 | bool tegra_fb_is_bottom_up(struct drm_framebuffer *framebuffer) |
| 40 | { |
| 41 | struct tegra_fb *fb = to_tegra_fb(framebuffer); |
| 42 | |
| 43 | if (fb->planes[0]->flags & TEGRA_BO_BOTTOM_UP) |
| 44 | return true; |
| 45 | |
| 46 | return false; |
| 47 | } |
| 48 | |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame^] | 49 | int tegra_fb_get_tiling(struct drm_framebuffer *framebuffer, |
| 50 | struct tegra_bo_tiling *tiling) |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 51 | { |
| 52 | struct tegra_fb *fb = to_tegra_fb(framebuffer); |
| 53 | |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame^] | 54 | /* TODO: handle YUV formats? */ |
| 55 | *tiling = fb->planes[0]->tiling; |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 56 | |
Thierry Reding | c134f01 | 2014-06-03 14:48:12 +0200 | [diff] [blame^] | 57 | return 0; |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 58 | } |
| 59 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 60 | static void tegra_fb_destroy(struct drm_framebuffer *framebuffer) |
| 61 | { |
| 62 | struct tegra_fb *fb = to_tegra_fb(framebuffer); |
| 63 | unsigned int i; |
| 64 | |
| 65 | for (i = 0; i < fb->num_planes; i++) { |
| 66 | struct tegra_bo *bo = fb->planes[i]; |
| 67 | |
| 68 | if (bo) |
| 69 | drm_gem_object_unreference_unlocked(&bo->gem); |
| 70 | } |
| 71 | |
| 72 | drm_framebuffer_cleanup(framebuffer); |
| 73 | kfree(fb->planes); |
| 74 | kfree(fb); |
| 75 | } |
| 76 | |
| 77 | static int tegra_fb_create_handle(struct drm_framebuffer *framebuffer, |
| 78 | struct drm_file *file, unsigned int *handle) |
| 79 | { |
| 80 | struct tegra_fb *fb = to_tegra_fb(framebuffer); |
| 81 | |
| 82 | return drm_gem_handle_create(file, &fb->planes[0]->gem, handle); |
| 83 | } |
| 84 | |
| 85 | static struct drm_framebuffer_funcs tegra_fb_funcs = { |
| 86 | .destroy = tegra_fb_destroy, |
| 87 | .create_handle = tegra_fb_create_handle, |
| 88 | }; |
| 89 | |
| 90 | static struct tegra_fb *tegra_fb_alloc(struct drm_device *drm, |
| 91 | struct drm_mode_fb_cmd2 *mode_cmd, |
| 92 | struct tegra_bo **planes, |
| 93 | unsigned int num_planes) |
| 94 | { |
| 95 | struct tegra_fb *fb; |
| 96 | unsigned int i; |
| 97 | int err; |
| 98 | |
| 99 | fb = kzalloc(sizeof(*fb), GFP_KERNEL); |
| 100 | if (!fb) |
| 101 | return ERR_PTR(-ENOMEM); |
| 102 | |
| 103 | fb->planes = kzalloc(num_planes * sizeof(*planes), GFP_KERNEL); |
Dan Carpenter | 6b7c79d | 2013-11-12 13:25:26 +0300 | [diff] [blame] | 104 | if (!fb->planes) { |
| 105 | kfree(fb); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 106 | return ERR_PTR(-ENOMEM); |
Dan Carpenter | 6b7c79d | 2013-11-12 13:25:26 +0300 | [diff] [blame] | 107 | } |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 108 | |
| 109 | fb->num_planes = num_planes; |
| 110 | |
| 111 | drm_helper_mode_fill_fb_struct(&fb->base, mode_cmd); |
| 112 | |
| 113 | for (i = 0; i < fb->num_planes; i++) |
| 114 | fb->planes[i] = planes[i]; |
| 115 | |
| 116 | err = drm_framebuffer_init(drm, &fb->base, &tegra_fb_funcs); |
| 117 | if (err < 0) { |
| 118 | dev_err(drm->dev, "failed to initialize framebuffer: %d\n", |
| 119 | err); |
| 120 | kfree(fb->planes); |
| 121 | kfree(fb); |
| 122 | return ERR_PTR(err); |
| 123 | } |
| 124 | |
| 125 | return fb; |
| 126 | } |
| 127 | |
| 128 | static struct drm_framebuffer *tegra_fb_create(struct drm_device *drm, |
| 129 | struct drm_file *file, |
| 130 | struct drm_mode_fb_cmd2 *cmd) |
| 131 | { |
| 132 | unsigned int hsub, vsub, i; |
| 133 | struct tegra_bo *planes[4]; |
| 134 | struct drm_gem_object *gem; |
| 135 | struct tegra_fb *fb; |
| 136 | int err; |
| 137 | |
| 138 | hsub = drm_format_horz_chroma_subsampling(cmd->pixel_format); |
| 139 | vsub = drm_format_vert_chroma_subsampling(cmd->pixel_format); |
| 140 | |
| 141 | for (i = 0; i < drm_format_num_planes(cmd->pixel_format); i++) { |
| 142 | unsigned int width = cmd->width / (i ? hsub : 1); |
| 143 | unsigned int height = cmd->height / (i ? vsub : 1); |
| 144 | unsigned int size, bpp; |
| 145 | |
| 146 | gem = drm_gem_object_lookup(drm, file, cmd->handles[i]); |
| 147 | if (!gem) { |
| 148 | err = -ENXIO; |
| 149 | goto unreference; |
| 150 | } |
| 151 | |
| 152 | bpp = drm_format_plane_cpp(cmd->pixel_format, i); |
| 153 | |
| 154 | size = (height - 1) * cmd->pitches[i] + |
| 155 | width * bpp + cmd->offsets[i]; |
| 156 | |
| 157 | if (gem->size < size) { |
| 158 | err = -EINVAL; |
| 159 | goto unreference; |
| 160 | } |
| 161 | |
| 162 | planes[i] = to_tegra_bo(gem); |
| 163 | } |
| 164 | |
| 165 | fb = tegra_fb_alloc(drm, cmd, planes, i); |
| 166 | if (IS_ERR(fb)) { |
| 167 | err = PTR_ERR(fb); |
| 168 | goto unreference; |
| 169 | } |
| 170 | |
| 171 | return &fb->base; |
| 172 | |
| 173 | unreference: |
| 174 | while (i--) |
| 175 | drm_gem_object_unreference_unlocked(&planes[i]->gem); |
| 176 | |
| 177 | return ERR_PTR(err); |
| 178 | } |
| 179 | |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 180 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 181 | static struct fb_ops tegra_fb_ops = { |
| 182 | .owner = THIS_MODULE, |
| 183 | .fb_fillrect = sys_fillrect, |
| 184 | .fb_copyarea = sys_copyarea, |
| 185 | .fb_imageblit = sys_imageblit, |
| 186 | .fb_check_var = drm_fb_helper_check_var, |
| 187 | .fb_set_par = drm_fb_helper_set_par, |
| 188 | .fb_blank = drm_fb_helper_blank, |
| 189 | .fb_pan_display = drm_fb_helper_pan_display, |
| 190 | .fb_setcmap = drm_fb_helper_setcmap, |
| 191 | }; |
| 192 | |
| 193 | static int tegra_fbdev_probe(struct drm_fb_helper *helper, |
| 194 | struct drm_fb_helper_surface_size *sizes) |
| 195 | { |
| 196 | struct tegra_fbdev *fbdev = to_tegra_fbdev(helper); |
| 197 | struct drm_device *drm = helper->dev; |
| 198 | struct drm_mode_fb_cmd2 cmd = { 0 }; |
| 199 | unsigned int bytes_per_pixel; |
| 200 | struct drm_framebuffer *fb; |
| 201 | unsigned long offset; |
| 202 | struct fb_info *info; |
| 203 | struct tegra_bo *bo; |
| 204 | size_t size; |
| 205 | int err; |
| 206 | |
| 207 | bytes_per_pixel = DIV_ROUND_UP(sizes->surface_bpp, 8); |
| 208 | |
| 209 | cmd.width = sizes->surface_width; |
| 210 | cmd.height = sizes->surface_height; |
| 211 | cmd.pitches[0] = sizes->surface_width * bytes_per_pixel; |
| 212 | cmd.pixel_format = drm_mode_legacy_fb_format(sizes->surface_bpp, |
| 213 | sizes->surface_depth); |
| 214 | |
| 215 | size = cmd.pitches[0] * cmd.height; |
| 216 | |
Thierry Reding | 773af77 | 2013-10-04 22:34:01 +0200 | [diff] [blame] | 217 | bo = tegra_bo_create(drm, size, 0); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 218 | if (IS_ERR(bo)) |
| 219 | return PTR_ERR(bo); |
| 220 | |
| 221 | info = framebuffer_alloc(0, drm->dev); |
| 222 | if (!info) { |
| 223 | dev_err(drm->dev, "failed to allocate framebuffer info\n"); |
| 224 | tegra_bo_free_object(&bo->gem); |
| 225 | return -ENOMEM; |
| 226 | } |
| 227 | |
| 228 | fbdev->fb = tegra_fb_alloc(drm, &cmd, &bo, 1); |
| 229 | if (IS_ERR(fbdev->fb)) { |
| 230 | dev_err(drm->dev, "failed to allocate DRM framebuffer\n"); |
| 231 | err = PTR_ERR(fbdev->fb); |
| 232 | goto release; |
| 233 | } |
| 234 | |
| 235 | fb = &fbdev->fb->base; |
| 236 | helper->fb = fb; |
| 237 | helper->fbdev = info; |
| 238 | |
| 239 | info->par = helper; |
| 240 | info->flags = FBINFO_FLAG_DEFAULT; |
| 241 | info->fbops = &tegra_fb_ops; |
| 242 | |
| 243 | err = fb_alloc_cmap(&info->cmap, 256, 0); |
| 244 | if (err < 0) { |
| 245 | dev_err(drm->dev, "failed to allocate color map: %d\n", err); |
| 246 | goto destroy; |
| 247 | } |
| 248 | |
| 249 | drm_fb_helper_fill_fix(info, fb->pitches[0], fb->depth); |
| 250 | drm_fb_helper_fill_var(info, helper, fb->width, fb->height); |
| 251 | |
| 252 | offset = info->var.xoffset * bytes_per_pixel + |
| 253 | info->var.yoffset * fb->pitches[0]; |
| 254 | |
| 255 | drm->mode_config.fb_base = (resource_size_t)bo->paddr; |
Thierry Reding | 9ab3415 | 2013-11-08 13:18:14 +0100 | [diff] [blame] | 256 | info->screen_base = (void __iomem *)bo->vaddr + offset; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 257 | info->screen_size = size; |
| 258 | info->fix.smem_start = (unsigned long)(bo->paddr + offset); |
| 259 | info->fix.smem_len = size; |
| 260 | |
| 261 | return 0; |
| 262 | |
| 263 | destroy: |
| 264 | drm_framebuffer_unregister_private(fb); |
| 265 | tegra_fb_destroy(fb); |
| 266 | release: |
| 267 | framebuffer_release(info); |
| 268 | return err; |
| 269 | } |
| 270 | |
Thierry Reding | 3a49387 | 2014-06-27 17:19:23 +0200 | [diff] [blame] | 271 | static const struct drm_fb_helper_funcs tegra_fb_helper_funcs = { |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 272 | .fb_probe = tegra_fbdev_probe, |
| 273 | }; |
| 274 | |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 275 | static struct tegra_fbdev *tegra_fbdev_create(struct drm_device *drm) |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 276 | { |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 277 | struct tegra_fbdev *fbdev; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 278 | |
| 279 | fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL); |
| 280 | if (!fbdev) { |
| 281 | dev_err(drm->dev, "failed to allocate DRM fbdev\n"); |
| 282 | return ERR_PTR(-ENOMEM); |
| 283 | } |
| 284 | |
Thierry Reding | 10a2310 | 2014-06-27 17:19:24 +0200 | [diff] [blame] | 285 | drm_fb_helper_prepare(drm, &fbdev->base, &tegra_fb_helper_funcs); |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 286 | |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 287 | return fbdev; |
| 288 | } |
| 289 | |
| 290 | static int tegra_fbdev_init(struct tegra_fbdev *fbdev, |
| 291 | unsigned int preferred_bpp, |
| 292 | unsigned int num_crtc, |
| 293 | unsigned int max_connectors) |
| 294 | { |
| 295 | struct drm_device *drm = fbdev->base.dev; |
| 296 | int err; |
| 297 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 298 | err = drm_fb_helper_init(drm, &fbdev->base, num_crtc, max_connectors); |
| 299 | if (err < 0) { |
| 300 | dev_err(drm->dev, "failed to initialize DRM FB helper\n"); |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 301 | return err; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | err = drm_fb_helper_single_add_all_connectors(&fbdev->base); |
| 305 | if (err < 0) { |
| 306 | dev_err(drm->dev, "failed to add connectors\n"); |
| 307 | goto fini; |
| 308 | } |
| 309 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 310 | err = drm_fb_helper_initial_config(&fbdev->base, preferred_bpp); |
| 311 | if (err < 0) { |
| 312 | dev_err(drm->dev, "failed to set initial configuration\n"); |
| 313 | goto fini; |
| 314 | } |
| 315 | |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 316 | return 0; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 317 | |
| 318 | fini: |
| 319 | drm_fb_helper_fini(&fbdev->base); |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 320 | return err; |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 321 | } |
| 322 | |
| 323 | static void tegra_fbdev_free(struct tegra_fbdev *fbdev) |
| 324 | { |
| 325 | struct fb_info *info = fbdev->base.fbdev; |
| 326 | |
| 327 | if (info) { |
| 328 | int err; |
| 329 | |
| 330 | err = unregister_framebuffer(info); |
| 331 | if (err < 0) |
| 332 | DRM_DEBUG_KMS("failed to unregister framebuffer\n"); |
| 333 | |
| 334 | if (info->cmap.len) |
| 335 | fb_dealloc_cmap(&info->cmap); |
| 336 | |
| 337 | framebuffer_release(info); |
| 338 | } |
| 339 | |
| 340 | if (fbdev->fb) { |
| 341 | drm_framebuffer_unregister_private(&fbdev->fb->base); |
| 342 | tegra_fb_destroy(&fbdev->fb->base); |
| 343 | } |
| 344 | |
| 345 | drm_fb_helper_fini(&fbdev->base); |
| 346 | kfree(fbdev); |
| 347 | } |
| 348 | |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 349 | void tegra_fbdev_restore_mode(struct tegra_fbdev *fbdev) |
| 350 | { |
Rob Clark | 5ea1f75 | 2014-05-30 12:29:48 -0400 | [diff] [blame] | 351 | if (fbdev) |
| 352 | drm_fb_helper_restore_fbdev_mode_unlocked(&fbdev->base); |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 353 | } |
| 354 | |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 355 | static void tegra_fb_output_poll_changed(struct drm_device *drm) |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 356 | { |
Thierry Reding | 386a2a7 | 2013-09-24 13:22:17 +0200 | [diff] [blame] | 357 | struct tegra_drm *tegra = drm->dev_private; |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 358 | |
Thierry Reding | 386a2a7 | 2013-09-24 13:22:17 +0200 | [diff] [blame] | 359 | if (tegra->fbdev) |
| 360 | drm_fb_helper_hotplug_event(&tegra->fbdev->base); |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 361 | } |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 362 | #endif |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 363 | |
| 364 | static const struct drm_mode_config_funcs tegra_drm_mode_funcs = { |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 365 | .fb_create = tegra_fb_create, |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 366 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Arto Merilainen | de2ba66 | 2013-03-22 16:34:08 +0200 | [diff] [blame] | 367 | .output_poll_changed = tegra_fb_output_poll_changed, |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 368 | #endif |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 369 | }; |
| 370 | |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 371 | int tegra_drm_fb_prepare(struct drm_device *drm) |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 372 | { |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 373 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Thierry Reding | 386a2a7 | 2013-09-24 13:22:17 +0200 | [diff] [blame] | 374 | struct tegra_drm *tegra = drm->dev_private; |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 375 | #endif |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 376 | |
| 377 | drm->mode_config.min_width = 0; |
| 378 | drm->mode_config.min_height = 0; |
| 379 | |
| 380 | drm->mode_config.max_width = 4096; |
| 381 | drm->mode_config.max_height = 4096; |
| 382 | |
| 383 | drm->mode_config.funcs = &tegra_drm_mode_funcs; |
| 384 | |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 385 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 386 | tegra->fbdev = tegra_fbdev_create(drm); |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 387 | if (IS_ERR(tegra->fbdev)) |
| 388 | return PTR_ERR(tegra->fbdev); |
| 389 | #endif |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 390 | |
| 391 | return 0; |
| 392 | } |
| 393 | |
Thierry Reding | e221532 | 2014-06-27 17:19:25 +0200 | [diff] [blame] | 394 | int tegra_drm_fb_init(struct drm_device *drm) |
| 395 | { |
| 396 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
| 397 | struct tegra_drm *tegra = drm->dev_private; |
| 398 | int err; |
| 399 | |
| 400 | err = tegra_fbdev_init(tegra->fbdev, 32, drm->mode_config.num_crtc, |
| 401 | drm->mode_config.num_connector); |
| 402 | if (err < 0) |
| 403 | return err; |
| 404 | #endif |
| 405 | |
| 406 | return 0; |
| 407 | } |
| 408 | |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 409 | void tegra_drm_fb_exit(struct drm_device *drm) |
| 410 | { |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 411 | #ifdef CONFIG_DRM_TEGRA_FBDEV |
Thierry Reding | 386a2a7 | 2013-09-24 13:22:17 +0200 | [diff] [blame] | 412 | struct tegra_drm *tegra = drm->dev_private; |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 413 | |
Thierry Reding | 386a2a7 | 2013-09-24 13:22:17 +0200 | [diff] [blame] | 414 | tegra_fbdev_free(tegra->fbdev); |
Thierry Reding | 60c2f70 | 2013-10-31 13:28:50 +0100 | [diff] [blame] | 415 | #endif |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 416 | } |