]>
Commit | Line | Data |
---|---|---|
e3d280fc TI |
1 | /* |
2 | * HD-audio core stuff | |
3 | */ | |
4 | ||
5 | #ifndef __SOUND_HDAUDIO_H | |
6 | #define __SOUND_HDAUDIO_H | |
7 | ||
8 | #include <linux/device.h> | |
d068ebc2 TI |
9 | #include <sound/hda_verbs.h> |
10 | ||
11 | struct hdac_bus; | |
12 | struct hdac_device; | |
13 | struct hdac_driver; | |
e3d280fc TI |
14 | |
15 | /* | |
16 | * exported bus type | |
17 | */ | |
18 | extern struct bus_type snd_hda_bus_type; | |
19 | ||
20 | /* | |
21 | * HD-audio codec base device | |
22 | */ | |
23 | struct hdac_device { | |
24 | struct device dev; | |
25 | int type; | |
d068ebc2 TI |
26 | struct hdac_bus *bus; |
27 | unsigned int addr; /* codec address */ | |
28 | struct list_head list; /* list point for bus codec_list */ | |
e3d280fc TI |
29 | }; |
30 | ||
31 | /* device/driver type used for matching */ | |
32 | enum { | |
33 | HDA_DEV_CORE, | |
34 | HDA_DEV_LEGACY, | |
35 | }; | |
36 | ||
37 | #define dev_to_hdac_dev(_dev) container_of(_dev, struct hdac_device, dev) | |
38 | ||
39 | /* | |
40 | * HD-audio codec base driver | |
41 | */ | |
42 | struct hdac_driver { | |
43 | struct device_driver driver; | |
44 | int type; | |
45 | int (*match)(struct hdac_device *dev, struct hdac_driver *drv); | |
d068ebc2 | 46 | void (*unsol_event)(struct hdac_device *dev, unsigned int event); |
e3d280fc TI |
47 | }; |
48 | ||
49 | #define drv_to_hdac_driver(_drv) container_of(_drv, struct hdac_driver, driver) | |
50 | ||
d068ebc2 TI |
51 | /* |
52 | * HD-audio bus base driver | |
53 | */ | |
54 | struct hdac_bus_ops { | |
55 | /* send a single command */ | |
56 | int (*command)(struct hdac_bus *bus, unsigned int cmd); | |
57 | /* get a response from the last command */ | |
58 | int (*get_response)(struct hdac_bus *bus, unsigned int addr, | |
59 | unsigned int *res); | |
60 | }; | |
61 | ||
62 | #define HDA_UNSOL_QUEUE_SIZE 64 | |
63 | ||
64 | struct hdac_bus { | |
65 | struct device *dev; | |
66 | const struct hdac_bus_ops *ops; | |
67 | ||
68 | /* codec linked list */ | |
69 | struct list_head codec_list; | |
70 | unsigned int num_codecs; | |
71 | ||
72 | /* link caddr -> codec */ | |
73 | struct hdac_device *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1]; | |
74 | ||
75 | /* unsolicited event queue */ | |
76 | u32 unsol_queue[HDA_UNSOL_QUEUE_SIZE * 2]; /* ring buffer */ | |
77 | unsigned int unsol_rp, unsol_wp; | |
78 | struct work_struct unsol_work; | |
79 | ||
80 | /* bit flags of powered codecs */ | |
81 | unsigned long codec_powered; | |
82 | ||
83 | /* flags */ | |
84 | bool sync_write:1; /* sync after verb write */ | |
85 | ||
86 | /* locks */ | |
87 | struct mutex cmd_mutex; | |
88 | }; | |
89 | ||
90 | int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev, | |
91 | const struct hdac_bus_ops *ops); | |
92 | void snd_hdac_bus_exit(struct hdac_bus *bus); | |
93 | int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr, | |
94 | unsigned int cmd, unsigned int *res); | |
95 | int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr, | |
96 | unsigned int cmd, unsigned int *res); | |
97 | void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex); | |
98 | ||
99 | int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec); | |
100 | void snd_hdac_bus_remove_device(struct hdac_bus *bus, | |
101 | struct hdac_device *codec); | |
102 | ||
e3d280fc | 103 | #endif /* __SOUND_HDAUDIO_H */ |