Lines Matching +full:diff +full:- +full:channels
1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Abramo Bagnara <abramo@alsa-project.org>
38 * runtime->silence_start: starting pointer to silence area
39 * runtime->silence_filled: size filled with silence
40 * runtime->silence_threshold: threshold from application
41 * runtime->silence_size: maximal size from application
43 * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately
47 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_playback_silence()
51 if (runtime->silence_size < runtime->boundary) { in snd_pcm_playback_silence()
53 snd_pcm_uframes_t appl_ptr = READ_ONCE(runtime->control->appl_ptr); in snd_pcm_playback_silence()
54 if (runtime->silence_start != appl_ptr) { in snd_pcm_playback_silence()
55 n = appl_ptr - runtime->silence_start; in snd_pcm_playback_silence()
57 n += runtime->boundary; in snd_pcm_playback_silence()
58 if ((snd_pcm_uframes_t)n < runtime->silence_filled) in snd_pcm_playback_silence()
59 runtime->silence_filled -= n; in snd_pcm_playback_silence()
61 runtime->silence_filled = 0; in snd_pcm_playback_silence()
62 runtime->silence_start = appl_ptr; in snd_pcm_playback_silence()
64 if (runtime->silence_filled >= runtime->buffer_size) in snd_pcm_playback_silence()
66 noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; in snd_pcm_playback_silence()
67 if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) in snd_pcm_playback_silence()
69 frames = runtime->silence_threshold - noise_dist; in snd_pcm_playback_silence()
70 if (frames > runtime->silence_size) in snd_pcm_playback_silence()
71 frames = runtime->silence_size; in snd_pcm_playback_silence()
75 if (avail > runtime->buffer_size) in snd_pcm_playback_silence()
76 avail = runtime->buffer_size; in snd_pcm_playback_silence()
77 runtime->silence_filled = avail > 0 ? avail : 0; in snd_pcm_playback_silence()
78 runtime->silence_start = (runtime->status->hw_ptr + in snd_pcm_playback_silence()
79 runtime->silence_filled) % in snd_pcm_playback_silence()
80 runtime->boundary; in snd_pcm_playback_silence()
82 ofs = runtime->status->hw_ptr; in snd_pcm_playback_silence()
83 frames = new_hw_ptr - ofs; in snd_pcm_playback_silence()
85 frames += runtime->boundary; in snd_pcm_playback_silence()
86 runtime->silence_filled -= frames; in snd_pcm_playback_silence()
87 if ((snd_pcm_sframes_t)runtime->silence_filled < 0) { in snd_pcm_playback_silence()
88 runtime->silence_filled = 0; in snd_pcm_playback_silence()
89 runtime->silence_start = new_hw_ptr; in snd_pcm_playback_silence()
91 runtime->silence_start = ofs; in snd_pcm_playback_silence()
94 frames = runtime->buffer_size - runtime->silence_filled; in snd_pcm_playback_silence()
96 if (snd_BUG_ON(frames > runtime->buffer_size)) in snd_pcm_playback_silence()
100 ofs = runtime->silence_start % runtime->buffer_size; in snd_pcm_playback_silence()
102 transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames; in snd_pcm_playback_silence()
105 runtime->silence_filled += transfer; in snd_pcm_playback_silence()
106 frames -= transfer; in snd_pcm_playback_silence()
117 substream->pcm->card->number, in snd_pcm_debug_name()
118 substream->pcm->device, in snd_pcm_debug_name()
119 substream->stream ? 'c' : 'p', in snd_pcm_debug_name()
120 substream->number); in snd_pcm_debug_name()
132 ((substream)->pstr->xrun_debug & (mask))
145 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_xrun()
148 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in __snd_pcm_xrun()
152 runtime->status->tstamp.tv_sec = tstamp.tv_sec; in __snd_pcm_xrun()
153 runtime->status->tstamp.tv_nsec = tstamp.tv_nsec; in __snd_pcm_xrun()
159 pcm_warn(substream->pcm, "XRUN: %s\n", name); in __snd_pcm_xrun()
187 if (avail > runtime->avail_max) in snd_pcm_update_state()
188 runtime->avail_max = avail; in snd_pcm_update_state()
189 if (runtime->state == SNDRV_PCM_STATE_DRAINING) { in snd_pcm_update_state()
190 if (avail >= runtime->buffer_size) { in snd_pcm_update_state()
192 return -EPIPE; in snd_pcm_update_state()
195 if (avail >= runtime->stop_threshold) { in snd_pcm_update_state()
197 return -EPIPE; in snd_pcm_update_state()
200 if (runtime->twake) { in snd_pcm_update_state()
201 if (avail >= runtime->twake) in snd_pcm_update_state()
202 wake_up(&runtime->tsleep); in snd_pcm_update_state()
203 } else if (avail >= runtime->control->avail_min) in snd_pcm_update_state()
204 wake_up(&runtime->sleep); in snd_pcm_update_state()
212 struct snd_pcm_runtime *runtime = substream->runtime; in update_audio_tstamp()
216 if (runtime->tstamp_mode != SNDRV_PCM_TSTAMP_ENABLE) in update_audio_tstamp()
219 if (!(substream->ops->get_time_info) || in update_audio_tstamp()
220 (runtime->audio_tstamp_report.actual_type == in update_audio_tstamp()
228 audio_frames = runtime->hw_ptr_wrap + runtime->status->hw_ptr; in update_audio_tstamp()
230 if (runtime->audio_tstamp_config.report_delay) { in update_audio_tstamp()
231 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) in update_audio_tstamp()
232 audio_frames -= runtime->delay; in update_audio_tstamp()
234 audio_frames += runtime->delay; in update_audio_tstamp()
237 runtime->rate); in update_audio_tstamp()
241 if (runtime->status->audio_tstamp.tv_sec != audio_tstamp->tv_sec || in update_audio_tstamp()
242 runtime->status->audio_tstamp.tv_nsec != audio_tstamp->tv_nsec) { in update_audio_tstamp()
243 runtime->status->audio_tstamp.tv_sec = audio_tstamp->tv_sec; in update_audio_tstamp()
244 runtime->status->audio_tstamp.tv_nsec = audio_tstamp->tv_nsec; in update_audio_tstamp()
245 runtime->status->tstamp.tv_sec = curr_tstamp->tv_sec; in update_audio_tstamp()
246 runtime->status->tstamp.tv_nsec = curr_tstamp->tv_nsec; in update_audio_tstamp()
251 * re-take a driver timestamp to let apps detect if the reference tstamp in update_audio_tstamp()
252 * read by low-level hardware was provided with a delay in update_audio_tstamp()
254 snd_pcm_gettime(substream->runtime, &driver_tstamp); in update_audio_tstamp()
255 runtime->driver_tstamp = driver_tstamp; in update_audio_tstamp()
261 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_update_hw_ptr0()
271 old_hw_ptr = runtime->status->hw_ptr; in snd_pcm_update_hw_ptr0()
279 pos = substream->ops->pointer(substream); in snd_pcm_update_hw_ptr0()
281 if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { in snd_pcm_update_hw_ptr0()
282 if ((substream->ops->get_time_info) && in snd_pcm_update_hw_ptr0()
283 (runtime->audio_tstamp_config.type_requested != SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT)) { in snd_pcm_update_hw_ptr0()
284 substream->ops->get_time_info(substream, &curr_tstamp, in snd_pcm_update_hw_ptr0()
286 &runtime->audio_tstamp_config, in snd_pcm_update_hw_ptr0()
287 &runtime->audio_tstamp_report); in snd_pcm_update_hw_ptr0()
289 /* re-test in case tstamp type is not supported in hardware and was demoted to DEFAULT */ in snd_pcm_update_hw_ptr0()
290 if (runtime->audio_tstamp_report.actual_type == SNDRV_PCM_AUDIO_TSTAMP_TYPE_DEFAULT) in snd_pcm_update_hw_ptr0()
298 return -EPIPE; in snd_pcm_update_hw_ptr0()
300 if (pos >= runtime->buffer_size) { in snd_pcm_update_hw_ptr0()
304 pcm_err(substream->pcm, in snd_pcm_update_hw_ptr0()
306 name, pos, runtime->buffer_size, in snd_pcm_update_hw_ptr0()
307 runtime->period_size); in snd_pcm_update_hw_ptr0()
311 pos -= pos % runtime->min_align; in snd_pcm_update_hw_ptr0()
313 hw_base = runtime->hw_ptr_base; in snd_pcm_update_hw_ptr0()
318 delta = runtime->hw_ptr_interrupt + runtime->period_size; in snd_pcm_update_hw_ptr0()
321 hdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
322 if (hdelta > runtime->hw_ptr_buffer_jiffies/2 + 1) { in snd_pcm_update_hw_ptr0()
323 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
324 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
336 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
337 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
344 delta = new_hw_ptr - old_hw_ptr; in snd_pcm_update_hw_ptr0()
346 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
348 if (runtime->no_period_wakeup) { in snd_pcm_update_hw_ptr0()
354 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
355 if (jdelta < runtime->hw_ptr_buffer_jiffies / 2) in snd_pcm_update_hw_ptr0()
357 hdelta = jdelta - delta * HZ / runtime->rate; in snd_pcm_update_hw_ptr0()
358 xrun_threshold = runtime->hw_ptr_buffer_jiffies / 2 + 1; in snd_pcm_update_hw_ptr0()
360 delta += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
361 hw_base += runtime->buffer_size; in snd_pcm_update_hw_ptr0()
362 if (hw_base >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
367 hdelta -= runtime->hw_ptr_buffer_jiffies; in snd_pcm_update_hw_ptr0()
373 if (delta >= runtime->buffer_size + runtime->period_size) { in snd_pcm_update_hw_ptr0()
376 substream->stream, (long)pos, in snd_pcm_update_hw_ptr0()
389 if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) in snd_pcm_update_hw_ptr0()
392 if (hdelta < runtime->delay) in snd_pcm_update_hw_ptr0()
394 hdelta -= runtime->delay; in snd_pcm_update_hw_ptr0()
395 jdelta = curr_jiffies - runtime->hw_ptr_jiffies; in snd_pcm_update_hw_ptr0()
396 if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { in snd_pcm_update_hw_ptr0()
398 (((runtime->period_size * HZ) / runtime->rate) in snd_pcm_update_hw_ptr0()
406 new_hw_ptr += runtime->period_size; in snd_pcm_update_hw_ptr0()
407 if (new_hw_ptr >= runtime->boundary) { in snd_pcm_update_hw_ptr0()
408 new_hw_ptr -= runtime->boundary; in snd_pcm_update_hw_ptr0()
409 crossed_boundary--; in snd_pcm_update_hw_ptr0()
411 delta--; in snd_pcm_update_hw_ptr0()
417 (long)runtime->period_size, jdelta, in snd_pcm_update_hw_ptr0()
418 ((hdelta * HZ) / runtime->rate), hw_base, in snd_pcm_update_hw_ptr0()
423 hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); in snd_pcm_update_hw_ptr0()
426 if (delta > runtime->period_size + runtime->period_size / 2) { in snd_pcm_update_hw_ptr0()
430 substream->stream, (long)delta, in snd_pcm_update_hw_ptr0()
436 if (runtime->status->hw_ptr == new_hw_ptr) { in snd_pcm_update_hw_ptr0()
437 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
442 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && in snd_pcm_update_hw_ptr0()
443 runtime->silence_size > 0) in snd_pcm_update_hw_ptr0()
447 delta = new_hw_ptr - runtime->hw_ptr_interrupt; in snd_pcm_update_hw_ptr0()
449 delta += runtime->boundary; in snd_pcm_update_hw_ptr0()
450 delta -= (snd_pcm_uframes_t)delta % runtime->period_size; in snd_pcm_update_hw_ptr0()
451 runtime->hw_ptr_interrupt += delta; in snd_pcm_update_hw_ptr0()
452 if (runtime->hw_ptr_interrupt >= runtime->boundary) in snd_pcm_update_hw_ptr0()
453 runtime->hw_ptr_interrupt -= runtime->boundary; in snd_pcm_update_hw_ptr0()
455 runtime->hw_ptr_base = hw_base; in snd_pcm_update_hw_ptr0()
456 runtime->status->hw_ptr = new_hw_ptr; in snd_pcm_update_hw_ptr0()
457 runtime->hw_ptr_jiffies = curr_jiffies; in snd_pcm_update_hw_ptr0()
460 runtime->hw_ptr_wrap += runtime->boundary; in snd_pcm_update_hw_ptr0()
475 * snd_pcm_set_ops - set the PCM operators
485 struct snd_pcm_str *stream = &pcm->streams[direction]; in snd_pcm_set_ops()
488 for (substream = stream->substream; substream != NULL; substream = substream->next) in snd_pcm_set_ops()
489 substream->ops = ops; in snd_pcm_set_ops()
494 * snd_pcm_set_sync - set the PCM sync id
501 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_set_sync()
503 runtime->sync.id32[0] = substream->pcm->card->number; in snd_pcm_set_sync()
504 runtime->sync.id32[1] = -1; in snd_pcm_set_sync()
505 runtime->sync.id32[2] = -1; in snd_pcm_set_sync()
506 runtime->sync.id32[3] = -1; in snd_pcm_set_sync()
570 * snd_interval_refine - refine the interval value of configurator
585 return -EINVAL; in snd_interval_refine()
586 if (i->min < v->min) { in snd_interval_refine()
587 i->min = v->min; in snd_interval_refine()
588 i->openmin = v->openmin; in snd_interval_refine()
590 } else if (i->min == v->min && !i->openmin && v->openmin) { in snd_interval_refine()
591 i->openmin = 1; in snd_interval_refine()
594 if (i->max > v->max) { in snd_interval_refine()
595 i->max = v->max; in snd_interval_refine()
596 i->openmax = v->openmax; in snd_interval_refine()
598 } else if (i->max == v->max && !i->openmax && v->openmax) { in snd_interval_refine()
599 i->openmax = 1; in snd_interval_refine()
602 if (!i->integer && v->integer) { in snd_interval_refine()
603 i->integer = 1; in snd_interval_refine()
606 if (i->integer) { in snd_interval_refine()
607 if (i->openmin) { in snd_interval_refine()
608 i->min++; in snd_interval_refine()
609 i->openmin = 0; in snd_interval_refine()
611 if (i->openmax) { in snd_interval_refine()
612 i->max--; in snd_interval_refine()
613 i->openmax = 0; in snd_interval_refine()
615 } else if (!i->openmin && !i->openmax && i->min == i->max) in snd_interval_refine()
616 i->integer = 1; in snd_interval_refine()
619 return -EINVAL; in snd_interval_refine()
627 const unsigned int last_max = i->max; in snd_interval_refine_first()
630 return -EINVAL; in snd_interval_refine_first()
633 i->max = i->min; in snd_interval_refine_first()
634 if (i->openmin) in snd_interval_refine_first()
635 i->max++; in snd_interval_refine_first()
637 i->openmax = (i->openmax && i->max >= last_max); in snd_interval_refine_first()
643 const unsigned int last_min = i->min; in snd_interval_refine_last()
646 return -EINVAL; in snd_interval_refine_last()
649 i->min = i->max; in snd_interval_refine_last()
650 if (i->openmax) in snd_interval_refine_last()
651 i->min--; in snd_interval_refine_last()
653 i->openmin = (i->openmin && i->min <= last_min); in snd_interval_refine_last()
659 if (a->empty || b->empty) { in snd_interval_mul()
663 c->empty = 0; in snd_interval_mul()
664 c->min = mul(a->min, b->min); in snd_interval_mul()
665 c->openmin = (a->openmin || b->openmin); in snd_interval_mul()
666 c->max = mul(a->max, b->max); in snd_interval_mul()
667 c->openmax = (a->openmax || b->openmax); in snd_interval_mul()
668 c->integer = (a->integer && b->integer); in snd_interval_mul()
672 * snd_interval_div - refine the interval value with division
679 * Returns non-zero if the value is changed, zero if not changed.
684 if (a->empty || b->empty) { in snd_interval_div()
688 c->empty = 0; in snd_interval_div()
689 c->min = div32(a->min, b->max, &r); in snd_interval_div()
690 c->openmin = (r || a->openmin || b->openmax); in snd_interval_div()
691 if (b->min > 0) { in snd_interval_div()
692 c->max = div32(a->max, b->min, &r); in snd_interval_div()
694 c->max++; in snd_interval_div()
695 c->openmax = 1; in snd_interval_div()
697 c->openmax = (a->openmax || b->openmin); in snd_interval_div()
699 c->max = UINT_MAX; in snd_interval_div()
700 c->openmax = 0; in snd_interval_div()
702 c->integer = 0; in snd_interval_div()
706 * snd_interval_muldivk - refine the interval value
714 * Returns non-zero if the value is changed, zero if not changed.
720 if (a->empty || b->empty) { in snd_interval_muldivk()
724 c->empty = 0; in snd_interval_muldivk()
725 c->min = muldiv32(a->min, b->min, k, &r); in snd_interval_muldivk()
726 c->openmin = (r || a->openmin || b->openmin); in snd_interval_muldivk()
727 c->max = muldiv32(a->max, b->max, k, &r); in snd_interval_muldivk()
729 c->max++; in snd_interval_muldivk()
730 c->openmax = 1; in snd_interval_muldivk()
732 c->openmax = (a->openmax || b->openmax); in snd_interval_muldivk()
733 c->integer = 0; in snd_interval_muldivk()
737 * snd_interval_mulkdiv - refine the interval value
745 * Returns non-zero if the value is changed, zero if not changed.
751 if (a->empty || b->empty) { in snd_interval_mulkdiv()
755 c->empty = 0; in snd_interval_mulkdiv()
756 c->min = muldiv32(a->min, k, b->max, &r); in snd_interval_mulkdiv()
757 c->openmin = (r || a->openmin || b->openmax); in snd_interval_mulkdiv()
758 if (b->min > 0) { in snd_interval_mulkdiv()
759 c->max = muldiv32(a->max, k, b->min, &r); in snd_interval_mulkdiv()
761 c->max++; in snd_interval_mulkdiv()
762 c->openmax = 1; in snd_interval_mulkdiv()
764 c->openmax = (a->openmax || b->openmin); in snd_interval_mulkdiv()
766 c->max = UINT_MAX; in snd_interval_mulkdiv()
767 c->openmax = 0; in snd_interval_mulkdiv()
769 c->integer = 0; in snd_interval_mulkdiv()
772 /* ---- */
776 * snd_interval_ratnum - refine the interval value
802 unsigned int q = i->min; in snd_interval_ratnum()
803 int diff; in snd_interval_ratnum() local
813 r = (den - rats[k].den_min) % rats[k].den_step; in snd_interval_ratnum()
815 den -= r; in snd_interval_ratnum()
817 diff = num - q * den; in snd_interval_ratnum()
818 if (diff < 0) in snd_interval_ratnum()
819 diff = -diff; in snd_interval_ratnum()
821 diff * best_den < best_diff * den) { in snd_interval_ratnum()
822 best_diff = diff; in snd_interval_ratnum()
828 i->empty = 1; in snd_interval_ratnum()
829 return -EINVAL; in snd_interval_ratnum()
841 unsigned int q = i->max; in snd_interval_ratnum()
842 int diff; in snd_interval_ratnum() local
844 i->empty = 1; in snd_interval_ratnum()
845 return -EINVAL; in snd_interval_ratnum()
854 r = (den - rats[k].den_min) % rats[k].den_step; in snd_interval_ratnum()
856 den += rats[k].den_step - r; in snd_interval_ratnum()
858 diff = q * den - num; in snd_interval_ratnum()
859 if (diff < 0) in snd_interval_ratnum()
860 diff = -diff; in snd_interval_ratnum()
862 diff * best_den < best_diff * den) { in snd_interval_ratnum()
863 best_diff = diff; in snd_interval_ratnum()
869 i->empty = 1; in snd_interval_ratnum()
870 return -EINVAL; in snd_interval_ratnum()
894 * snd_interval_ratden - refine the interval value
918 unsigned int q = i->min; in snd_interval_ratden()
919 int diff; in snd_interval_ratden() local
927 r = (num - rats[k].num_min) % rats[k].num_step; in snd_interval_ratden()
929 num += rats[k].num_step - r; in snd_interval_ratden()
931 diff = num - q * den; in snd_interval_ratden()
933 diff * best_den < best_diff * den) { in snd_interval_ratden()
934 best_diff = diff; in snd_interval_ratden()
940 i->empty = 1; in snd_interval_ratden()
941 return -EINVAL; in snd_interval_ratden()
950 unsigned int q = i->max; in snd_interval_ratden()
951 int diff; in snd_interval_ratden() local
959 r = (num - rats[k].num_min) % rats[k].num_step; in snd_interval_ratden()
961 num -= r; in snd_interval_ratden()
963 diff = q * den - num; in snd_interval_ratden()
965 diff * best_den < best_diff * den) { in snd_interval_ratden()
966 best_diff = diff; in snd_interval_ratden()
972 i->empty = 1; in snd_interval_ratden()
973 return -EINVAL; in snd_interval_ratden()
992 * snd_interval_list - refine the interval value from the list
996 * @mask: the bit-mask to evaluate
999 * When mask is non-zero, only the elements corresponding to bit 1 are
1012 i->empty = 1; in snd_interval_list()
1013 return -EINVAL; in snd_interval_list()
1031 * snd_interval_ranges - refine the interval value from the list of ranges
1035 * @mask: the bit-mask to evaluate
1038 * When mask is non-zero, only the elements corresponding to bit 1 are
1053 return -EINVAL; in snd_interval_ranges()
1088 n = i->min % step; in snd_interval_step()
1089 if (n != 0 || i->openmin) { in snd_interval_step()
1090 i->min += step - n; in snd_interval_step()
1091 i->openmin = 0; in snd_interval_step()
1094 n = i->max % step; in snd_interval_step()
1095 if (n != 0 || i->openmax) { in snd_interval_step()
1096 i->max -= n; in snd_interval_step()
1097 i->openmax = 0; in snd_interval_step()
1101 i->empty = 1; in snd_interval_step()
1102 return -EINVAL; in snd_interval_step()
1110 * snd_pcm_hw_rule_add - add the hw-constraint rule
1125 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_rule_add()
1130 if (constrs->rules_num >= constrs->rules_all) { in snd_pcm_hw_rule_add()
1132 unsigned int new_rules = constrs->rules_all + 16; in snd_pcm_hw_rule_add()
1133 new = krealloc_array(constrs->rules, new_rules, in snd_pcm_hw_rule_add()
1137 return -ENOMEM; in snd_pcm_hw_rule_add()
1139 constrs->rules = new; in snd_pcm_hw_rule_add()
1140 constrs->rules_all = new_rules; in snd_pcm_hw_rule_add()
1142 c = &constrs->rules[constrs->rules_num]; in snd_pcm_hw_rule_add()
1143 c->cond = cond; in snd_pcm_hw_rule_add()
1144 c->func = func; in snd_pcm_hw_rule_add()
1145 c->var = var; in snd_pcm_hw_rule_add()
1146 c->private = private; in snd_pcm_hw_rule_add()
1149 if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) { in snd_pcm_hw_rule_add()
1151 return -EINVAL; in snd_pcm_hw_rule_add()
1153 c->deps[k++] = dep; in snd_pcm_hw_rule_add()
1158 constrs->rules_num++; in snd_pcm_hw_rule_add()
1165 * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint
1170 * Apply the constraint of the given bitmap mask to a 32-bit mask parameter.
1177 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask()
1179 *maskp->bits &= mask; in snd_pcm_hw_constraint_mask()
1180 memset(maskp->bits + 1, 0, (SNDRV_MASK_MAX-32) / 8); /* clear rest */ in snd_pcm_hw_constraint_mask()
1181 if (*maskp->bits == 0) in snd_pcm_hw_constraint_mask()
1182 return -EINVAL; in snd_pcm_hw_constraint_mask()
1187 * snd_pcm_hw_constraint_mask64 - apply the given bitmap mask constraint
1192 * Apply the constraint of the given bitmap mask to a 64-bit mask parameter.
1199 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_mask64()
1201 maskp->bits[0] &= (u_int32_t)mask; in snd_pcm_hw_constraint_mask64()
1202 maskp->bits[1] &= (u_int32_t)(mask >> 32); in snd_pcm_hw_constraint_mask64()
1203 memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ in snd_pcm_hw_constraint_mask64()
1204 if (! maskp->bits[0] && ! maskp->bits[1]) in snd_pcm_hw_constraint_mask64()
1205 return -EINVAL; in snd_pcm_hw_constraint_mask64()
1211 * snd_pcm_hw_constraint_integer - apply an integer constraint to an interval
1222 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_integer()
1228 * snd_pcm_hw_constraint_minmax - apply a min/max range constraint to an interval
1242 struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; in snd_pcm_hw_constraint_minmax()
1255 struct snd_pcm_hw_constraint_list *list = rule->private; in snd_pcm_hw_rule_list()
1256 …return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask… in snd_pcm_hw_rule_list()
1261 * snd_pcm_hw_constraint_list - apply a list of constraints to a parameter
1278 var, -1); in snd_pcm_hw_constraint_list()
1285 struct snd_pcm_hw_constraint_ranges *r = rule->private; in snd_pcm_hw_rule_ranges()
1286 return snd_interval_ranges(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ranges()
1287 r->count, r->ranges, r->mask); in snd_pcm_hw_rule_ranges()
1292 * snd_pcm_hw_constraint_ranges - apply list of range constraints to a parameter
1309 var, -1); in snd_pcm_hw_constraint_ranges()
1316 const struct snd_pcm_hw_constraint_ratnums *r = rule->private; in snd_pcm_hw_rule_ratnums()
1319 err = snd_interval_ratnum(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ratnums()
1320 r->nrats, r->rats, &num, &den); in snd_pcm_hw_rule_ratnums()
1321 if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { in snd_pcm_hw_rule_ratnums()
1322 params->rate_num = num; in snd_pcm_hw_rule_ratnums()
1323 params->rate_den = den; in snd_pcm_hw_rule_ratnums()
1329 * snd_pcm_hw_constraint_ratnums - apply ratnums constraint to a parameter
1344 var, -1); in snd_pcm_hw_constraint_ratnums()
1351 const struct snd_pcm_hw_constraint_ratdens *r = rule->private; in snd_pcm_hw_rule_ratdens()
1353 int err = snd_interval_ratden(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_ratdens()
1354 r->nrats, r->rats, &num, &den); in snd_pcm_hw_rule_ratdens()
1355 if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { in snd_pcm_hw_rule_ratdens()
1356 params->rate_num = num; in snd_pcm_hw_rule_ratdens()
1357 params->rate_den = den; in snd_pcm_hw_rule_ratdens()
1363 * snd_pcm_hw_constraint_ratdens - apply ratdens constraint to a parameter
1378 var, -1); in snd_pcm_hw_constraint_ratdens()
1385 unsigned int l = (unsigned long) rule->private; in snd_pcm_hw_rule_msbits()
1396 params->msbits = min_not_zero(params->msbits, msbits); in snd_pcm_hw_rule_msbits()
1402 * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule
1421 return snd_pcm_hw_rule_add(runtime, cond, -1, in snd_pcm_hw_constraint_msbits()
1424 SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); in snd_pcm_hw_constraint_msbits()
1431 unsigned long step = (unsigned long) rule->private; in snd_pcm_hw_rule_step()
1432 return snd_interval_step(hw_param_interval(params, rule->var), step); in snd_pcm_hw_rule_step()
1436 * snd_pcm_hw_constraint_step - add a hw constraint step rule
1451 var, -1); in snd_pcm_hw_constraint_step()
1463 return snd_interval_list(hw_param_interval(params, rule->var), in snd_pcm_hw_rule_pow2()
1468 * snd_pcm_hw_constraint_pow2 - add a hw constraint power-of-2 rule
1471 * @var: hw_params variable to apply the power-of-2 constraint
1481 var, -1); in snd_pcm_hw_constraint_pow2()
1488 unsigned int base_rate = (unsigned int)(uintptr_t)rule->private; in snd_pcm_hw_rule_noresample_func()
1496 * snd_pcm_hw_rule_noresample - add a rule to allow disabling hw resampling
1509 SNDRV_PCM_HW_PARAM_RATE, -1); in snd_pcm_hw_rule_noresample()
1518 params->cmask |= 1 << var; in _snd_pcm_hw_param_any()
1519 params->rmask |= 1 << var; in _snd_pcm_hw_param_any()
1524 params->cmask |= 1 << var; in _snd_pcm_hw_param_any()
1525 params->rmask |= 1 << var; in _snd_pcm_hw_param_any()
1539 params->info = ~0U; in _snd_pcm_hw_params_any()
1544 * snd_pcm_hw_param_value - return @params field @var value
1547 * @dir: pointer to the direction (-1,0,1) or %NULL
1550 * defined by @params. -%EINVAL otherwise.
1558 return -EINVAL; in snd_pcm_hw_param_value()
1566 return -EINVAL; in snd_pcm_hw_param_value()
1568 *dir = i->openmin; in snd_pcm_hw_param_value()
1571 return -EINVAL; in snd_pcm_hw_param_value()
1580 params->cmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1581 params->rmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1584 params->cmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1585 params->rmask |= 1 << var; in _snd_pcm_hw_param_setempty()
1601 return -EINVAL; in _snd_pcm_hw_param_first()
1603 params->cmask |= 1 << var; in _snd_pcm_hw_param_first()
1604 params->rmask |= 1 << var; in _snd_pcm_hw_param_first()
1611 * snd_pcm_hw_param_first - refine config space and return minimum value
1615 * @dir: pointer to the direction (-1,0,1) or %NULL
1629 if (params->rmask) { in snd_pcm_hw_param_first()
1647 return -EINVAL; in _snd_pcm_hw_param_last()
1649 params->cmask |= 1 << var; in _snd_pcm_hw_param_last()
1650 params->rmask |= 1 << var; in _snd_pcm_hw_param_last()
1657 * snd_pcm_hw_param_last - refine config space and return maximum value
1661 * @dir: pointer to the direction (-1,0,1) or %NULL
1675 if (params->rmask) { in snd_pcm_hw_param_last()
1687 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_reset()
1692 runtime->status->hw_ptr %= runtime->buffer_size; in snd_pcm_lib_ioctl_reset()
1694 runtime->status->hw_ptr = 0; in snd_pcm_lib_ioctl_reset()
1695 runtime->hw_ptr_wrap = 0; in snd_pcm_lib_ioctl_reset()
1705 struct snd_pcm_runtime *runtime = substream->runtime; in snd_pcm_lib_ioctl_channel_info()
1707 if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { in snd_pcm_lib_ioctl_channel_info()
1708 info->offset = -1; in snd_pcm_lib_ioctl_channel_info()
1711 width = snd_pcm_format_physical_width(runtime->format); in snd_pcm_lib_ioctl_channel_info()
1714 info->offset = 0; in snd_pcm_lib_ioctl_channel_info()
1715 switch (runtime->access) { in snd_pcm_lib_ioctl_channel_info()
1718 info->first = info->channel * width; in snd_pcm_lib_ioctl_channel_info()
1719 info->step = runtime->channels * width; in snd_pcm_lib_ioctl_channel_info()
1724 size_t size = runtime->dma_bytes / runtime->channels; in snd_pcm_lib_ioctl_channel_info()
1725 info->first = info->channel * size * 8; in snd_pcm_lib_ioctl_channel_info()
1726 info->step = width; in snd_pcm_lib_ioctl_channel_info()
1741 int channels; in snd_pcm_lib_ioctl_fifo_size() local
1744 params->fifo_size = substream->runtime->hw.fifo_size; in snd_pcm_lib_ioctl_fifo_size()
1745 if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { in snd_pcm_lib_ioctl_fifo_size()
1747 channels = params_channels(params); in snd_pcm_lib_ioctl_fifo_size()
1748 frame_size = snd_pcm_format_size(format, channels); in snd_pcm_lib_ioctl_fifo_size()
1750 params->fifo_size /= frame_size; in snd_pcm_lib_ioctl_fifo_size()
1756 * snd_pcm_lib_ioctl - a generic PCM ioctl callback
1777 return -ENXIO; in snd_pcm_lib_ioctl()
1782 * snd_pcm_period_elapsed_under_stream_lock() - update the status of runtime for the next period
1802 …* - .pointer - to retrieve current position of audio data transmission by frame count or XRUN stat…
1803 * - .trigger - with SNDRV_PCM_TRIGGER_STOP at XRUN or DRAINING state.
1804 * - .get_time_info - to retrieve audio time stamp if needed.
1814 runtime = substream->runtime; in snd_pcm_period_elapsed_under_stream_lock()
1821 if (substream->timer_running) in snd_pcm_period_elapsed_under_stream_lock()
1822 snd_timer_interrupt(substream->timer, 1); in snd_pcm_period_elapsed_under_stream_lock()
1825 snd_kill_fasync(runtime->fasync, SIGIO, POLL_IN); in snd_pcm_period_elapsed_under_stream_lock()
1830 * snd_pcm_period_elapsed() - update the status of runtime for the next period by acquiring lock of
1863 struct snd_pcm_runtime *runtime = substream->runtime; in wait_for_avail()
1864 int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in wait_for_avail()
1872 add_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1874 if (runtime->no_period_wakeup) in wait_for_avail()
1878 if (substream->wait_time) { in wait_for_avail()
1879 wait_time = substream->wait_time; in wait_for_avail()
1883 if (runtime->rate) { in wait_for_avail()
1884 long t = runtime->period_size * 2 / in wait_for_avail()
1885 runtime->rate; in wait_for_avail()
1894 err = -ERESTARTSYS; in wait_for_avail()
1906 if (avail >= runtime->twake) in wait_for_avail()
1914 switch (runtime->state) { in wait_for_avail()
1916 err = -ESTRPIPE; in wait_for_avail()
1919 err = -EPIPE; in wait_for_avail()
1923 err = -EPIPE; in wait_for_avail()
1930 err = -EBADFD; in wait_for_avail()
1936 pcm_dbg(substream->pcm, in wait_for_avail()
1939 err = -EIO; in wait_for_avail()
1945 remove_wait_queue(&runtime->tsleep, &wait); in wait_for_avail()
1957 /* calculate the target DMA-buffer position to be written/read */
1961 return runtime->dma_area + hwoff + in get_dma_ptr()
1962 channel * (runtime->dma_bytes / runtime->channels); in get_dma_ptr()
1965 /* default copy_user ops for write; used for both interleaved and non- modes */
1970 if (copy_from_user(get_dma_ptr(substream->runtime, channel, hwoff), in default_write_copy()
1972 return -EFAULT; in default_write_copy()
1981 memcpy(get_dma_ptr(substream->runtime, channel, hwoff), buf, bytes); in default_write_copy_kernel()
1992 struct snd_pcm_runtime *runtime = substream->runtime; in fill_silence()
1994 if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK) in fill_silence()
1996 if (substream->ops->fill_silence) in fill_silence()
1997 return substream->ops->fill_silence(substream, channel, in fill_silence()
2000 snd_pcm_format_set_silence(runtime->format, in fill_silence()
2006 /* default copy_user ops for read; used for both interleaved and non- modes */
2012 get_dma_ptr(substream->runtime, channel, hwoff), in default_read_copy()
2014 return -EFAULT; in default_read_copy()
2023 memcpy(buf, get_dma_ptr(substream->runtime, channel, hwoff), bytes); in default_read_copy_kernel()
2036 struct snd_pcm_runtime *runtime = substream->runtime; in interleaved_copy()
2046 * non-interleaved channel; when buffer is NULL, silencing instead of copying
2054 struct snd_pcm_runtime *runtime = substream->runtime; in noninterleaved_copy()
2055 int channels = runtime->channels; in noninterleaved_copy() local
2060 * in non-interleaved mode, we copy for each channel, thus in noninterleaved_copy()
2061 * each copy is n_samples bytes x channels = whole frames. in noninterleaved_copy()
2066 for (c = 0; c < channels; ++c, ++bufs) { in noninterleaved_copy()
2084 if (substream->runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || in fill_silence_frames()
2085 substream->runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) in fill_silence_frames()
2093 /* sanity-check for read/write methods */
2098 return -ENXIO; in pcm_sanity_check()
2099 runtime = substream->runtime; in pcm_sanity_check()
2100 if (snd_BUG_ON(!substream->ops->copy_user && !runtime->dma_area)) in pcm_sanity_check()
2101 return -EINVAL; in pcm_sanity_check()
2102 if (runtime->state == SNDRV_PCM_STATE_OPEN) in pcm_sanity_check()
2103 return -EBADFD; in pcm_sanity_check()
2109 switch (runtime->state) { in pcm_accessible_state()
2115 return -EPIPE; in pcm_accessible_state()
2117 return -ESTRPIPE; in pcm_accessible_state()
2119 return -EBADFD; in pcm_accessible_state()
2129 struct snd_pcm_runtime *runtime = substream->runtime; in pcm_lib_apply_appl_ptr()
2130 snd_pcm_uframes_t old_appl_ptr = runtime->control->appl_ptr; in pcm_lib_apply_appl_ptr()
2131 snd_pcm_sframes_t diff; in pcm_lib_apply_appl_ptr() local
2137 if (appl_ptr >= runtime->boundary) in pcm_lib_apply_appl_ptr()
2138 return -EINVAL; in pcm_lib_apply_appl_ptr()
2142 if (substream->runtime->info & SNDRV_PCM_INFO_NO_REWINDS) { in pcm_lib_apply_appl_ptr()
2143 diff = appl_ptr - old_appl_ptr; in pcm_lib_apply_appl_ptr()
2144 if (diff >= 0) { in pcm_lib_apply_appl_ptr()
2145 if (diff > runtime->buffer_size) in pcm_lib_apply_appl_ptr()
2146 return -EINVAL; in pcm_lib_apply_appl_ptr()
2148 if (runtime->boundary + diff > runtime->buffer_size) in pcm_lib_apply_appl_ptr()
2149 return -EINVAL; in pcm_lib_apply_appl_ptr()
2153 runtime->control->appl_ptr = appl_ptr; in pcm_lib_apply_appl_ptr()
2154 if (substream->ops->ack) { in pcm_lib_apply_appl_ptr()
2155 ret = substream->ops->ack(substream); in pcm_lib_apply_appl_ptr()
2157 runtime->control->appl_ptr = old_appl_ptr; in pcm_lib_apply_appl_ptr()
2172 struct snd_pcm_runtime *runtime = substream->runtime; in __snd_pcm_lib_xfer()
2186 is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; in __snd_pcm_lib_xfer()
2188 if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && in __snd_pcm_lib_xfer()
2189 runtime->channels > 1) in __snd_pcm_lib_xfer()
2190 return -EINVAL; in __snd_pcm_lib_xfer()
2193 if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) in __snd_pcm_lib_xfer()
2194 return -EINVAL; in __snd_pcm_lib_xfer()
2202 return -EINVAL; in __snd_pcm_lib_xfer()
2204 if (substream->ops->copy_kernel) in __snd_pcm_lib_xfer()
2205 transfer = substream->ops->copy_kernel; in __snd_pcm_lib_xfer()
2210 if (substream->ops->copy_user) in __snd_pcm_lib_xfer()
2211 transfer = (pcm_transfer_f)substream->ops->copy_user; in __snd_pcm_lib_xfer()
2220 nonblock = !!(substream->f_flags & O_NONBLOCK); in __snd_pcm_lib_xfer()
2227 runtime->twake = runtime->control->avail_min ? : 1; in __snd_pcm_lib_xfer()
2228 if (runtime->state == SNDRV_PCM_STATE_RUNNING) in __snd_pcm_lib_xfer()
2236 runtime->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2237 size >= runtime->start_threshold) { in __snd_pcm_lib_xfer()
2250 runtime->state == SNDRV_PCM_STATE_DRAINING) { in __snd_pcm_lib_xfer()
2255 err = -EAGAIN; in __snd_pcm_lib_xfer()
2258 runtime->twake = min_t(snd_pcm_uframes_t, size, in __snd_pcm_lib_xfer()
2259 runtime->control->avail_min ? : 1); in __snd_pcm_lib_xfer()
2267 appl_ptr = READ_ONCE(runtime->control->appl_ptr); in __snd_pcm_lib_xfer()
2268 appl_ofs = appl_ptr % runtime->buffer_size; in __snd_pcm_lib_xfer()
2269 cont = runtime->buffer_size - appl_ofs; in __snd_pcm_lib_xfer()
2273 err = -EINVAL; in __snd_pcm_lib_xfer()
2276 if (!atomic_inc_unless_negative(&runtime->buffer_accessing)) { in __snd_pcm_lib_xfer()
2277 err = -EBUSY; in __snd_pcm_lib_xfer()
2288 atomic_dec(&runtime->buffer_accessing); in __snd_pcm_lib_xfer()
2295 if (appl_ptr >= runtime->boundary) in __snd_pcm_lib_xfer()
2296 appl_ptr -= runtime->boundary; in __snd_pcm_lib_xfer()
2302 size -= frames; in __snd_pcm_lib_xfer()
2304 avail -= frames; in __snd_pcm_lib_xfer()
2306 runtime->state == SNDRV_PCM_STATE_PREPARED && in __snd_pcm_lib_xfer()
2307 snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { in __snd_pcm_lib_xfer()
2314 runtime->twake = 0; in __snd_pcm_lib_xfer()
2326 /* default channel maps for multi-channel playbacks, up to 8 channels */
2328 { .channels = 1,
2330 { .channels = 2,
2332 { .channels = 4,
2335 { .channels = 6,
2339 { .channels = 8,
2348 /* alternative channel maps with CLFE <-> surround swapped for 6/8 channels */
2350 { .channels = 1,
2352 { .channels = 2,
2354 { .channels = 4,
2357 { .channels = 6,
2361 { .channels = 8,
2372 if (ch > info->max_channels) in valid_chmap_channels()
2374 return !info->channel_mask || (info->channel_mask & (1U << ch)); in valid_chmap_channels()
2382 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in pcm_chmap_ctl_info()
2383 uinfo->count = info->max_channels; in pcm_chmap_ctl_info()
2384 uinfo->value.integer.min = 0; in pcm_chmap_ctl_info()
2385 uinfo->value.integer.max = SNDRV_CHMAP_LAST; in pcm_chmap_ctl_info()
2390 * stores the channel position firstly matching with the current channels
2396 unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id); in pcm_chmap_ctl_get()
2400 if (!info->chmap) in pcm_chmap_ctl_get()
2401 return -EINVAL; in pcm_chmap_ctl_get()
2404 return -ENODEV; in pcm_chmap_ctl_get()
2405 memset(ucontrol->value.integer.value, 0, in pcm_chmap_ctl_get()
2406 sizeof(long) * info->max_channels); in pcm_chmap_ctl_get()
2407 if (!substream->runtime) in pcm_chmap_ctl_get()
2408 return 0; /* no channels set */ in pcm_chmap_ctl_get()
2409 for (map = info->chmap; map->channels; map++) { in pcm_chmap_ctl_get()
2411 if (map->channels == substream->runtime->channels && in pcm_chmap_ctl_get()
2412 valid_chmap_channels(info, map->channels)) { in pcm_chmap_ctl_get()
2413 for (i = 0; i < map->channels; i++) in pcm_chmap_ctl_get()
2414 ucontrol->value.integer.value[i] = map->map[i]; in pcm_chmap_ctl_get()
2418 return -EINVAL; in pcm_chmap_ctl_get()
2422 * expands the pre-defined channel maps in a form of TLV
2432 if (!info->chmap) in pcm_chmap_ctl_tlv()
2433 return -EINVAL; in pcm_chmap_ctl_tlv()
2435 return -ENOMEM; in pcm_chmap_ctl_tlv()
2437 return -EFAULT; in pcm_chmap_ctl_tlv()
2438 size -= 8; in pcm_chmap_ctl_tlv()
2440 for (map = info->chmap; map->channels; map++) { in pcm_chmap_ctl_tlv()
2441 int chs_bytes = map->channels * 4; in pcm_chmap_ctl_tlv()
2442 if (!valid_chmap_channels(info, map->channels)) in pcm_chmap_ctl_tlv()
2445 return -ENOMEM; in pcm_chmap_ctl_tlv()
2448 return -EFAULT; in pcm_chmap_ctl_tlv()
2450 size -= 8; in pcm_chmap_ctl_tlv()
2453 return -ENOMEM; in pcm_chmap_ctl_tlv()
2454 size -= chs_bytes; in pcm_chmap_ctl_tlv()
2456 for (c = 0; c < map->channels; c++) { in pcm_chmap_ctl_tlv()
2457 if (put_user(map->map[c], dst)) in pcm_chmap_ctl_tlv()
2458 return -EFAULT; in pcm_chmap_ctl_tlv()
2463 return -EFAULT; in pcm_chmap_ctl_tlv()
2470 info->pcm->streams[info->stream].chmap_kctl = NULL; in pcm_chmap_ctl_private_free()
2475 * snd_pcm_add_chmap_ctls - create channel-mapping control elements
2479 * @max_channels: the max number of channels for the stream
2481 * @info_ret: store struct snd_pcm_chmap instance if non-NULL
2483 * Create channel-mapping control elements assigned to the given PCM stream(s).
2504 if (WARN_ON(pcm->streams[stream].chmap_kctl)) in snd_pcm_add_chmap_ctls()
2505 return -EBUSY; in snd_pcm_add_chmap_ctls()
2508 return -ENOMEM; in snd_pcm_add_chmap_ctls()
2509 info->pcm = pcm; in snd_pcm_add_chmap_ctls()
2510 info->stream = stream; in snd_pcm_add_chmap_ctls()
2511 info->chmap = chmap; in snd_pcm_add_chmap_ctls()
2512 info->max_channels = max_channels; in snd_pcm_add_chmap_ctls()
2517 knew.device = pcm->device; in snd_pcm_add_chmap_ctls()
2518 knew.count = pcm->streams[stream].substream_count; in snd_pcm_add_chmap_ctls()
2520 info->kctl = snd_ctl_new1(&knew, info); in snd_pcm_add_chmap_ctls()
2521 if (!info->kctl) { in snd_pcm_add_chmap_ctls()
2523 return -ENOMEM; in snd_pcm_add_chmap_ctls()
2525 info->kctl->private_free = pcm_chmap_ctl_private_free; in snd_pcm_add_chmap_ctls()
2526 err = snd_ctl_add(pcm->card, info->kctl); in snd_pcm_add_chmap_ctls()
2529 pcm->streams[stream].chmap_kctl = info->kctl; in snd_pcm_add_chmap_ctls()