Skip to content

Commit 72ed6cc

Browse files
Andrzej Hajdadaeinki
authored andcommitted
drm/exynos: switch to universal plane API
The patch replaces legacy functions drm_plane_init() / drm_crtc_init() with drm_universal_plane_init() and drm_crtc_init_with_planes(). It allows to replace fake primary plane with the real one. Additionally the patch leaves cleanup of crtcs to core, this way planes and crtcs are cleaned in correct order. Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
1 parent 832316c commit 72ed6cc

7 files changed

Lines changed: 46 additions & 51 deletions

File tree

‎drivers/gpu/drm/exynos/exynos_drm_crtc.c‎

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ enum exynos_crtc_mode {
3232
* Exynos specific crtc structure.
3333
*
3434
* @drm_crtc: crtc object.
35-
* @drm_plane: pointer of private plane object for this crtc
3635
* @manager: the manager associated with this crtc
3736
* @pipe: a crtc index created at load() with a new crtc object creation
3837
* and the crtc object would be set to private->crtc array
@@ -46,7 +45,6 @@ enum exynos_crtc_mode {
4645
*/
4746
struct exynos_drm_crtc {
4847
struct drm_crtc drm_crtc;
49-
struct drm_plane *plane;
5048
struct exynos_drm_manager *manager;
5149
unsigned int pipe;
5250
unsigned int dpms;
@@ -94,12 +92,12 @@ static void exynos_drm_crtc_commit(struct drm_crtc *crtc)
9492

9593
exynos_drm_crtc_dpms(crtc, DRM_MODE_DPMS_ON);
9694

97-
exynos_plane_commit(exynos_crtc->plane);
95+
exynos_plane_commit(crtc->primary);
9896

9997
if (manager->ops->commit)
10098
manager->ops->commit(manager);
10199

102-
exynos_plane_dpms(exynos_crtc->plane, DRM_MODE_DPMS_ON);
100+
exynos_plane_dpms(crtc->primary, DRM_MODE_DPMS_ON);
103101
}
104102

105103
static bool
@@ -123,40 +121,31 @@ exynos_drm_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
123121
{
124122
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
125123
struct exynos_drm_manager *manager = exynos_crtc->manager;
126-
struct drm_plane *plane = exynos_crtc->plane;
124+
struct drm_framebuffer *fb = crtc->primary->fb;
127125
unsigned int crtc_w;
128126
unsigned int crtc_h;
129-
int ret;
130127

131128
/*
132129
* copy the mode data adjusted by mode_fixup() into crtc->mode
133130
* so that hardware can be seet to proper mode.
134131
*/
135132
memcpy(&crtc->mode, adjusted_mode, sizeof(*adjusted_mode));
136133

137-
crtc_w = crtc->primary->fb->width - x;
138-
crtc_h = crtc->primary->fb->height - y;
134+
crtc_w = fb->width - x;
135+
crtc_h = fb->height - y;
139136

140137
if (manager->ops->mode_set)
141138
manager->ops->mode_set(manager, &crtc->mode);
142139

143-
ret = exynos_plane_mode_set(plane, crtc, crtc->primary->fb, 0, 0, crtc_w, crtc_h,
144-
x, y, crtc_w, crtc_h);
145-
if (ret)
146-
return ret;
147-
148-
plane->crtc = crtc;
149-
plane->fb = crtc->primary->fb;
150-
drm_framebuffer_reference(plane->fb);
151-
152-
return 0;
140+
return exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0,
141+
crtc_w, crtc_h, x, y, crtc_w, crtc_h);
153142
}
154143

155144
static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y,
156145
struct drm_framebuffer *old_fb)
157146
{
158147
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(crtc);
159-
struct drm_plane *plane = exynos_crtc->plane;
148+
struct drm_framebuffer *fb = crtc->primary->fb;
160149
unsigned int crtc_w;
161150
unsigned int crtc_h;
162151
int ret;
@@ -167,11 +156,11 @@ static int exynos_drm_crtc_mode_set_commit(struct drm_crtc *crtc, int x, int y,
167156
return -EPERM;
168157
}
169158

170-
crtc_w = crtc->primary->fb->width - x;
171-
crtc_h = crtc->primary->fb->height - y;
159+
crtc_w = fb->width - x;
160+
crtc_h = fb->height - y;
172161

173-
ret = exynos_plane_mode_set(plane, crtc, crtc->primary->fb, 0, 0, crtc_w, crtc_h,
174-
x, y, crtc_w, crtc_h);
162+
ret = exynos_plane_mode_set(crtc->primary, crtc, fb, 0, 0,
163+
crtc_w, crtc_h, x, y, crtc_w, crtc_h);
175164
if (ret)
176165
return ret;
177166

@@ -304,8 +293,7 @@ static int exynos_drm_crtc_set_property(struct drm_crtc *crtc,
304293
exynos_drm_crtc_commit(crtc);
305294
break;
306295
case CRTC_MODE_BLANK:
307-
exynos_plane_dpms(exynos_crtc->plane,
308-
DRM_MODE_DPMS_OFF);
296+
exynos_plane_dpms(crtc->primary, DRM_MODE_DPMS_OFF);
309297
break;
310298
default:
311299
break;
@@ -351,8 +339,10 @@ static void exynos_drm_crtc_attach_mode_property(struct drm_crtc *crtc)
351339
int exynos_drm_crtc_create(struct exynos_drm_manager *manager)
352340
{
353341
struct exynos_drm_crtc *exynos_crtc;
342+
struct drm_plane *plane;
354343
struct exynos_drm_private *private = manager->drm_dev->dev_private;
355344
struct drm_crtc *crtc;
345+
int ret;
356346

357347
exynos_crtc = kzalloc(sizeof(*exynos_crtc), GFP_KERNEL);
358348
if (!exynos_crtc)
@@ -364,24 +354,34 @@ int exynos_drm_crtc_create(struct exynos_drm_manager *manager)
364354
exynos_crtc->dpms = DRM_MODE_DPMS_OFF;
365355
exynos_crtc->manager = manager;
366356
exynos_crtc->pipe = manager->pipe;
367-
exynos_crtc->plane = exynos_plane_init(manager->drm_dev,
368-
1 << manager->pipe, true);
369-
if (!exynos_crtc->plane) {
370-
kfree(exynos_crtc);
371-
return -ENOMEM;
357+
plane = exynos_plane_init(manager->drm_dev, 1 << manager->pipe,
358+
DRM_PLANE_TYPE_PRIMARY);
359+
if (IS_ERR(plane)) {
360+
ret = PTR_ERR(plane);
361+
goto err_plane;
372362
}
373363

374364
manager->crtc = &exynos_crtc->drm_crtc;
375365
crtc = &exynos_crtc->drm_crtc;
376366

377367
private->crtc[manager->pipe] = crtc;
378368

379-
drm_crtc_init(manager->drm_dev, crtc, &exynos_crtc_funcs);
369+
ret = drm_crtc_init_with_planes(manager->drm_dev, crtc, plane, NULL,
370+
&exynos_crtc_funcs);
371+
if (ret < 0)
372+
goto err_crtc;
373+
380374
drm_crtc_helper_add(crtc, &exynos_crtc_helper_funcs);
381375

382376
exynos_drm_crtc_attach_mode_property(crtc);
383377

384378
return 0;
379+
380+
err_crtc:
381+
plane->funcs->destroy(plane);
382+
err_plane:
383+
kfree(exynos_crtc);
384+
return ret;
385385
}
386386

387387
int exynos_drm_crtc_enable_vblank(struct drm_device *dev, int pipe)

‎drivers/gpu/drm/exynos/exynos_drm_drv.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ static int exynos_drm_load(struct drm_device *dev, unsigned long flags)
8585
struct drm_plane *plane;
8686
unsigned long possible_crtcs = (1 << MAX_CRTC) - 1;
8787

88-
plane = exynos_plane_init(dev, possible_crtcs, false);
89-
if (!plane)
88+
plane = exynos_plane_init(dev, possible_crtcs,
89+
DRM_PLANE_TYPE_OVERLAY);
90+
if (IS_ERR(plane))
9091
goto err_mode_config_cleanup;
9192
}
9293

‎drivers/gpu/drm/exynos/exynos_drm_fimd.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,16 +1057,13 @@ static void fimd_unbind(struct device *dev, struct device *master,
10571057
{
10581058
struct exynos_drm_manager *mgr = dev_get_drvdata(dev);
10591059
struct fimd_context *ctx = fimd_manager.ctx;
1060-
struct drm_crtc *crtc = mgr->crtc;
10611060

10621061
fimd_dpms(mgr, DRM_MODE_DPMS_OFF);
10631062

10641063
if (ctx->display)
10651064
exynos_dpi_remove(dev);
10661065

10671066
fimd_mgr_remove(mgr);
1068-
1069-
crtc->funcs->destroy(crtc);
10701067
}
10711068

10721069
static const struct component_ops fimd_component_ops = {

‎drivers/gpu/drm/exynos/exynos_drm_plane.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
139139
overlay->crtc_x, overlay->crtc_y,
140140
overlay->crtc_width, overlay->crtc_height);
141141

142+
plane->crtc = crtc;
143+
142144
exynos_drm_crtc_plane_mode_set(crtc, overlay);
143145

144146
return 0;
@@ -187,8 +189,6 @@ exynos_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
187189
if (ret < 0)
188190
return ret;
189191

190-
plane->crtc = crtc;
191-
192192
exynos_plane_commit(plane);
193193
exynos_plane_dpms(plane, DRM_MODE_DPMS_ON);
194194

@@ -254,25 +254,26 @@ static void exynos_plane_attach_zpos_property(struct drm_plane *plane)
254254
}
255255

256256
struct drm_plane *exynos_plane_init(struct drm_device *dev,
257-
unsigned long possible_crtcs, bool priv)
257+
unsigned long possible_crtcs,
258+
enum drm_plane_type type)
258259
{
259260
struct exynos_plane *exynos_plane;
260261
int err;
261262

262263
exynos_plane = kzalloc(sizeof(struct exynos_plane), GFP_KERNEL);
263264
if (!exynos_plane)
264-
return NULL;
265+
return ERR_PTR(-ENOMEM);
265266

266-
err = drm_plane_init(dev, &exynos_plane->base, possible_crtcs,
267-
&exynos_plane_funcs, formats, ARRAY_SIZE(formats),
268-
priv);
267+
err = drm_universal_plane_init(dev, &exynos_plane->base, possible_crtcs,
268+
&exynos_plane_funcs, formats,
269+
ARRAY_SIZE(formats), type);
269270
if (err) {
270271
DRM_ERROR("failed to initialize plane\n");
271272
kfree(exynos_plane);
272-
return NULL;
273+
return ERR_PTR(err);
273274
}
274275

275-
if (priv)
276+
if (type == DRM_PLANE_TYPE_PRIMARY)
276277
exynos_plane->overlay.zpos = DEFAULT_ZPOS;
277278
else
278279
exynos_plane_attach_zpos_property(&exynos_plane->base);

‎drivers/gpu/drm/exynos/exynos_drm_plane.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc,
1717
void exynos_plane_commit(struct drm_plane *plane);
1818
void exynos_plane_dpms(struct drm_plane *plane, int mode);
1919
struct drm_plane *exynos_plane_init(struct drm_device *dev,
20-
unsigned long possible_crtcs, bool priv);
20+
unsigned long possible_crtcs,
21+
enum drm_plane_type type);

‎drivers/gpu/drm/exynos/exynos_drm_vidi.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,6 @@ static int vidi_remove(struct platform_device *pdev)
631631
struct exynos_drm_manager *mgr = platform_get_drvdata(pdev);
632632
struct vidi_context *ctx = mgr->ctx;
633633
struct drm_encoder *encoder = ctx->encoder;
634-
struct drm_crtc *crtc = mgr->crtc;
635634

636635
if (ctx->raw_edid != (struct edid *)fake_edid_info) {
637636
kfree(ctx->raw_edid);
@@ -640,7 +639,6 @@ static int vidi_remove(struct platform_device *pdev)
640639
return -EINVAL;
641640
}
642641

643-
crtc->funcs->destroy(crtc);
644642
encoder->funcs->destroy(encoder);
645643
drm_connector_cleanup(&ctx->connector);
646644

‎drivers/gpu/drm/exynos/exynos_mixer.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,15 +1302,12 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
13021302
static void mixer_unbind(struct device *dev, struct device *master, void *data)
13031303
{
13041304
struct exynos_drm_manager *mgr = dev_get_drvdata(dev);
1305-
struct drm_crtc *crtc = mgr->crtc;
13061305

13071306
dev_info(dev, "remove successful\n");
13081307

13091308
mixer_mgr_remove(mgr);
13101309

13111310
pm_runtime_disable(dev);
1312-
1313-
crtc->funcs->destroy(crtc);
13141311
}
13151312

13161313
static const struct component_ops mixer_component_ops = {

0 commit comments

Comments
 (0)