Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Avionic Design GmbH |
| 3 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include "drm.h" |
| 11 | |
| 12 | static void tegra_drm_fb_output_poll_changed(struct drm_device *drm) |
| 13 | { |
| 14 | struct host1x *host1x = drm->dev_private; |
| 15 | |
| 16 | drm_fbdev_cma_hotplug_event(host1x->fbdev); |
| 17 | } |
| 18 | |
| 19 | static const struct drm_mode_config_funcs tegra_drm_mode_funcs = { |
| 20 | .fb_create = drm_fb_cma_create, |
| 21 | .output_poll_changed = tegra_drm_fb_output_poll_changed, |
| 22 | }; |
| 23 | |
| 24 | int tegra_drm_fb_init(struct drm_device *drm) |
| 25 | { |
| 26 | struct host1x *host1x = drm->dev_private; |
| 27 | struct drm_fbdev_cma *fbdev; |
| 28 | |
| 29 | drm->mode_config.min_width = 0; |
| 30 | drm->mode_config.min_height = 0; |
| 31 | |
| 32 | drm->mode_config.max_width = 4096; |
| 33 | drm->mode_config.max_height = 4096; |
| 34 | |
| 35 | drm->mode_config.funcs = &tegra_drm_mode_funcs; |
| 36 | |
| 37 | fbdev = drm_fbdev_cma_init(drm, 32, drm->mode_config.num_crtc, |
| 38 | drm->mode_config.num_connector); |
| 39 | if (IS_ERR(fbdev)) |
| 40 | return PTR_ERR(fbdev); |
| 41 | |
Thierry Reding | d8f4a9e | 2012-11-15 21:28:22 +0000 | [diff] [blame] | 42 | host1x->fbdev = fbdev; |
| 43 | |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | void tegra_drm_fb_exit(struct drm_device *drm) |
| 48 | { |
| 49 | struct host1x *host1x = drm->dev_private; |
| 50 | |
| 51 | drm_fbdev_cma_fini(host1x->fbdev); |
| 52 | } |