Lines Matching +full:convert +full:- +full:sample +full:- +full:format

1 // SPDX-License-Identifier: GPL-2.0-only
9 #include <linux/dma-mapping.h>
129 } while (!done && --retries); in snd_ps3_verify_dma_stop()
145 * NOTE: caller should reset card->running before call.
146 * If not, the interrupt handler will re-start DMA,
158 * 5.7ms is from 16bit/sample 2ch 44.1Khz; the time next in snd_ps3_wait_for_dma_stop()
187 * convert virtual addr to ioif bus addr.
191 return card->dma_start_bus_addr[ch] + in v_to_bus()
192 (paddr - card->dma_start_vaddr[ch]); in v_to_bus()
205 card->dma_last_transfer_vaddr[ch] = in snd_ps3_bump_buffer()
206 card->dma_next_transfer_vaddr[ch]; in snd_ps3_bump_buffer()
207 card->dma_next_transfer_vaddr[ch] += byte_count; in snd_ps3_bump_buffer()
208 if ((card->dma_start_vaddr[ch] + (card->dma_buffer_size / 2)) <= in snd_ps3_bump_buffer()
209 card->dma_next_transfer_vaddr[ch]) { in snd_ps3_bump_buffer()
210 card->dma_next_transfer_vaddr[ch] = card->dma_start_vaddr[ch]; in snd_ps3_bump_buffer()
245 spin_lock_irqsave(&card->dma_lock, irqsave); in snd_ps3_program_dma()
250 dma_addr = card->null_buffer_start_dma_addr; in snd_ps3_program_dma()
254 card->dma_next_transfer_vaddr[ch], in snd_ps3_program_dma()
286 - 1) | in snd_ps3_program_dma()
292 spin_unlock_irqrestore(&card->dma_lock, irqsave); in snd_ps3_program_dma()
307 if (!card->running) { in snd_ps3_interrupt()
324 if (card->silent) { in snd_ps3_interrupt()
331 card->silent--; in snd_ps3_interrupt()
338 snd_pcm_period_elapsed(card->substream); in snd_ps3_interrupt()
381 ret = ps3av_set_audio_mode(card->avs.avs_audio_ch, in snd_ps3_change_avsetting()
382 card->avs.avs_audio_rate, in snd_ps3_change_avsetting()
383 card->avs.avs_audio_width, in snd_ps3_change_avsetting()
384 card->avs.avs_audio_format, in snd_ps3_change_avsetting()
385 card->avs.avs_audio_source); in snd_ps3_change_avsetting()
405 --retries) { in snd_ps3_change_avsetting()
421 /* In 24bit mode,ALSA inserts a zero byte at first byte of per sample */ in snd_ps3_change_avsetting()
444 avs = card->avs; in snd_ps3_set_avsetting()
447 substream->runtime->rate, in snd_ps3_set_avsetting()
448 snd_pcm_format_width(substream->runtime->format)); in snd_ps3_set_avsetting()
451 card->avs.avs_audio_rate, card->avs.avs_audio_width); in snd_ps3_set_avsetting()
453 /* sample rate */ in snd_ps3_set_avsetting()
454 switch (substream->runtime->rate) { in snd_ps3_set_avsetting()
469 substream->runtime->rate); in snd_ps3_set_avsetting()
474 switch (snd_pcm_format_width(substream->runtime->format)) { in snd_ps3_set_avsetting()
483 snd_pcm_format_width(substream->runtime->format)); in snd_ps3_set_avsetting()
489 if (memcmp(&card->avs, &avs, sizeof(avs))) { in snd_ps3_set_avsetting()
491 card->avs.avs_audio_rate, card->avs.avs_audio_width); in snd_ps3_set_avsetting()
493 card->avs = avs; in snd_ps3_set_avsetting()
499 /* check CS non-audio bit and mute accordingly */ in snd_ps3_set_avsetting()
501 ps3av_audio_mute_analog(1); /* mute if non-audio */ in snd_ps3_set_avsetting()
513 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ps3_pcm_open()
517 card->substream = substream; in snd_ps3_pcm_open()
519 runtime->hw = snd_ps3_pcm_hw; in snd_ps3_pcm_open()
521 card->start_delay = snd_ps3_start_delay; in snd_ps3_pcm_open()
544 rate = substream->runtime->rate; in snd_ps3_delay_to_bytes()
545 ret = snd_pcm_format_size(substream->runtime->format, in snd_ps3_delay_to_bytes()
547 * substream->runtime->channels; in snd_ps3_delay_to_bytes()
553 snd_pcm_format_size(substream->runtime->format, rate), in snd_ps3_delay_to_bytes()
562 struct snd_pcm_runtime *runtime = substream->runtime; in snd_ps3_pcm_prepare()
572 * let SPDIF device re-lock with SPDIF signal, in snd_ps3_pcm_prepare()
575 card->silent = snd_ps3_delay_to_bytes(substream, in snd_ps3_pcm_prepare()
576 card->start_delay) / in snd_ps3_pcm_prepare()
581 spin_lock_irqsave(&card->dma_lock, irqsave); in snd_ps3_pcm_prepare()
583 card->dma_buffer_size = runtime->dma_bytes; in snd_ps3_pcm_prepare()
585 card->dma_last_transfer_vaddr[SND_PS3_CH_L] = in snd_ps3_pcm_prepare()
586 card->dma_next_transfer_vaddr[SND_PS3_CH_L] = in snd_ps3_pcm_prepare()
587 card->dma_start_vaddr[SND_PS3_CH_L] = in snd_ps3_pcm_prepare()
588 runtime->dma_area; in snd_ps3_pcm_prepare()
589 card->dma_start_bus_addr[SND_PS3_CH_L] = runtime->dma_addr; in snd_ps3_pcm_prepare()
591 card->dma_last_transfer_vaddr[SND_PS3_CH_R] = in snd_ps3_pcm_prepare()
592 card->dma_next_transfer_vaddr[SND_PS3_CH_R] = in snd_ps3_pcm_prepare()
593 card->dma_start_vaddr[SND_PS3_CH_R] = in snd_ps3_pcm_prepare()
594 runtime->dma_area + (runtime->dma_bytes / 2); in snd_ps3_pcm_prepare()
595 card->dma_start_bus_addr[SND_PS3_CH_R] = in snd_ps3_pcm_prepare()
596 runtime->dma_addr + (runtime->dma_bytes / 2); in snd_ps3_pcm_prepare()
599 card->dma_start_vaddr[SND_PS3_CH_L], in snd_ps3_pcm_prepare()
600 card->dma_start_bus_addr[SND_PS3_CH_L]); in snd_ps3_pcm_prepare()
603 spin_unlock_irqrestore(&card->dma_lock, irqsave); in snd_ps3_pcm_prepare()
621 spin_lock(&card->dma_lock); in snd_ps3_pcm_trigger()
623 card->running = 1; in snd_ps3_pcm_trigger()
625 spin_unlock(&card->dma_lock); in snd_ps3_pcm_trigger()
639 spin_lock(&card->dma_lock); in snd_ps3_pcm_trigger()
641 card->running = 0; in snd_ps3_pcm_trigger()
643 spin_unlock(&card->dma_lock); in snd_ps3_pcm_trigger()
664 spin_lock(&card->dma_lock); in snd_ps3_pcm_pointer()
666 bytes = (size_t)(card->dma_last_transfer_vaddr[SND_PS3_CH_L] - in snd_ps3_pcm_pointer()
667 card->dma_start_vaddr[SND_PS3_CH_L]); in snd_ps3_pcm_pointer()
669 spin_unlock(&card->dma_lock); in snd_ps3_pcm_pointer()
671 ret = bytes_to_frames(substream->runtime, bytes * 2); in snd_ps3_pcm_pointer()
682 uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958; in snd_ps3_spdif_mask_info()
683 uinfo->count = 1; in snd_ps3_spdif_mask_info()
691 memset(ucontrol->value.iec958.status, 0xff, 8); in snd_ps3_spdif_cmask_get()
704 memcpy(ucontrol->value.iec958.status, ps3av_mode_cs_info, 8); in snd_ps3_spdif_default_get()
711 if (memcmp(ps3av_mode_cs_info, ucontrol->value.iec958.status, 8)) { in snd_ps3_spdif_default_put()
712 memcpy(ps3av_mode_cs_info, ucontrol->value.iec958.status, 8); in snd_ps3_spdif_default_put()
754 ioremap(the_card.ps3_dev->m_region->bus_addr, in snd_ps3_map_mmio()
755 the_card.ps3_dev->m_region->len); in snd_ps3_map_mmio()
759 __func__, the_card.ps3_dev->m_region->lpar_addr, in snd_ps3_map_mmio()
760 the_card.ps3_dev->m_region->len); in snd_ps3_map_mmio()
761 return -ENXIO; in snd_ps3_map_mmio()
786 return -ENXIO; in snd_ps3_allocate_irq()
792 return -ENXIO; in snd_ps3_allocate_irq()
836 val = (ioaddr_start & (0x0fUL << 32)) >> (32 - 20) | in snd_ps3_audio_set_base_addr()
875 card->avs.avs_audio_ch = PS3AV_CMD_AUDIO_NUM_OF_CH_2; in snd_ps3_init_avsetting()
876 card->avs.avs_audio_rate = PS3AV_CMD_AUDIO_FS_48K; in snd_ps3_init_avsetting()
877 card->avs.avs_audio_width = PS3AV_CMD_AUDIO_WORD_BITS_16; in snd_ps3_init_avsetting()
878 card->avs.avs_audio_format = PS3AV_CMD_AUDIO_FORMAT_PCM; in snd_ps3_init_avsetting()
879 card->avs.avs_audio_source = PS3AV_CMD_AUDIO_SOURCE_SERIAL; in snd_ps3_init_avsetting()
880 memcpy(card->avs.avs_cs_info, ps3av_mode_cs_info, 8); in snd_ps3_init_avsetting()
904 return -ENXIO; in snd_ps3_driver_probe()
912 ps3_mmio_region_init(dev, dev->m_region, lpar_addr, lpar_size, in snd_ps3_driver_probe()
920 ps3_dma_region_init(dev, dev->d_region, in snd_ps3_driver_probe()
925 dev->d_region->ioid = PS3_AUDIO_IOID; in snd_ps3_driver_probe()
927 ret = ps3_dma_region_create(dev->d_region); in snd_ps3_driver_probe()
934 dev->core.dma_mask = &dummy_mask; in snd_ps3_driver_probe()
935 dma_set_coherent_mask(&dev->core, dummy_mask); in snd_ps3_driver_probe()
937 snd_ps3_audio_set_base_addr(dev->d_region->bus_addr); in snd_ps3_driver_probe()
944 ret = -ENXIO; in snd_ps3_driver_probe()
949 ret = snd_card_new(&dev->core, index, id, THIS_MODULE, in snd_ps3_driver_probe()
954 strcpy(the_card.card->driver, "PS3"); in snd_ps3_driver_probe()
955 strcpy(the_card.card->shortname, "PS3"); in snd_ps3_driver_probe()
956 strcpy(the_card.card->longname, "PS3 sound"); in snd_ps3_driver_probe()
977 the_card.pcm->private_data = &the_card; in snd_ps3_driver_probe()
978 strcpy(the_card.pcm->name, "SPDIF"); in snd_ps3_driver_probe()
984 the_card.pcm->info_flags = SNDRV_PCM_INFO_NONINTERLEAVED; in snd_ps3_driver_probe()
985 /* pre-alloc PCM DMA buffer*/ in snd_ps3_driver_probe()
988 &dev->core, in snd_ps3_driver_probe()
998 dma_alloc_coherent(&the_card.ps3_dev->core, in snd_ps3_driver_probe()
1004 ret = -ENOMEM; in snd_ps3_driver_probe()
1010 /* set default sample rate/word width */ in snd_ps3_driver_probe()
1019 the_card.card->longname, the_card.start_delay); in snd_ps3_driver_probe()
1023 dma_free_coherent(&the_card.ps3_dev->core, in snd_ps3_driver_probe()
1032 ps3_dma_region_free(dev->d_region); in snd_ps3_driver_probe()
1049 pr_info("%s:start id=%d\n", __func__, dev->match_id); in snd_ps3_driver_remove()
1057 dma_free_coherent(&dev->core, in snd_ps3_driver_remove()
1062 ps3_dma_region_free(dev->d_region); in snd_ps3_driver_remove()
1069 pr_info("%s:end id=%d\n", __func__, dev->match_id); in snd_ps3_driver_remove()
1092 return -ENXIO; in snd_ps3_init()