adb.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Definitions for ADB (Apple Desktop Bus) support.
  3. */
  4. #ifndef __ADB_H
  5. #define __ADB_H
  6. /* ADB commands */
  7. #define ADB_BUSRESET 0
  8. #define ADB_FLUSH(id) (0x01 | ((id) << 4))
  9. #define ADB_WRITEREG(id, reg) (0x08 | (reg) | ((id) << 4))
  10. #define ADB_READREG(id, reg) (0x0C | (reg) | ((id) << 4))
  11. /* ADB default device IDs (upper 4 bits of ADB command byte) */
  12. #define ADB_DONGLE 1 /* "software execution control" devices */
  13. #define ADB_KEYBOARD 2
  14. #define ADB_MOUSE 3
  15. #define ADB_TABLET 4
  16. #define ADB_MODEM 5
  17. #define ADB_MISC 7 /* maybe a monitor */
  18. #define ADB_RET_OK 0
  19. #define ADB_RET_TIMEOUT 3
  20. /* The kind of ADB request. The controller may emulate some
  21. or all of those CUDA/PMU packet kinds */
  22. #define ADB_PACKET 0
  23. #define CUDA_PACKET 1
  24. #define ERROR_PACKET 2
  25. #define TIMER_PACKET 3
  26. #define POWER_PACKET 4
  27. #define MACIIC_PACKET 5
  28. #define PMU_PACKET 6
  29. #define ADB_QUERY 7
  30. /* ADB queries */
  31. /* ADB_QUERY_GETDEVINFO
  32. * Query ADB slot for device presence
  33. * data[2] = id, rep[0] = orig addr, rep[1] = handler_id
  34. */
  35. #define ADB_QUERY_GETDEVINFO 1
  36. #ifdef __KERNEL__
  37. struct adb_request {
  38. unsigned char data[32];
  39. int nbytes;
  40. unsigned char reply[32];
  41. int reply_len;
  42. unsigned char reply_expected;
  43. unsigned char sent;
  44. unsigned char complete;
  45. void (*done)(struct adb_request *);
  46. void *arg;
  47. struct adb_request *next;
  48. };
  49. struct adb_ids {
  50. int nids;
  51. unsigned char id[16];
  52. };
  53. /* Structure which encapsulates a low-level ADB driver */
  54. struct adb_driver {
  55. char name[16];
  56. int (*probe)(void);
  57. int (*init)(void);
  58. int (*send_request)(struct adb_request *req, int sync);
  59. int (*autopoll)(int devs);
  60. void (*poll)(void);
  61. int (*reset_bus)(void);
  62. };
  63. /* Values for adb_request flags */
  64. #define ADBREQ_REPLY 1 /* expect reply */
  65. #define ADBREQ_SYNC 2 /* poll until done */
  66. #define ADBREQ_NOSEND 4 /* build the request, but don't send it */
  67. /* Messages sent thru the client_list notifier. You should NOT stop
  68. the operation, at least not with this version */
  69. enum adb_message {
  70. ADB_MSG_POWERDOWN, /* Currently called before sleep only */
  71. ADB_MSG_PRE_RESET, /* Called before resetting the bus */
  72. ADB_MSG_POST_RESET /* Called after resetting the bus (re-do init & register) */
  73. };
  74. extern struct adb_driver *adb_controller;
  75. extern struct blocking_notifier_head adb_client_list;
  76. int adb_request(struct adb_request *req, void (*done)(struct adb_request *),
  77. int flags, int nbytes, ...);
  78. int adb_register(int default_id,int handler_id,struct adb_ids *ids,
  79. void (*handler)(unsigned char *, int, int));
  80. int adb_unregister(int index);
  81. void adb_poll(void);
  82. void adb_input(unsigned char *, int, int);
  83. int adb_reset_bus(void);
  84. int adb_try_handler_change(int address, int new_id);
  85. int adb_get_infos(int address, int *original_address, int *handler_id);
  86. #endif /* __KERNEL__ */
  87. #endif /* __ADB_H */