aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2014-11-28 10:59:25 -0500
committerTakashi Iwai <tiwai@suse.de>2014-11-29 14:21:15 -0500
commit8832c5a74ba3506c51b6637ac78941fcd21afbef (patch)
tree3af204ffff0dbb32e2b950099c2ed582fde5f1aa
parent60cea522963fc0b3893d78e568666d105f117ff9 (diff)
ALSA: speakers: Rename to oxfw and rename some members
This commit renames 'firewire-speakers' to 'oxfw' to enhance support for devices which based on OXFW970/971. A line for MODULE_ALIAS is added. Additionally, to help for works in followed paches, some members in private structure are renamed. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/Kconfig12
-rw-r--r--sound/firewire/Makefile4
-rw-r--r--sound/firewire/oxfw.c (renamed from sound/firewire/speakers.c)341
3 files changed, 180 insertions, 177 deletions
diff --git a/sound/firewire/Kconfig b/sound/firewire/Kconfig
index a433149f0675..2a5b9a6cb6f8 100644
--- a/sound/firewire/Kconfig
+++ b/sound/firewire/Kconfig
@@ -26,15 +26,17 @@ config SND_DICE
26 To compile this driver as a module, choose M here: the module 26 To compile this driver as a module, choose M here: the module
27 will be called snd-dice. 27 will be called snd-dice.
28 28
29config SND_FIREWIRE_SPEAKERS 29config SND_OXFW
30 tristate "FireWire speakers" 30 tristate "Oxford Semiconductor FW970/971 chipset support"
31 select SND_FIREWIRE_LIB 31 select SND_FIREWIRE_LIB
32 help 32 help
33 Say Y here to include support for the Griffin FireWave Surround 33 Say Y here to include support for FireWire devices based on
34 and the LaCie FireWire Speakers. 34 Oxford Semiconductor FW970/971 chipset.
35 * Griffin Firewave
36 * LaCie Firewire Speakers
35 37
36 To compile this driver as a module, choose M here: the module 38 To compile this driver as a module, choose M here: the module
37 will be called snd-firewire-speakers. 39 will be called snd-oxfw.
38 40
39config SND_ISIGHT 41config SND_ISIGHT
40 tristate "Apple iSight microphone" 42 tristate "Apple iSight microphone"
diff --git a/sound/firewire/Makefile b/sound/firewire/Makefile
index c50761ccd66a..5ed6fb7bc979 100644
--- a/sound/firewire/Makefile
+++ b/sound/firewire/Makefile
@@ -1,12 +1,12 @@
1snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \ 1snd-firewire-lib-objs := lib.o iso-resources.o packets-buffer.o \
2 fcp.o cmp.o amdtp.o 2 fcp.o cmp.o amdtp.o
3snd-firewire-speakers-objs := speakers.o 3snd-oxfw-objs := oxfw.o
4snd-isight-objs := isight.o 4snd-isight-objs := isight.o
5snd-scs1x-objs := scs1x.o 5snd-scs1x-objs := scs1x.o
6 6
7obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o 7obj-$(CONFIG_SND_FIREWIRE_LIB) += snd-firewire-lib.o
8obj-$(CONFIG_SND_DICE) += dice/ 8obj-$(CONFIG_SND_DICE) += dice/
9obj-$(CONFIG_SND_FIREWIRE_SPEAKERS) += snd-firewire-speakers.o 9obj-$(CONFIG_SND_OXFW) += snd-oxfw.o
10obj-$(CONFIG_SND_ISIGHT) += snd-isight.o 10obj-$(CONFIG_SND_ISIGHT) += snd-isight.o
11obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o 11obj-$(CONFIG_SND_SCS1X) += snd-scs1x.o
12obj-$(CONFIG_SND_FIREWORKS) += fireworks/ 12obj-$(CONFIG_SND_FIREWORKS) += fireworks/
diff --git a/sound/firewire/speakers.c b/sound/firewire/oxfw.c
index 768d40ddfebb..b7498e9420d8 100644
--- a/sound/firewire/speakers.c
+++ b/sound/firewire/oxfw.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * OXFW970-based speakers driver 2 * oxfw.c - a part of driver for OXFW970/971 based devices
3 * 3 *
4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de> 4 * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
5 * Licensed under the terms of the GNU General Public License, version 2. 5 * Licensed under the terms of the GNU General Public License, version 2.
@@ -45,22 +45,23 @@ struct device_info {
45 u8 volume_fb_id; 45 u8 volume_fb_id;
46}; 46};
47 47
48struct fwspk { 48struct snd_oxfw {
49 struct snd_card *card; 49 struct snd_card *card;
50 struct fw_unit *unit; 50 struct fw_unit *unit;
51 const struct device_info *device_info; 51 const struct device_info *device_info;
52 struct mutex mutex; 52 struct mutex mutex;
53 struct cmp_connection connection; 53 struct cmp_connection in_conn;
54 struct amdtp_stream stream; 54 struct amdtp_stream rx_stream;
55 bool mute; 55 bool mute;
56 s16 volume[6]; 56 s16 volume[6];
57 s16 volume_min; 57 s16 volume_min;
58 s16 volume_max; 58 s16 volume_max;
59}; 59};
60 60
61MODULE_DESCRIPTION("FireWire speakers driver"); 61MODULE_DESCRIPTION("Oxford Semiconductor FW970/971 driver");
62MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>"); 62MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
63MODULE_LICENSE("GPL v2"); 63MODULE_LICENSE("GPL v2");
64MODULE_ALIAS("snd-firewire-speakers");
64 65
65static int firewave_rate_constraint(struct snd_pcm_hw_params *params, 66static int firewave_rate_constraint(struct snd_pcm_hw_params *params,
66 struct snd_pcm_hw_rule *rule) 67 struct snd_pcm_hw_rule *rule)
@@ -137,7 +138,7 @@ static int lacie_speakers_constraints(struct snd_pcm_runtime *runtime)
137 return 0; 138 return 0;
138} 139}
139 140
140static int fwspk_open(struct snd_pcm_substream *substream) 141static int oxfw_open(struct snd_pcm_substream *substream)
141{ 142{
142 static const struct snd_pcm_hardware hardware = { 143 static const struct snd_pcm_hardware hardware = {
143 .info = SNDRV_PCM_INFO_MMAP | 144 .info = SNDRV_PCM_INFO_MMAP |
@@ -154,66 +155,66 @@ static int fwspk_open(struct snd_pcm_substream *substream)
154 .periods_min = 1, 155 .periods_min = 1,
155 .periods_max = UINT_MAX, 156 .periods_max = UINT_MAX,
156 }; 157 };
157 struct fwspk *fwspk = substream->private_data; 158 struct snd_oxfw *oxfw = substream->private_data;
158 struct snd_pcm_runtime *runtime = substream->runtime; 159 struct snd_pcm_runtime *runtime = substream->runtime;
159 int err; 160 int err;
160 161
161 runtime->hw = hardware; 162 runtime->hw = hardware;
162 163
163 err = fwspk->device_info->pcm_constraints(runtime); 164 err = oxfw->device_info->pcm_constraints(runtime);
164 if (err < 0) 165 if (err < 0)
165 return err; 166 return err;
166 err = snd_pcm_limit_hw_rates(runtime); 167 err = snd_pcm_limit_hw_rates(runtime);
167 if (err < 0) 168 if (err < 0)
168 return err; 169 return err;
169 170
170 err = amdtp_stream_add_pcm_hw_constraints(&fwspk->stream, runtime); 171 err = amdtp_stream_add_pcm_hw_constraints(&oxfw->rx_stream, runtime);
171 if (err < 0) 172 if (err < 0)
172 return err; 173 return err;
173 174
174 return 0; 175 return 0;
175} 176}
176 177
177static int fwspk_close(struct snd_pcm_substream *substream) 178static int oxfw_close(struct snd_pcm_substream *substream)
178{ 179{
179 return 0; 180 return 0;
180} 181}
181 182
182static void fwspk_stop_stream(struct fwspk *fwspk) 183static void oxfw_stop_stream(struct snd_oxfw *oxfw)
183{ 184{
184 if (amdtp_stream_running(&fwspk->stream)) { 185 if (amdtp_stream_running(&oxfw->rx_stream)) {
185 amdtp_stream_stop(&fwspk->stream); 186 amdtp_stream_stop(&oxfw->rx_stream);
186 cmp_connection_break(&fwspk->connection); 187 cmp_connection_break(&oxfw->in_conn);
187 } 188 }
188} 189}
189 190
190static int fwspk_hw_params(struct snd_pcm_substream *substream, 191static int oxfw_hw_params(struct snd_pcm_substream *substream,
191 struct snd_pcm_hw_params *hw_params) 192 struct snd_pcm_hw_params *hw_params)
192{ 193{
193 struct fwspk *fwspk = substream->private_data; 194 struct snd_oxfw *oxfw = substream->private_data;
194 int err; 195 int err;
195 196
196 mutex_lock(&fwspk->mutex); 197 mutex_lock(&oxfw->mutex);
197 fwspk_stop_stream(fwspk); 198 oxfw_stop_stream(oxfw);
198 mutex_unlock(&fwspk->mutex); 199 mutex_unlock(&oxfw->mutex);
199 200
200 err = snd_pcm_lib_alloc_vmalloc_buffer(substream, 201 err = snd_pcm_lib_alloc_vmalloc_buffer(substream,
201 params_buffer_bytes(hw_params)); 202 params_buffer_bytes(hw_params));
202 if (err < 0) 203 if (err < 0)
203 goto error; 204 goto error;
204 205
205 amdtp_stream_set_parameters(&fwspk->stream, 206 amdtp_stream_set_parameters(&oxfw->rx_stream,
206 params_rate(hw_params), 207 params_rate(hw_params),
207 params_channels(hw_params), 208 params_channels(hw_params),
208 0); 209 0);
209 210
210 amdtp_stream_set_pcm_format(&fwspk->stream, 211 amdtp_stream_set_pcm_format(&oxfw->rx_stream,
211 params_format(hw_params)); 212 params_format(hw_params));
212 213
213 err = avc_general_set_sig_fmt(fwspk->unit, params_rate(hw_params), 214 err = avc_general_set_sig_fmt(oxfw->unit, params_rate(hw_params),
214 AVC_GENERAL_PLUG_DIR_IN, 0); 215 AVC_GENERAL_PLUG_DIR_IN, 0);
215 if (err < 0) { 216 if (err < 0) {
216 dev_err(&fwspk->unit->device, "failed to set sample rate\n"); 217 dev_err(&oxfw->unit->device, "failed to set sample rate\n");
217 goto err_buffer; 218 goto err_buffer;
218 } 219 }
219 220
@@ -225,57 +226,57 @@ error:
225 return err; 226 return err;
226} 227}
227 228
228static int fwspk_hw_free(struct snd_pcm_substream *substream) 229static int oxfw_hw_free(struct snd_pcm_substream *substream)
229{ 230{
230 struct fwspk *fwspk = substream->private_data; 231 struct snd_oxfw *oxfw = substream->private_data;
231 232
232 mutex_lock(&fwspk->mutex); 233 mutex_lock(&oxfw->mutex);
233 fwspk_stop_stream(fwspk); 234 oxfw_stop_stream(oxfw);
234 mutex_unlock(&fwspk->mutex); 235 mutex_unlock(&oxfw->mutex);
235 236
236 return snd_pcm_lib_free_vmalloc_buffer(substream); 237 return snd_pcm_lib_free_vmalloc_buffer(substream);
237} 238}
238 239
239static int fwspk_prepare(struct snd_pcm_substream *substream) 240static int oxfw_prepare(struct snd_pcm_substream *substream)
240{ 241{
241 struct fwspk *fwspk = substream->private_data; 242 struct snd_oxfw *oxfw = substream->private_data;
242 int err; 243 int err;
243 244
244 mutex_lock(&fwspk->mutex); 245 mutex_lock(&oxfw->mutex);
245 246
246 if (amdtp_streaming_error(&fwspk->stream)) 247 if (amdtp_streaming_error(&oxfw->rx_stream))
247 fwspk_stop_stream(fwspk); 248 oxfw_stop_stream(oxfw);
248 249
249 if (!amdtp_stream_running(&fwspk->stream)) { 250 if (!amdtp_stream_running(&oxfw->rx_stream)) {
250 err = cmp_connection_establish(&fwspk->connection, 251 err = cmp_connection_establish(&oxfw->in_conn,
251 amdtp_stream_get_max_payload(&fwspk->stream)); 252 amdtp_stream_get_max_payload(&oxfw->rx_stream));
252 if (err < 0) 253 if (err < 0)
253 goto err_mutex; 254 goto err_mutex;
254 255
255 err = amdtp_stream_start(&fwspk->stream, 256 err = amdtp_stream_start(&oxfw->rx_stream,
256 fwspk->connection.resources.channel, 257 oxfw->in_conn.resources.channel,
257 fwspk->connection.speed); 258 oxfw->in_conn.speed);
258 if (err < 0) 259 if (err < 0)
259 goto err_connection; 260 goto err_connection;
260 } 261 }
261 262
262 mutex_unlock(&fwspk->mutex); 263 mutex_unlock(&oxfw->mutex);
263 264
264 amdtp_stream_pcm_prepare(&fwspk->stream); 265 amdtp_stream_pcm_prepare(&oxfw->rx_stream);
265 266
266 return 0; 267 return 0;
267 268
268err_connection: 269err_connection:
269 cmp_connection_break(&fwspk->connection); 270 cmp_connection_break(&oxfw->in_conn);
270err_mutex: 271err_mutex:
271 mutex_unlock(&fwspk->mutex); 272 mutex_unlock(&oxfw->mutex);
272 273
273 return err; 274 return err;
274} 275}
275 276
276static int fwspk_trigger(struct snd_pcm_substream *substream, int cmd) 277static int oxfw_trigger(struct snd_pcm_substream *substream, int cmd)
277{ 278{
278 struct fwspk *fwspk = substream->private_data; 279 struct snd_oxfw *oxfw = substream->private_data;
279 struct snd_pcm_substream *pcm; 280 struct snd_pcm_substream *pcm;
280 281
281 switch (cmd) { 282 switch (cmd) {
@@ -288,39 +289,39 @@ static int fwspk_trigger(struct snd_pcm_substream *substream, int cmd)
288 default: 289 default:
289 return -EINVAL; 290 return -EINVAL;
290 } 291 }
291 amdtp_stream_pcm_trigger(&fwspk->stream, pcm); 292 amdtp_stream_pcm_trigger(&oxfw->rx_stream, pcm);
292 return 0; 293 return 0;
293} 294}
294 295
295static snd_pcm_uframes_t fwspk_pointer(struct snd_pcm_substream *substream) 296static snd_pcm_uframes_t oxfw_pointer(struct snd_pcm_substream *substream)
296{ 297{
297 struct fwspk *fwspk = substream->private_data; 298 struct snd_oxfw *oxfw = substream->private_data;
298 299
299 return amdtp_stream_pcm_pointer(&fwspk->stream); 300 return amdtp_stream_pcm_pointer(&oxfw->rx_stream);
300} 301}
301 302
302static int fwspk_create_pcm(struct fwspk *fwspk) 303static int oxfw_create_pcm(struct snd_oxfw *oxfw)
303{ 304{
304 static struct snd_pcm_ops ops = { 305 static struct snd_pcm_ops ops = {
305 .open = fwspk_open, 306 .open = oxfw_open,
306 .close = fwspk_close, 307 .close = oxfw_close,
307 .ioctl = snd_pcm_lib_ioctl, 308 .ioctl = snd_pcm_lib_ioctl,
308 .hw_params = fwspk_hw_params, 309 .hw_params = oxfw_hw_params,
309 .hw_free = fwspk_hw_free, 310 .hw_free = oxfw_hw_free,
310 .prepare = fwspk_prepare, 311 .prepare = oxfw_prepare,
311 .trigger = fwspk_trigger, 312 .trigger = oxfw_trigger,
312 .pointer = fwspk_pointer, 313 .pointer = oxfw_pointer,
313 .page = snd_pcm_lib_get_vmalloc_page, 314 .page = snd_pcm_lib_get_vmalloc_page,
314 .mmap = snd_pcm_lib_mmap_vmalloc, 315 .mmap = snd_pcm_lib_mmap_vmalloc,
315 }; 316 };
316 struct snd_pcm *pcm; 317 struct snd_pcm *pcm;
317 int err; 318 int err;
318 319
319 err = snd_pcm_new(fwspk->card, "OXFW970", 0, 1, 0, &pcm); 320 err = snd_pcm_new(oxfw->card, "OXFW", 0, 1, 0, &pcm);
320 if (err < 0) 321 if (err < 0)
321 return err; 322 return err;
322 pcm->private_data = fwspk; 323 pcm->private_data = oxfw;
323 strcpy(pcm->name, fwspk->device_info->short_name); 324 strcpy(pcm->name, oxfw->device_info->short_name);
324 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &ops); 325 snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &ops);
325 return 0; 326 return 0;
326} 327}
@@ -332,7 +333,7 @@ enum control_attribute {
332 CTL_CURRENT = 0x10, 333 CTL_CURRENT = 0x10,
333}; 334};
334 335
335static int fwspk_mute_command(struct fwspk *fwspk, bool *value, 336static int oxfw_mute_command(struct snd_oxfw *oxfw, bool *value,
336 enum control_action action) 337 enum control_action action)
337{ 338{
338 u8 *buf; 339 u8 *buf;
@@ -353,7 +354,7 @@ static int fwspk_mute_command(struct fwspk *fwspk, bool *value,
353 buf[1] = 0x08; /* audio unit 0 */ 354 buf[1] = 0x08; /* audio unit 0 */
354 buf[2] = 0xb8; /* FUNCTION BLOCK */ 355 buf[2] = 0xb8; /* FUNCTION BLOCK */
355 buf[3] = 0x81; /* function block type: feature */ 356 buf[3] = 0x81; /* function block type: feature */
356 buf[4] = fwspk->device_info->mute_fb_id; /* function block ID */ 357 buf[4] = oxfw->device_info->mute_fb_id; /* function block ID */
357 buf[5] = 0x10; /* control attribute: current */ 358 buf[5] = 0x10; /* control attribute: current */
358 buf[6] = 0x02; /* selector length */ 359 buf[6] = 0x02; /* selector length */
359 buf[7] = 0x00; /* audio channel number */ 360 buf[7] = 0x00; /* audio channel number */
@@ -364,16 +365,16 @@ static int fwspk_mute_command(struct fwspk *fwspk, bool *value,
364 else 365 else
365 buf[10] = *value ? 0x70 : 0x60; 366 buf[10] = *value ? 0x70 : 0x60;
366 367
367 err = fcp_avc_transaction(fwspk->unit, buf, 11, buf, 11, 0x3fe); 368 err = fcp_avc_transaction(oxfw->unit, buf, 11, buf, 11, 0x3fe);
368 if (err < 0) 369 if (err < 0)
369 goto error; 370 goto error;
370 if (err < 11) { 371 if (err < 11) {
371 dev_err(&fwspk->unit->device, "short FCP response\n"); 372 dev_err(&oxfw->unit->device, "short FCP response\n");
372 err = -EIO; 373 err = -EIO;
373 goto error; 374 goto error;
374 } 375 }
375 if (buf[0] != response_ok) { 376 if (buf[0] != response_ok) {
376 dev_err(&fwspk->unit->device, "mute command failed\n"); 377 dev_err(&oxfw->unit->device, "mute command failed\n");
377 err = -EIO; 378 err = -EIO;
378 goto error; 379 goto error;
379 } 380 }
@@ -388,7 +389,7 @@ error:
388 return err; 389 return err;
389} 390}
390 391
391static int fwspk_volume_command(struct fwspk *fwspk, s16 *value, 392static int oxfw_volume_command(struct snd_oxfw *oxfw, s16 *value,
392 unsigned int channel, 393 unsigned int channel,
393 enum control_attribute attribute, 394 enum control_attribute attribute,
394 enum control_action action) 395 enum control_action action)
@@ -411,7 +412,7 @@ static int fwspk_volume_command(struct fwspk *fwspk, s16 *value,
411 buf[1] = 0x08; /* audio unit 0 */ 412 buf[1] = 0x08; /* audio unit 0 */
412 buf[2] = 0xb8; /* FUNCTION BLOCK */ 413 buf[2] = 0xb8; /* FUNCTION BLOCK */
413 buf[3] = 0x81; /* function block type: feature */ 414 buf[3] = 0x81; /* function block type: feature */
414 buf[4] = fwspk->device_info->volume_fb_id; /* function block ID */ 415 buf[4] = oxfw->device_info->volume_fb_id; /* function block ID */
415 buf[5] = attribute; /* control attribute */ 416 buf[5] = attribute; /* control attribute */
416 buf[6] = 0x02; /* selector length */ 417 buf[6] = 0x02; /* selector length */
417 buf[7] = channel; /* audio channel number */ 418 buf[7] = channel; /* audio channel number */
@@ -425,16 +426,16 @@ static int fwspk_volume_command(struct fwspk *fwspk, s16 *value,
425 buf[11] = *value; 426 buf[11] = *value;
426 } 427 }
427 428
428 err = fcp_avc_transaction(fwspk->unit, buf, 12, buf, 12, 0x3fe); 429 err = fcp_avc_transaction(oxfw->unit, buf, 12, buf, 12, 0x3fe);
429 if (err < 0) 430 if (err < 0)
430 goto error; 431 goto error;
431 if (err < 12) { 432 if (err < 12) {
432 dev_err(&fwspk->unit->device, "short FCP response\n"); 433 dev_err(&oxfw->unit->device, "short FCP response\n");
433 err = -EIO; 434 err = -EIO;
434 goto error; 435 goto error;
435 } 436 }
436 if (buf[0] != response_ok) { 437 if (buf[0] != response_ok) {
437 dev_err(&fwspk->unit->device, "volume command failed\n"); 438 dev_err(&oxfw->unit->device, "volume command failed\n");
438 err = -EIO; 439 err = -EIO;
439 goto error; 440 goto error;
440 } 441 }
@@ -449,75 +450,75 @@ error:
449 return err; 450 return err;
450} 451}
451 452
452static int fwspk_mute_get(struct snd_kcontrol *control, 453static int oxfw_mute_get(struct snd_kcontrol *control,
453 struct snd_ctl_elem_value *value) 454 struct snd_ctl_elem_value *value)
454{ 455{
455 struct fwspk *fwspk = control->private_data; 456 struct snd_oxfw *oxfw = control->private_data;
456 457
457 value->value.integer.value[0] = !fwspk->mute; 458 value->value.integer.value[0] = !oxfw->mute;
458 459
459 return 0; 460 return 0;
460} 461}
461 462
462static int fwspk_mute_put(struct snd_kcontrol *control, 463static int oxfw_mute_put(struct snd_kcontrol *control,
463 struct snd_ctl_elem_value *value) 464 struct snd_ctl_elem_value *value)
464{ 465{
465 struct fwspk *fwspk = control->private_data; 466 struct snd_oxfw *oxfw = control->private_data;
466 bool mute; 467 bool mute;
467 int err; 468 int err;
468 469
469 mute = !value->value.integer.value[0]; 470 mute = !value->value.integer.value[0];
470 471
471 if (mute == fwspk->mute) 472 if (mute == oxfw->mute)
472 return 0; 473 return 0;
473 474
474 err = fwspk_mute_command(fwspk, &mute, CTL_WRITE); 475 err = oxfw_mute_command(oxfw, &mute, CTL_WRITE);
475 if (err < 0) 476 if (err < 0)
476 return err; 477 return err;
477 fwspk->mute = mute; 478 oxfw->mute = mute;
478 479
479 return 1; 480 return 1;
480} 481}
481 482
482static int fwspk_volume_info(struct snd_kcontrol *control, 483static int oxfw_volume_info(struct snd_kcontrol *control,
483 struct snd_ctl_elem_info *info) 484 struct snd_ctl_elem_info *info)
484{ 485{
485 struct fwspk *fwspk = control->private_data; 486 struct snd_oxfw *oxfw = control->private_data;
486 487
487 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; 488 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
488 info->count = fwspk->device_info->mixer_channels; 489 info->count = oxfw->device_info->mixer_channels;
489 info->value.integer.min = fwspk->volume_min; 490 info->value.integer.min = oxfw->volume_min;
490 info->value.integer.max = fwspk->volume_max; 491 info->value.integer.max = oxfw->volume_max;
491 492
492 return 0; 493 return 0;
493} 494}
494 495
495static const u8 channel_map[6] = { 0, 1, 4, 5, 2, 3 }; 496static const u8 channel_map[6] = { 0, 1, 4, 5, 2, 3 };
496 497
497static int fwspk_volume_get(struct snd_kcontrol *control, 498static int oxfw_volume_get(struct snd_kcontrol *control,
498 struct snd_ctl_elem_value *value) 499 struct snd_ctl_elem_value *value)
499{ 500{
500 struct fwspk *fwspk = control->private_data; 501 struct snd_oxfw *oxfw = control->private_data;
501 unsigned int i; 502 unsigned int i;
502 503
503 for (i = 0; i < fwspk->device_info->mixer_channels; ++i) 504 for (i = 0; i < oxfw->device_info->mixer_channels; ++i)
504 value->value.integer.value[channel_map[i]] = fwspk->volume[i]; 505 value->value.integer.value[channel_map[i]] = oxfw->volume[i];
505 506
506 return 0; 507 return 0;
507} 508}
508 509
509static int fwspk_volume_put(struct snd_kcontrol *control, 510static int oxfw_volume_put(struct snd_kcontrol *control,
510 struct snd_ctl_elem_value *value) 511 struct snd_ctl_elem_value *value)
511{ 512{
512 struct fwspk *fwspk = control->private_data; 513 struct snd_oxfw *oxfw = control->private_data;
513 unsigned int i, changed_channels; 514 unsigned int i, changed_channels;
514 bool equal_values = true; 515 bool equal_values = true;
515 s16 volume; 516 s16 volume;
516 int err; 517 int err;
517 518
518 for (i = 0; i < fwspk->device_info->mixer_channels; ++i) { 519 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) {
519 if (value->value.integer.value[i] < fwspk->volume_min || 520 if (value->value.integer.value[i] < oxfw->volume_min ||
520 value->value.integer.value[i] > fwspk->volume_max) 521 value->value.integer.value[i] > oxfw->volume_max)
521 return -EINVAL; 522 return -EINVAL;
522 if (value->value.integer.value[i] != 523 if (value->value.integer.value[i] !=
523 value->value.integer.value[0]) 524 value->value.integer.value[0])
@@ -525,74 +526,74 @@ static int fwspk_volume_put(struct snd_kcontrol *control,
525 } 526 }
526 527
527 changed_channels = 0; 528 changed_channels = 0;
528 for (i = 0; i < fwspk->device_info->mixer_channels; ++i) 529 for (i = 0; i < oxfw->device_info->mixer_channels; ++i)
529 if (value->value.integer.value[channel_map[i]] != 530 if (value->value.integer.value[channel_map[i]] !=
530 fwspk->volume[i]) 531 oxfw->volume[i])
531 changed_channels |= 1 << (i + 1); 532 changed_channels |= 1 << (i + 1);
532 533
533 if (equal_values && changed_channels != 0) 534 if (equal_values && changed_channels != 0)
534 changed_channels = 1 << 0; 535 changed_channels = 1 << 0;
535 536
536 for (i = 0; i <= fwspk->device_info->mixer_channels; ++i) { 537 for (i = 0; i <= oxfw->device_info->mixer_channels; ++i) {
537 volume = value->value.integer.value[channel_map[i ? i - 1 : 0]]; 538 volume = value->value.integer.value[channel_map[i ? i - 1 : 0]];
538 if (changed_channels & (1 << i)) { 539 if (changed_channels & (1 << i)) {
539 err = fwspk_volume_command(fwspk, &volume, i, 540 err = oxfw_volume_command(oxfw, &volume, i,
540 CTL_CURRENT, CTL_WRITE); 541 CTL_CURRENT, CTL_WRITE);
541 if (err < 0) 542 if (err < 0)
542 return err; 543 return err;
543 } 544 }
544 if (i > 0) 545 if (i > 0)
545 fwspk->volume[i - 1] = volume; 546 oxfw->volume[i - 1] = volume;
546 } 547 }
547 548
548 return changed_channels != 0; 549 return changed_channels != 0;
549} 550}
550 551
551static int fwspk_create_mixer(struct fwspk *fwspk) 552static int oxfw_create_mixer(struct snd_oxfw *oxfw)
552{ 553{
553 static const struct snd_kcontrol_new controls[] = { 554 static const struct snd_kcontrol_new controls[] = {
554 { 555 {
555 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 556 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
556 .name = "PCM Playback Switch", 557 .name = "PCM Playback Switch",
557 .info = snd_ctl_boolean_mono_info, 558 .info = snd_ctl_boolean_mono_info,
558 .get = fwspk_mute_get, 559 .get = oxfw_mute_get,
559 .put = fwspk_mute_put, 560 .put = oxfw_mute_put,
560 }, 561 },
561 { 562 {
562 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, 563 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
563 .name = "PCM Playback Volume", 564 .name = "PCM Playback Volume",
564 .info = fwspk_volume_info, 565 .info = oxfw_volume_info,
565 .get = fwspk_volume_get, 566 .get = oxfw_volume_get,
566 .put = fwspk_volume_put, 567 .put = oxfw_volume_put,
567 }, 568 },
568 }; 569 };
569 unsigned int i, first_ch; 570 unsigned int i, first_ch;
570 int err; 571 int err;
571 572
572 err = fwspk_volume_command(fwspk, &fwspk->volume_min, 573 err = oxfw_volume_command(oxfw, &oxfw->volume_min,
573 0, CTL_MIN, CTL_READ); 574 0, CTL_MIN, CTL_READ);
574 if (err < 0) 575 if (err < 0)
575 return err; 576 return err;
576 err = fwspk_volume_command(fwspk, &fwspk->volume_max, 577 err = oxfw_volume_command(oxfw, &oxfw->volume_max,
577 0, CTL_MAX, CTL_READ); 578 0, CTL_MAX, CTL_READ);
578 if (err < 0) 579 if (err < 0)
579 return err; 580 return err;
580 581
581 err = fwspk_mute_command(fwspk, &fwspk->mute, CTL_READ); 582 err = oxfw_mute_command(oxfw, &oxfw->mute, CTL_READ);
582 if (err < 0) 583 if (err < 0)
583 return err; 584 return err;
584 585
585 first_ch = fwspk->device_info->mixer_channels == 1 ? 0 : 1; 586 first_ch = oxfw->device_info->mixer_channels == 1 ? 0 : 1;
586 for (i = 0; i < fwspk->device_info->mixer_channels; ++i) { 587 for (i = 0; i < oxfw->device_info->mixer_channels; ++i) {
587 err = fwspk_volume_command(fwspk, &fwspk->volume[i], 588 err = oxfw_volume_command(oxfw, &oxfw->volume[i],
588 first_ch + i, CTL_CURRENT, CTL_READ); 589 first_ch + i, CTL_CURRENT, CTL_READ);
589 if (err < 0) 590 if (err < 0)
590 return err; 591 return err;
591 } 592 }
592 593
593 for (i = 0; i < ARRAY_SIZE(controls); ++i) { 594 for (i = 0; i < ARRAY_SIZE(controls); ++i) {
594 err = snd_ctl_add(fwspk->card, 595 err = snd_ctl_add(oxfw->card,
595 snd_ctl_new1(&controls[i], fwspk)); 596 snd_ctl_new1(&controls[i], oxfw));
596 if (err < 0) 597 if (err < 0)
597 return err; 598 return err;
598 } 599 }
@@ -600,7 +601,7 @@ static int fwspk_create_mixer(struct fwspk *fwspk)
600 return 0; 601 return 0;
601} 602}
602 603
603static u32 fwspk_read_firmware_version(struct fw_unit *unit) 604static u32 oxfw_read_firmware_version(struct fw_unit *unit)
604{ 605{
605 __be32 data; 606 __be32 data;
606 int err; 607 int err;
@@ -610,63 +611,63 @@ static u32 fwspk_read_firmware_version(struct fw_unit *unit)
610 return err >= 0 ? be32_to_cpu(data) : 0; 611 return err >= 0 ? be32_to_cpu(data) : 0;
611} 612}
612 613
613static void fwspk_card_free(struct snd_card *card) 614static void oxfw_card_free(struct snd_card *card)
614{ 615{
615 struct fwspk *fwspk = card->private_data; 616 struct snd_oxfw *oxfw = card->private_data;
616 617
617 amdtp_stream_destroy(&fwspk->stream); 618 amdtp_stream_destroy(&oxfw->rx_stream);
618 cmp_connection_destroy(&fwspk->connection); 619 cmp_connection_destroy(&oxfw->in_conn);
619 fw_unit_put(fwspk->unit); 620 fw_unit_put(oxfw->unit);
620 mutex_destroy(&fwspk->mutex); 621 mutex_destroy(&oxfw->mutex);
621} 622}
622 623
623static int fwspk_probe(struct fw_unit *unit, 624static int oxfw_probe(struct fw_unit *unit,
624 const struct ieee1394_device_id *id) 625 const struct ieee1394_device_id *id)
625{ 626{
626 struct fw_device *fw_dev = fw_parent_device(unit); 627 struct fw_device *fw_dev = fw_parent_device(unit);
627 struct snd_card *card; 628 struct snd_card *card;
628 struct fwspk *fwspk; 629 struct snd_oxfw *oxfw;
629 u32 firmware; 630 u32 firmware;
630 int err; 631 int err;
631 632
632 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE, 633 err = snd_card_new(&unit->device, -1, NULL, THIS_MODULE,
633 sizeof(*fwspk), &card); 634 sizeof(*oxfw), &card);
634 if (err < 0) 635 if (err < 0)
635 return err; 636 return err;
636 637
637 fwspk = card->private_data; 638 oxfw = card->private_data;
638 fwspk->card = card; 639 oxfw->card = card;
639 mutex_init(&fwspk->mutex); 640 mutex_init(&oxfw->mutex);
640 fwspk->unit = fw_unit_get(unit); 641 oxfw->unit = fw_unit_get(unit);
641 fwspk->device_info = (const struct device_info *)id->driver_data; 642 oxfw->device_info = (const struct device_info *)id->driver_data;
642 643
643 err = cmp_connection_init(&fwspk->connection, unit, CMP_INPUT, 0); 644 err = cmp_connection_init(&oxfw->in_conn, unit, CMP_INPUT, 0);
644 if (err < 0) 645 if (err < 0)
645 goto err_unit; 646 goto err_unit;
646 647
647 err = amdtp_stream_init(&fwspk->stream, unit, AMDTP_OUT_STREAM, 648 err = amdtp_stream_init(&oxfw->rx_stream, unit, AMDTP_OUT_STREAM,
648 CIP_NONBLOCKING); 649 CIP_NONBLOCKING);
649 if (err < 0) 650 if (err < 0)
650 goto err_connection; 651 goto err_connection;
651 652
652 card->private_free = fwspk_card_free; 653 card->private_free = oxfw_card_free;
653 654
654 strcpy(card->driver, fwspk->device_info->driver_name); 655 strcpy(card->driver, oxfw->device_info->driver_name);
655 strcpy(card->shortname, fwspk->device_info->short_name); 656 strcpy(card->shortname, oxfw->device_info->short_name);
656 firmware = fwspk_read_firmware_version(unit); 657 firmware = oxfw_read_firmware_version(unit);
657 snprintf(card->longname, sizeof(card->longname), 658 snprintf(card->longname, sizeof(card->longname),
658 "%s (OXFW%x %04x), GUID %08x%08x at %s, S%d", 659 "%s (OXFW%x %04x), GUID %08x%08x at %s, S%d",
659 fwspk->device_info->long_name, 660 oxfw->device_info->long_name,
660 firmware >> 20, firmware & 0xffff, 661 firmware >> 20, firmware & 0xffff,
661 fw_dev->config_rom[3], fw_dev->config_rom[4], 662 fw_dev->config_rom[3], fw_dev->config_rom[4],
662 dev_name(&unit->device), 100 << fw_dev->max_speed); 663 dev_name(&unit->device), 100 << fw_dev->max_speed);
663 strcpy(card->mixername, "OXFW970"); 664 strcpy(card->mixername, "OXFW");
664 665
665 err = fwspk_create_pcm(fwspk); 666 err = oxfw_create_pcm(oxfw);
666 if (err < 0) 667 if (err < 0)
667 goto error; 668 goto error;
668 669
669 err = fwspk_create_mixer(fwspk); 670 err = oxfw_create_mixer(oxfw);
670 if (err < 0) 671 if (err < 0)
671 goto error; 672 goto error;
672 673
@@ -674,49 +675,49 @@ static int fwspk_probe(struct fw_unit *unit,
674 if (err < 0) 675 if (err < 0)
675 goto error; 676 goto error;
676 677
677 dev_set_drvdata(&unit->device, fwspk); 678 dev_set_drvdata(&unit->device, oxfw);
678 679
679 return 0; 680 return 0;
680 681
681err_connection: 682err_connection:
682 cmp_connection_destroy(&fwspk->connection); 683 cmp_connection_destroy(&oxfw->in_conn);
683err_unit: 684err_unit:
684 fw_unit_put(fwspk->unit); 685 fw_unit_put(oxfw->unit);
685 mutex_destroy(&fwspk->mutex); 686 mutex_destroy(&oxfw->mutex);
686error: 687error:
687 snd_card_free(card); 688 snd_card_free(card);
688 return err; 689 return err;
689} 690}
690 691
691static void fwspk_bus_reset(struct fw_unit *unit) 692static void oxfw_bus_reset(struct fw_unit *unit)
692{ 693{
693 struct fwspk *fwspk = dev_get_drvdata(&unit->device); 694 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);
694 695
695 fcp_bus_reset(fwspk->unit); 696 fcp_bus_reset(oxfw->unit);
696 697
697 if (cmp_connection_update(&fwspk->connection) < 0) { 698 if (cmp_connection_update(&oxfw->in_conn) < 0) {
698 amdtp_stream_pcm_abort(&fwspk->stream); 699 amdtp_stream_pcm_abort(&oxfw->rx_stream);
699 mutex_lock(&fwspk->mutex); 700 mutex_lock(&oxfw->mutex);
700 fwspk_stop_stream(fwspk); 701 oxfw_stop_stream(oxfw);
701 mutex_unlock(&fwspk->mutex); 702 mutex_unlock(&oxfw->mutex);
702 return; 703 return;
703 } 704 }
704 705
705 amdtp_stream_update(&fwspk->stream); 706 amdtp_stream_update(&oxfw->rx_stream);
706} 707}
707 708
708static void fwspk_remove(struct fw_unit *unit) 709static void oxfw_remove(struct fw_unit *unit)
709{ 710{
710 struct fwspk *fwspk = dev_get_drvdata(&unit->device); 711 struct snd_oxfw *oxfw = dev_get_drvdata(&unit->device);
711 712
712 amdtp_stream_pcm_abort(&fwspk->stream); 713 amdtp_stream_pcm_abort(&oxfw->rx_stream);
713 snd_card_disconnect(fwspk->card); 714 snd_card_disconnect(oxfw->card);
714 715
715 mutex_lock(&fwspk->mutex); 716 mutex_lock(&oxfw->mutex);
716 fwspk_stop_stream(fwspk); 717 oxfw_stop_stream(oxfw);
717 mutex_unlock(&fwspk->mutex); 718 mutex_unlock(&oxfw->mutex);
718 719
719 snd_card_free_when_closed(fwspk->card); 720 snd_card_free_when_closed(oxfw->card);
720} 721}
721 722
722static const struct device_info griffin_firewave = { 723static const struct device_info griffin_firewave = {
@@ -739,7 +740,7 @@ static const struct device_info lacie_speakers = {
739 .volume_fb_id = 0x01, 740 .volume_fb_id = 0x01,
740}; 741};
741 742
742static const struct ieee1394_device_id fwspk_id_table[] = { 743static const struct ieee1394_device_id oxfw_id_table[] = {
743 { 744 {
744 .match_flags = IEEE1394_MATCH_VENDOR_ID | 745 .match_flags = IEEE1394_MATCH_VENDOR_ID |
745 IEEE1394_MATCH_MODEL_ID | 746 IEEE1394_MATCH_MODEL_ID |
@@ -764,29 +765,29 @@ static const struct ieee1394_device_id fwspk_id_table[] = {
764 }, 765 },
765 { } 766 { }
766}; 767};
767MODULE_DEVICE_TABLE(ieee1394, fwspk_id_table); 768MODULE_DEVICE_TABLE(ieee1394, oxfw_id_table);
768 769
769static struct fw_driver fwspk_driver = { 770static struct fw_driver oxfw_driver = {
770 .driver = { 771 .driver = {
771 .owner = THIS_MODULE, 772 .owner = THIS_MODULE,
772 .name = KBUILD_MODNAME, 773 .name = KBUILD_MODNAME,
773 .bus = &fw_bus_type, 774 .bus = &fw_bus_type,
774 }, 775 },
775 .probe = fwspk_probe, 776 .probe = oxfw_probe,
776 .update = fwspk_bus_reset, 777 .update = oxfw_bus_reset,
777 .remove = fwspk_remove, 778 .remove = oxfw_remove,
778 .id_table = fwspk_id_table, 779 .id_table = oxfw_id_table,
779}; 780};
780 781
781static int __init alsa_fwspk_init(void) 782static int __init snd_oxfw_init(void)
782{ 783{
783 return driver_register(&fwspk_driver.driver); 784 return driver_register(&oxfw_driver.driver);
784} 785}
785 786
786static void __exit alsa_fwspk_exit(void) 787static void __exit snd_oxfw_exit(void)
787{ 788{
788 driver_unregister(&fwspk_driver.driver); 789 driver_unregister(&oxfw_driver.driver);
789} 790}
790 791
791module_init(alsa_fwspk_init); 792module_init(snd_oxfw_init);
792module_exit(alsa_fwspk_exit); 793module_exit(snd_oxfw_exit);