Lines Matching refs:extron
193 static int extron_send_and_wait_len(struct extron *extron, struct extron_port *port, in extron_send_and_wait_len() argument
202 dev_info(extron->dev, "transmit %s (response: %s)\n", in extron_send_and_wait_len()
205 dev_info(extron->dev, "transmit %s\n", cmd); in extron_send_and_wait_len()
208 mutex_lock(&extron->serio_lock); in extron_send_and_wait_len()
214 init_completion(&extron->cmd_done); in extron_send_and_wait_len()
215 extron->cmd_error = 0; in extron_send_and_wait_len()
216 extron->response = response; in extron_send_and_wait_len()
218 err = extron_send_len(extron->serio, cmd, bin, len); in extron_send_and_wait_len()
221 !wait_for_completion_timeout(port ? &port->cmd_done : &extron->cmd_done, timeout)) { in extron_send_and_wait_len()
222 dev_info(extron->dev, "transmit %s failed with %s (expected: %s)\n", in extron_send_and_wait_len()
223 cmd, extron->reply, response); in extron_send_and_wait_len()
227 if (!err && response && (port ? port->cmd_error : extron->cmd_error)) { in extron_send_and_wait_len()
228 dev_info(extron->dev, "transmit %s failed with E%02u (expected: %s)\n", in extron_send_and_wait_len()
229 cmd, port ? port->cmd_error : extron->cmd_error, response); in extron_send_and_wait_len()
233 extron->cmd_error = 0; in extron_send_and_wait_len()
239 extron->response = NULL; in extron_send_and_wait_len()
240 mutex_unlock(&extron->serio_lock); in extron_send_and_wait_len()
244 static int extron_send_and_wait(struct extron *extron, struct extron_port *port, in extron_send_and_wait() argument
247 return extron_send_and_wait_len(extron, port, cmd, NULL, 0, response); in extron_send_and_wait()
424 extron_set_edid_string(port->edid_tmp + 0x5f, port->extron->unit_name); in extron_update_edid()
446 struct extron *extron = port->extron; in extron_write_edid() local
453 if (mutex_lock_interruptible(&extron->edid_lock)) in extron_write_edid()
461 ret = extron_send_and_wait_len(port->extron, port, "W+UF256,in.bin", in extron_write_edid()
466 ret = extron_send_and_wait(port->extron, port, "WI1,in.binEDID", in extron_write_edid()
474 mutex_unlock(&extron->edid_lock); in extron_write_edid()
480 mutex_unlock(&extron->edid_lock); in extron_write_edid()
486 struct extron *extron = container_of(w, struct extron, in update_edid_work() local
488 struct extron_port *in = extron->ports[extron->num_out_ports]; in update_edid_work()
499 for (out = 0; has_4kp60 && out < extron->num_out_ports; out++) { in update_edid_work()
500 p = extron->ports[out]; in update_edid_work()
508 for (out = 0; has_4kp30 && out < extron->num_out_ports; out++) in update_edid_work()
509 if (extron->ports[out]->read_edid) in update_edid_work()
510 has_4kp30 = extron->ports[out]->has_4kp30; in update_edid_work()
512 for (out = 0; has_qy && out < extron->num_out_ports; out++) in update_edid_work()
513 if (extron->ports[out]->read_edid) in update_edid_work()
514 has_qy = extron->ports[out]->has_qy; in update_edid_work()
516 for (out = 0; has_qs && out < extron->num_out_ports; out++) in update_edid_work()
517 if (extron->ports[out]->read_edid) in update_edid_work()
518 has_qs = extron->ports[out]->has_qs; in update_edid_work()
536 extron_write_edid(extron->ports[extron->num_out_ports], in update_edid_work()
543 struct extron *extron = port->extron; in extron_read_edid() local
547 idx = port->port.port + (port->is_input ? 0 : extron->num_in_ports); in extron_read_edid()
550 if (mutex_lock_interruptible(&extron->edid_lock)) in extron_read_edid()
554 extron->edid_bytes_read = 0; in extron_read_edid()
555 extron->edid_port = port; in extron_read_edid()
560 extron->edid_reading = true; in extron_read_edid()
562 if (!extron_send_and_wait(extron, port, cmd, reply)) in extron_read_edid()
563 wait_for_completion_killable_timeout(&extron->edid_completion, in extron_read_edid()
572 extron->edid_reading = false; in extron_read_edid()
574 mutex_unlock(&extron->edid_lock); in extron_read_edid()
575 cancel_delayed_work_sync(&extron->work_update_edid); in extron_read_edid()
577 schedule_delayed_work(&extron->work_update_edid, in extron_read_edid()
585 struct extron *extron = port->extron; in extron_irq_work_handler() local
637 if (extron->edid_reading && !has_edid && in extron_irq_work_handler()
638 extron->edid_port == port) in extron_irq_work_handler()
639 extron->edid_reading = false; in extron_irq_work_handler()
641 } else if (!extron->edid_reading || extron->edid_port != port) { in extron_irq_work_handler()
690 dev_info(port->extron->dev, "malformed msg received: '%s'\n", data); in extron_process_received()
712 static void extron_process_signal_change(struct extron *extron, const char *data) in extron_process_signal_change() argument
716 extron_port_signal_change(extron->ports[extron->num_out_ports], in extron_process_signal_change()
718 for (i = 0; i < extron->num_out_ports; i++) in extron_process_signal_change()
719 extron_port_signal_change(extron->ports[i], in extron_process_signal_change()
742 static void extron_process_edid_change(struct extron *extron, const char *data) in extron_process_edid_change() argument
750 if (!extron->is_ready) in extron_process_edid_change()
753 for (i = 0; i < extron->num_out_ports; i++) in extron_process_edid_change()
754 extron_port_edid_change(extron->ports[i], in extron_process_edid_change()
805 struct extron *extron = port ? port->extron : NULL; in extron_add_edid() local
807 if (!port || port != extron->edid_port) in extron_add_edid()
809 while (extron->edid_bytes_read < sizeof(port->edid) && *hex) { in extron_add_edid()
810 int err = hex2bin(&port->edid[extron->edid_bytes_read], hex, 1); in extron_add_edid()
813 extron->edid_reading = false; in extron_add_edid()
814 complete(&extron->edid_completion); in extron_add_edid()
817 extron->edid_bytes_read++; in extron_add_edid()
820 if (extron->edid_bytes_read == 128 && in extron_add_edid()
824 extron->edid_reading = false; in extron_add_edid()
825 complete(&extron->edid_completion); in extron_add_edid()
827 if (extron->edid_bytes_read < sizeof(port->edid)) in extron_add_edid()
831 extron->edid_reading = false; in extron_add_edid()
832 complete(&extron->edid_completion); in extron_add_edid()
838 struct extron *extron = serio_get_drvdata(serio); in extron_interrupt() local
844 if (extron->idx == 0) in extron_interrupt()
846 memcpy(extron->data, extron->buf, extron->idx); in extron_interrupt()
847 extron->len = extron->idx; in extron_interrupt()
848 extron->data[extron->len] = 0; in extron_interrupt()
850 dev_info(extron->dev, "received %s\n", extron->data); in extron_interrupt()
851 extron->idx = 0; in extron_interrupt()
852 if (!memcmp(extron->data, "Sig", 3) && in extron_interrupt()
853 extron->data[4] == '*') { in extron_interrupt()
854 extron_process_signal_change(extron, extron->data + 3); in extron_interrupt()
855 } else if (!memcmp(extron->data, "Hdcp", 4) && in extron_interrupt()
856 extron->data[5] == '*') { in extron_interrupt()
857 extron_process_edid_change(extron, extron->data + 4); in extron_interrupt()
858 } else if (!memcmp(extron->data, "DcecI", 5) && in extron_interrupt()
859 extron->data[5] >= '1' && in extron_interrupt()
860 extron->data[5] < '1' + extron->num_in_ports) { in extron_interrupt()
861 unsigned int p = extron->data[5] - '1'; in extron_interrupt()
863 p += extron->num_out_ports; in extron_interrupt()
864 extron_process_tx_done(extron->ports[p], in extron_interrupt()
865 extron->data[extron->len - 1]); in extron_interrupt()
866 } else if (!memcmp(extron->data, "Ceci", 4) && in extron_interrupt()
867 extron->data[4] >= '1' && in extron_interrupt()
868 extron->data[4] < '1' + extron->num_in_ports && in extron_interrupt()
869 extron->data[5] == '*') { in extron_interrupt()
870 unsigned int p = extron->data[4] - '1'; in extron_interrupt()
872 p += extron->num_out_ports; in extron_interrupt()
873 extron_process_received(extron->ports[p], in extron_interrupt()
874 extron->data + 6); in extron_interrupt()
875 } else if (!memcmp(extron->data, "DcecO", 5) && in extron_interrupt()
876 extron->data[5] >= '1' && in extron_interrupt()
877 extron->data[5] < '1' + extron->num_out_ports) { in extron_interrupt()
878 unsigned int p = extron->data[5] - '1'; in extron_interrupt()
880 extron_process_tx_done(extron->ports[p], in extron_interrupt()
881 extron->data[extron->len - 1]); in extron_interrupt()
882 } else if (!memcmp(extron->data, "Ceco", 4) && in extron_interrupt()
883 extron->data[4] >= '1' && in extron_interrupt()
884 extron->data[4] < '1' + extron->num_out_ports && in extron_interrupt()
885 extron->data[5] == '*') { in extron_interrupt()
886 unsigned int p = extron->data[4] - '1'; in extron_interrupt()
888 extron_process_received(extron->ports[p], in extron_interrupt()
889 extron->data + 6); in extron_interrupt()
890 } else if (!memcmp(extron->data, "Pceco", 5) && in extron_interrupt()
891 extron->data[5] >= '1' && in extron_interrupt()
892 extron->data[5] < '1' + extron->num_out_ports) { in extron_interrupt()
893 unsigned int p = extron->data[5] - '1'; in extron_interrupt()
896 if (sscanf(extron->data + 7, "%%%02x%%%02x", in extron_interrupt()
898 extron_phys_addr_change(extron->ports[p], in extron_interrupt()
900 } else if (!memcmp(extron->data, "Pceci", 5) && in extron_interrupt()
901 extron->data[5] >= '1' && in extron_interrupt()
902 extron->data[5] < '1' + extron->num_in_ports) { in extron_interrupt()
903 unsigned int p = extron->data[5] - '1'; in extron_interrupt()
906 p += extron->num_out_ports; in extron_interrupt()
907 if (sscanf(extron->data + 7, "%%%02x%%%02x", in extron_interrupt()
909 extron_phys_addr_change(extron->ports[p], in extron_interrupt()
911 } else if (!memcmp(extron->data, "EdidR", 5) && in extron_interrupt()
912 extron->data[5] >= '1' && in extron_interrupt()
913 extron->data[5] < '1' + extron->num_ports && in extron_interrupt()
914 extron->data[6] == '*') { in extron_interrupt()
915 unsigned int p = extron->data[5] - '1'; in extron_interrupt()
920 p = extron->num_out_ports; in extron_interrupt()
921 extron_add_edid(extron->ports[p], extron->data + 7); in extron_interrupt()
922 } else if (extron->edid_reading && extron->len == 32 && in extron_interrupt()
923 extron->edid_port) { in extron_interrupt()
924 extron_add_edid(extron->edid_port, extron->data); in extron_interrupt()
928 if (extron->response && in extron_interrupt()
929 !strncmp(extron->response, extron->data, in extron_interrupt()
930 strlen(extron->response))) in extron_interrupt()
933 for (p = 0; !found_response && p < extron->num_ports; p++) { in extron_interrupt()
934 port = extron->ports[p]; in extron_interrupt()
936 !strncmp(port->response, extron->data, in extron_interrupt()
941 if (!found_response && extron->response && in extron_interrupt()
942 extron->data[0] == 'E' && in extron_interrupt()
943 isdigit(extron->data[1]) && in extron_interrupt()
944 isdigit(extron->data[2]) && in extron_interrupt()
945 !extron->data[3]) { in extron_interrupt()
946 extron->cmd_error = (extron->data[1] - '0') * 10 + in extron_interrupt()
947 extron->data[2] - '0'; in extron_interrupt()
948 extron->response = NULL; in extron_interrupt()
949 complete(&extron->cmd_done); in extron_interrupt()
955 memcpy(extron->reply, extron->data, extron->len); in extron_interrupt()
956 extron->reply[extron->len] = 0; in extron_interrupt()
958 extron->response = NULL; in extron_interrupt()
959 complete(&extron->cmd_done); in extron_interrupt()
967 if (extron->idx >= DATA_SIZE - 1) { in extron_interrupt()
968 dev_info(extron->dev, in extron_interrupt()
969 "throwing away %d bytes of garbage\n", extron->idx); in extron_interrupt()
970 extron->idx = 0; in extron_interrupt()
972 extron->buf[extron->idx++] = (char)data; in extron_interrupt()
997 err = extron_send_and_wait(port->extron, port, cmd, resp); in extron_cec_adap_log_addr()
1017 return extron_send_and_wait(port->extron, port, cmd, NULL); in extron_cec_adap_transmit()
1027 dev_info(port->extron->dev, "unconfigured port %d (%s)\n", in extron_cec_adap_unconfigured()
1029 port->extron->splitter.is_standby ? "Off" : "On"); in extron_cec_adap_unconfigured()
1041 dev_info(port->extron->dev, "configured port %d (%s)\n", in extron_cec_configured()
1043 port->extron->splitter.is_standby ? "Off" : "On"); in extron_cec_configured()
1058 input_adap = port->extron->ports[port->extron->num_out_ports]->adap; in extron_cec_adap_nb_transmit_canceled()
1073 port->extron->ports[port->extron->num_out_ports]->adap); in extron_received()
1111 pwr_state[port->extron->splitter.is_standby]); in extron_adap_status_port()
1145 struct extron *extron = port->extron; in extron_adap_status() local
1149 extron->unit_name, extron->unit_type); in extron_adap_status()
1151 '6' + extron->num_out_ports / 2, extron->num_out_ports); in extron_adap_status()
1153 extron->unit_fw_version, extron->unit_cec_engine_version); in extron_adap_status()
1154 if (extron->hpd_never_low) in extron_adap_status()
1166 pwr_state[extron->splitter.is_standby]); in extron_adap_status()
1171 extron_adap_status_port(extron->ports[extron->num_out_ports], file); in extron_adap_status()
1174 for (i = 0; i < extron->num_out_ports; i++) in extron_adap_status()
1175 extron_adap_status_port(extron->ports[i], file); in extron_adap_status()
1350 struct extron *extron = serio_get_drvdata(serio); in extron_disconnect() local
1353 kthread_stop(extron->kthread_setup); in extron_disconnect()
1355 for (p = 0; p < extron->num_ports; p++) { in extron_disconnect()
1356 struct extron_port *port = extron->ports[p]; in extron_disconnect()
1363 cancel_delayed_work_sync(&extron->work_update_edid); in extron_disconnect()
1364 for (p = 0; p < extron->num_ports; p++) { in extron_disconnect()
1365 struct extron_port *port = extron->ports[p]; in extron_disconnect()
1386 complete(&extron->edid_completion); in extron_disconnect()
1388 for (p = 0; p < extron->num_ports; p++) { in extron_disconnect()
1389 struct extron_port *port = extron->ports[p]; in extron_disconnect()
1397 mutex_destroy(&extron->edid_lock); in extron_disconnect()
1398 mutex_destroy(&extron->serio_lock); in extron_disconnect()
1399 extron->serio = NULL; in extron_disconnect()
1404 static int extron_setup(struct extron *extron) in extron_setup() argument
1406 struct serio *serio = extron->serio; in extron_setup()
1408 u8 *reply = extron->reply; in extron_setup()
1417 extron_send_and_wait(extron, NULL, "WI1*0CCEC", NULL); in extron_setup()
1418 extron_send_and_wait(extron, NULL, "WO0*CCEC", NULL); in extron_setup()
1421 err = extron_send_and_wait(extron, NULL, "N", "Pno"); in extron_setup()
1424 dev_info(extron->dev, "Unit part number: %s\n", reply + 3); in extron_setup()
1428 dev_err(extron->dev, "Unsupported model\n"); in extron_setup()
1432 extron->num_out_ports = 2 * (reply[9] - '6'); in extron_setup()
1433 extron->splitter.num_out_ports = extron->num_out_ports; in extron_setup()
1434 extron->splitter.ports = extron->splitter_ports; in extron_setup()
1435 extron->splitter.dev = extron->dev; in extron_setup()
1436 extron->num_in_ports = 1; in extron_setup()
1437 extron->num_ports = extron->num_out_ports + extron->num_in_ports; in extron_setup()
1438 dev_info(extron->dev, "Unit output ports: %d\n", extron->num_out_ports); in extron_setup()
1439 dev_info(extron->dev, "Unit input ports: %d\n", extron->num_in_ports); in extron_setup()
1441 err = extron_send_and_wait(extron, NULL, "W CN", "Ipn "); in extron_setup()
1444 dev_info(extron->dev, "Unit name: %s\n", reply + 4); in extron_setup()
1445 strscpy(extron->unit_name, reply + 4, sizeof(extron->unit_name)); in extron_setup()
1447 err = extron_send_and_wait(extron, NULL, "*Q", "Bld"); in extron_setup()
1450 dev_info(extron->dev, "Unit FW Version: %s\n", reply + 3); in extron_setup()
1451 strscpy(extron->unit_fw_version, reply + 3, in extron_setup()
1452 sizeof(extron->unit_fw_version)); in extron_setup()
1455 dev_err(extron->dev, in extron_setup()
1460 err = extron_send_and_wait(extron, NULL, "2i", "Inf02*"); in extron_setup()
1463 dev_info(extron->dev, "Unit Type: %s\n", reply + 6); in extron_setup()
1464 strscpy(extron->unit_type, reply + 6, sizeof(extron->unit_type)); in extron_setup()
1466 err = extron_send_and_wait(extron, NULL, "39Q", "Ver39*"); in extron_setup()
1469 dev_info(extron->dev, "CEC Engine Version: %s\n", reply + 6); in extron_setup()
1470 strscpy(extron->unit_cec_engine_version, reply + 6, in extron_setup()
1471 sizeof(extron->unit_cec_engine_version)); in extron_setup()
1474 err = extron_send_and_wait(extron, NULL, "WI1*0CCEC", "CcecI1*"); in extron_setup()
1477 err = extron_send_and_wait(extron, NULL, "WO0*CCEC", "CcecO0"); in extron_setup()
1481 extron->hpd_never_low = hpd_never_low; in extron_setup()
1485 dev_info(extron->dev, "Always keep input HPD high\n"); in extron_setup()
1487 dev_info(extron->dev, "Pull input HPD low if all output HPDs are low\n"); in extron_setup()
1488 extron_send_and_wait(extron, NULL, "W1ihpd", "Ihpd1"); in extron_setup()
1491 for (p = 0; p < extron->num_ports; p++) { in extron_setup()
1503 port->extron = extron; in extron_setup()
1504 port->is_input = p >= extron->num_out_ports; in extron_setup()
1506 port->port.port = 1 + (port->is_input ? p - extron->num_out_ports : p); in extron_setup()
1507 port->port.splitter = &extron->splitter; in extron_setup()
1513 port->dev = extron->dev; in extron_setup()
1526 port->vdev.v4l2_dev = &extron->v4l2_dev; in extron_setup()
1558 extron->ports[p] = port; in extron_setup()
1559 extron->splitter_ports[p] = &port->port; in extron_setup()
1565 err = extron_send_and_wait(extron, NULL, "WI1*20CCEC", "CcecI1*"); in extron_setup()
1569 err = extron_send_and_wait(extron, NULL, "WO20*CCEC", "CcecO20"); in extron_setup()
1574 err = extron_send_and_wait(extron, NULL, "WI1*15LCEC", "LcecI1*15"); in extron_setup()
1578 for (p = 0; p < extron->num_out_ports; p++) { in extron_setup()
1584 err = extron_send_and_wait(extron, extron->ports[p], cmd, resp); in extron_setup()
1593 extron->is_ready = true; in extron_setup()
1596 err = extron_send_and_wait(extron, NULL, "WHDCP", "Hdcp"); in extron_setup()
1600 return extron_send_and_wait(extron, NULL, "WLS", "Sig"); in extron_setup()
1605 struct extron *extron = _extron; in extron_setup_thread() local
1615 err = extron_send_and_wait(extron, NULL, "W3CV", "Vrb3"); in extron_setup_thread()
1635 err = extron_setup(extron); in extron_setup_thread()
1639 for (p = 0; p < extron->num_ports; p++) { in extron_setup_thread()
1642 port = extron->ports[p]; in extron_setup_thread()
1647 v4l2_err(&extron->v4l2_dev, "Failed to register video device\n"); in extron_setup_thread()
1651 err = cec_register_adapter(port->adap, extron->dev); in extron_setup_thread()
1706 port = extron->ports[extron->num_out_ports]; in extron_setup_thread()
1709 if (hpd_never_low != extron->hpd_never_low) { in extron_setup_thread()
1715 dev_info(extron->dev, "Always keep input HPD high\n"); in extron_setup_thread()
1716 extron_send_and_wait(extron, NULL, "W0ihpd", "Ihpd0"); in extron_setup_thread()
1718 dev_info(extron->dev, "Pull input HPD low if all output HPDs are low\n"); in extron_setup_thread()
1719 extron_send_and_wait(extron, NULL, "W1ihpd", "Ihpd1"); in extron_setup_thread()
1721 extron->hpd_never_low = hpd_never_low; in extron_setup_thread()
1724 cec_splitter_poll(&extron->splitter, port->adap, debug) && in extron_setup_thread()
1730 cancel_delayed_work_sync(&extron->work_update_edid); in extron_setup_thread()
1731 schedule_delayed_work(&extron->work_update_edid, in extron_setup_thread()
1738 extron->is_ready = false; in extron_setup_thread()
1739 for (p = 0; p < extron->num_ports; p++) { in extron_setup_thread()
1740 struct extron_port *port = extron->ports[p]; in extron_setup_thread()
1750 cancel_delayed_work_sync(&extron->work_update_edid); in extron_setup_thread()
1751 complete(&extron->edid_completion); in extron_setup_thread()
1752 dev_err(extron->dev, "Setup failed with error %d\n", err); in extron_setup_thread()
1760 struct extron *extron; in extron_connect() local
1771 extron = kzalloc(sizeof(*extron), GFP_KERNEL); in extron_connect()
1773 if (!extron) in extron_connect()
1776 extron->serio = serio; in extron_connect()
1777 extron->dev = &serio->dev; in extron_connect()
1778 mutex_init(&extron->serio_lock); in extron_connect()
1779 mutex_init(&extron->edid_lock); in extron_connect()
1780 INIT_DELAYED_WORK(&extron->work_update_edid, update_edid_work); in extron_connect()
1782 err = v4l2_device_register(extron->dev, &extron->v4l2_dev); in extron_connect()
1790 serio_set_drvdata(serio, extron); in extron_connect()
1791 init_completion(&extron->edid_completion); in extron_connect()
1793 extron->kthread_setup = kthread_run(extron_setup_thread, extron, in extron_connect()
1795 if (!IS_ERR(extron->kthread_setup)) in extron_connect()
1798 dev_err(extron->dev, "kthread_run() failed\n"); in extron_connect()
1799 err = PTR_ERR(extron->kthread_setup); in extron_connect()
1801 extron->serio = NULL; in extron_connect()
1805 v4l2_device_unregister(&extron->v4l2_dev); in extron_connect()
1807 mutex_destroy(&extron->edid_lock); in extron_connect()
1808 mutex_destroy(&extron->serio_lock); in extron_connect()
1809 kfree(extron); in extron_connect()