diff options
author | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-01-24 15:34:47 -0500 |
---|---|---|
committer | Dave Kleikamp <shaggy@austin.ibm.com> | 2006-01-24 15:34:47 -0500 |
commit | 0a0fc0ddbe732779366ab6b1b879f62195e65967 (patch) | |
tree | 7b42490a676cf39ae0691b6859ecf7fd410f229b /sound/parisc | |
parent | 4d5dbd0945d9e0833dd7964a3d6ee33157f7cc7a (diff) | |
parent | 3ee68c4af3fd7228c1be63254b9f884614f9ebb2 (diff) |
Merge with /home/shaggy/git/linus-clean/
Diffstat (limited to 'sound/parisc')
-rw-r--r-- | sound/parisc/harmony.c | 270 | ||||
-rw-r--r-- | sound/parisc/harmony.h | 14 |
2 files changed, 126 insertions, 158 deletions
diff --git a/sound/parisc/harmony.c b/sound/parisc/harmony.c index d833349ed518..ce73f3eae78c 100644 --- a/sound/parisc/harmony.c +++ b/sound/parisc/harmony.c | |||
@@ -59,6 +59,14 @@ | |||
59 | 59 | ||
60 | #include "harmony.h" | 60 | #include "harmony.h" |
61 | 61 | ||
62 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ | ||
63 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ | ||
64 | module_param(index, int, 0444); | ||
65 | MODULE_PARM_DESC(index, "Index value for Harmony driver."); | ||
66 | module_param(id, charp, 0444); | ||
67 | MODULE_PARM_DESC(id, "ID string for Harmony driver."); | ||
68 | |||
69 | |||
62 | static struct parisc_device_id snd_harmony_devtable[] = { | 70 | static struct parisc_device_id snd_harmony_devtable[] = { |
63 | /* bushmaster / flounder */ | 71 | /* bushmaster / flounder */ |
64 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0007A }, | 72 | { HPHW_FIO, HVERSION_REV_ANY_ID, HVERSION_ANY_ID, 0x0007A }, |
@@ -91,32 +99,32 @@ static unsigned int rate_bits[14] = { | |||
91 | HARMONY_SR_44KHZ, HARMONY_SR_48KHZ | 99 | HARMONY_SR_44KHZ, HARMONY_SR_48KHZ |
92 | }; | 100 | }; |
93 | 101 | ||
94 | static snd_pcm_hw_constraint_list_t hw_constraint_rates = { | 102 | static struct snd_pcm_hw_constraint_list hw_constraint_rates = { |
95 | .count = ARRAY_SIZE(snd_harmony_rates), | 103 | .count = ARRAY_SIZE(snd_harmony_rates), |
96 | .list = snd_harmony_rates, | 104 | .list = snd_harmony_rates, |
97 | .mask = 0, | 105 | .mask = 0, |
98 | }; | 106 | }; |
99 | 107 | ||
100 | inline unsigned long | 108 | static inline unsigned long |
101 | harmony_read(harmony_t *h, unsigned r) | 109 | harmony_read(struct snd_harmony *h, unsigned r) |
102 | { | 110 | { |
103 | return __raw_readl(h->iobase + r); | 111 | return __raw_readl(h->iobase + r); |
104 | } | 112 | } |
105 | 113 | ||
106 | inline void | 114 | static inline void |
107 | harmony_write(harmony_t *h, unsigned r, unsigned long v) | 115 | harmony_write(struct snd_harmony *h, unsigned r, unsigned long v) |
108 | { | 116 | { |
109 | __raw_writel(v, h->iobase + r); | 117 | __raw_writel(v, h->iobase + r); |
110 | } | 118 | } |
111 | 119 | ||
112 | static void | 120 | static inline void |
113 | harmony_wait_for_control(harmony_t *h) | 121 | harmony_wait_for_control(struct snd_harmony *h) |
114 | { | 122 | { |
115 | while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; | 123 | while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; |
116 | } | 124 | } |
117 | 125 | ||
118 | inline void | 126 | static inline void |
119 | harmony_reset(harmony_t *h) | 127 | harmony_reset(struct snd_harmony *h) |
120 | { | 128 | { |
121 | harmony_write(h, HARMONY_RESET, 1); | 129 | harmony_write(h, HARMONY_RESET, 1); |
122 | mdelay(50); | 130 | mdelay(50); |
@@ -124,7 +132,7 @@ harmony_reset(harmony_t *h) | |||
124 | } | 132 | } |
125 | 133 | ||
126 | static void | 134 | static void |
127 | harmony_disable_interrupts(harmony_t *h) | 135 | harmony_disable_interrupts(struct snd_harmony *h) |
128 | { | 136 | { |
129 | u32 dstatus; | 137 | u32 dstatus; |
130 | harmony_wait_for_control(h); | 138 | harmony_wait_for_control(h); |
@@ -134,7 +142,7 @@ harmony_disable_interrupts(harmony_t *h) | |||
134 | } | 142 | } |
135 | 143 | ||
136 | static void | 144 | static void |
137 | harmony_enable_interrupts(harmony_t *h) | 145 | harmony_enable_interrupts(struct snd_harmony *h) |
138 | { | 146 | { |
139 | u32 dstatus; | 147 | u32 dstatus; |
140 | harmony_wait_for_control(h); | 148 | harmony_wait_for_control(h); |
@@ -144,7 +152,7 @@ harmony_enable_interrupts(harmony_t *h) | |||
144 | } | 152 | } |
145 | 153 | ||
146 | static void | 154 | static void |
147 | harmony_mute(harmony_t *h) | 155 | harmony_mute(struct snd_harmony *h) |
148 | { | 156 | { |
149 | unsigned long flags; | 157 | unsigned long flags; |
150 | 158 | ||
@@ -155,7 +163,7 @@ harmony_mute(harmony_t *h) | |||
155 | } | 163 | } |
156 | 164 | ||
157 | static void | 165 | static void |
158 | harmony_unmute(harmony_t *h) | 166 | harmony_unmute(struct snd_harmony *h) |
159 | { | 167 | { |
160 | unsigned long flags; | 168 | unsigned long flags; |
161 | 169 | ||
@@ -166,7 +174,7 @@ harmony_unmute(harmony_t *h) | |||
166 | } | 174 | } |
167 | 175 | ||
168 | static void | 176 | static void |
169 | harmony_set_control(harmony_t *h) | 177 | harmony_set_control(struct snd_harmony *h) |
170 | { | 178 | { |
171 | u32 ctrl; | 179 | u32 ctrl; |
172 | unsigned long flags; | 180 | unsigned long flags; |
@@ -188,7 +196,7 @@ static irqreturn_t | |||
188 | snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs) | 196 | snd_harmony_interrupt(int irq, void *dev, struct pt_regs *regs) |
189 | { | 197 | { |
190 | u32 dstatus; | 198 | u32 dstatus; |
191 | harmony_t *h = dev; | 199 | struct snd_harmony *h = dev; |
192 | 200 | ||
193 | spin_lock(&h->lock); | 201 | spin_lock(&h->lock); |
194 | harmony_disable_interrupts(h); | 202 | harmony_disable_interrupts(h); |
@@ -253,7 +261,7 @@ snd_harmony_rate_bits(int rate) | |||
253 | return HARMONY_SR_44KHZ; | 261 | return HARMONY_SR_44KHZ; |
254 | } | 262 | } |
255 | 263 | ||
256 | static snd_pcm_hardware_t snd_harmony_playback = | 264 | static struct snd_pcm_hardware snd_harmony_playback = |
257 | { | 265 | { |
258 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 266 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
259 | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | | 267 | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -274,7 +282,7 @@ static snd_pcm_hardware_t snd_harmony_playback = | |||
274 | .fifo_size = 0, | 282 | .fifo_size = 0, |
275 | }; | 283 | }; |
276 | 284 | ||
277 | static snd_pcm_hardware_t snd_harmony_capture = | 285 | static struct snd_pcm_hardware snd_harmony_capture = |
278 | { | 286 | { |
279 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | | 287 | .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | |
280 | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | | 288 | SNDRV_PCM_INFO_JOINT_DUPLEX | SNDRV_PCM_INFO_MMAP_VALID | |
@@ -296,15 +304,14 @@ static snd_pcm_hardware_t snd_harmony_capture = | |||
296 | }; | 304 | }; |
297 | 305 | ||
298 | static int | 306 | static int |
299 | snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) | 307 | snd_harmony_playback_trigger(struct snd_pcm_substream *ss, int cmd) |
300 | { | 308 | { |
301 | harmony_t *h = snd_pcm_substream_chip(ss); | 309 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
302 | unsigned long flags; | ||
303 | 310 | ||
304 | if (h->st.capturing) | 311 | if (h->st.capturing) |
305 | return -EBUSY; | 312 | return -EBUSY; |
306 | 313 | ||
307 | spin_lock_irqsave(&h->lock, flags); | 314 | spin_lock(&h->lock); |
308 | switch (cmd) { | 315 | switch (cmd) { |
309 | case SNDRV_PCM_TRIGGER_START: | 316 | case SNDRV_PCM_TRIGGER_START: |
310 | h->st.playing = 1; | 317 | h->st.playing = 1; |
@@ -323,25 +330,24 @@ snd_harmony_playback_trigger(snd_pcm_substream_t *ss, int cmd) | |||
323 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 330 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
324 | case SNDRV_PCM_TRIGGER_SUSPEND: | 331 | case SNDRV_PCM_TRIGGER_SUSPEND: |
325 | default: | 332 | default: |
326 | spin_unlock_irqrestore(&h->lock, flags); | 333 | spin_unlock(&h->lock); |
327 | snd_BUG(); | 334 | snd_BUG(); |
328 | return -EINVAL; | 335 | return -EINVAL; |
329 | } | 336 | } |
330 | spin_unlock_irqrestore(&h->lock, flags); | 337 | spin_unlock(&h->lock); |
331 | 338 | ||
332 | return 0; | 339 | return 0; |
333 | } | 340 | } |
334 | 341 | ||
335 | static int | 342 | static int |
336 | snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) | 343 | snd_harmony_capture_trigger(struct snd_pcm_substream *ss, int cmd) |
337 | { | 344 | { |
338 | harmony_t *h = snd_pcm_substream_chip(ss); | 345 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
339 | unsigned long flags; | ||
340 | 346 | ||
341 | if (h->st.playing) | 347 | if (h->st.playing) |
342 | return -EBUSY; | 348 | return -EBUSY; |
343 | 349 | ||
344 | spin_lock_irqsave(&h->lock, flags); | 350 | spin_lock(&h->lock); |
345 | switch (cmd) { | 351 | switch (cmd) { |
346 | case SNDRV_PCM_TRIGGER_START: | 352 | case SNDRV_PCM_TRIGGER_START: |
347 | h->st.capturing = 1; | 353 | h->st.capturing = 1; |
@@ -360,17 +366,17 @@ snd_harmony_capture_trigger(snd_pcm_substream_t *ss, int cmd) | |||
360 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 366 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
361 | case SNDRV_PCM_TRIGGER_SUSPEND: | 367 | case SNDRV_PCM_TRIGGER_SUSPEND: |
362 | default: | 368 | default: |
363 | spin_unlock_irqrestore(&h->lock, flags); | 369 | spin_unlock(&h->lock); |
364 | snd_BUG(); | 370 | snd_BUG(); |
365 | return -EINVAL; | 371 | return -EINVAL; |
366 | } | 372 | } |
367 | spin_unlock_irqrestore(&h->lock, flags); | 373 | spin_unlock(&h->lock); |
368 | 374 | ||
369 | return 0; | 375 | return 0; |
370 | } | 376 | } |
371 | 377 | ||
372 | static int | 378 | static int |
373 | snd_harmony_set_data_format(harmony_t *h, int fmt, int force) | 379 | snd_harmony_set_data_format(struct snd_harmony *h, int fmt, int force) |
374 | { | 380 | { |
375 | int o = h->st.format; | 381 | int o = h->st.format; |
376 | int n; | 382 | int n; |
@@ -400,10 +406,10 @@ snd_harmony_set_data_format(harmony_t *h, int fmt, int force) | |||
400 | } | 406 | } |
401 | 407 | ||
402 | static int | 408 | static int |
403 | snd_harmony_playback_prepare(snd_pcm_substream_t *ss) | 409 | snd_harmony_playback_prepare(struct snd_pcm_substream *ss) |
404 | { | 410 | { |
405 | harmony_t *h = snd_pcm_substream_chip(ss); | 411 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
406 | snd_pcm_runtime_t *rt = ss->runtime; | 412 | struct snd_pcm_runtime *rt = ss->runtime; |
407 | 413 | ||
408 | if (h->st.capturing) | 414 | if (h->st.capturing) |
409 | return -EBUSY; | 415 | return -EBUSY; |
@@ -430,10 +436,10 @@ snd_harmony_playback_prepare(snd_pcm_substream_t *ss) | |||
430 | } | 436 | } |
431 | 437 | ||
432 | static int | 438 | static int |
433 | snd_harmony_capture_prepare(snd_pcm_substream_t *ss) | 439 | snd_harmony_capture_prepare(struct snd_pcm_substream *ss) |
434 | { | 440 | { |
435 | harmony_t *h = snd_pcm_substream_chip(ss); | 441 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
436 | snd_pcm_runtime_t *rt = ss->runtime; | 442 | struct snd_pcm_runtime *rt = ss->runtime; |
437 | 443 | ||
438 | if (h->st.playing) | 444 | if (h->st.playing) |
439 | return -EBUSY; | 445 | return -EBUSY; |
@@ -460,10 +466,10 @@ snd_harmony_capture_prepare(snd_pcm_substream_t *ss) | |||
460 | } | 466 | } |
461 | 467 | ||
462 | static snd_pcm_uframes_t | 468 | static snd_pcm_uframes_t |
463 | snd_harmony_playback_pointer(snd_pcm_substream_t *ss) | 469 | snd_harmony_playback_pointer(struct snd_pcm_substream *ss) |
464 | { | 470 | { |
465 | snd_pcm_runtime_t *rt = ss->runtime; | 471 | struct snd_pcm_runtime *rt = ss->runtime; |
466 | harmony_t *h = snd_pcm_substream_chip(ss); | 472 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
467 | unsigned long pcuradd; | 473 | unsigned long pcuradd; |
468 | unsigned long played; | 474 | unsigned long played; |
469 | 475 | ||
@@ -489,10 +495,10 @@ snd_harmony_playback_pointer(snd_pcm_substream_t *ss) | |||
489 | } | 495 | } |
490 | 496 | ||
491 | static snd_pcm_uframes_t | 497 | static snd_pcm_uframes_t |
492 | snd_harmony_capture_pointer(snd_pcm_substream_t *ss) | 498 | snd_harmony_capture_pointer(struct snd_pcm_substream *ss) |
493 | { | 499 | { |
494 | snd_pcm_runtime_t *rt = ss->runtime; | 500 | struct snd_pcm_runtime *rt = ss->runtime; |
495 | harmony_t *h = snd_pcm_substream_chip(ss); | 501 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
496 | unsigned long rcuradd; | 502 | unsigned long rcuradd; |
497 | unsigned long caught; | 503 | unsigned long caught; |
498 | 504 | ||
@@ -518,10 +524,10 @@ snd_harmony_capture_pointer(snd_pcm_substream_t *ss) | |||
518 | } | 524 | } |
519 | 525 | ||
520 | static int | 526 | static int |
521 | snd_harmony_playback_open(snd_pcm_substream_t *ss) | 527 | snd_harmony_playback_open(struct snd_pcm_substream *ss) |
522 | { | 528 | { |
523 | harmony_t *h = snd_pcm_substream_chip(ss); | 529 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
524 | snd_pcm_runtime_t *rt = ss->runtime; | 530 | struct snd_pcm_runtime *rt = ss->runtime; |
525 | int err; | 531 | int err; |
526 | 532 | ||
527 | h->psubs = ss; | 533 | h->psubs = ss; |
@@ -537,10 +543,10 @@ snd_harmony_playback_open(snd_pcm_substream_t *ss) | |||
537 | } | 543 | } |
538 | 544 | ||
539 | static int | 545 | static int |
540 | snd_harmony_capture_open(snd_pcm_substream_t *ss) | 546 | snd_harmony_capture_open(struct snd_pcm_substream *ss) |
541 | { | 547 | { |
542 | harmony_t *h = snd_pcm_substream_chip(ss); | 548 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
543 | snd_pcm_runtime_t *rt = ss->runtime; | 549 | struct snd_pcm_runtime *rt = ss->runtime; |
544 | int err; | 550 | int err; |
545 | 551 | ||
546 | h->csubs = ss; | 552 | h->csubs = ss; |
@@ -556,27 +562,27 @@ snd_harmony_capture_open(snd_pcm_substream_t *ss) | |||
556 | } | 562 | } |
557 | 563 | ||
558 | static int | 564 | static int |
559 | snd_harmony_playback_close(snd_pcm_substream_t *ss) | 565 | snd_harmony_playback_close(struct snd_pcm_substream *ss) |
560 | { | 566 | { |
561 | harmony_t *h = snd_pcm_substream_chip(ss); | 567 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
562 | h->psubs = NULL; | 568 | h->psubs = NULL; |
563 | return 0; | 569 | return 0; |
564 | } | 570 | } |
565 | 571 | ||
566 | static int | 572 | static int |
567 | snd_harmony_capture_close(snd_pcm_substream_t *ss) | 573 | snd_harmony_capture_close(struct snd_pcm_substream *ss) |
568 | { | 574 | { |
569 | harmony_t *h = snd_pcm_substream_chip(ss); | 575 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
570 | h->csubs = NULL; | 576 | h->csubs = NULL; |
571 | return 0; | 577 | return 0; |
572 | } | 578 | } |
573 | 579 | ||
574 | static int | 580 | static int |
575 | snd_harmony_hw_params(snd_pcm_substream_t *ss, | 581 | snd_harmony_hw_params(struct snd_pcm_substream *ss, |
576 | snd_pcm_hw_params_t *hw) | 582 | struct snd_pcm_hw_params *hw) |
577 | { | 583 | { |
578 | int err; | 584 | int err; |
579 | harmony_t *h = snd_pcm_substream_chip(ss); | 585 | struct snd_harmony *h = snd_pcm_substream_chip(ss); |
580 | 586 | ||
581 | err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); | 587 | err = snd_pcm_lib_malloc_pages(ss, params_buffer_bytes(hw)); |
582 | if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) | 588 | if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) |
@@ -586,12 +592,12 @@ snd_harmony_hw_params(snd_pcm_substream_t *ss, | |||
586 | } | 592 | } |
587 | 593 | ||
588 | static int | 594 | static int |
589 | snd_harmony_hw_free(snd_pcm_substream_t *ss) | 595 | snd_harmony_hw_free(struct snd_pcm_substream *ss) |
590 | { | 596 | { |
591 | return snd_pcm_lib_free_pages(ss); | 597 | return snd_pcm_lib_free_pages(ss); |
592 | } | 598 | } |
593 | 599 | ||
594 | static snd_pcm_ops_t snd_harmony_playback_ops = { | 600 | static struct snd_pcm_ops snd_harmony_playback_ops = { |
595 | .open = snd_harmony_playback_open, | 601 | .open = snd_harmony_playback_open, |
596 | .close = snd_harmony_playback_close, | 602 | .close = snd_harmony_playback_close, |
597 | .ioctl = snd_pcm_lib_ioctl, | 603 | .ioctl = snd_pcm_lib_ioctl, |
@@ -602,7 +608,7 @@ static snd_pcm_ops_t snd_harmony_playback_ops = { | |||
602 | .pointer = snd_harmony_playback_pointer, | 608 | .pointer = snd_harmony_playback_pointer, |
603 | }; | 609 | }; |
604 | 610 | ||
605 | static snd_pcm_ops_t snd_harmony_capture_ops = { | 611 | static struct snd_pcm_ops snd_harmony_capture_ops = { |
606 | .open = snd_harmony_capture_open, | 612 | .open = snd_harmony_capture_open, |
607 | .close = snd_harmony_capture_close, | 613 | .close = snd_harmony_capture_close, |
608 | .ioctl = snd_pcm_lib_ioctl, | 614 | .ioctl = snd_pcm_lib_ioctl, |
@@ -614,9 +620,9 @@ static snd_pcm_ops_t snd_harmony_capture_ops = { | |||
614 | }; | 620 | }; |
615 | 621 | ||
616 | static int | 622 | static int |
617 | snd_harmony_pcm_init(harmony_t *h) | 623 | snd_harmony_pcm_init(struct snd_harmony *h) |
618 | { | 624 | { |
619 | snd_pcm_t *pcm; | 625 | struct snd_pcm *pcm; |
620 | int err; | 626 | int err; |
621 | 627 | ||
622 | harmony_disable_interrupts(h); | 628 | harmony_disable_interrupts(h); |
@@ -677,15 +683,15 @@ snd_harmony_pcm_init(harmony_t *h) | |||
677 | } | 683 | } |
678 | 684 | ||
679 | static void | 685 | static void |
680 | snd_harmony_set_new_gain(harmony_t *h) | 686 | snd_harmony_set_new_gain(struct snd_harmony *h) |
681 | { | 687 | { |
682 | harmony_wait_for_control(h); | 688 | harmony_wait_for_control(h); |
683 | harmony_write(h, HARMONY_GAINCTL, h->st.gain); | 689 | harmony_write(h, HARMONY_GAINCTL, h->st.gain); |
684 | } | 690 | } |
685 | 691 | ||
686 | static int | 692 | static int |
687 | snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, | 693 | snd_harmony_mixercontrol_info(struct snd_kcontrol *kc, |
688 | snd_ctl_elem_info_t *uinfo) | 694 | struct snd_ctl_elem_info *uinfo) |
689 | { | 695 | { |
690 | int mask = (kc->private_value >> 16) & 0xff; | 696 | int mask = (kc->private_value >> 16) & 0xff; |
691 | int left_shift = (kc->private_value) & 0xff; | 697 | int left_shift = (kc->private_value) & 0xff; |
@@ -701,18 +707,17 @@ snd_harmony_mixercontrol_info(snd_kcontrol_t *kc, | |||
701 | } | 707 | } |
702 | 708 | ||
703 | static int | 709 | static int |
704 | snd_harmony_volume_get(snd_kcontrol_t *kc, | 710 | snd_harmony_volume_get(struct snd_kcontrol *kc, |
705 | snd_ctl_elem_value_t *ucontrol) | 711 | struct snd_ctl_elem_value *ucontrol) |
706 | { | 712 | { |
707 | harmony_t *h = snd_kcontrol_chip(kc); | 713 | struct snd_harmony *h = snd_kcontrol_chip(kc); |
708 | int shift_left = (kc->private_value) & 0xff; | 714 | int shift_left = (kc->private_value) & 0xff; |
709 | int shift_right = (kc->private_value >> 8) & 0xff; | 715 | int shift_right = (kc->private_value >> 8) & 0xff; |
710 | int mask = (kc->private_value >> 16) & 0xff; | 716 | int mask = (kc->private_value >> 16) & 0xff; |
711 | int invert = (kc->private_value >> 24) & 0xff; | 717 | int invert = (kc->private_value >> 24) & 0xff; |
712 | int left, right; | 718 | int left, right; |
713 | unsigned long flags; | ||
714 | 719 | ||
715 | spin_lock_irqsave(&h->mixer_lock, flags); | 720 | spin_lock_irq(&h->mixer_lock); |
716 | 721 | ||
717 | left = (h->st.gain >> shift_left) & mask; | 722 | left = (h->st.gain >> shift_left) & mask; |
718 | right = (h->st.gain >> shift_right) & mask; | 723 | right = (h->st.gain >> shift_right) & mask; |
@@ -725,25 +730,24 @@ snd_harmony_volume_get(snd_kcontrol_t *kc, | |||
725 | if (shift_left != shift_right) | 730 | if (shift_left != shift_right) |
726 | ucontrol->value.integer.value[1] = right; | 731 | ucontrol->value.integer.value[1] = right; |
727 | 732 | ||
728 | spin_unlock_irqrestore(&h->mixer_lock, flags); | 733 | spin_unlock_irq(&h->mixer_lock); |
729 | 734 | ||
730 | return 0; | 735 | return 0; |
731 | } | 736 | } |
732 | 737 | ||
733 | static int | 738 | static int |
734 | snd_harmony_volume_put(snd_kcontrol_t *kc, | 739 | snd_harmony_volume_put(struct snd_kcontrol *kc, |
735 | snd_ctl_elem_value_t *ucontrol) | 740 | struct snd_ctl_elem_value *ucontrol) |
736 | { | 741 | { |
737 | harmony_t *h = snd_kcontrol_chip(kc); | 742 | struct snd_harmony *h = snd_kcontrol_chip(kc); |
738 | int shift_left = (kc->private_value) & 0xff; | 743 | int shift_left = (kc->private_value) & 0xff; |
739 | int shift_right = (kc->private_value >> 8) & 0xff; | 744 | int shift_right = (kc->private_value >> 8) & 0xff; |
740 | int mask = (kc->private_value >> 16) & 0xff; | 745 | int mask = (kc->private_value >> 16) & 0xff; |
741 | int invert = (kc->private_value >> 24) & 0xff; | 746 | int invert = (kc->private_value >> 24) & 0xff; |
742 | int left, right; | 747 | int left, right; |
743 | int old_gain = h->st.gain; | 748 | int old_gain = h->st.gain; |
744 | unsigned long flags; | ||
745 | 749 | ||
746 | spin_lock_irqsave(&h->mixer_lock, flags); | 750 | spin_lock_irq(&h->mixer_lock); |
747 | 751 | ||
748 | left = ucontrol->value.integer.value[0] & mask; | 752 | left = ucontrol->value.integer.value[0] & mask; |
749 | if (invert) | 753 | if (invert) |
@@ -761,14 +765,14 @@ snd_harmony_volume_put(snd_kcontrol_t *kc, | |||
761 | 765 | ||
762 | snd_harmony_set_new_gain(h); | 766 | snd_harmony_set_new_gain(h); |
763 | 767 | ||
764 | spin_unlock_irqrestore(&h->mixer_lock, flags); | 768 | spin_unlock_irq(&h->mixer_lock); |
765 | 769 | ||
766 | return h->st.gain != old_gain; | 770 | return h->st.gain != old_gain; |
767 | } | 771 | } |
768 | 772 | ||
769 | static int | 773 | static int |
770 | snd_harmony_captureroute_info(snd_kcontrol_t *kc, | 774 | snd_harmony_captureroute_info(struct snd_kcontrol *kc, |
771 | snd_ctl_elem_info_t *uinfo) | 775 | struct snd_ctl_elem_info *uinfo) |
772 | { | 776 | { |
773 | static char *texts[2] = { "Line", "Mic" }; | 777 | static char *texts[2] = { "Line", "Mic" }; |
774 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 778 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
@@ -782,33 +786,31 @@ snd_harmony_captureroute_info(snd_kcontrol_t *kc, | |||
782 | } | 786 | } |
783 | 787 | ||
784 | static int | 788 | static int |
785 | snd_harmony_captureroute_get(snd_kcontrol_t *kc, | 789 | snd_harmony_captureroute_get(struct snd_kcontrol *kc, |
786 | snd_ctl_elem_value_t *ucontrol) | 790 | struct snd_ctl_elem_value *ucontrol) |
787 | { | 791 | { |
788 | harmony_t *h = snd_kcontrol_chip(kc); | 792 | struct snd_harmony *h = snd_kcontrol_chip(kc); |
789 | int value; | 793 | int value; |
790 | unsigned long flags; | ||
791 | 794 | ||
792 | spin_lock_irqsave(&h->mixer_lock, flags); | 795 | spin_lock_irq(&h->mixer_lock); |
793 | 796 | ||
794 | value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; | 797 | value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; |
795 | ucontrol->value.enumerated.item[0] = value; | 798 | ucontrol->value.enumerated.item[0] = value; |
796 | 799 | ||
797 | spin_unlock_irqrestore(&h->mixer_lock, flags); | 800 | spin_unlock_irq(&h->mixer_lock); |
798 | 801 | ||
799 | return 0; | 802 | return 0; |
800 | } | 803 | } |
801 | 804 | ||
802 | static int | 805 | static int |
803 | snd_harmony_captureroute_put(snd_kcontrol_t *kc, | 806 | snd_harmony_captureroute_put(struct snd_kcontrol *kc, |
804 | snd_ctl_elem_value_t *ucontrol) | 807 | struct snd_ctl_elem_value *ucontrol) |
805 | { | 808 | { |
806 | harmony_t *h = snd_kcontrol_chip(kc); | 809 | struct snd_harmony *h = snd_kcontrol_chip(kc); |
807 | int value; | 810 | int value; |
808 | int old_gain = h->st.gain; | 811 | int old_gain = h->st.gain; |
809 | unsigned long flags; | ||
810 | 812 | ||
811 | spin_lock_irqsave(&h->mixer_lock, flags); | 813 | spin_lock_irq(&h->mixer_lock); |
812 | 814 | ||
813 | value = ucontrol->value.enumerated.item[0] & 1; | 815 | value = ucontrol->value.enumerated.item[0] & 1; |
814 | h->st.gain &= ~HARMONY_GAIN_IS_MASK; | 816 | h->st.gain &= ~HARMONY_GAIN_IS_MASK; |
@@ -816,13 +818,12 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, | |||
816 | 818 | ||
817 | snd_harmony_set_new_gain(h); | 819 | snd_harmony_set_new_gain(h); |
818 | 820 | ||
819 | spin_unlock_irqrestore(&h->mixer_lock, flags); | 821 | spin_unlock_irq(&h->mixer_lock); |
820 | 822 | ||
821 | return h->st.gain != old_gain; | 823 | return h->st.gain != old_gain; |
822 | } | 824 | } |
823 | 825 | ||
824 | #define HARMONY_CONTROLS (sizeof(snd_harmony_controls)/ \ | 826 | #define HARMONY_CONTROLS ARRAY_SIZE(snd_harmony_controls) |
825 | sizeof(snd_kcontrol_new_t)) | ||
826 | 827 | ||
827 | #define HARMONY_VOLUME(xname, left_shift, right_shift, mask, invert) \ | 828 | #define HARMONY_VOLUME(xname, left_shift, right_shift, mask, invert) \ |
828 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 829 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
@@ -831,7 +832,7 @@ snd_harmony_captureroute_put(snd_kcontrol_t *kc, | |||
831 | .private_value = ((left_shift) | ((right_shift) << 8) | \ | 832 | .private_value = ((left_shift) | ((right_shift) << 8) | \ |
832 | ((mask) << 16) | ((invert) << 24)) } | 833 | ((mask) << 16) | ((invert) << 24)) } |
833 | 834 | ||
834 | static snd_kcontrol_new_t snd_harmony_controls[] = { | 835 | static struct snd_kcontrol_new snd_harmony_controls[] = { |
835 | HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT, | 836 | HARMONY_VOLUME("Master Playback Volume", HARMONY_GAIN_LO_SHIFT, |
836 | HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), | 837 | HARMONY_GAIN_RO_SHIFT, HARMONY_GAIN_OUT, 1), |
837 | HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, | 838 | HARMONY_VOLUME("Capture Volume", HARMONY_GAIN_LI_SHIFT, |
@@ -854,7 +855,7 @@ static snd_kcontrol_new_t snd_harmony_controls[] = { | |||
854 | }; | 855 | }; |
855 | 856 | ||
856 | static void __init | 857 | static void __init |
857 | snd_harmony_mixer_reset(harmony_t *h) | 858 | snd_harmony_mixer_reset(struct snd_harmony *h) |
858 | { | 859 | { |
859 | harmony_mute(h); | 860 | harmony_mute(h); |
860 | harmony_reset(h); | 861 | harmony_reset(h); |
@@ -863,9 +864,9 @@ snd_harmony_mixer_reset(harmony_t *h) | |||
863 | } | 864 | } |
864 | 865 | ||
865 | static int __init | 866 | static int __init |
866 | snd_harmony_mixer_init(harmony_t *h) | 867 | snd_harmony_mixer_init(struct snd_harmony *h) |
867 | { | 868 | { |
868 | snd_card_t *card = h->card; | 869 | struct snd_card *card = h->card; |
869 | int idx, err; | 870 | int idx, err; |
870 | 871 | ||
871 | snd_assert(h != NULL, return -EINVAL); | 872 | snd_assert(h != NULL, return -EINVAL); |
@@ -884,7 +885,7 @@ snd_harmony_mixer_init(harmony_t *h) | |||
884 | } | 885 | } |
885 | 886 | ||
886 | static int | 887 | static int |
887 | snd_harmony_free(harmony_t *h) | 888 | snd_harmony_free(struct snd_harmony *h) |
888 | { | 889 | { |
889 | if (h->gdma.addr) | 890 | if (h->gdma.addr) |
890 | snd_dma_free_pages(&h->gdma); | 891 | snd_dma_free_pages(&h->gdma); |
@@ -904,38 +905,33 @@ snd_harmony_free(harmony_t *h) | |||
904 | } | 905 | } |
905 | 906 | ||
906 | static int | 907 | static int |
907 | snd_harmony_dev_free(snd_device_t *dev) | 908 | snd_harmony_dev_free(struct snd_device *dev) |
908 | { | 909 | { |
909 | harmony_t *h = dev->device_data; | 910 | struct snd_harmony *h = dev->device_data; |
910 | return snd_harmony_free(h); | 911 | return snd_harmony_free(h); |
911 | } | 912 | } |
912 | 913 | ||
913 | static int __devinit | 914 | static int __devinit |
914 | snd_harmony_create(snd_card_t *card, | 915 | snd_harmony_create(struct snd_card *card, |
915 | struct parisc_device *padev, | 916 | struct parisc_device *padev, |
916 | harmony_t **rchip) | 917 | struct snd_harmony **rchip) |
917 | { | 918 | { |
918 | int err; | 919 | int err; |
919 | harmony_t *h; | 920 | struct snd_harmony *h; |
920 | static snd_device_ops_t ops = { | 921 | static struct snd_device_ops ops = { |
921 | .dev_free = snd_harmony_dev_free, | 922 | .dev_free = snd_harmony_dev_free, |
922 | }; | 923 | }; |
923 | 924 | ||
924 | *rchip = NULL; | 925 | *rchip = NULL; |
925 | 926 | ||
926 | h = kmalloc(sizeof(*h), GFP_KERNEL); | 927 | h = kzalloc(sizeof(*h), GFP_KERNEL); |
927 | if (h == NULL) | 928 | if (h == NULL) |
928 | return -ENOMEM; | 929 | return -ENOMEM; |
929 | 930 | ||
930 | memset(&h->st, 0, sizeof(h->st)); | ||
931 | memset(&h->stats, 0, sizeof(h->stats)); | ||
932 | memset(&h->pbuf, 0, sizeof(h->pbuf)); | ||
933 | memset(&h->cbuf, 0, sizeof(h->cbuf)); | ||
934 | |||
935 | h->hpa = padev->hpa.start; | 931 | h->hpa = padev->hpa.start; |
936 | h->card = card; | 932 | h->card = card; |
937 | h->dev = padev; | 933 | h->dev = padev; |
938 | h->irq = padev->irq; | 934 | h->irq = -1; |
939 | h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); | 935 | h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); |
940 | if (h->iobase == NULL) { | 936 | if (h->iobase == NULL) { |
941 | printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", | 937 | printk(KERN_ERR PFX "unable to remap hpa 0x%lx\n", |
@@ -944,13 +940,14 @@ snd_harmony_create(snd_card_t *card, | |||
944 | goto free_and_ret; | 940 | goto free_and_ret; |
945 | } | 941 | } |
946 | 942 | ||
947 | err = request_irq(h->irq, snd_harmony_interrupt, 0, | 943 | err = request_irq(padev->irq, snd_harmony_interrupt, 0, |
948 | "harmony", h); | 944 | "harmony", h); |
949 | if (err) { | 945 | if (err) { |
950 | printk(KERN_ERR PFX "could not obtain interrupt %d", | 946 | printk(KERN_ERR PFX "could not obtain interrupt %d", |
951 | h->irq); | 947 | padev->irq); |
952 | goto free_and_ret; | 948 | goto free_and_ret; |
953 | } | 949 | } |
950 | h->irq = padev->irq; | ||
954 | 951 | ||
955 | spin_lock_init(&h->mixer_lock); | 952 | spin_lock_init(&h->mixer_lock); |
956 | spin_lock_init(&h->lock); | 953 | spin_lock_init(&h->lock); |
@@ -975,35 +972,24 @@ static int __devinit | |||
975 | snd_harmony_probe(struct parisc_device *padev) | 972 | snd_harmony_probe(struct parisc_device *padev) |
976 | { | 973 | { |
977 | int err; | 974 | int err; |
978 | static int dev; | 975 | struct snd_card *card; |
979 | snd_card_t *card; | 976 | struct snd_harmony *h; |
980 | harmony_t *h; | ||
981 | static int index = SNDRV_DEFAULT_IDX1; | ||
982 | static char *id = SNDRV_DEFAULT_STR1; | ||
983 | |||
984 | h = parisc_get_drvdata(padev); | ||
985 | if (h != NULL) { | ||
986 | return -ENODEV; | ||
987 | } | ||
988 | 977 | ||
989 | card = snd_card_new(index, id, THIS_MODULE, 0); | 978 | card = snd_card_new(index, id, THIS_MODULE, 0); |
990 | if (card == NULL) | 979 | if (card == NULL) |
991 | return -ENOMEM; | 980 | return -ENOMEM; |
992 | 981 | ||
993 | err = snd_harmony_create(card, padev, &h); | 982 | err = snd_harmony_create(card, padev, &h); |
994 | if (err < 0) { | 983 | if (err < 0) |
995 | goto free_and_ret; | 984 | goto free_and_ret; |
996 | } | ||
997 | 985 | ||
998 | err = snd_harmony_pcm_init(h); | 986 | err = snd_harmony_pcm_init(h); |
999 | if (err < 0) { | 987 | if (err < 0) |
1000 | goto free_and_ret; | 988 | goto free_and_ret; |
1001 | } | ||
1002 | 989 | ||
1003 | err = snd_harmony_mixer_init(h); | 990 | err = snd_harmony_mixer_init(h); |
1004 | if (err < 0) { | 991 | if (err < 0) |
1005 | goto free_and_ret; | 992 | goto free_and_ret; |
1006 | } | ||
1007 | 993 | ||
1008 | strcpy(card->driver, "harmony"); | 994 | strcpy(card->driver, "harmony"); |
1009 | strcpy(card->shortname, "Harmony"); | 995 | strcpy(card->shortname, "Harmony"); |
@@ -1011,13 +997,10 @@ snd_harmony_probe(struct parisc_device *padev) | |||
1011 | card->shortname, h->hpa, h->irq); | 997 | card->shortname, h->hpa, h->irq); |
1012 | 998 | ||
1013 | err = snd_card_register(card); | 999 | err = snd_card_register(card); |
1014 | if (err < 0) { | 1000 | if (err < 0) |
1015 | goto free_and_ret; | 1001 | goto free_and_ret; |
1016 | } | ||
1017 | |||
1018 | dev++; | ||
1019 | parisc_set_drvdata(padev, h); | ||
1020 | 1002 | ||
1003 | parisc_set_drvdata(padev, card); | ||
1021 | return 0; | 1004 | return 0; |
1022 | 1005 | ||
1023 | free_and_ret: | 1006 | free_and_ret: |
@@ -1028,8 +1011,8 @@ free_and_ret: | |||
1028 | static int __devexit | 1011 | static int __devexit |
1029 | snd_harmony_remove(struct parisc_device *padev) | 1012 | snd_harmony_remove(struct parisc_device *padev) |
1030 | { | 1013 | { |
1031 | harmony_t *h = parisc_get_drvdata(padev); | 1014 | snd_card_free(parisc_get_drvdata(padev)); |
1032 | snd_card_free(h->card); | 1015 | parisc_set_drvdata(padev, NULL); |
1033 | return 0; | 1016 | return 0; |
1034 | } | 1017 | } |
1035 | 1018 | ||
@@ -1043,28 +1026,13 @@ static struct parisc_driver snd_harmony_driver = { | |||
1043 | static int __init | 1026 | static int __init |
1044 | alsa_harmony_init(void) | 1027 | alsa_harmony_init(void) |
1045 | { | 1028 | { |
1046 | int err; | 1029 | return register_parisc_driver(&snd_harmony_driver); |
1047 | |||
1048 | err = register_parisc_driver(&snd_harmony_driver); | ||
1049 | if (err < 0) { | ||
1050 | printk(KERN_ERR PFX "device not found\n"); | ||
1051 | return err; | ||
1052 | } | ||
1053 | |||
1054 | return 0; | ||
1055 | } | 1030 | } |
1056 | 1031 | ||
1057 | static void __exit | 1032 | static void __exit |
1058 | alsa_harmony_fini(void) | 1033 | alsa_harmony_fini(void) |
1059 | { | 1034 | { |
1060 | int err; | 1035 | unregister_parisc_driver(&snd_harmony_driver); |
1061 | |||
1062 | err = unregister_parisc_driver(&snd_harmony_driver); | ||
1063 | if (err < 0) { | ||
1064 | printk(KERN_ERR PFX "failed to unregister\n"); | ||
1065 | } | ||
1066 | |||
1067 | return; | ||
1068 | } | 1036 | } |
1069 | 1037 | ||
1070 | MODULE_LICENSE("GPL"); | 1038 | MODULE_LICENSE("GPL"); |
diff --git a/sound/parisc/harmony.h b/sound/parisc/harmony.h index 526c52389de2..2e434523fedf 100644 --- a/sound/parisc/harmony.h +++ b/sound/parisc/harmony.h | |||
@@ -13,7 +13,7 @@ struct harmony_buffer { | |||
13 | int coherent; | 13 | int coherent; |
14 | }; | 14 | }; |
15 | 15 | ||
16 | typedef struct snd_card_harmony { | 16 | struct snd_harmony { |
17 | int irq; | 17 | int irq; |
18 | 18 | ||
19 | unsigned long hpa; /* hard physical address */ | 19 | unsigned long hpa; /* hard physical address */ |
@@ -44,15 +44,15 @@ typedef struct snd_card_harmony { | |||
44 | unsigned long silence_intr; | 44 | unsigned long silence_intr; |
45 | } stats; | 45 | } stats; |
46 | 46 | ||
47 | snd_pcm_t *pcm; | 47 | struct snd_pcm *pcm; |
48 | snd_card_t *card; | 48 | struct snd_card *card; |
49 | snd_pcm_substream_t *psubs; | 49 | struct snd_pcm_substream *psubs; |
50 | snd_pcm_substream_t *csubs; | 50 | struct snd_pcm_substream *csubs; |
51 | snd_info_entry_t *proc; | 51 | struct snd_info_entry *proc; |
52 | 52 | ||
53 | spinlock_t lock; | 53 | spinlock_t lock; |
54 | spinlock_t mixer_lock; | 54 | spinlock_t mixer_lock; |
55 | } harmony_t; | 55 | }; |
56 | 56 | ||
57 | #define MAX_PCM_DEVICES 1 | 57 | #define MAX_PCM_DEVICES 1 |
58 | #define MAX_PCM_SUBSTREAMS 4 | 58 | #define MAX_PCM_SUBSTREAMS 4 |