Skip to content

Commit c90ca39

Browse files
Hsiao Chien SungChun-Kuang Hu
authored andcommitted
drm/mediatek: Start/Stop components with function pointers
By registering component related functions to the pointers, we can easily manage them within a for-loop and simplify the logic of component start/stop process. Reviewed-by: CK Hu <ck.hu@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: Hsiao Chien Sung <shawn.sung@mediatek.com> Link: https://patchwork.kernel.org/project/dri-devel/patch/20231214055847.4936-16-shawn.sung@mediatek.com/ Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
1 parent b97fa2f commit c90ca39

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ static const char * const private_comp_stem[OVL_ADAPTOR_TYPE_NUM] = {
7272
static const struct mtk_ddp_comp_funcs ethdr = {
7373
.clk_enable = mtk_ethdr_clk_enable,
7474
.clk_disable = mtk_ethdr_clk_disable,
75+
.start = mtk_ethdr_start,
76+
.stop = mtk_ethdr_stop,
7577
};
7678

7779
static const struct mtk_ddp_comp_funcs merge = {
@@ -191,16 +193,30 @@ void mtk_ovl_adaptor_config(struct device *dev, unsigned int w,
191193

192194
void mtk_ovl_adaptor_start(struct device *dev)
193195
{
196+
int i;
194197
struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);
195198

196-
mtk_ethdr_start(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
199+
for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) {
200+
if (!ovl_adaptor->ovl_adaptor_comp[i] ||
201+
!comp_matches[i].funcs->start)
202+
continue;
203+
204+
comp_matches[i].funcs->start(ovl_adaptor->ovl_adaptor_comp[i]);
205+
}
197206
}
198207

199208
void mtk_ovl_adaptor_stop(struct device *dev)
200209
{
210+
int i;
201211
struct mtk_disp_ovl_adaptor *ovl_adaptor = dev_get_drvdata(dev);
202212

203-
mtk_ethdr_stop(ovl_adaptor->ovl_adaptor_comp[OVL_ADAPTOR_ETHDR0]);
213+
for (i = 0; i < OVL_ADAPTOR_ID_MAX; i++) {
214+
if (!ovl_adaptor->ovl_adaptor_comp[i] ||
215+
!comp_matches[i].funcs->stop)
216+
continue;
217+
218+
comp_matches[i].funcs->stop(ovl_adaptor->ovl_adaptor_comp[i]);
219+
}
204220
}
205221

206222
/**

0 commit comments

Comments
 (0)