]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/sound/hdaudio.h
ALSA: hda - Move some codes up to hdac_bus struct
[mirror_ubuntu-bionic-kernel.git] / include / sound / hdaudio.h
CommitLineData
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
11struct hdac_bus;
12struct hdac_device;
13struct hdac_driver;
e3d280fc
TI
14
15/*
16 * exported bus type
17 */
18extern struct bus_type snd_hda_bus_type;
19
20/*
21 * HD-audio codec base device
22 */
23struct 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 */
32enum {
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 */
42struct 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 */
54struct 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
64struct 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
90int snd_hdac_bus_init(struct hdac_bus *bus, struct device *dev,
91 const struct hdac_bus_ops *ops);
92void snd_hdac_bus_exit(struct hdac_bus *bus);
93int snd_hdac_bus_exec_verb(struct hdac_bus *bus, unsigned int addr,
94 unsigned int cmd, unsigned int *res);
95int snd_hdac_bus_exec_verb_unlocked(struct hdac_bus *bus, unsigned int addr,
96 unsigned int cmd, unsigned int *res);
97void snd_hdac_bus_queue_event(struct hdac_bus *bus, u32 res, u32 res_ex);
98
99int snd_hdac_bus_add_device(struct hdac_bus *bus, struct hdac_device *codec);
100void snd_hdac_bus_remove_device(struct hdac_bus *bus,
101 struct hdac_device *codec);
102
e3d280fc 103#endif /* __SOUND_HDAUDIO_H */