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

drm/bridge: tc358762: Handle HS/VS polarity

Add support for handling the HS/VS sync signals polarity in the bridge
driver, otherwise e.g. DSIM bridge feeds the TC358762 inverted polarity
sync signals and the image is shifted to the left, up, and wobbly.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Robert Foss <rfoss@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20230615201902.566182-5-marex@denx.de

authored by

Marek Vasut and committed by
Robert Foss
7f4e171f 80382226

+25 -2
+25 -2
drivers/gpu/drm/bridge/tc358762.c
··· 74 74 struct regulator *regulator; 75 75 struct drm_bridge *panel_bridge; 76 76 struct gpio_desc *reset_gpio; 77 + struct drm_display_mode mode; 77 78 bool pre_enabled; 78 79 int error; 79 80 }; ··· 115 114 116 115 static int tc358762_init(struct tc358762 *ctx) 117 116 { 117 + u32 lcdctrl; 118 + 118 119 tc358762_write(ctx, DSI_LANEENABLE, 119 120 LANEENABLE_L0EN | LANEENABLE_CLEN); 120 121 tc358762_write(ctx, PPI_D0S_CLRSIPOCOUNT, 5); ··· 126 123 tc358762_write(ctx, PPI_LPTXTIMECNT, LPX_PERIOD); 127 124 128 125 tc358762_write(ctx, SPICMR, 0x00); 129 - tc358762_write(ctx, LCDCTRL, LCDCTRL_VSDELAY(1) | LCDCTRL_RGB888 | 130 - LCDCTRL_UNK6 | LCDCTRL_VTGEN); 126 + 127 + lcdctrl = LCDCTRL_VSDELAY(1) | LCDCTRL_RGB888 | 128 + LCDCTRL_UNK6 | LCDCTRL_VTGEN; 129 + 130 + if (ctx->mode.flags & DRM_MODE_FLAG_NHSYNC) 131 + lcdctrl |= LCDCTRL_HSPOL; 132 + 133 + if (ctx->mode.flags & DRM_MODE_FLAG_NVSYNC) 134 + lcdctrl |= LCDCTRL_VSPOL; 135 + 136 + tc358762_write(ctx, LCDCTRL, lcdctrl); 137 + 131 138 tc358762_write(ctx, SYSCTRL, 0x040f); 132 139 msleep(100); 133 140 ··· 207 194 bridge, flags); 208 195 } 209 196 197 + static void tc358762_bridge_mode_set(struct drm_bridge *bridge, 198 + const struct drm_display_mode *mode, 199 + const struct drm_display_mode *adj) 200 + { 201 + struct tc358762 *ctx = bridge_to_tc358762(bridge); 202 + 203 + drm_mode_copy(&ctx->mode, mode); 204 + } 205 + 210 206 static const struct drm_bridge_funcs tc358762_bridge_funcs = { 211 207 .atomic_post_disable = tc358762_post_disable, 212 208 .atomic_pre_enable = tc358762_pre_enable, ··· 224 202 .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, 225 203 .atomic_reset = drm_atomic_helper_bridge_reset, 226 204 .attach = tc358762_attach, 205 + .mode_set = tc358762_bridge_mode_set, 227 206 }; 228 207 229 208 static int tc358762_parse_dt(struct tc358762 *ctx)