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