lowlevel.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _BFG_LOWLEVEL_H
  2. #define _BFG_LOWLEVEL_H
  3. #include <stdbool.h>
  4. #include <stdint.h>
  5. #include <pthread.h>
  6. #include <uthash.h>
  7. struct lowlevel_device_info;
  8. typedef bool (*lowl_found_devinfo_func_t)(struct lowlevel_device_info *, void *);
  9. struct lowlevel_driver {
  10. const char *dname;
  11. struct lowlevel_device_info *(*devinfo_scan)();
  12. void (*devinfo_free)(struct lowlevel_device_info *);
  13. };
  14. struct lowlevel_device_info {
  15. char *manufacturer;
  16. char *product;
  17. char *serial;
  18. char *path;
  19. char *devid;
  20. uint16_t vid;
  21. uint16_t pid;
  22. struct lowlevel_driver *lowl;
  23. void *lowl_data;
  24. struct lowlevel_device_info *next;
  25. UT_hash_handle hh;
  26. pthread_t probe_pth;
  27. };
  28. extern struct lowlevel_device_info *lowlevel_scan();
  29. extern int _lowlevel_detect(lowl_found_devinfo_func_t, const char *serial, const char **product_needles, void *);
  30. #define lowlevel_detect(func, ...) _lowlevel_detect(func, NULL, (const char *[]){__VA_ARGS__, NULL}, NULL)
  31. #define lowlevel_detect_serial(func, serial) _lowlevel_detect(func, serial, (const char *[]){NULL}, NULL)
  32. extern int lowlevel_detect_id(lowl_found_devinfo_func_t, void *, const struct lowlevel_driver *, int32_t vid, int32_t pid);
  33. extern void lowlevel_scan_free();
  34. extern void lowlevel_devinfo_semicpy(struct lowlevel_device_info *dst, const struct lowlevel_device_info *src);
  35. extern void lowlevel_devinfo_free(struct lowlevel_device_info *);
  36. #ifdef USE_X6500
  37. extern struct lowlevel_driver lowl_ft232r;
  38. #endif
  39. #ifdef NEED_BFG_LOWL_HID
  40. extern struct lowlevel_driver lowl_hid;
  41. #endif
  42. #ifdef USE_NANOFURY
  43. extern struct lowlevel_driver lowl_mcp2210;
  44. #endif
  45. #ifdef HAVE_LIBUSB
  46. extern struct lowlevel_driver lowl_usb;
  47. #else
  48. // Dummy definition for the various "don't warn if just a lower-level interface" checks
  49. static struct lowlevel_driver lowl_usb;
  50. #endif
  51. #ifdef HAVE_FPGAUTILS
  52. extern struct lowlevel_driver lowl_vcom;
  53. #endif
  54. #endif