diff options
-rw-r--r-- | drivers/media/rc/mceusb.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index 4c5909f06ac2..c4f3bc00611d 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c | |||
@@ -439,6 +439,10 @@ struct mceusb_dev { | |||
439 | 439 | ||
440 | bool need_reset; /* flag to issue a device resume cmd */ | 440 | bool need_reset; /* flag to issue a device resume cmd */ |
441 | u8 emver; /* emulator interface version */ | 441 | u8 emver; /* emulator interface version */ |
442 | u8 num_txports; /* number of transmit ports */ | ||
443 | u8 num_rxports; /* number of receive sensors */ | ||
444 | u8 txports_cabled; /* bitmask of transmitters with cable */ | ||
445 | u8 rxports_active; /* bitmask of active receive sensors */ | ||
442 | }; | 446 | }; |
443 | 447 | ||
444 | /* MCE Device Command Strings, generally a port and command pair */ | 448 | /* MCE Device Command Strings, generally a port and command pair */ |
@@ -450,6 +454,7 @@ static char GET_WAKEVERSION[] = {MCE_CMD_PORT_SYS, MCE_CMD_GETWAKEVERSION}; | |||
450 | static char GET_UNKNOWN2[] = {MCE_CMD_PORT_IR, MCE_CMD_UNKNOWN2}; | 454 | static char GET_UNKNOWN2[] = {MCE_CMD_PORT_IR, MCE_CMD_UNKNOWN2}; |
451 | static char GET_CARRIER_FREQ[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRCFS}; | 455 | static char GET_CARRIER_FREQ[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRCFS}; |
452 | static char GET_RX_TIMEOUT[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTIMEOUT}; | 456 | static char GET_RX_TIMEOUT[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTIMEOUT}; |
457 | static char GET_NUM_PORTS[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRNUMPORTS}; | ||
453 | static char GET_TX_BITMASK[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTXPORTS}; | 458 | static char GET_TX_BITMASK[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRTXPORTS}; |
454 | static char GET_RX_SENSOR[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRRXPORTEN}; | 459 | static char GET_RX_SENSOR[] = {MCE_CMD_PORT_IR, MCE_CMD_GETIRRXPORTEN}; |
455 | /* sub in desired values in lower byte or bytes for full command */ | 460 | /* sub in desired values in lower byte or bytes for full command */ |
@@ -543,6 +548,8 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, | |||
543 | 548 | ||
544 | switch (cmd) { | 549 | switch (cmd) { |
545 | case MCE_CMD_NULL: | 550 | case MCE_CMD_NULL: |
551 | if (subcmd == MCE_CMD_NULL) | ||
552 | break; | ||
546 | if ((subcmd == MCE_CMD_PORT_SYS) && | 553 | if ((subcmd == MCE_CMD_PORT_SYS) && |
547 | (data1 == MCE_CMD_RESUME)) | 554 | (data1 == MCE_CMD_RESUME)) |
548 | dev_info(dev, "Device resume requested\n"); | 555 | dev_info(dev, "Device resume requested\n"); |
@@ -909,10 +916,20 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) | |||
909 | u8 lo = ir->buf_in[index + 2] & 0xff; | 916 | u8 lo = ir->buf_in[index + 2] & 0xff; |
910 | 917 | ||
911 | switch (ir->buf_in[index]) { | 918 | switch (ir->buf_in[index]) { |
919 | /* the one and only 5-byte return value command */ | ||
920 | case MCE_RSP_GETPORTSTATUS: | ||
921 | if ((ir->buf_in[index + 4] & 0xff) == 0x00) | ||
922 | ir->txports_cabled |= 1 << hi; | ||
923 | break; | ||
924 | |||
912 | /* 2-byte return value commands */ | 925 | /* 2-byte return value commands */ |
913 | case MCE_RSP_EQIRTIMEOUT: | 926 | case MCE_RSP_EQIRTIMEOUT: |
914 | ir->rc->timeout = US_TO_NS((hi << 8 | lo) * MCE_TIME_UNIT); | 927 | ir->rc->timeout = US_TO_NS((hi << 8 | lo) * MCE_TIME_UNIT); |
915 | break; | 928 | break; |
929 | case MCE_RSP_EQIRNUMPORTS: | ||
930 | ir->num_txports = hi; | ||
931 | ir->num_rxports = lo; | ||
932 | break; | ||
916 | 933 | ||
917 | /* 1-byte return value commands */ | 934 | /* 1-byte return value commands */ |
918 | case MCE_RSP_EQEMVER: | 935 | case MCE_RSP_EQEMVER: |
@@ -923,6 +940,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, int index) | |||
923 | break; | 940 | break; |
924 | case MCE_RSP_EQIRRXPORTEN: | 941 | case MCE_RSP_EQIRRXPORTEN: |
925 | ir->learning_enabled = ((hi & 0x02) == 0x02); | 942 | ir->learning_enabled = ((hi & 0x02) == 0x02); |
943 | ir->rxports_active = hi; | ||
926 | break; | 944 | break; |
927 | case MCE_RSP_CMD_ILLEGAL: | 945 | case MCE_RSP_CMD_ILLEGAL: |
928 | ir->need_reset = true; | 946 | ir->need_reset = true; |
@@ -1115,10 +1133,21 @@ static void mceusb_gen2_init(struct mceusb_dev *ir) | |||
1115 | 1133 | ||
1116 | static void mceusb_get_parameters(struct mceusb_dev *ir) | 1134 | static void mceusb_get_parameters(struct mceusb_dev *ir) |
1117 | { | 1135 | { |
1136 | int i; | ||
1137 | unsigned char cmdbuf[3] = { MCE_CMD_PORT_SYS, | ||
1138 | MCE_CMD_GETPORTSTATUS, 0x00 }; | ||
1139 | |||
1140 | /* defaults, if the hardware doesn't support querying */ | ||
1141 | ir->num_txports = 2; | ||
1142 | ir->num_rxports = 2; | ||
1143 | |||
1144 | /* get number of tx and rx ports */ | ||
1145 | mce_async_out(ir, GET_NUM_PORTS, sizeof(GET_NUM_PORTS)); | ||
1146 | |||
1118 | /* get the carrier and frequency */ | 1147 | /* get the carrier and frequency */ |
1119 | mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); | 1148 | mce_async_out(ir, GET_CARRIER_FREQ, sizeof(GET_CARRIER_FREQ)); |
1120 | 1149 | ||
1121 | if (!ir->flags.no_tx) | 1150 | if (ir->num_txports && !ir->flags.no_tx) |
1122 | /* get the transmitter bitmask */ | 1151 | /* get the transmitter bitmask */ |
1123 | mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); | 1152 | mce_async_out(ir, GET_TX_BITMASK, sizeof(GET_TX_BITMASK)); |
1124 | 1153 | ||
@@ -1127,6 +1156,11 @@ static void mceusb_get_parameters(struct mceusb_dev *ir) | |||
1127 | 1156 | ||
1128 | /* get receiver sensor setting */ | 1157 | /* get receiver sensor setting */ |
1129 | mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); | 1158 | mce_async_out(ir, GET_RX_SENSOR, sizeof(GET_RX_SENSOR)); |
1159 | |||
1160 | for (i = 0; i < ir->num_txports; i++) { | ||
1161 | cmdbuf[2] = i; | ||
1162 | mce_async_out(ir, cmdbuf, sizeof(cmdbuf)); | ||
1163 | } | ||
1130 | } | 1164 | } |
1131 | 1165 | ||
1132 | static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) | 1166 | static struct rc_dev *mceusb_init_rc_dev(struct mceusb_dev *ir) |
@@ -1322,6 +1356,10 @@ static int __devinit mceusb_dev_probe(struct usb_interface *intf, | |||
1322 | 1356 | ||
1323 | dev_info(&intf->dev, "Registered %s with mce emulator interface " | 1357 | dev_info(&intf->dev, "Registered %s with mce emulator interface " |
1324 | "version %x\n", name, ir->emver); | 1358 | "version %x\n", name, ir->emver); |
1359 | dev_info(&intf->dev, "%x tx ports (0x%x cabled) and " | ||
1360 | "%x rx sensors (0x%x active)\n", | ||
1361 | ir->num_txports, ir->txports_cabled, | ||
1362 | ir->num_rxports, ir->rxports_active); | ||
1325 | 1363 | ||
1326 | return 0; | 1364 | return 0; |
1327 | 1365 | ||