Skip to content

Commit c228823

Browse files
committed
drm: renesas: shmobile: Unify plane allocation
Unify primary and overlay plane allocation: - Enhance shmob_drm_plane_create() so it can be used to create the primary plane, too, - Move overlay plane creation next to primary plane creation. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/adbc5febc0099fd1910f32a7af1c8e0f570f74b4.1694767209.git.geert+renesas@glider.be
1 parent adceac2 commit c228823

File tree

4 files changed

+36
-47
lines changed

4 files changed

+36
-47
lines changed

drivers/gpu/drm/renesas/shmobile/shmob_drm_crtc.c

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <drm/drm_gem_dma_helper.h>
2020
#include <drm/drm_modeset_helper.h>
2121
#include <drm/drm_modeset_helper_vtables.h>
22-
#include <drm/drm_plane_helper.h>
2322
#include <drm/drm_probe_helper.h>
2423
#include <drm/drm_simple_kms_helper.h>
2524
#include <drm/drm_vblank.h>
@@ -453,47 +452,29 @@ static const struct drm_crtc_funcs crtc_funcs = {
453452
.disable_vblank = shmob_drm_disable_vblank,
454453
};
455454

456-
static const uint32_t modeset_formats[] = {
457-
DRM_FORMAT_RGB565,
458-
DRM_FORMAT_RGB888,
459-
DRM_FORMAT_ARGB8888,
460-
DRM_FORMAT_XRGB8888,
461-
DRM_FORMAT_NV12,
462-
DRM_FORMAT_NV21,
463-
DRM_FORMAT_NV16,
464-
DRM_FORMAT_NV61,
465-
DRM_FORMAT_NV24,
466-
DRM_FORMAT_NV42,
467-
};
468-
469-
static const struct drm_plane_funcs primary_plane_funcs = {
470-
DRM_PLANE_NON_ATOMIC_FUNCS,
471-
};
472-
473455
int shmob_drm_crtc_create(struct shmob_drm_device *sdev)
474456
{
475457
struct drm_crtc *crtc = &sdev->crtc.crtc;
476-
struct drm_plane *primary;
458+
struct drm_plane *primary, *plane;
459+
unsigned int i;
477460
int ret;
478461

479462
sdev->crtc.dpms = DRM_MODE_DPMS_OFF;
480463

481-
primary = __drm_universal_plane_alloc(&sdev->ddev, sizeof(*primary), 0,
482-
0, &primary_plane_funcs,
483-
modeset_formats,
484-
ARRAY_SIZE(modeset_formats),
485-
NULL, DRM_PLANE_TYPE_PRIMARY,
486-
NULL);
464+
primary = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_PRIMARY, 0);
487465
if (IS_ERR(primary))
488466
return PTR_ERR(primary);
489467

468+
for (i = 1; i < 5; ++i) {
469+
plane = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_OVERLAY, i);
470+
if (IS_ERR(plane))
471+
return PTR_ERR(plane);
472+
}
473+
490474
ret = drm_crtc_init_with_planes(&sdev->ddev, crtc, primary, NULL,
491475
&crtc_funcs, NULL);
492-
if (ret < 0) {
493-
drm_plane_cleanup(primary);
494-
kfree(primary);
476+
if (ret < 0)
495477
return ret;
496-
}
497478

498479
drm_crtc_helper_add(crtc, &crtc_helper_funcs);
499480

drivers/gpu/drm/renesas/shmobile/shmob_drm_drv.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
180180
struct shmob_drm_platform_data *pdata = pdev->dev.platform_data;
181181
struct shmob_drm_device *sdev;
182182
struct drm_device *ddev;
183-
unsigned int i;
184183
int ret;
185184

186185
if (pdata == NULL) {
@@ -221,14 +220,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
221220
return dev_err_probe(&pdev->dev, ret,
222221
"failed to initialize mode setting\n");
223222

224-
for (i = 0; i < 4; ++i) {
225-
ret = shmob_drm_plane_create(sdev, i);
226-
if (ret < 0) {
227-
dev_err(&pdev->dev, "failed to create plane %u\n", i);
228-
goto err_modeset_cleanup;
229-
}
230-
}
231-
232223
ret = drm_vblank_init(ddev, 1);
233224
if (ret < 0) {
234225
dev_err(&pdev->dev, "failed to initialize vblank\n");

drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <drm/drm_fourcc.h>
1313
#include <drm/drm_framebuffer.h>
1414
#include <drm/drm_gem_dma_helper.h>
15+
#include <drm/drm_plane_helper.h>
1516

1617
#include "shmob_drm_drv.h"
1718
#include "shmob_drm_kms.h"
@@ -179,7 +180,12 @@ static int shmob_drm_plane_disable(struct drm_plane *plane,
179180
return 0;
180181
}
181182

182-
static const struct drm_plane_funcs shmob_drm_plane_funcs = {
183+
static const struct drm_plane_funcs shmob_drm_primary_plane_funcs = {
184+
.update_plane = drm_plane_helper_update_primary,
185+
.disable_plane = drm_plane_helper_disable_primary,
186+
};
187+
188+
static const struct drm_plane_funcs shmob_drm_overlay_plane_funcs = {
183189
.update_plane = shmob_drm_plane_update,
184190
.disable_plane = shmob_drm_plane_disable,
185191
};
@@ -197,19 +203,28 @@ static const uint32_t formats[] = {
197203
DRM_FORMAT_NV42,
198204
};
199205

200-
int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index)
206+
struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
207+
enum drm_plane_type type,
208+
unsigned int index)
201209
{
210+
const struct drm_plane_funcs *funcs;
202211
struct shmob_drm_plane *splane;
203212

204-
splane = drmm_universal_plane_alloc(&sdev->ddev, struct shmob_drm_plane,
205-
plane, 1, &shmob_drm_plane_funcs,
206-
formats, ARRAY_SIZE(formats), NULL,
207-
DRM_PLANE_TYPE_OVERLAY, NULL);
213+
if (type == DRM_PLANE_TYPE_PRIMARY)
214+
funcs = &shmob_drm_primary_plane_funcs;
215+
else
216+
funcs = &shmob_drm_overlay_plane_funcs;
217+
218+
splane = drmm_universal_plane_alloc(&sdev->ddev,
219+
struct shmob_drm_plane, plane, 1,
220+
funcs, formats,
221+
ARRAY_SIZE(formats), NULL, type,
222+
NULL);
208223
if (IS_ERR(splane))
209-
return PTR_ERR(splane);
224+
return ERR_CAST(splane);
210225

211226
splane->index = index;
212227
splane->alpha = 255;
213228

214-
return 0;
229+
return &splane->plane;
215230
}

drivers/gpu/drm/renesas/shmobile/shmob_drm_plane.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
struct drm_plane;
1414
struct shmob_drm_device;
1515

16-
int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index);
16+
struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
17+
enum drm_plane_type type,
18+
unsigned int index);
1719
void shmob_drm_plane_setup(struct drm_plane *plane);
1820

1921
#endif /* __SHMOB_DRM_PLANE_H__ */

0 commit comments

Comments
 (0)