|
9 | 9 |
|
10 | 10 | #include <linux/clk.h>
|
11 | 11 | #include <linux/io.h>
|
| 12 | +#include <linux/media-bus-format.h> |
12 | 13 | #include <linux/mm.h>
|
13 | 14 | #include <linux/module.h>
|
14 | 15 | #include <linux/platform_device.h>
|
|
34 | 35 |
|
35 | 36 | static int shmob_drm_init_interface(struct shmob_drm_device *sdev)
|
36 | 37 | {
|
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 }, |
46 | 50 | };
|
| 51 | + unsigned int i; |
47 | 52 |
|
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 | + } |
52 | 58 | }
|
53 | 59 |
|
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; |
56 | 63 | }
|
57 | 64 |
|
58 | 65 | static int shmob_drm_setup_clocks(struct shmob_drm_device *sdev,
|
|
0 commit comments