Refactor MediaTek DP drivers
Subsystems (3)
v2 cover Refactor MediaTek DP drivers
For this series, we do some clean-up and fix a build warning. This series is based on linux-next-20220915.
Changes for v2:
1. Update commit message in "drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect()".
2. Add fix tag for "drm/mediatek: dp: Fix warning in mtk_dp_video_mute()".
Bo-Chen Chen (3):
drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect() drm/mediatek: dp: Remove unused register definitions drm/mediatek: dp: Fix warning in mtk_dp_video_mute()
drivers/gpu/drm/mediatek/mtk_dp.c | 70 ++++++++++++++------------- drivers/gpu/drm/mediatek/mtk_dp_reg.h | 6 --- 2 files changed, 36 insertions(+), 40 deletions(-)
Signature · 1 line
2.18.0
PATCH v2 1/3 drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect()
In order to improve human readability, reduce the indentation by returning early if the dp/edp cable is not plugged in.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 66 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 32 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +34 -32
@@ -1933,39 +1933,41 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)bool enabled = mtk_dp->enabled;u8 sink_count =0 ; -if (mtk_dp->train_info.cable_plugged_in) { -if (!enabled) { -/* power on aux */ -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL_LANE , -DP_PWR_STATE_MASK ); - -/* power on panel */ -drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); -usleep_range (2000 ,5000 ); - } -/* -* Some dongles still source HPD when they do not connect to any -* sink device. To avoid this, we need to read the sink count -* to make sure we do connect to sink devices. After this detect -* function, we just need to check the HPD connection to check -* whether we connect to a sink device. -*/ -drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); -if (DP_GET_SINK_COUNT (sink_count)) - ret = connector_status_connected; - -if (!enabled) { -/* power off panel */ -drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); -usleep_range (2000 ,3000 ); - -/* power off aux */ -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL , -DP_PWR_STATE_MASK ); - } +if (!mtk_dp->train_info.cable_plugged_in) +return ret; + +if (!enabled) { +/* power on aux */ +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL_LANE , +DP_PWR_STATE_MASK ); + +/* power on panel */ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); +usleep_range (2000 ,5000 ); } +/* +* Some dongles still source HPD when they do not connect to any +* sink device. To avoid this, we need to read the sink count +* to make sure we do connect to sink devices. After this detect +* function, we just need to check the HPD connection to check +* whether we connect to a sink device. +*/ +drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); +if (DP_GET_SINK_COUNT (sink_count)) + ret = connector_status_connected; + +if (!enabled) { +/* power off panel */ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +usleep_range (2000 ,3000 ); + +/* power off aux */ +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL , +DP_PWR_STATE_MASK ); + } +return ret; }
Signature · 1 line
2.18.0
Re: [PATCH v2 1/3] drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect()
Bo-Chen Chen <[email protected]> 於 2022年9月16日 週五 晚上9:38寫道:
Quoted 3 lines
In order to improve human readability, reduce the indentation by returning early if the dp/edp cable is not plugged in.
Quoted 87 lines
Signed-off-by Bo-Chen Chen <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dp.c | 66 ++++++++++++++++--------------- 1 file changed, 34 insertions(+), 32 deletions(-)drivers/gpu/drm/mediatek/mtk_dp.c +34
-33@@ -1933,39 +1933,41 @@ static enum drm_connector_status mtk_dp_bdg_detect(struct drm_bridge *bridge)bool enabled = mtk_dp->enabled;u8 sink_count =0 ; -if (mtk_dp->train_info.cable_plugged_in) { -if (!enabled) { -/* power on aux */ -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL_LANE , -DP_PWR_STATE_MASK ); - -/* power on panel */ -drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); -usleep_range (2000 ,5000 ); - } -/* -* Some dongles still source HPD when they do not connect to any -* sink device. To avoid this, we need to read the sink count -* to make sure we do connect to sink devices. After this detect -* function, we just need to check the HPD connection to check -* whether we connect to a sink device. -*/ -drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); -if (DP_GET_SINK_COUNT (sink_count)) - ret = connector_status_connected; - -if (!enabled) { -/* power off panel */ -drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); -usleep_range (2000 ,3000 ); - -/* power off aux */ -mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , -DP_PWR_STATE_BANDGAP_TPLL , -DP_PWR_STATE_MASK ); - } +if (!mtk_dp->train_info.cable_plugged_in) +return ret; + +if (!enabled) { +/* power on aux */ +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL_LANE , +DP_PWR_STATE_MASK ); + +/* power on panel */ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D0 ); +usleep_range (2000 ,5000 ); } +/* +* Some dongles still source HPD when they do not connect to any +* sink device. To avoid this, we need to read the sink count +* to make sure we do connect to sink devices. After this detect +* function, we just need to check the HPD connection to check +* whether we connect to a sink device. +*/ +drm_dp_dpcd_readb (&mtk_dp->aux,DP_SINK_COUNT , &sink_count); +if (DP_GET_SINK_COUNT (sink_count)) + ret = connector_status_connected; + +if (!enabled) { +/* power off panel */ +drm_dp_dpcd_writeb (&mtk_dp->aux,DP_SET_POWER ,DP_SET_POWER_D3 ); +usleep_range (2000 ,3000 ); + +/* power off aux */ +mtk_dp_update_bits (mtk_dp,MTK_DP_TOP_PWR_STATE , +DP_PWR_STATE_BANDGAP_TPLL , +DP_PWR_STATE_MASK ); + } +return ret; } --2.18.0
Re: [PATCH v2 1/3] drm/mediatek: dp: Reduce indentation in mtk_dp_bdg_detect()
In reply to Bo-Chen ChenIl 16/09/22 15:38, Bo-Chen Chen ha scritto:
Quoted 4 lines
In order to improve human readability, reduce the indentation by returning early if the dp/edp cable is not plugged in.
Signed-off-by Bo-Chen Chen <[email protected]>
PATCH v2 2/3 drm/mediatek: dp: Remove unused register definitions
In reply to Bo-Chen ChenSome definitions in mtk_dp_reg.h are not used, so remove these redundant codes.
--- drivers/gpu/drm/mediatek/mtk_dp_reg.h | 6 ------ 1 file changed, 6 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp_reg.h +0 -6
@@ -153,8 +153,6 @@#define CH_STATUS_1_DP_ENC0_P0_MASK GENMASK(15, 0)#define MTK_DP_ENC0_P0_3094 0x3094#define CH_STATUS_2_DP_ENC0_P0_MASK GENMASK(7, 0) -#define MTK_DP_ENC0_P0_30A0 0x30a0 -#define DP_ENC0_30A0_MASK (BIT(7) | BIT(8) | BIT(12))#define MTK_DP_ENC0_P0_30A4 0x30a4#define AU_TS_CFG_DP_ENC0_P0_MASK GENMASK(7, 0)#define MTK_DP_ENC0_P0_30A8 0x30a8
@@ -171,8 +169,6 @@#define MTK_DP_ENC0_P0_312C 0x312c#define ASP_HB2_DP_ENC0_P0_MASK GENMASK(7, 0)#define ASP_HB3_DP_ENC0_P0_MASK GENMASK(15, 8) -#define MTK_DP_ENC0_P0_3130 0x3130 -#define MTK_DP_ENC0_P0_3138 0x3138#define MTK_DP_ENC0_P0_3154 0x3154#define PGEN_HTOTAL_DP_ENC0_P0_MASK GENMASK(13, 0)#define MTK_DP_ENC0_P0_3158 0x3158
@@ -206,8 +202,6 @@#define SDP_PACKET_TYPE_DP_ENC1_P0_MASK GENMASK(4, 0)#define SDP_PACKET_W_DP_ENC1_P0 BIT(5)#define SDP_PACKET_W_DP_ENC1_P0_MASK BIT(5) -#define MTK_DP_ENC1_P0_328C 0x328c -#define VSC_DATA_RDY_VESA_DP_ENC1_P0_MASK BIT(7)#define MTK_DP_ENC1_P0_3300 0x3300#define VIDEO_AFIFO_RDY_SEL_DP_ENC1_P0_VAL 2#define VIDEO_AFIFO_RDY_SEL_DP_ENC1_P0_MASK GENMASK(9, 8)
Signature · 1 line
2.18.0
Re: [PATCH v2 2/3] drm/mediatek: dp: Remove unused register definitions
Hi, Bo-Chen:
Bo-Chen Chen <[email protected]> 於 2022年9月16日 週五 晚上9:38寫道:
Quoted 3 lines
Some definitions in
mtk_dp_reg.hare not used, so remove these redundant codes.
Quoted 42 lines
Signed-off-by Bo-Chen Chen <[email protected]>Reviewed-by AngeloGioacchino Del Regno <[email protected]>Reviewed-by Matthias Brugger <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dp_reg.h | 6 ------ 1 file changed, 6 deletions(-)drivers/gpu/drm/mediatek/mtk_dp_reg.h +0
-7@@ -153,8 +153,6 @@#define CH_STATUS_1_DP_ENC0_P0_MASK GENMASK(15, 0)#define MTK_DP_ENC0_P0_3094 0x3094#define CH_STATUS_2_DP_ENC0_P0_MASK GENMASK(7, 0) -#define MTK_DP_ENC0_P0_30A0 0x30a0 -#define DP_ENC0_30A0_MASK (BIT(7) | BIT(8) | BIT(12))#define MTK_DP_ENC0_P0_30A4 0x30a4#define AU_TS_CFG_DP_ENC0_P0_MASK GENMASK(7, 0)#define MTK_DP_ENC0_P0_30A8 0x30a8@@ -171,8 +169,6 @@#define MTK_DP_ENC0_P0_312C 0x312c#define ASP_HB2_DP_ENC0_P0_MASK GENMASK(7, 0)#define ASP_HB3_DP_ENC0_P0_MASK GENMASK(15, 8) -#define MTK_DP_ENC0_P0_3130 0x3130 -#define MTK_DP_ENC0_P0_3138 0x3138#define MTK_DP_ENC0_P0_3154 0x3154#define PGEN_HTOTAL_DP_ENC0_P0_MASK GENMASK(13, 0)#define MTK_DP_ENC0_P0_3158 0x3158@@ -206,8 +202,6 @@#define SDP_PACKET_TYPE_DP_ENC1_P0_MASK GENMASK(4, 0)#define SDP_PACKET_W_DP_ENC1_P0 BIT(5)#define SDP_PACKET_W_DP_ENC1_P0_MASK BIT(5) -#define MTK_DP_ENC1_P0_328C 0x328c -#define VSC_DATA_RDY_VESA_DP_ENC1_P0_MASK BIT(7)#define MTK_DP_ENC1_P0_3300 0x3300#define VIDEO_AFIFO_RDY_SEL_DP_ENC1_P0_VAL 2#define VIDEO_AFIFO_RDY_SEL_DP_ENC1_P0_MASK GENMASK(9, 8) --2.18.0
PATCH v2 3/3 drm/mediatek: dp: Fix warning in mtk_dp_video_mute()
In reply to Bo-Chen ChenWarning:../drivers/gpu/drm/mediatek/mtk_dp.c: In function ‘mtk_dp_video_mute’:../drivers/gpu/drm/mediatek/mtk_dp.c:947:23: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/dev_printk.h:129:27: note: in definition of macro ‘dev_printk’
129 | _dev_printk(level, dev, fmt, ##__VA_ARGS__); \
| ^~~../include/linux/dev_printk.h:163:31: note: in expansion of macro ‘dev_fmt’
163 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
| ^~~~~~~../drivers/gpu/drm/mediatek/mtk_dp.c:947:2: note: in expansion of macro ‘dev_dbg’
947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n",
| ^~~~~~~
../drivers/gpu/drm/mediatek/mtk_dp.c:947:36: note: format string is defined here
947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n",
| ~^
| |
| unsigned int
| %lxTo fix this issue, we use %s to replace 0x%x.
--- drivers/gpu/drm/mediatek/mtk_dp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_dp.c +2 -2
@@ -1222,8 +1222,8 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable) mtk_dp->data->smc_cmd, enable, 0, 0, 0, 0, 0, &res); -dev_dbg (mtk_dp->dev,"smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n" , - mtk_dp->data->smc_cmd, enable, res.a0, res.a1); +dev_dbg (mtk_dp->dev,"smc cmd: 0x%x, p1: %s, ret: 0x%lx-0x%lx\n" , + mtk_dp->data->smc_cmd, enable ?"enable" :"disable" , res.a0, res.a1); }static void mtk_dp_audio_mute (struct mtk_dp *mtk_dp,bool mute)
Signature · 1 line
2.18.0
Re: [PATCH v2 3/3] drm/mediatek: dp: Fix warning in mtk_dp_video_mute()
Hi, Bo-Chen:
Bo-Chen Chen <[email protected]> 於 2022年9月16日 週五 晚上9:38寫道:
Quoted 25 lines
Warning:
../drivers/gpu/drm/mediatek/mtk_dp.c: In function ‘mtk_dp_video_mute’:../drivers/gpu/drm/mediatek/mtk_dp.c:947:23: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n",| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/dev_printk.h:129:27: note: in definition of macro ‘dev_printk’
129 |_dev_printk(level, dev, fmt, ##__VA_ARGS__); \
| ^~~../include/linux/dev_printk.h:163:31: note: in expansion of macro ‘dev_fmt’
163 |dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
| ^~~~~~~../drivers/gpu/drm/mediatek/mtk_dp.c:947:2: note: in expansion of macro ‘dev_dbg’947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n", | ^~~~~~~ ../drivers/gpu/drm/mediatek/mtk_dp.c:947:36: note: format string is defined here 947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n", | ~^ | | | unsigned int | %lx
Quoted 1 line
To fix this issue, we use %s to replace 0x%x.
Quoted 27 lines
Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")Reported-by Chun-Kuang Hu <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>Reviewed-by Matthias Brugger <[email protected]>--- drivers/gpu/drm/mediatek/mtk_dp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_dp.c +2
-3@@ -1222,8 +1222,8 @@ static void mtk_dp_video_mute(struct mtk_dp *mtk_dp, bool enable) mtk_dp->data->smc_cmd, enable, 0, 0, 0, 0, 0, &res); -dev_dbg (mtk_dp->dev,"smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n" , - mtk_dp->data->smc_cmd, enable, res.a0, res.a1); +dev_dbg (mtk_dp->dev,"smc cmd: 0x%x, p1: %s, ret: 0x%lx-0x%lx\n" , + mtk_dp->data->smc_cmd, enable ?"enable" :"disable" , res.a0, res.a1); }static void mtk_dp_audio_mute (struct mtk_dp *mtk_dp,bool mute) --2.18.0
Re: [PATCH v2 3/3] drm/mediatek: dp: Fix warning in mtk_dp_video_mute()
In reply to Bo-Chen ChenIl 16/09/22 15:38, Bo-Chen Chen ha scritto:
Quoted 24 lines
Warning:
../drivers/gpu/drm/mediatek/mtk_dp.c: In function ‘mtk_dp_video_mute’:../drivers/gpu/drm/mediatek/mtk_dp.c:947:23: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n",| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../include/linux/dev_printk.h:129:27: note: in definition of macro ‘dev_printk’
129 |_dev_printk(level, dev, fmt, ##__VA_ARGS__); \
| ^~~../include/linux/dev_printk.h:163:31: note: in expansion of macro ‘dev_fmt’
163 |dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
| ^~~~~~~../drivers/gpu/drm/mediatek/mtk_dp.c:947:2: note: in expansion of macro ‘dev_dbg’947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n", | ^~~~~~~ ../drivers/gpu/drm/mediatek/mtk_dp.c:947:36: note: format string is defined here 947 | dev_dbg(mtk_dp->dev, "smc cmd: 0x%x, p1: 0x%x, ret: 0x%lx-0x%lx\n", | ~^ | | | unsigned int | %lx
Quoted 6 lines
To fix this issue, we use %s to replace 0x%x.
Fixes f70ac097a2cf ("drm/mediatek: Add MT8195 Embedded DisplayPort driver")Reported-by Chun-Kuang Hu <[email protected]>Signed-off-by Bo-Chen Chen <[email protected]>Reviewed-by Matthias Brugger <[email protected]>
Chun-Kuang Hu
maintainerHi, Dmitry:
My tree has no mtk-dp driver yet. Would you like to pick this series?
Regards,
Chun-Kuang.
Bo-Chen Chen <[email protected]> 於 2022年9月16日 週五 晚上9:38寫道:
Quoted 20 lines
For this series, we do some clean-up and fix a build warning. This series is based on linux-next-20220915.
Changes for v2:
1. Update commit message in "drm/mediatek: dp: Reduce indentation inmtk_dp_bdg_detect()".
2. Add fix tag for "drm/mediatek: dp: Fix warning inmtk_dp_video_mute()".Bo-Chen Chen (3):
drm/mediatek: dp: Reduce indentation inmtk_dp_bdg_detect()drm/mediatek: dp: Remove unused register definitions drm/mediatek: dp: Fix warning inmtk_dp_video_mute()drivers/gpu/drm/mediatek/mtk_dp.c | 70 ++++++++++++++------------- drivers/gpu/drm/mediatek/mtk_dp_reg.h | 6 --- 2 files changed, 36 insertions(+), 40 deletions(-)--
2.18.0
Hello Chun-Kuang,
18.09.2022 06:17, Chun-Kuang Hu пишет:
Quoted 15 lines
Hi, Dmitry:
My tree has no mtk-dp driver yet. Would you like to pick this series?
Regards,
Chun-Kuang.Bo-Chen Chen <[email protected]> 於 2022年9月16日 週五 晚上9:38寫道:
Quoted 7 lines
For this series, we do some clean-up and fix a build warning. This series is based on linux-next-20220915.
Changes for v2:
1. Update commit message in "drm/mediatek: dp: Reduce indentation inmtk_dp_bdg_detect()".
2. Add fix tag for "drm/mediatek: dp: Fix warning inmtk_dp_video_mute()".
I changed commit message of the "Fix warning in mtk_dp_video_mute()" patch to make it less noisy and applied all the patches to drm-misc-next.