3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5 * Inki Dae <inki.dae@samsung.com>
6 * Joonyoung Shim <jy0922.shim@samsung.com>
7 * Seung-Woo Kim <sw0312.kim@samsung.com>
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice (including the next
17 * paragraph) shall be included in all copies or substantial portions of the
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
30 #include "exynos_drm_drv.h"
31 #include "exynos_drm_encoder.h"
32 #include "exynos_drm_connector.h"
33 #include "exynos_drm_fbdev.h"
35 static LIST_HEAD(exynos_drm_subdrv_list
);
36 static struct drm_device
*drm_dev
;
38 static int exynos_drm_subdrv_probe(struct drm_device
*dev
,
39 struct exynos_drm_subdrv
*subdrv
)
41 struct drm_encoder
*encoder
;
42 struct drm_connector
*connector
;
44 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
50 * this probe callback would be called by sub driver
51 * after setting of all resources to this sub driver,
52 * such as clock, irq and register map are done or by load()
53 * of exynos drm driver.
55 * P.S. note that this driver is considered for modularization.
57 ret
= subdrv
->probe(dev
, subdrv
->dev
);
65 subdrv
->manager
->dev
= subdrv
->dev
;
67 /* create and initialize a encoder for this sub driver. */
68 encoder
= exynos_drm_encoder_create(dev
, subdrv
->manager
,
71 DRM_ERROR("failed to create encoder\n");
76 * create and initialize a connector for this sub driver and
77 * attach the encoder created above to the connector.
79 connector
= exynos_drm_connector_create(dev
, encoder
);
81 DRM_ERROR("failed to create connector\n");
82 encoder
->funcs
->destroy(encoder
);
86 subdrv
->encoder
= encoder
;
87 subdrv
->connector
= connector
;
92 static void exynos_drm_subdrv_remove(struct drm_device
*dev
,
93 struct exynos_drm_subdrv
*subdrv
)
95 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
100 if (subdrv
->encoder
) {
101 struct drm_encoder
*encoder
= subdrv
->encoder
;
102 encoder
->funcs
->destroy(encoder
);
103 subdrv
->encoder
= NULL
;
106 if (subdrv
->connector
) {
107 struct drm_connector
*connector
= subdrv
->connector
;
108 connector
->funcs
->destroy(connector
);
109 subdrv
->connector
= NULL
;
113 int exynos_drm_device_register(struct drm_device
*dev
)
115 struct exynos_drm_subdrv
*subdrv
, *n
;
118 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
125 list_for_each_entry_safe(subdrv
, n
, &exynos_drm_subdrv_list
, list
) {
126 subdrv
->drm_dev
= dev
;
127 err
= exynos_drm_subdrv_probe(dev
, subdrv
);
129 DRM_DEBUG("exynos drm subdrv probe failed.\n");
130 list_del(&subdrv
->list
);
136 EXPORT_SYMBOL_GPL(exynos_drm_device_register
);
138 int exynos_drm_device_unregister(struct drm_device
*dev
)
140 struct exynos_drm_subdrv
*subdrv
;
142 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
145 WARN(1, "Unexpected drm device unregister!\n");
149 list_for_each_entry(subdrv
, &exynos_drm_subdrv_list
, list
)
150 exynos_drm_subdrv_remove(dev
, subdrv
);
156 EXPORT_SYMBOL_GPL(exynos_drm_device_unregister
);
158 int exynos_drm_subdrv_register(struct exynos_drm_subdrv
*subdrv
)
160 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
165 list_add_tail(&subdrv
->list
, &exynos_drm_subdrv_list
);
169 EXPORT_SYMBOL_GPL(exynos_drm_subdrv_register
);
171 int exynos_drm_subdrv_unregister(struct exynos_drm_subdrv
*subdrv
)
173 DRM_DEBUG_DRIVER("%s\n", __FILE__
);
178 list_del(&subdrv
->list
);
182 EXPORT_SYMBOL_GPL(exynos_drm_subdrv_unregister
);
184 int exynos_drm_subdrv_open(struct drm_device
*dev
, struct drm_file
*file
)
186 struct exynos_drm_subdrv
*subdrv
;
189 list_for_each_entry(subdrv
, &exynos_drm_subdrv_list
, list
) {
191 ret
= subdrv
->open(dev
, subdrv
->dev
, file
);
200 list_for_each_entry_reverse(subdrv
, &subdrv
->list
, list
) {
202 subdrv
->close(dev
, subdrv
->dev
, file
);
206 EXPORT_SYMBOL_GPL(exynos_drm_subdrv_open
);
208 void exynos_drm_subdrv_close(struct drm_device
*dev
, struct drm_file
*file
)
210 struct exynos_drm_subdrv
*subdrv
;
212 list_for_each_entry(subdrv
, &exynos_drm_subdrv_list
, list
) {
214 subdrv
->close(dev
, subdrv
->dev
, file
);
217 EXPORT_SYMBOL_GPL(exynos_drm_subdrv_close
);