All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] omapdrm/dss/hdmi4_cec.c: simplify clear_tx/rx_fifo functions
@ 2018-10-08 13:56 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2018-10-08 13:56 UTC (permalink / raw)
  To: Maling list - DRI developers, Tomi Valkeinen; +Cc: Linux Media Mailing List

Use REG_GET to avoid the temp variable.

Add pr_err_once if hdmi_cec_clear_tx_fifo() fails in hdmi4_cec_irq().

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Note: the FIFOs are cleared almost immediately (after just one try), so adding
delays is overkill.
---
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
index 00407f1995a8..92b55780aafd 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
@@ -110,16 +110,12 @@ static bool hdmi_cec_clear_tx_fifo(struct cec_adapter *adap)
 {
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int retry = HDMI_CORE_CEC_RETRY;
-	int temp;

 	REG_FLD_MOD(core->base, HDMI_CEC_DBG_3, 0x1, 7, 7);
-	while (retry) {
-		temp = hdmi_read_reg(core->base, HDMI_CEC_DBG_3);
-		if (FLD_GET(temp, 7, 7) == 0)
-			break;
-		retry--;
-	}
-	return retry != 0;
+	while (retry--)
+		if (!REG_GET(core->base, HDMI_CEC_DBG_3, 7, 7))
+			return true;
+	return false;
 }

 void hdmi4_cec_irq(struct hdmi_core_data *core)
@@ -136,7 +132,9 @@ void hdmi4_cec_irq(struct hdmi_core_data *core)
 	} else if (stat1 & 0x02) {
 		u32 dbg3 = hdmi_read_reg(core->base, HDMI_CEC_DBG_3);

-		hdmi_cec_clear_tx_fifo(core->adap);
+		if (!hdmi_cec_clear_tx_fifo(core->adap))
+			pr_err_once("cec-%s: could not clear TX FIFO\n",
+				    core->adap->name);
 		cec_transmit_done(core->adap,
 				  CEC_TX_STATUS_NACK |
 				  CEC_TX_STATUS_MAX_RETRIES,
@@ -150,17 +148,12 @@ static bool hdmi_cec_clear_rx_fifo(struct cec_adapter *adap)
 {
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int retry = HDMI_CORE_CEC_RETRY;
-	int temp;

 	hdmi_write_reg(core->base, HDMI_CEC_RX_CONTROL, 0x3);
-	retry = HDMI_CORE_CEC_RETRY;
-	while (retry) {
-		temp = hdmi_read_reg(core->base, HDMI_CEC_RX_CONTROL);
-		if (FLD_GET(temp, 1, 0) == 0)
-			break;
-		retry--;
-	}
-	return retry != 0;
+	while (retry--)
+		if (!REG_GET(core->base, HDMI_CEC_RX_CONTROL, 1, 0))
+			return true;
+	return false;
 }

 static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] omapdrm/dss/hdmi4_cec.c: simplify clear_tx/rx_fifo functions
@ 2018-10-08 13:56 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2018-10-08 13:56 UTC (permalink / raw)
  To: Maling list - DRI developers, Tomi Valkeinen; +Cc: Linux Media Mailing List

Use REG_GET to avoid the temp variable.

Add pr_err_once if hdmi_cec_clear_tx_fifo() fails in hdmi4_cec_irq().

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
Note: the FIFOs are cleared almost immediately (after just one try), so adding
delays is overkill.
---
diff --git a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
index 00407f1995a8..92b55780aafd 100644
--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_cec.c
@@ -110,16 +110,12 @@ static bool hdmi_cec_clear_tx_fifo(struct cec_adapter *adap)
 {
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int retry = HDMI_CORE_CEC_RETRY;
-	int temp;

 	REG_FLD_MOD(core->base, HDMI_CEC_DBG_3, 0x1, 7, 7);
-	while (retry) {
-		temp = hdmi_read_reg(core->base, HDMI_CEC_DBG_3);
-		if (FLD_GET(temp, 7, 7) == 0)
-			break;
-		retry--;
-	}
-	return retry != 0;
+	while (retry--)
+		if (!REG_GET(core->base, HDMI_CEC_DBG_3, 7, 7))
+			return true;
+	return false;
 }

 void hdmi4_cec_irq(struct hdmi_core_data *core)
@@ -136,7 +132,9 @@ void hdmi4_cec_irq(struct hdmi_core_data *core)
 	} else if (stat1 & 0x02) {
 		u32 dbg3 = hdmi_read_reg(core->base, HDMI_CEC_DBG_3);

-		hdmi_cec_clear_tx_fifo(core->adap);
+		if (!hdmi_cec_clear_tx_fifo(core->adap))
+			pr_err_once("cec-%s: could not clear TX FIFO\n",
+				    core->adap->name);
 		cec_transmit_done(core->adap,
 				  CEC_TX_STATUS_NACK |
 				  CEC_TX_STATUS_MAX_RETRIES,
@@ -150,17 +148,12 @@ static bool hdmi_cec_clear_rx_fifo(struct cec_adapter *adap)
 {
 	struct hdmi_core_data *core = cec_get_drvdata(adap);
 	int retry = HDMI_CORE_CEC_RETRY;
-	int temp;

 	hdmi_write_reg(core->base, HDMI_CEC_RX_CONTROL, 0x3);
-	retry = HDMI_CORE_CEC_RETRY;
-	while (retry) {
-		temp = hdmi_read_reg(core->base, HDMI_CEC_RX_CONTROL);
-		if (FLD_GET(temp, 1, 0) == 0)
-			break;
-		retry--;
-	}
-	return retry != 0;
+	while (retry--)
+		if (!REG_GET(core->base, HDMI_CEC_RX_CONTROL, 1, 0))
+			return true;
+	return false;
 }

 static int hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-08 21:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-08 13:56 [PATCH] omapdrm/dss/hdmi4_cec.c: simplify clear_tx/rx_fifo functions Hans Verkuil
2018-10-08 13:56 ` Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.