Commit 2b76e539 authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

media: cec-pin: improve status log

Keep track of the number of short or long start bits, the number
of short or long data bits and the number of initiated or detected
low drive conditions.

Show this information in the status debugfs log.

Helpful when debugging, particularly when doing error injection
as well.
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 865463fc
...@@ -181,6 +181,18 @@ struct cec_pin { ...@@ -181,6 +181,18 @@ struct cec_pin {
struct cec_msg rx_msg; struct cec_msg rx_msg;
u32 rx_bit; u32 rx_bit;
bool rx_toggle; bool rx_toggle;
u32 rx_start_bit_low_too_short_cnt;
u64 rx_start_bit_low_too_short_ts;
u32 rx_start_bit_low_too_short_delta;
u32 rx_start_bit_too_short_cnt;
u64 rx_start_bit_too_short_ts;
u32 rx_start_bit_too_short_delta;
u32 rx_start_bit_too_long_cnt;
u32 rx_data_bit_too_short_cnt;
u64 rx_data_bit_too_short_ts;
u32 rx_data_bit_too_short_delta;
u32 rx_data_bit_too_long_cnt;
u32 rx_low_drive_cnt;
struct cec_msg work_rx_msg; struct cec_msg work_rx_msg;
u8 work_tx_status; u8 work_tx_status;
...@@ -205,6 +217,7 @@ struct cec_pin { ...@@ -205,6 +217,7 @@ struct cec_pin {
bool tx_generated_poll; bool tx_generated_poll;
bool tx_post_eom; bool tx_post_eom;
u8 tx_extra_bytes; u8 tx_extra_bytes;
u32 tx_low_drive_cnt;
#ifdef CONFIG_CEC_PIN_ERROR_INJ #ifdef CONFIG_CEC_PIN_ERROR_INJ
u64 error_inj[CEC_ERROR_INJ_OP_ANY + 1]; u64 error_inj[CEC_ERROR_INJ_OP_ANY + 1];
u8 error_inj_args[CEC_ERROR_INJ_OP_ANY + 1][CEC_ERROR_INJ_NUM_ARGS]; u8 error_inj_args[CEC_ERROR_INJ_OP_ANY + 1][CEC_ERROR_INJ_NUM_ARGS];
......
...@@ -432,6 +432,7 @@ static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts) ...@@ -432,6 +432,7 @@ static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts)
pin->state = CEC_ST_TX_WAIT_FOR_HIGH; pin->state = CEC_ST_TX_WAIT_FOR_HIGH;
pin->work_tx_ts = ts; pin->work_tx_ts = ts;
pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE; pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE;
pin->tx_low_drive_cnt++;
wake_up_interruptible(&pin->kthread_waitq); wake_up_interruptible(&pin->kthread_waitq);
break; break;
} }
...@@ -463,6 +464,7 @@ static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts) ...@@ -463,6 +464,7 @@ static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts)
break; break;
pin->work_tx_ts = ts; pin->work_tx_ts = ts;
pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE; pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE;
pin->tx_low_drive_cnt++;
wake_up_interruptible(&pin->kthread_waitq); wake_up_interruptible(&pin->kthread_waitq);
break; break;
} }
...@@ -656,6 +658,10 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -656,6 +658,10 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
delta = ktime_us_delta(ts, pin->ts); delta = ktime_us_delta(ts, pin->ts);
/* Start bit low is too short, go back to idle */ /* Start bit low is too short, go back to idle */
if (delta < CEC_TIM_START_BIT_LOW_MIN - CEC_TIM_IDLE_SAMPLE) { if (delta < CEC_TIM_START_BIT_LOW_MIN - CEC_TIM_IDLE_SAMPLE) {
if (!pin->rx_start_bit_low_too_short_cnt++) {
pin->rx_start_bit_low_too_short_ts = pin->ts;
pin->rx_start_bit_low_too_short_delta = delta;
}
cec_pin_to_idle(pin); cec_pin_to_idle(pin);
break; break;
} }
...@@ -676,6 +682,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -676,6 +682,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
* and go to idle. We just pick TOTAL_LONG. * and go to idle. We just pick TOTAL_LONG.
*/ */
if (v && delta > CEC_TIM_START_BIT_TOTAL_LONG) { if (v && delta > CEC_TIM_START_BIT_TOTAL_LONG) {
pin->rx_start_bit_too_long_cnt++;
cec_pin_to_idle(pin); cec_pin_to_idle(pin);
break; break;
} }
...@@ -683,6 +690,10 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -683,6 +690,10 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
break; break;
/* Start bit is too short, go back to idle */ /* Start bit is too short, go back to idle */
if (delta < CEC_TIM_START_BIT_TOTAL_MIN - CEC_TIM_IDLE_SAMPLE) { if (delta < CEC_TIM_START_BIT_TOTAL_MIN - CEC_TIM_IDLE_SAMPLE) {
if (!pin->rx_start_bit_too_short_cnt++) {
pin->rx_start_bit_too_short_ts = pin->ts;
pin->rx_start_bit_too_short_delta = delta;
}
cec_pin_to_idle(pin); cec_pin_to_idle(pin);
break; break;
} }
...@@ -690,6 +701,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -690,6 +701,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
/* Error injection: go to low drive */ /* Error injection: go to low drive */
cec_pin_low(pin); cec_pin_low(pin);
pin->state = CEC_ST_RX_LOW_DRIVE; pin->state = CEC_ST_RX_LOW_DRIVE;
pin->rx_low_drive_cnt++;
break; break;
} }
pin->state = CEC_ST_RX_DATA_SAMPLE; pin->state = CEC_ST_RX_DATA_SAMPLE;
...@@ -728,6 +740,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -728,6 +740,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
* and go to idle. We just pick TOTAL_LONG. * and go to idle. We just pick TOTAL_LONG.
*/ */
if (v && delta > CEC_TIM_DATA_BIT_TOTAL_LONG) { if (v && delta > CEC_TIM_DATA_BIT_TOTAL_LONG) {
pin->rx_data_bit_too_long_cnt++;
cec_pin_to_idle(pin); cec_pin_to_idle(pin);
break; break;
} }
...@@ -738,6 +751,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -738,6 +751,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
/* Error injection: go to low drive */ /* Error injection: go to low drive */
cec_pin_low(pin); cec_pin_low(pin);
pin->state = CEC_ST_RX_LOW_DRIVE; pin->state = CEC_ST_RX_LOW_DRIVE;
pin->rx_low_drive_cnt++;
break; break;
} }
...@@ -746,8 +760,13 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts) ...@@ -746,8 +760,13 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
* too short. * too short.
*/ */
if (delta < CEC_TIM_DATA_BIT_TOTAL_MIN) { if (delta < CEC_TIM_DATA_BIT_TOTAL_MIN) {
if (!pin->rx_data_bit_too_short_cnt++) {
pin->rx_data_bit_too_short_ts = pin->ts;
pin->rx_data_bit_too_short_delta = delta;
}
cec_pin_low(pin); cec_pin_low(pin);
pin->state = CEC_ST_RX_LOW_DRIVE; pin->state = CEC_ST_RX_LOW_DRIVE;
pin->rx_low_drive_cnt++;
break; break;
} }
pin->ts = ts; pin->ts = ts;
...@@ -1163,11 +1182,44 @@ static void cec_pin_adap_status(struct cec_adapter *adap, ...@@ -1163,11 +1182,44 @@ static void cec_pin_adap_status(struct cec_adapter *adap,
seq_printf(file, "avg timer overrun: %u usecs\n", seq_printf(file, "avg timer overrun: %u usecs\n",
pin->timer_sum_overrun / pin->timer_100ms_overruns); pin->timer_sum_overrun / pin->timer_100ms_overruns);
} }
if (pin->rx_start_bit_low_too_short_cnt)
seq_printf(file,
"rx start bit low too short: %u (delta %u, ts %llu)\n",
pin->rx_start_bit_low_too_short_cnt,
pin->rx_start_bit_low_too_short_delta,
pin->rx_start_bit_low_too_short_ts);
if (pin->rx_start_bit_too_short_cnt)
seq_printf(file,
"rx start bit too short: %u (delta %u, ts %llu)\n",
pin->rx_start_bit_too_short_cnt,
pin->rx_start_bit_too_short_delta,
pin->rx_start_bit_too_short_ts);
if (pin->rx_start_bit_too_long_cnt)
seq_printf(file, "rx start bit too long: %u\n",
pin->rx_start_bit_too_long_cnt);
if (pin->rx_data_bit_too_short_cnt)
seq_printf(file,
"rx data bit too short: %u (delta %u, ts %llu)\n",
pin->rx_data_bit_too_short_cnt,
pin->rx_data_bit_too_short_delta,
pin->rx_data_bit_too_short_ts);
if (pin->rx_data_bit_too_long_cnt)
seq_printf(file, "rx data bit too long: %u\n",
pin->rx_data_bit_too_long_cnt);
seq_printf(file, "rx initiated low drive: %u\n", pin->rx_low_drive_cnt);
seq_printf(file, "tx detected low drive: %u\n", pin->tx_low_drive_cnt);
pin->timer_cnt = 0; pin->timer_cnt = 0;
pin->timer_100ms_overruns = 0; pin->timer_100ms_overruns = 0;
pin->timer_300ms_overruns = 0; pin->timer_300ms_overruns = 0;
pin->timer_max_overrun = 0; pin->timer_max_overrun = 0;
pin->timer_sum_overrun = 0; pin->timer_sum_overrun = 0;
pin->rx_start_bit_low_too_short_cnt = 0;
pin->rx_start_bit_too_short_cnt = 0;
pin->rx_start_bit_too_long_cnt = 0;
pin->rx_data_bit_too_short_cnt = 0;
pin->rx_data_bit_too_long_cnt = 0;
pin->rx_low_drive_cnt = 0;
pin->tx_low_drive_cnt = 0;
if (pin->ops->status) if (pin->ops->status)
pin->ops->status(adap, file); pin->ops->status(adap, file);
} }
......
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