Skip to content

Commit 2d684f4

Browse files
Vicioussdaeinki
authored andcommitted
drm/exynos: fimd: add BGR support for exynos4/5
In the downstream kernels for exynos4 and exynos5 devices, there is an undocumented register that controls the order of the RGB output. It can be set to either normal order or reversed, which enables BGR support for those SoCs. This patch enables the BGR support for all the SoCs that were found to have at least one device with this logic in the corresponding downstream kernels. Signed-off-by: Martin Jücker <martin.juecker@gmail.com> Signed-off-by: Inki Dae <inki.dae@samsung.com>
1 parent fedc898 commit 2d684f4

2 files changed

Lines changed: 44 additions & 2 deletions

File tree

drivers/gpu/drm/exynos/exynos_drm_fimd.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ struct fimd_driver_data {
109109
unsigned int has_dp_clk:1;
110110
unsigned int has_hw_trigger:1;
111111
unsigned int has_trigger_per_te:1;
112+
unsigned int has_bgr_support:1;
112113
};
113114

114115
static struct fimd_driver_data s3c64xx_fimd_driver_data = {
@@ -138,6 +139,7 @@ static struct fimd_driver_data exynos4_fimd_driver_data = {
138139
.lcdblk_bypass_shift = 1,
139140
.has_shadowcon = 1,
140141
.has_vtsel = 1,
142+
.has_bgr_support = 1,
141143
};
142144

143145
static struct fimd_driver_data exynos5_fimd_driver_data = {
@@ -149,6 +151,7 @@ static struct fimd_driver_data exynos5_fimd_driver_data = {
149151
.has_vidoutcon = 1,
150152
.has_vtsel = 1,
151153
.has_dp_clk = 1,
154+
.has_bgr_support = 1,
152155
};
153156

154157
static struct fimd_driver_data exynos5420_fimd_driver_data = {
@@ -162,6 +165,7 @@ static struct fimd_driver_data exynos5420_fimd_driver_data = {
162165
.has_vtsel = 1,
163166
.has_mic_bypass = 1,
164167
.has_dp_clk = 1,
168+
.has_bgr_support = 1,
165169
};
166170

167171
struct fimd_context {
@@ -226,6 +230,18 @@ static const uint32_t fimd_formats[] = {
226230
DRM_FORMAT_ARGB8888,
227231
};
228232

233+
static const uint32_t fimd_extended_formats[] = {
234+
DRM_FORMAT_C8,
235+
DRM_FORMAT_XRGB1555,
236+
DRM_FORMAT_XBGR1555,
237+
DRM_FORMAT_RGB565,
238+
DRM_FORMAT_BGR565,
239+
DRM_FORMAT_XRGB8888,
240+
DRM_FORMAT_XBGR8888,
241+
DRM_FORMAT_ARGB8888,
242+
DRM_FORMAT_ABGR8888,
243+
};
244+
229245
static const unsigned int capabilities[WINDOWS_NR] = {
230246
0,
231247
EXYNOS_DRM_PLANE_CAP_WIN_BLEND | EXYNOS_DRM_PLANE_CAP_PIX_BLEND,
@@ -673,28 +689,44 @@ static void fimd_win_set_pixfmt(struct fimd_context *ctx, unsigned int win,
673689
val |= WINCONx_BYTSWP;
674690
break;
675691
case DRM_FORMAT_XRGB1555:
692+
case DRM_FORMAT_XBGR1555:
676693
val |= WINCON0_BPPMODE_16BPP_1555;
677694
val |= WINCONx_HAWSWP;
678695
val |= WINCONx_BURSTLEN_16WORD;
679696
break;
680697
case DRM_FORMAT_RGB565:
698+
case DRM_FORMAT_BGR565:
681699
val |= WINCON0_BPPMODE_16BPP_565;
682700
val |= WINCONx_HAWSWP;
683701
val |= WINCONx_BURSTLEN_16WORD;
684702
break;
685703
case DRM_FORMAT_XRGB8888:
704+
case DRM_FORMAT_XBGR8888:
686705
val |= WINCON0_BPPMODE_24BPP_888;
687706
val |= WINCONx_WSWP;
688707
val |= WINCONx_BURSTLEN_16WORD;
689708
break;
690709
case DRM_FORMAT_ARGB8888:
710+
case DRM_FORMAT_ABGR8888:
691711
default:
692712
val |= WINCON1_BPPMODE_25BPP_A1888;
693713
val |= WINCONx_WSWP;
694714
val |= WINCONx_BURSTLEN_16WORD;
695715
break;
696716
}
697717

718+
switch (pixel_format) {
719+
case DRM_FORMAT_XBGR1555:
720+
case DRM_FORMAT_XBGR8888:
721+
case DRM_FORMAT_ABGR8888:
722+
case DRM_FORMAT_BGR565:
723+
writel(WIN_RGB_ORDER_REVERSE, ctx->regs + WIN_RGB_ORDER(win));
724+
break;
725+
default:
726+
writel(WIN_RGB_ORDER_FORWARD, ctx->regs + WIN_RGB_ORDER(win));
727+
break;
728+
}
729+
698730
/*
699731
* Setting dma-burst to 16Word causes permanent tearing for very small
700732
* buffers, e.g. cursor buffer. Burst Mode switching which based on
@@ -1074,8 +1106,14 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
10741106
ctx->drm_dev = drm_dev;
10751107

10761108
for (i = 0; i < WINDOWS_NR; i++) {
1077-
ctx->configs[i].pixel_formats = fimd_formats;
1078-
ctx->configs[i].num_pixel_formats = ARRAY_SIZE(fimd_formats);
1109+
if (ctx->driver_data->has_bgr_support) {
1110+
ctx->configs[i].pixel_formats = fimd_extended_formats;
1111+
ctx->configs[i].num_pixel_formats = ARRAY_SIZE(fimd_extended_formats);
1112+
} else {
1113+
ctx->configs[i].pixel_formats = fimd_formats;
1114+
ctx->configs[i].num_pixel_formats = ARRAY_SIZE(fimd_formats);
1115+
}
1116+
10791117
ctx->configs[i].zpos = i;
10801118
ctx->configs[i].type = fimd_win_types[i];
10811119
ctx->configs[i].capabilities = capabilities[i];

include/video/samsung_fimd.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,10 @@
476476
* 1111 -none- -none- -none- -none- -none-
477477
*/
478478

479+
#define WIN_RGB_ORDER(_win) (0x2020 + ((_win) * 4))
480+
#define WIN_RGB_ORDER_FORWARD (0 << 11)
481+
#define WIN_RGB_ORDER_REVERSE (1 << 11)
482+
479483
/* FIMD Version 8 register offset definitions */
480484
#define FIMD_V8_VIDTCON0 0x20010
481485
#define FIMD_V8_VIDTCON1 0x20014

0 commit comments

Comments
 (0)