Skip to content

Commit 7907cf1

Browse files
jernejskwens
authored andcommitted
drm/sun4i: mixer: Convert heuristics to quirk
Determination if FCC unit can be used for VI layer alpha depends on number of VI channels. This info won't be available anymore in future to VI layer driver because of DE33 way of allocating planes from same pool to different mixers. While order is slightly changed, it doesn't affect anything due to double buffering of registers. New order keeps related registers together and quirk separate. Reviewed-by: Chen-Yu Tsai <wens@kernel.org> Tested-by: Ryan Walklin <ryan@testtoast.com> Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://patch.msgid.link/20251104180942.61538-25-jernej.skrabec@gmail.com Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
1 parent c0cbdda commit 7907cf1

3 files changed

Lines changed: 19 additions & 5 deletions

File tree

drivers/gpu/drm/sun4i/sun8i_mixer.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ static const struct sun8i_mixer_cfg sun8i_a83t_mixer0_cfg = {
708708
.de_type = SUN8I_MIXER_DE2,
709709
.scaler_mask = 0xf,
710710
.scanline_yuv = 2048,
711+
.de2_fcc_alpha = 1,
711712
.ui_num = 3,
712713
.vi_num = 1,
713714
};
@@ -717,6 +718,7 @@ static const struct sun8i_mixer_cfg sun8i_a83t_mixer1_cfg = {
717718
.de_type = SUN8I_MIXER_DE2,
718719
.scaler_mask = 0x3,
719720
.scanline_yuv = 2048,
721+
.de2_fcc_alpha = 1,
720722
.ui_num = 1,
721723
.vi_num = 1,
722724
};
@@ -727,6 +729,7 @@ static const struct sun8i_mixer_cfg sun8i_h3_mixer0_cfg = {
727729
.mod_rate = 432000000,
728730
.scaler_mask = 0xf,
729731
.scanline_yuv = 2048,
732+
.de2_fcc_alpha = 1,
730733
.ui_num = 3,
731734
.vi_num = 1,
732735
};
@@ -737,6 +740,7 @@ static const struct sun8i_mixer_cfg sun8i_r40_mixer0_cfg = {
737740
.mod_rate = 297000000,
738741
.scaler_mask = 0xf,
739742
.scanline_yuv = 2048,
743+
.de2_fcc_alpha = 1,
740744
.ui_num = 3,
741745
.vi_num = 1,
742746
};
@@ -747,6 +751,7 @@ static const struct sun8i_mixer_cfg sun8i_r40_mixer1_cfg = {
747751
.mod_rate = 297000000,
748752
.scaler_mask = 0x3,
749753
.scanline_yuv = 2048,
754+
.de2_fcc_alpha = 1,
750755
.ui_num = 1,
751756
.vi_num = 1,
752757
};
@@ -767,6 +772,7 @@ static const struct sun8i_mixer_cfg sun20i_d1_mixer0_cfg = {
767772
.mod_rate = 297000000,
768773
.scaler_mask = 0x3,
769774
.scanline_yuv = 2048,
775+
.de2_fcc_alpha = 1,
770776
.ui_num = 1,
771777
.vi_num = 1,
772778
};
@@ -777,6 +783,7 @@ static const struct sun8i_mixer_cfg sun20i_d1_mixer1_cfg = {
777783
.mod_rate = 297000000,
778784
.scaler_mask = 0x1,
779785
.scanline_yuv = 1024,
786+
.de2_fcc_alpha = 1,
780787
.ui_num = 0,
781788
.vi_num = 1,
782789
};
@@ -787,6 +794,7 @@ static const struct sun8i_mixer_cfg sun50i_a64_mixer0_cfg = {
787794
.mod_rate = 297000000,
788795
.scaler_mask = 0xf,
789796
.scanline_yuv = 4096,
797+
.de2_fcc_alpha = 1,
790798
.ui_num = 3,
791799
.vi_num = 1,
792800
};
@@ -797,6 +805,7 @@ static const struct sun8i_mixer_cfg sun50i_a64_mixer1_cfg = {
797805
.mod_rate = 297000000,
798806
.scaler_mask = 0x3,
799807
.scanline_yuv = 2048,
808+
.de2_fcc_alpha = 1,
800809
.ui_num = 1,
801810
.vi_num = 1,
802811
};

drivers/gpu/drm/sun4i/sun8i_mixer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ enum sun8i_mixer_type {
176176
* a functional block.
177177
* @de_type: sun8i_mixer_type enum representing the display engine generation.
178178
* @scaline_yuv: size of a scanline for VI scaler for YUV formats.
179+
* @de2_fcc_alpha: use FCC for missing DE2 VI alpha capability
180+
* Most DE2 cores has FCC. If number of VI planes is one, enable this.
179181
* @map: channel map for DE variants processing YUV separately (DE33)
180182
*/
181183
struct sun8i_mixer_cfg {
@@ -186,6 +188,7 @@ struct sun8i_mixer_cfg {
186188
unsigned long mod_rate;
187189
unsigned int de_type;
188190
unsigned int scanline_yuv;
191+
unsigned int de2_fcc_alpha : 1;
189192
unsigned int map[6];
190193
};
191194

drivers/gpu/drm/sun4i/sun8i_vi_layer.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ static void sun8i_vi_layer_update_attributes(struct sun8i_layer *layer,
4949
val |= (state->alpha == DRM_BLEND_ALPHA_OPAQUE) ?
5050
SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA_MODE_PIXEL :
5151
SUN50I_MIXER_CHAN_VI_LAYER_ATTR_ALPHA_MODE_COMBINED;
52-
} else if (mixer->cfg->vi_num == 1) {
53-
regmap_write(layer->regs,
54-
SUN8I_MIXER_FCC_GLOBAL_ALPHA_REG,
55-
SUN8I_MIXER_FCC_GLOBAL_ALPHA(state->alpha >> 8));
5652
}
5753

5854
regmap_write(layer->regs,
5955
SUN8I_MIXER_CHAN_VI_LAYER_ATTR(ch_base, layer->overlay), val);
56+
57+
if (mixer->cfg->de2_fcc_alpha) {
58+
regmap_write(layer->regs,
59+
SUN8I_MIXER_FCC_GLOBAL_ALPHA_REG,
60+
SUN8I_MIXER_FCC_GLOBAL_ALPHA(state->alpha >> 8));
61+
}
6062
}
6163

6264
static void sun8i_vi_layer_update_coord(struct sun8i_layer *layer,
@@ -450,7 +452,7 @@ struct sun8i_layer *sun8i_vi_layer_init_one(struct drm_device *drm,
450452
return ERR_PTR(ret);
451453
}
452454

453-
if (mixer->cfg->vi_num == 1 || mixer->cfg->de_type >= SUN8I_MIXER_DE3) {
455+
if (mixer->cfg->de2_fcc_alpha || mixer->cfg->de_type >= SUN8I_MIXER_DE3) {
454456
ret = drm_plane_create_alpha_property(&layer->plane);
455457
if (ret) {
456458
dev_err(drm->dev, "Couldn't add alpha property\n");

0 commit comments

Comments
 (0)