media: cec: improve err inj and cec-gpio
Subsystems (3)
cover media: cec: improve err inj and cec-gpio
This patch series adds support for injecting 'glitches' in the CEC pulses. Proper CEC hardware will have 'deglitch' support to ignore short spikes, but if this is not done well it can actually reply with a 'Low Drive' condition, effectively making CEC impossible to use.
It is hard to reproduce this in real life, so being able to create this situation helps debugging bad CEC hardware.
The last two patches relax the requirements for the HPD and 5V
interrupts: reading the HPD/5V value is allowed to sleep. These signals are not time-sensitive, so that's fine.
Regards,
Hans
Hans Verkuil (5):
media: cec: core: add glitch error injection
media: cec: core: add rx-no-low-drive setting
Documentation: media: cec: update error inj doc
media: cec: cec-gpio: rename functions
media: cec: cec-gpio: reading hpd/5v is allowed to sleep
.../media/cec/cec-pin-error-inj.rst | 42 ++++++++++++ drivers/media/cec/core/cec-pin-error-inj.c | 59 +++++++++++++++- drivers/media/cec/core/cec-pin-priv.h | 8 +++ drivers/media/cec/core/cec-pin.c | 31 ++++++++- .../media/cec/platform/cec-gpio/cec-gpio.c | 68 ++++++++++--------- 5 files changed, 173 insertions(+), 35 deletions(-)
Signature · 1 line
2.47.2
PATCH 1/5 media: cec: core: add glitch error injection
This adds support for inserting 'glitches' after a falling and/or rising edge. This tests what happens when there are little voltage spikes after falling or rising edges, which can be caused due to noise or reflections on the CEC line.
A proper CEC implementation will deglitch this, but a poor implementation can create a Low Drive pulse in response, effectively making CEC unusable.
--- drivers/media/cec/core/cec-pin-error-inj.c | 48 +++++++++++++++++++++- drivers/media/cec/core/cec-pin-priv.h | 7 ++++ drivers/media/cec/core/cec-pin.c | 29 +++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-)
drivers/media/cec/core/cec-pin-error-inj.c +47 -1
@@ -95,6 +95,10 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line) pin->tx_custom_pulse = false; pin->tx_custom_low_usecs =CEC_TIM_CUSTOM_DEFAULT ; pin->tx_custom_high_usecs =CEC_TIM_CUSTOM_DEFAULT ; + pin->tx_glitch_low_usecs =CEC_TIM_GLITCH_DEFAULT ; + pin->tx_glitch_high_usecs =CEC_TIM_GLITCH_DEFAULT ; + pin->tx_glitch_falling_edge = false; + pin->tx_glitch_rising_edge = false;return true; }if (!strcmp (token,"rx-clear" )) {
@@ -111,6 +115,10 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line) pin->tx_custom_pulse = false; pin->tx_custom_low_usecs =CEC_TIM_CUSTOM_DEFAULT ; pin->tx_custom_high_usecs =CEC_TIM_CUSTOM_DEFAULT ; + pin->tx_glitch_low_usecs =CEC_TIM_GLITCH_DEFAULT ; + pin->tx_glitch_high_usecs =CEC_TIM_GLITCH_DEFAULT ; + pin->tx_glitch_falling_edge = false; + pin->tx_glitch_rising_edge = false;return true; }if (!strcmp (token,"tx-ignore-nack-until-eom" )) {
@@ -122,6 +130,14 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)cec_pin_start_timer (pin);return true; } +if (!strcmp (token,"tx-glitch-falling-edge" )) { + pin->tx_glitch_falling_edge = true; +return true; + } +if (!strcmp (token,"tx-glitch-rising-edge" )) { + pin->tx_glitch_rising_edge = true; +return true; + }if (!p)return false;
@@ -139,7 +155,23 @@ bool cec_pin_error_inj_parse_line(struct cec_adapter *adap, char *line)if (kstrtou32 (p,0 , &usecs) || usecs >10000000 )return false; - pin->tx_custom_high_usecs = usecs; + pin->tx_glitch_high_usecs = usecs; +return true; + } +if (!strcmp (token,"tx-glitch-low-usecs" )) { +u32 usecs; + +if (kstrtou32 (p,0 , &usecs) || usecs >100 ) +return false; + pin->tx_glitch_low_usecs = usecs; +return true; + } +if (!strcmp (token,"tx-glitch-high-usecs" )) { +u32 usecs; + +if (kstrtou32 (p,0 , &usecs) || usecs >100 ) +return false; + pin->tx_glitch_high_usecs = usecs;return true; }
@@ -285,6 +317,10 @@ int cec_pin_error_inj_show(struct cec_adapter *adap, struct seq_file *sf)seq_puts (sf,"# tx-custom-low-usecs <usecs> define the 'low' time for the custom pulse\n" );seq_puts (sf,"# tx-custom-high-usecs <usecs> define the 'high' time for the custom pulse\n" );seq_puts (sf,"# tx-custom-pulse transmit the custom pulse once the bus is idle\n" ); +seq_puts (sf,"# tx-glitch-low-usecs <usecs> define the 'low' time for the glitch pulse\n" ); +seq_puts (sf,"# tx-glitch-high-usecs <usecs> define the 'high' time for the glitch pulse\n" ); +seq_puts (sf,"# tx-glitch-falling-edge send the glitch pulse after every falling edge\n" ); +seq_puts (sf,"# tx-glitch-rising-edge send the glitch pulse after every rising edge\n" );seq_puts (sf,"#\n" );seq_puts (sf,"# TX error injection:\n" );seq_puts (sf,"# <op>[,<mode>] tx-no-eom don't set the EOM bit\n" );
@@ -334,6 +370,10 @@ int cec_pin_error_inj_show(struct cec_adapter *adap, struct seq_file *sf)if (pin->tx_ignore_nack_until_eom)seq_puts (sf,"tx-ignore-nack-until-eom\n" ); +if (pin->tx_glitch_falling_edge) +seq_puts (sf,"tx-glitch-falling-edge\n" ); +if (pin->tx_glitch_rising_edge) +seq_puts (sf,"tx-glitch-rising-edge\n" );if (pin->tx_custom_pulse)seq_puts (sf,"tx-custom-pulse\n" );if (pin->tx_custom_low_usecs !=CEC_TIM_CUSTOM_DEFAULT )
@@ -342,5 +382,11 @@ int cec_pin_error_inj_show(struct cec_adapter *adap, struct seq_file *sf)if (pin->tx_custom_high_usecs !=CEC_TIM_CUSTOM_DEFAULT )seq_printf (sf,"tx-custom-high-usecs %u\n" , pin->tx_custom_high_usecs); +if (pin->tx_glitch_low_usecs !=CEC_TIM_GLITCH_DEFAULT ) +seq_printf (sf,"tx-glitch-low-usecs %u\n" , + pin->tx_glitch_low_usecs); +if (pin->tx_glitch_high_usecs !=CEC_TIM_GLITCH_DEFAULT ) +seq_printf (sf,"tx-glitch-high-usecs %u\n" , + pin->tx_glitch_high_usecs);return 0 ; }
drivers/media/cec/core/cec-pin-priv.h +7 -0
@@ -164,6 +164,9 @@ enum cec_pin_state {/* The default for the low/high time of the custom pulse */ #define CEC_TIM_CUSTOM_DEFAULT 1000 +/* The default for the low/high time of the glitch pulse */ +#define CEC_TIM_GLITCH_DEFAULT 1 +#define CEC_NUM_PIN_EVENTS 128#define CEC_PIN_EVENT_FL_IS_HIGH (1 << 0)#define CEC_PIN_EVENT_FL_DROPPED (1 << 1)
@@ -227,10 +230,14 @@ struct cec_pin {u32 tx_custom_low_usecs;u32 tx_custom_high_usecs; +u32 tx_glitch_low_usecs; +u32 tx_glitch_high_usecs;bool tx_ignore_nack_until_eom;bool tx_custom_pulse;bool tx_generated_poll;bool tx_post_eom; +bool tx_glitch_falling_edge; +bool tx_glitch_rising_edge;u8 tx_extra_bytes;u32 tx_low_drive_cnt;#ifdef CONFIG_CEC_PIN_ERROR_INJ
drivers/media/cec/core/cec-pin.c +29 -0
@@ -142,15 +142,42 @@ static bool cec_pin_read(struct cec_pin *pin)return v; } +static void cec_pin_insert_glitch (struct cec_pin *pin,bool rising_edge) +{ +/* +* Insert a short glitch after the falling or rising edge to +* simulate reflections on the CEC line. This can be used to +* test deglitch filters, which should be present in CEC devices +* to deal with noise on the line. +*/ +if (!pin->tx_glitch_high_usecs || !pin->tx_glitch_low_usecs) +return ; +if (rising_edge) { +udelay (pin->tx_glitch_high_usecs); +call_void_pin_op (pin, low); +udelay (pin->tx_glitch_low_usecs); +call_void_pin_op (pin, high); + }else { +udelay (pin->tx_glitch_low_usecs); +call_void_pin_op (pin, high); +udelay (pin->tx_glitch_high_usecs); +call_void_pin_op (pin, low); + } +} +static void cec_pin_low (struct cec_pin *pin) {call_void_pin_op (pin, low); +if (pin->tx_glitch_falling_edge && pin->adap->cec_pin_is_high) +cec_pin_insert_glitch (pin, false);cec_pin_update (pin, false, false); }static bool cec_pin_high (struct cec_pin *pin) {call_void_pin_op (pin, high); +if (pin->tx_glitch_rising_edge && !pin->adap->cec_pin_is_high) +cec_pin_insert_glitch (pin, true);return cec_pin_read (pin); }
@@ -1350,6 +1377,8 @@ struct cec_adapter *cec_pin_allocate_adapter(const struct cec_pin_ops *pin_ops,init_waitqueue_head (&pin->kthread_waitq); pin->tx_custom_low_usecs =CEC_TIM_CUSTOM_DEFAULT ; pin->tx_custom_high_usecs =CEC_TIM_CUSTOM_DEFAULT ; + pin->tx_glitch_low_usecs =CEC_TIM_GLITCH_DEFAULT ; + pin->tx_glitch_high_usecs =CEC_TIM_GLITCH_DEFAULT ; adap = cec_allocate_adapter(&cec_pin_adap_ops, priv, name, caps | CEC_CAP_MONITOR_ALL | CEC_CAP_MONITOR_PIN,
Signature · 1 line
2.47.2
PATCH 2/5 media: cec: core: add rx-no-low-drive setting
In reply to Hans VerkuilIf 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.
--- drivers/media/cec/core/cec-pin-error-inj.c | 11 +++++++++++ drivers/media/cec/core/cec-pin-priv.h | 1 + drivers/media/cec/core/cec-pin.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-)
drivers/media/cec/core/cec-pin-error-inj.c +11 -0
@@ -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)
drivers/media/cec/core/cec-pin-priv.h +1 -0
@@ -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;
drivers/media/cec/core/cec-pin.c +1 -1
@@ -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;
Signature · 1 line
2.47.2
PATCH 3/5 Documentation: media: cec: update error inj doc
In reply to Hans VerkuilDocument rx-no-low-drive and the new support to inject glitches.
--- .../media/cec/cec-pin-error-inj.rst | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+)
Documentation/userspace-api/media/cec/cec-pin-error-inj.rst +42 -0
@@ -41,6 +41,9 @@ error injection status:: # <op> rx-clear clear all rx error injections for <op> # <op> tx-clear clear all tx error injections for <op> # + # RX error injection settings: + # rx-no-low-drive do not generate low-drive pulses + # # RX error injection: # <op>[,<mode>] rx-nack NACK the message instead of sending an ACK # <op>[,<mode>] rx-low-drive <bit> force a low-drive condition at this bit position
@@ -53,6 +56,10 @@ error injection status:: # tx-custom-low-usecs <usecs> define the 'low' time for the custom pulse # tx-custom-high-usecs <usecs> define the 'high' time for the custom pulse # tx-custom-pulse transmit the custom pulse once the bus is idle + # tx-glitch-low-usecs <usecs> define the 'low' time for the glitch pulse + # tx-glitch-high-usecs <usecs> define the 'high' time for the glitch pulse + # tx-glitch-falling-edge send the glitch pulse after every falling edge + # tx-glitch-rising-edge send the glitch pulse after every rising edge # # TX error injection: # <op>[,<mode>] tx-no-eom don't set the EOM bit
@@ -193,6 +200,14 @@ Receive Messages This does not work if the remote CEC transmitter has logical address 0 ('TV') since that will always win. +``rx-no-low-drive`` + The receiver will ignore situations that would normally generate a + Low Drive pulse (3.6 ms). This is typically done if a spurious pulse is + detected when receiving a message, and it indicates to the transmitter that + the message has to be retransmitted since the receiver got confused. + Disabling this is useful to test how other CEC devices handle glitches + by ensuring we will not be the one that generates a Low Drive. + Transmit Messages -----------------
@@ -327,3 +342,30 @@ Custom Pulses ``tx-custom-pulse`` Transmit a single custom pulse as soon as the CEC bus is idle. + +Glitch Pulses +------------- + +This emulates what happens if the signal on the CEC line is seeing spurious +pulses. Typically this happens after the falling or rising edge where there +is a short voltage fluctuation that, if the CEC hardware doesn't do +deglitching, can be seen as a spurious pulse and can cause a Low Drive +condition or corrupt data. + +``tx-glitch-low-usecs <usecs>`` + This defines the duration in microseconds that the glitch pulse pulls + the CEC line low. The default is 1 microsecond. The range is 0-100 + microseconds. If 0, then no glitch pulse will be generated. + +``tx-glitch-high-usecs <usecs>`` + This defines the duration in microseconds that the glitch pulse keeps the + CEC line high (unless another CEC adapter pulls it low in that time). + The default is 1 microseconds. The range is 0-100 microseconds. If 0, then + no glitch pulse will be generated.The total period of the glitch pulse is + ``tx-custom-low-usecs + tx-custom-high-usecs``. + +``tx-glitch-falling-edge`` + Send the glitch pulse right after the falling edge. + +``tx-glitch-rising-edge`` + Send the glitch pulse right after the rising edge.
Signature · 1 line
2.47.2
PATCH 4/5 media: cec: cec-gpio: rename functions
In reply to Hans VerkuilEnsure that the interrupt function names clearly state for which gpio they are (cec/hpd/5v). No functional changes.
--- .../media/cec/platform/cec-gpio/cec-gpio.c | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/media/cec/platform/cec-gpio/cec-gpio.c +16 -16
@@ -61,15 +61,15 @@ static void cec_gpio_low(struct cec_adapter *adap)gpiod_set_value (cec->cec_gpio,0 ); } -static irqreturn_t cec_hpd_gpio_irq_handler_thread (int irq,void *priv) +static irqreturn_t cec_gpio_5v_irq_handler_thread (int irq,void *priv) {struct cec_gpio *cec = priv; -cec_queue_pin_hpd_event (cec->adap, cec->hpd_is_high, cec->hpd_ts); +cec_queue_pin_5v_event (cec->adap, cec->v5_is_high, cec->v5_ts);return IRQ_HANDLED ; } -static irqreturn_t cec_5v_gpio_irq_handler (int irq,void *priv) +static irqreturn_t cec_gpio_5v_irq_handler (int irq,void *priv) {struct cec_gpio *cec = priv;int val =gpiod_get_value (cec->v5_gpio);
@@ -82,15 +82,15 @@ static irqreturn_t cec_5v_gpio_irq_handler(int irq, void *priv)return IRQ_WAKE_THREAD ; } -static irqreturn_t cec_5v_gpio_irq_handler_thread (int irq,void *priv) +static irqreturn_t cec_gpio_hpd_irq_handler_thread (int irq,void *priv) {struct cec_gpio *cec = priv; -cec_queue_pin_5v_event (cec->adap, cec->v5_is_high, cec->v5_ts); +cec_queue_pin_hpd_event (cec->adap, cec->hpd_is_high, cec->hpd_ts);return IRQ_HANDLED ; } -static irqreturn_t cec_hpd_gpio_irq_handler (int irq,void *priv) +static irqreturn_t cec_gpio_hpd_irq_handler (int irq,void *priv) {struct cec_gpio *cec = priv;int val =gpiod_get_value (cec->hpd_gpio);
@@ -103,7 +103,7 @@ static irqreturn_t cec_hpd_gpio_irq_handler(int irq, void *priv)return IRQ_WAKE_THREAD ; } -static irqreturn_t cec_gpio_irq_handler (int irq,void *priv) +static irqreturn_t cec_gpio_cec_irq_handler (int irq,void *priv) {struct cec_gpio *cec = priv;int val =gpiod_get_value (cec->cec_gpio);
@@ -113,7 +113,7 @@ static irqreturn_t cec_gpio_irq_handler(int irq, void *priv)return IRQ_HANDLED ; } -static bool cec_gpio_enable_irq (struct cec_adapter *adap) +static bool cec_gpio_cec_enable_irq (struct cec_adapter *adap) {struct cec_gpio *cec =cec_get_drvdata (adap);
@@ -121,7 +121,7 @@ static bool cec_gpio_enable_irq(struct cec_adapter *adap)return true; } -static void cec_gpio_disable_irq (struct cec_adapter *adap) +static void cec_gpio_cec_disable_irq (struct cec_adapter *adap) {struct cec_gpio *cec =cec_get_drvdata (adap);
@@ -164,8 +164,8 @@ static const struct cec_pin_ops cec_gpio_pin_ops = { .read = cec_gpio_read, .low = cec_gpio_low, .high = cec_gpio_high, - .enable_irq = cec_gpio_enable_irq, - .disable_irq = cec_gpio_disable_irq, + .enable_irq = cec_gpio_cec_enable_irq, + .disable_irq = cec_gpio_cec_disable_irq, .status = cec_gpio_status, .read_hpd = cec_gpio_read_hpd, .read_5v = cec_gpio_read_5v,
@@ -209,7 +209,7 @@ static int cec_gpio_probe(struct platform_device *pdev)if (IS_ERR (cec->adap))return PTR_ERR (cec->adap); - ret =devm_request_irq (dev, cec->cec_irq, cec_gpio_irq_handler, + ret =devm_request_irq (dev, cec->cec_irq, cec_gpio_cec_irq_handler,IRQF_TRIGGER_RISING |IRQF_TRIGGER_FALLING |IRQF_NO_AUTOEN , cec->adap->name, cec);if (ret)
@@ -218,8 +218,8 @@ static int cec_gpio_probe(struct platform_device *pdev)if (cec->hpd_gpio) { cec->hpd_irq =gpiod_to_irq (cec->hpd_gpio); ret =devm_request_threaded_irq (dev, cec->hpd_irq, - cec_hpd_gpio_irq_handler, - cec_hpd_gpio_irq_handler_thread, + cec_gpio_hpd_irq_handler, + cec_gpio_hpd_irq_handler_thread,IRQF_ONESHOT |IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ,"hpd-gpio" , cec);
@@ -230,8 +230,8 @@ static int cec_gpio_probe(struct platform_device *pdev)if (cec->v5_gpio) { cec->v5_irq =gpiod_to_irq (cec->v5_gpio); ret =devm_request_threaded_irq (dev, cec->v5_irq, - cec_5v_gpio_irq_handler, - cec_5v_gpio_irq_handler_thread, + cec_gpio_5v_irq_handler, + cec_gpio_5v_irq_handler_thread,IRQF_ONESHOT |IRQF_TRIGGER_FALLING |IRQF_TRIGGER_RISING ,"v5-gpio" , cec);
Signature · 1 line
2.47.2
PATCH 5/5 media: cec: cec-gpio: reading hpd/5v is allowed to sleep
In reply to Hans VerkuilReading the hpd or 5v gpios is something that can sleep, so rework the code to allow this.
--- .../media/cec/platform/cec-gpio/cec-gpio.c | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/media/cec/platform/cec-gpio/cec-gpio.c +14 -12
@@ -64,7 +64,13 @@ static void cec_gpio_low(struct cec_adapter *adap)static irqreturn_t cec_gpio_5v_irq_handler_thread (int irq,void *priv) {struct cec_gpio *cec = priv; +int val =gpiod_get_value_cansleep (cec->v5_gpio); +bool is_high = val >0 ; +if (val <0 || is_high == cec->v5_is_high) +return IRQ_HANDLED ; + + cec->v5_is_high = is_high;cec_queue_pin_5v_event (cec->adap, cec->v5_is_high, cec->v5_ts);return IRQ_HANDLED ; }
@@ -72,20 +78,21 @@ static irqreturn_t cec_gpio_5v_irq_handler_thread(int irq, void *priv)static irqreturn_t cec_gpio_5v_irq_handler (int irq,void *priv) {struct cec_gpio *cec = priv; -int val =gpiod_get_value (cec->v5_gpio); -bool is_high = val >0 ; -if (val <0 || is_high == cec->v5_is_high) -return IRQ_HANDLED ; cec->v5_ts =ktime_get (); - cec->v5_is_high = is_high;return IRQ_WAKE_THREAD ; }static irqreturn_t cec_gpio_hpd_irq_handler_thread (int irq,void *priv) {struct cec_gpio *cec = priv; +int val =gpiod_get_value_cansleep (cec->hpd_gpio); +bool is_high = val >0 ; +if (val <0 || is_high == cec->hpd_is_high) +return IRQ_HANDLED ; + + cec->hpd_is_high = is_high;cec_queue_pin_hpd_event (cec->adap, cec->hpd_is_high, cec->hpd_ts);return IRQ_HANDLED ; }
@@ -93,13 +100,8 @@ static irqreturn_t cec_gpio_hpd_irq_handler_thread(int irq, void *priv)static irqreturn_t cec_gpio_hpd_irq_handler (int irq,void *priv) {struct cec_gpio *cec = priv; -int val =gpiod_get_value (cec->hpd_gpio); -bool is_high = val >0 ; -if (val <0 || is_high == cec->hpd_is_high) -return IRQ_HANDLED ; cec->hpd_ts =ktime_get (); - cec->hpd_is_high = is_high;return IRQ_WAKE_THREAD ; }
@@ -148,7 +150,7 @@ static int cec_gpio_read_hpd(struct cec_adapter *adap)if (!cec->hpd_gpio)return -ENOTTY ; -return gpiod_get_value (cec->hpd_gpio); +return gpiod_get_value_cansleep (cec->hpd_gpio); }static int cec_gpio_read_5v (struct cec_adapter *adap)
@@ -157,7 +159,7 @@ static int cec_gpio_read_5v(struct cec_adapter *adap)if (!cec->v5_gpio)return -ENOTTY ; -return gpiod_get_value (cec->v5_gpio); +return gpiod_get_value_cansleep (cec->v5_gpio); }static const struct cec_pin_ops cec_gpio_pin_ops = {
Signature · 1 line
2.47.2