• Home
  • Raw
  • Download

Lines Matching full:h

25 #include <linux/init.h>
26 #include <linux/slab.h>
27 #include <linux/time.h>
28 #include <linux/wait.h>
29 #include <linux/delay.h>
30 #include <linux/module.h>
31 #include <linux/interrupt.h>
32 #include <linux/spinlock.h>
33 #include <linux/dma-mapping.h>
34 #include <linux/io.h>
36 #include <sound/core.h>
37 #include <sound/pcm.h>
38 #include <sound/control.h>
39 #include <sound/rawmidi.h>
40 #include <sound/initval.h>
41 #include <sound/info.h>
43 #include <asm/hardware.h>
44 #include <asm/parisc-device.h>
46 #include "harmony.h"
95 harmony_read(struct snd_harmony *h, unsigned r) in harmony_read() argument
97 return __raw_readl(h->iobase + r); in harmony_read()
101 harmony_write(struct snd_harmony *h, unsigned r, unsigned long v) in harmony_write() argument
103 __raw_writel(v, h->iobase + r); in harmony_write()
107 harmony_wait_for_control(struct snd_harmony *h) in harmony_wait_for_control() argument
109 while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; in harmony_wait_for_control()
113 harmony_reset(struct snd_harmony *h) in harmony_reset() argument
115 harmony_write(h, HARMONY_RESET, 1); in harmony_reset()
117 harmony_write(h, HARMONY_RESET, 0); in harmony_reset()
121 harmony_disable_interrupts(struct snd_harmony *h) in harmony_disable_interrupts() argument
124 harmony_wait_for_control(h); in harmony_disable_interrupts()
125 dstatus = harmony_read(h, HARMONY_DSTATUS); in harmony_disable_interrupts()
127 harmony_write(h, HARMONY_DSTATUS, dstatus); in harmony_disable_interrupts()
131 harmony_enable_interrupts(struct snd_harmony *h) in harmony_enable_interrupts() argument
134 harmony_wait_for_control(h); in harmony_enable_interrupts()
135 dstatus = harmony_read(h, HARMONY_DSTATUS); in harmony_enable_interrupts()
137 harmony_write(h, HARMONY_DSTATUS, dstatus); in harmony_enable_interrupts()
141 harmony_mute(struct snd_harmony *h) in harmony_mute() argument
145 spin_lock_irqsave(&h->mixer_lock, flags); in harmony_mute()
146 harmony_wait_for_control(h); in harmony_mute()
147 harmony_write(h, HARMONY_GAINCTL, HARMONY_GAIN_SILENCE); in harmony_mute()
148 spin_unlock_irqrestore(&h->mixer_lock, flags); in harmony_mute()
152 harmony_unmute(struct snd_harmony *h) in harmony_unmute() argument
156 spin_lock_irqsave(&h->mixer_lock, flags); in harmony_unmute()
157 harmony_wait_for_control(h); in harmony_unmute()
158 harmony_write(h, HARMONY_GAINCTL, h->st.gain); in harmony_unmute()
159 spin_unlock_irqrestore(&h->mixer_lock, flags); in harmony_unmute()
163 harmony_set_control(struct snd_harmony *h) in harmony_set_control() argument
168 spin_lock_irqsave(&h->lock, flags); in harmony_set_control()
171 (h->st.format << 6) | in harmony_set_control()
172 (h->st.stereo << 5) | in harmony_set_control()
173 (h->st.rate)); in harmony_set_control()
175 harmony_wait_for_control(h); in harmony_set_control()
176 harmony_write(h, HARMONY_CNTL, ctrl); in harmony_set_control()
178 spin_unlock_irqrestore(&h->lock, flags); in harmony_set_control()
185 struct snd_harmony *h = dev; in snd_harmony_interrupt() local
187 spin_lock(&h->lock); in snd_harmony_interrupt()
188 harmony_disable_interrupts(h); in snd_harmony_interrupt()
189 harmony_wait_for_control(h); in snd_harmony_interrupt()
190 dstatus = harmony_read(h, HARMONY_DSTATUS); in snd_harmony_interrupt()
191 spin_unlock(&h->lock); in snd_harmony_interrupt()
194 if (h->psubs && h->st.playing) { in snd_harmony_interrupt()
195 spin_lock(&h->lock); in snd_harmony_interrupt()
196 h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */ in snd_harmony_interrupt()
197 h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */ in snd_harmony_interrupt()
199 harmony_write(h, HARMONY_PNXTADD, in snd_harmony_interrupt()
200 h->pbuf.addr + h->pbuf.buf); in snd_harmony_interrupt()
201 h->stats.play_intr++; in snd_harmony_interrupt()
202 spin_unlock(&h->lock); in snd_harmony_interrupt()
203 snd_pcm_period_elapsed(h->psubs); in snd_harmony_interrupt()
205 spin_lock(&h->lock); in snd_harmony_interrupt()
206 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_interrupt()
207 h->stats.silence_intr++; in snd_harmony_interrupt()
208 spin_unlock(&h->lock); in snd_harmony_interrupt()
213 if (h->csubs && h->st.capturing) { in snd_harmony_interrupt()
214 spin_lock(&h->lock); in snd_harmony_interrupt()
215 h->cbuf.buf += h->cbuf.count; in snd_harmony_interrupt()
216 h->cbuf.buf %= h->cbuf.size; in snd_harmony_interrupt()
218 harmony_write(h, HARMONY_RNXTADD, in snd_harmony_interrupt()
219 h->cbuf.addr + h->cbuf.buf); in snd_harmony_interrupt()
220 h->stats.rec_intr++; in snd_harmony_interrupt()
221 spin_unlock(&h->lock); in snd_harmony_interrupt()
222 snd_pcm_period_elapsed(h->csubs); in snd_harmony_interrupt()
224 spin_lock(&h->lock); in snd_harmony_interrupt()
225 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_interrupt()
226 h->stats.graveyard_intr++; in snd_harmony_interrupt()
227 spin_unlock(&h->lock); in snd_harmony_interrupt()
231 spin_lock(&h->lock); in snd_harmony_interrupt()
232 harmony_enable_interrupts(h); in snd_harmony_interrupt()
233 spin_unlock(&h->lock); in snd_harmony_interrupt()
295 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_trigger() local
297 if (h->st.capturing) in snd_harmony_playback_trigger()
300 spin_lock(&h->lock); in snd_harmony_playback_trigger()
303 h->st.playing = 1; in snd_harmony_playback_trigger()
304 harmony_write(h, HARMONY_PNXTADD, h->pbuf.addr); in snd_harmony_playback_trigger()
305 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_playback_trigger()
306 harmony_unmute(h); in snd_harmony_playback_trigger()
307 harmony_enable_interrupts(h); in snd_harmony_playback_trigger()
310 h->st.playing = 0; in snd_harmony_playback_trigger()
311 harmony_mute(h); in snd_harmony_playback_trigger()
312 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_playback_trigger()
313 harmony_disable_interrupts(h); in snd_harmony_playback_trigger()
319 spin_unlock(&h->lock); in snd_harmony_playback_trigger()
323 spin_unlock(&h->lock); in snd_harmony_playback_trigger()
331 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_trigger() local
333 if (h->st.playing) in snd_harmony_capture_trigger()
336 spin_lock(&h->lock); in snd_harmony_capture_trigger()
339 h->st.capturing = 1; in snd_harmony_capture_trigger()
340 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_capture_trigger()
341 harmony_write(h, HARMONY_RNXTADD, h->cbuf.addr); in snd_harmony_capture_trigger()
342 harmony_unmute(h); in snd_harmony_capture_trigger()
343 harmony_enable_interrupts(h); in snd_harmony_capture_trigger()
346 h->st.capturing = 0; in snd_harmony_capture_trigger()
347 harmony_mute(h); in snd_harmony_capture_trigger()
348 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_capture_trigger()
349 harmony_disable_interrupts(h); in snd_harmony_capture_trigger()
355 spin_unlock(&h->lock); in snd_harmony_capture_trigger()
359 spin_unlock(&h->lock); in snd_harmony_capture_trigger()
365 snd_harmony_set_data_format(struct snd_harmony *h, int fmt, int force) in snd_harmony_set_data_format() argument
367 int o = h->st.format; in snd_harmony_set_data_format()
386 snd_pcm_format_set_silence(fmt, h->sdma.area, SILENCE_BUFSZ / in snd_harmony_set_data_format()
397 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_prepare() local
400 if (h->st.capturing) in snd_harmony_playback_prepare()
403 h->pbuf.size = snd_pcm_lib_buffer_bytes(ss); in snd_harmony_playback_prepare()
404 h->pbuf.count = snd_pcm_lib_period_bytes(ss); in snd_harmony_playback_prepare()
405 if (h->pbuf.buf >= h->pbuf.size) in snd_harmony_playback_prepare()
406 h->pbuf.buf = 0; in snd_harmony_playback_prepare()
407 h->st.playing = 0; in snd_harmony_playback_prepare()
409 h->st.rate = snd_harmony_rate_bits(rt->rate); in snd_harmony_playback_prepare()
410 h->st.format = snd_harmony_set_data_format(h, rt->format, 0); in snd_harmony_playback_prepare()
413 h->st.stereo = HARMONY_SS_STEREO; in snd_harmony_playback_prepare()
415 h->st.stereo = HARMONY_SS_MONO; in snd_harmony_playback_prepare()
417 harmony_set_control(h); in snd_harmony_playback_prepare()
419 h->pbuf.addr = rt->dma_addr; in snd_harmony_playback_prepare()
427 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_prepare() local
430 if (h->st.playing) in snd_harmony_capture_prepare()
433 h->cbuf.size = snd_pcm_lib_buffer_bytes(ss); in snd_harmony_capture_prepare()
434 h->cbuf.count = snd_pcm_lib_period_bytes(ss); in snd_harmony_capture_prepare()
435 if (h->cbuf.buf >= h->cbuf.size) in snd_harmony_capture_prepare()
436 h->cbuf.buf = 0; in snd_harmony_capture_prepare()
437 h->st.capturing = 0; in snd_harmony_capture_prepare()
439 h->st.rate = snd_harmony_rate_bits(rt->rate); in snd_harmony_capture_prepare()
440 h->st.format = snd_harmony_set_data_format(h, rt->format, 0); in snd_harmony_capture_prepare()
443 h->st.stereo = HARMONY_SS_STEREO; in snd_harmony_capture_prepare()
445 h->st.stereo = HARMONY_SS_MONO; in snd_harmony_capture_prepare()
447 harmony_set_control(h); in snd_harmony_capture_prepare()
449 h->cbuf.addr = rt->dma_addr; in snd_harmony_capture_prepare()
458 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_pointer() local
462 if (!(h->st.playing) || (h->psubs == NULL)) in snd_harmony_playback_pointer()
465 if ((h->pbuf.addr == 0) || (h->pbuf.size == 0)) in snd_harmony_playback_pointer()
468 pcuradd = harmony_read(h, HARMONY_PCURADD); in snd_harmony_playback_pointer()
469 played = pcuradd - h->pbuf.addr; in snd_harmony_playback_pointer()
473 pcuradd, h->pbuf.addr, played); in snd_harmony_playback_pointer()
476 if (pcuradd > h->pbuf.addr + h->pbuf.size) { in snd_harmony_playback_pointer()
487 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_pointer() local
491 if (!(h->st.capturing) || (h->csubs == NULL)) in snd_harmony_capture_pointer()
494 if ((h->cbuf.addr == 0) || (h->cbuf.size == 0)) in snd_harmony_capture_pointer()
497 rcuradd = harmony_read(h, HARMONY_RCURADD); in snd_harmony_capture_pointer()
498 caught = rcuradd - h->cbuf.addr; in snd_harmony_capture_pointer()
502 rcuradd, h->cbuf.addr, caught); in snd_harmony_capture_pointer()
505 if (rcuradd > h->cbuf.addr + h->cbuf.size) { in snd_harmony_capture_pointer()
515 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_open() local
519 h->psubs = ss; in snd_harmony_playback_open()
534 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_open() local
538 h->csubs = ss; in snd_harmony_capture_open()
553 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_close() local
554 h->psubs = NULL; in snd_harmony_playback_close()
561 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_close() local
562 h->csubs = NULL; in snd_harmony_capture_close()
570 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_hw_params() local
572 if (h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) in snd_harmony_hw_params()
597 snd_harmony_pcm_init(struct snd_harmony *h) in snd_harmony_pcm_init() argument
602 if (snd_BUG_ON(!h)) in snd_harmony_pcm_init()
605 harmony_disable_interrupts(h); in snd_harmony_pcm_init()
607 err = snd_pcm_new(h->card, "harmony", 0, 1, 1, &pcm); in snd_harmony_pcm_init()
616 pcm->private_data = h; in snd_harmony_pcm_init()
619 h->pcm = pcm; in snd_harmony_pcm_init()
621 h->psubs = NULL; in snd_harmony_pcm_init()
622 h->csubs = NULL; in snd_harmony_pcm_init()
625 h->dma.type = SNDRV_DMA_TYPE_DEV; in snd_harmony_pcm_init()
626 h->dma.dev = &h->dev->dev; in snd_harmony_pcm_init()
627 err = snd_dma_alloc_pages(h->dma.type, in snd_harmony_pcm_init()
628 h->dma.dev, in snd_harmony_pcm_init()
630 &h->gdma); in snd_harmony_pcm_init()
637 err = snd_dma_alloc_pages(h->dma.type, in snd_harmony_pcm_init()
638 h->dma.dev, in snd_harmony_pcm_init()
640 &h->sdma); in snd_harmony_pcm_init()
647 snd_pcm_set_managed_buffer_all(pcm, h->dma.type, h->dma.dev, in snd_harmony_pcm_init()
650 h->st.format = snd_harmony_set_data_format(h, in snd_harmony_pcm_init()
657 snd_harmony_set_new_gain(struct snd_harmony *h) in snd_harmony_set_new_gain() argument
659 harmony_wait_for_control(h); in snd_harmony_set_new_gain()
660 harmony_write(h, HARMONY_GAINCTL, h->st.gain); in snd_harmony_set_new_gain()
684 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_volume_get() local
691 spin_lock_irq(&h->mixer_lock); in snd_harmony_volume_get()
693 left = (h->st.gain >> shift_left) & mask; in snd_harmony_volume_get()
694 right = (h->st.gain >> shift_right) & mask; in snd_harmony_volume_get()
704 spin_unlock_irq(&h->mixer_lock); in snd_harmony_volume_get()
713 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_volume_put() local
719 int old_gain = h->st.gain; in snd_harmony_volume_put()
721 spin_lock_irq(&h->mixer_lock); in snd_harmony_volume_put()
726 h->st.gain &= ~( (mask << shift_left ) ); in snd_harmony_volume_put()
727 h->st.gain |= (left << shift_left); in snd_harmony_volume_put()
733 h->st.gain &= ~( (mask << shift_right) ); in snd_harmony_volume_put()
734 h->st.gain |= (right << shift_right); in snd_harmony_volume_put()
737 snd_harmony_set_new_gain(h); in snd_harmony_volume_put()
739 spin_unlock_irq(&h->mixer_lock); in snd_harmony_volume_put()
741 return h->st.gain != old_gain; in snd_harmony_volume_put()
757 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_captureroute_get() local
760 spin_lock_irq(&h->mixer_lock); in snd_harmony_captureroute_get()
762 value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; in snd_harmony_captureroute_get()
765 spin_unlock_irq(&h->mixer_lock); in snd_harmony_captureroute_get()
774 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_captureroute_put() local
776 int old_gain = h->st.gain; in snd_harmony_captureroute_put()
778 spin_lock_irq(&h->mixer_lock); in snd_harmony_captureroute_put()
781 h->st.gain &= ~HARMONY_GAIN_IS_MASK; in snd_harmony_captureroute_put()
782 h->st.gain |= value << HARMONY_GAIN_IS_SHIFT; in snd_harmony_captureroute_put()
784 snd_harmony_set_new_gain(h); in snd_harmony_captureroute_put()
786 spin_unlock_irq(&h->mixer_lock); in snd_harmony_captureroute_put()
788 return h->st.gain != old_gain; in snd_harmony_captureroute_put()
823 snd_harmony_mixer_reset(struct snd_harmony *h) in snd_harmony_mixer_reset() argument
825 harmony_mute(h); in snd_harmony_mixer_reset()
826 harmony_reset(h); in snd_harmony_mixer_reset()
827 h->st.gain = HARMONY_GAIN_DEFAULT; in snd_harmony_mixer_reset()
828 harmony_unmute(h); in snd_harmony_mixer_reset()
832 snd_harmony_mixer_init(struct snd_harmony *h) in snd_harmony_mixer_init() argument
837 if (snd_BUG_ON(!h)) in snd_harmony_mixer_init()
839 card = h->card; in snd_harmony_mixer_init()
844 snd_ctl_new1(&snd_harmony_controls[idx], h)); in snd_harmony_mixer_init()
849 snd_harmony_mixer_reset(h); in snd_harmony_mixer_init()
855 snd_harmony_free(struct snd_harmony *h) in snd_harmony_free() argument
857 if (h->gdma.addr) in snd_harmony_free()
858 snd_dma_free_pages(&h->gdma); in snd_harmony_free()
859 if (h->sdma.addr) in snd_harmony_free()
860 snd_dma_free_pages(&h->sdma); in snd_harmony_free()
862 if (h->irq >= 0) in snd_harmony_free()
863 free_irq(h->irq, h); in snd_harmony_free()
865 iounmap(h->iobase); in snd_harmony_free()
866 kfree(h); in snd_harmony_free()
873 struct snd_harmony *h = dev->device_data; in snd_harmony_dev_free() local
874 return snd_harmony_free(h); in snd_harmony_dev_free()
883 struct snd_harmony *h; in snd_harmony_create() local
890 h = kzalloc(sizeof(*h), GFP_KERNEL); in snd_harmony_create()
891 if (h == NULL) in snd_harmony_create()
894 h->hpa = padev->hpa.start; in snd_harmony_create()
895 h->card = card; in snd_harmony_create()
896 h->dev = padev; in snd_harmony_create()
897 h->irq = -1; in snd_harmony_create()
898 h->iobase = ioremap(padev->hpa.start, HARMONY_SIZE); in snd_harmony_create()
899 if (h->iobase == NULL) { in snd_harmony_create()
907 "harmony", h); in snd_harmony_create()
913 h->irq = padev->irq; in snd_harmony_create()
915 spin_lock_init(&h->mixer_lock); in snd_harmony_create()
916 spin_lock_init(&h->lock); in snd_harmony_create()
919 h, &ops)) < 0) { in snd_harmony_create()
923 *rchip = h; in snd_harmony_create()
928 snd_harmony_free(h); in snd_harmony_create()
937 struct snd_harmony *h; in snd_harmony_probe() local
943 err = snd_harmony_create(card, padev, &h); in snd_harmony_probe()
947 err = snd_harmony_pcm_init(h); in snd_harmony_probe()
951 err = snd_harmony_mixer_init(h); in snd_harmony_probe()
958 card->shortname, h->hpa, h->irq); in snd_harmony_probe()