media: s5p-cec: add NACK detection support
The s5p-cec driver returned CEC_TX_STATUS_ERROR for the NACK condition. Some digging into the datasheet uncovered the S5P_CEC_TX_STAT1 register where bit 0 indicates if the transmit was nacked or not. Use this to return the correct CEC_TX_STATUS_NACK status to userspace. This was the only driver that couldn't tell a NACK from another error, and that was very unusual. And a potential problem for applications as well. Tested with my Odroid-U3. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Sylwester Nawrocki <s.nawrocki@samsung.com> Cc: <stable@vger.kernel.org> # for v4.12 and up Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
This commit is contained in:
parent
81b79c71e5
commit
e949f61461
|
@ -172,7 +172,8 @@ u32 s5p_cec_get_status(struct s5p_cec_dev *cec)
|
|||
{
|
||||
u32 status = 0;
|
||||
|
||||
status = readb(cec->reg + S5P_CEC_STATUS_0);
|
||||
status = readb(cec->reg + S5P_CEC_STATUS_0) & 0xf;
|
||||
status |= (readb(cec->reg + S5P_CEC_TX_STAT1) & 0xf) << 4;
|
||||
status |= readb(cec->reg + S5P_CEC_STATUS_1) << 8;
|
||||
status |= readb(cec->reg + S5P_CEC_STATUS_2) << 16;
|
||||
status |= readb(cec->reg + S5P_CEC_STATUS_3) << 24;
|
||||
|
|
|
@ -92,7 +92,10 @@ static irqreturn_t s5p_cec_irq_handler(int irq, void *priv)
|
|||
dev_dbg(cec->dev, "irq received\n");
|
||||
|
||||
if (status & CEC_STATUS_TX_DONE) {
|
||||
if (status & CEC_STATUS_TX_ERROR) {
|
||||
if (status & CEC_STATUS_TX_NACK) {
|
||||
dev_dbg(cec->dev, "CEC_STATUS_TX_NACK set\n");
|
||||
cec->tx = STATE_NACK;
|
||||
} else if (status & CEC_STATUS_TX_ERROR) {
|
||||
dev_dbg(cec->dev, "CEC_STATUS_TX_ERROR set\n");
|
||||
cec->tx = STATE_ERROR;
|
||||
} else {
|
||||
|
@ -135,6 +138,12 @@ static irqreturn_t s5p_cec_irq_handler_thread(int irq, void *priv)
|
|||
cec_transmit_done(cec->adap, CEC_TX_STATUS_OK, 0, 0, 0, 0);
|
||||
cec->tx = STATE_IDLE;
|
||||
break;
|
||||
case STATE_NACK:
|
||||
cec_transmit_done(cec->adap,
|
||||
CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_NACK,
|
||||
0, 1, 0, 0);
|
||||
cec->tx = STATE_IDLE;
|
||||
break;
|
||||
case STATE_ERROR:
|
||||
cec_transmit_done(cec->adap,
|
||||
CEC_TX_STATUS_MAX_RETRIES | CEC_TX_STATUS_ERROR,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#define CEC_STATUS_TX_TRANSFERRING (1 << 1)
|
||||
#define CEC_STATUS_TX_DONE (1 << 2)
|
||||
#define CEC_STATUS_TX_ERROR (1 << 3)
|
||||
#define CEC_STATUS_TX_NACK (1 << 4)
|
||||
#define CEC_STATUS_TX_BYTES (0xFF << 8)
|
||||
#define CEC_STATUS_RX_RUNNING (1 << 16)
|
||||
#define CEC_STATUS_RX_RECEIVING (1 << 17)
|
||||
|
@ -55,6 +56,7 @@ enum cec_state {
|
|||
STATE_IDLE,
|
||||
STATE_BUSY,
|
||||
STATE_DONE,
|
||||
STATE_NACK,
|
||||
STATE_ERROR
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue