]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
media: cec: core: add rx-no-low-drive setting
authorHans Verkuil <hverkuil@xs4all.nl>
Mon, 30 Jun 2025 11:08:47 +0000 (13:08 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tue, 8 Jul 2025 06:35:26 +0000 (08:35 +0200)
If rx-no-low-drive is set, then the CEC pin framework will disable
the detection of situations where a Low Drive has to be generated.

So if this is set, then we will never generate Low Drives.

This helps testing whether other CEC devices generate Low Drive
pulses by ensuring it is not us that is generating them.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/cec/core/cec-pin-error-inj.c
drivers/media/cec/core/cec-pin-priv.h
drivers/media/cec/core/cec-pin.c

index 68cbd83dfd6e0a6fa66a45e1e492d7308f90cfcf..d9e613c7ce3fa8e20ba7f4caf2ea820aa6d6f939 100644 (file)
@@ -91,6 +91,7 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)
        if (!strcmp(token, "clear")) {
                memset(pin->error_inj, 0, sizeof(pin->error_inj));
                pin->rx_toggle = pin->tx_toggle = false;
+               pin->rx_no_low_drive = false;
                pin->tx_ignore_nack_until_eom = false;
                pin->tx_custom_pulse = false;
                pin->tx_custom_low_usecs = CEC_TIM_CUSTOM_DEFAULT;
@@ -105,6 +106,7 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)
                for (i = 0; i <= CEC_ERROR_INJ_OP_ANY; i++)
                        pin->error_inj[i] &= ~CEC_ERROR_INJ_RX_MASK;
                pin->rx_toggle = false;
+               pin->rx_no_low_drive = false;
                return true;
        }
        if (!strcmp(token, "tx-clear")) {
@@ -121,6 +123,10 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)
                pin->tx_glitch_rising_edge = false;
                return true;
        }
+       if (!strcmp(token, "rx-no-low-drive")) {
+               pin->rx_no_low_drive = true;
+               return true;
+       }
        if (!strcmp(token, "tx-ignore-nack-until-eom")) {
                pin->tx_ignore_nack_until_eom = true;
                return true;
@@ -305,6 +311,9 @@ int cec_pin_error_inj_show(struct cec_adapter *adap, struct seq_file *sf)
        seq_puts(sf, "#   <op> rx-clear  clear all rx error injections for <op>\n");
        seq_puts(sf, "#   <op> tx-clear  clear all tx error injections for <op>\n");
        seq_puts(sf, "#\n");
+       seq_puts(sf, "# RX error injection settings:\n");
+       seq_puts(sf, "#   rx-no-low-drive                    do not generate low-drive pulses\n");
+       seq_puts(sf, "#\n");
        seq_puts(sf, "# RX error injection:\n");
        seq_puts(sf, "#   <op>[,<mode>] rx-nack              NACK the message instead of sending an ACK\n");
        seq_puts(sf, "#   <op>[,<mode>] rx-low-drive <bit>   force a low-drive condition at this bit position\n");
@@ -368,6 +377,8 @@ int cec_pin_error_inj_show(struct cec_adapter *adap, struct seq_file *sf)
                }
        }
 
+       if (pin->rx_no_low_drive)
+               seq_puts(sf, "rx-no-low-drive\n");
        if (pin->tx_ignore_nack_until_eom)
                seq_puts(sf, "tx-ignore-nack-until-eom\n");
        if (pin->tx_glitch_falling_edge)
index 88eefcb60ab8a502d01d3621e37928d1d452527f..e7801be9adb98eac24da34d69de35825ec9f3dab 100644 (file)
@@ -228,6 +228,7 @@ struct cec_pin {
        u32                             timer_max_overrun;
        u32                             timer_sum_overrun;
 
+       bool                            rx_no_low_drive;
        u32                             tx_custom_low_usecs;
        u32                             tx_custom_high_usecs;
        u32                             tx_glitch_low_usecs;
index f3b0febf0f1c87dd5f0411f44dc2a64ef26dc064..4d7155281daaee38492ca9415a9844d03e035536 100644 (file)
@@ -797,7 +797,7 @@ static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
                 * Go to low drive state when the total bit time is
                 * too short.
                 */
-               if (delta < CEC_TIM_DATA_BIT_TOTAL_MIN) {
+               if (delta < CEC_TIM_DATA_BIT_TOTAL_MIN && !pin->rx_no_low_drive) {
                        if (!pin->rx_data_bit_too_short_cnt++) {
                                pin->rx_data_bit_too_short_ts = ktime_to_ns(pin->ts);
                                pin->rx_data_bit_too_short_delta = delta;