Linux Audio

Check our new training course

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