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: avoid hardcoding polarity info

Add polarity information via mode and bus flags, so that they are no
longer hardcoded and forward the information to the DRM stack. This is
required for adding panels with different settings.

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-13-sre@kernel.org

authored by

Sebastian Reichel and committed by
Neil Armstrong
e4572f99 7a628872

+18 -4
+18 -4
drivers/gpu/drm/panel/panel-sitronix-st7789v.c
··· 28 28 #define ST7789V_RGBCTRL_VSYNC_HIGH BIT(3) 29 29 #define ST7789V_RGBCTRL_HSYNC_HIGH BIT(2) 30 30 #define ST7789V_RGBCTRL_PCLK_HIGH BIT(1) 31 + #define ST7789V_RGBCTRL_DE_LOW BIT(0) 31 32 #define ST7789V_RGBCTRL_VBP(n) ((n) & 0x7f) 32 33 #define ST7789V_RGBCTRL_HBP(n) ((n) & 0x1f) 33 34 ··· 113 112 struct st7789_panel_info { 114 113 const struct drm_display_mode *mode; 115 114 u32 bus_format; 115 + u32 bus_flags; 116 116 bool invert_mode; 117 117 }; 118 118 ··· 170 168 .vtotal = 320 + 8 + 4 + 4, 171 169 .width_mm = 61, 172 170 .height_mm = 103, 171 + .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC, 173 172 }; 174 173 175 174 static const struct st7789_panel_info default_panel = { 176 175 .mode = &default_mode, 177 176 .invert_mode = true, 178 177 .bus_format = MEDIA_BUS_FMT_RGB666_1X18, 178 + .bus_flags = DRM_BUS_FLAG_DE_HIGH | 179 + DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE, 179 180 }; 180 181 181 182 static int st7789v_get_modes(struct drm_panel *panel, ··· 203 198 connector->display_info.bpc = 6; 204 199 connector->display_info.width_mm = ctx->info->mode->width_mm; 205 200 connector->display_info.height_mm = ctx->info->mode->height_mm; 201 + connector->display_info.bus_flags = ctx->info->bus_flags; 206 202 drm_display_info_set_bus_formats(&connector->display_info, 207 203 &ctx->info->bus_format, 1); 208 204 ··· 213 207 static int st7789v_prepare(struct drm_panel *panel) 214 208 { 215 209 struct st7789v *ctx = panel_to_st7789v(panel); 216 - u8 pixel_fmt; 210 + u8 pixel_fmt, polarity; 217 211 int ret; 218 212 219 213 switch (ctx->info->bus_format) { ··· 230 224 } 231 225 232 226 pixel_fmt = (pixel_fmt << 4) | pixel_fmt; 227 + 228 + polarity = 0; 229 + if (ctx->info->mode->flags & DRM_MODE_FLAG_PVSYNC) 230 + polarity |= ST7789V_RGBCTRL_VSYNC_HIGH; 231 + if (ctx->info->mode->flags & DRM_MODE_FLAG_PHSYNC) 232 + polarity |= ST7789V_RGBCTRL_HSYNC_HIGH; 233 + if (ctx->info->bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE) 234 + polarity |= ST7789V_RGBCTRL_PCLK_HIGH; 235 + if (ctx->info->bus_flags & DRM_BUS_FLAG_DE_LOW) 236 + polarity |= ST7789V_RGBCTRL_DE_LOW; 233 237 234 238 ret = regulator_enable(ctx->power); 235 239 if (ret) ··· 356 340 ST7789V_TEST(ret, st7789v_write_command(ctx, ST7789V_RGBCTRL_CMD)); 357 341 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_WO | 358 342 ST7789V_RGBCTRL_RCM(2) | 359 - ST7789V_RGBCTRL_VSYNC_HIGH | 360 - ST7789V_RGBCTRL_HSYNC_HIGH | 361 - ST7789V_RGBCTRL_PCLK_HIGH)); 343 + polarity)); 362 344 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_VBP(8))); 363 345 ST7789V_TEST(ret, st7789v_write_data(ctx, ST7789V_RGBCTRL_HBP(20))); 364 346