Commit fa32c6bc authored by Geert Uytterhoeven's avatar Geert Uytterhoeven

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Link: https://lore.kernel.org/r/0a15e5100ca30d14953c93550eb1d4c2e18de939.1694767209.git.geert+renesas@glider.be
parent 6a6ab0c7
......@@ -9,6 +9,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/media-bus-format.h>
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/platform_device.h>
......@@ -34,25 +35,31 @@
static int shmob_drm_init_interface(struct shmob_drm_device *sdev)
{
static const u32 ldmt1r[] = {
[SHMOB_DRM_IFACE_RGB8] = LDMT1R_MIFTYP_RGB8,
[SHMOB_DRM_IFACE_RGB9] = LDMT1R_MIFTYP_RGB9,
[SHMOB_DRM_IFACE_RGB12A] = LDMT1R_MIFTYP_RGB12A,
[SHMOB_DRM_IFACE_RGB12B] = LDMT1R_MIFTYP_RGB12B,
[SHMOB_DRM_IFACE_RGB16] = LDMT1R_MIFTYP_RGB16,
[SHMOB_DRM_IFACE_RGB18] = LDMT1R_MIFTYP_RGB18,
[SHMOB_DRM_IFACE_RGB24] = LDMT1R_MIFTYP_RGB24,
[SHMOB_DRM_IFACE_YUV422] = LDMT1R_MIFTYP_YCBCR,
static const struct {
u32 fmt;
u32 ldmt1r;
} bus_fmts[] = {
{ MEDIA_BUS_FMT_RGB888_3X8, LDMT1R_MIFTYP_RGB8 },
{ MEDIA_BUS_FMT_RGB666_2X9_BE, LDMT1R_MIFTYP_RGB9 },
{ MEDIA_BUS_FMT_RGB888_2X12_BE, LDMT1R_MIFTYP_RGB12A },
{ MEDIA_BUS_FMT_RGB444_1X12, LDMT1R_MIFTYP_RGB12B },
{ MEDIA_BUS_FMT_RGB565_1X16, LDMT1R_MIFTYP_RGB16 },
{ MEDIA_BUS_FMT_RGB666_1X18, LDMT1R_MIFTYP_RGB18 },
{ MEDIA_BUS_FMT_RGB888_1X24, LDMT1R_MIFTYP_RGB24 },
{ MEDIA_BUS_FMT_UYVY8_1X16, LDMT1R_MIFTYP_YCBCR },
};
unsigned int i;
if (sdev->pdata->iface.interface >= ARRAY_SIZE(ldmt1r)) {
dev_err(sdev->dev, "invalid interface type %u\n",
sdev->pdata->iface.interface);
return -EINVAL;
for (i = 0; i < ARRAY_SIZE(bus_fmts); i++) {
if (bus_fmts[i].fmt == sdev->pdata->iface.bus_fmt) {
sdev->ldmt1r = bus_fmts[i].ldmt1r;
return 0;
}
}
sdev->ldmt1r = ldmt1r[sdev->pdata->iface.interface];
return 0;
dev_err(sdev->dev, "unsupported bus format 0x%x\n",
sdev->pdata->iface.bus_fmt);
return -EINVAL;
}
static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
......
......@@ -18,17 +18,6 @@ enum shmob_drm_clk_source {
SHMOB_DRM_CLK_EXTERNAL,
};
enum shmob_drm_interface {
SHMOB_DRM_IFACE_RGB8, /* 24bpp, 8:8:8 */
SHMOB_DRM_IFACE_RGB9, /* 18bpp, 9:9 */
SHMOB_DRM_IFACE_RGB12A, /* 24bpp, 12:12 */
SHMOB_DRM_IFACE_RGB12B, /* 12bpp */
SHMOB_DRM_IFACE_RGB16, /* 16bpp */
SHMOB_DRM_IFACE_RGB18, /* 18bpp */
SHMOB_DRM_IFACE_RGB24, /* 24bpp */
SHMOB_DRM_IFACE_YUV422, /* 16bpp */
};
struct shmob_drm_panel_data {
unsigned int width_mm; /* Panel width in mm */
unsigned int height_mm; /* Panel height in mm */
......@@ -36,7 +25,7 @@ struct shmob_drm_panel_data {
};
struct shmob_drm_interface_data {
enum shmob_drm_interface interface;
unsigned int bus_fmt; /* MEDIA_BUS_FMT_* */
unsigned int clk_div;
};
......
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