Lines Matching +full:assigned +full:- +full:resolution +full:- +full:bits
1 // SPDX-License-Identifier: GPL-2.0-or-later
21 /* for art-tsc conversion */
54 /* release the assigned stream */
64 return &apcm->info->stream[substream->stream];
74 if (!hinfo->ops.get_delay)
77 codec_frames = hinfo->ops.get_delay(hinfo, apcm->codec, substream);
79 substream->runtime->rate);
81 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE)
84 return (nsec > codec_nsecs) ? nsec - codec_nsecs : 0;
95 struct azx *chip = apcm->chip;
99 scoped_guard(mutex, &chip->open_mutex) {
101 if (hinfo->ops.close)
102 hinfo->ops.close(hinfo, apcm->codec, substream);
103 snd_hda_power_down(apcm->codec);
105 snd_hda_codec_pcm_put(apcm->info);
113 struct azx *chip = apcm->chip;
120 return -EBUSY;
122 /* Set up BDLEs here, return -ENOMEM if too many BDLEs are required */
123 hdas->bufsize = params_buffer_bytes(hw_params);
124 hdas->period_bytes = params_period_bytes(hw_params);
125 hdas->format_val = 0;
126 hdas->no_period_wakeup =
127 (hw_params->info & SNDRV_PCM_INFO_NO_PERIOD_WAKEUP) &&
128 (hw_params->flags & SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP);
130 return -ENOMEM;
146 snd_hda_codec_cleanup(apcm->codec, hinfo, substream);
148 azx_stream(azx_dev)->prepared = 0;
155 struct azx *chip = apcm->chip;
158 struct snd_pcm_runtime *runtime = substream->runtime;
159 unsigned int format_val, stream_tag, bits;
162 snd_hda_spdif_out_of_nid(apcm->codec, hinfo->nid);
163 unsigned short ctls = spdif ? spdif->ctls : 0;
168 return -EBUSY;
171 bits = snd_hdac_stream_format_bits(runtime->format, SNDRV_PCM_SUBFORMAT_STD, hinfo->maxbps);
173 format_val = snd_hdac_spdif_stream_format(runtime->channels, bits, runtime->rate, ctls);
175 dev_err(chip->card->dev,
177 runtime->rate, runtime->channels, runtime->format);
178 return -EINVAL;
187 stream_tag = azx_dev->core.stream_tag;
188 /* CA-IBG chips need the playback stream starting from 1 */
189 if ((chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND) &&
190 stream_tag > chip->capture_streams)
191 stream_tag -= chip->capture_streams;
192 err = snd_hda_codec_prepare(apcm->codec, hinfo, stream_tag,
193 azx_dev->core.format_val, substream);
197 azx_stream(azx_dev)->prepared = 1;
204 struct azx *chip = apcm->chip;
217 if (chip->driver_caps & AZX_DCAPS_OLD_SSYNC)
222 if (dsp_is_locked(azx_dev) || !hstr->prepared)
223 return -EPIPE;
237 return -EINVAL;
241 if (s->pcm->card != substream->pcm->card)
244 sbits |= 1 << azx_dev->core.index;
248 scoped_guard(spinlock, &bus->reg_lock) {
249 /* first, set SYNC bits of corresponding streams */
253 if (s->pcm->card != substream->pcm->card)
257 azx_dev->insufficient = 1;
267 guard(spinlock)(&bus->reg_lock);
268 /* reset SYNC bits */
289 struct snd_pcm_substream *substream = azx_dev->core.substream;
291 int stream = substream->stream;
294 if (chip->get_position[stream])
295 pos = chip->get_position[stream](chip, azx_dev);
299 if (pos >= azx_dev->core.bufsize)
302 if (substream->runtime) {
306 if (chip->get_delay[stream])
307 delay += chip->get_delay[stream](chip, azx_dev, pos);
308 if (hinfo->ops.get_delay)
309 delay += hinfo->ops.get_delay(hinfo, apcm->codec,
311 substream->runtime->delay = delay;
322 struct azx *chip = apcm->chip;
324 return bytes_to_frames(substream->runtime,
342 * rem can’t overflow because both are 32-bit values
366 struct azx *chip = apcm->chip;
376 runtime = substream->runtime;
378 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
387 (azx_dev->core.stream_tag - 1);
398 timeout--;
402 dev_err(chip->card->dev, "GTSCC capture Timedout!\n");
403 return -EIO;
432 if (wallclk_cycles < HDA_MAX_CYCLE_VALUE - HDA_MAX_CYCLE_OFFSET
446 dev_err_ratelimited(chip->card->dev,
448 return -EIO;
452 NSEC_PER_SEC, runtime->rate));
454 ((HDA_MAX_CYCLE_VALUE + 1) * runtime->rate));
456 system->cycles = tsc_counter;
457 system->cs_id = CSID_X86_ART;
466 return -ENXIO;
480 if (runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME)
481 if (ts->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK_SYNCHRONIZED)
493 struct snd_pcm_runtime *runtime = substream->runtime;
498 if ((substream->runtime->hw.info & SNDRV_PCM_INFO_HAS_LINK_ATIME) &&
499 (audio_tstamp_config->type_requested == SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK)) {
501 snd_pcm_gettime(substream->runtime, system_ts);
503 nsec = timecounter_read(&azx_dev->core.tc);
504 if (audio_tstamp_config->report_delay)
509 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_LINK;
510 audio_tstamp_report->accuracy_report = 1; /* rest of structure is valid */
511 audio_tstamp_report->accuracy = 42; /* 24 MHz WallClock == 42ns resolution */
519 switch (runtime->tstamp_type) {
521 return -EINVAL;
535 audio_tstamp_report->actual_type =
537 audio_tstamp_report->accuracy_report = 1;
538 /* 24 MHz WallClock == 42ns resolution */
539 audio_tstamp_report->accuracy = 42;
542 audio_tstamp_report->actual_type = SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT;
553 /* No full-resume yet implemented */
578 struct azx *chip = apcm->chip;
580 struct snd_pcm_runtime *runtime = substream->runtime;
584 snd_hda_codec_pcm_get(apcm->info);
585 mutex_lock(&chip->open_mutex);
589 err = -EBUSY;
592 runtime->private_data = azx_dev;
594 runtime->hw = azx_pcm_hw;
595 if (chip->gts_present)
596 runtime->hw.info |= SNDRV_PCM_INFO_HAS_LINK_SYNCHRONIZED_ATIME;
597 runtime->hw.channels_min = hinfo->channels_min;
598 runtime->hw.channels_max = hinfo->channels_max;
599 runtime->hw.formats = hinfo->formats;
600 runtime->hw.rates = hinfo->rates;
604 /* avoid wrap-around with wall-clock */
609 if (chip->align_buffer_size)
628 snd_hda_power_up(apcm->codec);
629 if (hinfo->ops.open)
630 err = hinfo->ops.open(hinfo, apcm->codec, substream);
632 err = -ENODEV;
639 if (snd_BUG_ON(!runtime->hw.channels_min) ||
640 snd_BUG_ON(!runtime->hw.channels_max) ||
641 snd_BUG_ON(!runtime->hw.formats) ||
642 snd_BUG_ON(!runtime->hw.rates)) {
644 if (hinfo->ops.close)
645 hinfo->ops.close(hinfo, apcm->codec, substream);
646 err = -EINVAL;
652 if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) {
653 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_WALL_CLOCK; /* legacy */
654 runtime->hw.info &= ~SNDRV_PCM_INFO_HAS_LINK_ATIME;
658 mutex_unlock(&chip->open_mutex);
662 snd_hda_power_down(apcm->codec);
664 mutex_unlock(&chip->open_mutex);
665 snd_hda_codec_pcm_put(apcm->info);
682 struct azx_pcm *apcm = pcm->private_data;
684 list_del(&apcm->list);
685 apcm->info->pcm = NULL;
695 struct hdac_bus *bus = &_bus->core;
699 int pcm_dev = cpcm->device;
704 list_for_each_entry(apcm, &chip->pcm_list, list) {
705 if (apcm->pcm->device == pcm_dev) {
706 dev_err(chip->card->dev, "PCM %d already exists\n",
708 return -EBUSY;
711 err = snd_pcm_new(chip->card, cpcm->name, pcm_dev,
712 cpcm->stream[SNDRV_PCM_STREAM_PLAYBACK].substreams,
713 cpcm->stream[SNDRV_PCM_STREAM_CAPTURE].substreams,
717 strscpy(pcm->name, cpcm->name, sizeof(pcm->name));
720 snd_device_free(chip->card, pcm);
721 return -ENOMEM;
723 apcm->chip = chip;
724 apcm->pcm = pcm;
725 apcm->codec = codec;
726 apcm->info = cpcm;
727 pcm->private_data = apcm;
728 pcm->private_free = azx_pcm_free;
729 if (cpcm->pcm_type == HDA_PCM_TYPE_MODEM)
730 pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
731 list_add_tail(&apcm->list, &chip->pcm_list);
732 cpcm->pcm = pcm;
734 if (cpcm->stream[s].substreams)
737 /* buffer pre-allocation */
741 if (chip->uc_buffer)
743 snd_pcm_set_managed_buffer_all(pcm, type, chip->card->dev,
765 struct hda_bus *hbus = &chip->bus;
773 if (hbus->no_response_fallback)
774 return -EIO;
776 if (!bus->polling_mode) {
777 dev_warn(chip->card->dev,
779 bus->last_cmd[addr]);
780 bus->polling_mode = 1;
784 if (chip->msi) {
785 dev_warn(chip->card->dev,
787 bus->last_cmd[addr]);
788 if (chip->ops->disable_msi_reset_irq &&
789 chip->ops->disable_msi_reset_irq(chip) < 0)
790 return -EIO;
794 if (chip->probing) {
796 * phase, this is likely an access to a non-existing codec
799 return -EIO;
803 if (!chip->fallback_to_single_cmd)
804 return -EIO;
809 if (hbus->allow_bus_reset && !hbus->response_reset && !hbus->in_reset) {
810 hbus->response_reset = 1;
811 dev_err(chip->card->dev,
813 bus->last_cmd[addr]);
814 return -EAGAIN; /* give a chance to retry */
817 dev_err(chip->card->dev,
819 bus->last_cmd[addr]);
820 chip->single_cmd = 1;
821 hbus->response_reset = 0;
823 return -EIO;
841 while (timeout--) {
845 azx_bus(chip)->rirb.res[addr] = azx_readl(chip, IR);
851 dev_dbg(chip->card->dev, "get_response timeout: IRS=0x%x\n",
853 azx_bus(chip)->rirb.res[addr] = -1;
854 return -EIO;
864 bus->last_cmd[azx_command_addr(val)] = val;
865 while (timeout--) {
879 dev_dbg(chip->card->dev,
882 return -EIO;
890 *res = bus->rirb.res[addr];
897 * They are just the skeleton to call sub-callbacks according to the
898 * current setting of chip->single_cmd.
906 if (chip->disabled)
908 if (chip->single_cmd || bus->use_pio_for_commands)
920 if (chip->disabled)
922 if (chip->single_cmd || bus->use_pio_for_commands)
945 list_for_each_entry(s, &bus->stream_list, list)
946 if (s->index == chip->playback_index_offset)
956 struct hdac_bus *bus = &codec->bus->core;
965 scoped_guard(spinlock_irq, &bus->reg_lock) {
966 if (hstr->opened) {
967 chip->saved_azx_dev = *azx_dev;
974 guard(spinlock_irq)(&bus->reg_lock);
976 *azx_dev = chip->saved_azx_dev;
980 hstr->prepared = 0;
987 struct hdac_bus *bus = &codec->bus->core;
998 struct hdac_bus *bus = &codec->bus->core;
1003 if (!dmab->area || !hstr->locked)
1007 guard(spinlock_irq)(&bus->reg_lock);
1008 if (hstr->opened)
1009 *azx_dev = chip->saved_azx_dev;
1010 hstr->locked = false;
1022 if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
1051 if (!chip->ops->position_check ||
1052 chip->ops->position_check(chip, azx_dev)) {
1053 spin_unlock(&bus->reg_lock);
1054 snd_pcm_period_elapsed(azx_stream(azx_dev)->substream);
1055 spin_lock(&bus->reg_lock);
1068 if (!pm_runtime_active(chip->card->dev))
1071 guard(spinlock)(&bus->reg_lock);
1073 if (chip->disabled)
1099 if (chip->driver_caps & AZX_DCAPS_CTX_WORKAROUND)
1123 unsigned int res = -1;
1125 scoped_guard(mutex, &bus->cmd_mutex) {
1126 chip->probing = 1;
1129 chip->probing = 0;
1131 if (err < 0 || res == -1)
1132 return -EIO;
1133 dev_dbg(chip->card->dev, "codec #%d probed OK\n", addr);
1139 struct azx *chip = bus_to_azx(&bus->core);
1141 bus->in_reset = 1;
1144 if (bus->core.chip_init)
1146 bus->in_reset = 0;
1149 /* HD-audio bus initialization */
1152 struct hda_bus *bus = &chip->bus;
1155 err = snd_hdac_bus_init(&bus->core, chip->card->dev, &bus_core_ops);
1159 bus->card = chip->card;
1160 mutex_init(&bus->prepare_mutex);
1161 bus->pci = chip->pci;
1162 bus->modelname = model;
1163 bus->mixer_assigned = -1;
1164 bus->core.snoop = azx_snoop(chip);
1165 if (chip->get_position[0] != azx_get_pos_lpib ||
1166 chip->get_position[1] != azx_get_pos_lpib)
1167 bus->core.use_posbuf = true;
1168 bus->core.bdl_pos_adj = chip->bdl_pos_adj;
1169 if (chip->driver_caps & AZX_DCAPS_CORBRP_SELF_CLEAR)
1170 bus->core.corbrp_self_clear = true;
1172 if (chip->driver_caps & AZX_DCAPS_4K_BDLE_BOUNDARY)
1173 bus->core.align_bdle_4k = true;
1175 if (chip->driver_caps & AZX_DCAPS_PIO_COMMANDS)
1176 bus->core.use_pio_for_commands = true;
1179 bus->core.sync_write = 1;
1197 if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1202 dev_warn(chip->card->dev,
1204 bus->codec_mask &= ~(1 << c);
1206 if (bus->codec_mask == 0)
1208 /* More badly, accessing to a non-existing
1223 if ((bus->codec_mask & (1 << c)) & chip->codec_probe_mask) {
1225 err = snd_hda_codec_new(&chip->bus, chip->card, c, &codec);
1228 codec->jackpoll_interval = chip->jackpoll_interval;
1229 codec->beep_mode = chip->beep_mode;
1230 codec->ctl_dev_id = chip->ctl_dev_id;
1235 dev_err(chip->card->dev, "no codecs initialized\n");
1236 return -ENXIO;
1248 list_for_each_codec(codec, &chip->bus) {
1255 list_for_each_codec_safe(codec, next, &chip->bus) {
1256 if (!codec->configured) {
1258 snd_hdac_device_unregister(&codec->core);
1263 return success ? 0 : -ENODEV;
1269 if (index >= chip->capture_index_offset &&
1270 index < chip->capture_index_offset + chip->capture_streams)
1285 for (i = 0; i < chip->num_streams; i++) {
1290 return -ENOMEM;
1299 if (chip->driver_caps & AZX_DCAPS_SEPARATE_STREAM_TAG)
1316 while (!list_empty(&bus->stream_list)) {
1317 s = list_first_entry(&bus->stream_list, struct hdac_stream, list);
1318 list_del(&s->list);