Skip to content

Commit 611d4d1

Browse files
committed
Merge tag 'mediatek-drm-next-20251120' of https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux into drm-next
Mediatek DRM Next - 20251120 1. Fix probe resource leaks 2. Add support for MT8195/88 HDMIv2 and DDCv2 3. Fix CCORR mtk_ctm_s31_32_to_s1_n function issue 4. Fix device node reference leak in mtk_dp_dt_parse() Signed-off-by: Dave Airlie <airlied@redhat.com> From: Chun-Kuang Hu <chunkuang.hu@kernel.org> Link: https://patch.msgid.link/20251119233202.10034-1-chunkuang.hu@kernel.org
2 parents ee31621 + a846505 commit 611d4d1

14 files changed

Lines changed: 2925 additions & 549 deletions

drivers/gpu/drm/mediatek/Kconfig

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,30 @@ config DRM_MEDIATEK_DP
3030
help
3131
DRM/KMS Display Port driver for MediaTek SoCs.
3232

33+
config DRM_MEDIATEK_HDMI_COMMON
34+
tristate
35+
depends on DRM_MEDIATEK
36+
select DRM_DISPLAY_HDMI_HELPER
37+
select DRM_DISPLAY_HELPER
38+
select SND_SOC_HDMI_CODEC if SND_SOC
39+
help
40+
MediaTek SoC HDMI common library
41+
3342
config DRM_MEDIATEK_HDMI
3443
tristate "DRM HDMI Support for Mediatek SoCs"
3544
depends on DRM_MEDIATEK
36-
select SND_SOC_HDMI_CODEC if SND_SOC
45+
select DRM_MEDIATEK_HDMI_COMMON
3746
help
3847
DRM/KMS HDMI driver for Mediatek SoCs
48+
49+
config DRM_MEDIATEK_HDMI_V2
50+
tristate "DRM HDMI v2 IP support for MediaTek SoCs"
51+
depends on DRM_MEDIATEK
52+
select DRM_MEDIATEK_HDMI_COMMON
53+
help
54+
Say yes here to enable support for the HDMIv2 IP and related
55+
DDCv2 as found in the MediaTek MT8195, MT8188 SoCs and other
56+
variants.
57+
This driver can also be built as a module. If so, the HDMIv2
58+
module will be called "mtk_hdmi_v2", and the DDCv2 module
59+
will be called "mtk_hdmi_ddc_v2".

drivers/gpu/drm/mediatek/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ mediatek-drm-y := mtk_crtc.o \
2121

2222
obj-$(CONFIG_DRM_MEDIATEK) += mediatek-drm.o
2323

24+
obj-$(CONFIG_DRM_MEDIATEK_HDMI_COMMON) += mtk_hdmi_common.o
2425
obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mtk_cec.o
2526
obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mtk_hdmi.o
2627
obj-$(CONFIG_DRM_MEDIATEK_HDMI) += mtk_hdmi_ddc.o
28+
obj-$(CONFIG_DRM_MEDIATEK_HDMI_V2) += mtk_hdmi_v2.o
29+
obj-$(CONFIG_DRM_MEDIATEK_HDMI_V2) += mtk_hdmi_ddc_v2.o
2730

2831
obj-$(CONFIG_DRM_MEDIATEK_DP) += mtk_dp.o

drivers/gpu/drm/mediatek/mtk_ddp_comp.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,15 +621,27 @@ int mtk_find_possible_crtcs(struct drm_device *drm, struct device *dev)
621621
return ret;
622622
}
623623

624-
int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
624+
static void mtk_ddp_comp_put_device(void *_dev)
625+
{
626+
struct device *dev = _dev;
627+
628+
put_device(dev);
629+
}
630+
631+
static void mtk_ddp_comp_clk_put(void *_clk)
632+
{
633+
struct clk *clk = _clk;
634+
635+
clk_put(clk);
636+
}
637+
638+
int mtk_ddp_comp_init(struct device *dev, struct device_node *node, struct mtk_ddp_comp *comp,
625639
unsigned int comp_id)
626640
{
627641
struct platform_device *comp_pdev;
628642
enum mtk_ddp_comp_type type;
629643
struct mtk_ddp_comp_dev *priv;
630-
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
631644
int ret;
632-
#endif
633645

634646
if (comp_id >= DDP_COMPONENT_DRM_ID_MAX)
635647
return -EINVAL;
@@ -651,6 +663,10 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
651663
}
652664
comp->dev = &comp_pdev->dev;
653665

666+
ret = devm_add_action_or_reset(dev, mtk_ddp_comp_put_device, comp->dev);
667+
if (ret)
668+
return ret;
669+
654670
if (type == MTK_DISP_AAL ||
655671
type == MTK_DISP_BLS ||
656672
type == MTK_DISP_CCORR ||
@@ -666,15 +682,22 @@ int mtk_ddp_comp_init(struct device_node *node, struct mtk_ddp_comp *comp,
666682
type == MTK_DSI)
667683
return 0;
668684

669-
priv = devm_kzalloc(comp->dev, sizeof(*priv), GFP_KERNEL);
685+
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
670686
if (!priv)
671687
return -ENOMEM;
672688

673-
priv->regs = of_iomap(node, 0);
689+
priv->regs = devm_of_iomap(dev, node, 0, NULL);
690+
if (IS_ERR(priv->regs))
691+
return PTR_ERR(priv->regs);
692+
674693
priv->clk = of_clk_get(node, 0);
675694
if (IS_ERR(priv->clk))
676695
return PTR_ERR(priv->clk);
677696

697+
ret = devm_add_action_or_reset(dev, mtk_ddp_comp_clk_put, priv->clk);
698+
if (ret)
699+
return ret;
700+
678701
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
679702
ret = cmdq_dev_get_client_reg(comp->dev, &priv->cmdq_reg, 0);
680703
if (ret)

drivers/gpu/drm/mediatek/mtk_ddp_comp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ static inline void mtk_ddp_comp_encoder_index_set(struct mtk_ddp_comp *comp)
350350
int mtk_ddp_comp_get_id(struct device_node *node,
351351
enum mtk_ddp_comp_type comp_type);
352352
int mtk_find_possible_crtcs(struct drm_device *drm, struct device *dev);
353-
int mtk_ddp_comp_init(struct device_node *comp_node, struct mtk_ddp_comp *comp,
353+
int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node, struct mtk_ddp_comp *comp,
354354
unsigned int comp_id);
355355
enum mtk_ddp_comp_type mtk_ddp_comp_get_type(unsigned int comp_id);
356356
void mtk_ddp_write(struct cmdq_pkt *cmdq_pkt, unsigned int value,

drivers/gpu/drm/mediatek/mtk_disp_ccorr.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -80,27 +80,6 @@ void mtk_ccorr_stop(struct device *dev)
8080
writel_relaxed(0x0, ccorr->regs + DISP_CCORR_EN);
8181
}
8282

83-
/* Converts a DRM S31.32 value to the HW S1.n format. */
84-
static u16 mtk_ctm_s31_32_to_s1_n(u64 in, u32 n)
85-
{
86-
u16 r;
87-
88-
/* Sign bit. */
89-
r = in & BIT_ULL(63) ? BIT(n + 1) : 0;
90-
91-
if ((in & GENMASK_ULL(62, 33)) > 0) {
92-
/* identity value 0x100000000 -> 0x400(mt8183), */
93-
/* identity value 0x100000000 -> 0x800(mt8192), */
94-
/* if bigger this, set it to max 0x7ff. */
95-
r |= GENMASK(n, 0);
96-
} else {
97-
/* take the n+1 most important bits. */
98-
r |= (in >> (32 - n)) & GENMASK(n, 0);
99-
}
100-
101-
return r;
102-
}
103-
10483
void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state)
10584
{
10685
struct mtk_disp_ccorr *ccorr = dev_get_drvdata(dev);
@@ -119,7 +98,7 @@ void mtk_ccorr_ctm_set(struct device *dev, struct drm_crtc_state *state)
11998
input = ctm->matrix;
12099

121100
for (i = 0; i < ARRAY_SIZE(coeffs); i++)
122-
coeffs[i] = mtk_ctm_s31_32_to_s1_n(input[i], matrix_bits);
101+
coeffs[i] = drm_color_ctm_s31_32_to_qm_n(input[i], 2, matrix_bits);
123102

124103
mtk_ddp_write(cmdq_pkt, coeffs[0] << 16 | coeffs[1],
125104
&ccorr->cmdq_reg, ccorr->regs, DISP_CCORR_COEF_0);

drivers/gpu/drm/mediatek/mtk_disp_ovl_adaptor.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,13 @@ bool mtk_ovl_adaptor_is_comp_present(struct device_node *node)
527527
type == OVL_ADAPTOR_TYPE_PADDING;
528528
}
529529

530+
static void ovl_adaptor_put_device(void *_dev)
531+
{
532+
struct device *dev = _dev;
533+
534+
put_device(dev);
535+
}
536+
530537
static int ovl_adaptor_comp_init(struct device *dev, struct component_match **match)
531538
{
532539
struct mtk_disp_ovl_adaptor *priv = dev_get_drvdata(dev);
@@ -560,6 +567,11 @@ static int ovl_adaptor_comp_init(struct device *dev, struct component_match **ma
560567
if (!comp_pdev)
561568
return -EPROBE_DEFER;
562569

570+
ret = devm_add_action_or_reset(dev, ovl_adaptor_put_device,
571+
&comp_pdev->dev);
572+
if (ret)
573+
return ret;
574+
563575
priv->ovl_adaptor_comp[id] = &comp_pdev->dev;
564576

565577
drm_of_component_match_add(dev, match, component_compare_of, node);

drivers/gpu/drm/mediatek/mtk_dp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,6 +2087,7 @@ static int mtk_dp_dt_parse(struct mtk_dp *mtk_dp,
20872087
endpoint = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 1, -1);
20882088
len = of_property_count_elems_of_size(endpoint,
20892089
"data-lanes", sizeof(u32));
2090+
of_node_put(endpoint);
20902091
if (len < 0 || len > 4 || len == 3) {
20912092
dev_err(dev, "invalid data lane size: %d\n", len);
20922093
return -EINVAL;

drivers/gpu/drm/mediatek/mtk_drm_drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
11231123
(void *)private->mmsys_dev,
11241124
sizeof(*private->mmsys_dev));
11251125
private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev;
1126-
mtk_ddp_comp_init(NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR],
1126+
mtk_ddp_comp_init(dev, NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR],
11271127
DDP_COMPONENT_DRM_OVL_ADAPTOR);
11281128
component_match_add(dev, &match, compare_dev, &ovl_adaptor->dev);
11291129
}
@@ -1189,7 +1189,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
11891189
node);
11901190
}
11911191

1192-
ret = mtk_ddp_comp_init(node, &private->ddp_comp[comp_id], comp_id);
1192+
ret = mtk_ddp_comp_init(dev, node, &private->ddp_comp[comp_id], comp_id);
11931193
if (ret) {
11941194
of_node_put(node);
11951195
goto err_node;

0 commit comments

Comments
 (0)