Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <jason-jh.lin@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Reviewed-by: CK Hu <ck.hu@mediatek.com>
Link: https://patchwork.kernel.org/project/dri-devel/patch/20241009034646.13143-6-jason-jh.lin@mediatek.com/
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>

authored by

Jason-JH.Lin and committed by
Chun-Kuang Hu
e6411bf2 333ab436

+46 -10
+1
drivers/gpu/drm/mediatek/mtk_crtc.c
··· 913 913 BIT(pipe), 914 914 mtk_crtc_plane_type(mtk_crtc->layer_nr, num_planes), 915 915 mtk_ddp_comp_supported_rotations(comp), 916 + mtk_ddp_comp_get_blend_modes(comp), 916 917 mtk_ddp_comp_get_formats(comp), 917 918 mtk_ddp_comp_get_num_formats(comp), i); 918 919 if (ret)
+2
drivers/gpu/drm/mediatek/mtk_ddp_comp.c
··· 363 363 .layer_config = mtk_ovl_layer_config, 364 364 .bgclr_in_on = mtk_ovl_bgclr_in_on, 365 365 .bgclr_in_off = mtk_ovl_bgclr_in_off, 366 + .get_blend_modes = mtk_ovl_get_blend_modes, 366 367 .get_formats = mtk_ovl_get_formats, 367 368 .get_num_formats = mtk_ovl_get_num_formats, 368 369 }; ··· 417 416 .disconnect = mtk_ovl_adaptor_disconnect, 418 417 .add = mtk_ovl_adaptor_add_comp, 419 418 .remove = mtk_ovl_adaptor_remove_comp, 419 + .get_blend_modes = mtk_ovl_adaptor_get_blend_modes, 420 420 .get_formats = mtk_ovl_adaptor_get_formats, 421 421 .get_num_formats = mtk_ovl_adaptor_get_num_formats, 422 422 .mode_valid = mtk_ovl_adaptor_mode_valid,
+10
drivers/gpu/drm/mediatek/mtk_ddp_comp.h
··· 80 80 void (*ctm_set)(struct device *dev, 81 81 struct drm_crtc_state *state); 82 82 struct device * (*dma_dev_get)(struct device *dev); 83 + u32 (*get_blend_modes)(struct device *dev); 83 84 const u32 *(*get_formats)(struct device *dev); 84 85 size_t (*get_num_formats)(struct device *dev); 85 86 void (*connect)(struct device *dev, struct device *mmsys_dev, unsigned int next); ··· 265 264 if (comp->funcs && comp->funcs->dma_dev_get) 266 265 return comp->funcs->dma_dev_get(comp->dev); 267 266 return comp->dev; 267 + } 268 + 269 + static inline 270 + u32 mtk_ddp_comp_get_blend_modes(struct mtk_ddp_comp *comp) 271 + { 272 + if (comp->funcs && comp->funcs->get_blend_modes) 273 + return comp->funcs->get_blend_modes(comp->dev); 274 + 275 + return 0; 268 276 } 269 277 270 278 static inline
+2
drivers/gpu/drm/mediatek/mtk_disp_drv.h
··· 103 103 void mtk_ovl_unregister_vblank_cb(struct device *dev); 104 104 void mtk_ovl_enable_vblank(struct device *dev); 105 105 void mtk_ovl_disable_vblank(struct device *dev); 106 + u32 mtk_ovl_get_blend_modes(struct device *dev); 106 107 const u32 *mtk_ovl_get_formats(struct device *dev); 107 108 size_t mtk_ovl_get_num_formats(struct device *dev); 108 109 ··· 132 131 void mtk_ovl_adaptor_stop(struct device *dev); 133 132 unsigned int mtk_ovl_adaptor_layer_nr(struct device *dev); 134 133 struct device *mtk_ovl_adaptor_dma_dev_get(struct device *dev); 134 + u32 mtk_ovl_adaptor_get_blend_modes(struct device *dev); 135 135 const u32 *mtk_ovl_adaptor_get_formats(struct device *dev); 136 136 size_t mtk_ovl_adaptor_get_num_formats(struct device *dev); 137 137 enum drm_mode_status mtk_ovl_adaptor_mode_valid(struct device *dev,
+7
drivers/gpu/drm/mediatek/mtk_disp_ovl.c
··· 215 215 writel_relaxed(0x0, ovl->regs + DISP_REG_OVL_INTEN); 216 216 } 217 217 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 + 218 225 const u32 *mtk_ovl_get_formats(struct device *dev) 219 226 { 220 227 struct mtk_disp_ovl *ovl = dev_get_drvdata(dev);
+7
drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c
··· 400 400 mtk_ethdr_disable_vblank(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]); 401 401 } 402 402 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 + 403 410 const u32 *mtk_ovl_adaptor_get_formats(struct device *dev) 404 411 { 405 412 struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);
+7
drivers/gpu/drm/mediatek/mtk_ethdr.c
··· 145 145 return IRQ_HANDLED; 146 146 } 147 147 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 + 148 155 void mtk_ethdr_layer_config(struct device *dev, unsigned int idx, 149 156 struct mtk_plane_state *state, 150 157 struct cmdq_pkt *cmdq_pkt)
+1
drivers/gpu/drm/mediatek/mtk_ethdr.h
··· 13 13 void mtk_ethdr_config(struct device *dev, unsigned int w, 14 14 unsigned int h, unsigned int vrefresh, 15 15 unsigned int bpc, struct cmdq_pkt *cmdq_pkt); 16 + u32 mtk_ethdr_get_blend_modes(struct device *dev); 16 17 void mtk_ethdr_layer_config(struct device *dev, unsigned int idx, 17 18 struct mtk_plane_state *state, 18 19 struct cmdq_pkt *cmdq_pkt);
+7 -8
drivers/gpu/drm/mediatek/mtk_plane.c
··· 320 320 321 321 int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, 322 322 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) 325 325 { 326 326 int err; 327 327 ··· 366 366 if (err) 367 367 DRM_ERROR("failed to create property: alpha\n"); 368 368 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 + } 375 374 376 375 drm_plane_helper_add(plane, &mtk_plane_helper_funcs); 377 376
+2 -2
drivers/gpu/drm/mediatek/mtk_plane.h
··· 48 48 49 49 int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane, 50 50 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); 53 53 #endif