diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_crtc.c | 31 | ||||
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_plane.c | 40 | ||||
-rw-r--r-- | drivers/gpu/drm/exynos/exynos_drm_plane.h | 2 |
3 files changed, 47 insertions, 26 deletions
diff --git a/drivers/gpu/drm/exynos/exynos_drm_crtc.c b/drivers/gpu/drm/exynos/exynos_drm_crtc.c index 363b0193d580..ba44c9b490ec 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_crtc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_crtc.c | |||
@@ -116,6 +116,7 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, | |||
116 | struct drm_framebuffer *fb = crtc->primary->fb; | 116 | struct drm_framebuffer *fb = crtc->primary->fb; |
117 | unsigned int crtc_w; | 117 | unsigned int crtc_w; |
118 | unsigned int crtc_h; | 118 | unsigned int crtc_h; |
119 | int ret; | ||
119 | 120 | ||
120 | /* when framebuffer changing is requested, crtc's dpms should be on */ | 121 | /* when framebuffer changing is requested, crtc's dpms should be on */ |
121 | if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) { | 122 | if (exynos_crtc->dpms > DRM_MODE_DPMS_ON) { |
@@ -123,12 +124,17 @@ static int exynos_drm_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y, | |||
123 | return -EPERM; | 124 | return -EPERM; |
124 | } | 125 | } |
125 | 126 | ||
127 | ret = exynos_check_plane(crtc->primary, fb); | ||
128 | if (ret) | ||
129 | return ret; | ||
130 | |||
126 | crtc_w = fb->width - x; | 131 | crtc_w = fb->width - x; |
127 | crtc_h = fb->height - y; | 132 | crtc_h = fb->height - y; |
133 | exynos_update_plane(crtc->primary, crtc, fb, 0, 0, | ||
134 | crtc_w, crtc_h, x << 16, y << 16, | ||
135 | crtc_w << 16, crtc_h << 16); | ||
128 | 136 | ||
129 | return exynos_update_plane(crtc->primary, crtc, fb, 0, 0, | 137 | return 0; |
130 | crtc_w, crtc_h, x << 16, y << 16, | ||
131 | crtc_w << 16, crtc_h << 16); | ||
132 | } | 138 | } |
133 | 139 | ||
134 | static void exynos_drm_crtc_disable(struct drm_crtc *crtc) | 140 | static void exynos_drm_crtc_disable(struct drm_crtc *crtc) |
@@ -165,7 +171,6 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, | |||
165 | { | 171 | { |
166 | struct drm_device *dev = crtc->dev; | 172 | struct drm_device *dev = crtc->dev; |
167 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); | 173 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); |
168 | struct drm_framebuffer *old_fb = crtc->primary->fb; | ||
169 | unsigned int crtc_w, crtc_h; | 174 | unsigned int crtc_w, crtc_h; |
170 | int ret; | 175 | int ret; |
171 | 176 | ||
@@ -184,6 +189,10 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, | |||
184 | goto out; | 189 | goto out; |
185 | } | 190 | } |
186 | 191 | ||
192 | ret = exynos_check_plane(crtc->primary, fb); | ||
193 | if (ret) | ||
194 | goto out; | ||
195 | |||
187 | ret = drm_vblank_get(dev, exynos_crtc->pipe); | 196 | ret = drm_vblank_get(dev, exynos_crtc->pipe); |
188 | if (ret) { | 197 | if (ret) { |
189 | DRM_DEBUG("failed to acquire vblank counter\n"); | 198 | DRM_DEBUG("failed to acquire vblank counter\n"); |
@@ -202,17 +211,9 @@ static int exynos_drm_crtc_page_flip(struct drm_crtc *crtc, | |||
202 | crtc->primary->fb = fb; | 211 | crtc->primary->fb = fb; |
203 | crtc_w = fb->width - crtc->x; | 212 | crtc_w = fb->width - crtc->x; |
204 | crtc_h = fb->height - crtc->y; | 213 | crtc_h = fb->height - crtc->y; |
205 | ret = exynos_update_plane(crtc->primary, crtc, fb, 0, 0, | 214 | exynos_update_plane(crtc->primary, crtc, fb, 0, 0, |
206 | crtc_w, crtc_h, crtc->x << 16, crtc->y << 16, | 215 | crtc_w, crtc_h, crtc->x << 16, crtc->y << 16, |
207 | crtc_w << 16, crtc_h << 16); | 216 | crtc_w << 16, crtc_h << 16); |
208 | if (ret) { | ||
209 | crtc->primary->fb = old_fb; | ||
210 | spin_lock_irq(&dev->event_lock); | ||
211 | exynos_crtc->event = NULL; | ||
212 | drm_vblank_put(dev, exynos_crtc->pipe); | ||
213 | spin_unlock_irq(&dev->event_lock); | ||
214 | return ret; | ||
215 | } | ||
216 | 217 | ||
217 | return 0; | 218 | return 0; |
218 | 219 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index b1180fbe7546..2aaed648d346 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c | |||
@@ -144,21 +144,15 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, | |||
144 | plane->crtc = crtc; | 144 | plane->crtc = crtc; |
145 | } | 145 | } |
146 | 146 | ||
147 | int | 147 | void |
148 | exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | 148 | exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
149 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | 149 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
150 | unsigned int crtc_w, unsigned int crtc_h, | 150 | unsigned int crtc_w, unsigned int crtc_h, |
151 | uint32_t src_x, uint32_t src_y, | 151 | uint32_t src_x, uint32_t src_y, |
152 | uint32_t src_w, uint32_t src_h) | 152 | uint32_t src_w, uint32_t src_h) |
153 | { | 153 | { |
154 | |||
155 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); | 154 | struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc); |
156 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); | 155 | struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane); |
157 | int ret; | ||
158 | |||
159 | ret = exynos_check_plane(plane, fb); | ||
160 | if (ret < 0) | ||
161 | return ret; | ||
162 | 156 | ||
163 | exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, | 157 | exynos_plane_mode_set(plane, crtc, fb, crtc_x, crtc_y, |
164 | crtc_w, crtc_h, src_x >> 16, src_y >> 16, | 158 | crtc_w, crtc_h, src_x >> 16, src_y >> 16, |
@@ -166,8 +160,6 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | |||
166 | 160 | ||
167 | if (exynos_crtc->ops->win_commit) | 161 | if (exynos_crtc->ops->win_commit) |
168 | exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos); | 162 | exynos_crtc->ops->win_commit(exynos_crtc, exynos_plane->zpos); |
169 | |||
170 | return 0; | ||
171 | } | 163 | } |
172 | 164 | ||
173 | static int exynos_disable_plane(struct drm_plane *plane) | 165 | static int exynos_disable_plane(struct drm_plane *plane) |
@@ -183,11 +175,37 @@ static int exynos_disable_plane(struct drm_plane *plane) | |||
183 | } | 175 | } |
184 | 176 | ||
185 | static struct drm_plane_funcs exynos_plane_funcs = { | 177 | static struct drm_plane_funcs exynos_plane_funcs = { |
186 | .update_plane = exynos_update_plane, | 178 | .update_plane = drm_plane_helper_update, |
187 | .disable_plane = exynos_disable_plane, | 179 | .disable_plane = exynos_disable_plane, |
188 | .destroy = drm_plane_cleanup, | 180 | .destroy = drm_plane_cleanup, |
189 | }; | 181 | }; |
190 | 182 | ||
183 | static int exynos_plane_atomic_check(struct drm_plane *plane, | ||
184 | struct drm_plane_state *state) | ||
185 | { | ||
186 | return exynos_check_plane(plane, state->fb); | ||
187 | } | ||
188 | |||
189 | static void exynos_plane_atomic_update(struct drm_plane *plane, | ||
190 | struct drm_plane_state *old_state) | ||
191 | { | ||
192 | struct drm_plane_state *state = plane->state; | ||
193 | |||
194 | if (!state->crtc) | ||
195 | return; | ||
196 | |||
197 | exynos_update_plane(plane, state->crtc, state->fb, | ||
198 | state->crtc_x, state->crtc_y, | ||
199 | state->crtc_w, state->crtc_h, | ||
200 | state->src_x, state->src_y, | ||
201 | state->src_w, state->src_h); | ||
202 | } | ||
203 | |||
204 | static const struct drm_plane_helper_funcs plane_helper_funcs = { | ||
205 | .atomic_check = exynos_plane_atomic_check, | ||
206 | .atomic_update = exynos_plane_atomic_update, | ||
207 | }; | ||
208 | |||
191 | static void exynos_plane_attach_zpos_property(struct drm_plane *plane, | 209 | static void exynos_plane_attach_zpos_property(struct drm_plane *plane, |
192 | unsigned int zpos) | 210 | unsigned int zpos) |
193 | { | 211 | { |
@@ -223,6 +241,8 @@ int exynos_plane_init(struct drm_device *dev, | |||
223 | return err; | 241 | return err; |
224 | } | 242 | } |
225 | 243 | ||
244 | drm_plane_helper_add(&exynos_plane->base, &plane_helper_funcs); | ||
245 | |||
226 | exynos_plane->zpos = zpos; | 246 | exynos_plane->zpos = zpos; |
227 | 247 | ||
228 | if (type == DRM_PLANE_TYPE_OVERLAY) | 248 | if (type == DRM_PLANE_TYPE_OVERLAY) |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.h b/drivers/gpu/drm/exynos/exynos_drm_plane.h index f360590d1412..560ca71b57e7 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.h +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.h | |||
@@ -15,7 +15,7 @@ void exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, | |||
15 | unsigned int crtc_w, unsigned int crtc_h, | 15 | unsigned int crtc_w, unsigned int crtc_h, |
16 | uint32_t src_x, uint32_t src_y, | 16 | uint32_t src_x, uint32_t src_y, |
17 | uint32_t src_w, uint32_t src_h); | 17 | uint32_t src_w, uint32_t src_h); |
18 | int exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, | 18 | void exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, |
19 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, | 19 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
20 | unsigned int crtc_w, unsigned int crtc_h, | 20 | unsigned int crtc_w, unsigned int crtc_h, |
21 | uint32_t src_x, uint32_t src_y, | 21 | uint32_t src_x, uint32_t src_y, |