cypress_bootloader.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef CYPRESS_BOOTLOADER_H_
  2. #define CYPRESS_BOOTLOADER_H_
  3. #include "razer_private.h"
  4. struct cypress {
  5. struct razer_usb_context usb;
  6. unsigned int ep_in;
  7. unsigned int ep_out;
  8. void (*assign_key)(uint8_t *key);
  9. };
  10. #define CYPRESS_BOOT_VENDORID 0x04B4
  11. #define CYPRESS_BOOT_PRODUCTID 0xE006
  12. /** is_cypress_bootloader - Check whether an USB device is a cypress bootloader. */
  13. static inline bool is_cypress_bootloader(struct libusb_device_descriptor *desc)
  14. {
  15. return (desc->idVendor == CYPRESS_BOOT_VENDORID &&
  16. desc->idProduct == CYPRESS_BOOT_PRODUCTID);
  17. }
  18. /** cypress_open - Open a device.
  19. * @c: context structure.
  20. * @dev: USB device to use (must be a cypress bootloader device).
  21. * @assign_key: Callback function to assign the 8-byte bootloader key.
  22. * If NULL, it uses the default key.
  23. */
  24. int cypress_open(struct cypress *c, struct libusb_device *dev,
  25. void (*assign_key)(uint8_t *key));
  26. /** cypress_close - Close a device. */
  27. void cypress_close(struct cypress *c);
  28. /** cypress_upload_image - Upload a firmware image to the device.
  29. * The device must be opened. */
  30. int cypress_upload_image(struct cypress *c,
  31. const char *image, size_t len);
  32. #endif /* CYPRESS_BOOTLOADER_H_ */