View | Details | Raw Unified | Return to bug 179517
Collapse All | Expand All

(-)./src/lib/adapter/Pulse-Eight/USBCECAdapterDetection.cpp (-11 / +68 lines)
Lines 61-66 Link Here
61
#include <libudev.h>
61
#include <libudev.h>
62
}
62
}
63
#elif defined(__FreeBSD__)
63
#elif defined(__FreeBSD__)
64
#include <sys/param.h>
65
#include <sys/sysctl.h>
64
#include <stdio.h>
66
#include <stdio.h>
65
#include <unistd.h>
67
#include <unistd.h>
66
#endif
68
#endif
Lines 434-455 Link Here
434
  }
436
  }
435
#elif defined(__FreeBSD__)
437
#elif defined(__FreeBSD__)
436
  char devicePath[PATH_MAX + 1];
438
  char devicePath[PATH_MAX + 1];
439
  char infos[512];
440
  char sysctlname[32];
441
  char ttyname[8];
442
  char *pos;
443
  size_t infos_size = sizeof(infos);
437
  int i;
444
  int i;
438
445
439
  for (i = 0; i < 8; ++i)
446
  for (i = 0; ; ++i)
440
  {
447
  {
441
    (void)snprintf(devicePath, sizeof(devicePath), "/dev/ttyU%d", i);
448
    unsigned int iVendor, iProduct;
442
    if (strDevicePath && strcmp(devicePath, strDevicePath) != 0)
449
    memset(infos, 0, sizeof(infos));
450
    (void)snprintf(sysctlname, sizeof(sysctlname),
451
      "dev.umodem.%d.%%pnpinfo", i);
452
    if (sysctlbyname(sysctlname, infos, &infos_size,
453
      NULL, 0) != 0)
454
        break;
455
    pos = strstr(infos, "vendor=");
456
    if (pos == NULL)
443
      continue;
457
      continue;
444
    if (!access(devicePath, 0))
458
    sscanf(pos, "vendor=%x ", &iVendor);
445
    {
459
446
      snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicePath);
460
    pos = strstr(infos, "product=");
447
      snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", devicePath);
461
    if (pos == NULL)
448
      deviceList[iFound].iVendorId = CEC_VID;
462
      continue;
449
      deviceList[iFound].iProductId = CEC_VID;
463
    sscanf(pos, "product=%x ", &iProduct);
450
      deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
464
451
      iFound++;
465
    if (iVendor != CEC_VID || (iProduct != CEC_PID && iProduct != CEC_PID2))
466
      continue;
467
468
    pos = strstr(infos, "ttyname=");
469
    if (pos == NULL)
470
      continue;
471
    sscanf(pos, "ttyname=%s ", ttyname);
472
473
    (void)snprintf(devicePath, sizeof(devicePath),
474
      "/dev/tty%s", ttyname);
475
476
    if (strDevicePath) {
477
      char currStrDevicePath[512];
478
      int port = 0;
479
      int devaddr = 0;
480
      memset(currStrDevicePath, 0, sizeof(currStrDevicePath));
481
      memset(infos, 0, sizeof(infos));
482
      (void)snprintf(sysctlname, sizeof(sysctlname),
483
        "dev.umodem.%d.%%location", i);
484
      if (sysctlbyname(sysctlname, infos, &infos_size,
485
        NULL, 0) != 0)
486
          break;
487
488
      pos = strstr(infos, "port=");
489
      if (pos == NULL)
490
        continue;
491
      sscanf(pos, "port=%d ", &port);
492
493
      pos = strstr(infos, "devaddr=");
494
      if (pos == NULL)
495
        continue;
496
      sscanf(pos, "devaddr=%d ", &devaddr);
497
498
      (void)snprintf(currStrDevicePath, sizeof(currStrDevicePath),
499
        "/dev/ugen%d.%d", port, devaddr);
500
501
      if (strcmp(currStrDevicePath, strDevicePath) != 0)
502
        continue;
452
    }
503
    }
504
    snprintf(deviceList[iFound].strComPath, sizeof(deviceList[iFound].strComPath), "%s", devicePath);
505
    snprintf(deviceList[iFound].strComName, sizeof(deviceList[iFound].strComName), "%s", devicePath);
506
    deviceList[iFound].iVendorId = iVendor;
507
    deviceList[iFound].iProductId = iProduct;
508
    deviceList[iFound].adapterType = ADAPTERTYPE_P8_EXTERNAL; // will be overridden when not doing a "quick scan" by the actual type
509
    iFound++;
453
  }
510
  }
454
#else
511
#else
455
  //silence "unused" warnings
512
  //silence "unused" warnings

Return to bug 179517