Skip to content

Commit e6411bf

Browse files
Jason-JH.LinChun-Kuang Hu
authored andcommitted
drm/mediatek: Add blend_modes to mtk_plane_init() for different SoCs
Since some SoCs support premultiplied pixel formats but some do not, the blend_modes parameter is added to mtk_plane_init(), which is obtained from the mtk_ddp_comp_get_blend_modes function implemented in different blending supported components. The blending supported components can use driver data to set the blend mode capabilities for different SoCs. Signed-off-by: Jason-JH.Lin <[email protected]> Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Reviewed-by: CK Hu <[email protected]> Link: https://patchwork.kernel.org/project/dri-devel/patch/[email protected]/ Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent 333ab43 commit e6411bf

File tree

10 files changed

+46
-10
lines changed

10 files changed

+46
-10
lines changed

drivers/gpu/drm/mediatek/mtk_crtc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ static int mtk_crtc_init_comp_planes(struct drm_device *drm_dev,
913913
BIT(pipe),
914914
mtk_crtc_plane_type(mtk_crtc->layer_nr, num_planes),
915915
mtk_ddp_comp_supported_rotations(comp),
916+
mtk_ddp_comp_get_blend_modes(comp),
916917
mtk_ddp_comp_get_formats(comp),
917918
mtk_ddp_comp_get_num_formats(comp), i);
918919
if (ret)

drivers/gpu/drm/mediatek/mtk_ddp_comp.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl = {
363363
.layer_config = mtk_ovl_layer_config,
364364
.bgclr_in_on = mtk_ovl_bgclr_in_on,
365365
.bgclr_in_off = mtk_ovl_bgclr_in_off,
366+
.get_blend_modes = mtk_ovl_get_blend_modes,
366367
.get_formats = mtk_ovl_get_formats,
367368
.get_num_formats = mtk_ovl_get_num_formats,
368369
};
@@ -416,6 +417,7 @@ static const struct mtk_ddp_comp_funcs ddp_ovl_adaptor = {
416417
.disconnect = mtk_ovl_adaptor_disconnect,
417418
.add = mtk_ovl_adaptor_add_comp,
418419
.remove = mtk_ovl_adaptor_remove_comp,
420+
.get_blend_modes = mtk_ovl_adaptor_get_blend_modes,
419421
.get_formats = mtk_ovl_adaptor_get_formats,
420422
.get_num_formats = mtk_ovl_adaptor_get_num_formats,
421423
.mode_valid = mtk_ovl_adaptor_mode_valid,

drivers/gpu/drm/mediatek/mtk_ddp_comp.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct mtk_ddp_comp_funcs {
8080
void (*ctm_set)(struct device *dev,
8181
struct drm_crtc_state *state);
8282
struct device * (*dma_dev_get)(struct device *dev);
83+
u32 (*get_blend_modes)(struct device *dev);
8384
const u32 *(*get_formats)(struct device *dev);
8485
size_t (*get_num_formats)(struct device *dev);
8586
void (*connect)(struct device *dev, struct device *mmsys_dev, unsigned int next);
@@ -266,6 +267,15 @@ static inline struct device *mtk_ddp_comp_dma_dev_get(struct mtk_ddp_comp *comp)
266267
return comp->dev;
267268
}
268269

270+
static inline
271+
u32 mtk_ddp_comp_get_blend_modes(struct mtk_ddp_comp *comp)
272+
{
273+
if (comp->funcs && comp->funcs->get_blend_modes)
274+
return comp->funcs->get_blend_modes(comp->dev);
275+
276+
return 0;
277+
}
278+
269279
static inline
270280
const u32 *mtk_ddp_comp_get_formats(struct mtk_ddp_comp *comp)
271281
{

drivers/gpu/drm/mediatek/mtk_disp_drv.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ void mtk_ovl_register_vblank_cb(struct device *dev,
103103
void mtk_ovl_unregister_vblank_cb(struct device *dev);
104104
void mtk_ovl_enable_vblank(struct device *dev);
105105
void mtk_ovl_disable_vblank(struct device *dev);
106+
u32 mtk_ovl_get_blend_modes(struct device *dev);
106107
const u32 *mtk_ovl_get_formats(struct device *dev);
107108
size_t mtk_ovl_get_num_formats(struct device *dev);
108109

@@ -131,6 +132,7 @@ void mtk_ovl_adaptor_start(struct device *dev);
131132
void mtk_ovl_adaptor_stop(struct device *dev);
132133
unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev);
133134
struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev);
135+
u32 mtk_ovl_adaptor_get_blend_modes(struct device *dev);
134136
const u32 *mtk_ovl_adaptor_get_formats(struct device *dev);
135137
size_t mtk_ovl_adaptor_get_num_formats(struct device *dev);
136138
enum drm_mode_status mtk_ovl_adaptor_mode_valid(struct device *dev,

drivers/gpu/drm/mediatek/mtk_disp_ovl.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ void mtk_ovl_disable_vblank(struct device *dev)
215215
writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_INTEN);
216216
}
217217

218+
u32 mtk_ovl_get_blend_modes(struct device *dev)
219+
{
220+
struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
221+
222+
return ovl->data->blend_modes;
223+
}
224+
218225
const u32 *mtk_ovl_get_formats(struct device *dev)
219226
{
220227
struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,13 @@ void mtk_ovl_adaptor_disable_vblank(struct device *dev)
400400
mtk_ethdr_disable_vblank(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
401401
}
402402

403+
u32 mtk_ovl_adaptor_get_blend_modes(struct device *dev)
404+
{
405+
struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);
406+
407+
return mtk_ethdr_get_blend_modes(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
408+
}
409+
403410
const u32 *mtk_ovl_adaptor_get_formats(struct device *dev)
404411
{
405412
struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);

drivers/gpu/drm/mediatek/mtk_ethdr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@ static irqreturn_t mtk_ethdr_irq_handler(int irq, void *dev_id)
145145
return IRQ_HANDLED;
146146
}
147147

148+
u32 mtk_ethdr_get_blend_modes(struct device *dev)
149+
{
150+
return BIT(DRM_MODE_BLEND_PREMULTI) |
151+
BIT(DRM_MODE_BLEND_COVERAGE) |
152+
BIT(DRM_MODE_BLEND_PIXEL_NONE);
153+
}
154+
148155
void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,
149156
struct mtk_plane_state *state,
150157
struct cmdq_pkt *cmdq_pkt)

drivers/gpu/drm/mediatek/mtk_ethdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ void mtk_ethdr_clk_disable(struct device *dev);
1313
void mtk_ethdr_config(struct device *dev, unsigned int w,
1414
unsigned int h, unsigned int vrefresh,
1515
unsigned int bpc, struct cmdq_pkt *cmdq_pkt);
16+
u32 mtk_ethdr_get_blend_modes(struct device *dev);
1617
void mtk_ethdr_layer_config(struct device *dev, unsigned int idx,
1718
struct mtk_plane_state *state,
1819
struct cmdq_pkt *cmdq_pkt);

drivers/gpu/drm/mediatek/mtk_plane.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = {
320320

321321
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
322322
unsigned long possible_crtcs, enum drm_plane_type type,
323-
unsigned int supported_rotations, const u32 *formats,
324-
size_t num_formats, unsigned int plane_idx)
323+
unsigned int supported_rotations, const u32 blend_modes,
324+
const u32 *formats, size_t num_formats, unsigned int plane_idx)
325325
{
326326
int err;
327327

@@ -366,12 +366,11 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
366366
if (err)
367367
DRM_ERROR("failed to create property: alpha\n");
368368

369-
err = drm_plane_create_blend_mode_property(plane,
370-
BIT(DRM_MODE_BLEND_PREMULTI) |
371-
BIT(DRM_MODE_BLEND_COVERAGE) |
372-
BIT(DRM_MODE_BLEND_PIXEL_NONE));
373-
if (err)
374-
DRM_ERROR("failed to create property: blend_mode\n");
369+
if (blend_modes) {
370+
err = drm_plane_create_blend_mode_property(plane, blend_modes);
371+
if (err)
372+
DRM_ERROR("failed to create property: blend_mode\n");
373+
}
375374

376375
drm_plane_helper_add(plane, &mtk_plane_helper_funcs);
377376

drivers/gpu/drm/mediatek/mtk_plane.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ to_mtk_plane_state(struct drm_plane_state *state)
4848

4949
int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,
5050
unsigned long possible_crtcs, enum drm_plane_type type,
51-
unsigned int supported_rotations, const u32 *formats,
52-
size_t num_formats, unsigned int plane_idx);
51+
unsigned int supported_rotations, const u32 blend_modes,
52+
const u32 *formats, size_t num_formats, unsigned int plane_idx);
5353
#endif

0 commit comments

Comments
 (0)