|
Lines 1-11
Link Here
|
| 1 |
--- ./src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp.orig 2012-10-17 11:35:39.000000000 +0200 |
1 |
diff --git src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp |
| 2 |
+++ ./src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp 2012-10-17 11:35:52.000000000 +0200 |
2 |
index 35ba386..dc1c79b 100644 |
| 3 |
@@ -427,8 +427,6 @@ |
3 |
--- src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp |
| 4 |
for (i = 0; i < 8; ++i) |
4 |
+++ src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp |
|
|
5 |
@@ -63,6 +63,8 @@ extern "C" { |
| 6 |
#elif defined(__FreeBSD__) |
| 7 |
#include <stdio.h> |
| 8 |
#include <unistd.h> |
| 9 |
+#include <sys/types.h> |
| 10 |
+#include <sys/sysctl.h> |
| 11 |
#endif |
| 12 |
|
| 13 |
#define CEC_VID 0x2548 |
| 14 |
@@ -434,22 +436,68 @@ uint8_t CUSBCECAdapterDetection::FindAdapters(cec_adapter_descriptor *deviceList |
| 15 |
} |
| 16 |
#elif defined(__FreeBSD__) |
| 17 |
char devicePath[PATH_MAX + 1]; |
| 18 |
+ char infos[512]; |
| 19 |
+ char sysctlname[32]; |
| 20 |
+ char ttyname[8]; |
| 21 |
+ char *pos; |
| 22 |
+ size_t infos_size = sizeof(infos); |
| 23 |
int i; |
| 24 |
|
| 25 |
- for (i = 0; i < 8; ++i) |
| 26 |
+ for (i = 0; ; ++i) |
| 5 |
{ |
27 |
{ |
| 6 |
(void)snprintf(devicePath, sizeof(devicePath), "/dev/ttyU%d", i); |
28 |
- (void)snprintf(devicePath, sizeof(devicePath), "/dev/ttyU%d", i); |
| 7 |
- if (strDevicePath && strcmp(devicePath, strDevicePath) != 0) |
29 |
- if (strDevicePath && strcmp(devicePath, strDevicePath) != 0) |
| 8 |
- continue; |
30 |
+ memset(infos, 0, sizeof(infos)); |
| 9 |
if (!access(devicePath, 0)) |
31 |
+ (void)snprintf(sysctlname, sizeof(sysctlname), |
| 10 |
{ |
32 |
+ "dev.umodem.%d.%%pnpinfo", i); |
| 11 |
snprintf(deviceList[iFound].path, sizeof(deviceList[iFound].path), "%s", devicePath); |
33 |
+ if (sysctlbyname(sysctlname, infos, &infos_size, |
|
|
34 |
+ NULL, 0) != 0) |
| 35 |
+ break; |
| 36 |
+ if (strstr(infos, "vendor=0x2548") == NULL) |
| 37 |
continue; |
| 38 |
- if (!access(devicePath, 0)) |
| 39 |
- { |
| 40 |
- snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicePath); |
| 41 |
- snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", devicePath); |
| 42 |
- deviceList[iFound].iVendorId = CEC_VID; |
| 43 |
- deviceList[iFound].iProductId = CEC_VID; |
| 44 |
- deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type |
| 45 |
- iFound++; |
| 46 |
+ if (strstr(infos, "product=0x1001") == NULL |
| 47 |
+ && strstr(infos, "product=0x1002") == NULL) |
| 48 |
+ continue; |
| 49 |
+ pos = strstr(infos, "ttyname="); |
| 50 |
+ if (pos == NULL) |
| 51 |
+ continue; |
| 52 |
+ sscanf(pos, "ttyname=%s ", ttyname); |
| 53 |
+ |
| 54 |
+ (void)snprintf(devicePath, sizeof(devicePath), |
| 55 |
+ "/dev/tty%s", ttyname); |
| 56 |
+ |
| 57 |
+ if (strDevicePath) { |
| 58 |
+ char currStrDevicePath[512]; |
| 59 |
+ int port = 0; |
| 60 |
+ int devaddr = 0; |
| 61 |
+ memset(currStrDevicePath, 0, sizeof(currStrDevicePath)); |
| 62 |
+ memset(infos, 0, sizeof(infos)); |
| 63 |
+ (void)snprintf(sysctlname, sizeof(sysctlname), |
| 64 |
+ "dev.umodem.%d.%%location", i); |
| 65 |
+ if (sysctlbyname(sysctlname, infos, &infos_size, |
| 66 |
+ NULL, 0) != 0) |
| 67 |
+ break; |
| 68 |
+ |
| 69 |
+ pos = strstr(infos, "port="); |
| 70 |
+ if (pos == NULL) |
| 71 |
+ continue; |
| 72 |
+ sscanf(pos, "port=%d ", &port); |
| 73 |
+ |
| 74 |
+ pos = strstr(infos, "devaddr="); |
| 75 |
+ if (pos == NULL) |
| 76 |
+ continue; |
| 77 |
+ sscanf(pos, "devaddr=%d ", &devaddr); |
| 78 |
+ |
| 79 |
+ (void)snprintf(currStrDevicePath, sizeof(currStrDevicePath), |
| 80 |
+ "/dev/ugen%d.%d", port, devaddr); |
| 81 |
+ |
| 82 |
+ if (strcmp(currStrDevicePath, strDevicePath) != 0) |
| 83 |
+ continue; |
| 84 |
} |
| 85 |
+ snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicePath); |
| 86 |
+ snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", devicePath); |
| 87 |
+ deviceList[iFound].iVendorId = CEC_VID; |
| 88 |
+ deviceList[iFound].iProductId = CEC_VID; |
| 89 |
+ deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type |
| 90 |
+ iFound++; |
| 91 |
} |
| 92 |
#else |
| 93 |
//silence "unused" warnings |