Lines Matching refs:chip
217 static inline u32 snd_bt87x_readl(struct snd_bt87x *chip, u32 reg) in snd_bt87x_readl() argument
219 return readl(chip->mmio + reg); in snd_bt87x_readl()
222 static inline void snd_bt87x_writel(struct snd_bt87x *chip, u32 reg, u32 value) in snd_bt87x_writel() argument
224 writel(value, chip->mmio + reg); in snd_bt87x_writel()
227 static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substream *substream, in snd_bt87x_create_risc() argument
233 if (chip->dma_risc.area == NULL) { in snd_bt87x_create_risc()
234 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(chip->pci), in snd_bt87x_create_risc()
235 PAGE_ALIGN(MAX_RISC_SIZE), &chip->dma_risc) < 0) in snd_bt87x_create_risc()
238 risc = (u32 *)chip->dma_risc.area; in snd_bt87x_create_risc()
272 *risc++ = cpu_to_le32(chip->dma_risc.addr); in snd_bt87x_create_risc()
273 chip->line_bytes = period_bytes; in snd_bt87x_create_risc()
274 chip->lines = periods; in snd_bt87x_create_risc()
278 static void snd_bt87x_free_risc(struct snd_bt87x *chip) in snd_bt87x_free_risc() argument
280 if (chip->dma_risc.area) { in snd_bt87x_free_risc()
281 snd_dma_free_pages(&chip->dma_risc); in snd_bt87x_free_risc()
282 chip->dma_risc.area = NULL; in snd_bt87x_free_risc()
286 static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status) in snd_bt87x_pci_error() argument
290 pci_read_config_word(chip->pci, PCI_STATUS, &pci_status); in snd_bt87x_pci_error()
294 pci_write_config_word(chip->pci, PCI_STATUS, pci_status); in snd_bt87x_pci_error()
296 dev_err(chip->card->dev, in snd_bt87x_pci_error()
300 dev_err(chip->card->dev, in snd_bt87x_pci_error()
303 chip->pci_parity_errors++; in snd_bt87x_pci_error()
304 if (chip->pci_parity_errors > 20) { in snd_bt87x_pci_error()
305 dev_err(chip->card->dev, in snd_bt87x_pci_error()
307 dev_err(chip->card->dev, in snd_bt87x_pci_error()
309 dev_err(chip->card->dev, in snd_bt87x_pci_error()
311 dev_err(chip->card->dev, in snd_bt87x_pci_error()
313 chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR); in snd_bt87x_pci_error()
314 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); in snd_bt87x_pci_error()
321 struct snd_bt87x *chip = dev_id; in snd_bt87x_interrupt() local
324 status = snd_bt87x_readl(chip, REG_INT_STAT); in snd_bt87x_interrupt()
325 irq_status = status & chip->interrupt_mask; in snd_bt87x_interrupt()
328 snd_bt87x_writel(chip, REG_INT_STAT, irq_status); in snd_bt87x_interrupt()
332 dev_warn(chip->card->dev, in snd_bt87x_interrupt()
335 dev_err(chip->card->dev, in snd_bt87x_interrupt()
338 snd_bt87x_pci_error(chip, irq_status); in snd_bt87x_interrupt()
340 if ((irq_status & INT_RISCI) && (chip->reg_control & CTL_ACAP_EN)) { in snd_bt87x_interrupt()
344 chip->current_line = (chip->current_line + 1) % chip->lines; in snd_bt87x_interrupt()
346 current_block = chip->current_line * 16 / chip->lines; in snd_bt87x_interrupt()
349 chip->current_line = (irq_block * chip->lines + 15) / 16; in snd_bt87x_interrupt()
351 snd_pcm_period_elapsed(chip->substream); in snd_bt87x_interrupt()
392 static int snd_bt87x_set_digital_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) in snd_bt87x_set_digital_hw() argument
394 chip->reg_control |= CTL_DA_IOM_DA | CTL_A_PWRDN; in snd_bt87x_set_digital_hw()
396 runtime->hw.rates = snd_pcm_rate_to_rate_bit(chip->board.dig_rate); in snd_bt87x_set_digital_hw()
397 runtime->hw.rate_min = chip->board.dig_rate; in snd_bt87x_set_digital_hw()
398 runtime->hw.rate_max = chip->board.dig_rate; in snd_bt87x_set_digital_hw()
402 static int snd_bt87x_set_analog_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) in snd_bt87x_set_analog_hw() argument
415 chip->reg_control &= ~(CTL_DA_IOM_DA | CTL_A_PWRDN); in snd_bt87x_set_analog_hw()
423 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_pcm_open() local
427 if (test_and_set_bit(0, &chip->opened)) in snd_bt87x_pcm_open()
431 err = snd_bt87x_set_digital_hw(chip, runtime); in snd_bt87x_pcm_open()
433 err = snd_bt87x_set_analog_hw(chip, runtime); in snd_bt87x_pcm_open()
441 chip->substream = substream; in snd_bt87x_pcm_open()
445 clear_bit(0, &chip->opened); in snd_bt87x_pcm_open()
452 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_close() local
454 spin_lock_irq(&chip->reg_lock); in snd_bt87x_close()
455 chip->reg_control |= CTL_A_PWRDN; in snd_bt87x_close()
456 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_close()
457 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_close()
459 chip->substream = NULL; in snd_bt87x_close()
460 clear_bit(0, &chip->opened); in snd_bt87x_close()
468 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_hw_params() local
475 return snd_bt87x_create_risc(chip, substream, in snd_bt87x_hw_params()
482 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_hw_free() local
484 snd_bt87x_free_risc(chip); in snd_bt87x_hw_free()
491 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_prepare() local
495 spin_lock_irq(&chip->reg_lock); in snd_bt87x_prepare()
496 chip->reg_control &= ~(CTL_DA_SDR_MASK | CTL_DA_SBR); in snd_bt87x_prepare()
498 chip->reg_control |= decimation << CTL_DA_SDR_SHIFT; in snd_bt87x_prepare()
500 chip->reg_control |= CTL_DA_SBR; in snd_bt87x_prepare()
501 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_prepare()
502 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_prepare()
506 static int snd_bt87x_start(struct snd_bt87x *chip) in snd_bt87x_start() argument
508 spin_lock(&chip->reg_lock); in snd_bt87x_start()
509 chip->current_line = 0; in snd_bt87x_start()
510 chip->reg_control |= CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN; in snd_bt87x_start()
511 snd_bt87x_writel(chip, REG_RISC_STRT_ADD, chip->dma_risc.addr); in snd_bt87x_start()
512 snd_bt87x_writel(chip, REG_PACKET_LEN, in snd_bt87x_start()
513 chip->line_bytes | (chip->lines << 16)); in snd_bt87x_start()
514 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); in snd_bt87x_start()
515 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_start()
516 spin_unlock(&chip->reg_lock); in snd_bt87x_start()
520 static int snd_bt87x_stop(struct snd_bt87x *chip) in snd_bt87x_stop() argument
522 spin_lock(&chip->reg_lock); in snd_bt87x_stop()
523 chip->reg_control &= ~(CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN); in snd_bt87x_stop()
524 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_stop()
525 snd_bt87x_writel(chip, REG_INT_MASK, 0); in snd_bt87x_stop()
526 snd_bt87x_writel(chip, REG_INT_STAT, MY_INTERRUPTS); in snd_bt87x_stop()
527 spin_unlock(&chip->reg_lock); in snd_bt87x_stop()
533 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_trigger() local
537 return snd_bt87x_start(chip); in snd_bt87x_trigger()
539 return snd_bt87x_stop(chip); in snd_bt87x_trigger()
547 struct snd_bt87x *chip = snd_pcm_substream_chip(substream); in snd_bt87x_pointer() local
550 return (snd_pcm_uframes_t)bytes_to_frames(runtime, chip->current_line * chip->line_bytes); in snd_bt87x_pointer()
578 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_volume_get() local
580 value->value.integer.value[0] = (chip->reg_control & CTL_A_GAIN_MASK) >> CTL_A_GAIN_SHIFT; in snd_bt87x_capture_volume_get()
587 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_volume_put() local
591 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_volume_put()
592 old_control = chip->reg_control; in snd_bt87x_capture_volume_put()
593 chip->reg_control = (chip->reg_control & ~CTL_A_GAIN_MASK) in snd_bt87x_capture_volume_put()
595 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_volume_put()
596 changed = old_control != chip->reg_control; in snd_bt87x_capture_volume_put()
597 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_volume_put()
614 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_boost_get() local
616 value->value.integer.value[0] = !! (chip->reg_control & CTL_A_G2X); in snd_bt87x_capture_boost_get()
623 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_boost_put() local
627 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_boost_put()
628 old_control = chip->reg_control; in snd_bt87x_capture_boost_put()
629 chip->reg_control = (chip->reg_control & ~CTL_A_G2X) in snd_bt87x_capture_boost_put()
631 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_boost_put()
632 changed = chip->reg_control != old_control; in snd_bt87x_capture_boost_put()
633 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_boost_put()
656 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_source_get() local
658 value->value.enumerated.item[0] = (chip->reg_control & CTL_A_SEL_MASK) >> CTL_A_SEL_SHIFT; in snd_bt87x_capture_source_get()
665 struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); in snd_bt87x_capture_source_put() local
669 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_source_put()
670 old_control = chip->reg_control; in snd_bt87x_capture_source_put()
671 chip->reg_control = (chip->reg_control & ~CTL_A_SEL_MASK) in snd_bt87x_capture_source_put()
673 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_source_put()
674 changed = chip->reg_control != old_control; in snd_bt87x_capture_source_put()
675 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_source_put()
687 static int snd_bt87x_free(struct snd_bt87x *chip) in snd_bt87x_free() argument
689 if (chip->mmio) in snd_bt87x_free()
690 snd_bt87x_stop(chip); in snd_bt87x_free()
691 if (chip->irq >= 0) in snd_bt87x_free()
692 free_irq(chip->irq, chip); in snd_bt87x_free()
693 iounmap(chip->mmio); in snd_bt87x_free()
694 pci_release_regions(chip->pci); in snd_bt87x_free()
695 pci_disable_device(chip->pci); in snd_bt87x_free()
696 kfree(chip); in snd_bt87x_free()
702 struct snd_bt87x *chip = device->device_data; in snd_bt87x_dev_free() local
703 return snd_bt87x_free(chip); in snd_bt87x_dev_free()
706 static int snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) in snd_bt87x_pcm() argument
711 err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); in snd_bt87x_pcm()
714 pcm->private_data = chip; in snd_bt87x_pcm()
719 snd_dma_pci_data(chip->pci), in snd_bt87x_pcm()
728 struct snd_bt87x *chip; in snd_bt87x_create() local
740 chip = kzalloc(sizeof(*chip), GFP_KERNEL); in snd_bt87x_create()
741 if (!chip) { in snd_bt87x_create()
745 chip->card = card; in snd_bt87x_create()
746 chip->pci = pci; in snd_bt87x_create()
747 chip->irq = -1; in snd_bt87x_create()
748 spin_lock_init(&chip->reg_lock); in snd_bt87x_create()
751 kfree(chip); in snd_bt87x_create()
755 chip->mmio = pci_ioremap_bar(pci, 0); in snd_bt87x_create()
756 if (!chip->mmio) { in snd_bt87x_create()
762 chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 | in snd_bt87x_create()
764 chip->interrupt_mask = MY_INTERRUPTS; in snd_bt87x_create()
765 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_create()
766 snd_bt87x_writel(chip, REG_INT_MASK, 0); in snd_bt87x_create()
767 snd_bt87x_writel(chip, REG_INT_STAT, MY_INTERRUPTS); in snd_bt87x_create()
770 KBUILD_MODNAME, chip); in snd_bt87x_create()
775 chip->irq = pci->irq; in snd_bt87x_create()
777 synchronize_irq(chip->irq); in snd_bt87x_create()
779 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); in snd_bt87x_create()
783 *rchip = chip; in snd_bt87x_create()
787 snd_bt87x_free(chip); in snd_bt87x_create()
791 #define BT_DEVICE(chip, subvend, subdev, id) \ argument
793 .device = chip, \
879 struct snd_bt87x *chip; in snd_bt87x_probe() local
903 err = snd_bt87x_create(card, pci, &chip); in snd_bt87x_probe()
907 memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board)); in snd_bt87x_probe()
909 if (!chip->board.no_digital) { in snd_bt87x_probe()
911 chip->board.dig_rate = digital_rate[dev]; in snd_bt87x_probe()
913 chip->reg_control |= chip->board.digital_fmt; in snd_bt87x_probe()
915 err = snd_bt87x_pcm(chip, DEVICE_DIGITAL, "Bt87x Digital"); in snd_bt87x_probe()
919 if (!chip->board.no_analog) { in snd_bt87x_probe()
920 err = snd_bt87x_pcm(chip, DEVICE_ANALOG, "Bt87x Analog"); in snd_bt87x_probe()
924 &snd_bt87x_capture_volume, chip)); in snd_bt87x_probe()
928 &snd_bt87x_capture_boost, chip)); in snd_bt87x_probe()
932 &snd_bt87x_capture_source, chip)); in snd_bt87x_probe()
938 chip->board.no_analog ? "no " : "", in snd_bt87x_probe()
939 chip->board.no_digital ? "no " : "", chip->board.dig_rate); in snd_bt87x_probe()
945 chip->irq); in snd_bt87x_probe()