adb.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Definitions for ADB (Apple Desktop Bus) support.
  4. */
  5. #ifndef __ADB_H
  6. #define __ADB_H
  7. #include <uapi/linux/adb.h>
  8. struct adb_request {
  9. unsigned char data[32];
  10. int nbytes;
  11. unsigned char reply[32];
  12. int reply_len;
  13. unsigned char reply_expected;
  14. unsigned char sent;
  15. unsigned char complete;
  16. void (*done)(struct adb_request *);
  17. void *arg;
  18. struct adb_request *next;
  19. };
  20. struct adb_ids {
  21. int nids;
  22. unsigned char id[16];
  23. };
  24. /* Structure which encapsulates a low-level ADB driver */
  25. struct adb_driver {
  26. char name[16];
  27. int (*probe)(void);
  28. int (*init)(void);
  29. int (*send_request)(struct adb_request *req, int sync);
  30. int (*autopoll)(int devs);
  31. void (*poll)(void);
  32. int (*reset_bus)(void);
  33. };
  34. /* Values for adb_request flags */
  35. #define ADBREQ_REPLY 1 /* expect reply */
  36. #define ADBREQ_SYNC 2 /* poll until done */
  37. #define ADBREQ_NOSEND 4 /* build the request, but don't send it */
  38. /* Messages sent thru the client_list notifier. You should NOT stop
  39. the operation, at least not with this version */
  40. enum adb_message {
  41. ADB_MSG_POWERDOWN, /* Currently called before sleep only */
  42. ADB_MSG_PRE_RESET, /* Called before resetting the bus */
  43. ADB_MSG_POST_RESET /* Called after resetting the bus (re-do init & register) */
  44. };
  45. extern struct blocking_notifier_head adb_client_list;
  46. int adb_request(struct adb_request *req, void (*done)(struct adb_request *),
  47. int flags, int nbytes, ...);
  48. int adb_register(int default_id,int handler_id,struct adb_ids *ids,
  49. void (*handler)(unsigned char *, int, int));
  50. int adb_unregister(int index);
  51. void adb_poll(void);
  52. void adb_input(unsigned char *, int, int);
  53. int adb_reset_bus(void);
  54. int adb_try_handler_change(int address, int new_id);
  55. int adb_get_infos(int address, int *original_address, int *handler_id);
  56. #endif /* __ADB_H */