[S390] Remove error checking from copy_oldmem_page()
[linux/fpc-iii.git] / drivers / gpu / drm / exynos / exynos_drm_encoder.c
blob7cf6fa86a67efb57e10407213639e8084d2c2138
1 /* exynos_drm_encoder.c
3 * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4 * Authors:
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
18 * Software.
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.
29 #include "drmP.h"
30 #include "drm_crtc_helper.h"
32 #include "exynos_drm_drv.h"
33 #include "exynos_drm_crtc.h"
34 #include "exynos_drm_encoder.h"
36 #define to_exynos_encoder(x) container_of(x, struct exynos_drm_encoder,\
37 drm_encoder)
40 * exynos specific encoder structure.
42 * @drm_encoder: encoder object.
43 * @manager: specific encoder has its own manager to control a hardware
44 * appropriately and we can access a hardware drawing on this manager.
46 struct exynos_drm_encoder {
47 struct drm_encoder drm_encoder;
48 struct exynos_drm_manager *manager;
51 static void exynos_drm_encoder_dpms(struct drm_encoder *encoder, int mode)
53 struct drm_device *dev = encoder->dev;
54 struct drm_connector *connector;
55 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder);
57 DRM_DEBUG_KMS("%s, encoder dpms: %d\n", __FILE__, mode);
59 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
60 if (connector->encoder == encoder) {
61 struct exynos_drm_display *display = manager->display;
63 if (display && display->power_on)
64 display->power_on(manager->dev, mode);
69 static bool
70 exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder,
71 struct drm_display_mode *mode,
72 struct drm_display_mode *adjusted_mode)
74 DRM_DEBUG_KMS("%s\n", __FILE__);
76 /* drm framework doesn't check NULL. */
78 return true;
81 static void exynos_drm_encoder_mode_set(struct drm_encoder *encoder,
82 struct drm_display_mode *mode,
83 struct drm_display_mode *adjusted_mode)
85 struct drm_device *dev = encoder->dev;
86 struct drm_connector *connector;
87 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder);
88 struct exynos_drm_manager_ops *manager_ops = manager->ops;
89 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
90 struct exynos_drm_overlay *overlay = get_exynos_drm_overlay(dev,
91 encoder->crtc);
93 DRM_DEBUG_KMS("%s\n", __FILE__);
95 mode = adjusted_mode;
97 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
98 if (connector->encoder == encoder) {
99 if (manager_ops && manager_ops->mode_set)
100 manager_ops->mode_set(manager->dev, mode);
102 if (overlay_ops && overlay_ops->mode_set)
103 overlay_ops->mode_set(manager->dev, overlay);
108 static void exynos_drm_encoder_prepare(struct drm_encoder *encoder)
110 DRM_DEBUG_KMS("%s\n", __FILE__);
112 /* drm framework doesn't check NULL. */
115 static void exynos_drm_encoder_commit(struct drm_encoder *encoder)
117 struct exynos_drm_manager *manager = exynos_drm_get_manager(encoder);
118 struct exynos_drm_manager_ops *manager_ops = manager->ops;
119 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
121 DRM_DEBUG_KMS("%s\n", __FILE__);
123 if (manager_ops && manager_ops->commit)
124 manager_ops->commit(manager->dev);
126 if (overlay_ops && overlay_ops->commit)
127 overlay_ops->commit(manager->dev);
130 static struct drm_crtc *
131 exynos_drm_encoder_get_crtc(struct drm_encoder *encoder)
133 return encoder->crtc;
136 static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = {
137 .dpms = exynos_drm_encoder_dpms,
138 .mode_fixup = exynos_drm_encoder_mode_fixup,
139 .mode_set = exynos_drm_encoder_mode_set,
140 .prepare = exynos_drm_encoder_prepare,
141 .commit = exynos_drm_encoder_commit,
142 .get_crtc = exynos_drm_encoder_get_crtc,
145 static void exynos_drm_encoder_destroy(struct drm_encoder *encoder)
147 struct exynos_drm_encoder *exynos_encoder =
148 to_exynos_encoder(encoder);
150 DRM_DEBUG_KMS("%s\n", __FILE__);
152 exynos_encoder->manager->pipe = -1;
154 drm_encoder_cleanup(encoder);
155 encoder->dev->mode_config.num_encoder--;
156 kfree(exynos_encoder);
159 static struct drm_encoder_funcs exynos_encoder_funcs = {
160 .destroy = exynos_drm_encoder_destroy,
163 struct drm_encoder *
164 exynos_drm_encoder_create(struct drm_device *dev,
165 struct exynos_drm_manager *manager,
166 unsigned int possible_crtcs)
168 struct drm_encoder *encoder;
169 struct exynos_drm_encoder *exynos_encoder;
171 DRM_DEBUG_KMS("%s\n", __FILE__);
173 if (!manager || !possible_crtcs)
174 return NULL;
176 if (!manager->dev)
177 return NULL;
179 exynos_encoder = kzalloc(sizeof(*exynos_encoder), GFP_KERNEL);
180 if (!exynos_encoder) {
181 DRM_ERROR("failed to allocate encoder\n");
182 return NULL;
185 exynos_encoder->manager = manager;
186 encoder = &exynos_encoder->drm_encoder;
187 encoder->possible_crtcs = possible_crtcs;
189 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs);
191 drm_encoder_init(dev, encoder, &exynos_encoder_funcs,
192 DRM_MODE_ENCODER_TMDS);
194 drm_encoder_helper_add(encoder, &exynos_encoder_helper_funcs);
196 DRM_DEBUG_KMS("encoder has been created\n");
198 return encoder;
201 struct exynos_drm_manager *exynos_drm_get_manager(struct drm_encoder *encoder)
203 return to_exynos_encoder(encoder)->manager;
206 void exynos_drm_fn_encoder(struct drm_crtc *crtc, void *data,
207 void (*fn)(struct drm_encoder *, void *))
209 struct drm_device *dev = crtc->dev;
210 struct drm_encoder *encoder;
212 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
213 if (encoder->crtc != crtc)
214 continue;
216 fn(encoder, data);
220 void exynos_drm_enable_vblank(struct drm_encoder *encoder, void *data)
222 struct exynos_drm_manager *manager =
223 to_exynos_encoder(encoder)->manager;
224 struct exynos_drm_manager_ops *manager_ops = manager->ops;
225 int crtc = *(int *)data;
227 if (manager->pipe == -1)
228 manager->pipe = crtc;
230 if (manager_ops->enable_vblank)
231 manager_ops->enable_vblank(manager->dev);
234 void exynos_drm_disable_vblank(struct drm_encoder *encoder, void *data)
236 struct exynos_drm_manager *manager =
237 to_exynos_encoder(encoder)->manager;
238 struct exynos_drm_manager_ops *manager_ops = manager->ops;
239 int crtc = *(int *)data;
241 if (manager->pipe == -1)
242 manager->pipe = crtc;
244 if (manager_ops->disable_vblank)
245 manager_ops->disable_vblank(manager->dev);
248 void exynos_drm_encoder_crtc_commit(struct drm_encoder *encoder, void *data)
250 struct exynos_drm_manager *manager =
251 to_exynos_encoder(encoder)->manager;
252 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
254 overlay_ops->commit(manager->dev);
257 void exynos_drm_encoder_crtc_mode_set(struct drm_encoder *encoder, void *data)
259 struct exynos_drm_manager *manager =
260 to_exynos_encoder(encoder)->manager;
261 struct exynos_drm_overlay_ops *overlay_ops = manager->overlay_ops;
262 struct exynos_drm_overlay *overlay = data;
264 overlay_ops->mode_set(manager->dev, overlay);
267 MODULE_AUTHOR("Inki Dae <inki.dae@samsung.com>");
268 MODULE_AUTHOR("Joonyoung Shim <jy0922.shim@samsung.com>");
269 MODULE_AUTHOR("Seung-Woo Kim <sw0312.kim@samsung.com>");
270 MODULE_DESCRIPTION("Samsung SoC DRM Encoder Driver");
271 MODULE_LICENSE("GPL");