Skip to content

Commit 9868c20

Browse files
committed
drm/vc4: crtc: Add support for a custom background color
Since a previous patch introduced the BACKGROUND_COLOR CRTC property, which defaults to solid black, take it into account when programming the hardware. The exact registers used varies between the hardware generations, but is supported by all of them. Signed-off-by: Dave Stevenson <[email protected]>
1 parent 45643f5 commit 9868c20

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

drivers/gpu/drm/vc4/vc4_crtc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <drm/drm_atomic.h>
3939
#include <drm/drm_atomic_helper.h>
4040
#include <drm/drm_atomic_uapi.h>
41+
#include <drm/drm_blend.h>
4142
#include <drm/drm_fb_dma_helper.h>
4243
#include <drm/drm_framebuffer.h>
4344
#include <drm/drm_drv.h>
@@ -1437,6 +1438,8 @@ int __vc4_crtc_init(struct drm_device *drm,
14371438
if (ret)
14381439
return ret;
14391440

1441+
drm_crtc_attach_background_color_property(crtc);
1442+
14401443
drm_crtc_helper_add(crtc, crtc_helper_funcs);
14411444

14421445
if (vc4->gen == VC4_GEN_4) {

drivers/gpu/drm/vc4/vc4_hvs.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
12561256
struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
12571257
struct vc4_crtc_state *vc4_state = to_vc4_crtc_state(crtc->state);
12581258
unsigned int channel = vc4_state->assigned_channel;
1259+
u64 bgcolor = crtc->state->background_color;
12591260
struct drm_plane *plane;
12601261
struct vc4_plane_state *vc4_plane_state;
12611262
bool debug_dump_regs = false;
@@ -1320,16 +1321,32 @@ void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
13201321
WARN_ON_ONCE(dlist_next - dlist_start != vc4_state->mm->mm_node.size);
13211322

13221323
if (vc4->gen >= VC4_GEN_6_C) {
1323-
/* This sets a black background color fill, as is the case
1324+
/* This sets the background color fill, as is the case
13241325
* with other DRM drivers.
13251326
*/
1327+
if (vc4->gen == VC4_GEN_6_C) {
1328+
HVS_WRITE(SCALER6_DISPX_BGND(channel),
1329+
((bgcolor & 0xFF0000000000) >> 24) |
1330+
((bgcolor & 0xFF000000) >> 16) |
1331+
((bgcolor & 0xFF00) >> 8));
1332+
} else {
1333+
/* GEN_6_D takes a 12bit background colour */
1334+
HVS_WRITE(SCALER6D_DISPX_BGND0(channel),
1335+
bgcolor & 0xFFF0FFF0);
1336+
HVS_WRITE(SCALER6D_DISPX_BGND1(channel),
1337+
(bgcolor >> 32) & 0xFFF0);
1338+
}
13261339
hvs->bg_fill[channel] = enable_bg_fill;
13271340
} else {
13281341
/* we can actually run with a lower core clock when background
13291342
* fill is enabled on VC4_GEN_5 so leave it enabled always.
13301343
*/
13311344
HVS_WRITE(SCALER_DISPBKGNDX(channel),
1332-
HVS_READ(SCALER_DISPBKGNDX(channel)) |
1345+
(HVS_READ(SCALER_DISPBKGNDX(channel)) &
1346+
~SCALER_DISPBKGND_FILL_COLOUR) |
1347+
((bgcolor & 0xFF0000000000) >> 24) |
1348+
((bgcolor & 0xFF000000) >> 16) |
1349+
((bgcolor & 0xFF00) >> 8) |
13331350
SCALER_DISPBKGND_FILL);
13341351
}
13351352

drivers/gpu/drm/vc4/vc4_regs.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@
402402
* opaque display planes will cover everything.
403403
*/
404404
# define SCALER_DISPBKGND_FILL BIT(24)
405+
# define SCALER_DISPBKGND_FILL_COLOUR VC4_MASK(23, 0)
405406

406407
#define SCALER_DISPSTAT0 0x00000048
407408
# define SCALER_DISPSTATX_MODE_MASK VC4_MASK(31, 30)
@@ -580,9 +581,8 @@
580581
# define SCALER6_DISPX_CTRL1_INTLACE BIT(0)
581582

582583
#define SCALER6_DISP0_BGND 0x00000038
583-
#define SCALER6_DISPX_BGND(x) ((hvs->vc4->gen == VC4_GEN_6_C) ? \
584-
(SCALER6_DISP0_BGND + ((x) * (SCALER6_DISP1_BGND - SCALER6_DISP0_BGND))) : \
585-
(SCALER6D_DISP0_BGND + ((x) * (SCALER6D_DISP1_BGND - SCALER6D_DISP0_BGND))))
584+
#define SCALER6_DISPX_BGND(x) \
585+
(SCALER6_DISP0_BGND + ((x) * (SCALER6_DISP1_BGND - SCALER6_DISP0_BGND)))
586586

587587
#define SCALER6_DISP0_LPTRS 0x0000003c
588588
#define SCALER6_DISPX_LPTRS(x) ((hvs->vc4->gen == VC4_GEN_6_C) ? \
@@ -707,7 +707,11 @@
707707
#define SCALER6D_DISP0_CTRL0 0x00000100
708708
#define SCALER6D_DISP0_CTRL1 0x00000104
709709
#define SCALER6D_DISP0_BGND0 0x00000108
710+
#define SCALER6D_DISPX_BGND0(x) \
711+
(SCALER6D_DISP0_BGND0 + ((x) * (SCALER6D_DISP1_BGND0 - SCALER6D_DISP0_BGND0)))
710712
#define SCALER6D_DISP0_BGND1 0x0000010c
713+
#define SCALER6D_DISPX_BGND1(x) \
714+
(SCALER6D_DISP0_BGND1 + ((x) * (SCALER6D_DISP1_BGND1 - SCALER6D_DISP0_BGND1)))
711715
#define SCALER6D_DISP0_LPTRS 0x00000110
712716
#define SCALER6D_DISP0_COB 0x00000114
713717
#define SCALER6D_DISP0_STATUS 0x00000118

0 commit comments

Comments
 (0)