drm/exynos: removed exynos_drm_fbdev_recreate function.
[deliverable/linux.git] / drivers / gpu / drm / exynos / exynos_drm_drv.c
CommitLineData
1c248b7d
ID
1/*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
3 * Authors:
4 * Inki Dae <inki.dae@samsung.com>
5 * Joonyoung Shim <jy0922.shim@samsung.com>
6 * Seung-Woo Kim <sw0312.kim@samsung.com>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
17 * Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 */
27
28#include "drmP.h"
29#include "drm.h"
7db3eba6 30#include "drm_crtc_helper.h"
1c248b7d
ID
31
32#include <drm/exynos_drm.h>
33
34#include "exynos_drm_drv.h"
35#include "exynos_drm_crtc.h"
d081f566 36#include "exynos_drm_encoder.h"
1c248b7d
ID
37#include "exynos_drm_fbdev.h"
38#include "exynos_drm_fb.h"
39#include "exynos_drm_gem.h"
864ee9e6 40#include "exynos_drm_plane.h"
1c248b7d 41
0edf9936 42#define DRIVER_NAME "exynos"
1c248b7d
ID
43#define DRIVER_DESC "Samsung SoC DRM"
44#define DRIVER_DATE "20110530"
45#define DRIVER_MAJOR 1
46#define DRIVER_MINOR 0
47
52c68814
ID
48#define VBLANK_OFF_DELAY 50000
49
1c248b7d
ID
50static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
51{
52 struct exynos_drm_private *private;
53 int ret;
54 int nr;
55
56 DRM_DEBUG_DRIVER("%s\n", __FILE__);
57
58 private = kzalloc(sizeof(struct exynos_drm_private), GFP_KERNEL);
59 if (!private) {
60 DRM_ERROR("failed to allocate private\n");
61 return -ENOMEM;
62 }
63
64 INIT_LIST_HEAD(&private->pageflip_event_list);
65 dev->dev_private = (void *)private;
66
67 drm_mode_config_init(dev);
68
7db3eba6
SWK
69 /* init kms poll for handling hpd */
70 drm_kms_helper_poll_init(dev);
71
1c248b7d
ID
72 exynos_drm_mode_config_init(dev);
73
74 /*
75 * EXYNOS4 is enough to have two CRTCs and each crtc would be used
76 * without dependency of hardware.
77 */
78 for (nr = 0; nr < MAX_CRTC; nr++) {
79 ret = exynos_drm_crtc_create(dev, nr);
80 if (ret)
81 goto err_crtc;
82 }
83
864ee9e6
JS
84 for (nr = 0; nr < MAX_PLANE; nr++) {
85 ret = exynos_plane_init(dev, nr);
86 if (ret)
87 goto err_crtc;
88 }
89
1c248b7d
ID
90 ret = drm_vblank_init(dev, MAX_CRTC);
91 if (ret)
92 goto err_crtc;
93
94 /*
95 * probe sub drivers such as display controller and hdmi driver,
96 * that were registered at probe() of platform driver
97 * to the sub driver and create encoder and connector for them.
98 */
99 ret = exynos_drm_device_register(dev);
100 if (ret)
101 goto err_vblank;
102
d081f566
ID
103 /* setup possible_clones. */
104 exynos_drm_encoder_setup(dev);
105
1c248b7d
ID
106 /*
107 * create and configure fb helper and also exynos specific
108 * fbdev object.
109 */
110 ret = exynos_drm_fbdev_init(dev);
111 if (ret) {
112 DRM_ERROR("failed to initialize drm fbdev\n");
113 goto err_drm_device;
114 }
115
52c68814
ID
116 drm_vblank_offdelay = VBLANK_OFF_DELAY;
117
1c248b7d
ID
118 return 0;
119
120err_drm_device:
121 exynos_drm_device_unregister(dev);
122err_vblank:
123 drm_vblank_cleanup(dev);
124err_crtc:
125 drm_mode_config_cleanup(dev);
126 kfree(private);
127
128 return ret;
129}
130
131static int exynos_drm_unload(struct drm_device *dev)
132{
133 DRM_DEBUG_DRIVER("%s\n", __FILE__);
134
135 exynos_drm_fbdev_fini(dev);
136 exynos_drm_device_unregister(dev);
137 drm_vblank_cleanup(dev);
7db3eba6 138 drm_kms_helper_poll_fini(dev);
1c248b7d
ID
139 drm_mode_config_cleanup(dev);
140 kfree(dev->dev_private);
141
142 dev->dev_private = NULL;
143
144 return 0;
145}
146
ccf4d883 147static void exynos_drm_preclose(struct drm_device *dev,
6f811502 148 struct drm_file *file)
ccf4d883 149{
6f811502 150 DRM_DEBUG_DRIVER("%s\n", __FILE__);
ccf4d883 151
ccf4d883
ID
152}
153
1c248b7d
ID
154static void exynos_drm_lastclose(struct drm_device *dev)
155{
156 DRM_DEBUG_DRIVER("%s\n", __FILE__);
157
158 exynos_drm_fbdev_restore_mode(dev);
159}
160
161static struct vm_operations_struct exynos_drm_gem_vm_ops = {
162 .fault = exynos_drm_gem_fault,
163 .open = drm_gem_vm_open,
164 .close = drm_gem_vm_close,
165};
166
167static struct drm_ioctl_desc exynos_ioctls[] = {
168 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_CREATE, exynos_drm_gem_create_ioctl,
169 DRM_UNLOCKED | DRM_AUTH),
170 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MAP_OFFSET,
171 exynos_drm_gem_map_offset_ioctl, DRM_UNLOCKED |
172 DRM_AUTH),
173 DRM_IOCTL_DEF_DRV(EXYNOS_GEM_MMAP,
174 exynos_drm_gem_mmap_ioctl, DRM_UNLOCKED | DRM_AUTH),
864ee9e6
JS
175 DRM_IOCTL_DEF_DRV(EXYNOS_PLANE_SET_ZPOS, exynos_plane_set_zpos_ioctl,
176 DRM_UNLOCKED | DRM_AUTH),
1c248b7d
ID
177};
178
ac2bdf73
JS
179static const struct file_operations exynos_drm_driver_fops = {
180 .owner = THIS_MODULE,
181 .open = drm_open,
182 .mmap = exynos_drm_gem_mmap,
183 .poll = drm_poll,
184 .read = drm_read,
185 .unlocked_ioctl = drm_ioctl,
186 .release = drm_release,
187};
188
1c248b7d
ID
189static struct drm_driver exynos_drm_driver = {
190 .driver_features = DRIVER_HAVE_IRQ | DRIVER_BUS_PLATFORM |
191 DRIVER_MODESET | DRIVER_GEM,
192 .load = exynos_drm_load,
193 .unload = exynos_drm_unload,
ccf4d883 194 .preclose = exynos_drm_preclose,
1c248b7d
ID
195 .lastclose = exynos_drm_lastclose,
196 .get_vblank_counter = drm_vblank_count,
197 .enable_vblank = exynos_drm_crtc_enable_vblank,
198 .disable_vblank = exynos_drm_crtc_disable_vblank,
199 .gem_init_object = exynos_drm_gem_init_object,
200 .gem_free_object = exynos_drm_gem_free_object,
201 .gem_vm_ops = &exynos_drm_gem_vm_ops,
202 .dumb_create = exynos_drm_gem_dumb_create,
203 .dumb_map_offset = exynos_drm_gem_dumb_map_offset,
204 .dumb_destroy = exynos_drm_gem_dumb_destroy,
205 .ioctls = exynos_ioctls,
ac2bdf73 206 .fops = &exynos_drm_driver_fops,
1c248b7d
ID
207 .name = DRIVER_NAME,
208 .desc = DRIVER_DESC,
209 .date = DRIVER_DATE,
210 .major = DRIVER_MAJOR,
211 .minor = DRIVER_MINOR,
212};
213
214static int exynos_drm_platform_probe(struct platform_device *pdev)
215{
216 DRM_DEBUG_DRIVER("%s\n", __FILE__);
217
218 exynos_drm_driver.num_ioctls = DRM_ARRAY_SIZE(exynos_ioctls);
219
220 return drm_platform_init(&exynos_drm_driver, pdev);
221}
222
223static int exynos_drm_platform_remove(struct platform_device *pdev)
224{
225 DRM_DEBUG_DRIVER("%s\n", __FILE__);
226
227 drm_platform_exit(&exynos_drm_driver, pdev);
228
229 return 0;
230}
231
232static struct platform_driver exynos_drm_platform_driver = {
233 .probe = exynos_drm_platform_probe,
234 .remove = __devexit_p(exynos_drm_platform_remove),
235 .driver = {
236 .owner = THIS_MODULE,
237 .name = DRIVER_NAME,
238 },
239};
240
241static int __init exynos_drm_init(void)
242{
243 DRM_DEBUG_DRIVER("%s\n", __FILE__);
244
245 return platform_driver_register(&exynos_drm_platform_driver);
246}
247
248static void __exit exynos_drm_exit(void)
249{
250 DRM_DEBUG_DRIVER("%s\n", __FILE__);
251
252 platform_driver_unregister(&exynos_drm_platform_driver);
253}
254
255module_init(exynos_drm_init);
256module_exit(exynos_drm_exit);
257
258MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
259MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
260MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
261MODULE_DESCRIPTION("Samsung SoC DRM Driver");
262MODULE_LICENSE("GPL");
This page took 0.05752 seconds and 5 git commands to generate.