openwrt/target/linux/layerscape/patches-5.4/805-display-0020-drm-bridge-cdns-cec-fix-LA-failed-set-issue.patch

130 lines
3.7 KiB
Diff
Raw Normal View History

From 4e8d26c363c6e4b8b89d21feeb8c6dc57085b27d Mon Sep 17 00:00:00 2001
From: Sandor Yu <Sandor.yu@nxp.com>
Date: Fri, 27 Sep 2019 17:15:34 +0800
Subject: [PATCH] drm: bridge: cdns cec: fix LA failed set issue
improved function set_logical_addr() function.
Fix LA set failed issue in some case.
Signed-off-by: Sandor Yu <Sandor.yu@nxp.com>
---
drivers/gpu/drm/bridge/cadence/Kconfig | 6 ++++
drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c | 38 +++++++++++---------------
2 files changed, 22 insertions(+), 22 deletions(-)
--- a/drivers/gpu/drm/bridge/cadence/Kconfig
+++ b/drivers/gpu/drm/bridge/cadence/Kconfig
@@ -8,12 +8,18 @@ config DRM_CDNS_MHDP
config DRM_CDNS_HDMI
tristate "Cadence HDMI DRM driver"
+ depends on DRM_CDNS_MHDP
config DRM_CDNS_DP
tristate "Cadence DP DRM driver"
+ depends on DRM_CDNS_MHDP
config DRM_CDNS_AUDIO
tristate "Cadence MHDP Audio driver"
+ depends on DRM_CDNS_MHDP
config DRM_CDNS_HDMI_CEC
tristate "Cadence MHDP HDMI CEC driver"
+ depends on DRM_CDNS_HDMI
+ select CEC_CORE
+ select CEC_NOTIFIER
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp-cec.c
@@ -20,8 +20,6 @@
#define CEC_NAME "cdns-mhdp-cec"
#define REG_ADDR_OFF 4
-#define MAX_LA_IDX 4
-#define MAX_LA_VAL 15
/* regsiter define */
#define TX_MSG_HEADER 0x33800
@@ -158,26 +156,22 @@ static u32 mhdp_cec_write_message(struct
return true;
}
-//static void cec_abort_tx_transfer(struct cdns_mhdp_cec *cec)
-//{
-// cec_write(cec, TX_MSG_CMD, CEC_TX_ABORT);
-// cec_write(cec, TX_MSG_CMD, CEC_TX_STOP);
-//}
-
static int mhdp_cec_set_logical_addr(struct cdns_mhdp_cec *cec, u32 la)
{
- u8 i;
u8 la_reg;
+ u8 i;
- if (la >= MAX_LA_VAL) {
- dev_err(cec->dev, "Error logical Addr\n");
- return -EINVAL;
- }
-
- for (i = 0; i < MAX_LA_IDX; ++i) {
- la_reg =
- mhdp_cec_read(cec, LOGICAL_ADDRESS_LA0 + (i * REG_ADDR_OFF));
+ if (la == CEC_LOG_ADDR_INVALID)
+ /* invalid all LA address */
+ for (i = 0; i < CEC_MAX_LOG_ADDRS; ++i) {
+ mhdp_cec_write(cec, LOGICAL_ADDRESS_LA0 + (i * REG_ADDR_OFF), 0);
+ return 0;
+ }
+ /* In fact cdns mhdp cec could support max 5 La address */
+ for (i = 0; i < CEC_MAX_LOG_ADDRS; ++i) {
+ la_reg = mhdp_cec_read(cec, LOGICAL_ADDRESS_LA0 + (i * REG_ADDR_OFF));
+ /* Check LA already used */
if (la_reg & 0x10)
continue;
@@ -194,7 +188,7 @@ static int mhdp_cec_set_logical_addr(str
dev_warn(cec->dev, "All LA in use\n");
- return -EINVAL;
+ return -ENXIO;
}
static int mhdp_cec_poll_worker(void *_cec)
@@ -263,7 +257,7 @@ static int mhdp_cec_poll_worker(void *_c
static int mhdp_cec_adap_enable(struct cec_adapter *adap, bool enable)
{
- struct cdns_mhdp_cec *cec = adap->priv;
+ struct cdns_mhdp_cec *cec = cec_get_drvdata(adap);
if (enable) {
mhdp_cec_write(cec, DB_L_TIMER, 0x10);
@@ -276,7 +270,7 @@ static int mhdp_cec_adap_enable(struct c
static int mhdp_cec_adap_log_addr(struct cec_adapter *adap, u8 addr)
{
- struct cdns_mhdp_cec *cec = adap->priv;
+ struct cdns_mhdp_cec *cec = cec_get_drvdata(adap);
return mhdp_cec_set_logical_addr(cec, addr);
}
@@ -284,7 +278,7 @@ static int mhdp_cec_adap_log_addr(struct
static int mhdp_cec_adap_transmit(struct cec_adapter *adap, u8 attempts,
u32 signal_free_time, struct cec_msg *msg)
{
- struct cdns_mhdp_cec *cec = adap->priv;
+ struct cdns_mhdp_cec *cec = cec_get_drvdata(adap);
mhdp_cec_write_message(cec, msg);
@@ -307,7 +301,7 @@ int cdns_mhdp_register_cec_driver(struct
CEC_NAME,
CEC_CAP_PHYS_ADDR | CEC_CAP_LOG_ADDRS |
CEC_CAP_TRANSMIT | CEC_CAP_PASSTHROUGH
- | CEC_CAP_RC, 1);
+ | CEC_CAP_RC, CEC_MAX_LOG_ADDRS);
ret = PTR_ERR_OR_ZERO(cec->adap);
if (ret)
return ret;