Lines Matching refs:hal2

103 static u32 hal2_i_read32(struct snd_hal2 *hal2, u16 addr)  in hal2_i_read32()  argument
106 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_read32()
117 static void hal2_i_write16(struct snd_hal2 *hal2, u16 addr, u16 val) in hal2_i_write16() argument
119 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_write16()
129 static void hal2_i_write32(struct snd_hal2 *hal2, u16 addr, u32 val) in hal2_i_write32() argument
131 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_write32()
141 static void hal2_i_setbit16(struct snd_hal2 *hal2, u16 addr, u16 bit) in hal2_i_setbit16() argument
143 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_setbit16()
155 static void hal2_i_clearbit16(struct snd_hal2 *hal2, u16 addr, u16 bit) in hal2_i_clearbit16() argument
157 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_clearbit16()
189 struct snd_hal2 *hal2 = snd_kcontrol_chip(kcontrol); in hal2_gain_get() local
195 tmp = hal2_i_read32(hal2, H2I_DAC_C2); in hal2_gain_get()
205 tmp = hal2_i_read32(hal2, H2I_ADC_C2); in hal2_gain_get()
221 struct snd_hal2 *hal2 = snd_kcontrol_chip(kcontrol); in hal2_gain_put() local
230 old = hal2_i_read32(hal2, H2I_DAC_C2); in hal2_gain_put()
239 hal2_i_write32(hal2, H2I_DAC_C2, new); in hal2_gain_put()
242 old = hal2_i_read32(hal2, H2I_ADC_C2); in hal2_gain_put()
246 hal2_i_write32(hal2, H2I_ADC_C2, new); in hal2_gain_put()
274 static int hal2_mixer_create(struct snd_hal2 *hal2) in hal2_mixer_create() argument
279 hal2_i_write32(hal2, H2I_DAC_C2, in hal2_mixer_create()
282 hal2_i_write32(hal2, H2I_ADC_C2, 0); in hal2_mixer_create()
284 err = snd_ctl_add(hal2->card, in hal2_mixer_create()
285 snd_ctl_new1(&hal2_ctrl_headphone, hal2)); in hal2_mixer_create()
289 err = snd_ctl_add(hal2->card, in hal2_mixer_create()
290 snd_ctl_new1(&hal2_ctrl_mic, hal2)); in hal2_mixer_create()
299 struct snd_hal2 *hal2 = dev_id; in hal2_interrupt() local
303 if (hal2->dac.pbus.pbus->pbdma_ctrl & HPC3_PDMACTRL_INT) { in hal2_interrupt()
304 snd_pcm_period_elapsed(hal2->dac.substream); in hal2_interrupt()
307 if (hal2->adc.pbus.pbus->pbdma_ctrl & HPC3_PDMACTRL_INT) { in hal2_interrupt()
308 snd_pcm_period_elapsed(hal2->adc.substream); in hal2_interrupt()
333 static void hal2_set_dac_rate(struct snd_hal2 *hal2) in hal2_set_dac_rate() argument
335 unsigned int master = hal2->dac.master; in hal2_set_dac_rate()
336 int inc = hal2->dac.inc; in hal2_set_dac_rate()
337 int mod = hal2->dac.mod; in hal2_set_dac_rate()
339 hal2_i_write16(hal2, H2I_BRES1_C1, (master == 44100) ? 1 : 0); in hal2_set_dac_rate()
340 hal2_i_write32(hal2, H2I_BRES1_C2, in hal2_set_dac_rate()
344 static void hal2_set_adc_rate(struct snd_hal2 *hal2) in hal2_set_adc_rate() argument
346 unsigned int master = hal2->adc.master; in hal2_set_adc_rate()
347 int inc = hal2->adc.inc; in hal2_set_adc_rate()
348 int mod = hal2->adc.mod; in hal2_set_adc_rate()
350 hal2_i_write16(hal2, H2I_BRES2_C1, (master == 44100) ? 1 : 0); in hal2_set_adc_rate()
351 hal2_i_write32(hal2, H2I_BRES2_C2, in hal2_set_adc_rate()
355 static void hal2_setup_dac(struct snd_hal2 *hal2) in hal2_setup_dac() argument
358 struct hal2_pbus *pbus = &hal2->dac.pbus; in hal2_setup_dac()
365 sample_size = 2 * hal2->dac.voices; in hal2_setup_dac()
375 hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECTX); in hal2_setup_dac()
377 hal2_set_dac_rate(hal2); in hal2_setup_dac()
379 hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECTX); in hal2_setup_dac()
381 hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr)); in hal2_setup_dac()
383 hal2_i_write16(hal2, H2I_DAC_C1, (pbus->pbusnr << H2I_C1_DMA_SHIFT) in hal2_setup_dac()
385 | (hal2->dac.voices << H2I_C1_DATAT_SHIFT)); in hal2_setup_dac()
388 static void hal2_setup_adc(struct snd_hal2 *hal2) in hal2_setup_adc() argument
391 struct hal2_pbus *pbus = &hal2->adc.pbus; in hal2_setup_adc()
393 sample_size = 2 * hal2->adc.voices; in hal2_setup_adc()
400 hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECR); in hal2_setup_adc()
402 hal2_set_adc_rate(hal2); in hal2_setup_adc()
404 hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECR); in hal2_setup_adc()
406 hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr)); in hal2_setup_adc()
408 hal2_i_write16(hal2, H2I_ADC_C1, (pbus->pbusnr << H2I_C1_DMA_SHIFT) in hal2_setup_adc()
410 | (hal2->adc.voices << H2I_C1_DATAT_SHIFT)); in hal2_setup_adc()
413 static void hal2_start_dac(struct snd_hal2 *hal2) in hal2_start_dac() argument
415 struct hal2_pbus *pbus = &hal2->dac.pbus; in hal2_start_dac()
417 pbus->pbus->pbdma_dptr = hal2->dac.desc_dma; in hal2_start_dac()
420 hal2_i_setbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECTX); in hal2_start_dac()
423 static void hal2_start_adc(struct snd_hal2 *hal2) in hal2_start_adc() argument
425 struct hal2_pbus *pbus = &hal2->adc.pbus; in hal2_start_adc()
427 pbus->pbus->pbdma_dptr = hal2->adc.desc_dma; in hal2_start_adc()
430 hal2_i_setbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECR); in hal2_start_adc()
433 static inline void hal2_stop_dac(struct snd_hal2 *hal2) in hal2_stop_dac() argument
435 hal2->dac.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; in hal2_stop_dac()
439 static inline void hal2_stop_adc(struct snd_hal2 *hal2) in hal2_stop_adc() argument
441 hal2->adc.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; in hal2_stop_adc()
444 static int hal2_alloc_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec, in hal2_alloc_dmabuf() argument
447 struct device *dev = hal2->card->dev; in hal2_alloc_dmabuf()
481 static void hal2_free_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec, in hal2_free_dmabuf() argument
484 struct device *dev = hal2->card->dev; in hal2_free_dmabuf()
514 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_open() local
517 return hal2_alloc_dmabuf(hal2, &hal2->dac, DMA_TO_DEVICE); in hal2_playback_open()
522 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_close() local
524 hal2_free_dmabuf(hal2, &hal2->dac, DMA_TO_DEVICE); in hal2_playback_close()
530 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_prepare() local
532 struct hal2_codec *dac = &hal2->dac; in hal2_playback_prepare()
542 hal2_setup_dac(hal2); in hal2_playback_prepare()
548 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_trigger() local
552 hal2_start_dac(hal2); in hal2_playback_trigger()
555 hal2_stop_dac(hal2); in hal2_playback_trigger()
566 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_pointer() local
567 struct hal2_codec *dac = &hal2->dac; in hal2_playback_pointer()
576 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_transfer() local
577 unsigned char *buf = hal2->dac.buffer + rec->hw_data; in hal2_playback_transfer()
580 dma_sync_single_for_device(hal2->card->dev, in hal2_playback_transfer()
581 hal2->dac.buffer_dma + rec->hw_data, bytes, in hal2_playback_transfer()
588 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_ack() local
589 struct hal2_codec *dac = &hal2->dac; in hal2_playback_ack()
599 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_open() local
602 return hal2_alloc_dmabuf(hal2, &hal2->adc, DMA_FROM_DEVICE); in hal2_capture_open()
607 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_close() local
609 hal2_free_dmabuf(hal2, &hal2->adc, DMA_FROM_DEVICE); in hal2_capture_close()
615 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_prepare() local
617 struct hal2_codec *adc = &hal2->adc; in hal2_capture_prepare()
627 hal2_setup_adc(hal2); in hal2_capture_prepare()
633 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_trigger() local
637 hal2_start_adc(hal2); in hal2_capture_trigger()
640 hal2_stop_adc(hal2); in hal2_capture_trigger()
651 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_pointer() local
652 struct hal2_codec *adc = &hal2->adc; in hal2_capture_pointer()
661 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_transfer() local
662 unsigned char *buf = hal2->adc.buffer + rec->hw_data; in hal2_capture_transfer()
664 dma_sync_single_for_cpu(hal2->card->dev, in hal2_capture_transfer()
665 hal2->adc.buffer_dma + rec->hw_data, bytes, in hal2_capture_transfer()
672 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_ack() local
673 struct hal2_codec *adc = &hal2->adc; in hal2_capture_ack()
698 static int hal2_pcm_create(struct snd_hal2 *hal2) in hal2_pcm_create() argument
704 err = snd_pcm_new(hal2->card, "SGI HAL2 Audio", 0, 1, 1, &pcm); in hal2_pcm_create()
708 pcm->private_data = hal2; in hal2_pcm_create()
724 struct snd_hal2 *hal2 = device->device_data; in hal2_dev_free() local
726 free_irq(SGI_HPCDMA_IRQ, hal2); in hal2_dev_free()
727 kfree(hal2); in hal2_dev_free()
742 static int hal2_detect(struct snd_hal2 *hal2) in hal2_detect() argument
748 hal2_write(0, &hal2->ctl_regs->isr); in hal2_detect()
752 &hal2->ctl_regs->isr); in hal2_detect()
755 hal2_i_write16(hal2, H2I_RELAY_C, H2I_RELAY_C_STATE); in hal2_detect()
756 rev = hal2_read(&hal2->ctl_regs->rev); in hal2_detect()
772 struct snd_hal2 *hal2; in hal2_create() local
776 hal2 = kzalloc(sizeof(*hal2), GFP_KERNEL); in hal2_create()
777 if (!hal2) in hal2_create()
780 hal2->card = card; in hal2_create()
783 "SGI HAL2", hal2)) { in hal2_create()
785 kfree(hal2); in hal2_create()
789 hal2->ctl_regs = (struct hal2_ctl_regs *)hpc3->pbus_extregs[0]; in hal2_create()
790 hal2->aes_regs = (struct hal2_aes_regs *)hpc3->pbus_extregs[1]; in hal2_create()
791 hal2->vol_regs = (struct hal2_vol_regs *)hpc3->pbus_extregs[2]; in hal2_create()
792 hal2->syn_regs = (struct hal2_syn_regs *)hpc3->pbus_extregs[3]; in hal2_create()
794 if (hal2_detect(hal2) < 0) { in hal2_create()
795 kfree(hal2); in hal2_create()
799 hal2_init_codec(&hal2->dac, hpc3, 0); in hal2_create()
800 hal2_init_codec(&hal2->adc, hpc3, 1); in hal2_create()
825 hpc3->pbus_dmacfg[hal2->dac.pbus.pbusnr][0] = 0x8208844; in hal2_create()
826 hpc3->pbus_dmacfg[hal2->adc.pbus.pbusnr][0] = 0x8208844; in hal2_create()
828 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, hal2, &hal2_ops); in hal2_create()
830 free_irq(SGI_HPCDMA_IRQ, hal2); in hal2_create()
831 kfree(hal2); in hal2_create()
834 *rchip = hal2; in hal2_create()