Lines Matching +full:integer +full:- +full:n

1 // SPDX-License-Identifier: GPL-2.0-only
45 static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* index 0-MAX */
254 pr_warn("in file %s, line %d: HPI error %d\n",
266 struct device *dev = substream->pcm->card->dev;
270 dev_dbg(dev, "%s HWPARAMS\n", name);
271 dev_dbg(dev, " samplerate=%dHz channels=%d format=%d subformat=%d\n",
274 dev_dbg(dev, " buffer=%dB period=%dB period_size=%dB periods=%d\n",
277 dev_dbg(dev, " buffer_size=%d access=%d data_rate=%dB/s\n",
283 #define INVALID_FORMAT (__force snd_pcm_format_t)(-1)
302 /* ALSA can't handle 3 byte sample size together with power-of-2
326 dev_dbg(asihpi->card->dev, "failed match for alsa format %d\n",
329 return -EINVAL;
343 if (asihpi->support_mrx) {
351 err = hpi_mixer_get_control(asihpi->h_mixer,
355 dev_err(&asihpi->pci->dev,
356 "No local sampleclock, err %d\n", err);
359 for (idx = -1; idx < 100; idx++) {
360 if (idx == -1) {
418 pcmhw->rates = rates;
419 pcmhw->rate_min = rate_min;
420 pcmhw->rate_max = rate_max;
426 struct snd_pcm_runtime *runtime = substream->runtime;
427 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
439 hpi_handle_error(hpi_format_create(&dpcm->format,
443 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
444 if (hpi_instream_reset(dpcm->h_stream) != 0)
445 return -EINVAL;
448 dpcm->h_stream, &dpcm->format) != 0)
449 return -EINVAL;
452 dpcm->hpi_buffer_attached = 0;
453 if (card->can_dma) {
454 err = hpi_stream_host_buffer_attach(dpcm->h_stream,
455 params_buffer_bytes(params), runtime->dma_addr);
457 dev_dbg(card->card->dev,
458 "stream_host_buffer_attach success %u %lu\n",
460 (unsigned long)runtime->dma_addr);
462 dev_dbg(card->card->dev,
463 "stream_host_buffer_attach error %d\n", err);
464 return -ENOMEM;
467 hpi_stream_get_info_ex(dpcm->h_stream, NULL,
468 &dpcm->hpi_buffer_attached, NULL, NULL, NULL);
475 return -EINVAL;
477 dpcm->bytes_per_sec = bytes_per_sec;
478 dpcm->buffer_bytes = params_buffer_bytes(params);
479 dpcm->period_bytes = params_period_bytes(params);
487 struct snd_pcm_runtime *runtime = substream->runtime;
488 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
489 if (dpcm->hpi_buffer_attached)
490 hpi_stream_host_buffer_detach(dpcm->h_stream);
497 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
504 struct snd_pcm_runtime *runtime = substream->runtime;
505 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
511 mod_timer(&dpcm->timer, jiffies + expiry);
512 dpcm->respawn_timer = 1;
517 struct snd_pcm_runtime *runtime = substream->runtime;
518 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
520 dpcm->respawn_timer = 0;
521 timer_delete(&dpcm->timer);
529 dpcm = (struct snd_card_asihpi_pcm *)substream->runtime->private_data;
533 card->llmode_streampriv = dpcm;
535 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index,
537 card->update_interval_frames, 0));
546 hpi_handle_error(hpi_adapter_set_property(card->hpi->adapter->index,
549 card->llmode_streampriv = NULL;
555 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data;
565 dev_dbg(card->card->dev, "%s trigger start\n", name);
567 struct snd_pcm_runtime *runtime = s->runtime;
568 struct snd_card_asihpi_pcm *ds = runtime->private_data;
574 if (substream->stream != s->stream)
577 ds->drained_count = 0;
578 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
585 unsigned int preload = ds->period_bytes * 1;
586 asihpi_dbg("%d preload %d\n", s->number, preload);
588 ds->h_stream,
589 &runtime->dma_area[0],
591 &ds->format));
592 ds->pcm_buf_host_rw_ofs = preload;
595 if (card->support_grouping) {
596 dev_dbg(card->card->dev, "%d group\n", s->number);
598 dpcm->h_stream,
599 ds->h_stream);
610 card->pcm_start(substream);
611 if ((substream->stream == SNDRV_PCM_STREAM_CAPTURE) ||
612 !card->can_dma)
613 hpi_handle_error(hpi_stream_start(dpcm->h_stream));
617 dev_dbg(card->card->dev, "%s trigger stop\n", name);
618 card->pcm_stop(substream);
623 if (substream->stream != s->stream)
628 __snd_pcm_set_state(s->runtime, SNDRV_PCM_STATE_SETUP);
630 if (card->support_grouping) {
631 dev_dbg(card->card->dev, "%d group\n", s->number);
638 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
639 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
641 hpi_outstream_reset(dpcm->h_stream));
643 if (card->support_grouping)
644 hpi_handle_error(hpi_stream_group_reset(dpcm->h_stream));
648 dev_dbg(card->card->dev, "%s trigger pause release\n", name);
649 card->pcm_start(substream);
650 hpi_handle_error(hpi_stream_start(dpcm->h_stream));
653 dev_dbg(card->card->dev, "%s trigger pause push\n", name);
654 card->pcm_stop(substream);
655 hpi_handle_error(hpi_stream_stop(dpcm->h_stream));
658 dev_dbg(card->card->dev, "\tINVALID\n");
659 return -EINVAL;
678 s->pcm_buf_dma_ofs = min_buf_pos;
700 if (((a-b) % modulus) < (modulus/2))
713 struct snd_pcm_substream *substream = dpcm->substream;
730 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
731 runtime = s->runtime;
737 if (substream->stream != s->stream)
741 ds->h_stream, &state,
745 /* number of bytes in on-card buffer */
746 runtime->delay = on_card_bytes;
748 if (!card->can_dma)
751 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
752 pcm_buf_dma_ofs = ds->pcm_buf_host_rw_ofs - bytes_avail;
755 hpi_handle_error(hpi_stream_start(ds->h_stream));
756 dev_dbg(card->card->dev,
757 "P%d start\n", s->number);
758 ds->drained_count = 0;
761 dev_dbg(card->card->dev,
762 "P%d drained\n", s->number);
763 ds->drained_count++;
764 if (ds->drained_count > 20) {
769 ds->drained_count = 0;
772 pcm_buf_dma_ofs = bytes_avail + ds->pcm_buf_host_rw_ofs;
777 newdata = (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes;
783 (pcm_buf_dma_ofs - ds->pcm_buf_elapsed_dma_ofs) % ds->buffer_bytes,
788 "timer1, %s, %d, S=%d, elap=%d, rw=%d, dsp=%d, left=%d, aux=%d, space=%d, hw_ptr=%ld, appl_ptr=%ld\n",
789 name, s->number, state,
790 ds->pcm_buf_elapsed_dma_ofs,
791 ds->pcm_buf_host_rw_ofs,
796 buffer_size-bytes_avail,
798 runtime->status->hw_ptr),
800 runtime->control->appl_ptr)
805 remdata = newdata % dpcm->period_bytes;
806 xfercount = newdata - remdata; /* a multiple of period_bytes */
811 if (xfercount && (on_card_bytes > dpcm->period_bytes))
812 next_jiffies = ((on_card_bytes - dpcm->period_bytes) * HZ / dpcm->bytes_per_sec);
814 next_jiffies = ((dpcm->period_bytes - remdata) * HZ / dpcm->bytes_per_sec);
817 dpcm->timer.expires = jiffies + next_jiffies;
818 asihpi_dbg("timer2, jif=%d, buf_pos=%d, newdata=%d, xfer=%d\n",
822 struct snd_card_asihpi_pcm *ds = s->runtime->private_data;
825 if (substream->stream != s->stream)
829 ds->pcm_buf_dma_ofs = pcm_buf_dma_ofs;
833 ((on_card_bytes <= ds->period_bytes) ||
834 (s->stream == SNDRV_PCM_STREAM_CAPTURE)))
838 unsigned int buf_ofs = ds->pcm_buf_host_rw_ofs % ds->buffer_bytes;
840 char *pd = &s->runtime->dma_area[buf_ofs];
842 if (card->can_dma) { /* buffer wrap is handled at lower level */
846 xfer1 = min(xfercount, ds->buffer_bytes - buf_ofs);
847 xfer2 = xfercount - xfer1;
850 if (s->stream == SNDRV_PCM_STREAM_PLAYBACK) {
851 asihpi_dbg("write1, P=%d, xfer=%d, buf_ofs=%d\n",
852 s->number, xfer1, buf_ofs);
855 ds->h_stream, pd, xfer1,
856 &ds->format));
859 pd = s->runtime->dma_area;
861 asihpi_dbg("write2, P=%d, xfer=%d, buf_ofs=%d\n",
862 s->number,
863 xfercount - xfer1, buf_ofs);
866 ds->h_stream, pd,
867 xfercount - xfer1,
868 &ds->format));
871 asihpi_dbg("read1, C=%d, xfer=%d\n",
872 s->number, xfer1);
875 ds->h_stream,
878 pd = s->runtime->dma_area;
879 asihpi_dbg("read2, C=%d, xfer=%d\n",
880 s->number, xfer2);
883 ds->h_stream,
888 ds->pcm_buf_host_rw_ofs += xfercount;
889 ds->pcm_buf_elapsed_dma_ofs += xfercount;
894 if (!card->hpi->interrupt_mode && dpcm->respawn_timer)
895 add_timer(&dpcm->timer);
902 WARN_ON(!a || !a->snd_card || !a->snd_card->private_data);
903 asihpi = (struct snd_card_asihpi *)a->snd_card->private_data;
904 if (asihpi->llmode_streampriv)
906 &asihpi->llmode_streampriv->timer);
913 struct snd_pcm_runtime *runtime = substream->runtime;
914 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
916 hpi_handle_error(hpi_outstream_reset(dpcm->h_stream));
917 dpcm->pcm_buf_host_rw_ofs = 0;
918 dpcm->pcm_buf_dma_ofs = 0;
919 dpcm->pcm_buf_elapsed_dma_ofs = 0;
926 struct snd_pcm_runtime *runtime = substream->runtime;
927 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
932 ptr = bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
933 asihpi_dbg("%s, pointer=%ld\n", name, (unsigned long)ptr);
950 err = hpi_mixer_get_control(asihpi->h_mixer,
960 err = hpi_format_create(&hpi_format, asihpi->out_max_chans,
972 struct snd_pcm_runtime *runtime = substream->runtime;
980 return -ENOMEM;
982 err = hpi_outstream_open(card->hpi->adapter->index,
983 substream->number, &dpcm->h_stream);
988 return -EBUSY;
989 return -EIO;
997 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0);
998 dpcm->substream = substream;
999 runtime->private_data = dpcm;
1000 runtime->private_free = snd_card_asihpi_runtime_free;
1003 if (!card->hpi->interrupt_mode) {
1010 size_t pbmin = card->update_interval_frames *
1011 card->out_max_chans;
1020 snd_card_asihpi_playback.channels_max = card->out_max_chans;
1021 snd_card_asihpi_playback.channels_min = card->out_min_chans;
1023 snd_card_asihpi_playback_formats(card, dpcm->h_stream);
1035 if (card->support_grouping) {
1041 runtime->hw = snd_card_asihpi_playback;
1043 if (card->can_dma)
1050 card->update_interval_frames);
1053 card->update_interval_frames, UINT_MAX);
1060 struct snd_pcm_runtime *runtime = substream->runtime;
1061 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1063 hpi_handle_error(hpi_outstream_close(dpcm->h_stream));
1081 struct snd_pcm_runtime *runtime = substream->runtime;
1082 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1086 asihpi_dbg("%s, pointer=%d\n", name, dpcm->pcm_buf_dma_ofs);
1091 return bytes_to_frames(runtime, dpcm->pcm_buf_dma_ofs % dpcm->buffer_bytes);
1096 struct snd_pcm_runtime *runtime = substream->runtime;
1097 struct snd_card_asihpi_pcm *dpcm = runtime->private_data;
1099 hpi_handle_error(hpi_instream_reset(dpcm->h_stream));
1100 dpcm->pcm_buf_host_rw_ofs = 0;
1101 dpcm->pcm_buf_dma_ofs = 0;
1102 dpcm->pcm_buf_elapsed_dma_ofs = 0;
1119 err = hpi_mixer_get_control(asihpi->h_mixer,
1130 err = hpi_format_create(&hpi_format, asihpi->in_max_chans,
1142 struct snd_pcm_runtime *runtime = substream->runtime;
1150 return -ENOMEM;
1153 dev_dbg(card->card->dev, "capture open adapter %d stream %d\n",
1154 card->hpi->adapter->index, substream->number);
1157 hpi_instream_open(card->hpi->adapter->index,
1158 substream->number, &dpcm->h_stream));
1162 return -EBUSY;
1163 return -EIO;
1166 timer_setup(&dpcm->timer, snd_card_asihpi_timer_function, 0);
1167 dpcm->substream = substream;
1168 runtime->private_data = dpcm;
1169 runtime->private_free = snd_card_asihpi_runtime_free;
1172 if (!card->hpi->interrupt_mode) {
1179 size_t pbmin = card->update_interval_frames *
1180 card->out_max_chans;
1188 snd_card_asihpi_capture.channels_max = card->in_max_chans;
1189 snd_card_asihpi_capture.channels_min = card->in_min_chans;
1191 snd_card_asihpi_capture_formats(card, dpcm->h_stream);
1197 if (card->support_grouping)
1200 runtime->hw = snd_card_asihpi_capture;
1202 if (card->can_dma)
1209 card->update_interval_frames);
1211 card->update_interval_frames, UINT_MAX);
1220 struct snd_card_asihpi_pcm *dpcm = substream->runtime->private_data;
1222 hpi_handle_error(hpi_instream_close(dpcm->h_stream));
1243 err = hpi_adapter_get_info(asihpi->hpi->adapter->index,
1247 err = snd_pcm_new(asihpi->card, "Asihpi PCM", device,
1258 pcm->private_data = asihpi;
1259 pcm->info_flags = 0;
1260 strscpy(pcm->name, "Asihpi PCM");
1262 /*? do we want to emulate MMAP for non-BBM cards?
1263 Jack doesn't work with ALSAs MMAP emulation - WHY NOT? */
1265 &asihpi->pci->dev,
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);
1367 snd_control->name = hpi_ctl->name;
1368 snd_control->private_value = hpi_ctl->h_control;
1369 snd_control->iface = SNDRV_CTL_ELEM_IFACE_MIXER;
1370 snd_control->index = 0;
1372 if (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE == HPI_SOURCENODE_CLOCK_SOURCE)
1374 else if (hpi_ctl->dst_node_type + HPI_DESTNODE_NONE == HPI_DESTNODE_ISTREAM)
1376 else if ((hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1377 (!hpi_ctl->dst_node_type))
1379 else if (hpi_ctl->src_node_type &&
1380 (hpi_ctl->src_node_type + HPI_SOURCENODE_NONE != HPI_SOURCENODE_OSTREAM) &&
1381 (hpi_ctl->dst_node_type))
1386 if (hpi_ctl->src_node_type && hpi_ctl->dst_node_type)
1387 sprintf(hpi_ctl->name, "%s %d %s %d %s%s",
1388 asihpi_src_names[hpi_ctl->src_node_type],
1389 hpi_ctl->src_node_index,
1390 asihpi_dst_names[hpi_ctl->dst_node_type],
1391 hpi_ctl->dst_node_index,
1393 else if (hpi_ctl->dst_node_type) {
1394 sprintf(hpi_ctl->name, "%s %d %s%s",
1395 asihpi_dst_names[hpi_ctl->dst_node_type],
1396 hpi_ctl->dst_node_index,
1399 sprintf(hpi_ctl->name, "%s %d %s%s",
1400 asihpi_src_names[hpi_ctl->src_node_type],
1401 hpi_ctl->src_node_index,
1406 /*------------------------------------------------------------
1408 ------------------------------------------------------------*/
1413 u32 h_control = kcontrol->private_value;
1425 min_gain_mB = -10000;
1433 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1434 uinfo->count = count;
1435 uinfo->value.integer.min = min_gain_mB / VOL_STEP_mB;
1436 uinfo->value.integer.max = max_gain_mB / VOL_STEP_mB;
1437 uinfo->value.integer.step = step_gain_mB / VOL_STEP_mB;
1444 u32 h_control = kcontrol->private_value;
1448 ucontrol->value.integer.value[0] = an_gain_mB[0] / VOL_STEP_mB;
1449 ucontrol->value.integer.value[1] = an_gain_mB[1] / VOL_STEP_mB;
1457 u32 h_control = kcontrol->private_value;
1461 (ucontrol->value.integer.value[0]) * VOL_STEP_mB;
1463 (ucontrol->value.integer.value[1]) * VOL_STEP_mB;
1464 /* change = asihpi->mixer_volume[addr][0] != left ||
1465 asihpi->mixer_volume[addr][1] != right;
1471 static const DECLARE_TLV_DB_SCALE(db_scale_100, -10000, VOL_STEP_mB, 0);
1478 u32 h_control = kcontrol->private_value;
1482 ucontrol->value.integer.value[0] = mute ? 0 : 1;
1490 u32 h_control = kcontrol->private_value;
1494 int mute = ucontrol->value.integer.value[0] ? 0 : HPI_BITMASK_ALL_CHANNELS;
1502 struct snd_card *card = asihpi->card;
1519 if (hpi_volume_get_mute(hpi_ctl->h_control, &mute) == 0) {
1530 /*------------------------------------------------------------
1532 ------------------------------------------------------------*/
1536 u32 h_control = kcontrol->private_value;
1547 min_gain_mB = -1000;
1551 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1552 uinfo->count = 2;
1553 uinfo->value.integer.min = min_gain_mB / HPI_UNITS_PER_dB;
1554 uinfo->value.integer.max = max_gain_mB / HPI_UNITS_PER_dB;
1555 uinfo->value.integer.step = step_gain_mB / HPI_UNITS_PER_dB;
1562 u32 h_control = kcontrol->private_value;
1566 ucontrol->value.integer.value[0] =
1568 ucontrol->value.integer.value[1] =
1578 u32 h_control = kcontrol->private_value;
1582 (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB;
1584 (ucontrol->value.integer.value[1]) * HPI_UNITS_PER_dB;
1585 /* change = asihpi->mixer_level[addr][0] != left ||
1586 asihpi->mixer_level[addr][1] != right;
1593 static const DECLARE_TLV_DB_SCALE(db_scale_level, -1000, 100, 0);
1598 struct snd_card *card = asihpi->card;
1613 /*------------------------------------------------------------
1615 ------------------------------------------------------------*/
1619 "N/A", "S/PDIF", "AES/EBU" };
1631 u32 h_control = kcontrol->private_value;
1636 /* default to N/A */
1637 ucontrol->value.enumerated.item[0] = 0;
1638 /* return success but set the control to N/A */
1642 ucontrol->value.enumerated.item[0] = 1;
1644 ucontrol->value.enumerated.item[0] = 2;
1653 u32 h_control = kcontrol->private_value;
1658 if (ucontrol->value.enumerated.item[0] == 1)
1660 if (ucontrol->value.enumerated.item[0] == 2)
1664 return -EINVAL;
1684 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1685 uinfo->count = 1;
1687 uinfo->value.integer.min = 0;
1688 uinfo->value.integer.max = 0X1F;
1689 uinfo->value.integer.step = 1;
1697 u32 h_control = kcontrol->private_value;
1702 ucontrol->value.integer.value[0] = status;
1709 struct snd_card *card = asihpi->card;
1720 return -EINVAL;
1747 struct snd_card *card = asihpi->card;
1759 /*------------------------------------------------------------
1761 ------------------------------------------------------------*/
1768 u32 h_control = kcontrol->private_value;
1780 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1781 uinfo->count = 1;
1782 uinfo->value.integer.min = ((int)gain_range[0]) / HPI_UNITS_PER_dB;
1783 uinfo->value.integer.max = ((int)gain_range[1]) / HPI_UNITS_PER_dB;
1784 uinfo->value.integer.step = ((int) gain_range[2]) / HPI_UNITS_PER_dB;
1794 u32 h_control = kcontrol->private_value;
1798 ucontrol->value.integer.value[0] = gain / HPI_UNITS_PER_dB;
1809 u32 h_control = kcontrol->private_value;
1812 gain = (ucontrol->value.integer.value[0]) * HPI_UNITS_PER_dB;
1822 u32 h_control = kcontrol->private_value;
1834 return -EIO;
1857 u32 h_control = kcontrol->private_value;
1870 ucontrol->value.enumerated.item[0] = -1;
1873 ucontrol->value.enumerated.item[0] = idx;
1886 u32 h_control = kcontrol->private_value;
1895 idx = ucontrol->value.enumerated.item[0];
1897 idx = ARRAY_SIZE(tuner_bands) - 1;
1909 u32 h_control = kcontrol->private_value;
1943 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
1944 uinfo->count = 1;
1945 uinfo->value.integer.min = ((int)freq_range[0]);
1946 uinfo->value.integer.max = ((int)freq_range[1]);
1947 uinfo->value.integer.step = ((int)freq_range[2]);
1954 u32 h_control = kcontrol->private_value;
1958 ucontrol->value.integer.value[0] = freq;
1966 u32 h_control = kcontrol->private_value;
1969 freq = ucontrol->value.integer.value[0];
1979 struct snd_card *card = asihpi->card;
1982 snd_control.private_value = hpi_ctl->h_control;
1985 if (!hpi_tuner_get_gain(hpi_ctl->h_control, NULL)) {
1992 return -EINVAL;
2001 return -EINVAL;
2011 /*------------------------------------------------------------
2013 ------------------------------------------------------------*/
2017 u32 h_control = kcontrol->private_value;
2024 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2025 uinfo->count = count;
2026 uinfo->value.integer.min = 0;
2027 uinfo->value.integer.max = 0x7FFFFFFF;
2039 2147484, /* -60dB */
2041 214748, /* -80 */
2043 21475, /* -100 */
2057 u32 h_control = kcontrol->private_value;
2065 ucontrol->value.integer.value[i] = 0;
2067 ucontrol->value.integer.value[i] =
2070 /* -ve is log value in millibels < -60dB,
2073 ucontrol->value.integer.value[i] =
2074 log2lin[an_gain_mB[i] / -1000];
2083 struct snd_card *card = asihpi->card;
2097 /*------------------------------------------------------------
2099 ------------------------------------------------------------*/
2102 u32 h_control = snd_control->private_value;
2121 u32 h_control = kcontrol->private_value;
2123 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2124 uinfo->count = 1;
2125 uinfo->value.enumerated.items =
2128 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2129 uinfo->value.enumerated.item =
2130 uinfo->value.enumerated.items - 1;
2133 uinfo->value.enumerated.item,
2136 sprintf(uinfo->value.enumerated.name, "%s %d",
2137 asihpi_src_names[src_node_type - HPI_SOURCENODE_NONE],
2145 u32 h_control = kcontrol->private_value;
2160 ucontrol->value.enumerated.item[0] = s;
2164 pr_warn("%s: Control %x failed to match mux source %hu %hu\n",
2166 ucontrol->value.enumerated.item[0] = 0;
2174 u32 h_control = kcontrol->private_value;
2181 ucontrol->value.enumerated.item[0],
2194 struct snd_card *card = asihpi->card;
2207 /*------------------------------------------------------------
2209 ------------------------------------------------------------*/
2220 u32 h_control = kcontrol->private_value;
2237 return -EINVAL;
2245 u32 h_control = kcontrol->private_value;
2251 ucontrol->value.enumerated.item[0] = mode - 1;
2260 u32 h_control = kcontrol->private_value;
2265 ucontrol->value.enumerated.item[0] + 1));
2273 struct snd_card *card = asihpi->card;
2285 /*------------------------------------------------------------
2287 ------------------------------------------------------------*/
2289 "N/A", "Local PLL", "Digital Sync", "Word External", "Word Header",
2291 "Prev Module", "BLU-Link",
2304 struct clk_cache *clkcache = &asihpi->cc;
2305 uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
2306 uinfo->count = 1;
2307 uinfo->value.enumerated.items = clkcache->count;
2309 if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
2310 uinfo->value.enumerated.item =
2311 uinfo->value.enumerated.items - 1;
2313 strscpy(uinfo->value.enumerated.name,
2314 clkcache->s[uinfo->value.enumerated.item].name);
2322 struct clk_cache *clkcache = &asihpi->cc;
2323 u32 h_control = kcontrol->private_value;
2327 ucontrol->value.enumerated.item[0] = 0;
2335 for (i = 0; i < clkcache->count; i++)
2336 if ((clkcache->s[i].source == source) &&
2337 (clkcache->s[i].index == srcindex))
2340 ucontrol->value.enumerated.item[0] = i;
2349 struct clk_cache *clkcache = &asihpi->cc;
2352 u32 h_control = kcontrol->private_value;
2355 item = ucontrol->value.enumerated.item[0];
2356 if (item >= clkcache->count)
2357 item = clkcache->count-1;
2360 h_control, clkcache->s[item].source));
2362 if (clkcache->s[item].source == HPI_SAMPLECLOCK_SOURCE_AESEBU_INPUT)
2364 h_control, clkcache->s[item].index));
2368 /*------------------------------------------------------------
2370 ------------------------------------------------------------*/
2375 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2376 uinfo->count = 1;
2377 uinfo->value.integer.min = 8000;
2378 uinfo->value.integer.max = 192000;
2379 uinfo->value.integer.step = 100;
2387 u32 h_control = kcontrol->private_value;
2393 ucontrol->value.integer.value[0] = rate;
2395 ucontrol->value.integer.value[0] = 0;
2403 u32 h_control = kcontrol->private_value;
2405 /* change = asihpi->mixer_clkrate[addr][0] != left ||
2406 asihpi->mixer_clkrate[addr][1] != right;
2410 ucontrol->value.integer.value[0]));
2417 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
2418 uinfo->count = 1;
2419 uinfo->value.integer.min = 8000;
2420 uinfo->value.integer.max = 192000;
2421 uinfo->value.integer.step = 100;
2429 u32 h_control = kcontrol->private_value;
2435 ucontrol->value.integer.value[0] = rate;
2437 ucontrol->value.integer.value[0] = 0;
2448 u32 hSC = hpi_ctl->h_control;
2454 return -EINVAL;
2455 card = asihpi->card;
2456 clkcache = &asihpi->cc;
2457 snd_control.private_value = hpi_ctl->h_control;
2459 clkcache->has_local = 0;
2465 clkcache->s[i].source = source;
2466 clkcache->s[i].index = 0;
2467 clkcache->s[i].name = sampleclock_sources[source];
2471 clkcache->has_local = 1;
2480 clkcache->s[i].source =
2482 clkcache->s[i].index = j;
2483 clkcache->s[i].name = sampleclock_sources[
2487 clkcache->count = i;
2495 return -EINVAL;
2498 if (clkcache->has_local) {
2507 return -EINVAL;
2518 /*------------------------------------------------------------
2520 ------------------------------------------------------------*/
2531 return -EINVAL;
2532 card = asihpi->card;
2533 strscpy(card->mixername, "Asihpi Mixer");
2536 hpi_mixer_open(asihpi->hpi->adapter->index,
2537 &asihpi->h_mixer);
2540 return -err;
2543 prev_ctl.control_type = -1;
2547 asihpi->h_mixer,
2558 dev_info(&asihpi->pci->dev,
2559 "Disabled HPI Control(%d)\n",
2567 hpi_ctl.src_node_type -= HPI_SOURCENODE_NONE;
2568 hpi_ctl.dst_node_type -= HPI_DESTNODE_NONE;
2623 dev_info(&asihpi->pci->dev,
2624 "Untranslated HPI Control (%d) %d %d %d %d %d\n",
2639 dev_info(&asihpi->pci->dev, "%d mixer controls found\n", idx);
2644 /*------------------------------------------------------------
2646 ------------------------------------------------------------*/
2652 struct snd_card_asihpi *asihpi = entry->private_data;
2665 snd_iprintf(buffer, "ASIHPI driver proc file\n");
2667 hpi_handle_error(hpi_adapter_get_info(asihpi->hpi->adapter->index,
2672 "Adapter type ASI%4X\nHardware Index %d\n"
2673 "%d outstreams\n%d instreams\n",
2674 type, asihpi->hpi->adapter->index,
2678 "Serial#%d\nHardware version %c%d\nDSP code version %03d\n",
2682 err = hpi_mixer_get_control(asihpi->h_mixer,
2691 snd_iprintf(buffer, "Sample Clock %dHz, source %s\n",
2698 snd_card_ro_proc_new(asihpi->card, "info", asihpi,
2702 /*------------------------------------------------------------
2704 ------------------------------------------------------------*/
2711 return -ENODEV;
2720 return -ENODEV;
2729 return -ENODEV;
2734 also /proc/asound/hwdep will contain '#-00: asihpi (HPI) for each card'
2741 err = snd_hwdep_new(asihpi->card, "HPI", device, &hw);
2744 strscpy(hw->name, "asihpi (HPI)");
2745 hw->iface = SNDRV_HWDEP_IFACE_LAST;
2746 hw->ops.open = snd_asihpi_hpi_open;
2747 hw->ops.ioctl = snd_asihpi_hpi_ioctl;
2748 hw->ops.release = snd_asihpi_hpi_release;
2749 hw->private_data = asihpi;
2753 /*------------------------------------------------------------
2755 ------------------------------------------------------------*/
2770 return -ENODEV;
2772 /* Should this be enable[hpi->index] ? */
2775 return -ENOENT;
2778 /* Initialise low-level HPI driver */
2784 adapter_index = hpi->adapter->index;
2786 err = snd_card_new(&pci_dev->dev, adapter_index, id[adapter_index],
2790 err = snd_card_new(&pci_dev->dev, index[dev], id[dev],
2795 dev_warn(&pci_dev->dev, "Adapter index %d->ALSA index %d\n",
2796 adapter_index, card->number);
2799 asihpi = card->private_data;
2800 asihpi->card = card;
2801 asihpi->pci = pci_dev;
2802 asihpi->hpi = hpi;
2803 hpi->snd_card = card;
2807 NULL, &asihpi->support_grouping);
2809 asihpi->support_grouping = 0;
2813 &asihpi->support_mrx, NULL);
2815 asihpi->support_mrx = 0;
2819 NULL, &asihpi->update_interval_frames);
2821 asihpi->update_interval_frames = 512;
2823 if (hpi->interrupt_mode) {
2824 asihpi->pcm_start = snd_card_asihpi_pcm_int_start;
2825 asihpi->pcm_stop = snd_card_asihpi_pcm_int_stop;
2826 hpi->interrupt_callback = snd_card_asihpi_isr;
2828 asihpi->pcm_start = snd_card_asihpi_pcm_timer_start;
2829 asihpi->pcm_stop = snd_card_asihpi_pcm_timer_stop;
2836 asihpi->can_dma = (!err);
2840 if (!asihpi->can_dma)
2841 asihpi->update_interval_frames *= 2;
2845 &asihpi->in_max_chans, &asihpi->out_max_chans);
2847 asihpi->in_max_chans = 2;
2848 asihpi->out_max_chans = 2;
2851 if (asihpi->out_max_chans > 2) { /* assume LL mode */
2852 asihpi->out_min_chans = asihpi->out_max_chans;
2853 asihpi->in_min_chans = asihpi->in_max_chans;
2854 asihpi->support_grouping = 0;
2856 asihpi->out_min_chans = 1;
2857 asihpi->in_min_chans = 1;
2860 dev_info(&pci_dev->dev, "Has dma:%d, grouping:%d, mrx:%d, uif:%d\n",
2861 asihpi->can_dma,
2862 asihpi->support_grouping,
2863 asihpi->support_mrx,
2864 asihpi->update_interval_frames
2869 dev_err(&pci_dev->dev, "pcm_new failed\n");
2874 dev_err(&pci_dev->dev, "mixer_new failed\n");
2878 err = hpi_mixer_get_control(asihpi->h_mixer,
2892 strscpy(card->driver, "ASIHPI");
2894 sprintf(card->shortname, "AudioScience ASI%4X",
2895 asihpi->hpi->adapter->type);
2896 sprintf(card->longname, "%s %i",
2897 card->shortname, adapter_index);
2906 dev_err(&pci_dev->dev, "snd_asihpi_probe error %d\n", err);
2916 if (hpi->interrupt_mode) {
2917 hpi->interrupt_callback = NULL;
2918 hpi_handle_error(hpi_adapter_set_property(hpi->adapter->index,
2922 snd_card_free(hpi->snd_card);
2923 hpi->snd_card = NULL;