drm/msm/hdmi: rework and fix the HPD even generation
Subsystems (6)
v4 cover drm/msm/hdmi: rework and fix the HPD even generation
The MSM HDMI driver is plagued with the long-standing bug. If HDMI cable is disconnected, in most of the cases cable reconnection will not be detected properly. We have been carrying the patch from [1] in our integration tree for ages. The time has come to fix the long-standing bug and implement proper HPD handling.
This series was tested on msm8996 and apq8064 boards. Previously HPD handling sometimes could trigger in the CRTC event handling, however I can no longer reproduce it now.
[1] https://lore.kernel.org/linux-arm-msm/[email protected]/
---
Changes in v4:
- Added bindings patches. Dropped hpd-gpios from the IFC6410 board DT.
- Fixed checkpatch.pl warning about non-const string arrays.
- Rebased on top of linux-next and the MSM HDMI patchset.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Rebase on top of linux-next
- Dropped the patches that were replaced by the HDMI Connector
framework
- Picked up the mode_set -> atomic_pre_enable patch
- Link to v2: https://lore.kernel.org/r/[email protected]
---
Dmitry Baryshkov (16):
dt-bindings: display/msm/hdmi: drop obsolete GPIOs from schema
dt-bindings: display/msm: hdmi: drop hpd-gpios drm/msm/hdmi: convert clock and regulator arrays to const arrays drm/msm/hdmi: move the alt_iface clock to the hpd list drm/msm/hdmi: simplify extp clock handling drm/msm/hdmi: drop clock frequency assignment drm/msm/hdmi: switch to clk_bulk API
drm/msm/hdmi: switch to pm_runtime_resume_and_get() drm/msm/hdmi: add runtime PM calls to DDC transfer function drm/msm/hdmi: implement proper runtime PM handling drm/msm/hdmi: rename hpd_clks to pwr_clks drm/msm/hdmi: expand the HDMI_CFG macro
drm/msm/hdmi: drop hpd-gpios support
drm/msm/hdmi: ensure that HDMI is up if HPD is requested drm/msm/hdmi: wire in hpd_enable/hpd_disable bridge ops
ARM: dts: qcom: apq8064-ifc6410: drop HDMI HPD GPIO
.../devicetree/bindings/display/msm/hdmi.yaml | 20 --- arch/arm/boot/dts/qcom/qcom-apq8064-ifc6410.dts | 1 - drivers/gpu/drm/msm/hdmi/hdmi.c | 147 ++++++++++----------- drivers/gpu/drm/msm/hdmi/hdmi.h | 28 ++-- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 55 +++----- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 141 ++++---------------- drivers/gpu/drm/msm/hdmi/hdmi_i2c.c | 14 +- drivers/gpu/drm/msm/hdmi/hdmi_phy.c | 6 +- 8 files changed, 141 insertions(+), 271 deletions(-)
---
base-commit: 866e43b945bf98f8e807dfa45eca92f931f3a032
change-id: 20240522-fd-hdmi-hpd-e3868deb6ae0
prerequisite-change-id: 20240307-bridge-hdmi-connector-7e3754e661d0:v7
prerequisite-patch-id: 2ab3eb29f644faba596a27259c8c4d35f824b37b
prerequisite-patch-id: 469e655ccdfd1989d58b043a6b4766d40a334ba4
prerequisite-patch-id: caf6f731bbce246ee20f92f128a1480c230aa9f3
prerequisite-patch-id: 56a9d57d44360d0913023c4d77f765c2ebf29749
prerequisite-patch-id: ac7b8e8a14af4f45170ef5df6a632adb6d8ed483
prerequisite-patch-id: 4b6ed8a13b525d2c6a3ee449ba2381041d78dacd
prerequisite-patch-id: 396e7abb756bb9c8818d44dca8fb3f819c011ee0
Best regards,
Signature · 1 line
Dmitry Baryshkov <[email protected]>
PATCH v4 1/16 dt-bindings: display/msm/hdmi: drop obsolete GPIOs from schema
The commit 68e674b13b17 ("drm/msm/hdmi: drop unused GPIO support") dropped support for obsolete qcom,hdmi-tx-mux-* gpios. They were not used by any of the upstream platforms. Drop them from the bindings too.
--- Documentation/devicetree/bindings/display/msm/hdmi.yaml | 15 --------------- 1 file changed, 15 deletions(-)
Documentation/devicetree/bindings/display/msm/hdmi.yaml +0 -15
@@ -66,21 +66,6 @@ properties: maxItems: 1 description: hpd pin - qcom,hdmi-tx-mux-en-gpios: - maxItems: 1 - deprecated: true - description: HDMI mux enable pin - - qcom,hdmi-tx-mux-sel-gpios: - maxItems: 1 - deprecated: true - description: HDMI mux select pin - - qcom,hdmi-tx-mux-lpm-gpios: - maxItems: 1 - deprecated: true - description: HDMI mux lpm pin - '#sound-dai-cells': const: 1
Signature · 1 line
2.39.5
Re: [PATCH v4 01/16] dt-bindings: display/msm/hdmi: drop obsolete GPIOs from schema
Quoted 1 line · Dmitry Baryshkov
The commit
68e674b13b17("drm/msm/hdmi: drop unused GPIO support")
That commit looks a lot like an ABI break and keeping bindings is a proof of that. Commit mentions upstreamed platforms, but you have also downstream users which matters for the ABI.
Well, that ship has sailed, so:
Best regards,
Krzysztof
PATCH v4 2/16 dt-bindings: display/msm: hdmi: drop hpd-gpios
In reply to Dmitry BaryshkovSupporting simultaneous check of native HPD and the external GPIO proved to be less stable than just native HPD. Drop the hpd-gpios from the bindings. This is not a breaking change, since the HDMI block has been using both GPIO _and_ internal HPD anyway. In case the native HPD doesn't work users are urged to switch to specifying the hpd-gpios property to the hdmi-connector device.
--- Documentation/devicetree/bindings/display/msm/hdmi.yaml | 5 ----- 1 file changed, 5 deletions(-)
Documentation/devicetree/bindings/display/msm/hdmi.yaml +0 -5
@@ -62,10 +62,6 @@ properties: core-vcc-supply: description: phandle to VCC supply regulator - hpd-gpios: - maxItems: 1 - description: hpd pin - '#sound-dai-cells': const: 1
@@ -178,7 +174,6 @@ examples: clocks = <&clk 61>, <&clk 72>, <&clk 98>; - hpd-gpios = <&msmgpio 72 GPIO_ACTIVE_HIGH>; core-vdda-supply = <&pm8921_hdmi_mvs>; hdmi-mux-supply = <&ext_3p3v>; pinctrl-names = "default", "sleep";
Signature · 1 line
2.39.5
Re: [PATCH v4 02/16] dt-bindings: display/msm: hdmi: drop hpd-gpios
Quoted 6 lines · Dmitry Baryshkov
Supporting simultaneous check of native HPD and the external GPIO proved to be less stable than just native HPD. Drop the hpd-gpios from the bindings. This is not a breaking change, since the HDMI block has been using both GPIO _and_ internal HPD anyway. In case the native HPD doesn't work users are urged to switch to specifying the hpd-gpios property to the hdmi-connector device.
In that case users would need to update their DTS/DTB, so that's an ABI break.
Please deprecate the property here (deprecated: true) and keep support in the driver.
Best regards,
Krzysztof
Re: [PATCH v4 02/16] dt-bindings: display/msm: hdmi: drop hpd-gpios
Quoted 8 lines · Krzysztof Kozlowski
Quoted 6 lines · Dmitry Baryshkov
Supporting simultaneous check of native HPD and the external GPIO proved to be less stable than just native HPD. Drop the hpd-gpios from the bindings. This is not a breaking change, since the HDMI block has been using both GPIO _and_ internal HPD anyway. In case the native HPD doesn't work users are urged to switch to specifying the hpd-gpios property to the hdmi-connector device.
Quoted 5 lines
In that case users would need to update their DTS/DTB, so that's an ABI break.
Please deprecate the property here (deprecated: true) and keep support in the driver.
I will expand the explanation for the need of the ABI break. Yes, it's a bad idea. No, it doesn't prevent the board from working. Yes, it needs to be done.
Signature · 2 lines
With best wishes Dmitry
PATCH v4 3/16 drm/msm/hdmi: convert clock and regulator arrays to const arrays
In reply to Dmitry BaryshkovAs a preparation to the next patches convert 'static const char *' arrays to 'static const char * const', as required by the checkpatch.pl
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 10 +++++----- drivers/gpu/drm/msm/hdmi/hdmi.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +5 -5
@@ -224,17 +224,17 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, .item ## _names = item ##_names_ ## entry, \ .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry) -static const char *hpd_reg_names_8960[] = {"core-vdda" }; -static const char *hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" }; +static const char *const hpd_reg_names_8960[] = {"core-vdda" }; +static const char *const hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" };static const struct hdmi_platform_config hdmi_tx_8960_config = {HDMI_CFG (hpd_reg,8960 ),HDMI_CFG (hpd_clk,8960 ), }; -static const char *pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; -static const char *pwr_clk_names_8x74[] = {"extp" ,"alt_iface" }; -static const char *hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" }; +static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; +static const char *const pwr_clk_names_8x74[] = {"extp" ,"alt_iface" }; +static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" };static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 };static const struct hdmi_platform_config hdmi_tx_8974_config = {
drivers/gpu/drm/msm/hdmi/hdmi.h +4 -4
@@ -84,20 +84,20 @@ struct hdmi {/* platform config data (ie. from DT, or pdata) */ struct hdmi_platform_config {/* regulators that need to be on for hpd: */ -const char **hpd_reg_names; +const char *const *hpd_reg_names;int hpd_reg_cnt;/* regulators that need to be on for screen pwr: */ -const char **pwr_reg_names; +const char *const *pwr_reg_names;int pwr_reg_cnt;/* clks that need to be on for hpd: */ -const char **hpd_clk_names; +const char *const *hpd_clk_names;const long unsigned *hpd_freq;int hpd_clk_cnt;/* clks that need to be on for screen pwr (ie pixel clk): */ -const char **pwr_clk_names; +const char *const *pwr_clk_names;int pwr_clk_cnt; };
Signature · 1 line
2.39.5
Re: [PATCH v4 03/16] drm/msm/hdmi: convert clock and regulator arrays to const arrays
Quoted 4 lines · Dmitry Baryshkov
As a preparation to the next patches convert 'static const char *' arrays to 'static const char * const', as required by the checkpatch.pl
Signed-off-by Dmitry Baryshkov <[email protected]>
Quoted 62 lines
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 10 +++++----- drivers/gpu/drm/msm/hdmi/hdmi.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-)drivers/gpu/drm/msm/hdmi/hdmi.c +5
-5@@ -224,17 +224,17 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, .item ## _names = item ##_names_ ## entry, \ .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry) -static const char *hpd_reg_names_8960[] = {"core-vdda" }; -static const char *hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" }; +static const char *const hpd_reg_names_8960[] = {"core-vdda" }; +static const char *const hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" };static const struct hdmi_platform_config hdmi_tx_8960_config = {HDMI_CFG (hpd_reg,8960 ),HDMI_CFG (hpd_clk,8960 ), }; -static const char *pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; -static const char *pwr_clk_names_8x74[] = {"extp" ,"alt_iface" }; -static const char *hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" }; +static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; +static const char *const pwr_clk_names_8x74[] = {"extp" ,"alt_iface" }; +static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" };static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 };static const struct hdmi_platform_config hdmi_tx_8974_config = {drivers/gpu/drm/msm/hdmi/hdmi.h +4
-4@@ -84,20 +84,20 @@ struct hdmi {/* platform config data (ie. from DT, or pdata) */ struct hdmi_platform_config {/* regulators that need to be on for hpd: */ -const char **hpd_reg_names; +const char *const *hpd_reg_names;int hpd_reg_cnt;/* regulators that need to be on for screen pwr: */ -const char **pwr_reg_names; +const char *const *pwr_reg_names;int pwr_reg_cnt;/* clks that need to be on for hpd: */ -const char **hpd_clk_names; +const char *const *hpd_clk_names;const long unsigned *hpd_freq;int hpd_clk_cnt;/* clks that need to be on for screen pwr (ie pixel clk): */ -const char **pwr_clk_names; +const char *const *pwr_clk_names;int pwr_clk_cnt; };
PATCH v4 4/16 drm/msm/hdmi: move the alt_iface clock to the hpd list
In reply to Dmitry BaryshkovAccording to the vendor kernel [1] , the alt_iface clock should be enabled together with the rest of HPD clocks, to make HPD to work properly.
[1] https://git.codelinaro.org/clo/la/kernel/msm-3.18/-/commit/e07a5487e521e57f76083c0a6e2f995414ac6d03
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +3 -3
@@ -233,9 +233,9 @@ static const struct hdmi_platform_config hdmi_tx_8960_config = { };static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; -static const char *const pwr_clk_names_8x74[] = {"extp" ,"alt_iface" }; -static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" }; -static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 }; +static const char *const pwr_clk_names_8x74[] = {"extp" }; +static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" }; +static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 ,0 };static const struct hdmi_platform_config hdmi_tx_8974_config = { HDMI_CFG(pwr_reg, 8x74),
Signature · 1 line
2.39.5
PATCH v4 5/16 drm/msm/hdmi: simplify extp clock handling
In reply to Dmitry BaryshkovWith the extp being the only "power" clock left, remove the surrounding loops and handle the extp clock directly.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 24 ++++-------------------- drivers/gpu/drm/msm/hdmi/hdmi.h | 6 +----- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 33 +++++++++++++-------------------- 3 files changed, 18 insertions(+), 45 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +4 -20
@@ -233,13 +233,11 @@ static const struct hdmi_platform_config hdmi_tx_8960_config = { };static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; -static const char *const pwr_clk_names_8x74[] = {"extp" };static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" };static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 ,0 };static const struct hdmi_platform_config hdmi_tx_8974_config = { HDMI_CFG(pwr_reg, 8x74), - HDMI_CFG(pwr_clk, 8x74), HDMI_CFG(hpd_clk, 8x74), .hpd_freq = hpd_clk_freq_8x74, };
@@ -369,24 +367,10 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) hdmi->hpd_clks[i] = clk; } - hdmi->pwr_clks =devm_kcalloc (&pdev->dev, - config->pwr_clk_cnt, -sizeof (hdmi->pwr_clks[0 ]), -GFP_KERNEL ); -if (!hdmi->pwr_clks) -return -ENOMEM ; - -for (i =0 ; i < config->pwr_clk_cnt; i++) { -struct clk *clk; - - clk =msm_clk_get (pdev, config->pwr_clk_names[i]); -if (IS_ERR (clk)) -return dev_err_probe (dev,PTR_ERR (clk), -"failed to get pwr clk: %s\n" , - config->pwr_clk_names[i]); - - hdmi->pwr_clks[i] = clk; - } + hdmi->extp_clk =devm_clk_get_optional (&pdev->dev,"extp" ); +if (IS_ERR (hdmi->extp_clk)) +return dev_err_probe (dev,PTR_ERR (hdmi->extp_clk), +"failed to get extp clock\n" ); hdmi->hpd_gpiod =devm_gpiod_get_optional (&pdev->dev,"hpd" ,GPIOD_IN );/* This will catch e.g. -EPROBE_DEFER */
drivers/gpu/drm/msm/hdmi/hdmi.h +1 -5
@@ -50,7 +50,7 @@ struct hdmi {struct regulator_bulk_data *hpd_regs;struct regulator_bulk_data *pwr_regs;struct clk **hpd_clks; -struct clk **pwr_clks; +struct clk *extp_clk;struct gpio_desc *hpd_gpiod;
@@ -95,10 +95,6 @@ struct hdmi_platform_config {const char *const *hpd_clk_names;const long unsigned *hpd_freq;int hpd_clk_cnt; - -/* clks that need to be on for screen pwr (ie pixel clk): */ -const char *const *pwr_clk_names; -int pwr_clk_cnt; };struct hdmi_bridge {
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +13 -20
@@ -19,7 +19,7 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi;const struct hdmi_platform_config *config = hdmi->config; -int i, ret; +int ret;pm_runtime_get_sync (&hdmi->pdev->dev);
@@ -27,21 +27,15 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)if (ret)DRM_DEV_ERROR (dev->dev,"failed to enable pwr regulator: %d\n" , ret); -if (config->pwr_clk_cnt >0 ) { +if (hdmi->extp_clk) {DBG ("pixclock: %lu" , hdmi->pixclock); - ret =clk_set_rate (hdmi->pwr_clks[0 ], hdmi->pixclock); -if (ret) { -DRM_DEV_ERROR (dev->dev,"failed to set pixel clk: %s (%d)\n" , - config->pwr_clk_names[0 ], ret); - } - } + ret =clk_set_rate (hdmi->extp_clk, hdmi->pixclock); +if (ret) +DRM_DEV_ERROR (dev->dev,"failed to set extp clk rate: %d\n" , ret); -for (i =0 ; i < config->pwr_clk_cnt; i++) { - ret =clk_prepare_enable (hdmi->pwr_clks[i]); -if (ret) { -DRM_DEV_ERROR (dev->dev,"failed to enable pwr clk: %s (%d)\n" , - config->pwr_clk_names[i], ret); - } + ret =clk_prepare_enable (hdmi->extp_clk); +if (ret) +DRM_DEV_ERROR (dev->dev,"failed to enable extp clk: %d\n" , ret); } }
@@ -51,15 +45,15 @@ static void power_off(struct drm_bridge *bridge)struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi;const struct hdmi_platform_config *config = hdmi->config; -int i, ret; +int ret;/* TODO do we need to wait for final vblank somewhere before * cutting the clocks? */ mdelay (16 +4 ); -for (i =0 ; i < config->pwr_clk_cnt; i++) -clk_disable_unprepare (hdmi->pwr_clks[i]); +if (hdmi->extp_clk) +clk_disable_unprepare (hdmi->extp_clk); ret =regulator_bulk_disable (config->pwr_reg_cnt, hdmi->pwr_regs);if (ret)
@@ -441,7 +435,6 @@ static enum drm_mode_status msm_hdmi_bridge_tmds_char_rate_valid(const struct dr {struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi; -const struct hdmi_platform_config *config = hdmi->config;struct msm_drm_private *priv = bridge->dev->dev_private;struct msm_kms *kms = priv->kms;long actual;
@@ -454,8 +447,8 @@ static enum drm_mode_status msm_hdmi_bridge_tmds_char_rate_valid(const struct dr actual = kms->funcs->round_pixclk (kms, tmds_rate, hdmi_bridge->hdmi->encoder); - else if (config->pwr_clk_cnt > 0) - actual =clk_round_rate (hdmi->pwr_clks[0 ], tmds_rate); + else if (hdmi->extp_clk) + actual =clk_round_rate (hdmi->extp_clk, tmds_rate); else actual = tmds_rate;
Signature · 1 line
2.39.5
PATCH v4 6/16 drm/msm/hdmi: drop clock frequency assignment
In reply to Dmitry BaryshkovThe only clock which has frequency being set through hpd_freqs is the "core" aka MDSS_HDMI_CLK clock. It always has the specified frequency, so we can drop corresponding clk_set_rate() call together with the hpd_freq infrastructure.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 2 -- drivers/gpu/drm/msm/hdmi/hdmi.h | 1 - drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 9 --------- 3 files changed, 12 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +0 -2
@@ -234,12 +234,10 @@ static const struct hdmi_platform_config hdmi_tx_8960_config = {static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" };static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" }; -static unsigned long hpd_clk_freq_8x74[] = {0 ,19200000 ,0 ,0 };static const struct hdmi_platform_config hdmi_tx_8974_config = { HDMI_CFG(pwr_reg, 8x74), HDMI_CFG(hpd_clk, 8x74), - .hpd_freq = hpd_clk_freq_8x74, };static int msm_hdmi_bind (struct device *dev,struct device *master,void *data)
drivers/gpu/drm/msm/hdmi/hdmi.h +0 -1
@@ -93,7 +93,6 @@ struct hdmi_platform_config {/* clks that need to be on for hpd: */ const char *const *hpd_clk_names; -const long unsigned *hpd_freq;int hpd_clk_cnt; };
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +0 -9
@@ -68,15 +68,6 @@ static void enable_hpd_clocks(struct hdmi *hdmi, bool enable)if (enable) {for (i =0 ; i < config->hpd_clk_cnt; i++) { -if (config->hpd_freq && config->hpd_freq[i]) { - ret =clk_set_rate (hdmi->hpd_clks[i], - config->hpd_freq[i]); -if (ret) -dev_warn (dev, -"failed to set clk %s (%d)\n" , - config->hpd_clk_names[i], ret); - } - ret =clk_prepare_enable (hdmi->hpd_clks[i]);if (ret) { DRM_DEV_ERROR(dev,
Signature · 1 line
2.39.5
PATCH v4 7/16 drm/msm/hdmi: switch to clk_bulk API
In reply to Dmitry BaryshkovThe last platform using legacy clock names for HDMI block (APQ8064) switched to new clock names in 5.16. It's time to stop caring about old DT, drop hand-coded helpers and switch to clk_bulk_* API.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 15 +++++--------- drivers/gpu/drm/msm/hdmi/hdmi.h | 2 +- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 39 +++++++++++++------------------------ 3 files changed, 19 insertions(+), 37 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +5 -10
@@ -353,17 +353,12 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)if (!hdmi->hpd_clks)return -ENOMEM ; -for (i =0 ; i < config->hpd_clk_cnt; i++) { -struct clk *clk; +for (i =0 ; i < config->hpd_clk_cnt; i++) + hdmi->hpd_clks[i].id = config->hpd_clk_names[i]; - clk =msm_clk_get (pdev, config->hpd_clk_names[i]); -if (IS_ERR (clk)) -return dev_err_probe (dev,PTR_ERR (clk), -"failed to get hpd clk: %s\n" , - config->hpd_clk_names[i]); - - hdmi->hpd_clks[i] = clk; - } + ret =devm_clk_bulk_get (&pdev->dev, config->hpd_clk_cnt, hdmi->hpd_clks); +if (ret) +return ret; hdmi->extp_clk =devm_clk_get_optional (&pdev->dev,"extp" );if (IS_ERR (hdmi->extp_clk))
drivers/gpu/drm/msm/hdmi/hdmi.h +1 -1
@@ -49,7 +49,7 @@ struct hdmi {struct regulator_bulk_data *hpd_regs;struct regulator_bulk_data *pwr_regs; -struct clk **hpd_clks; +struct clk_bulk_data *hpd_clks;struct clk *extp_clk;struct gpio_desc *hpd_gpiod;
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +13 -26
@@ -60,27 +60,6 @@ static void msm_hdmi_phy_reset(struct hdmi *hdmi) } } -static void enable_hpd_clocks (struct hdmi *hdmi,bool enable) -{ -const struct hdmi_platform_config *config = hdmi->config; -struct device *dev = &hdmi->pdev->dev; -int i, ret; - -if (enable) { -for (i =0 ; i < config->hpd_clk_cnt; i++) { - ret =clk_prepare_enable (hdmi->hpd_clks[i]); -if (ret) { -DRM_DEV_ERROR (dev, -"failed to enable hpd clk: %s (%d)\n" , - config->hpd_clk_names[i], ret); - } - } - }else { -for (i = config->hpd_clk_cnt -1 ; i >=0 ; i--) -clk_disable_unprepare (hdmi->hpd_clks[i]); - } -} -int msm_hdmi_hpd_enable (struct drm_bridge *bridge) {struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);
@@ -107,7 +86,9 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)gpiod_set_value_cansleep (hdmi->hpd_gpiod,1 );pm_runtime_get_sync (dev); -enable_hpd_clocks (hdmi, true); + ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks); +if (ret) + goto fail;msm_hdmi_set_mode (hdmi, false);msm_hdmi_phy_reset (hdmi);
@@ -149,7 +130,7 @@ void msm_hdmi_hpd_disable(struct hdmi *hdmi)msm_hdmi_set_mode (hdmi, false); -enable_hpd_clocks (hdmi, false); +clk_bulk_disable_unprepare (config->hpd_clk_cnt, hdmi->hpd_clks);pm_runtime_put (dev); ret =pinctrl_pm_select_sleep_state (dev);
@@ -193,14 +174,20 @@ void msm_hdmi_hpd_irq(struct drm_bridge *bridge)static enum drm_connector_status detect_reg (struct hdmi *hdmi) { -uint32_t hpd_int_status; +const struct hdmi_platform_config *config = hdmi->config; +u32 hpd_int_status =0 ; +int ret;pm_runtime_get_sync (&hdmi->pdev->dev); -enable_hpd_clocks (hdmi, true); + ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks); +if (ret) + goto out; hpd_int_status =hdmi_read (hdmi,REG_HDMI_HPD_INT_STATUS ); -enable_hpd_clocks (hdmi, false); +clk_bulk_disable_unprepare (config->hpd_clk_cnt, hdmi->hpd_clks); + +out:pm_runtime_put (&hdmi->pdev->dev); return (hpd_int_status & HDMI_HPD_INT_STATUS_CABLE_DETECTED) ?
Signature · 1 line
2.39.5
PATCH v4 8/16 drm/msm/hdmi: switch to pm_runtime_resume_and_get()
In reply to Dmitry BaryshkovThe pm_runtime_get_sync() function is a bad choise for runtime power management. Switch HDMI driver to pm_runtime_resume_and_get() and add proper error handling, while we are at it.
--- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 +- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 12 ++++++++++-- drivers/gpu/drm/msm/hdmi/hdmi_phy.c | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +1 -1
@@ -21,7 +21,7 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)const struct hdmi_platform_config *config = hdmi->config;int ret; -pm_runtime_get_sync (&hdmi->pdev->dev); +pm_runtime_resume_and_get (&hdmi->pdev->dev); ret =regulator_bulk_enable (config->pwr_reg_cnt, hdmi->pwr_regs);if (ret)
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +10 -2
@@ -85,7 +85,12 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)if (hdmi->hpd_gpiod)gpiod_set_value_cansleep (hdmi->hpd_gpiod,1 ); -pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret) { +DRM_DEV_ERROR (dev,"runtime resume failed: %d\n" , ret); + goto fail; + } + ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks);if (ret) goto fail;
@@ -178,7 +183,10 @@ static enum drm_connector_status detect_reg(struct hdmi *hdmi)u32 hpd_int_status =0 ;int ret; -pm_runtime_get_sync (&hdmi->pdev->dev); + ret =pm_runtime_resume_and_get (&hdmi->pdev->dev); +if (ret) + goto out; + ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks);if (ret) goto out;
drivers/gpu/drm/msm/hdmi/hdmi_phy.c +5 -1
@@ -58,7 +58,11 @@ int msm_hdmi_phy_resource_enable(struct hdmi_phy *phy)struct device *dev = &phy->pdev->dev;int i, ret =0 ; -pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev); +if (ret) { +DRM_DEV_ERROR (dev,"runtime resume failed: %d\n" , ret); +return ret; + } ret =regulator_bulk_enable (cfg->num_regs, phy->regs);if (ret) {
Signature · 1 line
2.39.5
PATCH v4 9/16 drm/msm/hdmi: add runtime PM calls to DDC transfer function
In reply to Dmitry BaryshkovWe must be sure that the HDMI controller is powered on, while performing the DDC transfer. Add corresponding runtime PM calls to msm_hdmi_i2c_xfer().
--- drivers/gpu/drm/msm/hdmi/hdmi_i2c.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi_i2c.c +12 -2
@@ -107,11 +107,15 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,if (num ==0 )return num; + ret =pm_runtime_resume_and_get (&hdmi->pdev->dev); +if (ret) +return ret; +init_ddc (hdmi_i2c); ret =ddc_clear_irq (hdmi_i2c);if (ret) -return ret; + goto fail;for (i =0 ; i < num; i++) {struct i2c_msg *p = &msgs[i];
@@ -169,7 +173,7 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c,hdmi_read (hdmi,REG_HDMI_DDC_SW_STATUS ),hdmi_read (hdmi,REG_HDMI_DDC_HW_STATUS ), hdmi_read(hdmi, REG_HDMI_DDC_INT_CTRL)); -return ret; + goto fail; } ddc_status =hdmi_read (hdmi,REG_HDMI_DDC_SW_STATUS );
@@ -202,7 +206,13 @@ static int msm_hdmi_i2c_xfer(struct i2c_adapter *i2c, } } +pm_runtime_put (&hdmi->pdev->dev); +return i; + +fail: +pm_runtime_put (&hdmi->pdev->dev); +return ret; }static u32 msm_hdmi_i2c_func (struct i2c_adapter *adapter)
Signature · 1 line
2.39.5
PATCH v4 10/16 drm/msm/hdmi: implement proper runtime PM handling
In reply to Dmitry BaryshkovIt is completely not obvious, but the so-called 'hpd' clocks and regulators are required for the HDMI host to function properly. Merge pwr and hpd regulators. Use regulators, clocks and pinctrl to implement proper runtime PM callbacks.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 62 +++++++++++++++++++++++++--------- drivers/gpu/drm/msm/hdmi/hdmi.h | 5 --- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 12 ------- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 42 +---------------------- 4 files changed, 47 insertions(+), 74 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +46 -16
@@ -8,6 +8,7 @@#include <linux/gpio/consumer.h> #include <linux/of_irq.h> #include <linux/of_platform.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <drm/drm_bridge_connector.h>
@@ -224,11 +225,11 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, .item ## _names = item ##_names_ ## entry, \ .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry) -static const char *const hpd_reg_names_8960[] = {"core-vdda" }; +static const char *const pwr_reg_names_8960[] = {"core-vdda" };static const char *const hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" };static const struct hdmi_platform_config hdmi_tx_8960_config = { -HDMI_CFG (hpd_reg,8960 ), +HDMI_CFG (pwr_reg,8960 ),HDMI_CFG (hpd_clk,8960 ), };
@@ -318,20 +319,6 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)if (hdmi->irq <0 )return hdmi->irq; - hdmi->hpd_regs =devm_kcalloc (&pdev->dev, - config->hpd_reg_cnt, -sizeof (hdmi->hpd_regs[0 ]), -GFP_KERNEL ); -if (!hdmi->hpd_regs) -return -ENOMEM ; - -for (i =0 ; i < config->hpd_reg_cnt; i++) - hdmi->hpd_regs[i].supply = config->hpd_reg_names[i]; - - ret =devm_regulator_bulk_get (&pdev->dev, config->hpd_reg_cnt, hdmi->hpd_regs); -if (ret) -return dev_err_probe (dev, ret,"failed to get hpd regulators\n" ); - hdmi->pwr_regs = devm_kcalloc(&pdev->dev, config->pwr_reg_cnt, sizeof(hdmi->pwr_regs[0]),
@@ -409,6 +396,48 @@ static void msm_hdmi_dev_remove(struct platform_device *pdev)msm_hdmi_put_phy (hdmi); } +static int msm_hdmi_runtime_suspend (struct device *dev) +{ +struct hdmi *hdmi =dev_get_drvdata (dev); +const struct hdmi_platform_config *config = hdmi->config; + +clk_bulk_disable_unprepare (config->hpd_clk_cnt, hdmi->hpd_clks); + +pinctrl_pm_select_sleep_state (dev); + +regulator_bulk_disable (config->pwr_reg_cnt, hdmi->pwr_regs); + +return 0 ; +} + +static int msm_hdmi_runtime_resume (struct device *dev) +{ +struct hdmi *hdmi =dev_get_drvdata (dev); +const struct hdmi_platform_config *config = hdmi->config; +int ret; + + ret =regulator_bulk_enable (config->pwr_reg_cnt, hdmi->pwr_regs); +if (ret) +return ret; + + ret =pinctrl_pm_select_default_state (dev); +if (ret) + goto fail; + + ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks); +if (ret) + goto fail; + +return 0 ; + +fail: +pinctrl_pm_select_sleep_state (dev); + +return ret; +} + +DEFINE_RUNTIME_DEV_PM_OPS (msm_hdmi_pm_ops, msm_hdmi_runtime_suspend, msm_hdmi_runtime_resume,NULL ); +static const struct of_device_id msm_hdmi_dt_match[] = { { .compatible ="qcom,hdmi-tx-8998" , .data = &hdmi_tx_8974_config }, { .compatible ="qcom,hdmi-tx-8996" , .data = &hdmi_tx_8974_config },
@@ -426,6 +455,7 @@ static struct platform_driver msm_hdmi_driver = { .driver = { .name = "hdmi_msm", .of_match_table = msm_hdmi_dt_match, + .pm = &msm_hdmi_pm_ops, }, };
drivers/gpu/drm/msm/hdmi/hdmi.h +0 -5
@@ -47,7 +47,6 @@ struct hdmi {void __iomem *qfprom_mmio;phys_addr_t mmio_phy_addr; -struct regulator_bulk_data *hpd_regs;struct regulator_bulk_data *pwr_regs;struct clk_bulk_data *hpd_clks;struct clk *extp_clk;
@@ -83,10 +82,6 @@ struct hdmi {/* platform config data (ie. from DT, or pdata) */ struct hdmi_platform_config { -/* regulators that need to be on for hpd: */ -const char *const *hpd_reg_names; -int hpd_reg_cnt; -/* regulators that need to be on for screen pwr: */ const char *const *pwr_reg_names;int pwr_reg_cnt;
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +0 -12
@@ -18,15 +18,10 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)struct drm_device *dev = bridge->dev;struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi; -const struct hdmi_platform_config *config = hdmi->config;int ret;pm_runtime_resume_and_get (&hdmi->pdev->dev); - ret =regulator_bulk_enable (config->pwr_reg_cnt, hdmi->pwr_regs); -if (ret) -DRM_DEV_ERROR (dev->dev,"failed to enable pwr regulator: %d\n" , ret); -if (hdmi->extp_clk) {DBG ("pixclock: %lu" , hdmi->pixclock); ret =clk_set_rate (hdmi->extp_clk, hdmi->pixclock);
@@ -41,11 +36,8 @@ static void msm_hdmi_power_on(struct drm_bridge *bridge)static void power_off (struct drm_bridge *bridge) { -struct drm_device *dev = bridge->dev;struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi; -const struct hdmi_platform_config *config = hdmi->config; -int ret;/* TODO do we need to wait for final vblank somewhere before * cutting the clocks?
@@ -55,10 +47,6 @@ static void power_off(struct drm_bridge *bridge)if (hdmi->extp_clk)clk_disable_unprepare (hdmi->extp_clk); - ret =regulator_bulk_disable (config->pwr_reg_cnt, hdmi->pwr_regs); -if (ret) -DRM_DEV_ERROR (dev->dev,"failed to disable pwr regulator: %d\n" , ret); -pm_runtime_put (&hdmi->pdev->dev); }
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +1 -41
90 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 11/16 drm/msm/hdmi: rename hpd_clks to pwr_clks
In reply to Dmitry BaryshkovAs these clocks are now used in the runtime PM callbacks, they have no connection to 'HPD'. Rename corresponding fields to follow clocks purpose, to power up the HDMI controller.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 26 +++++++++++++------------- drivers/gpu/drm/msm/hdmi/hdmi.h | 6 +++--- 2 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +13 -13
@@ -226,19 +226,19 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry)static const char *const pwr_reg_names_8960[] = {"core-vdda" }; -static const char *const hpd_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" }; +static const char *const pwr_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" };static const struct hdmi_platform_config hdmi_tx_8960_config = {HDMI_CFG (pwr_reg,8960 ), -HDMI_CFG (hpd_clk,8960 ), +HDMI_CFG (pwr_clk,8960 ), };static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" }; -static const char *const hpd_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" }; +static const char *const pwr_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" };static const struct hdmi_platform_config hdmi_tx_8974_config = { HDMI_CFG(pwr_reg, 8x74), - HDMI_CFG(hpd_clk, 8x74), + HDMI_CFG(pwr_clk, 8x74), };static int msm_hdmi_bind (struct device *dev,struct device *master,void *data)
@@ -333,17 +333,17 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)if (ret)return dev_err_probe (dev, ret,"failed to get pwr regulators\n" ); - hdmi->hpd_clks =devm_kcalloc (&pdev->dev, - config->hpd_clk_cnt, -sizeof (hdmi->hpd_clks[0 ]), + hdmi->pwr_clks =devm_kcalloc (&pdev->dev, + config->pwr_clk_cnt, +sizeof (hdmi->pwr_clks[0 ]),GFP_KERNEL ); -if (!hdmi->hpd_clks) +if (!hdmi->pwr_clks)return -ENOMEM ; -for (i =0 ; i < config->hpd_clk_cnt; i++) - hdmi->hpd_clks[i].id = config->hpd_clk_names[i]; +for (i =0 ; i < config->pwr_clk_cnt; i++) + hdmi->pwr_clks[i].id = config->pwr_clk_names[i]; - ret =devm_clk_bulk_get (&pdev->dev, config->hpd_clk_cnt, hdmi->hpd_clks); + ret =devm_clk_bulk_get (&pdev->dev, config->pwr_clk_cnt, hdmi->pwr_clks);if (ret)return ret;
@@ -401,7 +401,7 @@ static int msm_hdmi_runtime_suspend(struct device *dev)struct hdmi *hdmi =dev_get_drvdata (dev);const struct hdmi_platform_config *config = hdmi->config; -clk_bulk_disable_unprepare (config->hpd_clk_cnt, hdmi->hpd_clks); +clk_bulk_disable_unprepare (config->pwr_clk_cnt, hdmi->pwr_clks);pinctrl_pm_select_sleep_state (dev);
@@ -424,7 +424,7 @@ static int msm_hdmi_runtime_resume(struct device *dev)if (ret) goto fail; - ret =clk_bulk_prepare_enable (config->hpd_clk_cnt, hdmi->hpd_clks); + ret =clk_bulk_prepare_enable (config->pwr_clk_cnt, hdmi->pwr_clks);if (ret) goto fail;
drivers/gpu/drm/msm/hdmi/hdmi.h +3 -3
@@ -48,7 +48,7 @@ struct hdmi {phys_addr_t mmio_phy_addr;struct regulator_bulk_data *pwr_regs; -struct clk_bulk_data *hpd_clks; +struct clk_bulk_data *pwr_clks;struct clk *extp_clk;struct gpio_desc *hpd_gpiod;
@@ -87,8 +87,8 @@ struct hdmi_platform_config {int pwr_reg_cnt;/* clks that need to be on for hpd: */ -const char *const *hpd_clk_names; -int hpd_clk_cnt; +const char *const *pwr_clk_names; +int pwr_clk_cnt; };struct hdmi_bridge {
Signature · 1 line
2.39.5
PATCH v4 12/16 drm/msm/hdmi: expand the HDMI_CFG macro
In reply to Dmitry BaryshkovExpand the HDMI_CFG() macro in HDMI config description. It has no added value other than hiding some boilerplate declarations.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 16 ++++++++-------- drivers/gpu/drm/msm/hdmi/hdmi.h | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +8 -8
@@ -221,24 +221,24 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi,* The hdmi device: */ -#define HDMI_CFG (item, entry) \ - .item ## _names = item ##_names_ ## entry, \ - .item ## _cnt = ARRAY_SIZE(item ## _names_ ## entry) -static const char *const pwr_reg_names_8960[] = {"core-vdda" };static const char *const pwr_clk_names_8960[] = {"core" ,"master_iface" ,"slave_iface" };static const struct hdmi_platform_config hdmi_tx_8960_config = { -HDMI_CFG (pwr_reg,8960 ), -HDMI_CFG (pwr_clk,8960 ), + .pwr_reg_names = pwr_reg_names_8960, + .pwr_reg_cnt =ARRAY_SIZE (pwr_reg_names_8960), + .pwr_clk_names = pwr_clk_names_8960, + .pwr_clk_cnt =ARRAY_SIZE (pwr_clk_names_8960), };static const char *const pwr_reg_names_8x74[] = {"core-vdda" ,"core-vcc" };static const char *const pwr_clk_names_8x74[] = {"iface" ,"core" ,"mdp_core" ,"alt_iface" };static const struct hdmi_platform_config hdmi_tx_8974_config = { - HDMI_CFG(pwr_reg, 8x74), - HDMI_CFG(pwr_clk, 8x74), + .pwr_reg_names = pwr_reg_names_8x74, + .pwr_reg_cnt =ARRAY_SIZE (pwr_reg_names_8x74), + .pwr_clk_names = pwr_clk_names_8x74, + .pwr_clk_cnt =ARRAY_SIZE (pwr_clk_names_8x74), };static int msm_hdmi_bind (struct device *dev,struct device *master,void *data)
drivers/gpu/drm/msm/hdmi/hdmi.h +1 -1
@@ -86,7 +86,7 @@ struct hdmi_platform_config {const char *const *pwr_reg_names;int pwr_reg_cnt; -/* clks that need to be on for hpd: */ +/* clks that need to be on: */ const char *const *pwr_clk_names;int pwr_clk_cnt; };
Signature · 1 line
2.39.5
PATCH v4 13/16 drm/msm/hdmi: drop hpd-gpios support
In reply to Dmitry BaryshkovSupporting simultaneous check of native HPD and the external GPIO proved to be less stable than just native HPD. Drop the hpd-gpios support, leaving just the native HPD support. In case the native HPD doesn't work the user is urged to switch to specifying the HPD property to the hdmi-connector device.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 14 +++------- drivers/gpu/drm/msm/hdmi/hdmi.h | 2 -- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 52 +++---------------------------------- 3 files changed, 6 insertions(+), 62 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +3 -11
@@ -352,17 +352,9 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (hdmi->extp_clk),"failed to get extp clock\n" ); - hdmi->hpd_gpiod =devm_gpiod_get_optional (&pdev->dev,"hpd" ,GPIOD_IN ); -/* This will catch e.g. -EPROBE_DEFER */ -if (IS_ERR (hdmi->hpd_gpiod)) -return dev_err_probe (dev,PTR_ERR (hdmi->hpd_gpiod), -"failed to get hpd gpio\n" ); - -if (!hdmi->hpd_gpiod) -DBG ("failed to get HPD gpio" ); - -if (hdmi->hpd_gpiod) -gpiod_set_consumer_name (hdmi->hpd_gpiod,"HDMI_HPD" ); +if (of_find_property (dev->of_node,"hpd-gpios" ,NULL ) || +of_find_property (dev->of_node,"hpd-gpio" ,NULL )) +dev_warn (dev,"hpd-gpios is not supported anymore, please migrate to the hdmi-connector\n" ); ret =msm_hdmi_get_phy (hdmi);if (ret) {
drivers/gpu/drm/msm/hdmi/hdmi.h +0 -2
@@ -51,8 +51,6 @@ struct hdmi {struct clk_bulk_data *pwr_clks;struct clk *extp_clk; -struct gpio_desc *hpd_gpiod; -struct hdmi_phy *phy;struct device *phy_dev;
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +3 -49
68 lines not on this page · raw message
Signature · 1 line
2.39.5
PATCH v4 14/16 drm/msm/hdmi: ensure that HDMI is up if HPD is requested
In reply to Dmitry BaryshkovThe HDMI block needs to be enabled to properly generate HPD events. Make sure it is not turned off in the disable paths if HPD delivery is enabled.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 1 + drivers/gpu/drm/msm/hdmi/hdmi.h | 2 ++ drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 8 +++++++- drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 9 ++++++++- 4 files changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +1 -0
@@ -293,6 +293,7 @@ static int msm_hdmi_dev_probe(struct platform_device *pdev) hdmi->pdev = pdev; hdmi->config = config;spin_lock_init (&hdmi->reg_lock); +mutex_init (&hdmi->state_mutex); ret =drm_of_find_panel_or_bridge (pdev->dev.of_node,1 ,0 ,NULL , &hdmi->next_bridge);if (ret && ret != -ENODEV )
drivers/gpu/drm/msm/hdmi/hdmi.h +2 -0
@@ -41,6 +41,8 @@ struct hdmi {/* video state: */ bool power_on; +bool hpd_enabled; +struct mutex state_mutex;/* protects two booleans */ unsigned long int pixclock;void __iomem *mmio;
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +7 -1
@@ -303,6 +303,7 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,msm_hdmi_set_timings (hdmi, &crtc_state->adjusted_mode); +mutex_lock (&hdmi->state_mutex);if (!hdmi->power_on) {msm_hdmi_phy_resource_enable (phy);msm_hdmi_power_on (bridge);
@@ -310,6 +311,7 @@ static void msm_hdmi_bridge_atomic_pre_enable(struct drm_bridge *bridge,if (connector->display_info.is_hdmi)msm_hdmi_audio_update (hdmi); } +mutex_unlock (&hdmi->state_mutex);drm_atomic_helper_connector_hdmi_update_infoframes (connector, state);
@@ -332,7 +334,10 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,msm_hdmi_hdcp_off (hdmi->hdcp_ctrl);DBG ("power down" ); -msm_hdmi_set_mode (hdmi, false); + +/* Keep the HDMI enabled if the HPD is enabled */ +mutex_lock (&hdmi->state_mutex); +msm_hdmi_set_mode (hdmi, hdmi->hpd_enabled);msm_hdmi_phy_powerdown (phy);
@@ -343,6 +348,7 @@ static void msm_hdmi_bridge_atomic_post_disable(struct drm_bridge *bridge,msm_hdmi_audio_update (hdmi);msm_hdmi_phy_resource_disable (phy); } +mutex_unlock (&hdmi->state_mutex); } static void msm_hdmi_set_timings(struct hdmi *hdmi,
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +8 -1
@@ -73,10 +73,14 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)if (ret)return ret; +mutex_lock (&hdmi->state_mutex);msm_hdmi_set_mode (hdmi, false);msm_hdmi_phy_reset (hdmi);msm_hdmi_set_mode (hdmi, true); + hdmi->hpd_enabled = true; +mutex_unlock (&hdmi->state_mutex); +hdmi_write (hdmi,REG_HDMI_USEC_REFTIMER ,0x0001001b );/* enable HPD events: */
@@ -106,7 +110,10 @@ void msm_hdmi_hpd_disable(struct hdmi *hdmi)/* Disable HPD interrupt */ hdmi_write (hdmi,REG_HDMI_HPD_INT_CTRL ,0 ); -msm_hdmi_set_mode (hdmi, false); +mutex_lock (&hdmi->state_mutex); + hdmi->hpd_enabled = false; +msm_hdmi_set_mode (hdmi, hdmi->power_on); +mutex_unlock (&hdmi->state_mutex);pm_runtime_put (dev); }
Signature · 1 line
2.39.5
PATCH v4 15/16 drm/msm/hdmi: wire in hpd_enable/hpd_disable bridge ops
In reply to Dmitry BaryshkovThe HDMI driver already has msm_hdmi_hpd_enable() and msm_hdmi_hpd_disable() functions. Wire them into the msm_hdmi_bridge_funcs, so that HPD can be enabled and disabled dynamically rather than always having HPD events generation enabled.
--- drivers/gpu/drm/msm/hdmi/hdmi.c | 9 --------- drivers/gpu/drm/msm/hdmi/hdmi.h | 4 ++-- drivers/gpu/drm/msm/hdmi/hdmi_bridge.c | 2 ++ drivers/gpu/drm/msm/hdmi/hdmi_hpd.c | 12 ++++++------ 4 files changed, 10 insertions(+), 17 deletions(-)
drivers/gpu/drm/msm/hdmi/hdmi.c +0 -9
@@ -200,12 +200,6 @@ int msm_hdmi_modeset_init(struct hdmi *hdmi, goto fail; } - ret =msm_hdmi_hpd_enable (hdmi->bridge); -if (ret <0 ) { -DRM_DEV_ERROR (&hdmi->pdev->dev,"failed to enable HPD: %d\n" , ret); - goto fail; - } -return 0 ; fail:
@@ -261,9 +255,6 @@ static void msm_hdmi_unbind(struct device *dev, struct device *master,struct msm_drm_private *priv =dev_get_drvdata (master);if (priv->hdmi) { -if (priv->hdmi->bridge) -msm_hdmi_hpd_disable (priv->hdmi); -msm_hdmi_destroy (priv->hdmi); priv->hdmi =NULL ; }
drivers/gpu/drm/msm/hdmi/hdmi.h +2 -2
@@ -214,8 +214,8 @@ int msm_hdmi_bridge_init(struct hdmi *hdmi);void msm_hdmi_hpd_irq (struct drm_bridge *bridge);enum drm_connector_status msm_hdmi_bridge_detect (struct drm_bridge *bridge); -int msm_hdmi_hpd_enable (struct drm_bridge *bridge); -void msm_hdmi_hpd_disable (struct hdmi *hdmi); +void msm_hdmi_hpd_enable (struct drm_bridge *bridge); +void msm_hdmi_hpd_disable (struct drm_bridge *bridge);/* * i2c adapter for ddc:
drivers/gpu/drm/msm/hdmi/hdmi_bridge.c +2 -0
@@ -462,6 +462,8 @@ static const struct drm_bridge_funcs msm_hdmi_bridge_funcs = { .atomic_post_disable = msm_hdmi_bridge_atomic_post_disable, .edid_read = msm_hdmi_bridge_edid_read, .detect = msm_hdmi_bridge_detect, + .hpd_enable = msm_hdmi_hpd_enable, + .hpd_disable = msm_hdmi_hpd_disable, .hdmi_tmds_char_rate_valid = msm_hdmi_bridge_tmds_char_rate_valid, .hdmi_clear_infoframe = msm_hdmi_bridge_clear_infoframe, .hdmi_write_infoframe = msm_hdmi_bridge_write_infoframe,
drivers/gpu/drm/msm/hdmi/hdmi_hpd.c +6 -6
@@ -60,7 +60,7 @@ static void msm_hdmi_phy_reset(struct hdmi *hdmi) } } -int msm_hdmi_hpd_enable (struct drm_bridge *bridge) +void msm_hdmi_hpd_enable (struct drm_bridge *bridge) {struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge);struct hdmi *hdmi = hdmi_bridge->hdmi;
@@ -70,8 +70,8 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)unsigned long flags; ret =pm_runtime_resume_and_get (dev); -if (ret) -return ret; +if (WARN_ON (ret)) +return ;mutex_lock (&hdmi->state_mutex);msm_hdmi_set_mode (hdmi, false);
@@ -99,12 +99,12 @@ int msm_hdmi_hpd_enable(struct drm_bridge *bridge)hdmi_write (hdmi,REG_HDMI_HPD_CTRL ,HDMI_HPD_CTRL_ENABLE | hpd_ctrl);spin_unlock_irqrestore (&hdmi->reg_lock, flags); - -return 0 ; } -void msm_hdmi_hpd_disable (struct hdmi *hdmi) +void msm_hdmi_hpd_disable (struct drm_bridge *bridge) { +struct hdmi_bridge *hdmi_bridge =to_hdmi_bridge (bridge); +struct hdmi *hdmi = hdmi_bridge->hdmi;struct device *dev = &hdmi->pdev->dev;/* Disable HPD interrupt */
Signature · 1 line
2.39.5
PATCH v4 16/16 ARM: dts: qcom: apq8064-ifc6410: drop HDMI HPD GPIO
In reply to Dmitry BaryshkovThere is no need to specify separate HPD gpio for the HDMI block. Use built-in HPD in order to detect if the monitor is plugged or not.
--- arch/arm/boot/dts/qcom/qcom-apq8064-ifc6410.dts | 1 - 1 file changed, 1 deletion(-)
arch/arm/boot/dts/qcom/qcom-apq8064-ifc6410.dts +0 -1
@@ -138,7 +138,6 @@ &gsbi7_serial { &hdmi { core-vdda-supply = <&pm8921_hdmi_switch>; - hpd-gpios = <&tlmm_pinmux 72 GPIO_ACTIVE_HIGH>; status = "okay"; };
Signature · 1 line
2.39.5
Re: [PATCH v4 16/16] ARM: dts: qcom: apq8064-ifc6410: drop HDMI HPD GPIO
Quoted 5 lines · Dmitry Baryshkov
There is no need to specify separate HPD gpio for the HDMI block. Use built-in HPD in order to detect if the monitor is plugged or not.
Signed-off-by Dmitry Baryshkov <[email protected]>---
Konrad
Re: (subset) [PATCH v4 00/16] drm/msm/hdmi: rework and fix the HPD even generation
In reply to Dmitry BaryshkovQuoted 11 lines · Dmitry Baryshkov
The MSM HDMI driver is plagued with the long-standing bug. If HDMI cable is disconnected, in most of the cases cable reconnection will not be detected properly. We have been carrying the patch from [1] in our integration tree for ages. The time has come to fix the long-standing bug and implement proper HPD handling.
This series was tested on msm8996 and apq8064 boards. Previously HPD handling sometimes could trigger in the CRTC event handling, however I can no longer reproduce it now.
[...]
Applied, thanks!
[16/16] ARM: dts: qcom: apq8064-ifc6410: drop HDMI HPD GPIO
commit: b2c547cffe2f67e18a3a276905649cc95aa7f293
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>