Lines Matching +full:ati +full:- +full:exclude
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * bt87x.c - Brooktree Bt878/Bt879 driver for ALSA
27 static int index[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = -2}; /* Exclude the first card */
70 #define CTL_PKTP_4 (0 << 2) /* packet mode FIFO trigger point - 4 DWORDs */
93 #define CTL_A_PWRDN (1 << 26) /* analog audio power-down */
131 #define MAX_RISC_SIZE ((1 + 255 + (PAGE_ALIGN(255 * 4092) / PAGE_SIZE - 1) + 1 + 1) * 8)
203 return readl(chip->mmio + reg); in snd_bt87x_readl()
208 writel(value, chip->mmio + reg); in snd_bt87x_writel()
217 if (chip->dma_risc.area == NULL) { in snd_bt87x_create_risc()
218 if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &chip->pci->dev, in snd_bt87x_create_risc()
219 PAGE_ALIGN(MAX_RISC_SIZE), &chip->dma_risc) < 0) in snd_bt87x_create_risc()
220 return -ENOMEM; in snd_bt87x_create_risc()
222 risc = (__le32 *)chip->dma_risc.area; in snd_bt87x_create_risc()
234 len = PAGE_SIZE - (offset % PAGE_SIZE); in snd_bt87x_create_risc()
250 rest -= len; in snd_bt87x_create_risc()
256 *risc++ = cpu_to_le32(chip->dma_risc.addr); in snd_bt87x_create_risc()
257 chip->line_bytes = period_bytes; in snd_bt87x_create_risc()
258 chip->lines = periods; in snd_bt87x_create_risc()
264 if (chip->dma_risc.area) { in snd_bt87x_free_risc()
265 snd_dma_free_pages(&chip->dma_risc); in snd_bt87x_free_risc()
266 chip->dma_risc.area = NULL; in snd_bt87x_free_risc()
272 int pci_status = pci_status_get_and_clear_errors(chip->pci); in snd_bt87x_pci_error()
275 dev_err(chip->card->dev, in snd_bt87x_pci_error()
276 "Aieee - PCI error! status %#08x, PCI status %#04x\n", in snd_bt87x_pci_error()
279 dev_err(chip->card->dev, in snd_bt87x_pci_error()
280 "Aieee - PCI parity error detected!\n"); in snd_bt87x_pci_error()
282 chip->pci_parity_errors++; in snd_bt87x_pci_error()
283 if (chip->pci_parity_errors > 20) { in snd_bt87x_pci_error()
284 dev_err(chip->card->dev, in snd_bt87x_pci_error()
286 dev_err(chip->card->dev, in snd_bt87x_pci_error()
288 dev_err(chip->card->dev, in snd_bt87x_pci_error()
290 dev_err(chip->card->dev, in snd_bt87x_pci_error()
292 chip->interrupt_mask &= ~(INT_PPERR | INT_RIPERR); in snd_bt87x_pci_error()
293 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); in snd_bt87x_pci_error()
304 irq_status = status & chip->interrupt_mask; in snd_bt87x_interrupt()
311 dev_warn(chip->card->dev, in snd_bt87x_interrupt()
314 dev_err(chip->card->dev, in snd_bt87x_interrupt()
319 if ((irq_status & INT_RISCI) && (chip->reg_control & CTL_ACAP_EN)) { in snd_bt87x_interrupt()
323 chip->current_line = (chip->current_line + 1) % chip->lines; in snd_bt87x_interrupt()
325 current_block = chip->current_line * 16 / chip->lines; in snd_bt87x_interrupt()
328 chip->current_line = DIV_ROUND_UP(irq_block * chip->lines, in snd_bt87x_interrupt()
331 snd_pcm_period_elapsed(chip->substream); in snd_bt87x_interrupt()
374 chip->reg_control |= CTL_DA_IOM_DA | CTL_A_PWRDN; in snd_bt87x_set_digital_hw()
375 runtime->hw = snd_bt87x_digital_hw; in snd_bt87x_set_digital_hw()
376 runtime->hw.rates = snd_pcm_rate_to_rate_bit(chip->board.dig_rate); in snd_bt87x_set_digital_hw()
377 runtime->hw.rate_min = chip->board.dig_rate; in snd_bt87x_set_digital_hw()
378 runtime->hw.rate_max = chip->board.dig_rate; in snd_bt87x_set_digital_hw()
395 chip->reg_control &= ~(CTL_DA_IOM_DA | CTL_A_PWRDN); in snd_bt87x_set_analog_hw()
396 runtime->hw = snd_bt87x_analog_hw; in snd_bt87x_set_analog_hw()
404 struct snd_pcm_runtime *runtime = substream->runtime; in snd_bt87x_pcm_open()
407 if (test_and_set_bit(0, &chip->opened)) in snd_bt87x_pcm_open()
408 return -EBUSY; in snd_bt87x_pcm_open()
410 if (substream->pcm->device == DEVICE_DIGITAL) in snd_bt87x_pcm_open()
421 chip->substream = substream; in snd_bt87x_pcm_open()
425 clear_bit(0, &chip->opened); in snd_bt87x_pcm_open()
434 spin_lock_irq(&chip->reg_lock); in snd_bt87x_close()
435 chip->reg_control |= CTL_A_PWRDN; in snd_bt87x_close()
436 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_close()
437 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_close()
439 chip->substream = NULL; in snd_bt87x_close()
440 clear_bit(0, &chip->opened); in snd_bt87x_close()
466 struct snd_pcm_runtime *runtime = substream->runtime; in snd_bt87x_prepare()
469 spin_lock_irq(&chip->reg_lock); in snd_bt87x_prepare()
470 chip->reg_control &= ~(CTL_DA_SDR_MASK | CTL_DA_SBR); in snd_bt87x_prepare()
471 decimation = (ANALOG_CLOCK + runtime->rate / 4) / runtime->rate; in snd_bt87x_prepare()
472 chip->reg_control |= decimation << CTL_DA_SDR_SHIFT; in snd_bt87x_prepare()
473 if (runtime->format == SNDRV_PCM_FORMAT_S8) in snd_bt87x_prepare()
474 chip->reg_control |= CTL_DA_SBR; in snd_bt87x_prepare()
475 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_prepare()
476 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_prepare()
482 spin_lock(&chip->reg_lock); in snd_bt87x_start()
483 chip->current_line = 0; in snd_bt87x_start()
484 chip->reg_control |= CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN; in snd_bt87x_start()
485 snd_bt87x_writel(chip, REG_RISC_STRT_ADD, chip->dma_risc.addr); in snd_bt87x_start()
487 chip->line_bytes | (chip->lines << 16)); in snd_bt87x_start()
488 snd_bt87x_writel(chip, REG_INT_MASK, chip->interrupt_mask); in snd_bt87x_start()
489 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_start()
490 spin_unlock(&chip->reg_lock); in snd_bt87x_start()
496 spin_lock(&chip->reg_lock); in snd_bt87x_stop()
497 chip->reg_control &= ~(CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN); in snd_bt87x_stop()
498 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_stop()
501 spin_unlock(&chip->reg_lock); in snd_bt87x_stop()
515 return -EINVAL; in snd_bt87x_trigger()
522 struct snd_pcm_runtime *runtime = substream->runtime; in snd_bt87x_pointer()
524 return (snd_pcm_uframes_t)bytes_to_frames(runtime, chip->current_line * chip->line_bytes); in snd_bt87x_pointer()
540 info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_bt87x_capture_volume_info()
541 info->count = 1; in snd_bt87x_capture_volume_info()
542 info->value.integer.min = 0; in snd_bt87x_capture_volume_info()
543 info->value.integer.max = 15; in snd_bt87x_capture_volume_info()
552 value->value.integer.value[0] = (chip->reg_control & CTL_A_GAIN_MASK) >> CTL_A_GAIN_SHIFT; in snd_bt87x_capture_volume_get()
563 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_volume_put()
564 old_control = chip->reg_control; in snd_bt87x_capture_volume_put()
565 chip->reg_control = (chip->reg_control & ~CTL_A_GAIN_MASK) in snd_bt87x_capture_volume_put()
566 | (value->value.integer.value[0] << CTL_A_GAIN_SHIFT); in snd_bt87x_capture_volume_put()
567 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_volume_put()
568 changed = old_control != chip->reg_control; in snd_bt87x_capture_volume_put()
569 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_volume_put()
588 value->value.integer.value[0] = !! (chip->reg_control & CTL_A_G2X); in snd_bt87x_capture_boost_get()
599 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_boost_put()
600 old_control = chip->reg_control; in snd_bt87x_capture_boost_put()
601 chip->reg_control = (chip->reg_control & ~CTL_A_G2X) in snd_bt87x_capture_boost_put()
602 | (value->value.integer.value[0] ? CTL_A_G2X : 0); in snd_bt87x_capture_boost_put()
603 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_boost_put()
604 changed = chip->reg_control != old_control; in snd_bt87x_capture_boost_put()
605 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_boost_put()
630 value->value.enumerated.item[0] = (chip->reg_control & CTL_A_SEL_MASK) >> CTL_A_SEL_SHIFT; in snd_bt87x_capture_source_get()
641 spin_lock_irq(&chip->reg_lock); in snd_bt87x_capture_source_put()
642 old_control = chip->reg_control; in snd_bt87x_capture_source_put()
643 chip->reg_control = (chip->reg_control & ~CTL_A_SEL_MASK) in snd_bt87x_capture_source_put()
644 | (value->value.enumerated.item[0] << CTL_A_SEL_SHIFT); in snd_bt87x_capture_source_put()
645 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_capture_source_put()
646 changed = chip->reg_control != old_control; in snd_bt87x_capture_source_put()
647 spin_unlock_irq(&chip->reg_lock); in snd_bt87x_capture_source_put()
661 struct snd_bt87x *chip = card->private_data; in snd_bt87x_free()
671 err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); in snd_bt87x_pcm()
674 pcm->private_data = chip; in snd_bt87x_pcm()
675 strcpy(pcm->name, name); in snd_bt87x_pcm()
678 &chip->pci->dev, in snd_bt87x_pcm()
687 struct snd_bt87x *chip = card->private_data; in snd_bt87x_create()
694 chip->card = card; in snd_bt87x_create()
695 chip->pci = pci; in snd_bt87x_create()
696 chip->irq = -1; in snd_bt87x_create()
697 spin_lock_init(&chip->reg_lock); in snd_bt87x_create()
702 chip->mmio = pcim_iomap_table(pci)[0]; in snd_bt87x_create()
704 chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 | in snd_bt87x_create()
706 chip->interrupt_mask = MY_INTERRUPTS; in snd_bt87x_create()
707 snd_bt87x_writel(chip, REG_GPIO_DMA_CTL, chip->reg_control); in snd_bt87x_create()
711 err = devm_request_irq(&pci->dev, pci->irq, snd_bt87x_interrupt, in snd_bt87x_create()
714 dev_err(card->dev, "cannot grab irq %d\n", pci->irq); in snd_bt87x_create()
717 chip->irq = pci->irq; in snd_bt87x_create()
718 card->sync_irq = chip->irq; in snd_bt87x_create()
719 card->private_free = snd_bt87x_free; in snd_bt87x_create()
741 /* ATI TV-Wonder */
753 /* Prolink PixelView PV-M4900 */
769 {0x1461, 0x0761}, /* AVermedia AverTV DVB-T */
770 {0x1461, 0x0771}, /* AVermedia DVB-T 771 */
771 {0x1822, 0x0001}, /* Twinhan VisionPlus DVB-T */
773 {0x18ac, 0xdb10}, /* DVICO FusionHDTV DVB-T Lite */
774 {0x18ac, 0xdb11}, /* Ultraview DVB-T Lite */
775 {0x270f, 0xfc00}, /* Chaintech Digitop DST-1000 DVB-S */
776 {0x7063, 0x2000}, /* pcHDTV HD-2000 TV */
788 if (supported && supported->driver_data > 0) in snd_bt87x_detect_card()
789 return supported->driver_data; in snd_bt87x_detect_card()
792 if (denylist[i].subvendor == pci->subsystem_vendor && in snd_bt87x_detect_card()
793 denylist[i].subdevice == pci->subsystem_device) { in snd_bt87x_detect_card()
794 dev_dbg(&pci->dev, in snd_bt87x_detect_card()
795 "card %#04x-%#04x:%#04x has no audio\n", in snd_bt87x_detect_card()
796 pci->device, pci->subsystem_vendor, pci->subsystem_device); in snd_bt87x_detect_card()
797 return -EBUSY; in snd_bt87x_detect_card()
800 dev_info(&pci->dev, "unknown card %#04x-%#04x:%#04x\n", in snd_bt87x_detect_card()
801 pci->device, pci->subsystem_vendor, pci->subsystem_device); in snd_bt87x_detect_card()
802 dev_info(&pci->dev, "please mail id, board name, and, " in snd_bt87x_detect_card()
804 "<alsa-devel@alsa-project.org>\n"); in snd_bt87x_detect_card()
817 if (!pci_id->driver_data) { in __snd_bt87x_probe()
820 return -ENODEV; in __snd_bt87x_probe()
823 boardid = pci_id->driver_data; in __snd_bt87x_probe()
826 return -ENODEV; in __snd_bt87x_probe()
829 return -ENOENT; in __snd_bt87x_probe()
832 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, in __snd_bt87x_probe()
836 chip = card->private_data; in __snd_bt87x_probe()
842 memcpy(&chip->board, &snd_bt87x_boards[boardid], sizeof(chip->board)); in __snd_bt87x_probe()
844 if (!chip->board.no_digital) { in __snd_bt87x_probe()
846 chip->board.dig_rate = digital_rate[dev]; in __snd_bt87x_probe()
848 chip->reg_control |= chip->board.digital_fmt; in __snd_bt87x_probe()
854 if (!chip->board.no_analog) { in __snd_bt87x_probe()
871 dev_info(card->dev, "bt87x%d: Using board %d, %sanalog, %sdigital " in __snd_bt87x_probe()
873 chip->board.no_analog ? "no " : "", in __snd_bt87x_probe()
874 chip->board.no_digital ? "no " : "", chip->board.dig_rate); in __snd_bt87x_probe()
876 strcpy(card->driver, "Bt87x"); in __snd_bt87x_probe()
877 sprintf(card->shortname, "Brooktree Bt%x", pci->device); in __snd_bt87x_probe()
878 sprintf(card->longname, "%s at %#llx, irq %i", in __snd_bt87x_probe()
879 card->shortname, (unsigned long long)pci_resource_start(pci, 0), in __snd_bt87x_probe()
880 chip->irq); in __snd_bt87x_probe()
881 strcpy(card->mixername, "Bt87x"); in __snd_bt87x_probe()
895 return snd_card_free_on_error(&pci->dev, __snd_bt87x_probe(pci, pci_id)); in snd_bt87x_probe()
898 /* default entries for all Bt87x cards - it's not exported */