Commit c2288234 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/adbc5febc0099fd1910f32a7af1c8e0f570f74b4.1694767209.git.geert+renesas@glider.be
parent adceac2c
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_dma_helper.h>
#include <drm/drm_modeset_helper.h> #include <drm/drm_modeset_helper.h>
#include <drm/drm_modeset_helper_vtables.h> #include <drm/drm_modeset_helper_vtables.h>
#include <drm/drm_plane_helper.h>
#include <drm/drm_probe_helper.h> #include <drm/drm_probe_helper.h>
#include <drm/drm_simple_kms_helper.h> #include <drm/drm_simple_kms_helper.h>
#include <drm/drm_vblank.h> #include <drm/drm_vblank.h>
...@@ -453,47 +452,29 @@ static const struct drm_crtc_funcs crtc_funcs = { ...@@ -453,47 +452,29 @@ static const struct drm_crtc_funcs crtc_funcs = {
.disable_vblank = shmob_drm_disable_vblank, .disable_vblank = shmob_drm_disable_vblank,
}; };
static const uint32_t modeset_formats[] = {
DRM_FORMAT_RGB565,
DRM_FORMAT_RGB888,
DRM_FORMAT_ARGB8888,
DRM_FORMAT_XRGB8888,
DRM_FORMAT_NV12,
DRM_FORMAT_NV21,
DRM_FORMAT_NV16,
DRM_FORMAT_NV61,
DRM_FORMAT_NV24,
DRM_FORMAT_NV42,
};
static const struct drm_plane_funcs primary_plane_funcs = {
DRM_PLANE_NON_ATOMIC_FUNCS,
};
int shmob_drm_crtc_create(struct shmob_drm_device *sdev) int shmob_drm_crtc_create(struct shmob_drm_device *sdev)
{ {
struct drm_crtc *crtc = &sdev->crtc.crtc; struct drm_crtc *crtc = &sdev->crtc.crtc;
struct drm_plane *primary; struct drm_plane *primary, *plane;
unsigned int i;
int ret; int ret;
sdev->crtc.dpms = DRM_MODE_DPMS_OFF; sdev->crtc.dpms = DRM_MODE_DPMS_OFF;
primary = __drm_universal_plane_alloc(&sdev->ddev, sizeof(*primary), 0, primary = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_PRIMARY, 0);
0, &primary_plane_funcs,
modeset_formats,
ARRAY_SIZE(modeset_formats),
NULL, DRM_PLANE_TYPE_PRIMARY,
NULL);
if (IS_ERR(primary)) if (IS_ERR(primary))
return PTR_ERR(primary); return PTR_ERR(primary);
for (i = 1; i < 5; ++i) {
plane = shmob_drm_plane_create(sdev, DRM_PLANE_TYPE_OVERLAY, i);
if (IS_ERR(plane))
return PTR_ERR(plane);
}
ret = drm_crtc_init_with_planes(&sdev->ddev, crtc, primary, NULL, ret = drm_crtc_init_with_planes(&sdev->ddev, crtc, primary, NULL,
&crtc_funcs, NULL); &crtc_funcs, NULL);
if (ret < 0) { if (ret < 0)
drm_plane_cleanup(primary);
kfree(primary);
return ret; return ret;
}
drm_crtc_helper_add(crtc, &crtc_helper_funcs); drm_crtc_helper_add(crtc, &crtc_helper_funcs);
......
...@@ -180,7 +180,6 @@ static int shmob_drm_probe(struct platform_device *pdev) ...@@ -180,7 +180,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
struct shmob_drm_platform_data *pdata = pdev->dev.platform_data; struct shmob_drm_platform_data *pdata = pdev->dev.platform_data;
struct shmob_drm_device *sdev; struct shmob_drm_device *sdev;
struct drm_device *ddev; struct drm_device *ddev;
unsigned int i;
int ret; int ret;
if (pdata == NULL) { if (pdata == NULL) {
...@@ -221,14 +220,6 @@ static int shmob_drm_probe(struct platform_device *pdev) ...@@ -221,14 +220,6 @@ static int shmob_drm_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, ret, return dev_err_probe(&pdev->dev, ret,
"failed to initialize mode setting\n"); "failed to initialize mode setting\n");
for (i = 0; i < 4; ++i) {
ret = shmob_drm_plane_create(sdev, i);
if (ret < 0) {
dev_err(&pdev->dev, "failed to create plane %u\n", i);
goto err_modeset_cleanup;
}
}
ret = drm_vblank_init(ddev, 1); ret = drm_vblank_init(ddev, 1);
if (ret < 0) { if (ret < 0) {
dev_err(&pdev->dev, "failed to initialize vblank\n"); dev_err(&pdev->dev, "failed to initialize vblank\n");
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include <drm/drm_fourcc.h> #include <drm/drm_fourcc.h>
#include <drm/drm_framebuffer.h> #include <drm/drm_framebuffer.h>
#include <drm/drm_gem_dma_helper.h> #include <drm/drm_gem_dma_helper.h>
#include <drm/drm_plane_helper.h>
#include "shmob_drm_drv.h" #include "shmob_drm_drv.h"
#include "shmob_drm_kms.h" #include "shmob_drm_kms.h"
...@@ -179,7 +180,12 @@ static int shmob_drm_plane_disable(struct drm_plane *plane, ...@@ -179,7 +180,12 @@ static int shmob_drm_plane_disable(struct drm_plane *plane,
return 0; return 0;
} }
static const struct drm_plane_funcs shmob_drm_plane_funcs = { static const struct drm_plane_funcs shmob_drm_primary_plane_funcs = {
.update_plane = drm_plane_helper_update_primary,
.disable_plane = drm_plane_helper_disable_primary,
};
static const struct drm_plane_funcs shmob_drm_overlay_plane_funcs = {
.update_plane = shmob_drm_plane_update, .update_plane = shmob_drm_plane_update,
.disable_plane = shmob_drm_plane_disable, .disable_plane = shmob_drm_plane_disable,
}; };
...@@ -197,19 +203,28 @@ static const uint32_t formats[] = { ...@@ -197,19 +203,28 @@ static const uint32_t formats[] = {
DRM_FORMAT_NV42, DRM_FORMAT_NV42,
}; };
int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index) struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
enum drm_plane_type type,
unsigned int index)
{ {
const struct drm_plane_funcs *funcs;
struct shmob_drm_plane *splane; struct shmob_drm_plane *splane;
splane = drmm_universal_plane_alloc(&sdev->ddev, struct shmob_drm_plane, if (type == DRM_PLANE_TYPE_PRIMARY)
plane, 1, &shmob_drm_plane_funcs, funcs = &shmob_drm_primary_plane_funcs;
formats, ARRAY_SIZE(formats), NULL, else
DRM_PLANE_TYPE_OVERLAY, NULL); funcs = &shmob_drm_overlay_plane_funcs;
splane = drmm_universal_plane_alloc(&sdev->ddev,
struct shmob_drm_plane, plane, 1,
funcs, formats,
ARRAY_SIZE(formats), NULL, type,
NULL);
if (IS_ERR(splane)) if (IS_ERR(splane))
return PTR_ERR(splane); return ERR_CAST(splane);
splane->index = index; splane->index = index;
splane->alpha = 255; splane->alpha = 255;
return 0; return &splane->plane;
} }
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
struct drm_plane; struct drm_plane;
struct shmob_drm_device; struct shmob_drm_device;
int shmob_drm_plane_create(struct shmob_drm_device *sdev, unsigned int index); struct drm_plane *shmob_drm_plane_create(struct shmob_drm_device *sdev,
enum drm_plane_type type,
unsigned int index);
void shmob_drm_plane_setup(struct drm_plane *plane); void shmob_drm_plane_setup(struct drm_plane *plane);
#endif /* __SHMOB_DRM_PLANE_H__ */ #endif /* __SHMOB_DRM_PLANE_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment