|
34 | 34 | struct sun4i_backend_quirks { |
35 | 35 | /* backend <-> TCON muxing selection done in backend */ |
36 | 36 | bool needs_output_muxing; |
| 37 | + |
| 38 | + /* alpha at the lowest z position is not always supported */ |
| 39 | + bool supports_lowest_plane_alpha; |
37 | 40 | }; |
38 | 41 |
|
39 | 42 | static const u32 sunxi_rgb2yuv_coef[12] = { |
@@ -457,12 +460,14 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, |
457 | 460 | struct drm_crtc_state *crtc_state) |
458 | 461 | { |
459 | 462 | struct drm_plane_state *plane_states[SUN4I_BACKEND_NUM_LAYERS] = { 0 }; |
| 463 | + struct sun4i_backend *backend = engine_to_sun4i_backend(engine); |
460 | 464 | struct drm_atomic_state *state = crtc_state->state; |
461 | 465 | struct drm_device *drm = state->dev; |
462 | 466 | struct drm_plane *plane; |
463 | 467 | unsigned int num_planes = 0; |
464 | 468 | unsigned int num_alpha_planes = 0; |
465 | 469 | unsigned int num_frontend_planes = 0; |
| 470 | + unsigned int num_alpha_planes_max = 1; |
466 | 471 | unsigned int num_yuv_planes = 0; |
467 | 472 | unsigned int current_pipe = 0; |
468 | 473 | unsigned int i; |
@@ -526,33 +531,40 @@ static int sun4i_backend_atomic_check(struct sunxi_engine *engine, |
526 | 531 | * the layer with the highest priority. |
527 | 532 | * |
528 | 533 | * 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 |
530 | 535 | * component to do the transparency between the two. |
531 | 536 | * |
532 | | - * This two steps scenario makes us unable to guarantee a |
| 537 | + * This two-step scenario makes us unable to guarantee a |
533 | 538 | * robust alpha blending between the 4 layers in all |
534 | 539 | * situations, since this means that we need to have one layer |
535 | 540 | * with alpha at the lowest position of our two pipes. |
536 | 541 | * |
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). |
542 | 547 | * |
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. |
547 | 553 | */ |
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) { |
549 | 560 | DRM_DEBUG_DRIVER("Too many planes with alpha, rejecting...\n"); |
550 | 561 | return -EINVAL; |
551 | 562 | } |
552 | 563 |
|
553 | 564 | /* 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))) |
556 | 568 | return -EINVAL; |
557 | 569 |
|
558 | 570 | for (i = 1; i < num_planes; i++) { |
@@ -937,9 +949,11 @@ static const struct sun4i_backend_quirks sun6i_backend_quirks = { |
937 | 949 |
|
938 | 950 | static const struct sun4i_backend_quirks sun7i_backend_quirks = { |
939 | 951 | .needs_output_muxing = true, |
| 952 | + .supports_lowest_plane_alpha = true, |
940 | 953 | }; |
941 | 954 |
|
942 | 955 | static const struct sun4i_backend_quirks sun8i_a33_backend_quirks = { |
| 956 | + .supports_lowest_plane_alpha = true, |
943 | 957 | }; |
944 | 958 |
|
945 | 959 | static const struct sun4i_backend_quirks sun9i_backend_quirks = { |
|
0 commit comments