Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <michael.riesch@wolfvision.net>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230714013756.1546769-11-sre@kernel.org

authored by

Sebastian Reichel and committed by
Neil Armstrong
a4b563b1 4098d186

+23 -3
+23 -3
drivers/gpu/drm/panel/panel-sitronix-st7789v.c
··· 10 10 #include <linux/spi/spi.h> 11 11 12 12 #include <video/mipi_display.h> 13 + #include <linux/media-bus-format.h> 13 14 14 15 #include <drm/drm_device.h> 15 16 #include <drm/drm_modes.h> ··· 111 110 112 111 struct st7789_panel_info { 113 112 const struct drm_display_mode *mode; 113 + u32 bus_format; 114 114 }; 115 115 116 116 struct st7789v { ··· 171 169 172 170 static const struct st7789_panel_info default_panel = { 173 171 .mode = &default_mode, 172 + .bus_format = MEDIA_BUS_FMT_RGB666_1X18, 174 173 }; 175 174 176 175 static int st7789v_get_modes(struct drm_panel *panel, ··· 193 190 mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; 194 191 drm_mode_probed_add(connector, mode); 195 192 193 + connector->display_info.bpc = 6; 196 194 connector->display_info.width_mm = ctx->info->mode->width_mm; 197 195 connector->display_info.height_mm = ctx->info->mode->height_mm; 196 + drm_display_info_set_bus_formats(&connector->display_info, 197 + &ctx->info->bus_format, 1); 198 198 199 199 return 1; 200 200 } ··· 205 199 static int st7789v_prepare(struct drm_panel *panel) 206 200 { 207 201 struct st7789v *ctx = panel_to_st7789v(panel); 202 + u8 pixel_fmt; 208 203 int ret; 204 + 205 + switch (ctx->info->bus_format) { 206 + case MEDIA_BUS_FMT_RGB666_1X18: 207 + pixel_fmt = MIPI_DCS_PIXEL_FMT_18BIT; 208 + break; 209 + case MEDIA_BUS_FMT_RGB565_1X16: 210 + pixel_fmt = MIPI_DCS_PIXEL_FMT_16BIT; 211 + break; 212 + default: 213 + dev_err(panel->dev, "unsupported bus format: %d\n", 214 + ctx->info->bus_format); 215 + return -EINVAL; 216 + } 217 + 218 + pixel_fmt = (pixel_fmt << 4) | pixel_fmt; 209 219 210 220 ret = regulator_enable(ctx->power); 211 221 if (ret) ··· 243 221 244 222 ST7789V_TEST(ret, st7789v_write_command(ctx, 245 223 MIPI_DCS_SET_PIXEL_FORMAT)); 246 - ST7789V_TEST(ret, st7789v_write_data(ctx, 247 - (MIPI_DCS_PIXEL_FMT_18BIT << 4) | 248 - (MIPI_DCS_PIXEL_FMT_18BIT))); 224 + ST7789V_TEST(ret, st7789v_write_data(ctx, pixel_fmt)); 249 225 250 226 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_PORCTRL_CMD)); 251 227 ST7789V_TEST(ret, st7789v_write_data(ctx, 0xc));