]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/suse-2.6.27.39/patches.drivers/alsa-post-ga-hda-codec-bus-intapi-change
Imported linux-2.6.27.39 suse/xen patches.
[ipfire-2.x.git] / src / patches / suse-2.6.27.39 / patches.drivers / alsa-post-ga-hda-codec-bus-intapi-change
CommitLineData
2cb7cef9
BS
1From: Takashi Iwai <tiwai@suse.de>
2Subject: ALSA: hda - simplify hda_bus ops callbacks
3Patch-mainline: 2.6.29-rc1
4References:
5
6The hda_bus ops callback take struct hda_bus pointer.
7Also, the command callback takes the composed command word, instead of
8each small bits in arguments.
9
10Signed-off-by: Takashi Iwai <tiwai@suse.de>
11
12---
13 sound/pci/hda/hda_codec.c | 59 +++++++++++++++++++++++++++++++++++-----------
14 sound/pci/hda/hda_codec.h | 7 ++---
15 sound/pci/hda/hda_intel.c | 55 +++++++++++++++++-------------------------
16 3 files changed, 71 insertions(+), 50 deletions(-)
17
18--- a/sound/pci/hda/hda_codec.c
19+++ b/sound/pci/hda/hda_codec.c
20@@ -107,6 +107,23 @@
21 static inline void hda_keep_power_on(struct hda_codec *codec) {}
22 #endif
23
24+/*
25+ * Compose a 32bit command word to be sent to the HD-audio controller
26+ */
27+static inline unsigned int
28+make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
29+ unsigned int verb, unsigned int parm)
30+{
31+ u32 val;
32+
33+ val = (u32)(codec->addr & 0x0f) << 28;
34+ val |= (u32)direct << 27;
35+ val |= (u32)nid << 20;
36+ val |= verb << 8;
37+ val |= parm;
38+ return val;
39+}
40+
41 /**
42 * snd_hda_codec_read - send a command and get the response
43 * @codec: the HDA codec
44@@ -123,14 +140,17 @@
45 int direct,
46 unsigned int verb, unsigned int parm)
47 {
48+ struct hda_bus *bus = codec->bus;
49 unsigned int res;
50+
51+ res = make_codec_cmd(codec, nid, direct, verb, parm);
52 snd_hda_power_up(codec);
53- mutex_lock(&codec->bus->cmd_mutex);
54- if (!codec->bus->ops.command(codec, nid, direct, verb, parm))
55- res = codec->bus->ops.get_response(codec);
56+ mutex_lock(&bus->cmd_mutex);
57+ if (!bus->ops.command(bus, res))
58+ res = bus->ops.get_response(bus);
59 else
60 res = (unsigned int)-1;
61- mutex_unlock(&codec->bus->cmd_mutex);
62+ mutex_unlock(&bus->cmd_mutex);
63 snd_hda_power_down(codec);
64 return res;
65 }
66@@ -150,11 +170,15 @@
67 int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
68 unsigned int verb, unsigned int parm)
69 {
70+ struct hda_bus *bus = codec->bus;
71+ unsigned int res;
72 int err;
73+
74+ res = make_codec_cmd(codec, nid, direct, verb, parm);
75 snd_hda_power_up(codec);
76- mutex_lock(&codec->bus->cmd_mutex);
77- err = codec->bus->ops.command(codec, nid, direct, verb, parm);
78- mutex_unlock(&codec->bus->cmd_mutex);
79+ mutex_lock(&bus->cmd_mutex);
80+ err = bus->ops.command(bus, res);
81+ mutex_unlock(&bus->cmd_mutex);
82 snd_hda_power_down(codec);
83 return err;
84 }
85@@ -1796,10 +1820,14 @@
86 int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
87 int direct, unsigned int verb, unsigned int parm)
88 {
89+ struct hda_bus *bus = codec->bus;
90+ unsigned int res;
91 int err;
92+
93+ res = make_codec_cmd(codec, nid, direct, verb, parm);
94 snd_hda_power_up(codec);
95- mutex_lock(&codec->bus->cmd_mutex);
96- err = codec->bus->ops.command(codec, nid, direct, verb, parm);
97+ mutex_lock(&bus->cmd_mutex);
98+ err = bus->ops.command(bus, res);
99 if (!err) {
100 struct hda_cache_head *c;
101 u32 key = build_cmd_cache_key(nid, verb);
102@@ -1807,7 +1835,7 @@
103 if (c)
104 c->val = parm;
105 }
106- mutex_unlock(&codec->bus->cmd_mutex);
107+ mutex_unlock(&bus->cmd_mutex);
108 snd_hda_power_down(codec);
109 return err;
110 }
111@@ -2507,6 +2535,7 @@
112 {
113 struct hda_codec *codec =
114 container_of(work, struct hda_codec, power_work.work);
115+ struct hda_bus *bus = codec->bus;
116
117 if (!codec->power_on || codec->power_count) {
118 codec->power_transition = 0;
119@@ -2514,8 +2543,8 @@
120 }
121
122 hda_call_codec_suspend(codec);
123- if (codec->bus->ops.pm_notify)
124- codec->bus->ops.pm_notify(codec);
125+ if (bus->ops.pm_notify)
126+ bus->ops.pm_notify(bus);
127 }
128
129 static void hda_keep_power_on(struct hda_codec *codec)
130@@ -2526,13 +2555,15 @@
131
132 void snd_hda_power_up(struct hda_codec *codec)
133 {
134+ struct hda_bus *bus = codec->bus;
135+
136 codec->power_count++;
137 if (codec->power_on || codec->power_transition)
138 return;
139
140 codec->power_on = 1;
141- if (codec->bus->ops.pm_notify)
142- codec->bus->ops.pm_notify(codec);
143+ if (bus->ops.pm_notify)
144+ bus->ops.pm_notify(bus);
145 hda_call_codec_resume(codec);
146 cancel_delayed_work(&codec->power_work);
147 codec->power_transition = 0;
148--- a/sound/pci/hda/hda_codec.h
149+++ b/sound/pci/hda/hda_codec.h
150@@ -536,15 +536,14 @@
151 /* bus operators */
152 struct hda_bus_ops {
153 /* send a single command */
154- int (*command)(struct hda_codec *codec, hda_nid_t nid, int direct,
155- unsigned int verb, unsigned int parm);
156+ int (*command)(struct hda_bus *bus, unsigned int cmd);
157 /* get a response from the last command */
158- unsigned int (*get_response)(struct hda_codec *codec);
159+ unsigned int (*get_response)(struct hda_bus *bus);
160 /* free the private data */
161 void (*private_free)(struct hda_bus *);
162 #ifdef CONFIG_SND_HDA_POWER_SAVE
163 /* notify power-up/down from codec to controller */
164- void (*pm_notify)(struct hda_codec *codec);
165+ void (*pm_notify)(struct hda_bus *bus);
166 #endif
167 };
168
169--- a/sound/pci/hda/hda_intel.c
170+++ b/sound/pci/hda/hda_intel.c
171@@ -527,9 +527,9 @@
172 }
173
174 /* send a command */
175-static int azx_corb_send_cmd(struct hda_codec *codec, u32 val)
176+static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
177 {
178- struct azx *chip = codec->bus->private_data;
179+ struct azx *chip = bus->private_data;
180 unsigned int wp;
181
182 /* add command to corb */
183@@ -577,9 +577,9 @@
184 }
185
186 /* receive a response */
187-static unsigned int azx_rirb_get_response(struct hda_codec *codec)
188+static unsigned int azx_rirb_get_response(struct hda_bus *bus)
189 {
190- struct azx *chip = codec->bus->private_data;
191+ struct azx *chip = bus->private_data;
192 unsigned long timeout;
193
194 again:
195@@ -596,7 +596,7 @@
196 }
197 if (time_after(jiffies, timeout))
198 break;
199- if (codec->bus->needs_damn_long_delay)
200+ if (bus->needs_damn_long_delay)
201 msleep(2); /* temporary workaround */
202 else {
203 udelay(10);
204@@ -646,9 +646,9 @@
205 */
206
207 /* send a command */
208-static int azx_single_send_cmd(struct hda_codec *codec, u32 val)
209+static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
210 {
211- struct azx *chip = codec->bus->private_data;
212+ struct azx *chip = bus->private_data;
213 int timeout = 50;
214
215 while (timeout--) {
216@@ -671,9 +671,9 @@
217 }
218
219 /* receive a response */
220-static unsigned int azx_single_get_response(struct hda_codec *codec)
221+static unsigned int azx_single_get_response(struct hda_bus *bus)
222 {
223- struct azx *chip = codec->bus->private_data;
224+ struct azx *chip = bus->private_data;
225 int timeout = 50;
226
227 while (timeout--) {
228@@ -696,38 +696,29 @@
229 */
230
231 /* send a command */
232-static int azx_send_cmd(struct hda_codec *codec, hda_nid_t nid,
233- int direct, unsigned int verb,
234- unsigned int para)
235-{
236- struct azx *chip = codec->bus->private_data;
237- u32 val;
238-
239- val = (u32)(codec->addr & 0x0f) << 28;
240- val |= (u32)direct << 27;
241- val |= (u32)nid << 20;
242- val |= verb << 8;
243- val |= para;
244- chip->last_cmd = val;
245+static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
246+{
247+ struct azx *chip = bus->private_data;
248
249+ chip->last_cmd = val;
250 if (chip->single_cmd)
251- return azx_single_send_cmd(codec, val);
252+ return azx_single_send_cmd(bus, val);
253 else
254- return azx_corb_send_cmd(codec, val);
255+ return azx_corb_send_cmd(bus, val);
256 }
257
258 /* get a response */
259-static unsigned int azx_get_response(struct hda_codec *codec)
260+static unsigned int azx_get_response(struct hda_bus *bus)
261 {
262- struct azx *chip = codec->bus->private_data;
263+ struct azx *chip = bus->private_data;
264 if (chip->single_cmd)
265- return azx_single_get_response(codec);
266+ return azx_single_get_response(bus);
267 else
268- return azx_rirb_get_response(codec);
269+ return azx_rirb_get_response(bus);
270 }
271
272 #ifdef CONFIG_SND_HDA_POWER_SAVE
273-static void azx_power_notify(struct hda_codec *codec);
274+static void azx_power_notify(struct hda_bus *bus);
275 #endif
276
277 /* reset codec link */
278@@ -1905,13 +1896,13 @@
279
280 #ifdef CONFIG_SND_HDA_POWER_SAVE
281 /* power-up/down the controller */
282-static void azx_power_notify(struct hda_codec *codec)
283+static void azx_power_notify(struct hda_bus *bus)
284 {
285- struct azx *chip = codec->bus->private_data;
286+ struct azx *chip = bus->private_data;
287 struct hda_codec *c;
288 int power_on = 0;
289
290- list_for_each_entry(c, &codec->bus->codec_list, list) {
291+ list_for_each_entry(c, &bus->codec_list, list) {
292 if (c->power_on) {
293 power_on = 1;
294 break;