Skip to content

Commit dcf496a

Browse files
paulkocialkowskimripard
authored andcommitted
drm/sun4i: sun4i: Introduce a quirk for lowest plane alpha support
Not all sunxi platforms with the first version of the Display Engine support an alpha component on the plane with the lowest z position (as in: lowest z-pos), that gets blended with the background color. In particular, the A13 is known to have this limitation. However, it was recently discovered that the A20 and A33 are capable of having alpha on their lowest plane. Thus, this introduces a specific quirk to indicate such support, per-platform. Since this was not tested on sun4i and sun6i platforms, a conservative approach is kept and this feature is not supported. Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180719080838.31598-2-paul.kocialkowski@bootlin.com
1 parent e527cd9 commit dcf496a

2 files changed

Lines changed: 28 additions & 15 deletions

File tree

‎drivers/gpu/drm/sun4i/sun4i_backend.c‎

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
struct sun4i_backend_quirks {
3535
/* backend <-> TCON muxing selection done in backend */
3636
bool needs_output_muxing;
37+
38+
/* alpha at the lowest z position is not always supported */
39+
bool supports_lowest_plane_alpha;
3740
};
3841

3942
static const u32 sunxi_rgb2yuv_coef[12] = {
@@ -457,12 +460,14 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
457460
struct drm_crtc_state *crtc_state)
458461
{
459462
struct drm_plane_state *plane_states[SUN4I_BACKEND_NUM_LAYERS] = { 0 };
463+
struct sun4i_backend *backend = engine_to_sun4i_backend(engine);
460464
struct drm_atomic_state *state = crtc_state->state;
461465
struct drm_device *drm = state->dev;
462466
struct drm_plane *plane;
463467
unsigned int num_planes = 0;
464468
unsigned int num_alpha_planes = 0;
465469
unsigned int num_frontend_planes = 0;
470+
unsigned int num_alpha_planes_max = 1;
466471
unsigned int num_yuv_planes = 0;
467472
unsigned int current_pipe = 0;
468473
unsigned int i;
@@ -526,33 +531,40 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine,
526531
* the layer with the highest priority.
527532
*
528533
* The second step is the actual alpha blending, that takes
529-
* the two pipes as input, and uses the eventual alpha
534+
* the two pipes as input, and uses the potential alpha
530535
* component to do the transparency between the two.
531536
*
532-
* This two steps scenario makes us unable to guarantee a
537+
* This two-step scenario makes us unable to guarantee a
533538
* robust alpha blending between the 4 layers in all
534539
* situations, since this means that we need to have one layer
535540
* with alpha at the lowest position of our two pipes.
536541
*
537-
* However, we cannot even do that, since the hardware has a
538-
* bug where the lowest plane of the lowest pipe (pipe 0,
539-
* priority 0), if it has any alpha, will discard the pixel
540-
* entirely and just display the pixels in the background
541-
* color (black by default).
542+
* However, we cannot even do that on every platform, since
543+
* the hardware has a bug where the lowest plane of the lowest
544+
* pipe (pipe 0, priority 0), if it has any alpha, will
545+
* discard the pixel data entirely and just display the pixels
546+
* in the background color (black by default).
542547
*
543-
* This means that we effectively have only three valid
544-
* configurations with alpha, all of them with the alpha being
545-
* on pipe1 with the lowest position, which can be 1, 2 or 3
546-
* depending on the number of planes and their zpos.
548+
* This means that on the affected platforms, we effectively
549+
* have only three valid configurations with alpha, all of
550+
* them with the alpha being on pipe1 with the lowest
551+
* position, which can be 1, 2 or 3 depending on the number of
552+
* planes and their zpos.
547553
*/
548-
if (num_alpha_planes > SUN4I_BACKEND_NUM_ALPHA_LAYERS) {
554+
555+
/* For platforms that are not affected by the issue described above. */
556+
if (backend->quirks->supports_lowest_plane_alpha)
557+
num_alpha_planes_max++;
558+
559+
if (num_alpha_planes > num_alpha_planes_max) {
549560
DRM_DEBUG_DRIVER("Too many planes with alpha, rejecting...\n");
550561
return -EINVAL;
551562
}
552563

553564
/* We can't have an alpha plane at the lowest position */
554-
if (plane_states[0]->fb->format->has_alpha ||
555-
(plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE))
565+
if (!backend->quirks->supports_lowest_plane_alpha &&
566+
(plane_states[0]->fb->format->has_alpha ||
567+
(plane_states[0]->alpha != DRM_BLEND_ALPHA_OPAQUE)))
556568
return -EINVAL;
557569

558570
for (i = 1; i < num_planes; i++) {
@@ -937,9 +949,11 @@ static const struct sun4i_backend_quirks sun6i_backend_quirks = {
937949

938950
static const struct sun4i_backend_quirks sun7i_backend_quirks = {
939951
.needs_output_muxing = true,
952+
.supports_lowest_plane_alpha = true,
940953
};
941954

942955
static const struct sun4i_backend_quirks sun8i_a33_backend_quirks = {
956+
.supports_lowest_plane_alpha = true,
943957
};
944958

945959
static const struct sun4i_backend_quirks sun9i_backend_quirks = {

‎drivers/gpu/drm/sun4i/sun4i_backend.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@
167167
#define SUN4I_BACKEND_PIPE_OFF(p) (0x5000 + (0x400 * (p)))
168168

169169
#define SUN4I_BACKEND_NUM_LAYERS 4
170-
#define SUN4I_BACKEND_NUM_ALPHA_LAYERS 1
171170
#define SUN4I_BACKEND_NUM_FRONTEND_LAYERS 1
172171
#define SUN4I_BACKEND_NUM_YUV_PLANES 1
173172

0 commit comments

Comments
 (0)