Skip to content

Commit a4b563b

Browse files
sresuperna9999
authored andcommitted
drm/panel: sitronix-st7789v: add media bus format
Add support for describing the media bus format in the panel configuration and expose that to userspace. Since both supported formats (RGB565 and RGB666) are using 6 bits per color also hardcode that information. Reviewed-by: Michael Riesch <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]> Signed-off-by: Neil Armstrong <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 4098d18 commit a4b563b

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

drivers/gpu/drm/panel/panel-sitronix-st7789v.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/spi/spi.h>
1111

1212
#include <video/mipi_display.h>
13+
#include <linux/media-bus-format.h>
1314

1415
#include <drm/drm_device.h>
1516
#include <drm/drm_modes.h>
@@ -110,6 +111,7 @@
110111

111112
struct st7789_panel_info {
112113
const struct drm_display_mode *mode;
114+
u32 bus_format;
113115
};
114116

115117
struct st7789v {
@@ -169,6 +171,7 @@ static const struct drm_display_mode default_mode = {
169171

170172
static const struct st7789_panel_info default_panel = {
171173
.mode = &default_mode,
174+
.bus_format = MEDIA_BUS_FMT_RGB666_1X18,
172175
};
173176

174177
static int st7789v_get_modes(struct drm_panel *panel,
@@ -190,17 +193,36 @@ static int st7789v_get_modes(struct drm_panel *panel,
190193
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
191194
drm_mode_probed_add(connector, mode);
192195

196+
connector->display_info.bpc = 6;
193197
connector->display_info.width_mm = ctx->info->mode->width_mm;
194198
connector->display_info.height_mm = ctx->info->mode->height_mm;
199+
drm_display_info_set_bus_formats(&connector->display_info,
200+
&ctx->info->bus_format, 1);
195201

196202
return 1;
197203
}
198204

199205
static int st7789v_prepare(struct drm_panel *panel)
200206
{
201207
struct st7789v *ctx = panel_to_st7789v(panel);
208+
u8 pixel_fmt;
202209
int ret;
203210

211+
switch (ctx->info->bus_format) {
212+
case MEDIA_BUS_FMT_RGB666_1X18:
213+
pixel_fmt = MIPI_DCS_PIXEL_FMT_18BIT;
214+
break;
215+
case MEDIA_BUS_FMT_RGB565_1X16:
216+
pixel_fmt = MIPI_DCS_PIXEL_FMT_16BIT;
217+
break;
218+
default:
219+
dev_err(panel->dev, "unsupported bus format: %d\n",
220+
ctx->info->bus_format);
221+
return -EINVAL;
222+
}
223+
224+
pixel_fmt = (pixel_fmt << 4) | pixel_fmt;
225+
204226
ret = regulator_enable(ctx->power);
205227
if (ret)
206228
return ret;
@@ -221,9 +243,7 @@ static int st7789v_prepare(struct drm_panel *panel)
221243

222244
ST7789V_TEST(ret, st7789v_write_command(ctx,
223245
MIPI_DCS_SET_PIXEL_FORMAT));
224-
ST7789V_TEST(ret, st7789v_write_data(ctx,
225-
(MIPI_DCS_PIXEL_FMT_18BIT << 4) |
226-
(MIPI_DCS_PIXEL_FMT_18BIT)));
246+
ST7789V_TEST(ret, st7789v_write_data(ctx, pixel_fmt));
227247

228248
ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_PORCTRL_CMD));
229249
ST7789V_TEST(ret, st7789v_write_data(ctx, 0xc));

0 commit comments

Comments
 (0)