summaryrefslogtreecommitdiffstats
path: root/Documentation/sound
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-06 13:56:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-06 13:56:51 -0400
commit920f2ecdf6c3b3526f60fbd38c68597953cad3ee (patch)
tree18188922ba38a5c53ee8d17032eb5c46dffc7fa2 /Documentation/sound
parent9ced560b82606b35adb33a27012a148d418a4c1f (diff)
parentfc18282cdcba984ab89c74d7e844c10114ae0795 (diff)
Merge tag 'sound-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai: "This development cycle resulted in a fair amount of changes in both core and driver sides. The most significant change in ALSA core is about PCM. Also the support of of-graph card and the new DAPM widget for DSP are noteworthy changes in ASoC core. And there're lots of small changes splat over the tree, as you can see in diffstat. Below are a few highlights: ALSA core: - Removal of set_fs() hackery from PCM core stuff, and the code reorganization / optimization thereafter - Improved support of PCM ack ops, and a new ABI for improved control/status mmap handling - Lots of constifications in various codes ASoC core: - The support of of-graph card, which may work as a better generic device for a replacement of simple-card - New widget types intended mainly for use with DSPs ASoC drivers: - New drivers for Allwinner V3s SoCs - Ensonic ES8316 codec support - More Intel SKL and KBL works - More device support for Intel SST Atom (mostly for cheap tablets and 2-in-1 devices) - Support for Rockchip PDM controllers - Support for STM32 I2S and S/PDIF controllers - Support for ZTE AUD96P22 codecs HD-audio: - Support of new Realtek codecs (ALC215/ALC285/ALC289), more quirks for HP and Dell machines - A few more fixes for i915 component binding" * tag 'sound-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (418 commits) ALSA: hda - Fix unbalance of i915 module refcount ASoC: Intel: Skylake: Remove driver debugfs exit ASoC: Intel: Skylake: explicitly add the headers sst-dsp.h ALSA: hda/realtek - Remove GPIO_MASK ALSA: hda/realtek - Fix typo of pincfg for Dell quirk ALSA: pcm: add a documentation for tracepoints ALSA: atmel: ac97c: fix error return code in atmel_ac97c_probe() ALSA: x86: fix error return code in hdmi_lpe_audio_probe() ASoC: Intel: Skylake: Add support to read firmware registers ASoC: Intel: Skylake: Add sram address to sst_addr structure ASoC: Intel: Skylake: Debugfs facility to dump module config ASoC: Intel: Skylake: Add debugfs support ASoC: fix semicolon.cocci warnings ASoC: rt5645: Add quirk override by module option ASoC: rsnd: make arrays path and cmd_case static const ASoC: audio-graph-card: add widgets and routing for external amplifier support ASoC: audio-graph-card: update bindings for amplifier support ASoC: rt5665: calibration should be done before jack detection ASoC: rsnd: constify dev_pm_ops structures. ASoC: nau8825: change crosstalk-bypass property to bool type ...
Diffstat (limited to 'Documentation/sound')
-rw-r--r--Documentation/sound/designs/index.rst1
-rw-r--r--Documentation/sound/designs/tracepoints.rst172
-rw-r--r--Documentation/sound/kernel-api/writing-an-alsa-driver.rst111
-rw-r--r--Documentation/sound/soc/dapm.rst18
4 files changed, 267 insertions, 35 deletions
diff --git a/Documentation/sound/designs/index.rst b/Documentation/sound/designs/index.rst
index 04dcdae3e4f2..f0749943ccb2 100644
--- a/Documentation/sound/designs/index.rst
+++ b/Documentation/sound/designs/index.rst
@@ -9,6 +9,7 @@ Designs and Implementations
9 compress-offload 9 compress-offload
10 timestamping 10 timestamping
11 jack-controls 11 jack-controls
12 tracepoints
12 procfile 13 procfile
13 powersave 14 powersave
14 oss-emulation 15 oss-emulation
diff --git a/Documentation/sound/designs/tracepoints.rst b/Documentation/sound/designs/tracepoints.rst
new file mode 100644
index 000000000000..78bc5572f829
--- /dev/null
+++ b/Documentation/sound/designs/tracepoints.rst
@@ -0,0 +1,172 @@
1===================
2Tracepoints in ALSA
3===================
4
52017/07/02
6Takasahi Sakamoto
7
8Tracepoints in ALSA PCM core
9============================
10
11ALSA PCM core registers ``snd_pcm`` subsystem to kernel tracepoint system.
12This subsystem includes two categories of tracepoints; for state of PCM buffer
13and for processing of PCM hardware parameters. These tracepoints are available
14when corresponding kernel configurations are enabled. When ``CONFIG_SND_DEBUG``
15is enabled, the latter tracepoints are available. When additional
16``SND_PCM_XRUN_DEBUG`` is enabled too, the former trace points are enabled.
17
18Tracepoints for state of PCM buffer
19------------------------------------
20
21This category includes four tracepoints; ``hwptr``, ``applptr``, ``xrun`` and
22``hw_ptr_error``.
23
24Tracepoints for processing of PCM hardware parameters
25-----------------------------------------------------
26
27This category includes two tracepoints; ``hw_mask_param`` and
28``hw_interval_param``.
29
30In a design of ALSA PCM core, data transmission is abstracted as PCM substream.
31Applications manage PCM substream to maintain data transmission for PCM frames.
32Before starting the data transmission, applications need to configure PCM
33substream. In this procedure, PCM hardware parameters are decided by
34interaction between applications and ALSA PCM core. Once decided, runtime of
35the PCM substream keeps the parameters.
36
37The parameters are described in :c:type:`struct snd_pcm_hw_params`. This
38structure includes several types of parameters. Applications set preferable
39value to these parameters, then execute ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE
40or SNDRV_PCM_IOCTL_HW_PARAMS. The former is used just for refining available
41set of parameters. The latter is used for an actual decision of the parameters.
42
43The :c:type:`struct snd_pcm_hw_params` structure has below members:
44
45``flags``
46 Configurable. ALSA PCM core and some drivers handle this flag to select
47 convenient parameters or change their behaviour.
48``masks``
49 Configurable. This type of parameter is described in
50 :c:type:`struct snd_mask` and represent mask values. As of PCM protocol
51 v2.0.13, three types are defined.
52
53 - SNDRV_PCM_HW_PARAM_ACCESS
54 - SNDRV_PCM_HW_PARAM_FORMAT
55 - SNDRV_PCM_HW_PARAM_SUBFORMAT
56``intervals``
57 Configurable. This type of parameter is described in
58 :c:type:`struct snd_interval` and represent values with a range. As of
59 PCM protocol v2.0.13, twelve types are defined.
60
61 - SNDRV_PCM_HW_PARAM_SAMPLE_BITS
62 - SNDRV_PCM_HW_PARAM_FRAME_BITS
63 - SNDRV_PCM_HW_PARAM_CHANNELS
64 - SNDRV_PCM_HW_PARAM_RATE
65 - SNDRV_PCM_HW_PARAM_PERIOD_TIME
66 - SNDRV_PCM_HW_PARAM_PERIOD_SIZE
67 - SNDRV_PCM_HW_PARAM_PERIOD_BYTES
68 - SNDRV_PCM_HW_PARAM_PERIODS
69 - SNDRV_PCM_HW_PARAM_BUFFER_TIME
70 - SNDRV_PCM_HW_PARAM_BUFFER_SIZE
71 - SNDRV_PCM_HW_PARAM_BUFFER_BYTES
72 - SNDRV_PCM_HW_PARAM_TICK_TIME
73``rmask``
74 Configurable. This is evaluated at ioctl(2) with
75 SNDRV_PCM_IOCTL_HW_REFINE only. Applications can select which
76 mask/interval parameter can be changed by ALSA PCM core. For
77 SNDRV_PCM_IOCTL_HW_PARAMS, this mask is ignored and all of parameters
78 are going to be changed.
79``cmask``
80 Read-only. After returning from ioctl(2), buffer in user space for
81 :c:type:`struct snd_pcm_hw_params` includes result of each operation.
82 This mask represents which mask/interval parameter is actually changed.
83``info``
84 Read-only. This represents hardware/driver capabilities as bit flags
85 with SNDRV_PCM_INFO_XXX. Typically, applications execute ioctl(2) with
86 SNDRV_PCM_IOCTL_HW_REFINE to retrieve this flag, then decide candidates
87 of parameters and execute ioctl(2) with SNDRV_PCM_IOCTL_HW_PARAMS to
88 configure PCM substream.
89``msbits``
90 Read-only. This value represents available bit width in MSB side of
91 a PCM sample. When a parameter of SNDRV_PCM_HW_PARAM_SAMPLE_BITS was
92 decided as a fixed number, this value is also calculated according to
93 it. Else, zero. But this behaviour depends on implementations in driver
94 side.
95``rate_num``
96 Read-only. This value represents numerator of sampling rate in fraction
97 notation. Basically, when a parameter of SNDRV_PCM_HW_PARAM_RATE was
98 decided as a single value, this value is also calculated according to
99 it. Else, zero. But this behaviour depends on implementations in driver
100 side.
101``rate_den``
102 Read-only. This value represents denominator of sampling rate in
103 fraction notation. Basically, when a parameter of
104 SNDRV_PCM_HW_PARAM_RATE was decided as a single value, this value is
105 also calculated according to it. Else, zero. But this behaviour depends
106 on implementations in driver side.
107``fifo_size``
108 Read-only. This value represents the size of FIFO in serial sound
109 interface of hardware. Basically, each driver can assigns a proper
110 value to this parameter but some drivers intentionally set zero with
111 a care of hardware design or data transmission protocol.
112
113ALSA PCM core handles buffer of :c:type:`struct snd_pcm_hw_params` when
114applications execute ioctl(2) with SNDRV_PCM_HW_REFINE or SNDRV_PCM_HW_PARAMS.
115Parameters in the buffer are changed according to
116:c:type:`struct snd_pcm_hardware` and rules of constraints in the runtime. The
117structure describes capabilities of handled hardware. The rules describes
118dependencies on which a parameter is decided according to several parameters.
119A rule has a callback function, and drivers can register arbitrary functions
120to compute the target parameter. ALSA PCM core registers some rules to the
121runtime as a default.
122
123Each driver can join in the interaction as long as it prepared for two stuffs
124in a callback of :c:type:`struct snd_pcm_ops.open`.
125
1261. In the callback, drivers are expected to change a member of
127 :c:type:`struct snd_pcm_hardware` type in the runtime, according to
128 capacities of corresponding hardware.
1292. In the same callback, drivers are also expected to register additional rules
130 of constraints into the runtime when several parameters have dependencies
131 due to hardware design.
132
133The driver can refers to result of the interaction in a callback of
134:c:type:`struct snd_pcm_ops.hw_params`, however it should not change the
135content.
136
137Tracepoints in this category are designed to trace changes of the
138mask/interval parameters. When ALSA PCM core changes them, ``hw_mask_param`` or
139``hw_interval_param`` event is probed according to type of the changed parameter.
140
141ALSA PCM core also has a pretty print format for each of the tracepoints. Below
142is an example for ``hw_mask_param``.
143
144::
145
146 hw_mask_param: pcmC0D0p 001/023 FORMAT 00000000000000000000001000000044 00000000000000000000001000000044
147
148
149Below is an example for ``hw_interval_param``.
150
151::
152
153 hw_interval_param: pcmC0D0p 000/023 BUFFER_SIZE 0 0 [0 4294967295] 0 1 [0 4294967295]
154
155The first three fields are common. They represent name of ALSA PCM character
156device, rules of constraint and name of the changed parameter, in order. The
157field for rules of constraint consists of two sub-fields; index of applied rule
158and total number of rules added to the runtime. As an exception, the index 000
159means that the parameter is changed by ALSA PCM core, regardless of the rules.
160
161The rest of field represent state of the parameter before/after changing. These
162fields are different according to type of the parameter. For parameters of mask
163type, the fields represent hexadecimal dump of content of the parameter. For
164parameters of interval type, the fields represent values of each member of
165``empty``, ``integer``, ``openmin``, ``min``, ``max``, ``openmax`` in
166:c:type:`struct snd_interval` in this order.
167
168Tracepoints in drivers
169======================
170
171Some drivers have tracepoints for developers' convenience. For them, please
172refer to each documentation or implementation.
diff --git a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
index 95c5443eff38..58ffa3f5bda7 100644
--- a/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
+++ b/Documentation/sound/kernel-api/writing-an-alsa-driver.rst
@@ -2080,8 +2080,8 @@ sleeping poll threads, etc.
2080 2080
2081This callback is also atomic as default. 2081This callback is also atomic as default.
2082 2082
2083copy and silence callbacks 2083copy_user, copy_kernel and fill_silence ops
2084~~~~~~~~~~~~~~~~~~~~~~~~~~ 2084~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2085 2085
2086These callbacks are not mandatory, and can be omitted in most cases. 2086These callbacks are not mandatory, and can be omitted in most cases.
2087These callbacks are used when the hardware buffer cannot be in the 2087These callbacks are used when the hardware buffer cannot be in the
@@ -3532,8 +3532,9 @@ external hardware buffer in interrupts (or in tasklets, preferably).
3532 3532
3533The first case works fine if the external hardware buffer is large 3533The first case works fine if the external hardware buffer is large
3534enough. This method doesn't need any extra buffers and thus is more 3534enough. This method doesn't need any extra buffers and thus is more
3535effective. You need to define the ``copy`` and ``silence`` callbacks 3535effective. You need to define the ``copy_user`` and ``copy_kernel``
3536for the data transfer. However, there is a drawback: it cannot be 3536callbacks for the data transfer, in addition to ``fill_silence``
3537callback for playback. However, there is a drawback: it cannot be
3537mmapped. The examples are GUS's GF1 PCM or emu8000's wavetable PCM. 3538mmapped. The examples are GUS's GF1 PCM or emu8000's wavetable PCM.
3538 3539
3539The second case allows for mmap on the buffer, although you have to 3540The second case allows for mmap on the buffer, although you have to
@@ -3545,30 +3546,34 @@ Another case is when the chip uses a PCI memory-map region for the
3545buffer instead of the host memory. In this case, mmap is available only 3546buffer instead of the host memory. In this case, mmap is available only
3546on certain architectures like the Intel one. In non-mmap mode, the data 3547on certain architectures like the Intel one. In non-mmap mode, the data
3547cannot be transferred as in the normal way. Thus you need to define the 3548cannot be transferred as in the normal way. Thus you need to define the
3548``copy`` and ``silence`` callbacks as well, as in the cases above. The 3549``copy_user``, ``copy_kernel`` and ``fill_silence`` callbacks as well,
3549examples are found in ``rme32.c`` and ``rme96.c``. 3550as in the cases above. The examples are found in ``rme32.c`` and
3551``rme96.c``.
3550 3552
3551The implementation of the ``copy`` and ``silence`` callbacks depends 3553The implementation of the ``copy_user``, ``copy_kernel`` and
3552upon whether the hardware supports interleaved or non-interleaved 3554``silence`` callbacks depends upon whether the hardware supports
3553samples. The ``copy`` callback is defined like below, a bit 3555interleaved or non-interleaved samples. The ``copy_user`` callback is
3554differently depending whether the direction is playback or capture: 3556defined like below, a bit differently depending whether the direction
3557is playback or capture:
3555 3558
3556:: 3559::
3557 3560
3558 static int playback_copy(struct snd_pcm_substream *substream, int channel, 3561 static int playback_copy_user(struct snd_pcm_substream *substream,
3559 snd_pcm_uframes_t pos, void *src, snd_pcm_uframes_t count); 3562 int channel, unsigned long pos,
3560 static int capture_copy(struct snd_pcm_substream *substream, int channel, 3563 void __user *src, unsigned long count);
3561 snd_pcm_uframes_t pos, void *dst, snd_pcm_uframes_t count); 3564 static int capture_copy_user(struct snd_pcm_substream *substream,
3565 int channel, unsigned long pos,
3566 void __user *dst, unsigned long count);
3562 3567
3563In the case of interleaved samples, the second argument (``channel``) is 3568In the case of interleaved samples, the second argument (``channel``) is
3564not used. The third argument (``pos``) points the current position 3569not used. The third argument (``pos``) points the current position
3565offset in frames. 3570offset in bytes.
3566 3571
3567The meaning of the fourth argument is different between playback and 3572The meaning of the fourth argument is different between playback and
3568capture. For playback, it holds the source data pointer, and for 3573capture. For playback, it holds the source data pointer, and for
3569capture, it's the destination data pointer. 3574capture, it's the destination data pointer.
3570 3575
3571The last argument is the number of frames to be copied. 3576The last argument is the number of bytes to be copied.
3572 3577
3573What you have to do in this callback is again different between playback 3578What you have to do in this callback is again different between playback
3574and capture directions. In the playback case, you copy the given amount 3579and capture directions. In the playback case, you copy the given amount
@@ -3578,8 +3583,7 @@ way, the copy would be like:
3578 3583
3579:: 3584::
3580 3585
3581 my_memcpy(my_buffer + frames_to_bytes(runtime, pos), src, 3586 my_memcpy_from_user(my_buffer + pos, src, count);
3582 frames_to_bytes(runtime, count));
3583 3587
3584For the capture direction, you copy the given amount of data (``count``) 3588For the capture direction, you copy the given amount of data (``count``)
3585at the specified offset (``pos``) on the hardware buffer to the 3589at the specified offset (``pos``) on the hardware buffer to the
@@ -3587,31 +3591,68 @@ specified pointer (``dst``).
3587 3591
3588:: 3592::
3589 3593
3590 my_memcpy(dst, my_buffer + frames_to_bytes(runtime, pos), 3594 my_memcpy_to_user(dst, my_buffer + pos, count);
3591 frames_to_bytes(runtime, count)); 3595
3596Here the functions are named as ``from_user`` and ``to_user`` because
3597it's the user-space buffer that is passed to these callbacks. That
3598is, the callback is supposed to copy from/to the user-space data
3599directly to/from the hardware buffer.
3592 3600
3593Note that both the position and the amount of data are given in frames. 3601Careful readers might notice that these callbacks receive the
3602arguments in bytes, not in frames like other callbacks. It's because
3603it would make coding easier like the examples above, and also it makes
3604easier to unify both the interleaved and non-interleaved cases, as
3605explained in the following.
3594 3606
3595In the case of non-interleaved samples, the implementation will be a bit 3607In the case of non-interleaved samples, the implementation will be a bit
3596more complicated. 3608more complicated. The callback is called for each channel, passed by
3609the second argument, so totally it's called for N-channels times per
3610transfer.
3611
3612The meaning of other arguments are almost same as the interleaved
3613case. The callback is supposed to copy the data from/to the given
3614user-space buffer, but only for the given channel. For the detailed
3615implementations, please check ``isa/gus/gus_pcm.c`` or
3616"pci/rme9652/rme9652.c" as examples.
3617
3618The above callbacks are the copy from/to the user-space buffer. There
3619are some cases where we want copy from/to the kernel-space buffer
3620instead. In such a case, ``copy_kernel`` callback is called. It'd
3621look like:
3622
3623::
3624
3625 static int playback_copy_kernel(struct snd_pcm_substream *substream,
3626 int channel, unsigned long pos,
3627 void *src, unsigned long count);
3628 static int capture_copy_kernel(struct snd_pcm_substream *substream,
3629 int channel, unsigned long pos,
3630 void *dst, unsigned long count);
3631
3632As found easily, the only difference is that the buffer pointer is
3633without ``__user`` prefix; that is, a kernel-buffer pointer is passed
3634in the fourth argument. Correspondingly, the implementation would be
3635a version without the user-copy, such as:
3597 3636
3598You need to check the channel argument, and if it's -1, copy the whole 3637::
3599channels. Otherwise, you have to copy only the specified channel. Please 3638
3600check ``isa/gus/gus_pcm.c`` as an example. 3639 my_memcpy(my_buffer + pos, src, count);
3601 3640
3602The ``silence`` callback is also implemented in a similar way 3641Usually for the playback, another callback ``fill_silence`` is
3642defined. It's implemented in a similar way as the copy callbacks
3643above:
3603 3644
3604:: 3645::
3605 3646
3606 static int silence(struct snd_pcm_substream *substream, int channel, 3647 static int silence(struct snd_pcm_substream *substream, int channel,
3607 snd_pcm_uframes_t pos, snd_pcm_uframes_t count); 3648 unsigned long pos, unsigned long count);
3608 3649
3609The meanings of arguments are the same as in the ``copy`` callback, 3650The meanings of arguments are the same as in the ``copy_user`` and
3610although there is no ``src/dst`` argument. In the case of interleaved 3651``copy_kernel`` callbacks, although there is no buffer pointer
3611samples, the channel argument has no meaning, as well as on ``copy`` 3652argument. In the case of interleaved samples, the channel argument has
3612callback. 3653no meaning, as well as on ``copy_*`` callbacks.
3613 3654
3614The role of ``silence`` callback is to set the given amount 3655The role of ``fill_silence`` callback is to set the given amount
3615(``count``) of silence data at the specified offset (``pos``) on the 3656(``count``) of silence data at the specified offset (``pos``) on the
3616hardware buffer. Suppose that the data format is signed (that is, the 3657hardware buffer. Suppose that the data format is signed (that is, the
3617silent-data is 0), and the implementation using a memset-like function 3658silent-data is 0), and the implementation using a memset-like function
@@ -3619,11 +3660,11 @@ would be like:
3619 3660
3620:: 3661::
3621 3662
3622 my_memcpy(my_buffer + frames_to_bytes(runtime, pos), 0, 3663 my_memset(my_buffer + pos, 0, count);
3623 frames_to_bytes(runtime, count));
3624 3664
3625In the case of non-interleaved samples, again, the implementation 3665In the case of non-interleaved samples, again, the implementation
3626becomes a bit more complicated. See, for example, ``isa/gus/gus_pcm.c``. 3666becomes a bit more complicated, as it's called N-times per transfer
3667for each channel. See, for example, ``isa/gus/gus_pcm.c``.
3627 3668
3628Non-Contiguous Buffers 3669Non-Contiguous Buffers
3629---------------------- 3670----------------------
diff --git a/Documentation/sound/soc/dapm.rst b/Documentation/sound/soc/dapm.rst
index a27f42befa4d..8e44107933ab 100644
--- a/Documentation/sound/soc/dapm.rst
+++ b/Documentation/sound/soc/dapm.rst
@@ -105,6 +105,24 @@ Pre
105 Special PRE widget (exec before all others) 105 Special PRE widget (exec before all others)
106Post 106Post
107 Special POST widget (exec after all others) 107 Special POST widget (exec after all others)
108Buffer
109 Inter widget audio data buffer within a DSP.
110Scheduler
111 DSP internal scheduler that schedules component/pipeline processing
112 work.
113Effect
114 Widget that performs an audio processing effect.
115SRC
116 Sample Rate Converter within DSP or CODEC
117ASRC
118 Asynchronous Sample Rate Converter within DSP or CODEC
119Encoder
120 Widget that encodes audio data from one format (usually PCM) to another
121 usually more compressed format.
122Decoder
123 Widget that decodes audio data from a compressed format to an
124 uncompressed format like PCM.
125
108 126
109(Widgets are defined in include/sound/soc-dapm.h) 127(Widgets are defined in include/sound/soc-dapm.h)
110 128