Skip to content

Commit fa32c6b

Browse files
committed
drm: renesas: shmobile: Use media bus formats in platform data
Replace the custom shmob_drm_interface enumeration values with standard media bus formats. This simplifies driver handling of bus formats and prepares for DT support. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/0a15e5100ca30d14953c93550eb1d4c2e18de939.1694767209.git.geert+renesas@glider.be
1 parent 6a6ab0c commit fa32c6b

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <linux/clk.h>
1111
#include <linux/io.h>
12+
#include <linux/media-bus-format.h>
1213
#include <linux/mm.h>
1314
#include <linux/module.h>
1415
#include <linux/platform_device.h>
@@ -34,25 +35,31 @@
3435

3536
static int shmob_drm_init_interface(struct shmob_drm_device *sdev)
3637
{
37-
static const u32 ldmt1r[] = {
38-
[SHMOB_DRM_IFACE_RGB8] = LDMT1R_MIFTYP_RGB8,
39-
[SHMOB_DRM_IFACE_RGB9] = LDMT1R_MIFTYP_RGB9,
40-
[SHMOB_DRM_IFACE_RGB12A] = LDMT1R_MIFTYP_RGB12A,
41-
[SHMOB_DRM_IFACE_RGB12B] = LDMT1R_MIFTYP_RGB12B,
42-
[SHMOB_DRM_IFACE_RGB16] = LDMT1R_MIFTYP_RGB16,
43-
[SHMOB_DRM_IFACE_RGB18] = LDMT1R_MIFTYP_RGB18,
44-
[SHMOB_DRM_IFACE_RGB24] = LDMT1R_MIFTYP_RGB24,
45-
[SHMOB_DRM_IFACE_YUV422] = LDMT1R_MIFTYP_YCBCR,
38+
static const struct {
39+
u32 fmt;
40+
u32 ldmt1r;
41+
} bus_fmts[] = {
42+
{ MEDIA_BUS_FMT_RGB888_3X8, LDMT1R_MIFTYP_RGB8 },
43+
{ MEDIA_BUS_FMT_RGB666_2X9_BE, LDMT1R_MIFTYP_RGB9 },
44+
{ MEDIA_BUS_FMT_RGB888_2X12_BE, LDMT1R_MIFTYP_RGB12A },
45+
{ MEDIA_BUS_FMT_RGB444_1X12, LDMT1R_MIFTYP_RGB12B },
46+
{ MEDIA_BUS_FMT_RGB565_1X16, LDMT1R_MIFTYP_RGB16 },
47+
{ MEDIA_BUS_FMT_RGB666_1X18, LDMT1R_MIFTYP_RGB18 },
48+
{ MEDIA_BUS_FMT_RGB888_1X24, LDMT1R_MIFTYP_RGB24 },
49+
{ MEDIA_BUS_FMT_UYVY8_1X16, LDMT1R_MIFTYP_YCBCR },
4650
};
51+
unsigned int i;
4752

48-
if (sdev->pdata->iface.interface >= ARRAY_SIZE(ldmt1r)) {
49-
dev_err(sdev->dev, "invalid interface type %u\n",
50-
sdev->pdata->iface.interface);
51-
return -EINVAL;
53+
for (i = 0; i < ARRAY_SIZE(bus_fmts); i++) {
54+
if (bus_fmts[i].fmt == sdev->pdata->iface.bus_fmt) {
55+
sdev->ldmt1r = bus_fmts[i].ldmt1r;
56+
return 0;
57+
}
5258
}
5359

54-
sdev->ldmt1r = ldmt1r[sdev->pdata->iface.interface];
55-
return 0;
60+
dev_err(sdev->dev, "unsupported bus format 0x%x\n",
61+
sdev->pdata->iface.bus_fmt);
62+
return -EINVAL;
5663
}
5764

5865
static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,

include/linux/platform_data/shmob_drm.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,14 @@ enum shmob_drm_clk_source {
1818
SHMOB_DRM_CLK_EXTERNAL,
1919
};
2020

21-
enum shmob_drm_interface {
22-
SHMOB_DRM_IFACE_RGB8, /* 24bpp, 8:8:8 */
23-
SHMOB_DRM_IFACE_RGB9, /* 18bpp, 9:9 */
24-
SHMOB_DRM_IFACE_RGB12A, /* 24bpp, 12:12 */
25-
SHMOB_DRM_IFACE_RGB12B, /* 12bpp */
26-
SHMOB_DRM_IFACE_RGB16, /* 16bpp */
27-
SHMOB_DRM_IFACE_RGB18, /* 18bpp */
28-
SHMOB_DRM_IFACE_RGB24, /* 24bpp */
29-
SHMOB_DRM_IFACE_YUV422, /* 16bpp */
30-
};
31-
3221
struct shmob_drm_panel_data {
3322
unsigned int width_mm; /* Panel width in mm */
3423
unsigned int height_mm; /* Panel height in mm */
3524
struct videomode mode;
3625
};
3726

3827
struct shmob_drm_interface_data {
39-
enum shmob_drm_interface interface;
28+
unsigned int bus_fmt; /* MEDIA_BUS_FMT_* */
4029
unsigned int clk_div;
4130
};
4231

0 commit comments

Comments
 (0)