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
112
113
struct st7789_panel_info {
113
114
const struct drm_display_mode * mode ;
114
115
u32 bus_format ;
116
+ u32 bus_flags ;
115
117
bool invert_mode ;
116
118
};
117
119
@@ -168,12 +170,15 @@ static const struct drm_display_mode default_mode = {
168
170
.vtotal = 320 + 8 + 4 + 4 ,
169
171
.width_mm = 61 ,
170
172
.height_mm = 103 ,
173
+ .flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC ,
171
174
};
172
175
173
176
static const struct st7789_panel_info default_panel = {
174
177
.mode = & default_mode ,
175
178
.invert_mode = true,
176
179
.bus_format = MEDIA_BUS_FMT_RGB666_1X18 ,
180
+ .bus_flags = DRM_BUS_FLAG_DE_HIGH |
181
+ DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE ,
177
182
};
178
183
179
184
static int st7789v_get_modes (struct drm_panel * panel ,
@@ -198,6 +203,7 @@ static int st7789v_get_modes(struct drm_panel *panel,
198
203
connector -> display_info .bpc = 6 ;
199
204
connector -> display_info .width_mm = ctx -> info -> mode -> width_mm ;
200
205
connector -> display_info .height_mm = ctx -> info -> mode -> height_mm ;
206
+ connector -> display_info .bus_flags = ctx -> info -> bus_flags ;
201
207
drm_display_info_set_bus_formats (& connector -> display_info ,
202
208
& ctx -> info -> bus_format , 1 );
203
209
@@ -207,7 +213,7 @@ static int st7789v_get_modes(struct drm_panel *panel,
207
213
static int st7789v_prepare (struct drm_panel * panel )
208
214
{
209
215
struct st7789v * ctx = panel_to_st7789v (panel );
210
- u8 pixel_fmt ;
216
+ u8 pixel_fmt , polarity ;
211
217
int ret ;
212
218
213
219
switch (ctx -> info -> bus_format ) {
@@ -225,6 +231,16 @@ static int st7789v_prepare(struct drm_panel *panel)
225
231
226
232
pixel_fmt = (pixel_fmt << 4 ) | pixel_fmt ;
227
233
234
+ polarity = 0 ;
235
+ if (ctx -> info -> mode -> flags & DRM_MODE_FLAG_PVSYNC )
236
+ polarity |= ST7789V_RGBCTRL_VSYNC_HIGH ;
237
+ if (ctx -> info -> mode -> flags & DRM_MODE_FLAG_PHSYNC )
238
+ polarity |= ST7789V_RGBCTRL_HSYNC_HIGH ;
239
+ if (ctx -> info -> bus_flags & DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE )
240
+ polarity |= ST7789V_RGBCTRL_PCLK_HIGH ;
241
+ if (ctx -> info -> bus_flags & DRM_BUS_FLAG_DE_LOW )
242
+ polarity |= ST7789V_RGBCTRL_DE_LOW ;
243
+
228
244
ret = regulator_enable (ctx -> power );
229
245
if (ret )
230
246
return ret ;
@@ -340,9 +356,7 @@ static int st7789v_prepare(struct drm_panel *panel)
340
356
ST7789V_TEST (ret , st7789v_write_command (ctx , ST7789V_RGBCTRL_CMD ));
341
357
ST7789V_TEST (ret , st7789v_write_data (ctx , ST7789V_RGBCTRL_WO |
342
358
ST7789V_RGBCTRL_RCM (2 ) |
343
- ST7789V_RGBCTRL_VSYNC_HIGH |
344
- ST7789V_RGBCTRL_HSYNC_HIGH |
345
- ST7789V_RGBCTRL_PCLK_HIGH ));
359
+ polarity ));
346
360
ST7789V_TEST (ret , st7789v_write_data (ctx , ST7789V_RGBCTRL_VBP (8 )));
347
361
ST7789V_TEST (ret , st7789v_write_data (ctx , ST7789V_RGBCTRL_HBP (20 )));
348
362
0 commit comments