Lines Matching refs:adap

26 static void cec_fill_msg_report_features(struct cec_adapter *adap,
30 static int cec_log_addr2idx(const struct cec_adapter *adap, u8 log_addr) in cec_log_addr2idx() argument
34 for (i = 0; i < adap->log_addrs.num_log_addrs; i++) in cec_log_addr2idx()
35 if (adap->log_addrs.log_addr[i] == log_addr) in cec_log_addr2idx()
40 static unsigned int cec_log_addr2dev(const struct cec_adapter *adap, u8 log_addr) in cec_log_addr2dev() argument
42 int i = cec_log_addr2idx(adap, log_addr); in cec_log_addr2dev()
44 return adap->log_addrs.primary_device_type[i < 0 ? 0 : i]; in cec_log_addr2dev()
137 static void cec_queue_event(struct cec_adapter *adap, in cec_queue_event() argument
143 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_event()
144 list_for_each_entry(fh, &adap->devnode.fhs, list) in cec_queue_event()
146 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_event()
150 void cec_queue_pin_cec_event(struct cec_adapter *adap, bool is_high, in cec_queue_pin_cec_event() argument
160 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_pin_cec_event()
161 list_for_each_entry(fh, &adap->devnode.fhs, list) { in cec_queue_pin_cec_event()
165 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_pin_cec_event()
170 void cec_queue_pin_hpd_event(struct cec_adapter *adap, bool is_high, ktime_t ts) in cec_queue_pin_hpd_event() argument
178 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_pin_hpd_event()
179 list_for_each_entry(fh, &adap->devnode.fhs, list) in cec_queue_pin_hpd_event()
181 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_pin_hpd_event()
186 void cec_queue_pin_5v_event(struct cec_adapter *adap, bool is_high, ktime_t ts) in cec_queue_pin_5v_event() argument
194 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_pin_5v_event()
195 list_for_each_entry(fh, &adap->devnode.fhs, list) in cec_queue_pin_5v_event()
197 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_pin_5v_event()
261 static void cec_queue_msg_monitor(struct cec_adapter *adap, in cec_queue_msg_monitor() argument
269 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_msg_monitor()
270 list_for_each_entry(fh, &adap->devnode.fhs, list) { in cec_queue_msg_monitor()
274 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_msg_monitor()
280 static void cec_queue_msg_followers(struct cec_adapter *adap, in cec_queue_msg_followers() argument
285 mutex_lock(&adap->devnode.lock_fhs); in cec_queue_msg_followers()
286 list_for_each_entry(fh, &adap->devnode.fhs, list) { in cec_queue_msg_followers()
290 mutex_unlock(&adap->devnode.lock_fhs); in cec_queue_msg_followers()
294 static void cec_post_state_event(struct cec_adapter *adap) in cec_post_state_event() argument
300 ev.state_change.phys_addr = adap->phys_addr; in cec_post_state_event()
301 ev.state_change.log_addr_mask = adap->log_addrs.log_addr_mask; in cec_post_state_event()
303 adap->conn_info.type != CEC_CONNECTOR_TYPE_NO_CONNECTOR; in cec_post_state_event()
304 cec_queue_event(adap, &ev); in cec_post_state_event()
354 struct cec_adapter *adap = data->adap; in cec_data_cancel() local
360 if (adap->transmitting == data) { in cec_data_cancel()
361 adap->transmitting = NULL; in cec_data_cancel()
365 if (!WARN_ON(!adap->transmit_queue_sz)) in cec_data_cancel()
366 adap->transmit_queue_sz--; in cec_data_cancel()
385 cec_queue_msg_monitor(adap, &data->msg, 1); in cec_data_cancel()
389 call_op(adap, received, &data->msg); in cec_data_cancel()
399 static void cec_flush(struct cec_adapter *adap) in cec_flush() argument
407 while (!list_empty(&adap->transmit_queue)) { in cec_flush()
408 data = list_first_entry(&adap->transmit_queue, in cec_flush()
412 if (adap->transmitting) in cec_flush()
413 adap->transmit_in_progress_aborted = true; in cec_flush()
416 list_for_each_entry_safe(data, n, &adap->wait_queue, list) { in cec_flush()
432 if (WARN_ON(adap->transmit_queue_sz)) in cec_flush()
433 adap->transmit_queue_sz = 0; in cec_flush()
450 struct cec_adapter *adap = _adap; in cec_thread_func() local
458 if (adap->transmit_in_progress) { in cec_thread_func()
468 err = wait_event_interruptible_timeout(adap->kthread_waitq, in cec_thread_func()
469 (adap->needs_hpd && in cec_thread_func()
470 (!adap->is_configured && !adap->is_configuring)) || in cec_thread_func()
472 (!adap->transmit_in_progress && in cec_thread_func()
473 !list_empty(&adap->transmit_queue)), in cec_thread_func()
474 msecs_to_jiffies(adap->xfer_timeout_ms)); in cec_thread_func()
478 wait_event_interruptible(adap->kthread_waitq, in cec_thread_func()
480 (!adap->transmit_in_progress && in cec_thread_func()
481 !list_empty(&adap->transmit_queue))); in cec_thread_func()
484 mutex_lock(&adap->lock); in cec_thread_func()
486 if ((adap->needs_hpd && in cec_thread_func()
487 (!adap->is_configured && !adap->is_configuring)) || in cec_thread_func()
489 cec_flush(adap); in cec_thread_func()
493 if (adap->transmit_in_progress && timeout) { in cec_thread_func()
503 if (adap->transmitting) { in cec_thread_func()
504 pr_warn("cec-%s: message %*ph timed out\n", adap->name, in cec_thread_func()
505 adap->transmitting->msg.len, in cec_thread_func()
506 adap->transmitting->msg.msg); in cec_thread_func()
508 cec_data_cancel(adap->transmitting, in cec_thread_func()
511 pr_warn("cec-%s: transmit timed out\n", adap->name); in cec_thread_func()
513 adap->transmit_in_progress = false; in cec_thread_func()
514 adap->tx_timeouts++; in cec_thread_func()
522 if (adap->transmit_in_progress || list_empty(&adap->transmit_queue)) in cec_thread_func()
526 data = list_first_entry(&adap->transmit_queue, in cec_thread_func()
529 if (!WARN_ON(!data->adap->transmit_queue_sz)) in cec_thread_func()
530 adap->transmit_queue_sz--; in cec_thread_func()
533 adap->transmitting = data; in cec_thread_func()
541 if (data->msg.len == 1 && adap->is_configured) in cec_thread_func()
550 } else if (adap->last_initiator != in cec_thread_func()
554 adap->last_initiator = cec_msg_initiator(&data->msg); in cec_thread_func()
565 adap->transmit_in_progress_aborted = false; in cec_thread_func()
567 if (call_op(adap, adap_transmit, data->attempts, in cec_thread_func()
571 adap->transmit_in_progress = true; in cec_thread_func()
574 mutex_unlock(&adap->lock); in cec_thread_func()
585 void cec_transmit_done_ts(struct cec_adapter *adap, u8 status, in cec_transmit_done_ts() argument
594 bool aborted = adap->transmit_in_progress_aborted; in cec_transmit_done_ts()
600 mutex_lock(&adap->lock); in cec_transmit_done_ts()
601 data = adap->transmitting; in cec_transmit_done_ts()
608 if (!adap->transmit_in_progress) in cec_transmit_done_ts()
611 adap->transmit_in_progress = false; in cec_transmit_done_ts()
614 adap->transmit_in_progress = false; in cec_transmit_done_ts()
615 adap->transmit_in_progress_aborted = false; in cec_transmit_done_ts()
629 adap->transmitting = NULL; in cec_transmit_done_ts()
646 list_add(&data->list, &adap->transmit_queue); in cec_transmit_done_ts()
647 adap->transmit_queue_sz++; in cec_transmit_done_ts()
660 cec_queue_msg_monitor(adap, msg, 1); in cec_transmit_done_ts()
662 if ((status & CEC_TX_STATUS_OK) && adap->is_configured && in cec_transmit_done_ts()
668 list_add_tail(&data->list, &adap->wait_queue); in cec_transmit_done_ts()
681 wake_up_interruptible(&adap->kthread_waitq); in cec_transmit_done_ts()
682 mutex_unlock(&adap->lock); in cec_transmit_done_ts()
686 void cec_transmit_attempt_done_ts(struct cec_adapter *adap, in cec_transmit_attempt_done_ts() argument
691 cec_transmit_done_ts(adap, status, 0, 0, 0, 0, ts); in cec_transmit_attempt_done_ts()
694 cec_transmit_done_ts(adap, status, 1, 0, 0, 0, ts); in cec_transmit_attempt_done_ts()
697 cec_transmit_done_ts(adap, status, 0, 1, 0, 0, ts); in cec_transmit_attempt_done_ts()
700 cec_transmit_done_ts(adap, status, 0, 0, 1, 0, ts); in cec_transmit_attempt_done_ts()
703 cec_transmit_done_ts(adap, status, 0, 0, 0, 1, ts); in cec_transmit_attempt_done_ts()
707 WARN(1, "cec-%s: invalid status 0x%02x\n", adap->name, status); in cec_transmit_attempt_done_ts()
719 struct cec_adapter *adap = data->adap; in cec_wait_timeout() local
721 mutex_lock(&adap->lock); in cec_wait_timeout()
733 mutex_unlock(&adap->lock); in cec_wait_timeout()
742 int cec_transmit_msg_fh(struct cec_adapter *adap, struct cec_msg *msg, in cec_transmit_msg_fh() argument
748 if (adap->devnode.unregistered) in cec_transmit_msg_fh()
796 if ((adap->log_addrs.flags & CEC_LOG_ADDRS_FL_CDC_ONLY) && in cec_transmit_msg_fh()
803 msg->msg[2] = adap->phys_addr >> 8; in cec_transmit_msg_fh()
804 msg->msg[3] = adap->phys_addr & 0xff; in cec_transmit_msg_fh()
813 if (cec_has_log_addr(adap, cec_msg_destination(msg))) { in cec_transmit_msg_fh()
826 msg->sequence = ++adap->sequence; in cec_transmit_msg_fh()
828 msg->sequence = ++adap->sequence; in cec_transmit_msg_fh()
833 cec_has_log_addr(adap, cec_msg_destination(msg))) { in cec_transmit_msg_fh()
838 if (msg->len > 1 && adap->is_configured && in cec_transmit_msg_fh()
839 !cec_has_log_addr(adap, cec_msg_initiator(msg))) { in cec_transmit_msg_fh()
850 if (!adap->is_configured && !adap->is_configuring && in cec_transmit_msg_fh()
860 if (!adap->is_configured && !adap->is_configuring) { in cec_transmit_msg_fh()
861 if (adap->needs_hpd) { in cec_transmit_msg_fh()
872 if (adap->transmit_queue_sz >= CEC_MAX_MSG_TX_QUEUE_SZ) { in cec_transmit_msg_fh()
881 msg->sequence = ++adap->sequence; in cec_transmit_msg_fh()
883 msg->sequence = ++adap->sequence; in cec_transmit_msg_fh()
887 data->adap = adap; in cec_transmit_msg_fh()
898 list_add_tail(&data->list, &adap->transmit_queue); in cec_transmit_msg_fh()
899 adap->transmit_queue_sz++; in cec_transmit_msg_fh()
900 if (!adap->transmitting) in cec_transmit_msg_fh()
901 wake_up_interruptible(&adap->kthread_waitq); in cec_transmit_msg_fh()
910 mutex_unlock(&adap->lock); in cec_transmit_msg_fh()
914 mutex_lock(&adap->lock); in cec_transmit_msg_fh()
935 int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, in cec_transmit_msg() argument
940 mutex_lock(&adap->lock); in cec_transmit_msg()
941 ret = cec_transmit_msg_fh(adap, msg, NULL, block); in cec_transmit_msg()
942 mutex_unlock(&adap->lock); in cec_transmit_msg()
952 static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
1046 void cec_received_msg_ts(struct cec_adapter *adap, in cec_received_msg_ts() argument
1060 if (adap->devnode.unregistered) in cec_received_msg_ts()
1075 cec_has_log_addr(adap, msg_init)) in cec_received_msg_ts()
1090 mutex_lock(&adap->lock); in cec_received_msg_ts()
1093 adap->last_initiator = 0xff; in cec_received_msg_ts()
1097 valid_la = cec_has_log_addr(adap, msg_dest); in cec_received_msg_ts()
1116 adap->log_addrs.cec_version < CEC_OP_CEC_VERSION_2_0 && in cec_received_msg_ts()
1174 list_for_each_entry(data, &adap->wait_queue, list) { in cec_received_msg_ts()
1213 mutex_unlock(&adap->lock); in cec_received_msg_ts()
1215 mutex_lock(&adap->lock); in cec_received_msg_ts()
1227 mutex_unlock(&adap->lock); in cec_received_msg_ts()
1230 cec_queue_msg_monitor(adap, msg, valid_la); in cec_received_msg_ts()
1236 if (adap->log_addrs.log_addr_mask == 0) in cec_received_msg_ts()
1244 cec_receive_notify(adap, msg, is_reply); in cec_received_msg_ts()
1255 static int cec_config_log_addr(struct cec_adapter *adap, in cec_config_log_addr() argument
1259 struct cec_log_addrs *las = &adap->log_addrs; in cec_config_log_addr()
1265 if (cec_has_log_addr(adap, log_addr)) in cec_config_log_addr()
1273 err = cec_transmit_msg_fh(adap, &msg, NULL, true); in cec_config_log_addr()
1279 if (adap->phys_addr == CEC_PHYS_ADDR_INVALID) in cec_config_log_addr()
1283 if (adap->must_reconfigure) in cec_config_log_addr()
1323 err = call_op(adap, adap_log_addr, log_addr); in cec_config_log_addr()
1338 static void cec_adap_unconfigure(struct cec_adapter *adap) in cec_adap_unconfigure() argument
1340 if (!adap->needs_hpd || adap->phys_addr != CEC_PHYS_ADDR_INVALID) in cec_adap_unconfigure()
1341 WARN_ON(call_op(adap, adap_log_addr, CEC_LOG_ADDR_INVALID)); in cec_adap_unconfigure()
1342 adap->log_addrs.log_addr_mask = 0; in cec_adap_unconfigure()
1343 adap->is_configured = false; in cec_adap_unconfigure()
1344 cec_flush(adap); in cec_adap_unconfigure()
1345 wake_up_interruptible(&adap->kthread_waitq); in cec_adap_unconfigure()
1346 cec_post_state_event(adap); in cec_adap_unconfigure()
1347 call_void_op(adap, adap_configured, false); in cec_adap_unconfigure()
1403 struct cec_adapter *adap = arg; in cec_config_thread_func() local
1404 struct cec_log_addrs *las = &adap->log_addrs; in cec_config_thread_func()
1408 mutex_lock(&adap->lock); in cec_config_thread_func()
1410 cec_phys_addr_exp(adap->phys_addr), las->num_log_addrs); in cec_config_thread_func()
1427 if (adap->phys_addr && type == CEC_LOG_ADDR_TYPE_TV) in cec_config_thread_func()
1438 err = cec_config_log_addr(adap, i, last_la); in cec_config_thread_func()
1440 if (adap->must_reconfigure) { in cec_config_thread_func()
1441 adap->must_reconfigure = false; in cec_config_thread_func()
1462 err = cec_config_log_addr(adap, i, la_list[j]); in cec_config_thread_func()
1475 if (adap->log_addrs.log_addr_mask == 0 && in cec_config_thread_func()
1480 if (adap->log_addrs.log_addr_mask == 0) { in cec_config_thread_func()
1489 adap->is_configured = true; in cec_config_thread_func()
1490 adap->is_configuring = false; in cec_config_thread_func()
1491 adap->must_reconfigure = false; in cec_config_thread_func()
1492 cec_post_state_event(adap); in cec_config_thread_func()
1515 adap->log_addrs.cec_version >= CEC_OP_CEC_VERSION_2_0) { in cec_config_thread_func()
1516 cec_fill_msg_report_features(adap, &msg, i); in cec_config_thread_func()
1517 cec_transmit_msg_fh(adap, &msg, NULL, false); in cec_config_thread_func()
1521 cec_msg_report_physical_addr(&msg, adap->phys_addr, in cec_config_thread_func()
1525 cec_phys_addr_exp(adap->phys_addr)); in cec_config_thread_func()
1526 cec_transmit_msg_fh(adap, &msg, NULL, false); in cec_config_thread_func()
1529 if (adap->log_addrs.vendor_id != CEC_VENDOR_ID_NONE) { in cec_config_thread_func()
1531 adap->log_addrs.vendor_id); in cec_config_thread_func()
1532 cec_transmit_msg_fh(adap, &msg, NULL, false); in cec_config_thread_func()
1535 adap->kthread_config = NULL; in cec_config_thread_func()
1536 complete(&adap->config_completion); in cec_config_thread_func()
1537 mutex_unlock(&adap->lock); in cec_config_thread_func()
1538 call_void_op(adap, adap_configured, true); in cec_config_thread_func()
1544 cec_adap_unconfigure(adap); in cec_config_thread_func()
1545 adap->is_configuring = false; in cec_config_thread_func()
1546 adap->must_reconfigure = false; in cec_config_thread_func()
1547 adap->kthread_config = NULL; in cec_config_thread_func()
1548 complete(&adap->config_completion); in cec_config_thread_func()
1549 mutex_unlock(&adap->lock); in cec_config_thread_func()
1559 static void cec_claim_log_addrs(struct cec_adapter *adap, bool block) in cec_claim_log_addrs() argument
1561 if (WARN_ON(adap->is_configuring || adap->is_configured)) in cec_claim_log_addrs()
1564 init_completion(&adap->config_completion); in cec_claim_log_addrs()
1567 adap->is_configuring = true; in cec_claim_log_addrs()
1568 adap->kthread_config = kthread_run(cec_config_thread_func, adap, in cec_claim_log_addrs()
1569 "ceccfg-%s", adap->name); in cec_claim_log_addrs()
1570 if (IS_ERR(adap->kthread_config)) { in cec_claim_log_addrs()
1571 adap->kthread_config = NULL; in cec_claim_log_addrs()
1572 adap->is_configuring = false; in cec_claim_log_addrs()
1574 mutex_unlock(&adap->lock); in cec_claim_log_addrs()
1575 wait_for_completion(&adap->config_completion); in cec_claim_log_addrs()
1576 mutex_lock(&adap->lock); in cec_claim_log_addrs()
1585 static int cec_adap_enable(struct cec_adapter *adap) in cec_adap_enable() argument
1590 enable = adap->monitor_all_cnt || adap->monitor_pin_cnt || in cec_adap_enable()
1591 adap->log_addrs.num_log_addrs; in cec_adap_enable()
1592 if (adap->needs_hpd) in cec_adap_enable()
1593 enable = enable && adap->phys_addr != CEC_PHYS_ADDR_INVALID; in cec_adap_enable()
1595 if (enable == adap->is_enabled) in cec_adap_enable()
1599 mutex_lock(&adap->devnode.lock); in cec_adap_enable()
1601 adap->last_initiator = 0xff; in cec_adap_enable()
1602 adap->transmit_in_progress = false; in cec_adap_enable()
1603 ret = adap->ops->adap_enable(adap, true); in cec_adap_enable()
1609 if (adap->monitor_all_cnt) in cec_adap_enable()
1610 WARN_ON(call_op(adap, adap_monitor_all_enable, true)); in cec_adap_enable()
1611 if (adap->monitor_pin_cnt) in cec_adap_enable()
1612 WARN_ON(call_op(adap, adap_monitor_pin_enable, true)); in cec_adap_enable()
1616 if (adap->monitor_all_cnt) in cec_adap_enable()
1617 WARN_ON(call_op(adap, adap_monitor_all_enable, false)); in cec_adap_enable()
1618 if (adap->monitor_pin_cnt) in cec_adap_enable()
1619 WARN_ON(call_op(adap, adap_monitor_pin_enable, false)); in cec_adap_enable()
1620 WARN_ON(adap->ops->adap_enable(adap, false)); in cec_adap_enable()
1621 adap->last_initiator = 0xff; in cec_adap_enable()
1622 adap->transmit_in_progress = false; in cec_adap_enable()
1623 adap->transmit_in_progress_aborted = false; in cec_adap_enable()
1624 if (adap->transmitting) in cec_adap_enable()
1625 cec_data_cancel(adap->transmitting, CEC_TX_STATUS_ABORTED, 0); in cec_adap_enable()
1628 adap->is_enabled = enable; in cec_adap_enable()
1629 wake_up_interruptible(&adap->kthread_waitq); in cec_adap_enable()
1630 mutex_unlock(&adap->devnode.lock); in cec_adap_enable()
1638 void __cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block) in __cec_s_phys_addr() argument
1641 bool is_invalid = adap->phys_addr == CEC_PHYS_ADDR_INVALID; in __cec_s_phys_addr()
1643 if (phys_addr == adap->phys_addr) in __cec_s_phys_addr()
1645 if (!becomes_invalid && adap->devnode.unregistered) in __cec_s_phys_addr()
1651 adap->phys_addr = CEC_PHYS_ADDR_INVALID; in __cec_s_phys_addr()
1652 cec_post_state_event(adap); in __cec_s_phys_addr()
1653 cec_adap_unconfigure(adap); in __cec_s_phys_addr()
1655 cec_adap_enable(adap); in __cec_s_phys_addr()
1660 adap->phys_addr = phys_addr; in __cec_s_phys_addr()
1662 cec_adap_enable(adap); in __cec_s_phys_addr()
1664 cec_post_state_event(adap); in __cec_s_phys_addr()
1665 if (!adap->log_addrs.num_log_addrs) in __cec_s_phys_addr()
1667 if (adap->is_configuring) in __cec_s_phys_addr()
1668 adap->must_reconfigure = true; in __cec_s_phys_addr()
1670 cec_claim_log_addrs(adap, block); in __cec_s_phys_addr()
1673 void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, bool block) in cec_s_phys_addr() argument
1675 if (IS_ERR_OR_NULL(adap)) in cec_s_phys_addr()
1678 mutex_lock(&adap->lock); in cec_s_phys_addr()
1679 __cec_s_phys_addr(adap, phys_addr, block); in cec_s_phys_addr()
1680 mutex_unlock(&adap->lock); in cec_s_phys_addr()
1684 void cec_s_phys_addr_from_edid(struct cec_adapter *adap, in cec_s_phys_addr_from_edid() argument
1692 cec_s_phys_addr(adap, pa, false); in cec_s_phys_addr_from_edid()
1696 void cec_s_conn_info(struct cec_adapter *adap, in cec_s_conn_info() argument
1699 if (IS_ERR_OR_NULL(adap)) in cec_s_conn_info()
1702 if (!(adap->capabilities & CEC_CAP_CONNECTOR_INFO)) in cec_s_conn_info()
1705 mutex_lock(&adap->lock); in cec_s_conn_info()
1707 adap->conn_info = *conn_info; in cec_s_conn_info()
1709 memset(&adap->conn_info, 0, sizeof(adap->conn_info)); in cec_s_conn_info()
1710 cec_post_state_event(adap); in cec_s_conn_info()
1711 mutex_unlock(&adap->lock); in cec_s_conn_info()
1720 int __cec_s_log_addrs(struct cec_adapter *adap, in __cec_s_log_addrs() argument
1727 if (adap->devnode.unregistered) in __cec_s_log_addrs()
1731 if (!adap->log_addrs.num_log_addrs) in __cec_s_log_addrs()
1733 if (adap->is_configuring || adap->is_configured) in __cec_s_log_addrs()
1734 cec_adap_unconfigure(adap); in __cec_s_log_addrs()
1735 adap->log_addrs.num_log_addrs = 0; in __cec_s_log_addrs()
1737 adap->log_addrs.log_addr[i] = CEC_LOG_ADDR_INVALID; in __cec_s_log_addrs()
1738 adap->log_addrs.osd_name[0] = '\0'; in __cec_s_log_addrs()
1739 adap->log_addrs.vendor_id = CEC_VENDOR_ID_NONE; in __cec_s_log_addrs()
1740 adap->log_addrs.cec_version = CEC_OP_CEC_VERSION_2_0; in __cec_s_log_addrs()
1741 cec_adap_enable(adap); in __cec_s_log_addrs()
1772 if (log_addrs->num_log_addrs > adap->available_log_addrs) { in __cec_s_log_addrs()
1773 dprintk(1, "num_log_addrs > %d\n", adap->available_log_addrs); in __cec_s_log_addrs()
1875 log_addrs->log_addr_mask = adap->log_addrs.log_addr_mask; in __cec_s_log_addrs()
1876 adap->log_addrs = *log_addrs; in __cec_s_log_addrs()
1877 err = cec_adap_enable(adap); in __cec_s_log_addrs()
1878 if (!err && adap->phys_addr != CEC_PHYS_ADDR_INVALID) in __cec_s_log_addrs()
1879 cec_claim_log_addrs(adap, block); in __cec_s_log_addrs()
1883 int cec_s_log_addrs(struct cec_adapter *adap, in cec_s_log_addrs() argument
1888 mutex_lock(&adap->lock); in cec_s_log_addrs()
1889 err = __cec_s_log_addrs(adap, log_addrs, block); in cec_s_log_addrs()
1890 mutex_unlock(&adap->lock); in cec_s_log_addrs()
1898 static void cec_fill_msg_report_features(struct cec_adapter *adap, in cec_fill_msg_report_features() argument
1902 const struct cec_log_addrs *las = &adap->log_addrs; in cec_fill_msg_report_features()
1911 msg->msg[2] = adap->log_addrs.cec_version; in cec_fill_msg_report_features()
1926 static int cec_feature_abort_reason(struct cec_adapter *adap, in cec_feature_abort_reason() argument
1942 return cec_transmit_msg(adap, &tx_msg, false); in cec_feature_abort_reason()
1945 static int cec_feature_abort(struct cec_adapter *adap, struct cec_msg *msg) in cec_feature_abort() argument
1947 return cec_feature_abort_reason(adap, msg, in cec_feature_abort()
1951 static int cec_feature_refused(struct cec_adapter *adap, struct cec_msg *msg) in cec_feature_refused() argument
1953 return cec_feature_abort_reason(adap, msg, in cec_feature_refused()
1964 static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg, in cec_receive_notify() argument
1970 u8 devtype = cec_log_addr2dev(adap, dest_laddr); in cec_receive_notify()
1971 int la_idx = cec_log_addr2idx(adap, dest_laddr); in cec_receive_notify()
1978 if (cec_is_cdc_only(&adap->log_addrs) && in cec_receive_notify()
1983 if (adap->ops->received && !adap->devnode.unregistered && in cec_receive_notify()
1984 adap->ops->received(adap, msg) != -ENOMSG) in cec_receive_notify()
2002 if (!adap->passthrough && from_unregistered) in cec_receive_notify()
2012 if (adap->passthrough) in cec_receive_notify()
2054 if (!(adap->capabilities & CEC_CAP_RC) || in cec_receive_notify()
2055 !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU)) in cec_receive_notify()
2066 rc_keydown(adap->rc, RC_PROTO_CEC, in cec_receive_notify()
2069 rc_keydown(adap->rc, RC_PROTO_CEC, in cec_receive_notify()
2089 rc_keydown(adap->rc, RC_PROTO_CEC, msg->msg[2], 0); in cec_receive_notify()
2096 if (!(adap->capabilities & CEC_CAP_RC) || in cec_receive_notify()
2097 !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU)) in cec_receive_notify()
2100 rc_keyup(adap->rc); in cec_receive_notify()
2109 cec_msg_cec_version(&tx_cec_msg, adap->log_addrs.cec_version); in cec_receive_notify()
2110 return cec_transmit_msg(adap, &tx_cec_msg, false); in cec_receive_notify()
2116 cec_msg_report_physical_addr(&tx_cec_msg, adap->phys_addr, devtype); in cec_receive_notify()
2117 return cec_transmit_msg(adap, &tx_cec_msg, false); in cec_receive_notify()
2120 if (adap->log_addrs.vendor_id == CEC_VENDOR_ID_NONE) in cec_receive_notify()
2121 return cec_feature_abort(adap, msg); in cec_receive_notify()
2122 cec_msg_device_vendor_id(&tx_cec_msg, adap->log_addrs.vendor_id); in cec_receive_notify()
2123 return cec_transmit_msg(adap, &tx_cec_msg, false); in cec_receive_notify()
2129 return cec_feature_refused(adap, msg); in cec_receive_notify()
2132 if (adap->log_addrs.osd_name[0] == 0) in cec_receive_notify()
2133 return cec_feature_abort(adap, msg); in cec_receive_notify()
2134 cec_msg_set_osd_name(&tx_cec_msg, adap->log_addrs.osd_name); in cec_receive_notify()
2135 return cec_transmit_msg(adap, &tx_cec_msg, false); in cec_receive_notify()
2139 if (adap->log_addrs.cec_version < CEC_OP_CEC_VERSION_2_0) in cec_receive_notify()
2140 return cec_feature_abort(adap, msg); in cec_receive_notify()
2141 cec_fill_msg_report_features(adap, &tx_cec_msg, la_idx); in cec_receive_notify()
2142 return cec_transmit_msg(adap, &tx_cec_msg, false); in cec_receive_notify()
2149 if (!is_broadcast && !is_reply && !adap->follower_cnt && in cec_receive_notify()
2150 !adap->cec_follower && msg->msg[1] != CEC_MSG_FEATURE_ABORT) in cec_receive_notify()
2151 return cec_feature_abort(adap, msg); in cec_receive_notify()
2164 if (adap->cec_follower) in cec_receive_notify()
2165 cec_queue_msg_fh(adap->cec_follower, msg); in cec_receive_notify()
2167 cec_queue_msg_followers(adap, msg); in cec_receive_notify()
2176 int cec_monitor_all_cnt_inc(struct cec_adapter *adap) in cec_monitor_all_cnt_inc() argument
2180 if (adap->monitor_all_cnt++) in cec_monitor_all_cnt_inc()
2183 ret = cec_adap_enable(adap); in cec_monitor_all_cnt_inc()
2185 adap->monitor_all_cnt--; in cec_monitor_all_cnt_inc()
2189 void cec_monitor_all_cnt_dec(struct cec_adapter *adap) in cec_monitor_all_cnt_dec() argument
2191 if (WARN_ON(!adap->monitor_all_cnt)) in cec_monitor_all_cnt_dec()
2193 if (--adap->monitor_all_cnt) in cec_monitor_all_cnt_dec()
2195 WARN_ON(call_op(adap, adap_monitor_all_enable, false)); in cec_monitor_all_cnt_dec()
2196 cec_adap_enable(adap); in cec_monitor_all_cnt_dec()
2204 int cec_monitor_pin_cnt_inc(struct cec_adapter *adap) in cec_monitor_pin_cnt_inc() argument
2208 if (adap->monitor_pin_cnt++) in cec_monitor_pin_cnt_inc()
2211 ret = cec_adap_enable(adap); in cec_monitor_pin_cnt_inc()
2213 adap->monitor_pin_cnt--; in cec_monitor_pin_cnt_inc()
2217 void cec_monitor_pin_cnt_dec(struct cec_adapter *adap) in cec_monitor_pin_cnt_dec() argument
2219 if (WARN_ON(!adap->monitor_pin_cnt)) in cec_monitor_pin_cnt_dec()
2221 if (--adap->monitor_pin_cnt) in cec_monitor_pin_cnt_dec()
2223 WARN_ON(call_op(adap, adap_monitor_pin_enable, false)); in cec_monitor_pin_cnt_dec()
2224 cec_adap_enable(adap); in cec_monitor_pin_cnt_dec()
2234 struct cec_adapter *adap = dev_get_drvdata(file->private); in cec_adap_status() local
2237 mutex_lock(&adap->lock); in cec_adap_status()
2238 seq_printf(file, "enabled: %d\n", adap->is_enabled); in cec_adap_status()
2239 seq_printf(file, "configured: %d\n", adap->is_configured); in cec_adap_status()
2240 seq_printf(file, "configuring: %d\n", adap->is_configuring); in cec_adap_status()
2242 cec_phys_addr_exp(adap->phys_addr)); in cec_adap_status()
2243 seq_printf(file, "number of LAs: %d\n", adap->log_addrs.num_log_addrs); in cec_adap_status()
2244 seq_printf(file, "LA mask: 0x%04x\n", adap->log_addrs.log_addr_mask); in cec_adap_status()
2245 if (adap->cec_follower) in cec_adap_status()
2247 adap->passthrough ? " (in passthrough mode)" : ""); in cec_adap_status()
2248 if (adap->cec_initiator) in cec_adap_status()
2250 if (adap->monitor_all_cnt) in cec_adap_status()
2252 adap->monitor_all_cnt); in cec_adap_status()
2253 if (adap->monitor_pin_cnt) in cec_adap_status()
2255 adap->monitor_pin_cnt); in cec_adap_status()
2256 if (adap->tx_timeouts) { in cec_adap_status()
2258 adap->tx_timeouts); in cec_adap_status()
2259 adap->tx_timeouts = 0; in cec_adap_status()
2261 data = adap->transmitting; in cec_adap_status()
2266 seq_printf(file, "pending transmits: %u\n", adap->transmit_queue_sz); in cec_adap_status()
2267 list_for_each_entry(data, &adap->transmit_queue, list) { in cec_adap_status()
2272 list_for_each_entry(data, &adap->wait_queue, list) { in cec_adap_status()
2278 call_void_op(adap, adap_status, file); in cec_adap_status()
2279 mutex_unlock(&adap->lock); in cec_adap_status()