Message ID | 20180420230503.9629-1-stschake@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Stefan Schake <stschake@gmail.com> writes: > The HVS supports mixing fixed alpha with per-pixel alpha or > setting a fixed plane alpha in case there is no per-pixel information. > This allows us to support the generic DRM plane alpha property. Don't we need to set needs_bg_fill based on alpha != OPAQUE, as well? Other than that, looks good to me.
On Sat, Apr 21, 2018 at 1:45 AM, Eric Anholt <eric@anholt.net> wrote: > Stefan Schake <stschake@gmail.com> writes: > >> The HVS supports mixing fixed alpha with per-pixel alpha or >> setting a fixed plane alpha in case there is no per-pixel information. >> This allows us to support the generic DRM plane alpha property. > > Don't we need to set needs_bg_fill based on alpha != OPAQUE, as well? > > Other than that, looks good to me. I did forget about the whole background situation, and a quick test shows you are right: anything less than opaque has the funky repeating pattern artifact. Thanks, I'll send a new version.
Hi Stefan, Thank you for the patch! Yet something to improve: [auto build test ERROR on v4.17-rc1] [also build test ERROR on next-20180420] [cannot apply to anholt/for-next] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Stefan-Schake/drm-vc4-Add-support-for-plane-alpha/20180423-002110 config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=sh All errors (new ones prefixed by >>): drivers/gpu/drm/vc4/vc4_plane.c: In function 'vc4_plane_reset': >> drivers/gpu/drm/vc4/vc4_plane.c:204:14: error: 'struct drm_plane_state' has no member named 'alpha' plane->state->alpha = DRM_BLEND_ALPHA_OPAQUE; ^~ >> drivers/gpu/drm/vc4/vc4_plane.c:204:24: error: 'DRM_BLEND_ALPHA_OPAQUE' undeclared (first use in this function) plane->state->alpha = DRM_BLEND_ALPHA_OPAQUE; ^~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vc4/vc4_plane.c:204:24: note: each undeclared identifier is reported only once for each function it appears in In file included from drivers/gpu/drm/vc4/vc4_plane.c:28:0: drivers/gpu/drm/vc4/vc4_plane.c: In function 'vc4_plane_mode_set': drivers/gpu/drm/vc4/vc4_plane.c:557:23: error: 'struct drm_plane_state' has no member named 'alpha' VC4_SET_FIELD(state->alpha >> 8, SCALER_POS0_FIXED_ALPHA) | ^ drivers/gpu/drm/vc4/vc4_regs.h:18:24: note: in definition of macro 'VC4_SET_FIELD' uint32_t fieldval = (value) << field##_SHIFT; \ ^~~~~ drivers/gpu/drm/vc4/vc4_plane.c:574:25: error: 'struct drm_plane_state' has no member named 'alpha' mix_plane_alpha = state->alpha != DRM_BLEND_ALPHA_OPAQUE && ^~ drivers/gpu/drm/vc4/vc4_plane.c:574:36: error: 'DRM_BLEND_ALPHA_OPAQUE' undeclared (first use in this function) mix_plane_alpha = state->alpha != DRM_BLEND_ALPHA_OPAQUE && ^~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/vc4/vc4_plane.c: In function 'vc4_plane_init': >> drivers/gpu/drm/vc4/vc4_plane.c:952:2: error: implicit declaration of function 'drm_plane_create_alpha_property'; did you mean 'drm_plane_create_zpos_property'? [-Werror=implicit-function-declaration] drm_plane_create_alpha_property(plane); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drm_plane_create_zpos_property cc1: some warnings being treated as errors vim +204 drivers/gpu/drm/vc4/vc4_plane.c 191 192 /* Called during init to allocate the plane's atomic state. */ 193 static void vc4_plane_reset(struct drm_plane *plane) 194 { 195 struct vc4_plane_state *vc4_state; 196 197 WARN_ON(plane->state); 198 199 vc4_state = kzalloc(sizeof(*vc4_state), GFP_KERNEL); 200 if (!vc4_state) 201 return; 202 203 plane->state = &vc4_state->base; > 204 plane->state->alpha = DRM_BLEND_ALPHA_OPAQUE; 205 vc4_state->base.plane = plane; 206 } 207 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index c3a37a99e601..b06e0ec013c5 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c @@ -201,6 +201,7 @@ static void vc4_plane_reset(struct drm_plane *plane) return; plane->state = &vc4_state->base; + plane->state->alpha = DRM_BLEND_ALPHA_OPAQUE; vc4_state->base.plane = plane; } @@ -467,6 +468,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane, u32 ctl0_offset = vc4_state->dlist_count; const struct hvs_format *format = vc4_get_hvs_format(fb->format->format); int num_planes = drm_format_num_planes(format->drm); + bool mix_plane_alpha; bool covers_screen; u32 scl0, scl1, pitch0; u32 lbm_size, tiling; @@ -552,7 +554,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane, /* Position Word 0: Image Positions and Alpha Value */ vc4_state->pos0_offset = vc4_state->dlist_count; vc4_dlist_write(vc4_state, - VC4_SET_FIELD(0xff, SCALER_POS0_FIXED_ALPHA) | + VC4_SET_FIELD(state->alpha >> 8, SCALER_POS0_FIXED_ALPHA) | VC4_SET_FIELD(vc4_state->crtc_x, SCALER_POS0_START_X) | VC4_SET_FIELD(vc4_state->crtc_y, SCALER_POS0_START_Y)); @@ -565,6 +567,13 @@ static int vc4_plane_mode_set(struct drm_plane *plane, SCALER_POS1_SCL_HEIGHT)); } + /* Don't waste cycles mixing with plane alpha if the set alpha + * is opaque or there is no per-pixel alpha information. + * In any case we use the alpha property value as the fixed alpha. + */ + mix_plane_alpha = state->alpha != DRM_BLEND_ALPHA_OPAQUE && + fb->format->has_alpha; + /* Position Word 2: Source Image Size, Alpha */ vc4_state->pos2_offset = vc4_state->dlist_count; vc4_dlist_write(vc4_state, @@ -572,6 +581,7 @@ static int vc4_plane_mode_set(struct drm_plane *plane, SCALER_POS2_ALPHA_MODE_PIPELINE : SCALER_POS2_ALPHA_MODE_FIXED, SCALER_POS2_ALPHA_MODE) | + (mix_plane_alpha ? SCALER_POS2_ALPHA_MIX : 0) | (fb->format->has_alpha ? SCALER_POS2_ALPHA_PREMULT : 0) | VC4_SET_FIELD(vc4_state->src_w[0], SCALER_POS2_WIDTH) | VC4_SET_FIELD(vc4_state->src_h[0], SCALER_POS2_HEIGHT)); @@ -916,5 +926,7 @@ struct drm_plane *vc4_plane_init(struct drm_device *dev, drm_plane_helper_add(plane, &vc4_plane_helper_funcs); + drm_plane_create_alpha_property(plane); + return plane; } diff --git a/drivers/gpu/drm/vc4/vc4_regs.h b/drivers/gpu/drm/vc4/vc4_regs.h index 4af3e29d076a..d1fb6fec46eb 100644 --- a/drivers/gpu/drm/vc4/vc4_regs.h +++ b/drivers/gpu/drm/vc4/vc4_regs.h @@ -945,6 +945,7 @@ enum hvs_pixel_format { #define SCALER_POS2_ALPHA_MODE_FIXED_NONZERO 2 #define SCALER_POS2_ALPHA_MODE_FIXED_OVER_0x07 3 #define SCALER_POS2_ALPHA_PREMULT BIT(29) +#define SCALER_POS2_ALPHA_MIX BIT(28) #define SCALER_POS2_HEIGHT_MASK VC4_MASK(27, 16) #define SCALER_POS2_HEIGHT_SHIFT 16
The HVS supports mixing fixed alpha with per-pixel alpha or setting a fixed plane alpha in case there is no per-pixel information. This allows us to support the generic DRM plane alpha property. Signed-off-by: Stefan Schake <stschake@gmail.com> --- drivers/gpu/drm/vc4/vc4_plane.c | 14 +++++++++++++- drivers/gpu/drm/vc4/vc4_regs.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-)