Commit 0861ad14 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: cec: add *_ts variants for transmit_done/received_msg

Currently the transmit_(attempt_)done and received_msg functions set
the timestamp themselves. For the upcoming low-level pin API we need
to pass this as an argument instead. So make _ts variants that allow
the caller to specify the timestamp.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: default avatarMaxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent bb789e03
...@@ -471,12 +471,12 @@ int cec_thread_func(void *_adap) ...@@ -471,12 +471,12 @@ int cec_thread_func(void *_adap)
/* /*
* Called by the CEC adapter if a transmit finished. * Called by the CEC adapter if a transmit finished.
*/ */
void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, void cec_transmit_done_ts(struct cec_adapter *adap, u8 status,
u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt) u8 arb_lost_cnt, u8 nack_cnt, u8 low_drive_cnt,
u8 error_cnt, ktime_t ts)
{ {
struct cec_data *data; struct cec_data *data;
struct cec_msg *msg; struct cec_msg *msg;
u64 ts = ktime_get_ns();
dprintk(2, "%s: status %02x\n", __func__, status); dprintk(2, "%s: status %02x\n", __func__, status);
mutex_lock(&adap->lock); mutex_lock(&adap->lock);
...@@ -496,7 +496,7 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, ...@@ -496,7 +496,7 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt,
/* Drivers must fill in the status! */ /* Drivers must fill in the status! */
WARN_ON(status == 0); WARN_ON(status == 0);
msg->tx_ts = ts; msg->tx_ts = ktime_to_ns(ts);
msg->tx_status |= status; msg->tx_status |= status;
msg->tx_arb_lost_cnt += arb_lost_cnt; msg->tx_arb_lost_cnt += arb_lost_cnt;
msg->tx_nack_cnt += nack_cnt; msg->tx_nack_cnt += nack_cnt;
...@@ -559,25 +559,26 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, ...@@ -559,25 +559,26 @@ void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt,
unlock: unlock:
mutex_unlock(&adap->lock); mutex_unlock(&adap->lock);
} }
EXPORT_SYMBOL_GPL(cec_transmit_done); EXPORT_SYMBOL_GPL(cec_transmit_done_ts);
void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status) void cec_transmit_attempt_done_ts(struct cec_adapter *adap,
u8 status, ktime_t ts)
{ {
switch (status) { switch (status) {
case CEC_TX_STATUS_OK: case CEC_TX_STATUS_OK:
cec_transmit_done(adap, status, 0, 0, 0, 0); cec_transmit_done_ts(adap, status, 0, 0, 0, 0, ts);
return; return;
case CEC_TX_STATUS_ARB_LOST: case CEC_TX_STATUS_ARB_LOST:
cec_transmit_done(adap, status, 1, 0, 0, 0); cec_transmit_done_ts(adap, status, 1, 0, 0, 0, ts);
return; return;
case CEC_TX_STATUS_NACK: case CEC_TX_STATUS_NACK:
cec_transmit_done(adap, status, 0, 1, 0, 0); cec_transmit_done_ts(adap, status, 0, 1, 0, 0, ts);
return; return;
case CEC_TX_STATUS_LOW_DRIVE: case CEC_TX_STATUS_LOW_DRIVE:
cec_transmit_done(adap, status, 0, 0, 1, 0); cec_transmit_done_ts(adap, status, 0, 0, 1, 0, ts);
return; return;
case CEC_TX_STATUS_ERROR: case CEC_TX_STATUS_ERROR:
cec_transmit_done(adap, status, 0, 0, 0, 1); cec_transmit_done_ts(adap, status, 0, 0, 0, 1, ts);
return; return;
default: default:
/* Should never happen */ /* Should never happen */
...@@ -585,7 +586,7 @@ void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status) ...@@ -585,7 +586,7 @@ void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status)
return; return;
} }
} }
EXPORT_SYMBOL_GPL(cec_transmit_attempt_done); EXPORT_SYMBOL_GPL(cec_transmit_attempt_done_ts);
/* /*
* Called when waiting for a reply times out. * Called when waiting for a reply times out.
...@@ -721,7 +722,8 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, ...@@ -721,7 +722,8 @@ int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg,
if (msg->timeout) if (msg->timeout)
dprintk(2, "%s: %*ph (wait for 0x%02x%s)\n", dprintk(2, "%s: %*ph (wait for 0x%02x%s)\n",
__func__, msg->len, msg->msg, msg->reply, !block ? ", nb" : ""); __func__, msg->len, msg->msg, msg->reply,
!block ? ", nb" : "");
else else
dprintk(2, "%s: %*ph%s\n", dprintk(2, "%s: %*ph%s\n",
__func__, msg->len, msg->msg, !block ? " (nb)" : ""); __func__, msg->len, msg->msg, !block ? " (nb)" : "");
...@@ -918,7 +920,8 @@ static const u8 cec_msg_size[256] = { ...@@ -918,7 +920,8 @@ static const u8 cec_msg_size[256] = {
}; };
/* Called by the CEC adapter if a message is received */ /* Called by the CEC adapter if a message is received */
void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) void cec_received_msg_ts(struct cec_adapter *adap,
struct cec_msg *msg, ktime_t ts)
{ {
struct cec_data *data; struct cec_data *data;
u8 msg_init = cec_msg_initiator(msg); u8 msg_init = cec_msg_initiator(msg);
...@@ -946,7 +949,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) ...@@ -946,7 +949,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
cec_has_log_addr(adap, msg_init)) cec_has_log_addr(adap, msg_init))
return; return;
msg->rx_ts = ktime_get_ns(); msg->rx_ts = ktime_to_ns(ts);
msg->rx_status = CEC_RX_STATUS_OK; msg->rx_status = CEC_RX_STATUS_OK;
msg->sequence = msg->reply = msg->timeout = 0; msg->sequence = msg->reply = msg->timeout = 0;
msg->tx_status = 0; msg->tx_status = 0;
...@@ -1111,7 +1114,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg) ...@@ -1111,7 +1114,7 @@ void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg)
*/ */
cec_receive_notify(adap, msg, is_reply); cec_receive_notify(adap, msg, is_reply);
} }
EXPORT_SYMBOL_GPL(cec_received_msg); EXPORT_SYMBOL_GPL(cec_received_msg_ts);
/* Logical Address Handling */ /* Logical Address Handling */
......
...@@ -228,15 +228,39 @@ int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, ...@@ -228,15 +228,39 @@ int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg,
bool block); bool block);
/* Called by the adapter */ /* Called by the adapter */
void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, void cec_transmit_done_ts(struct cec_adapter *adap, u8 status,
u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); u8 arb_lost_cnt, u8 nack_cnt, u8 low_drive_cnt,
u8 error_cnt, ktime_t ts);
static inline void cec_transmit_done(struct cec_adapter *adap, u8 status,
u8 arb_lost_cnt, u8 nack_cnt,
u8 low_drive_cnt, u8 error_cnt)
{
cec_transmit_done_ts(adap, status, arb_lost_cnt, nack_cnt,
low_drive_cnt, error_cnt, ktime_get());
}
/* /*
* Simplified version of cec_transmit_done for hardware that doesn't retry * Simplified version of cec_transmit_done for hardware that doesn't retry
* failed transmits. So this is always just one attempt in which case * failed transmits. So this is always just one attempt in which case
* the status is sufficient. * the status is sufficient.
*/ */
void cec_transmit_attempt_done(struct cec_adapter *adap, u8 status); void cec_transmit_attempt_done_ts(struct cec_adapter *adap,
void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); u8 status, ktime_t ts);
static inline void cec_transmit_attempt_done(struct cec_adapter *adap,
u8 status)
{
cec_transmit_attempt_done_ts(adap, status, ktime_get());
}
void cec_received_msg_ts(struct cec_adapter *adap,
struct cec_msg *msg, ktime_t ts);
static inline void cec_received_msg(struct cec_adapter *adap,
struct cec_msg *msg)
{
cec_received_msg_ts(adap, msg, ktime_get());
}
/** /**
* cec_get_edid_phys_addr() - find and return the physical address * cec_get_edid_phys_addr() - find and return the physical address
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment