Lines Matching refs:h

108 harmony_read(struct snd_harmony *h, unsigned r)  in harmony_read()  argument
110 return __raw_readl(h->iobase + r); in harmony_read()
114 harmony_write(struct snd_harmony *h, unsigned r, unsigned long v) in harmony_write() argument
116 __raw_writel(v, h->iobase + r); in harmony_write()
120 harmony_wait_for_control(struct snd_harmony *h) in harmony_wait_for_control() argument
122 while (harmony_read(h, HARMONY_CNTL) & HARMONY_CNTL_C) ; in harmony_wait_for_control()
126 harmony_reset(struct snd_harmony *h) in harmony_reset() argument
128 harmony_write(h, HARMONY_RESET, 1); in harmony_reset()
130 harmony_write(h, HARMONY_RESET, 0); in harmony_reset()
134 harmony_disable_interrupts(struct snd_harmony *h) in harmony_disable_interrupts() argument
137 harmony_wait_for_control(h); in harmony_disable_interrupts()
138 dstatus = harmony_read(h, HARMONY_DSTATUS); in harmony_disable_interrupts()
140 harmony_write(h, HARMONY_DSTATUS, dstatus); in harmony_disable_interrupts()
144 harmony_enable_interrupts(struct snd_harmony *h) in harmony_enable_interrupts() argument
147 harmony_wait_for_control(h); in harmony_enable_interrupts()
148 dstatus = harmony_read(h, HARMONY_DSTATUS); in harmony_enable_interrupts()
150 harmony_write(h, HARMONY_DSTATUS, dstatus); in harmony_enable_interrupts()
154 harmony_mute(struct snd_harmony *h) in harmony_mute() argument
158 spin_lock_irqsave(&h->mixer_lock, flags); in harmony_mute()
159 harmony_wait_for_control(h); in harmony_mute()
160 harmony_write(h, HARMONY_GAINCTL, HARMONY_GAIN_SILENCE); in harmony_mute()
161 spin_unlock_irqrestore(&h->mixer_lock, flags); in harmony_mute()
165 harmony_unmute(struct snd_harmony *h) in harmony_unmute() argument
169 spin_lock_irqsave(&h->mixer_lock, flags); in harmony_unmute()
170 harmony_wait_for_control(h); in harmony_unmute()
171 harmony_write(h, HARMONY_GAINCTL, h->st.gain); in harmony_unmute()
172 spin_unlock_irqrestore(&h->mixer_lock, flags); in harmony_unmute()
176 harmony_set_control(struct snd_harmony *h) in harmony_set_control() argument
181 spin_lock_irqsave(&h->lock, flags); in harmony_set_control()
184 (h->st.format << 6) | in harmony_set_control()
185 (h->st.stereo << 5) | in harmony_set_control()
186 (h->st.rate)); in harmony_set_control()
188 harmony_wait_for_control(h); in harmony_set_control()
189 harmony_write(h, HARMONY_CNTL, ctrl); in harmony_set_control()
191 spin_unlock_irqrestore(&h->lock, flags); in harmony_set_control()
198 struct snd_harmony *h = dev; in snd_harmony_interrupt() local
200 spin_lock(&h->lock); in snd_harmony_interrupt()
201 harmony_disable_interrupts(h); in snd_harmony_interrupt()
202 harmony_wait_for_control(h); in snd_harmony_interrupt()
203 dstatus = harmony_read(h, HARMONY_DSTATUS); in snd_harmony_interrupt()
204 spin_unlock(&h->lock); in snd_harmony_interrupt()
207 if (h->psubs && h->st.playing) { in snd_harmony_interrupt()
208 spin_lock(&h->lock); in snd_harmony_interrupt()
209 h->pbuf.buf += h->pbuf.count; /* PAGE_SIZE */ in snd_harmony_interrupt()
210 h->pbuf.buf %= h->pbuf.size; /* MAX_BUFS*PAGE_SIZE */ in snd_harmony_interrupt()
212 harmony_write(h, HARMONY_PNXTADD, in snd_harmony_interrupt()
213 h->pbuf.addr + h->pbuf.buf); in snd_harmony_interrupt()
214 h->stats.play_intr++; in snd_harmony_interrupt()
215 spin_unlock(&h->lock); in snd_harmony_interrupt()
216 snd_pcm_period_elapsed(h->psubs); in snd_harmony_interrupt()
218 spin_lock(&h->lock); in snd_harmony_interrupt()
219 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_interrupt()
220 h->stats.silence_intr++; in snd_harmony_interrupt()
221 spin_unlock(&h->lock); in snd_harmony_interrupt()
226 if (h->csubs && h->st.capturing) { in snd_harmony_interrupt()
227 spin_lock(&h->lock); in snd_harmony_interrupt()
228 h->cbuf.buf += h->cbuf.count; in snd_harmony_interrupt()
229 h->cbuf.buf %= h->cbuf.size; in snd_harmony_interrupt()
231 harmony_write(h, HARMONY_RNXTADD, in snd_harmony_interrupt()
232 h->cbuf.addr + h->cbuf.buf); in snd_harmony_interrupt()
233 h->stats.rec_intr++; in snd_harmony_interrupt()
234 spin_unlock(&h->lock); in snd_harmony_interrupt()
235 snd_pcm_period_elapsed(h->csubs); in snd_harmony_interrupt()
237 spin_lock(&h->lock); in snd_harmony_interrupt()
238 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_interrupt()
239 h->stats.graveyard_intr++; in snd_harmony_interrupt()
240 spin_unlock(&h->lock); in snd_harmony_interrupt()
244 spin_lock(&h->lock); in snd_harmony_interrupt()
245 harmony_enable_interrupts(h); in snd_harmony_interrupt()
246 spin_unlock(&h->lock); in snd_harmony_interrupt()
308 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_trigger() local
310 if (h->st.capturing) in snd_harmony_playback_trigger()
313 spin_lock(&h->lock); in snd_harmony_playback_trigger()
316 h->st.playing = 1; in snd_harmony_playback_trigger()
317 harmony_write(h, HARMONY_PNXTADD, h->pbuf.addr); in snd_harmony_playback_trigger()
318 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_playback_trigger()
319 harmony_unmute(h); in snd_harmony_playback_trigger()
320 harmony_enable_interrupts(h); in snd_harmony_playback_trigger()
323 h->st.playing = 0; in snd_harmony_playback_trigger()
324 harmony_mute(h); in snd_harmony_playback_trigger()
325 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_playback_trigger()
326 harmony_disable_interrupts(h); in snd_harmony_playback_trigger()
332 spin_unlock(&h->lock); in snd_harmony_playback_trigger()
336 spin_unlock(&h->lock); in snd_harmony_playback_trigger()
344 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_trigger() local
346 if (h->st.playing) in snd_harmony_capture_trigger()
349 spin_lock(&h->lock); in snd_harmony_capture_trigger()
352 h->st.capturing = 1; in snd_harmony_capture_trigger()
353 harmony_write(h, HARMONY_PNXTADD, h->sdma.addr); in snd_harmony_capture_trigger()
354 harmony_write(h, HARMONY_RNXTADD, h->cbuf.addr); in snd_harmony_capture_trigger()
355 harmony_unmute(h); in snd_harmony_capture_trigger()
356 harmony_enable_interrupts(h); in snd_harmony_capture_trigger()
359 h->st.capturing = 0; in snd_harmony_capture_trigger()
360 harmony_mute(h); in snd_harmony_capture_trigger()
361 harmony_write(h, HARMONY_RNXTADD, h->gdma.addr); in snd_harmony_capture_trigger()
362 harmony_disable_interrupts(h); in snd_harmony_capture_trigger()
368 spin_unlock(&h->lock); in snd_harmony_capture_trigger()
372 spin_unlock(&h->lock); in snd_harmony_capture_trigger()
378 snd_harmony_set_data_format(struct snd_harmony *h, int fmt, int force) in snd_harmony_set_data_format() argument
380 int o = h->st.format; in snd_harmony_set_data_format()
399 snd_pcm_format_set_silence(fmt, h->sdma.area, SILENCE_BUFSZ / in snd_harmony_set_data_format()
410 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_prepare() local
413 if (h->st.capturing) in snd_harmony_playback_prepare()
416 h->pbuf.size = snd_pcm_lib_buffer_bytes(ss); in snd_harmony_playback_prepare()
417 h->pbuf.count = snd_pcm_lib_period_bytes(ss); in snd_harmony_playback_prepare()
418 if (h->pbuf.buf >= h->pbuf.size) in snd_harmony_playback_prepare()
419 h->pbuf.buf = 0; in snd_harmony_playback_prepare()
420 h->st.playing = 0; in snd_harmony_playback_prepare()
422 h->st.rate = snd_harmony_rate_bits(rt->rate); in snd_harmony_playback_prepare()
423 h->st.format = snd_harmony_set_data_format(h, rt->format, 0); in snd_harmony_playback_prepare()
426 h->st.stereo = HARMONY_SS_STEREO; in snd_harmony_playback_prepare()
428 h->st.stereo = HARMONY_SS_MONO; in snd_harmony_playback_prepare()
430 harmony_set_control(h); in snd_harmony_playback_prepare()
432 h->pbuf.addr = rt->dma_addr; in snd_harmony_playback_prepare()
440 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_prepare() local
443 if (h->st.playing) in snd_harmony_capture_prepare()
446 h->cbuf.size = snd_pcm_lib_buffer_bytes(ss); in snd_harmony_capture_prepare()
447 h->cbuf.count = snd_pcm_lib_period_bytes(ss); in snd_harmony_capture_prepare()
448 if (h->cbuf.buf >= h->cbuf.size) in snd_harmony_capture_prepare()
449 h->cbuf.buf = 0; in snd_harmony_capture_prepare()
450 h->st.capturing = 0; in snd_harmony_capture_prepare()
452 h->st.rate = snd_harmony_rate_bits(rt->rate); in snd_harmony_capture_prepare()
453 h->st.format = snd_harmony_set_data_format(h, rt->format, 0); in snd_harmony_capture_prepare()
456 h->st.stereo = HARMONY_SS_STEREO; in snd_harmony_capture_prepare()
458 h->st.stereo = HARMONY_SS_MONO; in snd_harmony_capture_prepare()
460 harmony_set_control(h); in snd_harmony_capture_prepare()
462 h->cbuf.addr = rt->dma_addr; in snd_harmony_capture_prepare()
471 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_pointer() local
475 if (!(h->st.playing) || (h->psubs == NULL)) in snd_harmony_playback_pointer()
478 if ((h->pbuf.addr == 0) || (h->pbuf.size == 0)) in snd_harmony_playback_pointer()
481 pcuradd = harmony_read(h, HARMONY_PCURADD); in snd_harmony_playback_pointer()
482 played = pcuradd - h->pbuf.addr; in snd_harmony_playback_pointer()
486 pcuradd, h->pbuf.addr, played); in snd_harmony_playback_pointer()
489 if (pcuradd > h->pbuf.addr + h->pbuf.size) { in snd_harmony_playback_pointer()
500 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_pointer() local
504 if (!(h->st.capturing) || (h->csubs == NULL)) in snd_harmony_capture_pointer()
507 if ((h->cbuf.addr == 0) || (h->cbuf.size == 0)) in snd_harmony_capture_pointer()
510 rcuradd = harmony_read(h, HARMONY_RCURADD); in snd_harmony_capture_pointer()
511 caught = rcuradd - h->cbuf.addr; in snd_harmony_capture_pointer()
515 rcuradd, h->cbuf.addr, caught); in snd_harmony_capture_pointer()
518 if (rcuradd > h->cbuf.addr + h->cbuf.size) { in snd_harmony_capture_pointer()
528 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_open() local
532 h->psubs = ss; in snd_harmony_playback_open()
547 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_open() local
551 h->csubs = ss; in snd_harmony_capture_open()
566 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_playback_close() local
567 h->psubs = NULL; in snd_harmony_playback_close()
574 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_capture_close() local
575 h->csubs = NULL; in snd_harmony_capture_close()
584 struct snd_harmony *h = snd_pcm_substream_chip(ss); in snd_harmony_hw_params() local
587 if (err > 0 && h->dma.type == SNDRV_DMA_TYPE_CONTINUOUS) in snd_harmony_hw_params()
622 snd_harmony_pcm_init(struct snd_harmony *h) in snd_harmony_pcm_init() argument
627 if (snd_BUG_ON(!h)) in snd_harmony_pcm_init()
630 harmony_disable_interrupts(h); in snd_harmony_pcm_init()
632 err = snd_pcm_new(h->card, "harmony", 0, 1, 1, &pcm); in snd_harmony_pcm_init()
641 pcm->private_data = h; in snd_harmony_pcm_init()
644 h->pcm = pcm; in snd_harmony_pcm_init()
646 h->psubs = NULL; in snd_harmony_pcm_init()
647 h->csubs = NULL; in snd_harmony_pcm_init()
650 h->dma.type = SNDRV_DMA_TYPE_DEV; in snd_harmony_pcm_init()
651 h->dma.dev = &h->dev->dev; in snd_harmony_pcm_init()
652 err = snd_dma_alloc_pages(h->dma.type, in snd_harmony_pcm_init()
653 h->dma.dev, in snd_harmony_pcm_init()
655 &h->gdma); in snd_harmony_pcm_init()
662 err = snd_dma_alloc_pages(h->dma.type, in snd_harmony_pcm_init()
663 h->dma.dev, in snd_harmony_pcm_init()
665 &h->sdma); in snd_harmony_pcm_init()
672 err = snd_pcm_lib_preallocate_pages_for_all(pcm, h->dma.type, in snd_harmony_pcm_init()
673 h->dma.dev, in snd_harmony_pcm_init()
681 h->st.format = snd_harmony_set_data_format(h, in snd_harmony_pcm_init()
688 snd_harmony_set_new_gain(struct snd_harmony *h) in snd_harmony_set_new_gain() argument
690 harmony_wait_for_control(h); in snd_harmony_set_new_gain()
691 harmony_write(h, HARMONY_GAINCTL, h->st.gain); in snd_harmony_set_new_gain()
715 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_volume_get() local
722 spin_lock_irq(&h->mixer_lock); in snd_harmony_volume_get()
724 left = (h->st.gain >> shift_left) & mask; in snd_harmony_volume_get()
725 right = (h->st.gain >> shift_right) & mask; in snd_harmony_volume_get()
735 spin_unlock_irq(&h->mixer_lock); in snd_harmony_volume_get()
744 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_volume_put() local
750 int old_gain = h->st.gain; in snd_harmony_volume_put()
752 spin_lock_irq(&h->mixer_lock); in snd_harmony_volume_put()
757 h->st.gain &= ~( (mask << shift_left ) ); in snd_harmony_volume_put()
758 h->st.gain |= (left << shift_left); in snd_harmony_volume_put()
764 h->st.gain &= ~( (mask << shift_right) ); in snd_harmony_volume_put()
765 h->st.gain |= (right << shift_right); in snd_harmony_volume_put()
768 snd_harmony_set_new_gain(h); in snd_harmony_volume_put()
770 spin_unlock_irq(&h->mixer_lock); in snd_harmony_volume_put()
772 return h->st.gain != old_gain; in snd_harmony_volume_put()
788 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_captureroute_get() local
791 spin_lock_irq(&h->mixer_lock); in snd_harmony_captureroute_get()
793 value = (h->st.gain >> HARMONY_GAIN_IS_SHIFT) & 1; in snd_harmony_captureroute_get()
796 spin_unlock_irq(&h->mixer_lock); in snd_harmony_captureroute_get()
805 struct snd_harmony *h = snd_kcontrol_chip(kc); in snd_harmony_captureroute_put() local
807 int old_gain = h->st.gain; in snd_harmony_captureroute_put()
809 spin_lock_irq(&h->mixer_lock); in snd_harmony_captureroute_put()
812 h->st.gain &= ~HARMONY_GAIN_IS_MASK; in snd_harmony_captureroute_put()
813 h->st.gain |= value << HARMONY_GAIN_IS_SHIFT; in snd_harmony_captureroute_put()
815 snd_harmony_set_new_gain(h); in snd_harmony_captureroute_put()
817 spin_unlock_irq(&h->mixer_lock); in snd_harmony_captureroute_put()
819 return h->st.gain != old_gain; in snd_harmony_captureroute_put()
854 snd_harmony_mixer_reset(struct snd_harmony *h) in snd_harmony_mixer_reset() argument
856 harmony_mute(h); in snd_harmony_mixer_reset()
857 harmony_reset(h); in snd_harmony_mixer_reset()
858 h->st.gain = HARMONY_GAIN_DEFAULT; in snd_harmony_mixer_reset()
859 harmony_unmute(h); in snd_harmony_mixer_reset()
863 snd_harmony_mixer_init(struct snd_harmony *h) in snd_harmony_mixer_init() argument
868 if (snd_BUG_ON(!h)) in snd_harmony_mixer_init()
870 card = h->card; in snd_harmony_mixer_init()
875 snd_ctl_new1(&snd_harmony_controls[idx], h)); in snd_harmony_mixer_init()
880 snd_harmony_mixer_reset(h); in snd_harmony_mixer_init()
886 snd_harmony_free(struct snd_harmony *h) in snd_harmony_free() argument
888 if (h->gdma.addr) in snd_harmony_free()
889 snd_dma_free_pages(&h->gdma); in snd_harmony_free()
890 if (h->sdma.addr) in snd_harmony_free()
891 snd_dma_free_pages(&h->sdma); in snd_harmony_free()
893 if (h->irq >= 0) in snd_harmony_free()
894 free_irq(h->irq, h); in snd_harmony_free()
896 iounmap(h->iobase); in snd_harmony_free()
897 kfree(h); in snd_harmony_free()
904 struct snd_harmony *h = dev->device_data; in snd_harmony_dev_free() local
905 return snd_harmony_free(h); in snd_harmony_dev_free()
914 struct snd_harmony *h; in snd_harmony_create() local
921 h = kzalloc(sizeof(*h), GFP_KERNEL); in snd_harmony_create()
922 if (h == NULL) in snd_harmony_create()
925 h->hpa = padev->hpa.start; in snd_harmony_create()
926 h->card = card; in snd_harmony_create()
927 h->dev = padev; in snd_harmony_create()
928 h->irq = -1; in snd_harmony_create()
929 h->iobase = ioremap_nocache(padev->hpa.start, HARMONY_SIZE); in snd_harmony_create()
930 if (h->iobase == NULL) { in snd_harmony_create()
938 "harmony", h); in snd_harmony_create()
944 h->irq = padev->irq; in snd_harmony_create()
946 spin_lock_init(&h->mixer_lock); in snd_harmony_create()
947 spin_lock_init(&h->lock); in snd_harmony_create()
950 h, &ops)) < 0) { in snd_harmony_create()
954 *rchip = h; in snd_harmony_create()
959 snd_harmony_free(h); in snd_harmony_create()
968 struct snd_harmony *h; in snd_harmony_probe() local
974 err = snd_harmony_create(card, padev, &h); in snd_harmony_probe()
978 err = snd_harmony_pcm_init(h); in snd_harmony_probe()
982 err = snd_harmony_mixer_init(h); in snd_harmony_probe()
989 card->shortname, h->hpa, h->irq); in snd_harmony_probe()