Lines Matching +full:avb +full:- +full:algorithm
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
54 * snd_printddd - very verbose debug printk
67 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
314 #define INVALID_FORMAT (__force snd_pcm_format_t)(-1)
333 /* ALSA can't handle 3 byte sample size together with power-of-2
359 return -EINVAL; in snd_card_asihpi_format_alsa2hpi()
373 if (asihpi->support_mrx) { in snd_card_asihpi_pcm_samplerates()
381 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_pcm_samplerates()
385 dev_err(&asihpi->pci->dev, in snd_card_asihpi_pcm_samplerates()
389 for (idx = -1; idx < 100; idx++) { in snd_card_asihpi_pcm_samplerates()
390 if (idx == -1) { in snd_card_asihpi_pcm_samplerates()
448 pcmhw->rates = rates; in snd_card_asihpi_pcm_samplerates()
449 pcmhw->rate_min = rate_min; in snd_card_asihpi_pcm_samplerates()
450 pcmhw->rate_max = rate_max; in snd_card_asihpi_pcm_samplerates()
456 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_hw_params()
457 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_hw_params()
472 hpi_handle_error(hpi_format_create(&dpcm->format, in snd_card_asihpi_pcm_hw_params()
476 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_card_asihpi_pcm_hw_params()
477 if (hpi_instream_reset(dpcm->h_stream) != 0) in snd_card_asihpi_pcm_hw_params()
478 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
481 dpcm->h_stream, &dpcm->format) != 0) in snd_card_asihpi_pcm_hw_params()
482 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
485 dpcm->hpi_buffer_attached = 0; in snd_card_asihpi_pcm_hw_params()
486 if (card->can_dma) { in snd_card_asihpi_pcm_hw_params()
487 err = hpi_stream_host_buffer_attach(dpcm->h_stream, in snd_card_asihpi_pcm_hw_params()
488 params_buffer_bytes(params), runtime->dma_addr); in snd_card_asihpi_pcm_hw_params()
493 (unsigned long)runtime->dma_addr); in snd_card_asihpi_pcm_hw_params()
497 return -ENOMEM; in snd_card_asihpi_pcm_hw_params()
500 err = hpi_stream_get_info_ex(dpcm->h_stream, NULL, in snd_card_asihpi_pcm_hw_params()
501 &dpcm->hpi_buffer_attached, NULL, NULL, NULL); in snd_card_asihpi_pcm_hw_params()
508 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
510 dpcm->bytes_per_sec = bytes_per_sec; in snd_card_asihpi_pcm_hw_params()
511 dpcm->buffer_bytes = params_buffer_bytes(params); in snd_card_asihpi_pcm_hw_params()
512 dpcm->period_bytes = params_period_bytes(params); in snd_card_asihpi_pcm_hw_params()
520 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_hw_free()
521 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_hw_free()
522 if (dpcm->hpi_buffer_attached) in snd_card_asihpi_hw_free()
523 hpi_stream_host_buffer_detach(dpcm->h_stream); in snd_card_asihpi_hw_free()
531 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_runtime_free()
538 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_timer_start()
539 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_timer_start()
545 mod_timer(&dpcm->timer, jiffies + expiry); in snd_card_asihpi_pcm_timer_start()
546 dpcm->respawn_timer = 1; in snd_card_asihpi_pcm_timer_start()
551 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_timer_stop()
552 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_timer_stop()
554 dpcm->respawn_timer = 0; in snd_card_asihpi_pcm_timer_stop()
555 del_timer(&dpcm->timer); in snd_card_asihpi_pcm_timer_stop()
563 dpcm = (struct snd_card_asihpi_pcm *)substream->runtime->private_data; in snd_card_asihpi_pcm_int_start()
567 tasklet_disable(&card->t); in snd_card_asihpi_pcm_int_start()
568 card->llmode_streampriv = dpcm; in snd_card_asihpi_pcm_int_start()
569 tasklet_enable(&card->t); in snd_card_asihpi_pcm_int_start()
571 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index, in snd_card_asihpi_pcm_int_start()
573 card->update_interval_frames, 0)); in snd_card_asihpi_pcm_int_start()
582 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index, in snd_card_asihpi_pcm_int_stop()
586 card->llmode_streampriv = NULL; in snd_card_asihpi_pcm_int_stop()
588 tasklet_disable(&card->t); in snd_card_asihpi_pcm_int_stop()
589 card->llmode_streampriv = NULL; in snd_card_asihpi_pcm_int_stop()
590 tasklet_enable(&card->t); in snd_card_asihpi_pcm_int_stop()
597 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; in snd_card_asihpi_trigger()
609 struct snd_pcm_runtime *runtime = s->runtime; in snd_card_asihpi_trigger()
610 struct snd_card_asihpi_pcm *ds = runtime->private_data; in snd_card_asihpi_trigger()
616 if (substream->stream != s->stream) in snd_card_asihpi_trigger()
619 ds->drained_count = 0; in snd_card_asihpi_trigger()
620 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_trigger()
627 unsigned int preload = ds->period_bytes * 1; in snd_card_asihpi_trigger()
628 snd_printddd("%d preload %d\n", s->number, preload); in snd_card_asihpi_trigger()
630 ds->h_stream, in snd_card_asihpi_trigger()
631 &runtime->dma_area[0], in snd_card_asihpi_trigger()
633 &ds->format)); in snd_card_asihpi_trigger()
634 ds->pcm_buf_host_rw_ofs = preload; in snd_card_asihpi_trigger()
637 if (card->support_grouping) { in snd_card_asihpi_trigger()
638 snd_printdd("%d group\n", s->number); in snd_card_asihpi_trigger()
640 dpcm->h_stream, in snd_card_asihpi_trigger()
641 ds->h_stream); in snd_card_asihpi_trigger()
652 card->pcm_start(substream); in snd_card_asihpi_trigger()
653 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || in snd_card_asihpi_trigger()
654 !card->can_dma) in snd_card_asihpi_trigger()
655 hpi_handle_error(hpi_stream_start(dpcm->h_stream)); in snd_card_asihpi_trigger()
660 card->pcm_stop(substream); in snd_card_asihpi_trigger()
665 if (substream->stream != s->stream) in snd_card_asihpi_trigger()
670 s->runtime->status->state = SNDRV_PCM_STATE_SETUP; in snd_card_asihpi_trigger()
672 if (card->support_grouping) { in snd_card_asihpi_trigger()
673 snd_printdd("%d group\n", s->number); in snd_card_asihpi_trigger()
680 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); in snd_card_asihpi_trigger()
681 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_card_asihpi_trigger()
683 hpi_outstream_reset(dpcm->h_stream)); in snd_card_asihpi_trigger()
685 if (card->support_grouping) in snd_card_asihpi_trigger()
686 hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream)); in snd_card_asihpi_trigger()
691 card->pcm_start(substream); in snd_card_asihpi_trigger()
692 hpi_handle_error(hpi_stream_start(dpcm->h_stream)); in snd_card_asihpi_trigger()
696 card->pcm_stop(substream); in snd_card_asihpi_trigger()
697 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); in snd_card_asihpi_trigger()
701 return -EINVAL; in snd_card_asihpi_trigger()
707 /*algorithm outline
720 s->pcm_buf_dma_ofs = min_buf_pos;
742 if (((a-b) % modulus) < (modulus/2)) in modulo_min()
755 struct snd_pcm_substream *substream = dpcm->substream; in snd_card_asihpi_timer_function()
773 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; in snd_card_asihpi_timer_function()
774 runtime = s->runtime; in snd_card_asihpi_timer_function()
780 if (substream->stream != s->stream) in snd_card_asihpi_timer_function()
784 ds->h_stream, &state, in snd_card_asihpi_timer_function()
788 /* number of bytes in on-card buffer */ in snd_card_asihpi_timer_function()
789 runtime->delay = on_card_bytes; in snd_card_asihpi_timer_function()
791 if (!card->can_dma) in snd_card_asihpi_timer_function()
794 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_timer_function()
795 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; in snd_card_asihpi_timer_function()
798 hpi_handle_error(hpi_stream_start(ds->h_stream)); in snd_card_asihpi_timer_function()
799 snd_printdd("P%d start\n", s->number); in snd_card_asihpi_timer_function()
800 ds->drained_count = 0; in snd_card_asihpi_timer_function()
804 s->number); in snd_card_asihpi_timer_function()
805 ds->drained_count++; in snd_card_asihpi_timer_function()
806 if (ds->drained_count > 20) { in snd_card_asihpi_timer_function()
811 ds->drained_count = 0; in snd_card_asihpi_timer_function()
814 pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs; in snd_card_asihpi_timer_function()
819 newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes; in snd_card_asihpi_timer_function()
825 (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes, in snd_card_asihpi_timer_function()
831 name, s->number, state, in snd_card_asihpi_timer_function()
832 ds->pcm_buf_elapsed_dma_ofs, in snd_card_asihpi_timer_function()
833 ds->pcm_buf_host_rw_ofs, in snd_card_asihpi_timer_function()
838 buffer_size-bytes_avail, in snd_card_asihpi_timer_function()
840 runtime->status->hw_ptr), in snd_card_asihpi_timer_function()
842 runtime->control->appl_ptr) in snd_card_asihpi_timer_function()
848 remdata = newdata % dpcm->period_bytes; in snd_card_asihpi_timer_function()
849 xfercount = newdata - remdata; /* a multiple of period_bytes */ in snd_card_asihpi_timer_function()
854 if (xfercount && (on_card_bytes > dpcm->period_bytes)) in snd_card_asihpi_timer_function()
855 next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec); in snd_card_asihpi_timer_function()
857 next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec); in snd_card_asihpi_timer_function()
860 dpcm->timer.expires = jiffies + next_jiffies; in snd_card_asihpi_timer_function()
865 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; in snd_card_asihpi_timer_function()
868 if (substream->stream != s->stream) in snd_card_asihpi_timer_function()
872 ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs; in snd_card_asihpi_timer_function()
876 ((on_card_bytes <= ds->period_bytes) || in snd_card_asihpi_timer_function()
877 (s->stream == SNDRV_PCM_STREAM_CAPTURE))) in snd_card_asihpi_timer_function()
881 unsigned int buf_ofs = ds->pcm_buf_host_rw_ofs % ds->buffer_bytes; in snd_card_asihpi_timer_function()
883 char *pd = &s->runtime->dma_area[buf_ofs]; in snd_card_asihpi_timer_function()
885 if (card->can_dma) { /* buffer wrap is handled at lower level */ in snd_card_asihpi_timer_function()
889 xfer1 = min(xfercount, ds->buffer_bytes - buf_ofs); in snd_card_asihpi_timer_function()
890 xfer2 = xfercount - xfer1; in snd_card_asihpi_timer_function()
893 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_timer_function()
895 s->number, xfer1, buf_ofs); in snd_card_asihpi_timer_function()
898 ds->h_stream, pd, xfer1, in snd_card_asihpi_timer_function()
899 &ds->format)); in snd_card_asihpi_timer_function()
902 pd = s->runtime->dma_area; in snd_card_asihpi_timer_function()
905 s->number, in snd_card_asihpi_timer_function()
906 xfercount - xfer1, buf_ofs); in snd_card_asihpi_timer_function()
909 ds->h_stream, pd, in snd_card_asihpi_timer_function()
910 xfercount - xfer1, in snd_card_asihpi_timer_function()
911 &ds->format)); in snd_card_asihpi_timer_function()
915 s->number, xfer1); in snd_card_asihpi_timer_function()
918 ds->h_stream, in snd_card_asihpi_timer_function()
921 pd = s->runtime->dma_area; in snd_card_asihpi_timer_function()
923 s->number, xfer2); in snd_card_asihpi_timer_function()
926 ds->h_stream, in snd_card_asihpi_timer_function()
931 ds->pcm_buf_host_rw_ofs += xfercount; in snd_card_asihpi_timer_function()
932 ds->pcm_buf_elapsed_dma_ofs += xfercount; in snd_card_asihpi_timer_function()
937 if (!card->hpi->interrupt_mode && dpcm->respawn_timer) in snd_card_asihpi_timer_function()
938 add_timer(&dpcm->timer); in snd_card_asihpi_timer_function()
946 WARN_ON(!a || !a->snd_card || !a->snd_card->private_data); in snd_card_asihpi_int_task()
947 asihpi = (struct snd_card_asihpi *)a->snd_card->private_data; in snd_card_asihpi_int_task()
948 if (asihpi->llmode_streampriv) in snd_card_asihpi_int_task()
950 &asihpi->llmode_streampriv->timer); in snd_card_asihpi_int_task()
957 WARN_ON(!a || !a->snd_card || !a->snd_card->private_data); in snd_card_asihpi_isr()
958 asihpi = (struct snd_card_asihpi *)a->snd_card->private_data; in snd_card_asihpi_isr()
959 tasklet_schedule(&asihpi->t); in snd_card_asihpi_isr()
975 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_prepare()
976 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_prepare()
978 snd_printdd("P%d prepare\n", substream->number); in snd_card_asihpi_playback_prepare()
980 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); in snd_card_asihpi_playback_prepare()
981 dpcm->pcm_buf_host_rw_ofs = 0; in snd_card_asihpi_playback_prepare()
982 dpcm->pcm_buf_dma_ofs = 0; in snd_card_asihpi_playback_prepare()
983 dpcm->pcm_buf_elapsed_dma_ofs = 0; in snd_card_asihpi_playback_prepare()
990 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_pointer()
991 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_pointer()
996 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); in snd_card_asihpi_playback_pointer()
1014 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_playback_formats()
1024 err = hpi_format_create(&hpi_format, asihpi->out_max_chans, in snd_card_asihpi_playback_formats()
1036 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_open()
1044 return -ENOMEM; in snd_card_asihpi_playback_open()
1046 err = hpi_outstream_open(card->hpi->adapter->index, in snd_card_asihpi_playback_open()
1047 substream->number, &dpcm->h_stream); in snd_card_asihpi_playback_open()
1052 return -EBUSY; in snd_card_asihpi_playback_open()
1054 return -EIO; in snd_card_asihpi_playback_open()
1061 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0); in snd_card_asihpi_playback_open()
1062 dpcm->substream = substream; in snd_card_asihpi_playback_open()
1063 runtime->private_data = dpcm; in snd_card_asihpi_playback_open()
1064 runtime->private_free = snd_card_asihpi_runtime_free; in snd_card_asihpi_playback_open()
1067 if (!card->hpi->interrupt_mode) { in snd_card_asihpi_playback_open()
1074 size_t pbmin = card->update_interval_frames * in snd_card_asihpi_playback_open()
1075 card->out_max_chans; in snd_card_asihpi_playback_open()
1084 snd_card_asihpi_playback.channels_max = card->out_max_chans; in snd_card_asihpi_playback_open()
1085 snd_card_asihpi_playback.channels_min = card->out_min_chans; in snd_card_asihpi_playback_open()
1087 snd_card_asihpi_playback_formats(card, dpcm->h_stream); in snd_card_asihpi_playback_open()
1099 if (card->support_grouping) { in snd_card_asihpi_playback_open()
1105 runtime->hw = snd_card_asihpi_playback; in snd_card_asihpi_playback_open()
1107 if (card->can_dma) in snd_card_asihpi_playback_open()
1114 card->update_interval_frames); in snd_card_asihpi_playback_open()
1117 card->update_interval_frames, UINT_MAX); in snd_card_asihpi_playback_open()
1126 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_close()
1127 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_close()
1129 hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); in snd_card_asihpi_playback_close()
1150 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_pointer()
1151 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_capture_pointer()
1155 snd_printddd("%s, pointer=%d\n", name, dpcm->pcm_buf_dma_ofs); in snd_card_asihpi_capture_pointer()
1160 return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); in snd_card_asihpi_capture_pointer()
1171 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_prepare()
1172 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_capture_prepare()
1174 hpi_handle_error(hpi_instream_reset(dpcm->h_stream)); in snd_card_asihpi_capture_prepare()
1175 dpcm->pcm_buf_host_rw_ofs = 0; in snd_card_asihpi_capture_prepare()
1176 dpcm->pcm_buf_dma_ofs = 0; in snd_card_asihpi_capture_prepare()
1177 dpcm->pcm_buf_elapsed_dma_ofs = 0; in snd_card_asihpi_capture_prepare()
1179 snd_printdd("Capture Prepare %d\n", substream->number); in snd_card_asihpi_capture_prepare()
1195 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_capture_formats()
1206 err = hpi_format_create(&hpi_format, asihpi->in_max_chans, in snd_card_asihpi_capture_formats()
1218 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_open()
1226 return -ENOMEM; in snd_card_asihpi_capture_open()
1229 card->hpi->adapter->index, substream->number); in snd_card_asihpi_capture_open()
1232 hpi_instream_open(card->hpi->adapter->index, in snd_card_asihpi_capture_open()
1233 substream->number, &dpcm->h_stream)); in snd_card_asihpi_capture_open()
1237 return -EBUSY; in snd_card_asihpi_capture_open()
1239 return -EIO; in snd_card_asihpi_capture_open()
1241 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0); in snd_card_asihpi_capture_open()
1242 dpcm->substream = substream; in snd_card_asihpi_capture_open()
1243 runtime->private_data = dpcm; in snd_card_asihpi_capture_open()
1244 runtime->private_free = snd_card_asihpi_runtime_free; in snd_card_asihpi_capture_open()
1247 if (!card->hpi->interrupt_mode) { in snd_card_asihpi_capture_open()
1254 size_t pbmin = card->update_interval_frames * in snd_card_asihpi_capture_open()
1255 card->out_max_chans; in snd_card_asihpi_capture_open()
1263 snd_card_asihpi_capture.channels_max = card->in_max_chans; in snd_card_asihpi_capture_open()
1264 snd_card_asihpi_capture.channels_min = card->in_min_chans; in snd_card_asihpi_capture_open()
1266 snd_card_asihpi_capture_formats(card, dpcm->h_stream); in snd_card_asihpi_capture_open()
1272 if (card->support_grouping) in snd_card_asihpi_capture_open()
1275 runtime->hw = snd_card_asihpi_capture; in snd_card_asihpi_capture_open()
1277 if (card->can_dma) in snd_card_asihpi_capture_open()
1284 card->update_interval_frames); in snd_card_asihpi_capture_open()
1286 card->update_interval_frames, UINT_MAX); in snd_card_asihpi_capture_open()
1295 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; in snd_card_asihpi_capture_close()
1297 hpi_handle_error(hpi_instream_close(dpcm->h_stream)); in snd_card_asihpi_capture_close()
1319 err = hpi_adapter_get_info(asihpi->hpi->adapter->index, in snd_card_asihpi_pcm_new()
1323 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, in snd_card_asihpi_pcm_new()
1334 pcm->private_data = asihpi; in snd_card_asihpi_pcm_new()
1335 pcm->info_flags = 0; in snd_card_asihpi_pcm_new()
1336 strcpy(pcm->name, "Asihpi PCM"); in snd_card_asihpi_pcm_new()
1338 /*? do we want to emulate MMAP for non-BBM cards? in snd_card_asihpi_pcm_new()
1339 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ in snd_card_asihpi_pcm_new()
1341 snd_dma_pci_data(asihpi->pci), in snd_card_asihpi_pcm_new()
1363 "TV NTSC-M",
1393 "AVB",
1394 "BLU-Link"
1399 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)),
1412 "AVB",
1414 "BLU-Link"
1419 (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_NONE+1)),
1431 dev_info(&asihpi->pci->dev, "added %s(%d)\n", ctl->name, ctl->index); in ctl_add()
1443 snd_control->name = hpi_ctl->name; in asihpi_ctl_init()
1444 snd_control->private_value = hpi_ctl->h_control; in asihpi_ctl_init()
1445 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in asihpi_ctl_init()
1446 snd_control->index = 0; in asihpi_ctl_init()
1448 if (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE == HPI_SOURCENODE_CLOCK_SOURCE) in asihpi_ctl_init()
1450 else if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM) in asihpi_ctl_init()
1452 else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && in asihpi_ctl_init()
1453 (!hpi_ctl->dst_node_type)) in asihpi_ctl_init()
1455 else if (hpi_ctl->src_node_type && in asihpi_ctl_init()
1456 (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && in asihpi_ctl_init()
1457 (hpi_ctl->dst_node_type)) in asihpi_ctl_init()
1462 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type) in asihpi_ctl_init()
1463 sprintf(hpi_ctl->name, "%s %d %s %d %s%s", in asihpi_ctl_init()
1464 asihpi_src_names[hpi_ctl->src_node_type], in asihpi_ctl_init()
1465 hpi_ctl->src_node_index, in asihpi_ctl_init()
1466 asihpi_dst_names[hpi_ctl->dst_node_type], in asihpi_ctl_init()
1467 hpi_ctl->dst_node_index, in asihpi_ctl_init()
1469 else if (hpi_ctl->dst_node_type) { in asihpi_ctl_init()
1470 sprintf(hpi_ctl->name, "%s %d %s%s", in asihpi_ctl_init()
1471 asihpi_dst_names[hpi_ctl->dst_node_type], in asihpi_ctl_init()
1472 hpi_ctl->dst_node_index, in asihpi_ctl_init()
1475 sprintf(hpi_ctl->name, "%s %d %s%s", in asihpi_ctl_init()
1476 asihpi_src_names[hpi_ctl->src_node_type], in asihpi_ctl_init()
1477 hpi_ctl->src_node_index, in asihpi_ctl_init()
1480 /* printk(KERN_INFO "Adding %s %d to %d ", hpi_ctl->name, in asihpi_ctl_init()
1481 hpi_ctl->wSrcNodeType, hpi_ctl->wDstNodeType); */ in asihpi_ctl_init()
1484 /*------------------------------------------------------------
1486 ------------------------------------------------------------*/
1491 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_info()
1503 min_gain_mB = -10000; in snd_asihpi_volume_info()
1511 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_volume_info()
1512 uinfo->count = count; in snd_asihpi_volume_info()
1513 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1514 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1515 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1522 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_get()
1526 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; in snd_asihpi_volume_get()
1527 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; in snd_asihpi_volume_get()
1536 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_put()
1540 (ucontrol->value.integer.value[0]) * VOL_STEP_mB; in snd_asihpi_volume_put()
1542 (ucontrol->value.integer.value[1]) * VOL_STEP_mB; in snd_asihpi_volume_put()
1543 /* change = asihpi->mixer_volume[addr][0] != left || in snd_asihpi_volume_put()
1544 asihpi->mixer_volume[addr][1] != right; in snd_asihpi_volume_put()
1551 static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0);
1558 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_mute_get()
1562 ucontrol->value.integer.value[0] = mute ? 0 : 1; in snd_asihpi_volume_mute_get()
1570 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_mute_put()
1575 int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS; in snd_asihpi_volume_mute_put()
1583 struct snd_card *card = asihpi->card; in snd_asihpi_volume_add()
1600 if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) { in snd_asihpi_volume_add()
1611 /*------------------------------------------------------------
1613 ------------------------------------------------------------*/
1617 u32 h_control = kcontrol->private_value; in snd_asihpi_level_info()
1628 min_gain_mB = -1000; in snd_asihpi_level_info()
1632 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_level_info()
1633 uinfo->count = 2; in snd_asihpi_level_info()
1634 uinfo->value.integer.min = min_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1635 uinfo->value.integer.max = max_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1636 uinfo->value.integer.step = step_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1643 u32 h_control = kcontrol->private_value; in snd_asihpi_level_get()
1647 ucontrol->value.integer.value[0] = in snd_asihpi_level_get()
1649 ucontrol->value.integer.value[1] = in snd_asihpi_level_get()
1659 u32 h_control = kcontrol->private_value; in snd_asihpi_level_put()
1663 (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; in snd_asihpi_level_put()
1665 (ucontrol->value.integer.value[1]) * HPI_UNITS_PER_dB; in snd_asihpi_level_put()
1666 /* change = asihpi->mixer_level[addr][0] != left || in snd_asihpi_level_put()
1667 asihpi->mixer_level[addr][1] != right; in snd_asihpi_level_put()
1674 static const DECLARE_TLV_DB_SCALE(db_scale_level, -1000, 100, 0);
1679 struct snd_card *card = asihpi->card; in snd_asihpi_level_add()
1694 /*------------------------------------------------------------
1696 ------------------------------------------------------------*/
1712 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_format_get()
1718 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_aesebu_format_get()
1723 ucontrol->value.enumerated.item[0] = 1; in snd_asihpi_aesebu_format_get()
1725 ucontrol->value.enumerated.item[0] = 2; in snd_asihpi_aesebu_format_get()
1734 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_format_put()
1739 if (ucontrol->value.enumerated.item[0] == 1) in snd_asihpi_aesebu_format_put()
1741 if (ucontrol->value.enumerated.item[0] == 2) in snd_asihpi_aesebu_format_put()
1745 return -EINVAL; in snd_asihpi_aesebu_format_put()
1765 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_aesebu_rxstatus_info()
1766 uinfo->count = 1; in snd_asihpi_aesebu_rxstatus_info()
1768 uinfo->value.integer.min = 0; in snd_asihpi_aesebu_rxstatus_info()
1769 uinfo->value.integer.max = 0X1F; in snd_asihpi_aesebu_rxstatus_info()
1770 uinfo->value.integer.step = 1; in snd_asihpi_aesebu_rxstatus_info()
1778 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_rxstatus_get()
1783 ucontrol->value.integer.value[0] = status; in snd_asihpi_aesebu_rxstatus_get()
1790 struct snd_card *card = asihpi->card; in snd_asihpi_aesebu_rx_add()
1801 return -EINVAL; in snd_asihpi_aesebu_rx_add()
1828 struct snd_card *card = asihpi->card; in snd_asihpi_aesebu_tx_add()
1840 /*------------------------------------------------------------
1842 ------------------------------------------------------------*/
1849 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_info()
1861 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_tuner_gain_info()
1862 uinfo->count = 1; in snd_asihpi_tuner_gain_info()
1863 uinfo->value.integer.min = ((int)gain_range[0]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1864 uinfo->value.integer.max = ((int)gain_range[1]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1865 uinfo->value.integer.step = ((int) gain_range[2]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1875 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_get()
1879 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_get()
1890 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_put()
1893 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_put()
1903 u32 h_control = kcontrol->private_value; in asihpi_tuner_band_query()
1915 return -EIO; in asihpi_tuner_band_query()
1938 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_band_get()
1951 ucontrol->value.enumerated.item[0] = -1; in snd_asihpi_tuner_band_get()
1954 ucontrol->value.enumerated.item[0] = idx; in snd_asihpi_tuner_band_get()
1967 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_band_put()
1976 idx = ucontrol->value.enumerated.item[0]; in snd_asihpi_tuner_band_put()
1978 idx = ARRAY_SIZE(tuner_bands) - 1; in snd_asihpi_tuner_band_put()
1990 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_info()
2024 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_tuner_freq_info()
2025 uinfo->count = 1; in snd_asihpi_tuner_freq_info()
2026 uinfo->value.integer.min = ((int)freq_range[0]); in snd_asihpi_tuner_freq_info()
2027 uinfo->value.integer.max = ((int)freq_range[1]); in snd_asihpi_tuner_freq_info()
2028 uinfo->value.integer.step = ((int)freq_range[2]); in snd_asihpi_tuner_freq_info()
2035 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_get()
2039 ucontrol->value.integer.value[0] = freq; in snd_asihpi_tuner_freq_get()
2047 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_put()
2050 freq = ucontrol->value.integer.value[0]; in snd_asihpi_tuner_freq_put()
2060 struct snd_card *card = asihpi->card; in snd_asihpi_tuner_add()
2063 snd_control.private_value = hpi_ctl->h_control; in snd_asihpi_tuner_add()
2066 if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) { in snd_asihpi_tuner_add()
2073 return -EINVAL; in snd_asihpi_tuner_add()
2082 return -EINVAL; in snd_asihpi_tuner_add()
2092 /*------------------------------------------------------------
2094 ------------------------------------------------------------*/
2098 u32 h_control = kcontrol->private_value; in snd_asihpi_meter_info()
2105 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_meter_info()
2106 uinfo->count = count; in snd_asihpi_meter_info()
2107 uinfo->value.integer.min = 0; in snd_asihpi_meter_info()
2108 uinfo->value.integer.max = 0x7FFFFFFF; in snd_asihpi_meter_info()
2120 2147484, /* -60dB */
2122 214748, /* -80 */
2124 21475, /* -100 */
2138 u32 h_control = kcontrol->private_value; in snd_asihpi_meter_get()
2146 ucontrol->value.integer.value[i] = 0; in snd_asihpi_meter_get()
2148 ucontrol->value.integer.value[i] = in snd_asihpi_meter_get()
2151 /* -ve is log value in millibels < -60dB, in snd_asihpi_meter_get()
2154 ucontrol->value.integer.value[i] = in snd_asihpi_meter_get()
2155 log2lin[an_gain_mB[i] / -1000]; in snd_asihpi_meter_get()
2164 struct snd_card *card = asihpi->card; in snd_asihpi_meter_add()
2178 /*------------------------------------------------------------
2180 ------------------------------------------------------------*/
2183 u32 h_control = snd_control->private_value; in snd_card_asihpi_mux_count_sources()
2203 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_info()
2205 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_asihpi_mux_info()
2206 uinfo->count = 1; in snd_asihpi_mux_info()
2207 uinfo->value.enumerated.items = in snd_asihpi_mux_info()
2210 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in snd_asihpi_mux_info()
2211 uinfo->value.enumerated.item = in snd_asihpi_mux_info()
2212 uinfo->value.enumerated.items - 1; in snd_asihpi_mux_info()
2216 uinfo->value.enumerated.item, in snd_asihpi_mux_info()
2219 sprintf(uinfo->value.enumerated.name, "%s %d", in snd_asihpi_mux_info()
2220 asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE], in snd_asihpi_mux_info()
2228 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_get()
2243 ucontrol->value.enumerated.item[0] = s; in snd_asihpi_mux_get()
2250 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_mux_get()
2258 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_put()
2265 ucontrol->value.enumerated.item[0], in snd_asihpi_mux_put()
2278 struct snd_card *card = asihpi->card; in snd_asihpi_mux_add()
2291 /*------------------------------------------------------------
2293 ------------------------------------------------------------*/
2304 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_info()
2321 return -EINVAL; in snd_asihpi_cmode_info()
2329 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_get()
2335 ucontrol->value.enumerated.item[0] = mode - 1; in snd_asihpi_cmode_get()
2344 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_put()
2349 ucontrol->value.enumerated.item[0] + 1)); in snd_asihpi_cmode_put()
2357 struct snd_card *card = asihpi->card; in snd_asihpi_cmode_add()
2369 /*------------------------------------------------------------
2371 ------------------------------------------------------------*/
2375 "Prev Module", "BLU-Link",
2388 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_info()
2389 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_info()
2390 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_asihpi_clksrc_info()
2391 uinfo->count = 1; in snd_asihpi_clksrc_info()
2392 uinfo->value.enumerated.items = clkcache->count; in snd_asihpi_clksrc_info()
2394 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in snd_asihpi_clksrc_info()
2395 uinfo->value.enumerated.item = in snd_asihpi_clksrc_info()
2396 uinfo->value.enumerated.items - 1; in snd_asihpi_clksrc_info()
2398 strcpy(uinfo->value.enumerated.name, in snd_asihpi_clksrc_info()
2399 clkcache->s[uinfo->value.enumerated.item].name); in snd_asihpi_clksrc_info()
2407 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_get()
2408 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_get()
2409 u32 h_control = kcontrol->private_value; in snd_asihpi_clksrc_get()
2413 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_clksrc_get()
2421 for (i = 0; i < clkcache->count; i++) in snd_asihpi_clksrc_get()
2422 if ((clkcache->s[i].source == source) && in snd_asihpi_clksrc_get()
2423 (clkcache->s[i].index == srcindex)) in snd_asihpi_clksrc_get()
2426 ucontrol->value.enumerated.item[0] = i; in snd_asihpi_clksrc_get()
2435 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_put()
2436 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_put()
2439 u32 h_control = kcontrol->private_value; in snd_asihpi_clksrc_put()
2442 item = ucontrol->value.enumerated.item[0]; in snd_asihpi_clksrc_put()
2443 if (item >= clkcache->count) in snd_asihpi_clksrc_put()
2444 item = clkcache->count-1; in snd_asihpi_clksrc_put()
2447 h_control, clkcache->s[item].source)); in snd_asihpi_clksrc_put()
2449 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) in snd_asihpi_clksrc_put()
2451 h_control, clkcache->s[item].index)); in snd_asihpi_clksrc_put()
2455 /*------------------------------------------------------------
2457 ------------------------------------------------------------*/
2462 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_clklocal_info()
2463 uinfo->count = 1; in snd_asihpi_clklocal_info()
2464 uinfo->value.integer.min = 8000; in snd_asihpi_clklocal_info()
2465 uinfo->value.integer.max = 192000; in snd_asihpi_clklocal_info()
2466 uinfo->value.integer.step = 100; in snd_asihpi_clklocal_info()
2474 u32 h_control = kcontrol->private_value; in snd_asihpi_clklocal_get()
2480 ucontrol->value.integer.value[0] = rate; in snd_asihpi_clklocal_get()
2482 ucontrol->value.integer.value[0] = 0; in snd_asihpi_clklocal_get()
2490 u32 h_control = kcontrol->private_value; in snd_asihpi_clklocal_put()
2492 /* change = asihpi->mixer_clkrate[addr][0] != left || in snd_asihpi_clklocal_put()
2493 asihpi->mixer_clkrate[addr][1] != right; in snd_asihpi_clklocal_put()
2497 ucontrol->value.integer.value[0])); in snd_asihpi_clklocal_put()
2504 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_clkrate_info()
2505 uinfo->count = 1; in snd_asihpi_clkrate_info()
2506 uinfo->value.integer.min = 8000; in snd_asihpi_clkrate_info()
2507 uinfo->value.integer.max = 192000; in snd_asihpi_clkrate_info()
2508 uinfo->value.integer.step = 100; in snd_asihpi_clkrate_info()
2516 u32 h_control = kcontrol->private_value; in snd_asihpi_clkrate_get()
2522 ucontrol->value.integer.value[0] = rate; in snd_asihpi_clkrate_get()
2524 ucontrol->value.integer.value[0] = 0; in snd_asihpi_clkrate_get()
2535 u32 hSC = hpi_ctl->h_control; in snd_asihpi_sampleclock_add()
2541 return -EINVAL; in snd_asihpi_sampleclock_add()
2542 card = asihpi->card; in snd_asihpi_sampleclock_add()
2543 clkcache = &asihpi->cc; in snd_asihpi_sampleclock_add()
2544 snd_control.private_value = hpi_ctl->h_control; in snd_asihpi_sampleclock_add()
2546 clkcache->has_local = 0; in snd_asihpi_sampleclock_add()
2552 clkcache->s[i].source = source; in snd_asihpi_sampleclock_add()
2553 clkcache->s[i].index = 0; in snd_asihpi_sampleclock_add()
2554 clkcache->s[i].name = sampleclock_sources[source]; in snd_asihpi_sampleclock_add()
2558 clkcache->has_local = 1; in snd_asihpi_sampleclock_add()
2567 clkcache->s[i].source = in snd_asihpi_sampleclock_add()
2569 clkcache->s[i].index = j; in snd_asihpi_sampleclock_add()
2570 clkcache->s[i].name = sampleclock_sources[ in snd_asihpi_sampleclock_add()
2574 clkcache->count = i; in snd_asihpi_sampleclock_add()
2582 return -EINVAL; in snd_asihpi_sampleclock_add()
2585 if (clkcache->has_local) { in snd_asihpi_sampleclock_add()
2594 return -EINVAL; in snd_asihpi_sampleclock_add()
2605 /*------------------------------------------------------------
2607 ------------------------------------------------------------*/
2618 return -EINVAL; in snd_card_asihpi_mixer_new()
2619 card = asihpi->card; in snd_card_asihpi_mixer_new()
2620 strcpy(card->mixername, "Asihpi Mixer"); in snd_card_asihpi_mixer_new()
2623 hpi_mixer_open(asihpi->hpi->adapter->index, in snd_card_asihpi_mixer_new()
2624 &asihpi->h_mixer); in snd_card_asihpi_mixer_new()
2627 return -err; in snd_card_asihpi_mixer_new()
2630 prev_ctl.control_type = -1; in snd_card_asihpi_mixer_new()
2634 asihpi->h_mixer, in snd_card_asihpi_mixer_new()
2645 dev_info(&asihpi->pci->dev, in snd_card_asihpi_mixer_new()
2654 hpi_ctl.src_node_type -= HPI_SOURCENODE_NONE; in snd_card_asihpi_mixer_new()
2655 hpi_ctl.dst_node_type -= HPI_DESTNODE_NONE; in snd_card_asihpi_mixer_new()
2710 dev_info(&asihpi->pci->dev, in snd_card_asihpi_mixer_new()
2726 dev_info(&asihpi->pci->dev, "%d mixer controls found\n", idx); in snd_card_asihpi_mixer_new()
2731 /*------------------------------------------------------------
2733 ------------------------------------------------------------*/
2739 struct snd_card_asihpi *asihpi = entry->private_data; in snd_asihpi_proc_read()
2754 hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index, in snd_asihpi_proc_read()
2761 type, asihpi->hpi->adapter->index, in snd_asihpi_proc_read()
2769 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_asihpi_proc_read()
2787 if (!snd_card_proc_new(asihpi->card, "info", &entry)) in snd_asihpi_proc_init()
2791 /*------------------------------------------------------------
2793 ------------------------------------------------------------*/
2800 return -ENODEV; in snd_asihpi_hpi_open()
2809 return -ENODEV; in snd_asihpi_hpi_release()
2818 return -ENODEV; in snd_asihpi_hpi_ioctl()
2823 also /proc/asound/hwdep will contain '#-00: asihpi (HPI) for each card'
2830 err = snd_hwdep_new(asihpi->card, "HPI", device, &hw); in snd_asihpi_hpi_new()
2833 strcpy(hw->name, "asihpi (HPI)"); in snd_asihpi_hpi_new()
2834 hw->iface = SNDRV_HWDEP_IFACE_LAST; in snd_asihpi_hpi_new()
2835 hw->ops.open = snd_asihpi_hpi_open; in snd_asihpi_hpi_new()
2836 hw->ops.ioctl = snd_asihpi_hpi_ioctl; in snd_asihpi_hpi_new()
2837 hw->ops.release = snd_asihpi_hpi_release; in snd_asihpi_hpi_new()
2838 hw->private_data = asihpi; in snd_asihpi_hpi_new()
2842 /*------------------------------------------------------------
2844 ------------------------------------------------------------*/
2859 return -ENODEV; in snd_asihpi_probe()
2861 /* Should this be enable[hpi->index] ? */ in snd_asihpi_probe()
2864 return -ENOENT; in snd_asihpi_probe()
2867 /* Initialise low-level HPI driver */ in snd_asihpi_probe()
2873 adapter_index = hpi->adapter->index; in snd_asihpi_probe()
2875 err = snd_card_new(&pci_dev->dev, adapter_index, id[adapter_index], in snd_asihpi_probe()
2879 err = snd_card_new(&pci_dev->dev, index[dev], id[dev], in snd_asihpi_probe()
2884 dev_warn(&pci_dev->dev, "Adapter index %d->ALSA index %d\n", in snd_asihpi_probe()
2885 adapter_index, card->number); in snd_asihpi_probe()
2888 asihpi = card->private_data; in snd_asihpi_probe()
2889 asihpi->card = card; in snd_asihpi_probe()
2890 asihpi->pci = pci_dev; in snd_asihpi_probe()
2891 asihpi->hpi = hpi; in snd_asihpi_probe()
2892 hpi->snd_card = card; in snd_asihpi_probe()
2896 NULL, &asihpi->support_grouping); in snd_asihpi_probe()
2898 asihpi->support_grouping = 0; in snd_asihpi_probe()
2902 &asihpi->support_mrx, NULL); in snd_asihpi_probe()
2904 asihpi->support_mrx = 0; in snd_asihpi_probe()
2908 NULL, &asihpi->update_interval_frames); in snd_asihpi_probe()
2910 asihpi->update_interval_frames = 512; in snd_asihpi_probe()
2912 if (hpi->interrupt_mode) { in snd_asihpi_probe()
2913 asihpi->pcm_start = snd_card_asihpi_pcm_int_start; in snd_asihpi_probe()
2914 asihpi->pcm_stop = snd_card_asihpi_pcm_int_stop; in snd_asihpi_probe()
2915 tasklet_init(&asihpi->t, snd_card_asihpi_int_task, in snd_asihpi_probe()
2917 hpi->interrupt_callback = snd_card_asihpi_isr; in snd_asihpi_probe()
2919 asihpi->pcm_start = snd_card_asihpi_pcm_timer_start; in snd_asihpi_probe()
2920 asihpi->pcm_stop = snd_card_asihpi_pcm_timer_stop; in snd_asihpi_probe()
2927 asihpi->can_dma = (!err); in snd_asihpi_probe()
2931 if (!asihpi->can_dma) in snd_asihpi_probe()
2932 asihpi->update_interval_frames *= 2; in snd_asihpi_probe()
2936 &asihpi->in_max_chans, &asihpi->out_max_chans); in snd_asihpi_probe()
2938 asihpi->in_max_chans = 2; in snd_asihpi_probe()
2939 asihpi->out_max_chans = 2; in snd_asihpi_probe()
2942 if (asihpi->out_max_chans > 2) { /* assume LL mode */ in snd_asihpi_probe()
2943 asihpi->out_min_chans = asihpi->out_max_chans; in snd_asihpi_probe()
2944 asihpi->in_min_chans = asihpi->in_max_chans; in snd_asihpi_probe()
2945 asihpi->support_grouping = 0; in snd_asihpi_probe()
2947 asihpi->out_min_chans = 1; in snd_asihpi_probe()
2948 asihpi->in_min_chans = 1; in snd_asihpi_probe()
2951 dev_info(&pci_dev->dev, "Has dma:%d, grouping:%d, mrx:%d, uif:%d\n", in snd_asihpi_probe()
2952 asihpi->can_dma, in snd_asihpi_probe()
2953 asihpi->support_grouping, in snd_asihpi_probe()
2954 asihpi->support_mrx, in snd_asihpi_probe()
2955 asihpi->update_interval_frames in snd_asihpi_probe()
2960 dev_err(&pci_dev->dev, "pcm_new failed\n"); in snd_asihpi_probe()
2965 dev_err(&pci_dev->dev, "mixer_new failed\n"); in snd_asihpi_probe()
2969 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_asihpi_probe()
2983 strcpy(card->driver, "ASIHPI"); in snd_asihpi_probe()
2985 sprintf(card->shortname, "AudioScience ASI%4X", in snd_asihpi_probe()
2986 asihpi->hpi->adapter->type); in snd_asihpi_probe()
2987 sprintf(card->longname, "%s %i", in snd_asihpi_probe()
2988 card->shortname, adapter_index); in snd_asihpi_probe()
2997 dev_err(&pci_dev->dev, "snd_asihpi_probe error %d\n", err); in snd_asihpi_probe()
3005 struct snd_card_asihpi *asihpi = hpi->snd_card->private_data; in snd_asihpi_remove()
3008 if (hpi->interrupt_mode) { in snd_asihpi_remove()
3009 hpi->interrupt_callback = NULL; in snd_asihpi_remove()
3010 hpi_handle_error(hpi_adapter_set_property(hpi->adapter->index, in snd_asihpi_remove()
3012 tasklet_kill(&asihpi->t); in snd_asihpi_remove()
3015 snd_card_free(hpi->snd_card); in snd_asihpi_remove()
3016 hpi->snd_card = NULL; in snd_asihpi_remove()