1 /* exynos_drm_encoder.c
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 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation; either version 2 of the License, or (at your
12 * option) any later version.
16 #include <drm/drm_crtc_helper.h>
18 #include "exynos_drm_drv.h"
19 #include "exynos_drm_encoder.h"
22 exynos_drm_encoder_mode_fixup(struct drm_encoder *encoder,
23 const struct drm_display_mode *mode,
24 struct drm_display_mode *adjusted_mode)
26 struct drm_device *dev = encoder->dev;
27 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
28 struct drm_connector *connector;
30 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
31 if (connector->encoder != encoder)
34 if (exynos_encoder->ops->mode_fixup)
35 exynos_encoder->ops->mode_fixup(exynos_encoder,
43 static void exynos_drm_encoder_mode_set(struct drm_encoder *encoder,
44 struct drm_display_mode *mode,
45 struct drm_display_mode *adjusted_mode)
47 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
49 if (exynos_encoder->ops->mode_set)
50 exynos_encoder->ops->mode_set(exynos_encoder, adjusted_mode);
53 static void exynos_drm_encoder_enable(struct drm_encoder *encoder)
55 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
57 if (exynos_encoder->ops->enable)
58 exynos_encoder->ops->enable(exynos_encoder);
60 if (exynos_encoder->ops->commit)
61 exynos_encoder->ops->commit(exynos_encoder);
64 static void exynos_drm_encoder_disable(struct drm_encoder *encoder)
66 struct exynos_drm_encoder *exynos_encoder = to_exynos_encoder(encoder);
68 if (exynos_encoder->ops->disable)
69 exynos_encoder->ops->disable(exynos_encoder);
72 static struct drm_encoder_helper_funcs exynos_encoder_helper_funcs = {
73 .mode_fixup = exynos_drm_encoder_mode_fixup,
74 .mode_set = exynos_drm_encoder_mode_set,
75 .enable = exynos_drm_encoder_enable,
76 .disable = exynos_drm_encoder_disable,
79 static struct drm_encoder_funcs exynos_encoder_funcs = {
80 .destroy = drm_encoder_cleanup,
83 void exynos_drm_encoder_setup(struct drm_device *dev)
85 struct drm_encoder *encoder;
86 unsigned int clone_mask = 0;
89 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
90 clone_mask |= (1 << (cnt++));
92 list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
93 encoder->possible_clones = clone_mask;
96 int exynos_drm_encoder_create(struct drm_device *dev,
97 struct exynos_drm_encoder *exynos_encoder,
98 unsigned long possible_crtcs)
100 struct drm_encoder *encoder;
105 encoder = &exynos_encoder->base;
106 encoder->possible_crtcs = possible_crtcs;
108 DRM_DEBUG_KMS("possible_crtcs = 0x%x\n", encoder->possible_crtcs);
110 drm_encoder_init(dev, encoder, &exynos_encoder_funcs,
111 DRM_MODE_ENCODER_TMDS);
113 drm_encoder_helper_add(encoder, &exynos_encoder_helper_funcs);
115 DRM_DEBUG_KMS("encoder has been created\n");