Lines Matching +full:asi +full:- +full:format
1 // SPDX-License-Identifier: GPL-2.0-only
40 #define asihpi_dbg(format, args...) pr_debug(format, ##args) argument
42 #define asihpi_dbg(format, args...) do { } while (0) argument
45 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
141 struct hpi_format format; member
266 struct device *dev = substream->pcm->card->dev; in print_hwparams()
271 dev_dbg(dev, " samplerate=%dHz channels=%d format=%d subformat=%d\n", in print_hwparams()
283 #define INVALID_FORMAT (__force snd_pcm_format_t)(-1)
302 /* ALSA can't handle 3 byte sample size together with power-of-2
303 * constraint on buffer_bytes, so disable this format
316 u16 format; in snd_card_asihpi_format_alsa2hpi() local
318 for (format = HPI_FORMAT_PCM8_UNSIGNED; in snd_card_asihpi_format_alsa2hpi()
319 format <= HPI_FORMAT_PCM24_SIGNED; format++) { in snd_card_asihpi_format_alsa2hpi()
320 if (hpi_to_alsa_formats[format] == alsa_format) { in snd_card_asihpi_format_alsa2hpi()
321 *hpi_format = format; in snd_card_asihpi_format_alsa2hpi()
326 dev_dbg(asihpi->card->dev, "failed match for alsa format %d\n", in snd_card_asihpi_format_alsa2hpi()
329 return -EINVAL; in snd_card_asihpi_format_alsa2hpi()
343 if (asihpi->support_mrx) { in snd_card_asihpi_pcm_samplerates()
351 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_pcm_samplerates()
355 dev_err(&asihpi->pci->dev, in snd_card_asihpi_pcm_samplerates()
359 for (idx = -1; idx < 100; idx++) { in snd_card_asihpi_pcm_samplerates()
360 if (idx == -1) { in snd_card_asihpi_pcm_samplerates()
418 pcmhw->rates = rates; in snd_card_asihpi_pcm_samplerates()
419 pcmhw->rate_min = rate_min; in snd_card_asihpi_pcm_samplerates()
420 pcmhw->rate_max = rate_max; in snd_card_asihpi_pcm_samplerates()
426 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_hw_params()
427 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_hw_params()
430 u16 format; in snd_card_asihpi_pcm_hw_params() local
435 err = snd_card_asihpi_format_alsa2hpi(card, params_format(params), &format); in snd_card_asihpi_pcm_hw_params()
439 hpi_handle_error(hpi_format_create(&dpcm->format, in snd_card_asihpi_pcm_hw_params()
441 format, params_rate(params), 0, 0)); in snd_card_asihpi_pcm_hw_params()
443 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) { in snd_card_asihpi_pcm_hw_params()
444 if (hpi_instream_reset(dpcm->h_stream) != 0) in snd_card_asihpi_pcm_hw_params()
445 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
448 dpcm->h_stream, &dpcm->format) != 0) in snd_card_asihpi_pcm_hw_params()
449 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
452 dpcm->hpi_buffer_attached = 0; in snd_card_asihpi_pcm_hw_params()
453 if (card->can_dma) { in snd_card_asihpi_pcm_hw_params()
454 err = hpi_stream_host_buffer_attach(dpcm->h_stream, in snd_card_asihpi_pcm_hw_params()
455 params_buffer_bytes(params), runtime->dma_addr); in snd_card_asihpi_pcm_hw_params()
457 dev_dbg(card->card->dev, in snd_card_asihpi_pcm_hw_params()
460 (unsigned long)runtime->dma_addr); in snd_card_asihpi_pcm_hw_params()
462 dev_dbg(card->card->dev, in snd_card_asihpi_pcm_hw_params()
464 return -ENOMEM; in snd_card_asihpi_pcm_hw_params()
467 err = hpi_stream_get_info_ex(dpcm->h_stream, NULL, in snd_card_asihpi_pcm_hw_params()
468 &dpcm->hpi_buffer_attached, NULL, NULL, NULL); in snd_card_asihpi_pcm_hw_params()
475 return -EINVAL; in snd_card_asihpi_pcm_hw_params()
477 dpcm->bytes_per_sec = bytes_per_sec; in snd_card_asihpi_pcm_hw_params()
478 dpcm->buffer_bytes = params_buffer_bytes(params); in snd_card_asihpi_pcm_hw_params()
479 dpcm->period_bytes = params_period_bytes(params); in snd_card_asihpi_pcm_hw_params()
487 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_hw_free()
488 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_hw_free()
489 if (dpcm->hpi_buffer_attached) in snd_card_asihpi_hw_free()
490 hpi_stream_host_buffer_detach(dpcm->h_stream); in snd_card_asihpi_hw_free()
497 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_runtime_free()
504 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_timer_start()
505 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_timer_start()
511 mod_timer(&dpcm->timer, jiffies + expiry); in snd_card_asihpi_pcm_timer_start()
512 dpcm->respawn_timer = 1; in snd_card_asihpi_pcm_timer_start()
517 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_pcm_timer_stop()
518 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_pcm_timer_stop()
520 dpcm->respawn_timer = 0; in snd_card_asihpi_pcm_timer_stop()
521 del_timer(&dpcm->timer); in snd_card_asihpi_pcm_timer_stop()
529 dpcm = (struct snd_card_asihpi_pcm *)substream->runtime->private_data; in snd_card_asihpi_pcm_int_start()
533 card->llmode_streampriv = dpcm; in snd_card_asihpi_pcm_int_start()
535 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index, in snd_card_asihpi_pcm_int_start()
537 card->update_interval_frames, 0)); in snd_card_asihpi_pcm_int_start()
546 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index, in snd_card_asihpi_pcm_int_stop()
549 card->llmode_streampriv = NULL; in snd_card_asihpi_pcm_int_stop()
555 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; in snd_card_asihpi_trigger()
565 dev_dbg(card->card->dev, "%s trigger start\n", name); in snd_card_asihpi_trigger()
567 struct snd_pcm_runtime *runtime = s->runtime; in snd_card_asihpi_trigger()
568 struct snd_card_asihpi_pcm *ds = runtime->private_data; in snd_card_asihpi_trigger()
574 if (substream->stream != s->stream) in snd_card_asihpi_trigger()
577 ds->drained_count = 0; in snd_card_asihpi_trigger()
578 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_trigger()
585 unsigned int preload = ds->period_bytes * 1; in snd_card_asihpi_trigger()
586 asihpi_dbg("%d preload %d\n", s->number, preload); in snd_card_asihpi_trigger()
588 ds->h_stream, in snd_card_asihpi_trigger()
589 &runtime->dma_area[0], in snd_card_asihpi_trigger()
591 &ds->format)); in snd_card_asihpi_trigger()
592 ds->pcm_buf_host_rw_ofs = preload; in snd_card_asihpi_trigger()
595 if (card->support_grouping) { in snd_card_asihpi_trigger()
596 dev_dbg(card->card->dev, "%d group\n", s->number); in snd_card_asihpi_trigger()
598 dpcm->h_stream, in snd_card_asihpi_trigger()
599 ds->h_stream); in snd_card_asihpi_trigger()
610 card->pcm_start(substream); in snd_card_asihpi_trigger()
611 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) || in snd_card_asihpi_trigger()
612 !card->can_dma) in snd_card_asihpi_trigger()
613 hpi_handle_error(hpi_stream_start(dpcm->h_stream)); in snd_card_asihpi_trigger()
617 dev_dbg(card->card->dev, "%s trigger stop\n", name); in snd_card_asihpi_trigger()
618 card->pcm_stop(substream); in snd_card_asihpi_trigger()
623 if (substream->stream != s->stream) in snd_card_asihpi_trigger()
628 __snd_pcm_set_state(s->runtime, SNDRV_PCM_STATE_SETUP); in snd_card_asihpi_trigger()
630 if (card->support_grouping) { in snd_card_asihpi_trigger()
631 dev_dbg(card->card->dev, "%d group\n", s->number); in snd_card_asihpi_trigger()
638 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); in snd_card_asihpi_trigger()
639 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in snd_card_asihpi_trigger()
641 hpi_outstream_reset(dpcm->h_stream)); in snd_card_asihpi_trigger()
643 if (card->support_grouping) in snd_card_asihpi_trigger()
644 hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream)); in snd_card_asihpi_trigger()
648 dev_dbg(card->card->dev, "%s trigger pause release\n", name); in snd_card_asihpi_trigger()
649 card->pcm_start(substream); in snd_card_asihpi_trigger()
650 hpi_handle_error(hpi_stream_start(dpcm->h_stream)); in snd_card_asihpi_trigger()
653 dev_dbg(card->card->dev, "%s trigger pause push\n", name); in snd_card_asihpi_trigger()
654 card->pcm_stop(substream); in snd_card_asihpi_trigger()
655 hpi_handle_error(hpi_stream_stop(dpcm->h_stream)); in snd_card_asihpi_trigger()
658 dev_dbg(card->card->dev, "\tINVALID\n"); in snd_card_asihpi_trigger()
659 return -EINVAL; in snd_card_asihpi_trigger()
678 s->pcm_buf_dma_ofs = min_buf_pos;
700 if (((a-b) % modulus) < (modulus/2)) in modulo_min()
713 struct snd_pcm_substream *substream = dpcm->substream; in snd_card_asihpi_timer_function()
730 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; in snd_card_asihpi_timer_function()
731 runtime = s->runtime; in snd_card_asihpi_timer_function()
737 if (substream->stream != s->stream) in snd_card_asihpi_timer_function()
741 ds->h_stream, &state, in snd_card_asihpi_timer_function()
745 /* number of bytes in on-card buffer */ in snd_card_asihpi_timer_function()
746 runtime->delay = on_card_bytes; in snd_card_asihpi_timer_function()
748 if (!card->can_dma) in snd_card_asihpi_timer_function()
751 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_timer_function()
752 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail; in snd_card_asihpi_timer_function()
755 hpi_handle_error(hpi_stream_start(ds->h_stream)); in snd_card_asihpi_timer_function()
756 dev_dbg(card->card->dev, in snd_card_asihpi_timer_function()
757 "P%d start\n", s->number); in snd_card_asihpi_timer_function()
758 ds->drained_count = 0; in snd_card_asihpi_timer_function()
761 dev_dbg(card->card->dev, in snd_card_asihpi_timer_function()
762 "P%d drained\n", s->number); in snd_card_asihpi_timer_function()
763 ds->drained_count++; in snd_card_asihpi_timer_function()
764 if (ds->drained_count > 20) { in snd_card_asihpi_timer_function()
769 ds->drained_count = 0; in snd_card_asihpi_timer_function()
772 pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs; in snd_card_asihpi_timer_function()
777 newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes; in snd_card_asihpi_timer_function()
783 (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes, in snd_card_asihpi_timer_function()
789 name, s->number, state, in snd_card_asihpi_timer_function()
790 ds->pcm_buf_elapsed_dma_ofs, in snd_card_asihpi_timer_function()
791 ds->pcm_buf_host_rw_ofs, in snd_card_asihpi_timer_function()
796 buffer_size-bytes_avail, in snd_card_asihpi_timer_function()
798 runtime->status->hw_ptr), in snd_card_asihpi_timer_function()
800 runtime->control->appl_ptr) in snd_card_asihpi_timer_function()
805 remdata = newdata % dpcm->period_bytes; in snd_card_asihpi_timer_function()
806 xfercount = newdata - remdata; /* a multiple of period_bytes */ in snd_card_asihpi_timer_function()
811 if (xfercount && (on_card_bytes > dpcm->period_bytes)) in snd_card_asihpi_timer_function()
812 next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec); in snd_card_asihpi_timer_function()
814 next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec); in snd_card_asihpi_timer_function()
817 dpcm->timer.expires = jiffies + next_jiffies; in snd_card_asihpi_timer_function()
822 struct snd_card_asihpi_pcm *ds = s->runtime->private_data; in snd_card_asihpi_timer_function()
825 if (substream->stream != s->stream) in snd_card_asihpi_timer_function()
829 ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs; in snd_card_asihpi_timer_function()
833 ((on_card_bytes <= ds->period_bytes) || in snd_card_asihpi_timer_function()
834 (s->stream == SNDRV_PCM_STREAM_CAPTURE))) in snd_card_asihpi_timer_function()
838 unsigned int buf_ofs = ds->pcm_buf_host_rw_ofs % ds->buffer_bytes; in snd_card_asihpi_timer_function()
840 char *pd = &s->runtime->dma_area[buf_ofs]; in snd_card_asihpi_timer_function()
842 if (card->can_dma) { /* buffer wrap is handled at lower level */ in snd_card_asihpi_timer_function()
846 xfer1 = min(xfercount, ds->buffer_bytes - buf_ofs); in snd_card_asihpi_timer_function()
847 xfer2 = xfercount - xfer1; in snd_card_asihpi_timer_function()
850 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) { in snd_card_asihpi_timer_function()
852 s->number, xfer1, buf_ofs); in snd_card_asihpi_timer_function()
855 ds->h_stream, pd, xfer1, in snd_card_asihpi_timer_function()
856 &ds->format)); in snd_card_asihpi_timer_function()
859 pd = s->runtime->dma_area; in snd_card_asihpi_timer_function()
862 s->number, in snd_card_asihpi_timer_function()
863 xfercount - xfer1, buf_ofs); in snd_card_asihpi_timer_function()
866 ds->h_stream, pd, in snd_card_asihpi_timer_function()
867 xfercount - xfer1, in snd_card_asihpi_timer_function()
868 &ds->format)); in snd_card_asihpi_timer_function()
872 s->number, xfer1); in snd_card_asihpi_timer_function()
875 ds->h_stream, in snd_card_asihpi_timer_function()
878 pd = s->runtime->dma_area; in snd_card_asihpi_timer_function()
880 s->number, xfer2); in snd_card_asihpi_timer_function()
883 ds->h_stream, in snd_card_asihpi_timer_function()
888 ds->pcm_buf_host_rw_ofs += xfercount; in snd_card_asihpi_timer_function()
889 ds->pcm_buf_elapsed_dma_ofs += xfercount; in snd_card_asihpi_timer_function()
894 if (!card->hpi->interrupt_mode && dpcm->respawn_timer) in snd_card_asihpi_timer_function()
895 add_timer(&dpcm->timer); in snd_card_asihpi_timer_function()
902 WARN_ON(!a || !a->snd_card || !a->snd_card->private_data); in snd_card_asihpi_isr()
903 asihpi = (struct snd_card_asihpi *)a->snd_card->private_data; in snd_card_asihpi_isr()
904 if (asihpi->llmode_streampriv) in snd_card_asihpi_isr()
906 &asihpi->llmode_streampriv->timer); in snd_card_asihpi_isr()
913 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_prepare()
914 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_prepare()
916 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream)); in snd_card_asihpi_playback_prepare()
917 dpcm->pcm_buf_host_rw_ofs = 0; in snd_card_asihpi_playback_prepare()
918 dpcm->pcm_buf_dma_ofs = 0; in snd_card_asihpi_playback_prepare()
919 dpcm->pcm_buf_elapsed_dma_ofs = 0; in snd_card_asihpi_playback_prepare()
926 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_pointer()
927 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_pointer()
932 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); in snd_card_asihpi_playback_pointer()
941 u16 format; in snd_card_asihpi_playback_formats() local
950 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_playback_formats()
958 for (format = HPI_FORMAT_PCM8_UNSIGNED; in snd_card_asihpi_playback_formats()
959 format <= HPI_FORMAT_PCM24_SIGNED; format++) { in snd_card_asihpi_playback_formats()
960 err = hpi_format_create(&hpi_format, asihpi->out_max_chans, in snd_card_asihpi_playback_formats()
961 format, sample_rate, 128000, 0); in snd_card_asihpi_playback_formats()
964 if (!err && (hpi_to_alsa_formats[format] != INVALID_FORMAT)) in snd_card_asihpi_playback_formats()
965 formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]); in snd_card_asihpi_playback_formats()
972 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_open()
980 return -ENOMEM; in snd_card_asihpi_playback_open()
982 err = hpi_outstream_open(card->hpi->adapter->index, in snd_card_asihpi_playback_open()
983 substream->number, &dpcm->h_stream); in snd_card_asihpi_playback_open()
988 return -EBUSY; in snd_card_asihpi_playback_open()
990 return -EIO; in snd_card_asihpi_playback_open()
997 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0); in snd_card_asihpi_playback_open()
998 dpcm->substream = substream; in snd_card_asihpi_playback_open()
999 runtime->private_data = dpcm; in snd_card_asihpi_playback_open()
1000 runtime->private_free = snd_card_asihpi_runtime_free; in snd_card_asihpi_playback_open()
1003 if (!card->hpi->interrupt_mode) { in snd_card_asihpi_playback_open()
1010 size_t pbmin = card->update_interval_frames * in snd_card_asihpi_playback_open()
1011 card->out_max_chans; in snd_card_asihpi_playback_open()
1020 snd_card_asihpi_playback.channels_max = card->out_max_chans; in snd_card_asihpi_playback_open()
1021 snd_card_asihpi_playback.channels_min = card->out_min_chans; in snd_card_asihpi_playback_open()
1023 snd_card_asihpi_playback_formats(card, dpcm->h_stream); in snd_card_asihpi_playback_open()
1035 if (card->support_grouping) { in snd_card_asihpi_playback_open()
1041 runtime->hw = snd_card_asihpi_playback; in snd_card_asihpi_playback_open()
1043 if (card->can_dma) in snd_card_asihpi_playback_open()
1050 card->update_interval_frames); in snd_card_asihpi_playback_open()
1053 card->update_interval_frames, UINT_MAX); in snd_card_asihpi_playback_open()
1060 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_playback_close()
1061 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_playback_close()
1063 hpi_handle_error(hpi_outstream_close(dpcm->h_stream)); in snd_card_asihpi_playback_close()
1081 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_pointer()
1082 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_capture_pointer()
1086 asihpi_dbg("%s, pointer=%d\n", name, dpcm->pcm_buf_dma_ofs); in snd_card_asihpi_capture_pointer()
1091 return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes); in snd_card_asihpi_capture_pointer()
1096 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_prepare()
1097 struct snd_card_asihpi_pcm *dpcm = runtime->private_data; in snd_card_asihpi_capture_prepare()
1099 hpi_handle_error(hpi_instream_reset(dpcm->h_stream)); in snd_card_asihpi_capture_prepare()
1100 dpcm->pcm_buf_host_rw_ofs = 0; in snd_card_asihpi_capture_prepare()
1101 dpcm->pcm_buf_dma_ofs = 0; in snd_card_asihpi_capture_prepare()
1102 dpcm->pcm_buf_elapsed_dma_ofs = 0; in snd_card_asihpi_capture_prepare()
1111 u16 format; in snd_card_asihpi_capture_formats() local
1119 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_card_asihpi_capture_formats()
1127 for (format = HPI_FORMAT_PCM8_UNSIGNED; in snd_card_asihpi_capture_formats()
1128 format <= HPI_FORMAT_PCM24_SIGNED; format++) { in snd_card_asihpi_capture_formats()
1130 err = hpi_format_create(&hpi_format, asihpi->in_max_chans, in snd_card_asihpi_capture_formats()
1131 format, sample_rate, 128000, 0); in snd_card_asihpi_capture_formats()
1134 if (!err && (hpi_to_alsa_formats[format] != INVALID_FORMAT)) in snd_card_asihpi_capture_formats()
1135 formats |= pcm_format_to_bits(hpi_to_alsa_formats[format]); in snd_card_asihpi_capture_formats()
1142 struct snd_pcm_runtime *runtime = substream->runtime; in snd_card_asihpi_capture_open()
1150 return -ENOMEM; in snd_card_asihpi_capture_open()
1153 dev_dbg(card->card->dev, "capture open adapter %d stream %d\n", in snd_card_asihpi_capture_open()
1154 card->hpi->adapter->index, substream->number); in snd_card_asihpi_capture_open()
1157 hpi_instream_open(card->hpi->adapter->index, in snd_card_asihpi_capture_open()
1158 substream->number, &dpcm->h_stream)); in snd_card_asihpi_capture_open()
1162 return -EBUSY; in snd_card_asihpi_capture_open()
1164 return -EIO; in snd_card_asihpi_capture_open()
1166 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0); in snd_card_asihpi_capture_open()
1167 dpcm->substream = substream; in snd_card_asihpi_capture_open()
1168 runtime->private_data = dpcm; in snd_card_asihpi_capture_open()
1169 runtime->private_free = snd_card_asihpi_runtime_free; in snd_card_asihpi_capture_open()
1172 if (!card->hpi->interrupt_mode) { in snd_card_asihpi_capture_open()
1179 size_t pbmin = card->update_interval_frames * in snd_card_asihpi_capture_open()
1180 card->out_max_chans; in snd_card_asihpi_capture_open()
1188 snd_card_asihpi_capture.channels_max = card->in_max_chans; in snd_card_asihpi_capture_open()
1189 snd_card_asihpi_capture.channels_min = card->in_min_chans; in snd_card_asihpi_capture_open()
1191 snd_card_asihpi_capture_formats(card, dpcm->h_stream); in snd_card_asihpi_capture_open()
1197 if (card->support_grouping) in snd_card_asihpi_capture_open()
1200 runtime->hw = snd_card_asihpi_capture; in snd_card_asihpi_capture_open()
1202 if (card->can_dma) in snd_card_asihpi_capture_open()
1209 card->update_interval_frames); in snd_card_asihpi_capture_open()
1211 card->update_interval_frames, UINT_MAX); in snd_card_asihpi_capture_open()
1220 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data; in snd_card_asihpi_capture_close()
1222 hpi_handle_error(hpi_instream_close(dpcm->h_stream)); in snd_card_asihpi_capture_close()
1243 err = hpi_adapter_get_info(asihpi->hpi->adapter->index, in snd_card_asihpi_pcm_new()
1247 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device, in snd_card_asihpi_pcm_new()
1258 pcm->private_data = asihpi; in snd_card_asihpi_pcm_new()
1259 pcm->info_flags = 0; in snd_card_asihpi_pcm_new()
1260 strcpy(pcm->name, "Asihpi PCM"); in snd_card_asihpi_pcm_new()
1262 /*? do we want to emulate MMAP for non-BBM cards? in snd_card_asihpi_pcm_new()
1263 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */ in snd_card_asihpi_pcm_new()
1265 &asihpi->pci->dev, in snd_card_asihpi_pcm_new()
1287 "TV NTSC-M",
1318 "BLU-Link"
1323 (HPI_SOURCENODE_LAST_INDEX-HPI_SOURCENODE_NONE+1)),
1338 "BLU-Link"
1343 (HPI_DESTNODE_LAST_INDEX-HPI_DESTNODE_NONE+1)),
1355 dev_info(&asihpi->pci->dev, "added %s(%d)\n", ctl->name, ctl->index); in ctl_add()
1367 snd_control->name = hpi_ctl->name; in asihpi_ctl_init()
1368 snd_control->private_value = hpi_ctl->h_control; in asihpi_ctl_init()
1369 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER; in asihpi_ctl_init()
1370 snd_control->index = 0; in asihpi_ctl_init()
1372 if (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE == HPI_SOURCENODE_CLOCK_SOURCE) in asihpi_ctl_init()
1374 else if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM) in asihpi_ctl_init()
1376 else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && in asihpi_ctl_init()
1377 (!hpi_ctl->dst_node_type)) in asihpi_ctl_init()
1379 else if (hpi_ctl->src_node_type && in asihpi_ctl_init()
1380 (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) && in asihpi_ctl_init()
1381 (hpi_ctl->dst_node_type)) in asihpi_ctl_init()
1386 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type) in asihpi_ctl_init()
1387 sprintf(hpi_ctl->name, "%s %d %s %d %s%s", in asihpi_ctl_init()
1388 asihpi_src_names[hpi_ctl->src_node_type], in asihpi_ctl_init()
1389 hpi_ctl->src_node_index, in asihpi_ctl_init()
1390 asihpi_dst_names[hpi_ctl->dst_node_type], in asihpi_ctl_init()
1391 hpi_ctl->dst_node_index, in asihpi_ctl_init()
1393 else if (hpi_ctl->dst_node_type) { in asihpi_ctl_init()
1394 sprintf(hpi_ctl->name, "%s %d %s%s", in asihpi_ctl_init()
1395 asihpi_dst_names[hpi_ctl->dst_node_type], in asihpi_ctl_init()
1396 hpi_ctl->dst_node_index, in asihpi_ctl_init()
1399 sprintf(hpi_ctl->name, "%s %d %s%s", in asihpi_ctl_init()
1400 asihpi_src_names[hpi_ctl->src_node_type], in asihpi_ctl_init()
1401 hpi_ctl->src_node_index, in asihpi_ctl_init()
1406 /*------------------------------------------------------------
1408 ------------------------------------------------------------*/
1413 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_info()
1425 min_gain_mB = -10000; in snd_asihpi_volume_info()
1433 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_volume_info()
1434 uinfo->count = count; in snd_asihpi_volume_info()
1435 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1436 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1437 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB; in snd_asihpi_volume_info()
1444 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_get()
1448 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB; in snd_asihpi_volume_get()
1449 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB; in snd_asihpi_volume_get()
1457 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_put()
1461 (ucontrol->value.integer.value[0]) * VOL_STEP_mB; in snd_asihpi_volume_put()
1463 (ucontrol->value.integer.value[1]) * VOL_STEP_mB; in snd_asihpi_volume_put()
1464 /* change = asihpi->mixer_volume[addr][0] != left || in snd_asihpi_volume_put()
1465 asihpi->mixer_volume[addr][1] != right; in snd_asihpi_volume_put()
1471 static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0);
1478 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_mute_get()
1482 ucontrol->value.integer.value[0] = mute ? 0 : 1; in snd_asihpi_volume_mute_get()
1490 u32 h_control = kcontrol->private_value; in snd_asihpi_volume_mute_put()
1494 int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS; in snd_asihpi_volume_mute_put()
1502 struct snd_card *card = asihpi->card; in snd_asihpi_volume_add()
1519 if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) { in snd_asihpi_volume_add()
1530 /*------------------------------------------------------------
1532 ------------------------------------------------------------*/
1536 u32 h_control = kcontrol->private_value; in snd_asihpi_level_info()
1547 min_gain_mB = -1000; in snd_asihpi_level_info()
1551 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_level_info()
1552 uinfo->count = 2; in snd_asihpi_level_info()
1553 uinfo->value.integer.min = min_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1554 uinfo->value.integer.max = max_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1555 uinfo->value.integer.step = step_gain_mB / HPI_UNITS_PER_dB; in snd_asihpi_level_info()
1562 u32 h_control = kcontrol->private_value; in snd_asihpi_level_get()
1566 ucontrol->value.integer.value[0] = in snd_asihpi_level_get()
1568 ucontrol->value.integer.value[1] = in snd_asihpi_level_get()
1578 u32 h_control = kcontrol->private_value; in snd_asihpi_level_put()
1582 (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; in snd_asihpi_level_put()
1584 (ucontrol->value.integer.value[1]) * HPI_UNITS_PER_dB; in snd_asihpi_level_put()
1585 /* change = asihpi->mixer_level[addr][0] != left || in snd_asihpi_level_put()
1586 asihpi->mixer_level[addr][1] != right; in snd_asihpi_level_put()
1593 static const DECLARE_TLV_DB_SCALE(db_scale_level, -1000, 100, 0);
1598 struct snd_card *card = asihpi->card; in snd_asihpi_level_add()
1613 /*------------------------------------------------------------
1615 ------------------------------------------------------------*/
1617 /* AESEBU format */
1631 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_format_get()
1637 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_aesebu_format_get()
1642 ucontrol->value.enumerated.item[0] = 1; in snd_asihpi_aesebu_format_get()
1644 ucontrol->value.enumerated.item[0] = 2; in snd_asihpi_aesebu_format_get()
1653 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_format_put()
1658 if (ucontrol->value.enumerated.item[0] == 1) in snd_asihpi_aesebu_format_put()
1660 if (ucontrol->value.enumerated.item[0] == 2) in snd_asihpi_aesebu_format_put()
1664 return -EINVAL; in snd_asihpi_aesebu_format_put()
1684 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_aesebu_rxstatus_info()
1685 uinfo->count = 1; in snd_asihpi_aesebu_rxstatus_info()
1687 uinfo->value.integer.min = 0; in snd_asihpi_aesebu_rxstatus_info()
1688 uinfo->value.integer.max = 0X1F; in snd_asihpi_aesebu_rxstatus_info()
1689 uinfo->value.integer.step = 1; in snd_asihpi_aesebu_rxstatus_info()
1697 u32 h_control = kcontrol->private_value; in snd_asihpi_aesebu_rxstatus_get()
1702 ucontrol->value.integer.value[0] = status; in snd_asihpi_aesebu_rxstatus_get()
1709 struct snd_card *card = asihpi->card; in snd_asihpi_aesebu_rx_add()
1712 asihpi_ctl_init(&snd_control, hpi_ctl, "Format"); in snd_asihpi_aesebu_rx_add()
1720 return -EINVAL; in snd_asihpi_aesebu_rx_add()
1747 struct snd_card *card = asihpi->card; in snd_asihpi_aesebu_tx_add()
1750 asihpi_ctl_init(&snd_control, hpi_ctl, "Format"); in snd_asihpi_aesebu_tx_add()
1759 /*------------------------------------------------------------
1761 ------------------------------------------------------------*/
1768 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_info()
1780 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_tuner_gain_info()
1781 uinfo->count = 1; in snd_asihpi_tuner_gain_info()
1782 uinfo->value.integer.min = ((int)gain_range[0]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1783 uinfo->value.integer.max = ((int)gain_range[1]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1784 uinfo->value.integer.step = ((int) gain_range[2]) / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_info()
1794 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_get()
1798 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_get()
1809 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_gain_put()
1812 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB; in snd_asihpi_tuner_gain_put()
1822 u32 h_control = kcontrol->private_value; in asihpi_tuner_band_query()
1834 return -EIO; in asihpi_tuner_band_query()
1857 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_band_get()
1870 ucontrol->value.enumerated.item[0] = -1; in snd_asihpi_tuner_band_get()
1873 ucontrol->value.enumerated.item[0] = idx; in snd_asihpi_tuner_band_get()
1886 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_band_put()
1895 idx = ucontrol->value.enumerated.item[0]; in snd_asihpi_tuner_band_put()
1897 idx = ARRAY_SIZE(tuner_bands) - 1; in snd_asihpi_tuner_band_put()
1909 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_info()
1943 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_tuner_freq_info()
1944 uinfo->count = 1; in snd_asihpi_tuner_freq_info()
1945 uinfo->value.integer.min = ((int)freq_range[0]); in snd_asihpi_tuner_freq_info()
1946 uinfo->value.integer.max = ((int)freq_range[1]); in snd_asihpi_tuner_freq_info()
1947 uinfo->value.integer.step = ((int)freq_range[2]); in snd_asihpi_tuner_freq_info()
1954 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_get()
1958 ucontrol->value.integer.value[0] = freq; in snd_asihpi_tuner_freq_get()
1966 u32 h_control = kcontrol->private_value; in snd_asihpi_tuner_freq_put()
1969 freq = ucontrol->value.integer.value[0]; in snd_asihpi_tuner_freq_put()
1979 struct snd_card *card = asihpi->card; in snd_asihpi_tuner_add()
1982 snd_control.private_value = hpi_ctl->h_control; in snd_asihpi_tuner_add()
1985 if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) { in snd_asihpi_tuner_add()
1992 return -EINVAL; in snd_asihpi_tuner_add()
2001 return -EINVAL; in snd_asihpi_tuner_add()
2011 /*------------------------------------------------------------
2013 ------------------------------------------------------------*/
2017 u32 h_control = kcontrol->private_value; in snd_asihpi_meter_info()
2024 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_meter_info()
2025 uinfo->count = count; in snd_asihpi_meter_info()
2026 uinfo->value.integer.min = 0; in snd_asihpi_meter_info()
2027 uinfo->value.integer.max = 0x7FFFFFFF; in snd_asihpi_meter_info()
2039 2147484, /* -60dB */
2041 214748, /* -80 */
2043 21475, /* -100 */
2057 u32 h_control = kcontrol->private_value; in snd_asihpi_meter_get()
2065 ucontrol->value.integer.value[i] = 0; in snd_asihpi_meter_get()
2067 ucontrol->value.integer.value[i] = in snd_asihpi_meter_get()
2070 /* -ve is log value in millibels < -60dB, in snd_asihpi_meter_get()
2073 ucontrol->value.integer.value[i] = in snd_asihpi_meter_get()
2074 log2lin[an_gain_mB[i] / -1000]; in snd_asihpi_meter_get()
2083 struct snd_card *card = asihpi->card; in snd_asihpi_meter_add()
2097 /*------------------------------------------------------------
2099 ------------------------------------------------------------*/
2102 u32 h_control = snd_control->private_value; in snd_card_asihpi_mux_count_sources()
2121 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_info()
2123 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_asihpi_mux_info()
2124 uinfo->count = 1; in snd_asihpi_mux_info()
2125 uinfo->value.enumerated.items = in snd_asihpi_mux_info()
2128 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in snd_asihpi_mux_info()
2129 uinfo->value.enumerated.item = in snd_asihpi_mux_info()
2130 uinfo->value.enumerated.items - 1; in snd_asihpi_mux_info()
2133 uinfo->value.enumerated.item, in snd_asihpi_mux_info()
2136 sprintf(uinfo->value.enumerated.name, "%s %d", in snd_asihpi_mux_info()
2137 asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE], in snd_asihpi_mux_info()
2145 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_get()
2160 ucontrol->value.enumerated.item[0] = s; in snd_asihpi_mux_get()
2166 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_mux_get()
2174 u32 h_control = kcontrol->private_value; in snd_asihpi_mux_put()
2181 ucontrol->value.enumerated.item[0], in snd_asihpi_mux_put()
2194 struct snd_card *card = asihpi->card; in snd_asihpi_mux_add()
2207 /*------------------------------------------------------------
2209 ------------------------------------------------------------*/
2220 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_info()
2237 return -EINVAL; in snd_asihpi_cmode_info()
2245 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_get()
2251 ucontrol->value.enumerated.item[0] = mode - 1; in snd_asihpi_cmode_get()
2260 u32 h_control = kcontrol->private_value; in snd_asihpi_cmode_put()
2265 ucontrol->value.enumerated.item[0] + 1)); in snd_asihpi_cmode_put()
2273 struct snd_card *card = asihpi->card; in snd_asihpi_cmode_add()
2285 /*------------------------------------------------------------
2287 ------------------------------------------------------------*/
2291 "Prev Module", "BLU-Link",
2304 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_info()
2305 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_info()
2306 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; in snd_asihpi_clksrc_info()
2307 uinfo->count = 1; in snd_asihpi_clksrc_info()
2308 uinfo->value.enumerated.items = clkcache->count; in snd_asihpi_clksrc_info()
2310 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items) in snd_asihpi_clksrc_info()
2311 uinfo->value.enumerated.item = in snd_asihpi_clksrc_info()
2312 uinfo->value.enumerated.items - 1; in snd_asihpi_clksrc_info()
2314 strcpy(uinfo->value.enumerated.name, in snd_asihpi_clksrc_info()
2315 clkcache->s[uinfo->value.enumerated.item].name); in snd_asihpi_clksrc_info()
2323 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_get()
2324 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_get()
2325 u32 h_control = kcontrol->private_value; in snd_asihpi_clksrc_get()
2329 ucontrol->value.enumerated.item[0] = 0; in snd_asihpi_clksrc_get()
2337 for (i = 0; i < clkcache->count; i++) in snd_asihpi_clksrc_get()
2338 if ((clkcache->s[i].source == source) && in snd_asihpi_clksrc_get()
2339 (clkcache->s[i].index == srcindex)) in snd_asihpi_clksrc_get()
2342 ucontrol->value.enumerated.item[0] = i; in snd_asihpi_clksrc_get()
2351 (struct snd_card_asihpi *)(kcontrol->private_data); in snd_asihpi_clksrc_put()
2352 struct clk_cache *clkcache = &asihpi->cc; in snd_asihpi_clksrc_put()
2355 u32 h_control = kcontrol->private_value; in snd_asihpi_clksrc_put()
2358 item = ucontrol->value.enumerated.item[0]; in snd_asihpi_clksrc_put()
2359 if (item >= clkcache->count) in snd_asihpi_clksrc_put()
2360 item = clkcache->count-1; in snd_asihpi_clksrc_put()
2363 h_control, clkcache->s[item].source)); in snd_asihpi_clksrc_put()
2365 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT) in snd_asihpi_clksrc_put()
2367 h_control, clkcache->s[item].index)); in snd_asihpi_clksrc_put()
2371 /*------------------------------------------------------------
2373 ------------------------------------------------------------*/
2378 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_clklocal_info()
2379 uinfo->count = 1; in snd_asihpi_clklocal_info()
2380 uinfo->value.integer.min = 8000; in snd_asihpi_clklocal_info()
2381 uinfo->value.integer.max = 192000; in snd_asihpi_clklocal_info()
2382 uinfo->value.integer.step = 100; in snd_asihpi_clklocal_info()
2390 u32 h_control = kcontrol->private_value; in snd_asihpi_clklocal_get()
2396 ucontrol->value.integer.value[0] = rate; in snd_asihpi_clklocal_get()
2398 ucontrol->value.integer.value[0] = 0; in snd_asihpi_clklocal_get()
2406 u32 h_control = kcontrol->private_value; in snd_asihpi_clklocal_put()
2408 /* change = asihpi->mixer_clkrate[addr][0] != left || in snd_asihpi_clklocal_put()
2409 asihpi->mixer_clkrate[addr][1] != right; in snd_asihpi_clklocal_put()
2413 ucontrol->value.integer.value[0])); in snd_asihpi_clklocal_put()
2420 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in snd_asihpi_clkrate_info()
2421 uinfo->count = 1; in snd_asihpi_clkrate_info()
2422 uinfo->value.integer.min = 8000; in snd_asihpi_clkrate_info()
2423 uinfo->value.integer.max = 192000; in snd_asihpi_clkrate_info()
2424 uinfo->value.integer.step = 100; in snd_asihpi_clkrate_info()
2432 u32 h_control = kcontrol->private_value; in snd_asihpi_clkrate_get()
2438 ucontrol->value.integer.value[0] = rate; in snd_asihpi_clkrate_get()
2440 ucontrol->value.integer.value[0] = 0; in snd_asihpi_clkrate_get()
2451 u32 hSC = hpi_ctl->h_control; in snd_asihpi_sampleclock_add()
2457 return -EINVAL; in snd_asihpi_sampleclock_add()
2458 card = asihpi->card; in snd_asihpi_sampleclock_add()
2459 clkcache = &asihpi->cc; in snd_asihpi_sampleclock_add()
2460 snd_control.private_value = hpi_ctl->h_control; in snd_asihpi_sampleclock_add()
2462 clkcache->has_local = 0; in snd_asihpi_sampleclock_add()
2468 clkcache->s[i].source = source; in snd_asihpi_sampleclock_add()
2469 clkcache->s[i].index = 0; in snd_asihpi_sampleclock_add()
2470 clkcache->s[i].name = sampleclock_sources[source]; in snd_asihpi_sampleclock_add()
2474 clkcache->has_local = 1; in snd_asihpi_sampleclock_add()
2483 clkcache->s[i].source = in snd_asihpi_sampleclock_add()
2485 clkcache->s[i].index = j; in snd_asihpi_sampleclock_add()
2486 clkcache->s[i].name = sampleclock_sources[ in snd_asihpi_sampleclock_add()
2490 clkcache->count = i; in snd_asihpi_sampleclock_add()
2498 return -EINVAL; in snd_asihpi_sampleclock_add()
2501 if (clkcache->has_local) { in snd_asihpi_sampleclock_add()
2510 return -EINVAL; in snd_asihpi_sampleclock_add()
2521 /*------------------------------------------------------------
2523 ------------------------------------------------------------*/
2534 return -EINVAL; in snd_card_asihpi_mixer_new()
2535 card = asihpi->card; in snd_card_asihpi_mixer_new()
2536 strcpy(card->mixername, "Asihpi Mixer"); in snd_card_asihpi_mixer_new()
2539 hpi_mixer_open(asihpi->hpi->adapter->index, in snd_card_asihpi_mixer_new()
2540 &asihpi->h_mixer); in snd_card_asihpi_mixer_new()
2543 return -err; in snd_card_asihpi_mixer_new()
2546 prev_ctl.control_type = -1; in snd_card_asihpi_mixer_new()
2550 asihpi->h_mixer, in snd_card_asihpi_mixer_new()
2561 dev_info(&asihpi->pci->dev, in snd_card_asihpi_mixer_new()
2570 hpi_ctl.src_node_type -= HPI_SOURCENODE_NONE; in snd_card_asihpi_mixer_new()
2571 hpi_ctl.dst_node_type -= HPI_DESTNODE_NONE; in snd_card_asihpi_mixer_new()
2626 dev_info(&asihpi->pci->dev, in snd_card_asihpi_mixer_new()
2642 dev_info(&asihpi->pci->dev, "%d mixer controls found\n", idx); in snd_card_asihpi_mixer_new()
2647 /*------------------------------------------------------------
2649 ------------------------------------------------------------*/
2655 struct snd_card_asihpi *asihpi = entry->private_data; in snd_asihpi_proc_read()
2670 hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index, in snd_asihpi_proc_read()
2675 "Adapter type ASI%4X\nHardware Index %d\n" in snd_asihpi_proc_read()
2677 type, asihpi->hpi->adapter->index, in snd_asihpi_proc_read()
2685 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_asihpi_proc_read()
2701 snd_card_ro_proc_new(asihpi->card, "info", asihpi, in snd_asihpi_proc_init()
2705 /*------------------------------------------------------------
2707 ------------------------------------------------------------*/
2714 return -ENODEV; in snd_asihpi_hpi_open()
2723 return -ENODEV; in snd_asihpi_hpi_release()
2732 return -ENODEV; in snd_asihpi_hpi_ioctl()
2737 also /proc/asound/hwdep will contain '#-00: asihpi (HPI) for each card'
2744 err = snd_hwdep_new(asihpi->card, "HPI", device, &hw); in snd_asihpi_hpi_new()
2747 strcpy(hw->name, "asihpi (HPI)"); in snd_asihpi_hpi_new()
2748 hw->iface = SNDRV_HWDEP_IFACE_LAST; in snd_asihpi_hpi_new()
2749 hw->ops.open = snd_asihpi_hpi_open; in snd_asihpi_hpi_new()
2750 hw->ops.ioctl = snd_asihpi_hpi_ioctl; in snd_asihpi_hpi_new()
2751 hw->ops.release = snd_asihpi_hpi_release; in snd_asihpi_hpi_new()
2752 hw->private_data = asihpi; in snd_asihpi_hpi_new()
2756 /*------------------------------------------------------------
2758 ------------------------------------------------------------*/
2773 return -ENODEV; in snd_asihpi_probe()
2775 /* Should this be enable[hpi->index] ? */ in snd_asihpi_probe()
2778 return -ENOENT; in snd_asihpi_probe()
2781 /* Initialise low-level HPI driver */ in snd_asihpi_probe()
2787 adapter_index = hpi->adapter->index; in snd_asihpi_probe()
2789 err = snd_card_new(&pci_dev->dev, adapter_index, id[adapter_index], in snd_asihpi_probe()
2793 err = snd_card_new(&pci_dev->dev, index[dev], id[dev], in snd_asihpi_probe()
2798 dev_warn(&pci_dev->dev, "Adapter index %d->ALSA index %d\n", in snd_asihpi_probe()
2799 adapter_index, card->number); in snd_asihpi_probe()
2802 asihpi = card->private_data; in snd_asihpi_probe()
2803 asihpi->card = card; in snd_asihpi_probe()
2804 asihpi->pci = pci_dev; in snd_asihpi_probe()
2805 asihpi->hpi = hpi; in snd_asihpi_probe()
2806 hpi->snd_card = card; in snd_asihpi_probe()
2810 NULL, &asihpi->support_grouping); in snd_asihpi_probe()
2812 asihpi->support_grouping = 0; in snd_asihpi_probe()
2816 &asihpi->support_mrx, NULL); in snd_asihpi_probe()
2818 asihpi->support_mrx = 0; in snd_asihpi_probe()
2822 NULL, &asihpi->update_interval_frames); in snd_asihpi_probe()
2824 asihpi->update_interval_frames = 512; in snd_asihpi_probe()
2826 if (hpi->interrupt_mode) { in snd_asihpi_probe()
2827 asihpi->pcm_start = snd_card_asihpi_pcm_int_start; in snd_asihpi_probe()
2828 asihpi->pcm_stop = snd_card_asihpi_pcm_int_stop; in snd_asihpi_probe()
2829 hpi->interrupt_callback = snd_card_asihpi_isr; in snd_asihpi_probe()
2831 asihpi->pcm_start = snd_card_asihpi_pcm_timer_start; in snd_asihpi_probe()
2832 asihpi->pcm_stop = snd_card_asihpi_pcm_timer_stop; in snd_asihpi_probe()
2839 asihpi->can_dma = (!err); in snd_asihpi_probe()
2843 if (!asihpi->can_dma) in snd_asihpi_probe()
2844 asihpi->update_interval_frames *= 2; in snd_asihpi_probe()
2848 &asihpi->in_max_chans, &asihpi->out_max_chans); in snd_asihpi_probe()
2850 asihpi->in_max_chans = 2; in snd_asihpi_probe()
2851 asihpi->out_max_chans = 2; in snd_asihpi_probe()
2854 if (asihpi->out_max_chans > 2) { /* assume LL mode */ in snd_asihpi_probe()
2855 asihpi->out_min_chans = asihpi->out_max_chans; in snd_asihpi_probe()
2856 asihpi->in_min_chans = asihpi->in_max_chans; in snd_asihpi_probe()
2857 asihpi->support_grouping = 0; in snd_asihpi_probe()
2859 asihpi->out_min_chans = 1; in snd_asihpi_probe()
2860 asihpi->in_min_chans = 1; in snd_asihpi_probe()
2863 dev_info(&pci_dev->dev, "Has dma:%d, grouping:%d, mrx:%d, uif:%d\n", in snd_asihpi_probe()
2864 asihpi->can_dma, in snd_asihpi_probe()
2865 asihpi->support_grouping, in snd_asihpi_probe()
2866 asihpi->support_mrx, in snd_asihpi_probe()
2867 asihpi->update_interval_frames in snd_asihpi_probe()
2872 dev_err(&pci_dev->dev, "pcm_new failed\n"); in snd_asihpi_probe()
2877 dev_err(&pci_dev->dev, "mixer_new failed\n"); in snd_asihpi_probe()
2881 err = hpi_mixer_get_control(asihpi->h_mixer, in snd_asihpi_probe()
2895 strcpy(card->driver, "ASIHPI"); in snd_asihpi_probe()
2897 sprintf(card->shortname, "AudioScience ASI%4X", in snd_asihpi_probe()
2898 asihpi->hpi->adapter->type); in snd_asihpi_probe()
2899 sprintf(card->longname, "%s %i", in snd_asihpi_probe()
2900 card->shortname, adapter_index); in snd_asihpi_probe()
2909 dev_err(&pci_dev->dev, "snd_asihpi_probe error %d\n", err); in snd_asihpi_probe()
2919 if (hpi->interrupt_mode) { in snd_asihpi_remove()
2920 hpi->interrupt_callback = NULL; in snd_asihpi_remove()
2921 hpi_handle_error(hpi_adapter_set_property(hpi->adapter->index, in snd_asihpi_remove()
2925 snd_card_free(hpi->snd_card); in snd_asihpi_remove()
2926 hpi->snd_card = NULL; in snd_asihpi_remove()