Lines Matching refs:hal2

116 static u32 hal2_i_read32(struct snd_hal2 *hal2, u16 addr)  in hal2_i_read32()  argument
119 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_read32()
130 static void hal2_i_write16(struct snd_hal2 *hal2, u16 addr, u16 val) in hal2_i_write16() argument
132 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_write16()
142 static void hal2_i_write32(struct snd_hal2 *hal2, u16 addr, u32 val) in hal2_i_write32() argument
144 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_write32()
154 static void hal2_i_setbit16(struct snd_hal2 *hal2, u16 addr, u16 bit) in hal2_i_setbit16() argument
156 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_setbit16()
168 static void hal2_i_clearbit16(struct snd_hal2 *hal2, u16 addr, u16 bit) in hal2_i_clearbit16() argument
170 struct hal2_ctl_regs *regs = hal2->ctl_regs; in hal2_i_clearbit16()
202 struct snd_hal2 *hal2 = snd_kcontrol_chip(kcontrol); in hal2_gain_get() local
208 tmp = hal2_i_read32(hal2, H2I_DAC_C2); in hal2_gain_get()
218 tmp = hal2_i_read32(hal2, H2I_ADC_C2); in hal2_gain_get()
234 struct snd_hal2 *hal2 = snd_kcontrol_chip(kcontrol); in hal2_gain_put() local
243 old = hal2_i_read32(hal2, H2I_DAC_C2); in hal2_gain_put()
252 hal2_i_write32(hal2, H2I_DAC_C2, new); in hal2_gain_put()
255 old = hal2_i_read32(hal2, H2I_ADC_C2); in hal2_gain_put()
259 hal2_i_write32(hal2, H2I_ADC_C2, new); in hal2_gain_put()
287 static int hal2_mixer_create(struct snd_hal2 *hal2) in hal2_mixer_create() argument
292 hal2_i_write32(hal2, H2I_DAC_C2, in hal2_mixer_create()
295 hal2_i_write32(hal2, H2I_ADC_C2, 0); in hal2_mixer_create()
297 err = snd_ctl_add(hal2->card, in hal2_mixer_create()
298 snd_ctl_new1(&hal2_ctrl_headphone, hal2)); in hal2_mixer_create()
302 err = snd_ctl_add(hal2->card, in hal2_mixer_create()
303 snd_ctl_new1(&hal2_ctrl_mic, hal2)); in hal2_mixer_create()
312 struct snd_hal2 *hal2 = dev_id; in hal2_interrupt() local
316 if (hal2->dac.pbus.pbus->pbdma_ctrl & HPC3_PDMACTRL_INT) { in hal2_interrupt()
317 snd_pcm_period_elapsed(hal2->dac.substream); in hal2_interrupt()
320 if (hal2->adc.pbus.pbus->pbdma_ctrl & HPC3_PDMACTRL_INT) { in hal2_interrupt()
321 snd_pcm_period_elapsed(hal2->adc.substream); in hal2_interrupt()
346 static void hal2_set_dac_rate(struct snd_hal2 *hal2) in hal2_set_dac_rate() argument
348 unsigned int master = hal2->dac.master; in hal2_set_dac_rate()
349 int inc = hal2->dac.inc; in hal2_set_dac_rate()
350 int mod = hal2->dac.mod; in hal2_set_dac_rate()
352 hal2_i_write16(hal2, H2I_BRES1_C1, (master == 44100) ? 1 : 0); in hal2_set_dac_rate()
353 hal2_i_write32(hal2, H2I_BRES1_C2, in hal2_set_dac_rate()
357 static void hal2_set_adc_rate(struct snd_hal2 *hal2) in hal2_set_adc_rate() argument
359 unsigned int master = hal2->adc.master; in hal2_set_adc_rate()
360 int inc = hal2->adc.inc; in hal2_set_adc_rate()
361 int mod = hal2->adc.mod; in hal2_set_adc_rate()
363 hal2_i_write16(hal2, H2I_BRES2_C1, (master == 44100) ? 1 : 0); in hal2_set_adc_rate()
364 hal2_i_write32(hal2, H2I_BRES2_C2, in hal2_set_adc_rate()
368 static void hal2_setup_dac(struct snd_hal2 *hal2) in hal2_setup_dac() argument
371 struct hal2_pbus *pbus = &hal2->dac.pbus; in hal2_setup_dac()
378 sample_size = 2 * hal2->dac.voices; in hal2_setup_dac()
388 hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECTX); in hal2_setup_dac()
390 hal2_set_dac_rate(hal2); in hal2_setup_dac()
392 hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECTX); in hal2_setup_dac()
394 hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr)); in hal2_setup_dac()
396 hal2_i_write16(hal2, H2I_DAC_C1, (pbus->pbusnr << H2I_C1_DMA_SHIFT) in hal2_setup_dac()
398 | (hal2->dac.voices << H2I_C1_DATAT_SHIFT)); in hal2_setup_dac()
401 static void hal2_setup_adc(struct snd_hal2 *hal2) in hal2_setup_adc() argument
404 struct hal2_pbus *pbus = &hal2->adc.pbus; in hal2_setup_adc()
406 sample_size = 2 * hal2->adc.voices; in hal2_setup_adc()
413 hal2_i_clearbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECR); in hal2_setup_adc()
415 hal2_set_adc_rate(hal2); in hal2_setup_adc()
417 hal2_i_clearbit16(hal2, H2I_DMA_END, H2I_DMA_END_CODECR); in hal2_setup_adc()
419 hal2_i_setbit16(hal2, H2I_DMA_DRV, (1 << pbus->pbusnr)); in hal2_setup_adc()
421 hal2_i_write16(hal2, H2I_ADC_C1, (pbus->pbusnr << H2I_C1_DMA_SHIFT) in hal2_setup_adc()
423 | (hal2->adc.voices << H2I_C1_DATAT_SHIFT)); in hal2_setup_adc()
426 static void hal2_start_dac(struct snd_hal2 *hal2) in hal2_start_dac() argument
428 struct hal2_pbus *pbus = &hal2->dac.pbus; in hal2_start_dac()
430 pbus->pbus->pbdma_dptr = hal2->dac.desc_dma; in hal2_start_dac()
433 hal2_i_setbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECTX); in hal2_start_dac()
436 static void hal2_start_adc(struct snd_hal2 *hal2) in hal2_start_adc() argument
438 struct hal2_pbus *pbus = &hal2->adc.pbus; in hal2_start_adc()
440 pbus->pbus->pbdma_dptr = hal2->adc.desc_dma; in hal2_start_adc()
443 hal2_i_setbit16(hal2, H2I_DMA_PORT_EN, H2I_DMA_PORT_EN_CODECR); in hal2_start_adc()
446 static inline void hal2_stop_dac(struct snd_hal2 *hal2) in hal2_stop_dac() argument
448 hal2->dac.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; in hal2_stop_dac()
452 static inline void hal2_stop_adc(struct snd_hal2 *hal2) in hal2_stop_adc() argument
454 hal2->adc.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; in hal2_stop_adc()
537 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_open() local
542 err = hal2_alloc_dmabuf(&hal2->dac); in hal2_playback_open()
550 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_close() local
552 hal2_free_dmabuf(&hal2->dac); in hal2_playback_close()
558 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_prepare() local
560 struct hal2_codec *dac = &hal2->dac; in hal2_playback_prepare()
568 hal2_setup_dac(hal2); in hal2_playback_prepare()
574 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_trigger() local
578 hal2->dac.pcm_indirect.hw_io = hal2->dac.buffer_dma; in hal2_playback_trigger()
579 hal2->dac.pcm_indirect.hw_data = 0; in hal2_playback_trigger()
581 hal2_start_dac(hal2); in hal2_playback_trigger()
584 hal2_stop_dac(hal2); in hal2_playback_trigger()
595 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_pointer() local
596 struct hal2_codec *dac = &hal2->dac; in hal2_playback_pointer()
605 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_transfer() local
606 unsigned char *buf = hal2->dac.buffer + rec->hw_data; in hal2_playback_transfer()
615 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_playback_ack() local
616 struct hal2_codec *dac = &hal2->dac; in hal2_playback_ack()
627 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_open() local
628 struct hal2_codec *adc = &hal2->adc; in hal2_capture_open()
641 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_close() local
643 hal2_free_dmabuf(&hal2->adc); in hal2_capture_close()
649 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_prepare() local
651 struct hal2_codec *adc = &hal2->adc; in hal2_capture_prepare()
660 hal2_setup_adc(hal2); in hal2_capture_prepare()
666 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_trigger() local
670 hal2->adc.pcm_indirect.hw_io = hal2->adc.buffer_dma; in hal2_capture_trigger()
671 hal2->adc.pcm_indirect.hw_data = 0; in hal2_capture_trigger()
672 printk(KERN_DEBUG "buffer_dma %x\n", hal2->adc.buffer_dma); in hal2_capture_trigger()
673 hal2_start_adc(hal2); in hal2_capture_trigger()
676 hal2_stop_adc(hal2); in hal2_capture_trigger()
687 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_pointer() local
688 struct hal2_codec *adc = &hal2->adc; in hal2_capture_pointer()
697 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_transfer() local
698 unsigned char *buf = hal2->adc.buffer + rec->hw_data; in hal2_capture_transfer()
706 struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); in hal2_capture_ack() local
707 struct hal2_codec *adc = &hal2->adc; in hal2_capture_ack()
738 static int hal2_pcm_create(struct snd_hal2 *hal2) in hal2_pcm_create() argument
744 err = snd_pcm_new(hal2->card, "SGI HAL2 Audio", 0, 1, 1, &pcm); in hal2_pcm_create()
748 pcm->private_data = hal2; in hal2_pcm_create()
765 struct snd_hal2 *hal2 = device->device_data; in hal2_dev_free() local
767 free_irq(SGI_HPCDMA_IRQ, hal2); in hal2_dev_free()
768 kfree(hal2); in hal2_dev_free()
783 static int hal2_detect(struct snd_hal2 *hal2) in hal2_detect() argument
789 hal2_write(0, &hal2->ctl_regs->isr); in hal2_detect()
793 &hal2->ctl_regs->isr); in hal2_detect()
796 hal2_i_write16(hal2, H2I_RELAY_C, H2I_RELAY_C_STATE); in hal2_detect()
797 rev = hal2_read(&hal2->ctl_regs->rev); in hal2_detect()
813 struct snd_hal2 *hal2; in hal2_create() local
817 hal2 = kzalloc(sizeof(*hal2), GFP_KERNEL); in hal2_create()
818 if (!hal2) in hal2_create()
821 hal2->card = card; in hal2_create()
824 "SGI HAL2", hal2)) { in hal2_create()
826 kfree(hal2); in hal2_create()
830 hal2->ctl_regs = (struct hal2_ctl_regs *)hpc3->pbus_extregs[0]; in hal2_create()
831 hal2->aes_regs = (struct hal2_aes_regs *)hpc3->pbus_extregs[1]; in hal2_create()
832 hal2->vol_regs = (struct hal2_vol_regs *)hpc3->pbus_extregs[2]; in hal2_create()
833 hal2->syn_regs = (struct hal2_syn_regs *)hpc3->pbus_extregs[3]; in hal2_create()
835 if (hal2_detect(hal2) < 0) { in hal2_create()
836 kfree(hal2); in hal2_create()
840 hal2_init_codec(&hal2->dac, hpc3, 0); in hal2_create()
841 hal2_init_codec(&hal2->adc, hpc3, 1); in hal2_create()
866 hpc3->pbus_dmacfg[hal2->dac.pbus.pbusnr][0] = 0x8208844; in hal2_create()
867 hpc3->pbus_dmacfg[hal2->adc.pbus.pbusnr][0] = 0x8208844; in hal2_create()
869 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, hal2, &hal2_ops); in hal2_create()
871 free_irq(SGI_HPCDMA_IRQ, hal2); in hal2_create()
872 kfree(hal2); in hal2_create()
875 *rchip = hal2; in hal2_create()