Lines Matching +full:num +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Abramo Bagnara <abramo@alsa-project.org>
43 delta = new_ptr - ptr; in update_silence_vars()
47 delta += runtime->boundary; in update_silence_vars()
48 if ((snd_pcm_uframes_t)delta < runtime->silence_filled) in update_silence_vars()
49 runtime->silence_filled -= delta; in update_silence_vars()
51 runtime->silence_filled = 0; in update_silence_vars()
52 runtime->silence_start = new_ptr; in update_silence_vars()
57 * runtime->silence_start: starting pointer to silence area
58 * runtime->silence_filled: size filled with silence
59 * runtime->silence_threshold: threshold from application
60 * runtime->silence_size: maximal size from application
62 * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately
66 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_silence()
70 if (runtime->silence_size < runtime->boundary) { in snd_pcm_playback_silence()
72 snd_pcm_uframes_t appl_ptr = READ_ONCE(runtime->control->appl_ptr); in snd_pcm_playback_silence()
73 update_silence_vars(runtime, runtime->silence_start, appl_ptr); in snd_pcm_playback_silence()
76 new_hw_ptr = runtime->status->hw_ptr; in snd_pcm_playback_silence()
78 noise_dist = appl_ptr - new_hw_ptr; in snd_pcm_playback_silence()
80 noise_dist += runtime->boundary; in snd_pcm_playback_silence()
82 noise_dist += runtime->silence_filled; in snd_pcm_playback_silence()
83 if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) in snd_pcm_playback_silence()
85 frames = runtime->silence_threshold - noise_dist; in snd_pcm_playback_silence()
86 if (frames > runtime->silence_size) in snd_pcm_playback_silence()
87 frames = runtime->silence_size; in snd_pcm_playback_silence()
90 * This filling mode aims at free-running mode (used for example by dmix), in snd_pcm_playback_silence()
93 snd_pcm_uframes_t hw_ptr = runtime->status->hw_ptr; in snd_pcm_playback_silence()
101 snd_pcm_sframes_t avail = runtime->control->appl_ptr - hw_ptr; in snd_pcm_playback_silence()
103 avail += runtime->boundary; in snd_pcm_playback_silence()
105 * In free-running mode, appl_ptr will be zero even while running, in snd_pcm_playback_silence()
109 runtime->silence_filled = avail > runtime->buffer_size ? 0 : avail; in snd_pcm_playback_silence()
110 runtime->silence_start = hw_ptr; in snd_pcm_playback_silence()
119 frames = runtime->buffer_size - runtime->silence_filled; in snd_pcm_playback_silence()
121 if (snd_BUG_ON(frames > runtime->buffer_size)) in snd_pcm_playback_silence()
125 ofs = (runtime->silence_start + runtime->silence_filled) % runtime->buffer_size; in snd_pcm_playback_silence()
127 transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames; in snd_pcm_playback_silence()
130 runtime->silence_filled += transfer; in snd_pcm_playback_silence()
131 frames -= transfer; in snd_pcm_playback_silence()
142 substream->pcm->card->number, in snd_pcm_debug_name()
143 substream->pcm->device, in snd_pcm_debug_name()
144 substream->stream ? 'c' : 'p', in snd_pcm_debug_name()
145 substream->number); in snd_pcm_debug_name()
157 ((substream)->pstr->xrun_debug & (mask))
170 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_xrun()
173 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in __snd_pcm_xrun()
177 runtime->status->tstamp.tv_sec = tstamp.tv_sec; in __snd_pcm_xrun()
178 runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; in __snd_pcm_xrun()
184 pcm_warn(substream->pcm, "XRUN: %s\n", name); in __snd_pcm_xrun()
188 substream->xrun_counter++; in __snd_pcm_xrun()
215 if (avail > runtime->avail_max) in snd_pcm_update_state()
216 runtime->avail_max = avail; in snd_pcm_update_state()
217 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_update_state()
218 if (avail >= runtime->buffer_size) { in snd_pcm_update_state()
220 return -EPIPE; in snd_pcm_update_state()
223 if (avail >= runtime->stop_threshold) { in snd_pcm_update_state()
225 return -EPIPE; in snd_pcm_update_state()
228 if (runtime->twake) { in snd_pcm_update_state()
229 if (avail >= runtime->twake) in snd_pcm_update_state()
230 wake_up(&runtime->tsleep); in snd_pcm_update_state()
231 } else if (avail >= runtime->control->avail_min) in snd_pcm_update_state()
232 wake_up(&runtime->sleep); in snd_pcm_update_state()
240 struct snd_pcm_runtime *runtime = substream->runtime; in update_audio_tstamp()
244 if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) in update_audio_tstamp()
247 if (!(substream->ops->get_time_info) || in update_audio_tstamp()
248 (runtime->audio_tstamp_report.actual_type == in update_audio_tstamp()
256 audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; in update_audio_tstamp()
258 if (runtime->audio_tstamp_config.report_delay) { in update_audio_tstamp()
259 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in update_audio_tstamp()
260 audio_frames -= runtime->delay; in update_audio_tstamp()
262 audio_frames += runtime->delay; in update_audio_tstamp()
265 runtime->rate); in update_audio_tstamp()
269 if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || in update_audio_tstamp()
270 runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { in update_audio_tstamp()
271 runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; in update_audio_tstamp()
272 runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; in update_audio_tstamp()
273 runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; in update_audio_tstamp()
274 runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; in update_audio_tstamp()
279 * re-take a driver timestamp to let apps detect if the reference tstamp in update_audio_tstamp()
280 * read by low-level hardware was provided with a delay in update_audio_tstamp()
282 snd_pcm_gettime(substream->runtime, &driver_tstamp); in update_audio_tstamp()
283 runtime->driver_tstamp = driver_tstamp; in update_audio_tstamp()
289 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_update_hw_ptr0()
299 old_hw_ptr = runtime->status->hw_ptr; in snd_pcm_update_hw_ptr0()
307 pos = substream->ops->pointer(substream); in snd_pcm_update_hw_ptr0()
309 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_update_hw_ptr0()
310 if ((substream->ops->get_time_info) && in snd_pcm_update_hw_ptr0()
311 (runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { in snd_pcm_update_hw_ptr0()
312 substream->ops->get_time_info(substream, &curr_tstamp, in snd_pcm_update_hw_ptr0()
314 &runtime->audio_tstamp_config, in snd_pcm_update_hw_ptr0()
315 &runtime->audio_tstamp_report); in snd_pcm_update_hw_ptr0()
317 /* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */ in snd_pcm_update_hw_ptr0()
318 if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) in snd_pcm_update_hw_ptr0()
326 return -EPIPE; in snd_pcm_update_hw_ptr0()
328 if (pos >= runtime->buffer_size) { in snd_pcm_update_hw_ptr0()
332 pcm_err(substream->pcm, in snd_pcm_update_hw_ptr0()
334 name, pos, runtime->buffer_size, in snd_pcm_update_hw_ptr0()
335 runtime->period_size); in snd_pcm_update_hw_ptr0()
339 pos -= pos % runtime->min_align; in snd_pcm_update_hw_ptr0()
341 hw_base = runtime->hw_ptr_base; in snd_pcm_update_hw_ptr0()
346 delta = runtime->hw_ptr_interrupt + runtime->period_size; in snd_pcm_update_hw_ptr0()
349 hdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
350 if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) { in snd_pcm_update_hw_ptr0()
351 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
352 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
364 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
365 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
372 delta = new_hw_ptr - old_hw_ptr; in snd_pcm_update_hw_ptr0()
374 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
376 if (runtime->no_period_wakeup) { in snd_pcm_update_hw_ptr0()
382 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
383 if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) in snd_pcm_update_hw_ptr0()
385 hdelta = jdelta - delta * HZ / runtime->rate; in snd_pcm_update_hw_ptr0()
386 xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; in snd_pcm_update_hw_ptr0()
388 delta += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
389 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
390 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
395 hdelta -= runtime->hw_ptr_buffer_jiffies; in snd_pcm_update_hw_ptr0()
401 if (delta >= runtime->buffer_size + runtime->period_size) { in snd_pcm_update_hw_ptr0()
404 substream->stream, (long)pos, in snd_pcm_update_hw_ptr0()
417 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) in snd_pcm_update_hw_ptr0()
420 if (hdelta < runtime->delay) in snd_pcm_update_hw_ptr0()
422 hdelta -= runtime->delay; in snd_pcm_update_hw_ptr0()
423 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
424 if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { in snd_pcm_update_hw_ptr0()
426 (((runtime->period_size * HZ) / runtime->rate) in snd_pcm_update_hw_ptr0()
434 new_hw_ptr += runtime->period_size; in snd_pcm_update_hw_ptr0()
435 if (new_hw_ptr >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
436 new_hw_ptr -= runtime->boundary; in snd_pcm_update_hw_ptr0()
437 crossed_boundary--; in snd_pcm_update_hw_ptr0()
439 delta--; in snd_pcm_update_hw_ptr0()
445 (long)runtime->period_size, jdelta, in snd_pcm_update_hw_ptr0()
446 ((hdelta * HZ) / runtime->rate), hw_base, in snd_pcm_update_hw_ptr0()
451 hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); in snd_pcm_update_hw_ptr0()
454 if (delta > runtime->period_size + runtime->period_size / 2) { in snd_pcm_update_hw_ptr0()
458 substream->stream, (long)delta, in snd_pcm_update_hw_ptr0()
464 if (runtime->status->hw_ptr == new_hw_ptr) { in snd_pcm_update_hw_ptr0()
465 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
470 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_update_hw_ptr0()
471 runtime->silence_size > 0) in snd_pcm_update_hw_ptr0()
475 delta = new_hw_ptr - runtime->hw_ptr_interrupt; in snd_pcm_update_hw_ptr0()
477 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
478 delta -= (snd_pcm_uframes_t)delta % runtime->period_size; in snd_pcm_update_hw_ptr0()
479 runtime->hw_ptr_interrupt += delta; in snd_pcm_update_hw_ptr0()
480 if (runtime->hw_ptr_interrupt >= runtime->boundary) in snd_pcm_update_hw_ptr0()
481 runtime->hw_ptr_interrupt -= runtime->boundary; in snd_pcm_update_hw_ptr0()
483 runtime->hw_ptr_base = hw_base; in snd_pcm_update_hw_ptr0()
484 runtime->status->hw_ptr = new_hw_ptr; in snd_pcm_update_hw_ptr0()
485 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
488 runtime->hw_ptr_wrap += runtime->boundary; in snd_pcm_update_hw_ptr0()
503 * snd_pcm_set_ops - set the PCM operators
513 struct snd_pcm_str *stream = &pcm->streams[direction]; in snd_pcm_set_ops()
516 for (substream = stream->substream; substream != NULL; substream = substream->next) in snd_pcm_set_ops()
517 substream->ops = ops; in snd_pcm_set_ops()
522 * snd_pcm_set_sync_per_card - set the PCM sync id with card number
530 * User space or any user should use this 16-byte identifier for a comparison only
532 * containing only zeros. Interpretation for this combination is - empty (not set).
540 * 12-byte additional ID. When other ID composition is used (e.g. for multiple
548 *(__u32 *)params->sync = cpu_to_le32(substream->pcm->card->number); in snd_pcm_set_sync_per_card()
550 memcpy(params->sync + 4, id, len); in snd_pcm_set_sync_per_card()
551 memset(params->sync + 4 + len, 0, 12 - len); in snd_pcm_set_sync_per_card()
615 * snd_interval_refine - refine the interval value of configurator
630 return -EINVAL; in snd_interval_refine()
631 if (i->min < v->min) { in snd_interval_refine()
632 i->min = v->min; in snd_interval_refine()
633 i->openmin = v->openmin; in snd_interval_refine()
635 } else if (i->min == v->min && !i->openmin && v->openmin) { in snd_interval_refine()
636 i->openmin = 1; in snd_interval_refine()
639 if (i->max > v->max) { in snd_interval_refine()
640 i->max = v->max; in snd_interval_refine()
641 i->openmax = v->openmax; in snd_interval_refine()
643 } else if (i->max == v->max && !i->openmax && v->openmax) { in snd_interval_refine()
644 i->openmax = 1; in snd_interval_refine()
647 if (!i->integer && v->integer) { in snd_interval_refine()
648 i->integer = 1; in snd_interval_refine()
651 if (i->integer) { in snd_interval_refine()
652 if (i->openmin) { in snd_interval_refine()
653 i->min++; in snd_interval_refine()
654 i->openmin = 0; in snd_interval_refine()
656 if (i->openmax) { in snd_interval_refine()
657 i->max--; in snd_interval_refine()
658 i->openmax = 0; in snd_interval_refine()
660 } else if (!i->openmin && !i->openmax && i->min == i->max) in snd_interval_refine()
661 i->integer = 1; in snd_interval_refine()
664 return -EINVAL; in snd_interval_refine()
672 const unsigned int last_max = i->max; in snd_interval_refine_first()
675 return -EINVAL; in snd_interval_refine_first()
678 i->max = i->min; in snd_interval_refine_first()
679 if (i->openmin) in snd_interval_refine_first()
680 i->max++; in snd_interval_refine_first()
682 i->openmax = (i->openmax && i->max >= last_max); in snd_interval_refine_first()
688 const unsigned int last_min = i->min; in snd_interval_refine_last()
691 return -EINVAL; in snd_interval_refine_last()
694 i->min = i->max; in snd_interval_refine_last()
695 if (i->openmax) in snd_interval_refine_last()
696 i->min--; in snd_interval_refine_last()
698 i->openmin = (i->openmin && i->min <= last_min); in snd_interval_refine_last()
704 if (a->empty || b->empty) { in snd_interval_mul()
708 c->empty = 0; in snd_interval_mul()
709 c->min = mul(a->min, b->min); in snd_interval_mul()
710 c->openmin = (a->openmin || b->openmin); in snd_interval_mul()
711 c->max = mul(a->max, b->max); in snd_interval_mul()
712 c->openmax = (a->openmax || b->openmax); in snd_interval_mul()
713 c->integer = (a->integer && b->integer); in snd_interval_mul()
717 * snd_interval_div - refine the interval value with division
724 * Returns non-zero if the value is changed, zero if not changed.
729 if (a->empty || b->empty) { in snd_interval_div()
733 c->empty = 0; in snd_interval_div()
734 c->min = div32(a->min, b->max, &r); in snd_interval_div()
735 c->openmin = (r || a->openmin || b->openmax); in snd_interval_div()
736 if (b->min > 0) { in snd_interval_div()
737 c->max = div32(a->max, b->min, &r); in snd_interval_div()
739 c->max++; in snd_interval_div()
740 c->openmax = 1; in snd_interval_div()
742 c->openmax = (a->openmax || b->openmin); in snd_interval_div()
744 c->max = UINT_MAX; in snd_interval_div()
745 c->openmax = 0; in snd_interval_div()
747 c->integer = 0; in snd_interval_div()
751 * snd_interval_muldivk - refine the interval value
759 * Returns non-zero if the value is changed, zero if not changed.
765 if (a->empty || b->empty) { in snd_interval_muldivk()
769 c->empty = 0; in snd_interval_muldivk()
770 c->min = muldiv32(a->min, b->min, k, &r); in snd_interval_muldivk()
771 c->openmin = (r || a->openmin || b->openmin); in snd_interval_muldivk()
772 c->max = muldiv32(a->max, b->max, k, &r); in snd_interval_muldivk()
774 c->max++; in snd_interval_muldivk()
775 c->openmax = 1; in snd_interval_muldivk()
777 c->openmax = (a->openmax || b->openmax); in snd_interval_muldivk()
778 c->integer = 0; in snd_interval_muldivk()
782 * snd_interval_mulkdiv - refine the interval value
790 * Returns non-zero if the value is changed, zero if not changed.
796 if (a->empty || b->empty) { in snd_interval_mulkdiv()
800 c->empty = 0; in snd_interval_mulkdiv()
801 c->min = muldiv32(a->min, k, b->max, &r); in snd_interval_mulkdiv()
802 c->openmin = (r || a->openmin || b->openmax); in snd_interval_mulkdiv()
803 if (b->min > 0) { in snd_interval_mulkdiv()
804 c->max = muldiv32(a->max, k, b->min, &r); in snd_interval_mulkdiv()
806 c->max++; in snd_interval_mulkdiv()
807 c->openmax = 1; in snd_interval_mulkdiv()
809 c->openmax = (a->openmax || b->openmin); in snd_interval_mulkdiv()
811 c->max = UINT_MAX; in snd_interval_mulkdiv()
812 c->openmax = 0; in snd_interval_mulkdiv()
814 c->integer = 0; in snd_interval_mulkdiv()
817 /* ---- */
821 * snd_interval_ratnum - refine the interval value
845 unsigned int num = rats[k].num; in snd_interval_ratnum() local
847 unsigned int q = i->min; in snd_interval_ratnum()
851 den = div_up(num, q); in snd_interval_ratnum()
858 r = (den - rats[k].den_min) % rats[k].den_step; in snd_interval_ratnum()
860 den -= r; in snd_interval_ratnum()
862 diff = num - q * den; in snd_interval_ratnum()
864 diff = -diff; in snd_interval_ratnum()
869 best_num = num; in snd_interval_ratnum()
873 i->empty = 1; in snd_interval_ratnum()
874 return -EINVAL; in snd_interval_ratnum()
884 unsigned int num = rats[k].num; in snd_interval_ratnum() local
886 unsigned int q = i->max; in snd_interval_ratnum()
889 i->empty = 1; in snd_interval_ratnum()
890 return -EINVAL; in snd_interval_ratnum()
892 den = div_down(num, q); in snd_interval_ratnum()
899 r = (den - rats[k].den_min) % rats[k].den_step; in snd_interval_ratnum()
901 den += rats[k].den_step - r; in snd_interval_ratnum()
903 diff = q * den - num; in snd_interval_ratnum()
905 diff = -diff; in snd_interval_ratnum()
910 best_num = num; in snd_interval_ratnum()
914 i->empty = 1; in snd_interval_ratnum()
915 return -EINVAL; in snd_interval_ratnum()
939 * snd_interval_ratden - refine the interval value
961 unsigned int num; in snd_interval_ratden() local
963 unsigned int q = i->min; in snd_interval_ratden()
965 num = mul(q, den); in snd_interval_ratden()
966 if (num > rats[k].num_max) in snd_interval_ratden()
968 if (num < rats[k].num_min) in snd_interval_ratden()
969 num = rats[k].num_max; in snd_interval_ratden()
972 r = (num - rats[k].num_min) % rats[k].num_step; in snd_interval_ratden()
974 num += rats[k].num_step - r; in snd_interval_ratden()
976 diff = num - q * den; in snd_interval_ratden()
981 best_num = num; in snd_interval_ratden()
985 i->empty = 1; in snd_interval_ratden()
986 return -EINVAL; in snd_interval_ratden()
993 unsigned int num; in snd_interval_ratden() local
995 unsigned int q = i->max; in snd_interval_ratden()
997 num = mul(q, den); in snd_interval_ratden()
998 if (num < rats[k].num_min) in snd_interval_ratden()
1000 if (num > rats[k].num_max) in snd_interval_ratden()
1001 num = rats[k].num_max; in snd_interval_ratden()
1004 r = (num - rats[k].num_min) % rats[k].num_step; in snd_interval_ratden()
1006 num -= r; in snd_interval_ratden()
1008 diff = q * den - num; in snd_interval_ratden()
1013 best_num = num; in snd_interval_ratden()
1017 i->empty = 1; in snd_interval_ratden()
1018 return -EINVAL; in snd_interval_ratden()
1037 * snd_interval_list - refine the interval value from the list
1041 * @mask: the bit-mask to evaluate
1044 * When mask is non-zero, only the elements corresponding to bit 1 are
1057 i->empty = 1; in snd_interval_list()
1058 return -EINVAL; in snd_interval_list()
1076 * snd_interval_ranges - refine the interval value from the list of ranges
1080 * @mask: the bit-mask to evaluate
1083 * When mask is non-zero, only the elements corresponding to bit 1 are
1098 return -EINVAL; in snd_interval_ranges()
1133 n = i->min % step; in snd_interval_step()
1134 if (n != 0 || i->openmin) { in snd_interval_step()
1135 i->min += step - n; in snd_interval_step()
1136 i->openmin = 0; in snd_interval_step()
1139 n = i->max % step; in snd_interval_step()
1140 if (n != 0 || i->openmax) { in snd_interval_step()
1141 i->max -= n; in snd_interval_step()
1142 i->openmax = 0; in snd_interval_step()
1146 i->empty = 1; in snd_interval_step()
1147 return -EINVAL; in snd_interval_step()
1155 * snd_pcm_hw_rule_add - add the hw-constraint rule
1170 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_rule_add()
1175 if (constrs->rules_num >= constrs->rules_all) { in snd_pcm_hw_rule_add()
1177 unsigned int new_rules = constrs->rules_all + 16; in snd_pcm_hw_rule_add()
1178 new = krealloc_array(constrs->rules, new_rules, in snd_pcm_hw_rule_add()
1182 return -ENOMEM; in snd_pcm_hw_rule_add()
1184 constrs->rules = new; in snd_pcm_hw_rule_add()
1185 constrs->rules_all = new_rules; in snd_pcm_hw_rule_add()
1187 c = &constrs->rules[constrs->rules_num]; in snd_pcm_hw_rule_add()
1188 c->cond = cond; in snd_pcm_hw_rule_add()
1189 c->func = func; in snd_pcm_hw_rule_add()
1190 c->var = var; in snd_pcm_hw_rule_add()
1191 c->private = private; in snd_pcm_hw_rule_add()
1194 if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) { in snd_pcm_hw_rule_add()
1196 return -EINVAL; in snd_pcm_hw_rule_add()
1198 c->deps[k++] = dep; in snd_pcm_hw_rule_add()
1203 constrs->rules_num++; in snd_pcm_hw_rule_add()
1210 * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint
1215 * Apply the constraint of the given bitmap mask to a 32-bit mask parameter.
1222 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask()
1224 *maskp->bits &= mask; in snd_pcm_hw_constraint_mask()
1225 memset(maskp->bits + 1, 0, (SNDRV_MASK_MAX-32) / 8); /* clear rest */ in snd_pcm_hw_constraint_mask()
1226 if (*maskp->bits == 0) in snd_pcm_hw_constraint_mask()
1227 return -EINVAL; in snd_pcm_hw_constraint_mask()
1232 * snd_pcm_hw_constraint_mask64 - apply the given bitmap mask constraint
1237 * Apply the constraint of the given bitmap mask to a 64-bit mask parameter.
1244 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask64()
1246 maskp->bits[0] &= (u_int32_t)mask; in snd_pcm_hw_constraint_mask64()
1247 maskp->bits[1] &= (u_int32_t)(mask >> 32); in snd_pcm_hw_constraint_mask64()
1248 memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ in snd_pcm_hw_constraint_mask64()
1249 if (! maskp->bits[0] && ! maskp->bits[1]) in snd_pcm_hw_constraint_mask64()
1250 return -EINVAL; in snd_pcm_hw_constraint_mask64()
1256 * snd_pcm_hw_constraint_integer - apply an integer constraint to an interval
1267 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_integer()
1273 * snd_pcm_hw_constraint_minmax - apply a min/max range constraint to an interval
1287 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_minmax()
1300 struct snd_pcm_hw_constraint_list *list = rule->private; in snd_pcm_hw_rule_list()
1301 …return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask… in snd_pcm_hw_rule_list()
1306 * snd_pcm_hw_constraint_list - apply a list of constraints to a parameter
1323 var, -1); in snd_pcm_hw_constraint_list()
1330 struct snd_pcm_hw_constraint_ranges *r = rule->private; in snd_pcm_hw_rule_ranges()
1331 return snd_interval_ranges(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ranges()
1332 r->count, r->ranges, r->mask); in snd_pcm_hw_rule_ranges()
1337 * snd_pcm_hw_constraint_ranges - apply list of range constraints to a parameter
1354 var, -1); in snd_pcm_hw_constraint_ranges()
1361 const struct snd_pcm_hw_constraint_ratnums *r = rule->private; in snd_pcm_hw_rule_ratnums()
1362 unsigned int num = 0, den = 0; in snd_pcm_hw_rule_ratnums() local
1364 err = snd_interval_ratnum(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ratnums()
1365 r->nrats, r->rats, &num, &den); in snd_pcm_hw_rule_ratnums()
1366 if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { in snd_pcm_hw_rule_ratnums()
1367 params->rate_num = num; in snd_pcm_hw_rule_ratnums()
1368 params->rate_den = den; in snd_pcm_hw_rule_ratnums()
1374 * snd_pcm_hw_constraint_ratnums - apply ratnums constraint to a parameter
1389 var, -1); in snd_pcm_hw_constraint_ratnums()
1396 const struct snd_pcm_hw_constraint_ratdens *r = rule->private; in snd_pcm_hw_rule_ratdens()
1397 unsigned int num = 0, den = 0; in snd_pcm_hw_rule_ratdens() local
1398 int err = snd_interval_ratden(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ratdens()
1399 r->nrats, r->rats, &num, &den); in snd_pcm_hw_rule_ratdens()
1400 if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { in snd_pcm_hw_rule_ratdens()
1401 params->rate_num = num; in snd_pcm_hw_rule_ratdens()
1402 params->rate_den = den; in snd_pcm_hw_rule_ratdens()
1408 * snd_pcm_hw_constraint_ratdens - apply ratdens constraint to a parameter
1423 var, -1); in snd_pcm_hw_constraint_ratdens()
1430 unsigned int l = (unsigned long) rule->private; in snd_pcm_hw_rule_msbits()
1441 params->msbits = min_not_zero(params->msbits, msbits); in snd_pcm_hw_rule_msbits()
1447 * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule
1466 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_msbits()
1469 SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); in snd_pcm_hw_constraint_msbits()
1476 unsigned long step = (unsigned long) rule->private; in snd_pcm_hw_rule_step()
1477 return snd_interval_step(hw_param_interval(params, rule->var), step); in snd_pcm_hw_rule_step()
1481 * snd_pcm_hw_constraint_step - add a hw constraint step rule
1496 var, -1); in snd_pcm_hw_constraint_step()
1508 return snd_interval_list(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_pow2()
1513 * snd_pcm_hw_constraint_pow2 - add a hw constraint power-of-2 rule
1516 * @var: hw_params variable to apply the power-of-2 constraint
1526 var, -1); in snd_pcm_hw_constraint_pow2()
1533 unsigned int base_rate = (unsigned int)(uintptr_t)rule->private; in snd_pcm_hw_rule_noresample_func()
1541 * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling
1554 SNDRV_PCM_HW_PARAM_RATE, -1); in snd_pcm_hw_rule_noresample()
1563 params->cmask |= 1 << var; in _snd_pcm_hw_param_any()
1564 params->rmask |= 1 << var; in _snd_pcm_hw_param_any()
1569 params->cmask |= 1 << var; in _snd_pcm_hw_param_any()
1570 params->rmask |= 1 << var; in _snd_pcm_hw_param_any()
1584 params->info = ~0U; in _snd_pcm_hw_params_any()
1589 * snd_pcm_hw_param_value - return @params field @var value
1592 * @dir: pointer to the direction (-1,0,1) or %NULL
1595 * defined by @params. -%EINVAL otherwise.
1603 return -EINVAL; in snd_pcm_hw_param_value()
1611 return -EINVAL; in snd_pcm_hw_param_value()
1613 *dir = i->openmin; in snd_pcm_hw_param_value()
1616 return -EINVAL; in snd_pcm_hw_param_value()
1625 params->cmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1626 params->rmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1629 params->cmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1630 params->rmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1646 return -EINVAL; in _snd_pcm_hw_param_first()
1648 params->cmask |= 1 << var; in _snd_pcm_hw_param_first()
1649 params->rmask |= 1 << var; in _snd_pcm_hw_param_first()
1656 * snd_pcm_hw_param_first - refine config space and return minimum value
1660 * @dir: pointer to the direction (-1,0,1) or %NULL
1674 if (params->rmask) { in snd_pcm_hw_param_first()
1692 return -EINVAL; in _snd_pcm_hw_param_last()
1694 params->cmask |= 1 << var; in _snd_pcm_hw_param_last()
1695 params->rmask |= 1 << var; in _snd_pcm_hw_param_last()
1702 * snd_pcm_hw_param_last - refine config space and return maximum value
1706 * @dir: pointer to the direction (-1,0,1) or %NULL
1720 if (params->rmask) { in snd_pcm_hw_param_last()
1730 * snd_pcm_hw_params_bits - Get the number of bits per the sample.
1766 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset()
1771 runtime->status->hw_ptr %= runtime->buffer_size; in snd_pcm_lib_ioctl_reset()
1773 runtime->status->hw_ptr = 0; in snd_pcm_lib_ioctl_reset()
1774 runtime->hw_ptr_wrap = 0; in snd_pcm_lib_ioctl_reset()
1783 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info()
1785 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { in snd_pcm_lib_ioctl_channel_info()
1786 info->offset = -1; in snd_pcm_lib_ioctl_channel_info()
1789 width = snd_pcm_format_physical_width(runtime->format); in snd_pcm_lib_ioctl_channel_info()
1792 info->offset = 0; in snd_pcm_lib_ioctl_channel_info()
1793 switch (runtime->access) { in snd_pcm_lib_ioctl_channel_info()
1796 info->first = info->channel * width; in snd_pcm_lib_ioctl_channel_info()
1797 info->step = runtime->channels * width; in snd_pcm_lib_ioctl_channel_info()
1802 size_t size = runtime->dma_bytes / runtime->channels; in snd_pcm_lib_ioctl_channel_info()
1803 info->first = info->channel * size * 8; in snd_pcm_lib_ioctl_channel_info()
1804 info->step = width; in snd_pcm_lib_ioctl_channel_info()
1819 int channels; in snd_pcm_lib_ioctl_fifo_size() local
1822 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1823 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1825 channels = params_channels(params); in snd_pcm_lib_ioctl_fifo_size()
1826 frame_size = snd_pcm_format_size(format, channels); in snd_pcm_lib_ioctl_fifo_size()
1828 params->fifo_size /= frame_size; in snd_pcm_lib_ioctl_fifo_size()
1840 if (substream->runtime->std_sync_id) in snd_pcm_lib_ioctl_sync_id()
1846 * snd_pcm_lib_ioctl - a generic PCM ioctl callback
1869 return -ENXIO; in snd_pcm_lib_ioctl()
1874 * snd_pcm_period_elapsed_under_stream_lock() - update the status of runtime for the next period
1894 …* - .pointer - to retrieve current position of audio data transmission by frame count or XRUN stat…
1895 * - .trigger - with SNDRV_PCM_TRIGGER_STOP at XRUN or DRAINING state.
1896 * - .get_time_info - to retrieve audio time stamp if needed.
1906 runtime = substream->runtime; in snd_pcm_period_elapsed_under_stream_lock()
1913 if (substream->timer_running) in snd_pcm_period_elapsed_under_stream_lock()
1914 snd_timer_interrupt(substream->timer, 1); in snd_pcm_period_elapsed_under_stream_lock()
1917 snd_kill_fasync(runtime->fasync, SIGIO, POLL_IN); in snd_pcm_period_elapsed_under_stream_lock()
1922 * snd_pcm_period_elapsed() - update the status of runtime for the next period by acquiring lock of
1952 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail()
1953 int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wait_for_avail()
1961 add_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1963 if (runtime->no_period_wakeup) in wait_for_avail()
1967 if (substream->wait_time) { in wait_for_avail()
1968 wait_time = substream->wait_time; in wait_for_avail()
1972 if (runtime->rate) { in wait_for_avail()
1973 long t = runtime->buffer_size * 1100 / runtime->rate; in wait_for_avail()
1982 err = -ERESTARTSYS; in wait_for_avail()
1994 if (avail >= runtime->twake) in wait_for_avail()
2002 switch (runtime->state) { in wait_for_avail()
2004 err = -ESTRPIPE; in wait_for_avail()
2007 err = -EPIPE; in wait_for_avail()
2011 err = -EPIPE; in wait_for_avail()
2018 err = -EBADFD; in wait_for_avail()
2024 pcm_dbg(substream->pcm, in wait_for_avail()
2027 err = -EIO; in wait_for_avail()
2033 remove_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
2046 /* calculate the target DMA-buffer position to be written/read */
2050 return runtime->dma_area + hwoff + in get_dma_ptr()
2051 channel * (runtime->dma_bytes / runtime->channels); in get_dma_ptr()
2054 /* default copy ops for write; used for both interleaved and non- modes */
2059 if (copy_from_iter(get_dma_ptr(substream->runtime, channel, hwoff), in default_write_copy()
2061 return -EFAULT; in default_write_copy()
2073 struct snd_pcm_runtime *runtime = substream->runtime; in fill_silence()
2075 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in fill_silence()
2077 if (substream->ops->fill_silence) in fill_silence()
2078 return substream->ops->fill_silence(substream, channel, in fill_silence()
2081 snd_pcm_format_set_silence(runtime->format, in fill_silence()
2087 /* default copy ops for read; used for both interleaved and non- modes */
2092 if (copy_to_iter(get_dma_ptr(substream->runtime, channel, hwoff), in default_read_copy()
2094 return -EFAULT; in default_read_copy()
2106 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in do_transfer()
2134 struct snd_pcm_runtime *runtime = substream->runtime; in interleaved_copy()
2146 * non-interleaved channel; when buffer is NULL, silencing instead of copying
2155 struct snd_pcm_runtime *runtime = substream->runtime; in noninterleaved_copy()
2156 int channels = runtime->channels; in noninterleaved_copy() local
2161 * in non-interleaved mode, we copy for each channel, thus in noninterleaved_copy()
2162 * each copy is n_samples bytes x channels = whole frames. in noninterleaved_copy()
2167 for (c = 0; c < channels; ++c, ++bufs) { in noninterleaved_copy()
2185 if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in fill_silence_frames()
2186 substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) in fill_silence_frames()
2194 /* sanity-check for read/write methods */
2199 return -ENXIO; in pcm_sanity_check()
2200 runtime = substream->runtime; in pcm_sanity_check()
2201 if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) in pcm_sanity_check()
2202 return -EINVAL; in pcm_sanity_check()
2203 if (runtime->state == SNDRV_PCM_STATE_OPEN) in pcm_sanity_check()
2204 return -EBADFD; in pcm_sanity_check()
2210 switch (runtime->state) { in pcm_accessible_state()
2216 return -EPIPE; in pcm_accessible_state()
2218 return -ESTRPIPE; in pcm_accessible_state()
2220 return -EBADFD; in pcm_accessible_state()
2230 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_lib_apply_appl_ptr()
2231 snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; in pcm_lib_apply_appl_ptr()
2238 if (appl_ptr >= runtime->boundary) in pcm_lib_apply_appl_ptr()
2239 return -EINVAL; in pcm_lib_apply_appl_ptr()
2243 if (substream->runtime->info & SNDRV_PCM_INFO_NO_REWINDS) { in pcm_lib_apply_appl_ptr()
2244 diff = appl_ptr - old_appl_ptr; in pcm_lib_apply_appl_ptr()
2246 if (diff > runtime->buffer_size) in pcm_lib_apply_appl_ptr()
2247 return -EINVAL; in pcm_lib_apply_appl_ptr()
2249 if (runtime->boundary + diff > runtime->buffer_size) in pcm_lib_apply_appl_ptr()
2250 return -EINVAL; in pcm_lib_apply_appl_ptr()
2254 runtime->control->appl_ptr = appl_ptr; in pcm_lib_apply_appl_ptr()
2255 if (substream->ops->ack) { in pcm_lib_apply_appl_ptr()
2256 ret = substream->ops->ack(substream); in pcm_lib_apply_appl_ptr()
2258 runtime->control->appl_ptr = old_appl_ptr; in pcm_lib_apply_appl_ptr()
2259 if (ret == -EPIPE) in pcm_lib_apply_appl_ptr()
2275 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_lib_xfer()
2289 is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in __snd_pcm_lib_xfer()
2291 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && in __snd_pcm_lib_xfer()
2292 runtime->channels > 1) in __snd_pcm_lib_xfer()
2293 return -EINVAL; in __snd_pcm_lib_xfer()
2296 if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in __snd_pcm_lib_xfer()
2297 return -EINVAL; in __snd_pcm_lib_xfer()
2305 return -EINVAL; in __snd_pcm_lib_xfer()
2307 if (substream->ops->copy) in __snd_pcm_lib_xfer()
2308 transfer = substream->ops->copy; in __snd_pcm_lib_xfer()
2317 nonblock = !!(substream->f_flags & O_NONBLOCK); in __snd_pcm_lib_xfer()
2324 runtime->twake = runtime->control->avail_min ? : 1; in __snd_pcm_lib_xfer()
2325 if (runtime->state == SNDRV_PCM_STATE_RUNNING) in __snd_pcm_lib_xfer()
2333 runtime->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2334 size >= runtime->start_threshold) { in __snd_pcm_lib_xfer()
2347 runtime->state == SNDRV_PCM_STATE_DRAINING) { in __snd_pcm_lib_xfer()
2352 err = -EAGAIN; in __snd_pcm_lib_xfer()
2355 runtime->twake = min_t(snd_pcm_uframes_t, size, in __snd_pcm_lib_xfer()
2356 runtime->control->avail_min ? : 1); in __snd_pcm_lib_xfer()
2364 appl_ptr = READ_ONCE(runtime->control->appl_ptr); in __snd_pcm_lib_xfer()
2365 appl_ofs = appl_ptr % runtime->buffer_size; in __snd_pcm_lib_xfer()
2366 cont = runtime->buffer_size - appl_ofs; in __snd_pcm_lib_xfer()
2370 err = -EINVAL; in __snd_pcm_lib_xfer()
2373 if (!atomic_inc_unless_negative(&runtime->buffer_accessing)) { in __snd_pcm_lib_xfer()
2374 err = -EBUSY; in __snd_pcm_lib_xfer()
2385 atomic_dec(&runtime->buffer_accessing); in __snd_pcm_lib_xfer()
2392 if (appl_ptr >= runtime->boundary) in __snd_pcm_lib_xfer()
2393 appl_ptr -= runtime->boundary; in __snd_pcm_lib_xfer()
2399 size -= frames; in __snd_pcm_lib_xfer()
2401 avail -= frames; in __snd_pcm_lib_xfer()
2403 runtime->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2404 snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { in __snd_pcm_lib_xfer()
2411 runtime->twake = 0; in __snd_pcm_lib_xfer()
2423 /* default channel maps for multi-channel playbacks, up to 8 channels */
2425 { .channels = 1,
2427 { .channels = 2,
2429 { .channels = 4,
2432 { .channels = 6,
2436 { .channels = 8,
2445 /* alternative channel maps with CLFE <-> surround swapped for 6/8 channels */
2447 { .channels = 1,
2449 { .channels = 2,
2451 { .channels = 4,
2454 { .channels = 6,
2458 { .channels = 8,
2469 if (ch > info->max_channels) in valid_chmap_channels()
2471 return !info->channel_mask || (info->channel_mask & (1U << ch)); in valid_chmap_channels()
2479 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in pcm_chmap_ctl_info()
2480 uinfo->count = info->max_channels; in pcm_chmap_ctl_info()
2481 uinfo->value.integer.min = 0; in pcm_chmap_ctl_info()
2482 uinfo->value.integer.max = SNDRV_CHMAP_LAST; in pcm_chmap_ctl_info()
2487 * stores the channel position firstly matching with the current channels
2493 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in pcm_chmap_ctl_get()
2497 if (!info->chmap) in pcm_chmap_ctl_get()
2498 return -EINVAL; in pcm_chmap_ctl_get()
2501 return -ENODEV; in pcm_chmap_ctl_get()
2502 memset(ucontrol->value.integer.value, 0, in pcm_chmap_ctl_get()
2503 sizeof(long) * info->max_channels); in pcm_chmap_ctl_get()
2504 if (!substream->runtime) in pcm_chmap_ctl_get()
2505 return 0; /* no channels set */ in pcm_chmap_ctl_get()
2506 for (map = info->chmap; map->channels; map++) { in pcm_chmap_ctl_get()
2508 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()
2509 valid_chmap_channels(info, map->channels)) { in pcm_chmap_ctl_get()
2510 for (i = 0; i < map->channels; i++) in pcm_chmap_ctl_get()
2511 ucontrol->value.integer.value[i] = map->map[i]; in pcm_chmap_ctl_get()
2515 return -EINVAL; in pcm_chmap_ctl_get()
2519 * expands the pre-defined channel maps in a form of TLV
2529 if (!info->chmap) in pcm_chmap_ctl_tlv()
2530 return -EINVAL; in pcm_chmap_ctl_tlv()
2532 return -ENOMEM; in pcm_chmap_ctl_tlv()
2534 return -EFAULT; in pcm_chmap_ctl_tlv()
2535 size -= 8; in pcm_chmap_ctl_tlv()
2537 for (map = info->chmap; map->channels; map++) { in pcm_chmap_ctl_tlv()
2538 int chs_bytes = map->channels * 4; in pcm_chmap_ctl_tlv()
2539 if (!valid_chmap_channels(info, map->channels)) in pcm_chmap_ctl_tlv()
2542 return -ENOMEM; in pcm_chmap_ctl_tlv()
2545 return -EFAULT; in pcm_chmap_ctl_tlv()
2547 size -= 8; in pcm_chmap_ctl_tlv()
2550 return -ENOMEM; in pcm_chmap_ctl_tlv()
2551 size -= chs_bytes; in pcm_chmap_ctl_tlv()
2553 for (c = 0; c < map->channels; c++) { in pcm_chmap_ctl_tlv()
2554 if (put_user(map->map[c], dst)) in pcm_chmap_ctl_tlv()
2555 return -EFAULT; in pcm_chmap_ctl_tlv()
2560 return -EFAULT; in pcm_chmap_ctl_tlv()
2567 info->pcm->streams[info->stream].chmap_kctl = NULL; in pcm_chmap_ctl_private_free()
2572 * snd_pcm_add_chmap_ctls - create channel-mapping control elements
2576 * @max_channels: the max number of channels for the stream
2578 * @info_ret: store struct snd_pcm_chmap instance if non-NULL
2580 * Create channel-mapping control elements assigned to the given PCM stream(s).
2602 if (WARN_ON(pcm->streams[stream].chmap_kctl)) in snd_pcm_add_chmap_ctls()
2603 return -EBUSY; in snd_pcm_add_chmap_ctls()
2606 return -ENOMEM; in snd_pcm_add_chmap_ctls()
2607 info->pcm = pcm; in snd_pcm_add_chmap_ctls()
2608 info->stream = stream; in snd_pcm_add_chmap_ctls()
2609 info->chmap = chmap; in snd_pcm_add_chmap_ctls()
2610 info->max_channels = max_channels; in snd_pcm_add_chmap_ctls()
2615 knew.device = pcm->device; in snd_pcm_add_chmap_ctls()
2616 knew.count = pcm->streams[stream].substream_count; in snd_pcm_add_chmap_ctls()
2618 info->kctl = snd_ctl_new1(&knew, info); in snd_pcm_add_chmap_ctls()
2619 if (!info->kctl) { in snd_pcm_add_chmap_ctls()
2621 return -ENOMEM; in snd_pcm_add_chmap_ctls()
2623 info->kctl->private_free = pcm_chmap_ctl_private_free; in snd_pcm_add_chmap_ctls()
2624 err = snd_ctl_add(pcm->card, info->kctl); in snd_pcm_add_chmap_ctls()
2627 pcm->streams[stream].chmap_kctl = info->kctl; in snd_pcm_add_chmap_ctls()