linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cec: ignore messages that we initiated.
@ 2016-11-21 15:18 Hans Verkuil
  0 siblings, 0 replies; only message in thread
From: Hans Verkuil @ 2016-11-21 15:18 UTC (permalink / raw)
  To: Linux Media Mailing List

Some CEC adapters will receive messages that they initiated. Add a
check that will ignore such messages.

Most hardware behaves correctly in this respect, but I have seen
adapters that don't, so just filter this out in the framework.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
  drivers/media/cec/cec-adap.c | 15 +++++++++++++++
  1 file changed, 15 insertions(+)

diff --git a/drivers/media/cec/cec-adap.c b/drivers/media/cec/cec-adap.c
index d9c6f2c..0ea4efb 100644
--- a/drivers/media/cec/cec-adap.c
+++ b/drivers/media/cec/cec-adap.c
@@ -869,6 +869,21 @@ void cec_received_msg(struct cec_adapter *adap, 
struct cec_msg *msg)
  	if (WARN_ON(!msg->len || msg->len > CEC_MAX_MSG_SIZE))
  		return;

+	/*
+	 * Some CEC adapters will receive the messages that they transmitted.
+	 * This test filters out those messages by checking if we are the
+	 * initiator, and just returning in that case.
+	 *
+	 * Note that this won't work if this is an Unregistered device.
+	 *
+	 * It is bad practice if the hardware receives the message that it
+	 * transmitted and luckily most CEC adapters behave correctly in this
+	 * respect.
+	 */
+	if (msg_init != CEC_LOG_ADDR_UNREGISTERED &&
+	    cec_has_log_addr(adap, msg_init))
+		return;
+
  	msg->rx_ts = ktime_get_ns();
  	msg->rx_status = CEC_RX_STATUS_OK;
  	msg->sequence = msg->reply = msg->timeout = 0;
-- 
2.10.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-11-21 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-21 15:18 [PATCH] cec: ignore messages that we initiated Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).