Lines Matching refs:pin

10 #include <media/cec-pin.h>
11 #include "cec-pin-priv.h"
111 static void cec_pin_update(struct cec_pin *pin, bool v, bool force)
113 if (!force && v == pin->adap->cec_pin_is_high)
116 pin->adap->cec_pin_is_high = v;
117 if (atomic_read(&pin->work_pin_num_events) < CEC_NUM_PIN_EVENTS) {
120 if (pin->work_pin_events_dropped) {
121 pin->work_pin_events_dropped = false;
124 pin->work_pin_events[pin->work_pin_events_wr] = ev;
125 pin->work_pin_ts[pin->work_pin_events_wr] = ktime_get();
126 pin->work_pin_events_wr =
127 (pin->work_pin_events_wr + 1) % CEC_NUM_PIN_EVENTS;
128 atomic_inc(&pin->work_pin_num_events);
130 pin->work_pin_events_dropped = true;
131 pin->work_pin_events_dropped_cnt++;
133 wake_up_interruptible(&pin->kthread_waitq);
136 static bool cec_pin_read(struct cec_pin *pin)
138 bool v = call_pin_op(pin, read);
140 cec_pin_update(pin, v, false);
144 static void cec_pin_low(struct cec_pin *pin)
146 call_void_pin_op(pin, low);
147 cec_pin_update(pin, false, false);
150 static bool cec_pin_high(struct cec_pin *pin)
152 call_void_pin_op(pin, high);
153 return cec_pin_read(pin);
156 static bool rx_error_inj(struct cec_pin *pin, unsigned int mode_offset,
160 u16 cmd = cec_pin_rx_error_inj(pin);
161 u64 e = pin->error_inj[cmd];
165 u8 pos = pin->error_inj_args[cmd][arg_idx];
169 else if (pos != pin->rx_bit)
175 pin->error_inj[cmd] &=
181 return pin->rx_toggle;
190 static bool rx_nack(struct cec_pin *pin)
192 return rx_error_inj(pin, CEC_ERROR_INJ_RX_NACK_OFFSET, -1, NULL);
195 static bool rx_low_drive(struct cec_pin *pin)
197 return rx_error_inj(pin, CEC_ERROR_INJ_RX_LOW_DRIVE_OFFSET,
201 static bool rx_add_byte(struct cec_pin *pin)
203 return rx_error_inj(pin, CEC_ERROR_INJ_RX_ADD_BYTE_OFFSET, -1, NULL);
206 static bool rx_remove_byte(struct cec_pin *pin)
208 return rx_error_inj(pin, CEC_ERROR_INJ_RX_REMOVE_BYTE_OFFSET, -1, NULL);
211 static bool rx_arb_lost(struct cec_pin *pin, u8 *poll)
213 return pin->tx_msg.len == 0 &&
214 rx_error_inj(pin, CEC_ERROR_INJ_RX_ARB_LOST_OFFSET,
218 static bool tx_error_inj(struct cec_pin *pin, unsigned int mode_offset,
222 u16 cmd = cec_pin_tx_error_inj(pin);
223 u64 e = pin->error_inj[cmd];
227 u8 pos = pin->error_inj_args[cmd][arg_idx];
231 else if (pos != pin->tx_bit)
237 pin->error_inj[cmd] &=
243 return pin->tx_toggle;
252 static bool tx_no_eom(struct cec_pin *pin)
254 return tx_error_inj(pin, CEC_ERROR_INJ_TX_NO_EOM_OFFSET, -1, NULL);
257 static bool tx_early_eom(struct cec_pin *pin)
259 return tx_error_inj(pin, CEC_ERROR_INJ_TX_EARLY_EOM_OFFSET, -1, NULL);
262 static bool tx_short_bit(struct cec_pin *pin)
264 return tx_error_inj(pin, CEC_ERROR_INJ_TX_SHORT_BIT_OFFSET,
268 static bool tx_long_bit(struct cec_pin *pin)
270 return tx_error_inj(pin, CEC_ERROR_INJ_TX_LONG_BIT_OFFSET,
274 static bool tx_custom_bit(struct cec_pin *pin)
276 return tx_error_inj(pin, CEC_ERROR_INJ_TX_CUSTOM_BIT_OFFSET,
280 static bool tx_short_start(struct cec_pin *pin)
282 return tx_error_inj(pin, CEC_ERROR_INJ_TX_SHORT_START_OFFSET, -1, NULL);
285 static bool tx_long_start(struct cec_pin *pin)
287 return tx_error_inj(pin, CEC_ERROR_INJ_TX_LONG_START_OFFSET, -1, NULL);
290 static bool tx_custom_start(struct cec_pin *pin)
292 return tx_error_inj(pin, CEC_ERROR_INJ_TX_CUSTOM_START_OFFSET,
296 static bool tx_last_bit(struct cec_pin *pin)
298 return tx_error_inj(pin, CEC_ERROR_INJ_TX_LAST_BIT_OFFSET,
302 static u8 tx_add_bytes(struct cec_pin *pin)
306 if (tx_error_inj(pin, CEC_ERROR_INJ_TX_ADD_BYTES_OFFSET,
312 static bool tx_remove_byte(struct cec_pin *pin)
314 return tx_error_inj(pin, CEC_ERROR_INJ_TX_REMOVE_BYTE_OFFSET, -1, NULL);
317 static bool tx_low_drive(struct cec_pin *pin)
319 return tx_error_inj(pin, CEC_ERROR_INJ_TX_LOW_DRIVE_OFFSET,
323 static void cec_pin_to_idle(struct cec_pin *pin)
329 pin->rx_bit = pin->tx_bit = 0;
330 pin->rx_msg.len = 0;
331 memset(pin->rx_msg.msg, 0, sizeof(pin->rx_msg.msg));
332 pin->ts = ns_to_ktime(0);
333 pin->tx_generated_poll = false;
334 pin->tx_post_eom = false;
335 if (pin->state >= CEC_ST_TX_WAIT &&
336 pin->state <= CEC_ST_TX_LOW_DRIVE)
337 pin->tx_toggle ^= 1;
338 if (pin->state >= CEC_ST_RX_START_BIT_LOW &&
339 pin->state <= CEC_ST_RX_LOW_DRIVE)
340 pin->rx_toggle ^= 1;
341 pin->state = CEC_ST_IDLE;
370 static void cec_pin_tx_states(struct cec_pin *pin, ktime_t ts)
375 switch (pin->state) {
377 if (cec_pin_read(pin))
378 cec_pin_to_idle(pin);
382 if (tx_short_start(pin)) {
387 pin->state = CEC_ST_TX_START_BIT_HIGH_SHORT;
388 } else if (tx_long_start(pin)) {
393 pin->state = CEC_ST_TX_START_BIT_HIGH_LONG;
395 pin->state = CEC_ST_TX_START_BIT_HIGH;
398 cec_pin_high(pin);
402 pin->state = CEC_ST_TX_START_BIT_HIGH_CUSTOM;
404 cec_pin_high(pin);
410 if (pin->tx_nacked) {
411 cec_pin_to_idle(pin);
412 pin->tx_msg.len = 0;
413 if (pin->tx_generated_poll)
415 pin->work_tx_ts = ts;
416 pin->work_tx_status = CEC_TX_STATUS_NACK;
417 wake_up_interruptible(&pin->kthread_waitq);
433 * the pin can actually be low in that case.
435 if (!cec_pin_read(pin) && !pin->tx_generated_poll) {
440 pin->tx_msg.len = 0;
441 pin->state = CEC_ST_TX_WAIT_FOR_HIGH;
442 pin->work_tx_ts = ts;
443 pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE;
444 pin->tx_low_drive_cnt++;
445 wake_up_interruptible(&pin->kthread_waitq);
450 if (tx_last_bit(pin)) {
452 cec_pin_to_idle(pin);
453 pin->tx_msg.len = 0;
454 if (pin->tx_generated_poll)
456 pin->work_tx_ts = ts;
457 pin->work_tx_status = CEC_TX_STATUS_OK;
458 wake_up_interruptible(&pin->kthread_waitq);
461 pin->tx_bit++;
467 if (tx_low_drive(pin)) {
469 cec_pin_low(pin);
470 pin->state = CEC_ST_TX_LOW_DRIVE;
471 pin->tx_msg.len = 0;
472 if (pin->tx_generated_poll)
474 pin->work_tx_ts = ts;
475 pin->work_tx_status = CEC_TX_STATUS_LOW_DRIVE;
476 pin->tx_low_drive_cnt++;
477 wake_up_interruptible(&pin->kthread_waitq);
480 if (pin->tx_bit / 10 >= pin->tx_msg.len + pin->tx_extra_bytes) {
481 cec_pin_to_idle(pin);
482 pin->tx_msg.len = 0;
483 if (pin->tx_generated_poll)
485 pin->work_tx_ts = ts;
486 pin->work_tx_status = CEC_TX_STATUS_OK;
487 wake_up_interruptible(&pin->kthread_waitq);
491 switch (pin->tx_bit % 10) {
495 * extra bytes, so pin->tx_bit / 10 can become >= 16.
499 unsigned int idx = (pin->tx_bit / 10);
502 if (idx < pin->tx_msg.len)
503 val = pin->tx_msg.msg[idx];
504 v = val & (1 << (7 - (pin->tx_bit % 10)));
506 pin->state = v ? CEC_ST_TX_DATA_BIT_1_LOW :
511 unsigned int tot_len = pin->tx_msg.len +
512 pin->tx_extra_bytes;
513 unsigned int tx_byte_idx = pin->tx_bit / 10;
515 v = !pin->tx_post_eom && tx_byte_idx == tot_len - 1;
517 tx_early_eom(pin)) {
520 pin->tx_post_eom = true;
521 } else if (v && tx_no_eom(pin)) {
525 pin->state = v ? CEC_ST_TX_DATA_BIT_1_LOW :
530 pin->state = CEC_ST_TX_DATA_BIT_1_LOW;
533 if (tx_custom_bit(pin))
534 pin->state = CEC_ST_TX_DATA_BIT_LOW_CUSTOM;
535 cec_pin_low(pin);
540 v = pin->state == CEC_ST_TX_DATA_BIT_1_LOW;
541 is_ack_bit = pin->tx_bit % 10 == ACK_BIT;
542 if (v && (pin->tx_bit < 4 || is_ack_bit)) {
543 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_PRE_SAMPLE;
544 } else if (!is_ack_bit && tx_short_bit(pin)) {
546 pin->state = v ? CEC_ST_TX_DATA_BIT_1_HIGH_SHORT :
548 } else if (!is_ack_bit && tx_long_bit(pin)) {
550 pin->state = v ? CEC_ST_TX_DATA_BIT_1_HIGH_LONG :
553 pin->state = v ? CEC_ST_TX_DATA_BIT_1_HIGH :
556 cec_pin_high(pin);
560 pin->state = CEC_ST_TX_DATA_BIT_HIGH_CUSTOM;
561 cec_pin_high(pin);
566 v = cec_pin_read(pin);
567 is_ack_bit = pin->tx_bit % 10 == ACK_BIT;
576 if (!v && !is_ack_bit && !pin->tx_generated_poll) {
577 pin->tx_msg.len = 0;
578 pin->work_tx_ts = ts;
579 pin->work_tx_status = CEC_TX_STATUS_ARB_LOST;
580 wake_up_interruptible(&pin->kthread_waitq);
581 pin->rx_bit = pin->tx_bit;
582 pin->tx_bit = 0;
583 memset(pin->rx_msg.msg, 0, sizeof(pin->rx_msg.msg));
584 pin->rx_msg.msg[0] = pin->tx_msg.msg[0];
585 pin->rx_msg.msg[0] &= (0xff << (8 - pin->rx_bit));
586 pin->rx_msg.len = 0;
587 pin->ts = ktime_sub_us(ts, CEC_TIM_DATA_BIT_SAMPLE);
588 pin->state = CEC_ST_RX_DATA_POST_SAMPLE;
589 pin->rx_bit++;
592 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE;
593 if (!is_ack_bit && tx_short_bit(pin)) {
595 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE_SHORT;
596 } else if (!is_ack_bit && tx_long_bit(pin)) {
598 pin->state = CEC_ST_TX_DATA_BIT_1_HIGH_POST_SAMPLE_LONG;
603 ack = cec_msg_is_broadcast(&pin->tx_msg) ? v : !v;
604 if (!ack && (!pin->tx_ignore_nack_until_eom ||
605 pin->tx_bit / 10 == pin->tx_msg.len - 1) &&
606 !pin->tx_post_eom) {
619 pin->tx_nacked = true;
624 cec_pin_high(pin);
625 pin->state = CEC_ST_TX_PULSE_HIGH_CUSTOM;
629 cec_pin_to_idle(pin);
652 static void cec_pin_rx_states(struct cec_pin *pin, ktime_t ts)
661 switch (pin->state) {
664 v = cec_pin_read(pin);
667 pin->state = CEC_ST_RX_START_BIT_HIGH;
668 delta = ktime_us_delta(ts, pin->ts);
671 if (!pin->rx_start_bit_low_too_short_cnt++) {
672 pin->rx_start_bit_low_too_short_ts = ktime_to_ns(pin->ts);
673 pin->rx_start_bit_low_too_short_delta = delta;
675 cec_pin_to_idle(pin);
678 if (rx_arb_lost(pin, &poll)) {
679 cec_msg_init(&pin->tx_msg, poll >> 4, poll & 0xf);
680 pin->tx_generated_poll = true;
681 pin->tx_extra_bytes = 0;
682 pin->state = CEC_ST_TX_START_BIT_HIGH;
683 pin->ts = ts;
688 v = cec_pin_read(pin);
689 delta = ktime_us_delta(ts, pin->ts);
695 pin->rx_start_bit_too_long_cnt++;
696 cec_pin_to_idle(pin);
703 if (!pin->rx_start_bit_too_short_cnt++) {
704 pin->rx_start_bit_too_short_ts = ktime_to_ns(pin->ts);
705 pin->rx_start_bit_too_short_delta = delta;
707 cec_pin_to_idle(pin);
710 if (rx_low_drive(pin)) {
712 cec_pin_low(pin);
713 pin->state = CEC_ST_RX_LOW_DRIVE;
714 pin->rx_low_drive_cnt++;
717 pin->state = CEC_ST_RX_DATA_SAMPLE;
718 pin->ts = ts;
719 pin->rx_eom = false;
723 v = cec_pin_read(pin);
724 pin->state = CEC_ST_RX_DATA_POST_SAMPLE;
725 switch (pin->rx_bit % 10) {
727 if (pin->rx_bit / 10 < CEC_MAX_MSG_SIZE)
728 pin->rx_msg.msg[pin->rx_bit / 10] |=
729 v << (7 - (pin->rx_bit % 10));
732 pin->rx_eom = v;
733 pin->rx_msg.len = pin->rx_bit / 10 + 1;
738 pin->rx_bit++;
742 pin->state = CEC_ST_RX_DATA_WAIT_FOR_LOW;
746 v = cec_pin_read(pin);
747 delta = ktime_us_delta(ts, pin->ts);
753 pin->rx_data_bit_too_long_cnt++;
754 cec_pin_to_idle(pin);
760 if (rx_low_drive(pin)) {
762 cec_pin_low(pin);
763 pin->state = CEC_ST_RX_LOW_DRIVE;
764 pin->rx_low_drive_cnt++;
773 if (!pin->rx_data_bit_too_short_cnt++) {
774 pin->rx_data_bit_too_short_ts = ktime_to_ns(pin->ts);
775 pin->rx_data_bit_too_short_delta = delta;
777 cec_pin_low(pin);
778 pin->state = CEC_ST_RX_LOW_DRIVE;
779 pin->rx_low_drive_cnt++;
782 pin->ts = ts;
783 if (pin->rx_bit % 10 != 9) {
784 pin->state = CEC_ST_RX_DATA_SAMPLE;
788 dest = cec_msg_destination(&pin->rx_msg);
791 for_us = bcast || (pin->la_mask & (1 << dest));
795 if (for_us && rx_nack(pin)) {
802 pin->state = CEC_ST_RX_ACK_HIGH_POST;
805 cec_pin_low(pin);
806 pin->state = CEC_ST_RX_ACK_LOW;
810 cec_pin_high(pin);
811 pin->state = CEC_ST_RX_ACK_LOW_POST;
816 v = cec_pin_read(pin);
817 if (v && pin->rx_eom) {
818 pin->work_rx_msg = pin->rx_msg;
819 pin->work_rx_msg.rx_ts = ktime_to_ns(ts);
820 wake_up_interruptible(&pin->kthread_waitq);
821 pin->ts = ts;
822 pin->state = CEC_ST_RX_ACK_FINISH;
825 pin->rx_bit++;
826 pin->state = CEC_ST_RX_DATA_WAIT_FOR_LOW;
830 cec_pin_to_idle(pin);
844 struct cec_pin *pin = container_of(timer, struct cec_pin, timer);
845 struct cec_adapter *adap = pin->adap;
851 if (ktime_to_ns(pin->timer_ts)) {
852 delta = ktime_us_delta(ts, pin->timer_ts);
853 pin->timer_cnt++;
854 if (delta > 100 && pin->state != CEC_ST_IDLE) {
856 pin->timer_sum_overrun += delta;
857 pin->timer_100us_overruns++;
859 pin->timer_300us_overruns++;
860 if (delta > pin->timer_max_overrun)
861 pin->timer_max_overrun = delta;
865 cec_pin_read(pin);
867 if (pin->wait_usecs) {
869 * If we are monitoring the pin, then we have to
872 if (pin->wait_usecs > 150) {
873 pin->wait_usecs -= 100;
874 pin->timer_ts = ktime_add_us(ts, 100);
878 if (pin->wait_usecs > 100) {
879 pin->wait_usecs /= 2;
880 pin->timer_ts = ktime_add_us(ts, pin->wait_usecs);
882 ns_to_ktime(pin->wait_usecs * 1000));
885 pin->timer_ts = ktime_add_us(ts, pin->wait_usecs);
887 ns_to_ktime(pin->wait_usecs * 1000));
888 pin->wait_usecs = 0;
892 switch (pin->state) {
917 cec_pin_tx_states(pin, ts);
930 cec_pin_rx_states(pin, ts);
935 if (!cec_pin_high(pin)) {
937 pin->ts = ts;
938 pin->state = CEC_ST_RX_START_BIT_LOW;
946 if (pin->tx_msg.len && pin->tx_signal_free_time >
948 pin->tx_signal_free_time =
952 if (ktime_to_ns(pin->ts) == 0)
953 pin->ts = ts;
954 if (pin->tx_msg.len) {
959 delta = ktime_us_delta(ts, pin->ts);
961 pin->tx_signal_free_time) {
962 pin->tx_nacked = false;
963 if (tx_custom_start(pin))
964 pin->state = CEC_ST_TX_START_BIT_LOW_CUSTOM;
966 pin->state = CEC_ST_TX_START_BIT_LOW;
968 cec_pin_low(pin);
972 pin->tx_signal_free_time - 1)
973 pin->state = CEC_ST_TX_WAIT;
976 if (pin->tx_custom_pulse && pin->state == CEC_ST_IDLE) {
977 pin->tx_custom_pulse = false;
979 cec_pin_low(pin);
980 pin->state = CEC_ST_TX_PULSE_LOW_CUSTOM;
983 if (pin->state != CEC_ST_IDLE || pin->ops->enable_irq == NULL ||
984 pin->enable_irq_failed || adap->is_configuring ||
988 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_ENABLE);
989 pin->state = CEC_ST_RX_IRQ;
990 wake_up_interruptible(&pin->kthread_waitq);
995 cec_pin_high(pin);
996 cec_pin_to_idle(pin);
1003 switch (pin->state) {
1007 usecs = pin->tx_custom_low_usecs;
1012 usecs = pin->tx_custom_high_usecs;
1015 usecs = states[pin->state].usecs;
1020 pin->wait_usecs = 0;
1021 pin->timer_ts = ktime_add_us(ts, usecs);
1026 pin->wait_usecs = usecs - 100;
1027 pin->timer_ts = ktime_add_us(ts, 100);
1035 struct cec_pin *pin = adap->pin;
1037 pin->enabled_irq = false;
1038 pin->enable_irq_failed = false;
1040 wait_event_interruptible(pin->kthread_waitq,
1042 pin->work_rx_msg.len ||
1043 pin->work_tx_status ||
1044 atomic_read(&pin->work_irq_change) ||
1045 atomic_read(&pin->work_pin_num_events));
1050 if (pin->work_rx_msg.len) {
1051 struct cec_msg *msg = &pin->work_rx_msg;
1054 rx_add_byte(pin)) {
1058 if (msg->len > 2 && rx_remove_byte(pin)) {
1065 ns_to_ktime(pin->work_rx_msg.rx_ts));
1069 if (pin->work_tx_status) {
1070 unsigned int tx_status = pin->work_tx_status;
1072 pin->work_tx_status = 0;
1074 pin->work_tx_ts);
1077 while (atomic_read(&pin->work_pin_num_events)) {
1078 unsigned int idx = pin->work_pin_events_rd;
1079 u8 v = pin->work_pin_events[idx];
1084 pin->work_pin_ts[idx]);
1085 pin->work_pin_events_rd = (idx + 1) % CEC_NUM_PIN_EVENTS;
1086 atomic_dec(&pin->work_pin_num_events);
1089 switch (atomic_xchg(&pin->work_irq_change,
1092 if (pin->enabled_irq) {
1093 pin->ops->disable_irq(adap);
1094 pin->enabled_irq = false;
1095 pin->enable_irq_failed = false;
1097 cec_pin_high(pin);
1098 if (pin->state == CEC_ST_OFF)
1100 cec_pin_to_idle(pin);
1101 hrtimer_start(&pin->timer, ns_to_ktime(0),
1105 if (pin->enabled_irq || !pin->ops->enable_irq ||
1106 pin->adap->devnode.unregistered)
1108 pin->enable_irq_failed = !pin->ops->enable_irq(adap);
1109 if (pin->enable_irq_failed) {
1110 cec_pin_to_idle(pin);
1111 hrtimer_start(&pin->timer, ns_to_ktime(0),
1114 pin->enabled_irq = true;
1122 if (pin->enabled_irq) {
1123 pin->ops->disable_irq(pin->adap);
1124 pin->enabled_irq = false;
1125 pin->enable_irq_failed = false;
1126 cec_pin_high(pin);
1133 struct cec_pin *pin = adap->pin;
1136 cec_pin_read(pin);
1137 cec_pin_to_idle(pin);
1138 pin->tx_msg.len = 0;
1139 pin->timer_ts = ns_to_ktime(0);
1140 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_UNCHANGED);
1141 if (!pin->kthread) {
1142 pin->kthread = kthread_run(cec_pin_thread_func, adap,
1143 "cec-pin");
1144 if (IS_ERR(pin->kthread)) {
1145 int err = PTR_ERR(pin->kthread);
1147 pr_err("cec-pin: kernel_thread() failed\n");
1148 pin->kthread = NULL;
1152 hrtimer_start(&pin->timer, ns_to_ktime(0),
1154 } else if (pin->kthread) {
1155 hrtimer_cancel(&pin->timer);
1156 cec_pin_high(pin);
1157 cec_pin_to_idle(pin);
1158 pin->state = CEC_ST_OFF;
1159 pin->work_tx_status = 0;
1160 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_DISABLE);
1161 wake_up_interruptible(&pin->kthread_waitq);
1168 struct cec_pin *pin = adap->pin;
1171 pin->la_mask = 0;
1173 pin->la_mask |= (1 << log_addr);
1177 void cec_pin_start_timer(struct cec_pin *pin)
1179 if (pin->state != CEC_ST_RX_IRQ)
1182 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_DISABLE);
1183 wake_up_interruptible(&pin->kthread_waitq);
1189 struct cec_pin *pin = adap->pin;
1196 if (pin->state != CEC_ST_IDLE &&
1200 pin->tx_signal_free_time = signal_free_time;
1201 pin->tx_extra_bytes = 0;
1202 pin->tx_msg = *msg;
1205 pin->tx_extra_bytes = tx_add_bytes(pin);
1207 if (msg->len > 2 && tx_remove_byte(pin)) {
1209 pin->tx_msg.len--;
1211 pin->work_tx_status = 0;
1212 pin->tx_bit = 0;
1213 cec_pin_start_timer(pin);
1220 struct cec_pin *pin = adap->pin;
1222 seq_printf(file, "state: %s\n", states[pin->state].name);
1223 seq_printf(file, "tx_bit: %d\n", pin->tx_bit);
1224 seq_printf(file, "rx_bit: %d\n", pin->rx_bit);
1225 seq_printf(file, "cec pin: %d\n", call_pin_op(pin, read));
1226 seq_printf(file, "cec pin events dropped: %u\n",
1227 pin->work_pin_events_dropped_cnt);
1228 if (pin->ops->enable_irq)
1229 seq_printf(file, "irq %s\n", pin->enabled_irq ? "enabled" :
1230 (pin->enable_irq_failed ? "failed" : "disabled"));
1231 if (pin->timer_100us_overruns) {
1233 pin->timer_100us_overruns, pin->timer_cnt);
1235 pin->timer_300us_overruns, pin->timer_cnt);
1237 pin->timer_max_overrun);
1239 pin->timer_sum_overrun / pin->timer_100us_overruns);
1241 if (pin->rx_start_bit_low_too_short_cnt)
1244 pin->rx_start_bit_low_too_short_cnt,
1245 pin->rx_start_bit_low_too_short_delta,
1246 pin->rx_start_bit_low_too_short_ts);
1247 if (pin->rx_start_bit_too_short_cnt)
1250 pin->rx_start_bit_too_short_cnt,
1251 pin->rx_start_bit_too_short_delta,
1252 pin->rx_start_bit_too_short_ts);
1253 if (pin->rx_start_bit_too_long_cnt)
1255 pin->rx_start_bit_too_long_cnt);
1256 if (pin->rx_data_bit_too_short_cnt)
1259 pin->rx_data_bit_too_short_cnt,
1260 pin->rx_data_bit_too_short_delta,
1261 pin->rx_data_bit_too_short_ts);
1262 if (pin->rx_data_bit_too_long_cnt)
1264 pin->rx_data_bit_too_long_cnt);
1265 seq_printf(file, "rx initiated low drive: %u\n", pin->rx_low_drive_cnt);
1266 seq_printf(file, "tx detected low drive: %u\n", pin->tx_low_drive_cnt);
1267 pin->work_pin_events_dropped_cnt = 0;
1268 pin->timer_cnt = 0;
1269 pin->timer_100us_overruns = 0;
1270 pin->timer_300us_overruns = 0;
1271 pin->timer_max_overrun = 0;
1272 pin->timer_sum_overrun = 0;
1273 pin->rx_start_bit_low_too_short_cnt = 0;
1274 pin->rx_start_bit_too_short_cnt = 0;
1275 pin->rx_start_bit_too_long_cnt = 0;
1276 pin->rx_data_bit_too_short_cnt = 0;
1277 pin->rx_data_bit_too_long_cnt = 0;
1278 pin->rx_low_drive_cnt = 0;
1279 pin->tx_low_drive_cnt = 0;
1280 call_void_pin_op(pin, status, file);
1286 struct cec_pin *pin = adap->pin;
1288 pin->monitor_all = enable;
1294 struct cec_pin *pin = adap->pin;
1296 if (pin->kthread)
1297 kthread_stop(pin->kthread);
1298 pin->kthread = NULL;
1299 if (pin->ops->free)
1300 pin->ops->free(adap);
1301 adap->pin = NULL;
1302 kfree(pin);
1307 struct cec_pin *pin = adap->pin;
1309 if (pin->ops->received && !adap->devnode.unregistered)
1310 return pin->ops->received(adap, msg);
1316 struct cec_pin *pin = adap->pin;
1318 cec_pin_update(pin, value, false);
1321 atomic_set(&pin->work_irq_change, CEC_PIN_IRQ_DISABLE);
1343 struct cec_pin *pin = kzalloc(sizeof(*pin), GFP_KERNEL);
1345 if (pin == NULL)
1347 pin->ops = pin_ops;
1348 hrtimer_init(&pin->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
1349 atomic_set(&pin->work_pin_num_events, 0);
1350 pin->timer.function = cec_pin_timer;
1351 init_waitqueue_head(&pin->kthread_waitq);
1352 pin->tx_custom_low_usecs = CEC_TIM_CUSTOM_DEFAULT;
1353 pin->tx_custom_high_usecs = CEC_TIM_CUSTOM_DEFAULT;
1360 kfree(pin);
1364 adap->pin = pin;
1365 pin->adap = adap;
1366 cec_pin_update(pin, cec_pin_high(pin), true);