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>
110
111
111
112
struct st7789_panel_info {
112
113
const struct drm_display_mode * mode ;
114
+ u32 bus_format ;
113
115
};
114
116
115
117
struct st7789v {
@@ -169,6 +171,7 @@ static const struct drm_display_mode default_mode = {
169
171
170
172
static const struct st7789_panel_info default_panel = {
171
173
.mode = & default_mode ,
174
+ .bus_format = MEDIA_BUS_FMT_RGB666_1X18 ,
172
175
};
173
176
174
177
static int st7789v_get_modes (struct drm_panel * panel ,
@@ -190,17 +193,36 @@ static int st7789v_get_modes(struct drm_panel *panel,
190
193
mode -> type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED ;
191
194
drm_mode_probed_add (connector , mode );
192
195
196
+ connector -> display_info .bpc = 6 ;
193
197
connector -> display_info .width_mm = ctx -> info -> mode -> width_mm ;
194
198
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 );
195
201
196
202
return 1 ;
197
203
}
198
204
199
205
static int st7789v_prepare (struct drm_panel * panel )
200
206
{
201
207
struct st7789v * ctx = panel_to_st7789v (panel );
208
+ u8 pixel_fmt ;
202
209
int ret ;
203
210
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
+
204
226
ret = regulator_enable (ctx -> power );
205
227
if (ret )
206
228
return ret ;
@@ -221,9 +243,7 @@ static int st7789v_prepare(struct drm_panel *panel)
221
243
222
244
ST7789V_TEST (ret , st7789v_write_command (ctx ,
223
245
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 ));
227
247
228
248
ST7789V_TEST (ret , st7789v_write_command (ctx , ST7789V_PORCTRL_CMD ));
229
249
ST7789V_TEST (ret , st7789v_write_data (ctx , 0xc ));
0 commit comments