Skip to content

Commit 85a359f

Browse files
tom3qMark Yao
authored and
Mark Yao
committed
drm/rockchip: Add BGR formats to VOP
VOP can support BGR formats in all windows thanks to red/blue swap option provided in WINx_CTRL0 registers. This patch enables support for ABGR8888, XBGR8888, BGR888 and BGR565 formats by using this feature. Signed-off-by: Tomasz Figa <[email protected]>
1 parent c5fd936 commit 85a359f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/gpu/drm/rockchip/rockchip_drm_vop.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct vop_win_phy {
169169

170170
struct vop_reg enable;
171171
struct vop_reg format;
172+
struct vop_reg rb_swap;
172173
struct vop_reg act_info;
173174
struct vop_reg dsp_info;
174175
struct vop_reg dsp_st;
@@ -198,8 +199,12 @@ struct vop_data {
198199
static const uint32_t formats_01[] = {
199200
DRM_FORMAT_XRGB8888,
200201
DRM_FORMAT_ARGB8888,
202+
DRM_FORMAT_XBGR8888,
203+
DRM_FORMAT_ABGR8888,
201204
DRM_FORMAT_RGB888,
205+
DRM_FORMAT_BGR888,
202206
DRM_FORMAT_RGB565,
207+
DRM_FORMAT_BGR565,
203208
DRM_FORMAT_NV12,
204209
DRM_FORMAT_NV16,
205210
DRM_FORMAT_NV24,
@@ -208,15 +213,20 @@ static const uint32_t formats_01[] = {
208213
static const uint32_t formats_234[] = {
209214
DRM_FORMAT_XRGB8888,
210215
DRM_FORMAT_ARGB8888,
216+
DRM_FORMAT_XBGR8888,
217+
DRM_FORMAT_ABGR8888,
211218
DRM_FORMAT_RGB888,
219+
DRM_FORMAT_BGR888,
212220
DRM_FORMAT_RGB565,
221+
DRM_FORMAT_BGR565,
213222
};
214223

215224
static const struct vop_win_phy win01_data = {
216225
.data_formats = formats_01,
217226
.nformats = ARRAY_SIZE(formats_01),
218227
.enable = VOP_REG(WIN0_CTRL0, 0x1, 0),
219228
.format = VOP_REG(WIN0_CTRL0, 0x7, 1),
229+
.rb_swap = VOP_REG(WIN0_CTRL0, 0x1, 12),
220230
.act_info = VOP_REG(WIN0_ACT_INFO, 0x1fff1fff, 0),
221231
.dsp_info = VOP_REG(WIN0_DSP_INFO, 0x0fff0fff, 0),
222232
.dsp_st = VOP_REG(WIN0_DSP_ST, 0x1fff1fff, 0),
@@ -233,6 +243,7 @@ static const struct vop_win_phy win23_data = {
233243
.nformats = ARRAY_SIZE(formats_234),
234244
.enable = VOP_REG(WIN2_CTRL0, 0x1, 0),
235245
.format = VOP_REG(WIN2_CTRL0, 0x7, 1),
246+
.rb_swap = VOP_REG(WIN2_CTRL0, 0x1, 12),
236247
.dsp_info = VOP_REG(WIN2_DSP_INFO0, 0x0fff0fff, 0),
237248
.dsp_st = VOP_REG(WIN2_DSP_ST0, 0x1fff1fff, 0),
238249
.yrgb_mst = VOP_REG(WIN2_MST0, 0xffffffff, 0),
@@ -246,6 +257,7 @@ static const struct vop_win_phy cursor_data = {
246257
.nformats = ARRAY_SIZE(formats_234),
247258
.enable = VOP_REG(HWC_CTRL0, 0x1, 0),
248259
.format = VOP_REG(HWC_CTRL0, 0x7, 1),
260+
.rb_swap = VOP_REG(HWC_CTRL0, 0x1, 12),
249261
.dsp_st = VOP_REG(HWC_DSP_ST, 0x1fff1fff, 0),
250262
.yrgb_mst = VOP_REG(HWC_MST, 0xffffffff, 0),
251263
};
@@ -351,15 +363,32 @@ static inline void vop_mask_write_relaxed(struct vop *vop, uint32_t offset,
351363
}
352364
}
353365

366+
static bool has_rb_swapped(uint32_t format)
367+
{
368+
switch (format) {
369+
case DRM_FORMAT_XBGR8888:
370+
case DRM_FORMAT_ABGR8888:
371+
case DRM_FORMAT_BGR888:
372+
case DRM_FORMAT_BGR565:
373+
return true;
374+
default:
375+
return false;
376+
}
377+
}
378+
354379
static enum vop_data_format vop_convert_format(uint32_t format)
355380
{
356381
switch (format) {
357382
case DRM_FORMAT_XRGB8888:
358383
case DRM_FORMAT_ARGB8888:
384+
case DRM_FORMAT_XBGR8888:
385+
case DRM_FORMAT_ABGR8888:
359386
return VOP_FMT_ARGB8888;
360387
case DRM_FORMAT_RGB888:
388+
case DRM_FORMAT_BGR888:
361389
return VOP_FMT_RGB888;
362390
case DRM_FORMAT_RGB565:
391+
case DRM_FORMAT_BGR565:
363392
return VOP_FMT_RGB565;
364393
case DRM_FORMAT_NV12:
365394
return VOP_FMT_YUV420SP;
@@ -377,6 +406,7 @@ static bool is_alpha_support(uint32_t format)
377406
{
378407
switch (format) {
379408
case DRM_FORMAT_ARGB8888:
409+
case DRM_FORMAT_ABGR8888:
380410
return true;
381411
default:
382412
return false;
@@ -587,6 +617,7 @@ static int vop_update_plane_event(struct drm_plane *plane,
587617
enum vop_data_format format;
588618
uint32_t val;
589619
bool is_alpha;
620+
bool rb_swap;
590621
bool visible;
591622
int ret;
592623
struct drm_rect dest = {
@@ -620,6 +651,7 @@ static int vop_update_plane_event(struct drm_plane *plane,
620651
return 0;
621652

622653
is_alpha = is_alpha_support(fb->pixel_format);
654+
rb_swap = has_rb_swapped(fb->pixel_format);
623655
format = vop_convert_format(fb->pixel_format);
624656
if (format < 0)
625657
return format;
@@ -688,6 +720,7 @@ static int vop_update_plane_event(struct drm_plane *plane,
688720
val = (dsp_sty - 1) << 16;
689721
val |= (dsp_stx - 1) & 0xffff;
690722
VOP_WIN_SET(vop, win, dsp_st, val);
723+
VOP_WIN_SET(vop, win, rb_swap, rb_swap);
691724

692725
if (is_alpha) {
693726
VOP_WIN_SET(vop, win, dst_alpha_ctl,

0 commit comments

Comments
 (0)