aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.c31
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_crtc.h2
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_drv.c7
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.c34
-rw-r--r--drivers/gpu/drm/exynos/exynos_drm_plane.h4
5 files changed, 47 insertions, 31 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
index a3fa7cd6d36a..eaf6fb5b30f0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c
@@ -29,11 +29,12 @@
29#include "drmP.h" 29#include "drmP.h"
30#include "drm_crtc_helper.h" 30#include "drm_crtc_helper.h"
31 31
32#include "exynos_drm_crtc.h"
33#include "exynos_drm_drv.h" 32#include "exynos_drm_drv.h"
33#include "exynos_drm_crtc.h"
34#include "exynos_drm_fb.h" 34#include "exynos_drm_fb.h"
35#include "exynos_drm_encoder.h" 35#include "exynos_drm_encoder.h"
36#include "exynos_drm_gem.h" 36#include "exynos_drm_gem.h"
37#include "exynos_drm_plane.h"
37 38
38#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\ 39#define to_exynos_crtc(x) container_of(x, struct exynos_drm_crtc,\
39 drm_crtc) 40 drm_crtc)
@@ -42,8 +43,7 @@
42 * Exynos specific crtc structure. 43 * Exynos specific crtc structure.
43 * 44 *
44 * @drm_crtc: crtc object. 45 * @drm_crtc: crtc object.
45 * @overlay: contain information common to display controller and hdmi and 46 * @drm_plane: pointer of private plane object for this crtc
46 * contents of this overlay object would be copied to sub driver size.
47 * @pipe: a crtc index created at load() with a new crtc object creation 47 * @pipe: a crtc index created at load() with a new crtc object creation
48 * and the crtc object would be set to private->crtc array 48 * and the crtc object would be set to private->crtc array
49 * to get a crtc object corresponding to this pipe from private->crtc 49 * to get a crtc object corresponding to this pipe from private->crtc
@@ -55,7 +55,7 @@
55 */ 55 */
56struct exynos_drm_crtc { 56struct exynos_drm_crtc {
57 struct drm_crtc drm_crtc; 57 struct drm_crtc drm_crtc;
58 struct exynos_drm_overlay overlay; 58 struct drm_plane *plane;
59 unsigned int pipe; 59 unsigned int pipe;
60 unsigned int dpms; 60 unsigned int dpms;
61}; 61};
@@ -63,7 +63,8 @@ struct exynos_drm_crtc {
63static void exynos_drm_crtc_apply(struct drm_crtc *crtc) 63static void exynos_drm_crtc_apply(struct drm_crtc *crtc)
64{ 64{
65 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 65 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
66 struct exynos_drm_overlay *overlay = &exynos_crtc->overlay; 66 struct exynos_drm_overlay *overlay =
67 get_exynos_drm_overlay(exynos_crtc->plane);
67 68
68 exynos_drm_fn_encoder(crtc, overlay, 69 exynos_drm_fn_encoder(crtc, overlay,
69 exynos_drm_encoder_crtc_mode_set); 70 exynos_drm_encoder_crtc_mode_set);
@@ -141,7 +142,7 @@ static int exynos_drm_crtc_update(struct drm_crtc *crtc)
141 return -EINVAL; 142 return -EINVAL;
142 143
143 exynos_crtc = to_exynos_crtc(crtc); 144 exynos_crtc = to_exynos_crtc(crtc);
144 overlay = &exynos_crtc->overlay; 145 overlay = get_exynos_drm_overlay(exynos_crtc->plane);
145 146
146 memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos)); 147 memset(&pos, 0, sizeof(struct exynos_drm_crtc_pos));
147 148
@@ -250,7 +251,8 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
250 struct drm_framebuffer *old_fb) 251 struct drm_framebuffer *old_fb)
251{ 252{
252 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); 253 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
253 struct exynos_drm_overlay *overlay = &exynos_crtc->overlay; 254 struct exynos_drm_overlay *overlay =
255 get_exynos_drm_overlay(exynos_crtc->plane);
254 int pipe = exynos_crtc->pipe; 256 int pipe = exynos_crtc->pipe;
255 int ret; 257 int ret;
256 258
@@ -378,14 +380,6 @@ static struct drm_crtc_funcs exynos_crtc_funcs = {
378 .destroy = exynos_drm_crtc_destroy, 380 .destroy = exynos_drm_crtc_destroy,
379}; 381};
380 382
381struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev,
382 struct drm_crtc *crtc)
383{
384 struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
385
386 return &exynos_crtc->overlay;
387}
388
389int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr) 383int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
390{ 384{
391 struct exynos_drm_crtc *exynos_crtc; 385 struct exynos_drm_crtc *exynos_crtc;
@@ -402,7 +396,12 @@ int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr)
402 396
403 exynos_crtc->pipe = nr; 397 exynos_crtc->pipe = nr;
404 exynos_crtc->dpms = DRM_MODE_DPMS_OFF; 398 exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
405 exynos_crtc->overlay.zpos = DEFAULT_ZPOS; 399 exynos_crtc->plane = exynos_plane_init(dev, 1 << nr, true);
400 if (!exynos_crtc->plane) {
401 kfree(exynos_crtc);
402 return -ENOMEM;
403 }
404
406 crtc = &exynos_crtc->drm_crtc; 405 crtc = &exynos_crtc->drm_crtc;
407 406
408 private->crtc[nr] = crtc; 407 private->crtc[nr] = crtc;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.h b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
index 16b8e2195a0d..b1c6e83dafa0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_crtc.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.h
@@ -29,8 +29,6 @@
29#ifndef _EXYNOS_DRM_CRTC_H_ 29#ifndef _EXYNOS_DRM_CRTC_H_
30#define _EXYNOS_DRM_CRTC_H_ 30#define _EXYNOS_DRM_CRTC_H_
31 31
32struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_device *dev,
33 struct drm_crtc *crtc);
34int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr); 32int exynos_drm_crtc_create(struct drm_device *dev, unsigned int nr);
35int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int crtc); 33int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int crtc);
36void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int crtc); 34void exynos_drm_crtc_disable_vblank(struct drm_device *dev, int crtc);
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.c b/drivers/gpu/drm/exynos/exynos_drm_drv.c
index d6de2e07fa03..e313dc23e2a8 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.c
@@ -85,8 +85,11 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
85 } 85 }
86 86
87 for (nr = 0; nr < MAX_PLANE; nr++) { 87 for (nr = 0; nr < MAX_PLANE; nr++) {
88 ret = exynos_plane_init(dev, nr); 88 struct drm_plane *plane;
89 if (ret) 89 unsigned int possible_crtcs = (1 << MAX_CRTC) - 1;
90
91 plane = exynos_plane_init(dev, possible_crtcs, false);
92 if (!plane)
90 goto err_crtc; 93 goto err_crtc;
91 } 94 }
92 95
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index 17510f54e4a7..9ef5b8c42d3e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -12,8 +12,8 @@
12#include "drmP.h" 12#include "drmP.h"
13 13
14#include "exynos_drm.h" 14#include "exynos_drm.h"
15#include "exynos_drm_crtc.h"
16#include "exynos_drm_drv.h" 15#include "exynos_drm_drv.h"
16#include "exynos_drm_crtc.h"
17#include "exynos_drm_encoder.h" 17#include "exynos_drm_encoder.h"
18 18
19#define to_exynos_plane(x) container_of(x, struct exynos_plane, base) 19#define to_exynos_plane(x) container_of(x, struct exynos_plane, base)
@@ -108,23 +108,30 @@ static struct drm_plane_funcs exynos_plane_funcs = {
108 .destroy = exynos_plane_destroy, 108 .destroy = exynos_plane_destroy,
109}; 109};
110 110
111int exynos_plane_init(struct drm_device *dev, unsigned int nr) 111struct drm_plane *exynos_plane_init(struct drm_device *dev,
112 unsigned int possible_crtcs, bool priv)
112{ 113{
113 struct exynos_plane *exynos_plane; 114 struct exynos_plane *exynos_plane;
114 uint32_t possible_crtcs; 115 int err;
115 116
116 exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL); 117 exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL);
117 if (!exynos_plane) 118 if (!exynos_plane) {
118 return -ENOMEM; 119 DRM_ERROR("failed to allocate plane\n");
119 120 return NULL;
120 /* all CRTCs are available */ 121 }
121 possible_crtcs = (1 << MAX_CRTC) - 1;
122 122
123 exynos_plane->overlay.zpos = DEFAULT_ZPOS; 123 exynos_plane->overlay.zpos = DEFAULT_ZPOS;
124 124
125 return drm_plane_init(dev, &exynos_plane->base, possible_crtcs, 125 err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
126 &exynos_plane_funcs, formats, ARRAY_SIZE(formats), 126 &exynos_plane_funcs, formats, ARRAY_SIZE(formats),
127 false); 127 priv);
128 if (err) {
129 DRM_ERROR("failed to initialize plane\n");
130 kfree(exynos_plane);
131 return NULL;
132 }
133
134 return &exynos_plane->base;
128} 135}
129 136
130int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 137int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data,
@@ -168,3 +175,10 @@ out:
168 mutex_unlock(&dev->mode_config.mutex); 175 mutex_unlock(&dev->mode_config.mutex);
169 return ret; 176 return ret;
170} 177}
178
179struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_plane *plane)
180{
181 struct exynos_plane *exynos_plane = to_exynos_plane(plane);
182
183 return &exynos_plane->overlay;
184}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h
index 16b71f8217e7..d0529181624d 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h
@@ -9,6 +9,8 @@
9 * 9 *
10 */ 10 */
11 11
12int exynos_plane_init(struct drm_device *dev, unsigned int nr); 12struct drm_plane *exynos_plane_init(struct drm_device *dev,
13 unsigned int possible_crtcs, bool priv);
13int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data, 14int exynos_plane_set_zpos_ioctl(struct drm_device *dev, void *data,
14 struct drm_file *file_priv); 15 struct drm_file *file_priv);
16struct exynos_drm_overlay *get_exynos_drm_overlay(struct drm_plane *plane);