Skip to content

Commit 2511d52

Browse files
warped-rudijnettlet
authored andcommitted
MXC-CEC: Enable transmissions retries in case of errors and NACKs
Re-send an outgoing message when it was NAKed taking in account the required bus arbitration timing. Signed-off-by: Rudi <[email protected]>
1 parent 570d925 commit 2511d52

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

drivers/mxc/hdmi-cec/mxc_hdmi-cec.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
#define CEC_TX_INPROGRESS -1
5959
#define CEC_TX_AVAIL 0
6060

61+
#define CEC_TX_RETRIES 3
62+
63+
6164
/* These flags must not collide with HDMI_IH_CEC_STAT0_xxxx */
6265
#define CEC_STAT0_EX_CONNECTED 0x0100
6366
#define CEC_STAT0_EX_DISCONNECTED 0x0200
@@ -213,6 +216,7 @@ static irqreturn_t mxc_hdmi_cec_isr(int irq, void *data)
213216
static void mxc_hdmi_cec_handle(struct hdmi_cec_priv *priv, u32 cec_stat)
214217
{
215218
int i;
219+
u8 val;
216220
struct hdmi_cec_event *event;
217221

218222
if (!priv->open_count)
@@ -269,19 +273,18 @@ static void mxc_hdmi_cec_handle(struct hdmi_cec_priv *priv, u32 cec_stat)
269273
}
270274

271275
/* An error is detected on cec line (for initiator only). */
272-
if (cec_stat & HDMI_IH_CEC_STAT0_ERROR_INIT) {
273-
priv->tx_answer = cec_stat;
274-
wake_up(&tx_queue);
275-
return;
276-
}
277276
/* A frame is not acknowledged in a directly addressed message.
278277
* Or a frame is negatively acknowledged in
279278
* a broadcast message (for initiator only).
280279
*/
281-
if (cec_stat & HDMI_IH_CEC_STAT0_NACK) {
282-
priv->send_error++;
283-
priv->tx_answer = cec_stat;
284-
wake_up(&tx_queue);
280+
if (cec_stat & (HDMI_IH_CEC_STAT0_ERROR_INIT | HDMI_IH_CEC_STAT0_NACK)) {
281+
if (++priv->send_error < CEC_TX_RETRIES) {
282+
val = hdmi_readb(HDMI_CEC_CTRL) & ~0x07;
283+
hdmi_writeb(val | 0x01, HDMI_CEC_CTRL);
284+
} else {
285+
priv->tx_answer = cec_stat;
286+
wake_up(&tx_queue);
287+
}
285288
}
286289

287290
/* An error is notified by a follower.
@@ -426,10 +429,9 @@ static ssize_t hdmi_cec_write(struct file *file, const char __user *buf,
426429
msg_len = count;
427430
hdmi_writeb(msg_len, HDMI_CEC_TX_CNT);
428431
for (i = 0; i < msg_len; i++)
429-
hdmi_writeb(msg[i], HDMI_CEC_TX_DATA0+i);
430-
val = hdmi_readb(HDMI_CEC_CTRL);
431-
val |= 0x01;
432-
hdmi_writeb(val, HDMI_CEC_CTRL);
432+
hdmi_writeb(msg[i], HDMI_CEC_TX_DATA0 + i);
433+
val = hdmi_readb(HDMI_CEC_CTRL) & ~0x07;
434+
hdmi_writeb(val | 0x03, HDMI_CEC_CTRL);
433435

434436
mutex_unlock(&priv->lock);
435437

0 commit comments

Comments
 (0)