OSDN Git Service

android-x86/external-alsa-lib.git
6 years agopcm: Return the consistent error code for unexpected PCM states
Takashi Iwai [Wed, 17 Jan 2018 14:57:20 +0000 (15:57 +0100)]
pcm: Return the consistent error code for unexpected PCM states

Some PCM functions have the sanity check of the expected PCM states,
and most of them return -EBADFD if the current state doesn't match.
This is bad for some programs like aplay that expect the function
returning a proper code corresponding to the state, e.g. -ESTRPIPE for
the suspend.

This patch is an attempt to address such inconsistencies.  The sanity
checker bad_pcm_state() now returns the error code instead of bool, so
that the caller can pass the returned code as is.  And it calls a new
helper, pcm_state_to_error(), for obtaining the error code to certain
known PCM error state.

While we're at it, use the new pcm_state_to_error() for simplifying
the existing code to retrieve the error code, too.

Tested-by: Mirza Krak <mirza.krak@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: Add chtrt5645-mono-speaker-analog-mic configuration
Hans de Goede [Sat, 6 Jan 2018 22:03:20 +0000 (23:03 +0100)]
conf/ucm: Add chtrt5645-mono-speaker-analog-mic configuration

Add a configuration for Cherry Trail boards which use a rt5645 codec
connected to a mono speaker and with an analog mic on IN2N + IN2P.

The chtrt5645-mono-speaker-analog-mic/HiFi.conf for this is based on the
latest version from https://github.com/plbossart/UCM/tree/master/chtrt5645
with all the unused input options removed and some changes made to make
the analog mic work.

This commit also adds 2 ucm dirs with the longname of 2 boards known to use
this setup, which simply contain a symlink to the generic
chtrt5645-mono-speaker-analog-mic entry.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agocore: Proper reference of internal snd_dlopen()
Takashi Iwai [Thu, 4 Jan 2018 14:26:33 +0000 (15:26 +0100)]
core: Proper reference of internal snd_dlopen()

snd_dlopen() was recently rewritten to be versioned symbols, and we
have to call it with INTERNAL() wrapper from the library itself.

Add the proper declaration in the local header and fix the callers
appropriately.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotimer: Proper reference of internal versioned symbols
Takashi Iwai [Thu, 4 Jan 2018 14:24:14 +0000 (15:24 +0100)]
timer: Proper reference of internal versioned symbols

The multiply defined versioned symbols have to be called with
INTERNAL() wrapper.

Add the missing declarations of versioned timer API functions in the
local header, and use them in the callers in PCM.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agocontrol: Proper reference of internal versioned functions
Takashi Iwai [Thu, 4 Jan 2018 14:20:58 +0000 (15:20 +0100)]
control: Proper reference of internal versioned functions

The multiply defined versioned symbols have to be called with
INTERNAL() wrapper.

Add the missing declarations of the internal forms of
snd_ctl_elem_info_get_dimension*() in the local header, and use them
in the (still remaining) callers in alisp.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: Fix to skip writing of header for compound elements
GuruprasadX Pawse [Tue, 2 Jan 2018 05:20:01 +0000 (10:50 +0530)]
topology: Fix to skip writing of header for compound elements

While calculating the size of data to be written into the topology
binary file, the size of the compound elements is added as well. This
results in wrong file offset calculation and topology build failure.

The compound elements shouldn't be written to the topology as these are
already embedded as part of other elements. So, skip adding the size of
compound elements to the file offset size calculation.

Signed-off-by: GuruprasadX Pawse <guruprasadx.pawse@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: fix wrong comments for some cases of linear interpolation of PCM samples
Takashi Sakamoto [Wed, 20 Dec 2017 17:17:03 +0000 (02:17 +0900)]
pcm: fix wrong comments for some cases of linear interpolation of PCM samples

A commit 16b3bf447c28 ('Enhanced bitmasks in PCM - added support for more
formats by Takashi and me') adds support for some cases of linear
interpolation of PCM samples, however some of added comments are not
proper. This commit fixes them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: remove unused macros of NORMS_LABELS/NORMS_END
Takashi Sakamoto [Wed, 20 Dec 2017 17:17:02 +0000 (02:17 +0900)]
pcm: remove unused macros of NORMS_LABELS/NORMS_END

A commit fcd164e6229c ("Permit to PCM plug configuration to specify unchanged
parameters. Added support for RT signals to async interface. Added ops for
PCM mix.") added a pair of NORMS_LABELS/NORMS_END, however they have been
no longer used.

This commit removes them in a point to reduce the amount of code to
maintain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: remove unused macros of GETU_LABELS/GETU_END
Takashi Sakamoto [Wed, 20 Dec 2017 17:17:01 +0000 (02:17 +0900)]
pcm: remove unused macros of GETU_LABELS/GETU_END

A commit 07c07da44f27 ("Fixed signess for route conversion") obsoletes
usage of a pair of GETU_LABEL/GETU_END, but it did not remove some
actual codes in 'src/pcm_plugin_ops.h'.

This commit removes them in a point to reduce the amount of code to
maintain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: remove unused macros of COPY_LABELS/COPY_END
Takashi Sakamoto [Wed, 20 Dec 2017 17:17:00 +0000 (02:17 +0900)]
pcm: remove unused macros of COPY_LABELS/COPY_END

A commit 7b054f4dce56 obsoleted usage of a pair of COPY_LABELS/COPY_END,
however it did not remove some codes in 'src/pcm/plugin_ops.h'.

This commit removes them in a point to reduce the amount of code to
maintain.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: plug: add SND_PCM_FORMAT_{S, U}20 to linear_preferred_formats
Maciej S. Szmigiero [Thu, 14 Dec 2017 13:54:29 +0000 (14:54 +0100)]
pcm: plug: add SND_PCM_FORMAT_{S, U}20 to linear_preferred_formats

This commit adds the recently added formats SND_PCM_FORMAT_{S,U}20 to
the linear_preferred_formats array in pcm_plug.
Let's give them lower priority than more standard S24 formats but a higher
priority than less typical 3-byte versions.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: linear, route: handle linear formats with 20-bit sample on 4 bytes
Maciej S. Szmigiero [Thu, 14 Dec 2017 13:53:41 +0000 (14:53 +0100)]
pcm: linear, route: handle linear formats with 20-bit sample on 4 bytes

The previous patch has added 20-bit PCM formats SND_PCM_FORMAT_{S,U}20 to
alsa-lib.
We need to extend the linear format conversion code with handling of these
sample formats so they can also be utilized by applications that only
recognize the more typical ones like SND_PCM_FORMAT_S16.

Since the conversion arrays are indexed by a format bit width divided by 8
the easiest way to handle these formats is to treat them like they were
40-bit wide (the next free integer multiple of 8 bits).
This doesn't create a collision risk with a future format since there can't
really be a 40-bit sample format that occupies 4 bytes.

Make sure we use the getput conversion method for these formats since a
direct conversion from / to them is not supported.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: add and describe SND_PCM_FORMAT_{S, U}20
Maciej S. Szmigiero [Thu, 14 Dec 2017 13:52:07 +0000 (14:52 +0100)]
pcm: add and describe SND_PCM_FORMAT_{S, U}20

This patch adds and describes in various functions that query format
properties SND_PCM_FORMAT_{S,U}20 formats that were recently added to the
kernel as SNDRV_PCM_FORMAT_{S,U}20.

These formats are similar to existing 20-bit PCM formats
SND_PCM_FORMAT_{S,U}20_3, however they occupy 4 bytes instead of 3.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoasound.h: add SNDRV_PCM_FORMAT_{S, U}20
Maciej S. Szmigiero [Thu, 14 Dec 2017 13:51:35 +0000 (14:51 +0100)]
asound.h: add SNDRV_PCM_FORMAT_{S, U}20

This patch adds definitions of 20-bit, 4-byte PCM formats
SNDRV_PCM_FORMAT_{S,U}20, that were recently added to the kernel, to
alsa-lib's own copy of asound.h.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: Add Gigabyte mobo UCM profile with dual HD-audio codecs
Takashi Iwai [Tue, 5 Dec 2017 14:08:01 +0000 (15:08 +0100)]
conf/ucm: Add Gigabyte mobo UCM profile with dual HD-audio codecs

Like the previous Lenovo laptops, some Gigabyte mobos have dual
HD-audio codecs and need to switch dynamically via UCM profile.
Reuse the same profile as Lenovo dual codecs, so far.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: Add dual HD-audio codecs config for Lenovo
Takashi Iwai [Tue, 5 Dec 2017 13:53:11 +0000 (14:53 +0100)]
conf/ucm: Add dual HD-audio codecs config for Lenovo

Some recent Lenovo laptops have dual codecs and we need to switch them
accordingly.  The kernel side already contains a fix and gives the
unique longname string for identifying the board, and here we hook up
the corresponding UCM profile.

The profile was corrected and tested by Hui Wang on Lenovo p520.

Tested-by: Kailang <kailang@realtek.com>
Tested-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: Rearrange Makefile.am
Takashi Iwai [Tue, 5 Dec 2017 13:58:30 +0000 (14:58 +0100)]
conf/ucm: Rearrange Makefile.am

Just rearrange and split to multiple lines to make future patches
cleaner.  No actual code change.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconfigure.ac: do not enable alisp code by default
Jaroslav Kysela [Mon, 27 Nov 2017 20:43:22 +0000 (21:43 +0100)]
configure.ac: do not enable alisp code by default

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoconfigure.ac: build extra mixer modules conditionally
Jaroslav Kysela [Mon, 27 Nov 2017 20:38:18 +0000 (21:38 +0100)]
configure.ac: build extra mixer modules conditionally

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoChange snd_dlopen() function to return the error string
Jaroslav Kysela [Wed, 22 Nov 2017 12:23:45 +0000 (13:23 +0100)]
Change snd_dlopen() function to return the error string

The dlopen() function might fail also for another reason than
a missing file, thus return the error string from dlerror().

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agotest: correct emulation for channel-map TLV
Takashi Sakamoto [Fri, 24 Nov 2017 12:10:51 +0000 (21:10 +0900)]
test: correct emulation for channel-map TLV

Current implementation of channel-map TLV on test program is not valid.
Furthermore, it brings buffer-over-run due to byte counting.

This commit fixes it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: route: Fix use_getput flag computation for 3 byte formats
Maciej S. Szmigiero [Mon, 20 Nov 2017 12:12:32 +0000 (13:12 +0100)]
pcm: route: Fix use_getput flag computation for 3 byte formats

Commit de63b942acf520 ("pcm: route: Use get/put labels for all 3 byte formats")
wanted to make the route plugin use get / put labels not only for 24-bit
physical width formats but also for 18 and 20-bit ones.
There was, however, a typo in that commit so a check for these widths
didn't really work.

Let's fix it now.

Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoChange FSF address (Franklin Street)
Jaroslav Kysela [Tue, 14 Nov 2017 13:29:26 +0000 (14:29 +0100)]
Change FSF address (Franklin Street)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agoRelease v1.1.5
Jaroslav Kysela [Tue, 14 Nov 2017 07:52:09 +0000 (08:52 +0100)]
Release v1.1.5

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
6 years agotest: obsolete usage of APIs of dimensional information
Takashi Sakamoto [Mon, 13 Nov 2017 00:14:11 +0000 (09:14 +0900)]
test: obsolete usage of APIs of dimensional information

APIs of dimensional information are deprecated for future removal. This
commit removes test codes for user-defined element set in an aspect of
the feature.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoctl: deprecate APIs of dimensional information
Takashi Sakamoto [Mon, 13 Nov 2017 00:14:10 +0000 (09:14 +0900)]
ctl: deprecate APIs of dimensional information

In ALSA control interface in asound.h, 'struct snd_ctl_elem_info' has
'dimen' member to deliver information for multi-dimensional array, however
there's no common way to handle the member. As a result, drivers can
force userspace applications to handle the information by inconsistent
ways.

This issue was reported by a commit 51db452df07b ('Revert "ALSA: echoaudio:
purge contradictions between dimension matrix members and total number of
members"') to Linux kernel. As a result of discussion at Linux
miniconference 2017, usage of 'dimen' member of 'struct snd_ctl_elem_info'
is going to be deprecated for future removal.

A removal of kernel interface can cause regression issues. However no ALSA
driver in kernel land except for 'echoaudio' series utilizes this feature.
Actually it's reasonable to assume that 'echomixer' program is an unique
consumer of the interface in user land and the removal rarely brings any
impact to user land.

This commit deprecates some APIs corresponding to the kernel interface. The
kernel interface is kept till Linux kernel v4.20 at least, but actual
timing of removal is not fixed yet. After that, these APIs may also be
removed at a reasonable timing.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: rt5651: Mute speakers on boot
Carlo Caione [Wed, 8 Nov 2017 12:33:30 +0000 (12:33 +0000)]
conf/ucm: rt5651: Mute speakers on boot

The UCM configuration is enabling the speakers in the SectionDefaults.
This is a problem when booting with an headset already connected since
the audio output is routed at the same time both on speakers and
heaphones until the jack is disconnected and reconnected again.

Fix this disabling all the outputs in the default mixer configuration.

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: rt5651: Add missing cdev
Carlo Caione [Wed, 8 Nov 2017 12:33:29 +0000 (12:33 +0000)]
conf/ucm: rt5651: Add missing cdev

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoalsa-lib: topology: fix DSP_B mode string
Liam Girdwood [Wed, 1 Nov 2017 12:26:24 +0000 (12:26 +0000)]
alsa-lib: topology: fix DSP_B mode string

Use the correct string for DSP_B mode.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: rt5651: Fix HiFi file name
Carlo Caione [Thu, 26 Oct 2017 15:05:01 +0000 (16:05 +0100)]
conf/ucm: rt5651: Fix HiFi file name

The conf HiFi file name is HiFi.conf, fix the name in the main
configuration file.

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf/ucm: rt5651: Add UCM config for bytcr-rt5651
Carlo Caione [Tue, 24 Oct 2017 11:27:12 +0000 (12:27 +0100)]
conf/ucm: rt5651: Add UCM config for bytcr-rt5651

Add a UCM configuration for the rt5651 codec on Intel's Cherry-Trail
platform. Adapted from [0].

[0] https://github.com/plbossart/UCM/tree/master/bytcr-rt5651

Signed-off-by: Carlo Caione <carlo@endlessm.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: fix coverity issues
Jaroslav Kysela [Sun, 22 Oct 2017 13:02:19 +0000 (15:02 +0200)]
topology: fix coverity issues

6 years agoconf: HdmiLpeAudio: remove the "front" pcm definition
Tanu Kaskinen [Wed, 4 Oct 2017 19:44:00 +0000 (22:44 +0300)]
conf: HdmiLpeAudio: remove the "front" pcm definition

PulseAudio assumes that the "front" pcm device always refers to an
analog device, not HDMI. While that assumption is not really valid, the
reality is that without that assumption PulseAudio can't know whether
"front" and "hdmi" refer to a different or the same device.

The HDMI LPE driver doesn't allow audio streaming while the HDMI cable
is unplugged, so PulseAudio has to know when it's plugged in and when
it's not. If both "front" and "hdmi" devices exist, PulseAudio will
notice that HDMI is unplugged, but it doesn't know that "front" refers
to the same device, and PulseAudio will try to use the "front" device
with bad consequences. The kernel driver's refusal to stream any audio
makes PulseAudio enter an infinite loop and then the kernel kills
PulseAudio, because it consumes too much CPU time in a realtime thread.

While the looping in PulseAudio could probably be fixed, that wouldn't
change the fact that PulseAudio thinks that there is an analog device. I
believe it's best to avoid having the same device as both "front" and
"hdmi" in alsa-lib.

I removed also the surround configuration includes. I don't think they
had any effect anyway, so I wonder why they were there in the first
place.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoctl: ext: Fail with error code if snd_ctl_ext_callback::read_event() callback is...
Timo Wischer [Thu, 5 Oct 2017 14:25:23 +0000 (16:25 +0200)]
ctl: ext: Fail with error code if snd_ctl_ext_callback::read_event() callback is not defined

The snd_ctl_ext_callback::read_event() callback is only optional
if no poll descriptor was given via
snd_ctl_ext_t::poll_fd
or
snd_ctl_ext_callback::snd_ctl_ext_poll_descriptors().

If a poll descriptor is given the
snd_ctl_ext_callback::read_event()
callback has also to be defined
because there is no minigful default behavior.

This callback will be called when ever the poll() on
the file descriptor indicates that there is an event pending.
Therefore returning a 0 which indicates that there is no event makes no
sense.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotest/seq-decoder: enable timestamping for external subscribers
Antonio Ospite [Tue, 26 Sep 2017 14:44:49 +0000 (16:44 +0200)]
test/seq-decoder: enable timestamping for external subscribers

Events sent by external clients subscribed to the input port are not
timestamped.

This inconsistent behavior may surprise newbies who look at seq-decoder as
a reference example.

See the example below using "vkeybd --addr 128:0" to connect to seq-decoder,
the events sent by vkeybd are on a different queue with no timestamps:

  ...
  EVENT>>> Type = 66, flags = 0x0, time = 0 ticks
           Source = 0.1, dest = 128.0, queue = 253
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.829712627
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Program Change; ch=0, program=0
  ...

After the change events are on the main queue and are timestamped:

  ...
  EVENT>>> Type = 66, flags = 0x1, time = 4.280907223
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.280912063
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x1, time = 4.280990702
           Source = 129.0, dest = 128.0, queue = 0
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x1, time = 4.280994862
           Source = 129.0, dest = 128.0, queue = 0
           Event = Program Change; ch=0, program=0
  ...

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoseq: fix snd_seq_set_queue_tempo() usage example in the documentation
Antonio Ospite [Thu, 28 Sep 2017 13:46:15 +0000 (15:46 +0200)]
seq: fix snd_seq_set_queue_tempo() usage example in the documentation

snd_seq_set_queue_tempo() requires a queue id as the second argument,
fix the example in documentation to reflect that.

Also add the queue id as an argument of the set_tempo() function, just
to keep the whole example compilable.

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agopcm: softvol: add support for S24_LE
Jörg Krause [Wed, 13 Sep 2017 14:21:10 +0000 (16:21 +0200)]
pcm: softvol: add support for S24_LE

Tested with the Wolfson WM8524 DAC on a i.MX6UL board and the following
ALSA configuration file using the pcm test utility from alsa-lib:

"""
$ cat /etc/asound.conf
pcm.!default {
    type plug
    slave.pcm "softvol"
}
pcm.softvol {
    type softvol
    slave {
        pcm "hw:0"
    }
    control {
        name "Master"
        card 0
    }
}
ctl.!default {
    type hw
    card 0
}
ctl.softvol {
    type hw
    card 0
}

$ pcm -D softvol -o S24_LE -c 2 -r 48000
"""

The data in the Synchronous Audio Interface (SAI) of the i.MX6UL is
aligned the following way:

"""
31 30 29 28 | 27 26 25 24 | 23 22 21 20 | .. | 3 2 1 0
## ## ## ##   ## ## ## ## [           DATA[23:0]       ]
"""

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: fix usage of SND_TPLG_INDEX_ALL when checking routes
Liam Girdwood [Tue, 12 Sep 2017 20:47:42 +0000 (21:47 +0100)]
topology: fix usage of SND_TPLG_INDEX_ALL when checking routes

Make sure SND_TPLG_INDEX_ALL is used correctly when checking routes so
that connecting routes of different indexes does not emit any warnings.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotest: apply optimization for v4.14 kernel about changes for TLV data handling on...
Takashi Sakamoto [Thu, 24 Aug 2017 01:48:35 +0000 (10:48 +0900)]
test: apply optimization for v4.14 kernel about changes for TLV data handling on user-defined element set

At kernel v4.14, in initial state, elements on user-defined sets have
write-only flag. When applications write TLV data, then the elements
get readable flag and the TLV data is available. Originally TLV data
is shared by elements in the same set, thus events are generated for
all of elements in the set by the write operation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agotopology: Fix private data for BEs
Liam Girdwood [Tue, 22 Aug 2017 09:16:05 +0000 (10:16 +0100)]
topology: Fix private data for BEs

Private data was not being added to BEs. Fix this.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoconf: HdmiLpeAudio: add support for 3 devices
Pierre-Louis Bossart [Wed, 16 Aug 2017 16:08:48 +0000 (11:08 -0500)]
conf: HdmiLpeAudio: add support for 3 devices

The LPE Audio mode on BYT/CHT supports up to 3 devices, and also supports
IEC61937 passthrough. Add missing alsa-lib configurations so that
apps can use the usual -D'hdmi:CARD=X,DEV=Y,AES0=0x[4|6]' syntax, e.g.

aplay -D'hdmi:CARD=0,DEV=2,AES0=0x6' -c2 -r48000 -fs16_le
ac3_surround_test.spdif

Tested on Zotac PI330 with Onkyo receiver

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agorawmidi: symbols: use rawmidi_virt only when available
Thomas Petazzoni [Fri, 11 Aug 2017 21:24:03 +0000 (23:24 +0200)]
rawmidi: symbols: use rawmidi_virt only when available

src/rawmidi/Makefile.am only brings rawmidi_virt.c into the build when
BUILD_SEQ is defined (i.e when --enable-seq is passed). However,
rawmidi_symbols.c unconditionally refers to _snd_module_rawmidi_virt,
defined in rawmidi_virt.c.

This causes a link failure when BUILD_SEQ is disabled. For example
when linking ffmpeg against alsa-lib:

/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libasound.a(pcm_dmix.o): In function `snd_pcm_dmix_sync_ptr':
pcm_dmix.c:(.text+0x83c): warning:
/home/thomas/projets/buildroot/output/host/arm-buildroot-linux-uclibcgnueabi/sysroot/usr/lib/libasound.a(rawmidi_symbols.o):(.data+0x4): undefined reference to `_snd_module_rawmidi_virt'
collect2: error: ld returned 1 exit status

To fix this, we make sure that rawmidi_symbols.c only uses
_snd_module_rawmidi_virt when available.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf/ucm: DB410c-HiFi: add CIC selection
Srinivas Kandagatla [Thu, 10 Aug 2017 11:36:16 +0000 (13:36 +0200)]
conf/ucm: DB410c-HiFi: add CIC selection

This patch adds CIC selection controls which have been added recently to
the kernel to select mic source.

Without this patch user has to manually select the control to record
from DMIC or AMIC.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agosnd_user_file: avoid use wordexp
Natanael Copa [Fri, 14 Jul 2017 16:47:05 +0000 (18:47 +0200)]
snd_user_file: avoid use wordexp

As suggested in POSIX[1], wordexp might execute the shell. If the libc
implementation does so, it will break the firefox sandbox which does
not allow exec. This happened on Alpine Linux with musl libc[2].

Since we cannot guarantee that the system wordexp implementation does
not execute shell, we cannot really use it, and need to implement the
~/ expansion ourselves.

We provide a configure option --with-wordexp for users that still may
need it, but we leave this off by default because wordexp is a large
attack vector and it is better to avoid it.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/wordexp.html#tag_16_684_08
[2]: http://bugs.alpinelinux.org/issues/7454#note-2

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agocleanup: Use uint*_t instead of u_int*_t everythwere
Natanael Copa [Fri, 14 Jul 2017 14:18:11 +0000 (16:18 +0200)]
cleanup: Use uint*_t instead of u_int*_t everythwere

Use the standard uint{8,16,32,64}_t everywhere instead of the
non-standard u_int{8,16,32,64}_t.

This changes the types in the public headers and removes the u_int*_t
defines. This may break things. However, indentifiers ending with _t are
reserved by POSIX[1]; defining those can lead to undefined behavior.

So if you rely on alsa-lib defining those for you, then you want the
compiler to error so things can be fixed properly.

[1]: http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_02

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agocleanup: fix poll.h includes
Natanael Copa [Wed, 12 Jul 2017 08:45:18 +0000 (10:45 +0200)]
cleanup: fix poll.h includes

According POSIX[1] and linux manpage[2] the include is poll.h, not
sys/poll.h.

This fixes the he following compiler warning when build with musl libc:

  /usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
   #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
    ^~~~~~~

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: remove superfluous code to call of SNDRV_PCM_IOCTL_SYNC_PTR in snd_pcm_hw_fo...
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:29 +0000 (20:37 +0900)]
pcm: hw: remove superfluous code to call of SNDRV_PCM_IOCTL_SYNC_PTR in snd_pcm_hw_forward()

SNDRV_PCM_IOCTL_SYNC_PTR command was introduced to PCM protocol/interface
in its version 2.0.7, however this command is used in a branch for the
newer version protocol/interface in snd_pcm_hw_forward().

This commit removes the superfluous code as a part of work for code
refactoring.

Fixes: eafb4925124b ("- added SYNC_PTR ioctl support for pcm_hw plugin")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add a helper function to issue avail_min without side-effects
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:28 +0000 (20:37 +0900)]
pcm: hw: add a helper function to issue avail_min without side-effects

At present, applications can change avail_min parameter of PCM substream
by two ways; via mapped control data, and by executing ioctl(2) with
SNDRV_PCM_IOCTL_SYNC_PTR. The former is available in a case that the
applications map the data successfully.

When utilizing alsa-lib API, the above is done by a call of
'snd_pcm_sw_params()' to hw PCM plugin. In current implementation, this
call has an side-effect to issue appl_ptr unexpectedly.

This commit adds a helper function to issue avail_min without the
side-effect.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add a helper function to issue appl_ptr without side-effects
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:27 +0000 (20:37 +0900)]
pcm: hw: add a helper function to issue appl_ptr without side-effects

After starting, PCM substream shift its state to running and applications
can move appl_ptr by several ways. When status and control data of runtime
of the PCM substream is not mapped, the applications should issue appl_ptr
to kernel land. In this case, when any PCM frames is handled by mmap
operation, the applications should issue appl_ptr to update.

This commit adds a helper function for this purpose. To avoid unexpected
change of avail_min, this commit uses a flag just to update appl_ptr.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add a helper function to request hwsync without side-effects
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:26 +0000 (20:37 +0900)]
pcm: hw: add a helper function to request hwsync without side-effects

SNDRV_PCM_IOCTL_SYNC_PTR command for ioctl(2) with
SNDRV_PCM_SYNC_PTR_HWSYNC flag has an effect to update hw_ptr.
This is an alternative of SNDRV_PCM_IOCTL_HWSYNC but caller can get
current status simultaneously.

This commit adds a helper function just to issue hwsync. To avoid
side-effect to change appl_ptr and avail_min, this commit uses
SNDRV_PCM_SYNC_PTR_APPL and SNDRV_PCM_SYNC_PTR_AVAIL_MIN flags.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add a helper function just to query status data
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:25 +0000 (20:37 +0900)]
pcm: hw: add a helper function just to query status data

When mapping status data successfully, mapped page includes status data
for applications. In this case, applications have no need to call ioctl(2)
with SNDRV_PCM_IOCTL_SYNC_PTR. However, in current implementation, when
map of control data is unavailable, applications execute the ioctl(2).
This is inconvenient for some cases that applications require to query
status only.

This commit adds a helper function to query status data without issuing
the control in fallback mode from failure of status mmap.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add a helper function to query status/control data
Takashi Sakamoto [Fri, 30 Jun 2017 11:37:24 +0000 (20:37 +0900)]
pcm: hw: add a helper function to query status/control data

When executing ioctl(2) with some commands, applications can request
ALSA PCM core to change appl_ptr in kernel space. Below is a list of
such operations:
 - SNDRV_PCM_IOCTL_PREPARE
 - SNDRV_PCM_IOCTL_RESET
 - SNDRV_PCM_IOCTL_REWIND
 - SNDRV_PCM_IOCTL_FORWARD
 - SNDRV_PCM_IOCTL_WRITEI_FRAMES
 - SNDRV_PCM_IOCTL_WRITEN_FRAMES
 - SNDRV_PCM_IOCTL_READI_FRAMES
 - SNDRV_PCM_IOCTL_READN_FRAMES

After these operations, the value of appl_ptr should be synchronized
between kernel/user spaces.

This commit adds a helper function to query status and control data
without issuing the control data just in fallback from failure of control
mapping.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: minor refactoring for initialization of control data
Takashi Sakamoto [Fri, 30 Jun 2017 11:00:26 +0000 (20:00 +0900)]
pcm: hw: minor refactoring for initialization of control data

At failure of control data mapping, alsa-lib goes to fallback mode. In
this mode, a buffer is kept in user space and executes ioctl(2) with
SNDRV_PCM_IOCTL_SYNC_PTR for the buffer to synchronize the control data.

In current implementation, no helper function is used for initialize
the control data. This commit use an proper helper function instead of
a direct call of ioctl(2).

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: improve verbose output for block output.
Liam Girdwood [Fri, 30 Jun 2017 13:14:56 +0000 (14:14 +0100)]
topology: improve verbose output for block output.

Show index and full DAPm route in verbose output.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Add support for new widget types
Liam Girdwood [Fri, 30 Jun 2017 13:14:55 +0000 (14:14 +0100)]
topology: Add support for new widget types

Add topology support for new DSP widget types. This allows the new
widgets to be added to the driver and firmware DAPM graphs.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: fix to initialize function local variable
Takashi Sakamoto [Fri, 30 Jun 2017 10:50:00 +0000 (19:50 +0900)]
pcm: hw: fix to initialize function local variable

This commit is to fix below warning.

pcm_hw.c: In function â€˜snd1_pcm_hw_open_fd’:
pcm_hw.c:955:33: warning: â€˜mmap_control’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (mmap_control == MAP_FAILED || mmap_control == NULL) {
                                 ^
pcm_hw.c:946:31: note: â€˜mmap_control’ was declared here
  struct snd_pcm_mmap_control *mmap_control;
                               ^~~~~~~~~~~~

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: Call USER_PVERSION ioctl at open
Takashi Iwai [Tue, 20 Jun 2017 12:21:20 +0000 (14:21 +0200)]
pcm: hw: Call USER_PVERSION ioctl at open

Up from the new PCM protocol 2.0.14, user-space can inform the
protocol version it supports to kernel, so that the kernel may switch
its behavior depending on it.  Add this ioctl call in the PCM hw
plugin at opening.

The patch contains also the addition of SNDRV_PCM_INFO_SYNC_APPLPTR
carried from the upstream kernel commit 42f945970af9 ("ALSA: pcm: Add
the explicit appl_ptr sync support"), as well as the trivial change
(an addition of comma) to sync with the kernel asound.h.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: maintain fallback mode for control data mapping independently
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:24 +0000 (13:41 +0900)]
pcm: hw: maintain fallback mode for control data mapping independently

Currently, failures of status/control data mapping are handled dependently.
However, it's not sure that one of the operations is failed when another
is failed.

This commit adds a member into private data structure to maintain fallback
mode for control data mapping, independently of status data mapping. As a
result, we have four cases to handle status/control data:

1. both of status/control data are mapped.
Nothing changed. A structure with alias of 'snd_pcm_hw_t' already has two
members to point the mapped area and in application runtime they're used
to refer/set status/control data. No need to call ioctl(2) with
SNDRV_PCM_IOCTL_SYNC_PTR to issue/query the data.

2. both of status/control data are unmapped.
The two members point to allocated memory for fallback buffer. In
application runtime, the buffer is given as an argument for ioctl(2) with
SNDRV_PCM_IOCTL_SYNC_PTR to issue/query the data.

3. status data is mapped only.
One of the two members is used to point the mapped area. Another points to
allocated memory for fallback buffer. In application runtime, the buffer
is used as an argument to execute ioctl(2) with SNDRV_PCM_IOCTL_SYNC_PTR
for the latter data, but the former data is already synchronized.

4. control data is mapped only.
The same as the above.

In design of ALSA PCM interface, userspace applications are not expected
to map the status data as writable. On the other hand, expected to map
the control data as writable. In a focus on the differences, we could
achieve to reduce calls of the ioctl(2) in a case that one of the
status/control data is successfully mapped and another is failed (case 3
and 4). Especially, in current alsa-lib implementation, application
runtime queries state of runtime of PCM substream so often.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: maintain fallback mode for status data mapping
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:23 +0000 (13:41 +0900)]
pcm: hw: maintain fallback mode for status data mapping

In current implementation, results to map status/control data are not
maintained separately. It's handled as a fatal error that mapping of status
data is successful and mapping of control data is failed. However, it's
possible to handle this case by utilizing fallback buffer.

This commit adds a member into a local structure to maintain fallback mode
just for the mapping of status data as a preparation of later commit, in
which mapping results are maintained separately for each of status/control
data.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: allocate fallback buffer in advance of trials of mapping
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:22 +0000 (13:41 +0900)]
pcm: hw: allocate fallback buffer in advance of trials of mapping

When allowing failure of map operation for both of status/control data
for runtime of PCM substream, applications need to use fallback buffer
for an alternative ioctl. However, in current implementation, status
mapping is dominant to the allocation.

This commit moves code for the allocation outside of the mapping
operation for status data.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: deallocate fallback buffer when trials of unmapping finished
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:21 +0000 (13:41 +0900)]
pcm: hw: deallocate fallback buffer when trials of unmapping finished

In current implementation, deallocation of fallback buffer is done at
several places.

This commit unifies these deallocations in one place.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add an arrangement for initialization of appl_ptr/avail_min
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:20 +0000 (13:41 +0900)]
pcm: hw: add an arrangement for initialization of appl_ptr/avail_min

Regardless of success/failure mapping of control/status data for runtime of
PCM substream, appl_ptr/avail_min parameters are initialized. In current
implementation, they are initialized in case-dependent, different places.
It's possible to collect them to one place.

This commit unifies relevant code in a place after all of trials for the
mappings are finished.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: add helper functions to map/unmap status/control data for runtime of PCM...
Takashi Sakamoto [Sun, 25 Jun 2017 04:41:19 +0000 (13:41 +0900)]
pcm: hw: add helper functions to map/unmap status/control data for runtime of PCM substream

Handling mapping operation for status/control data includes some
supplemental operations for fallback mode. It's better to have helper
functions for this purpose.

This commit adds the helper functions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: hw: Remove superfluous call of snd_pcm_set_appl_ptr()
Takashi Iwai [Tue, 20 Jun 2017 10:39:23 +0000 (12:39 +0200)]
pcm: hw: Remove superfluous call of snd_pcm_set_appl_ptr()

There is a call of snd_pcm_set_appl_ptr() in snd_pcm_hw_hw_params()
only for the capture direction.  This must be a leftover from the
ancient code.  Although it's harmless for now, it's superfluous and
confusing.  Let's kill it.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: minor code cleanup for ioctl call
Takashi Sakamoto [Fri, 23 Jun 2017 13:09:24 +0000 (22:09 +0900)]
pcm: minor code cleanup for ioctl call

When error occurs, return value from ioctl(2) is -1 and error code can
be got thread local variable, errno. It's OK just to check the return
value without any assignment.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: obsolete 'mmap_emulation' parameter of snd_pcm_hw_open_fd()
Takashi Sakamoto [Fri, 23 Jun 2017 13:09:23 +0000 (22:09 +0900)]
pcm: obsolete 'mmap_emulation' parameter of snd_pcm_hw_open_fd()

A function, snd_pcm_hw_open_fd(), is just for internal use. This function
has an obsoleted parameter and we can remove it without any compatibility
issue.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf: USB-Audio: allow custom definitions for "default" devices
Alexander Tsoy [Sun, 18 Jun 2017 20:23:03 +0000 (23:23 +0300)]
conf: USB-Audio: allow custom definitions for "default" devices

Fixes: a9b129955659 ("USB-Audio.conf: fix definition for M-Audio AudioP...")
Signed-off-by: Alexander Tsoy <alexander@tsoy.me>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf: USB-Audio: fix dsnoop args for Audiophile USB card
Alexander Tsoy [Sun, 18 Jun 2017 20:23:02 +0000 (23:23 +0300)]
conf: USB-Audio: fix dsnoop args for Audiophile USB card

Fixes: a9b129955659 ("USB-Audio.conf: fix definition for M-Audio AudioP...")
Signed-off-by: Alexander Tsoy <alexander@tsoy.me>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Add parsing for rates from conf
Guneshwor Singh [Tue, 20 Jun 2017 04:15:45 +0000 (09:45 +0530)]
topology: Add parsing for rates from conf

In alsa-lib topology parser, rate_min and rate_max are parsed currently.
Add support to parse rates also.

Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: disable alsa-lib topology debug output by default.
Liam Girdwood [Wed, 14 Jun 2017 11:37:40 +0000 (12:37 +0100)]
topology: disable alsa-lib topology debug output by default.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Add support for missing fields parser.
Liam Girdwood [Wed, 14 Jun 2017 11:37:39 +0000 (12:37 +0100)]
topology: Add support for missing fields parser.

The alsa-lib topology parser is missing some fields for certain objects that
are part of the ABI. This patch adds the missing fields to the parser.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoRelease v1.1.4.1
Jaroslav Kysela [Thu, 1 Jun 2017 06:27:36 +0000 (08:27 +0200)]
Release v1.1.4.1

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
7 years agopcm: dmix: Fix the inconsistent PCM state
Takashi Iwai [Tue, 30 May 2017 21:08:51 +0000 (23:08 +0200)]
pcm: dmix: Fix the inconsistent PCM state

The commit 38a2d2eda880 ("pcm: dmix: Do not discard slave reported
delay in...") changed the handling in snd_pcm_dmix_status() for taking
the actual delay from the slave PCM status.  Along with it, the commit
removed the line to update its own state altogether, as it had been
done originally in the dshare patch (commit faf53c197cab "pcm_dshare:
Do not discard slave reported delay..."), supposing that the slave PCM
keeps this same state.  However, for dmix/dshare, the PCM state may
differ from the slave, thus these changes resulted in the inconsistent
PCM state.

For dshare, the issue was already addressed by commit ad6957c61867
("plugin:dshare: wrong state reporting"), while the fix for dmix was
forgotten until now.

This patch restores the code to set the proper dmix PCM state again
like in the previous versions.

Fixes: 38a2d2eda880 ("pcm: dmix: Do not discard slave reported delay in...")
Reported-by: Cheng Sun <chengsun9@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: dshare: Call snd_pcm_dshare_state() directly
Takashi Iwai [Tue, 30 May 2017 15:33:17 +0000 (17:33 +0200)]
pcm: dshare: Call snd_pcm_dshare_state() directly

... otherwise it may be a deadlock if recursive lock isn't available.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: dmix: Workaround for binary incompatibility
Takashi Iwai [Fri, 26 May 2017 12:37:59 +0000 (14:37 +0200)]
pcm: dmix: Workaround for binary incompatibility

The commit 1a9bd0f04481 ("pcm: direct: Fix for sync issue on xrun
recover") introduced a new field "recoveries" in
snd_pcm_direct_share_t.  Unfortunately this caused two issues:

- It changed the size of the struct which is used as the magic key
- The struct size differs between 32bit and 64bit due to alignment

The former brought the incompatibility with the older alsa-lib,
e.g. when you run an app with an older alsa-lib via LD_PRELOAD, it
doesn't work any longer.

The latter is more serious, it disallows running 32bit apps dmix with
64bit together.

As a workaround, put recoveries field to the unused field
"s.xfer_align", so that the struct is in an old form.  This makes the
dmix again binary-compatible with 1.1.3 and older versions, and also
fix the incompatibility between 32/64 bits.

This is a one-time workaround, and we may need to reconsider more
about a breakage in future...

Fixes: 1a9bd0f04481 ("pcm: direct: Fix for sync issue on xrun recover")
Reported-and-tested-by: Cheng Sun <chengsun9@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotest: add a test for list operation to user-defined element sets
Takashi Sakamoto [Wed, 24 May 2017 14:34:14 +0000 (23:34 +0900)]
test: add a test for list operation to user-defined element sets

Current implementation of test for user-defined element doesn't perform
list operation. This commit adds easy test for the operation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf: Check the availability of PTHREAD_MUTEX_RECURSIVE
Takashi Iwai [Tue, 16 May 2017 14:02:59 +0000 (16:02 +0200)]
conf: Check the availability of PTHREAD_MUTEX_RECURSIVE

Check the availability of PTHREAD_MUTEX_RECURSIVE in configure script
and use it only when possible.  A fairly old version of glibc still
seems working, but just to be sure.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agobuild: Define __USE_UNIX98 for old glibc
Takashi Iwai [Tue, 16 May 2017 14:17:57 +0000 (16:17 +0200)]
build: Define __USE_UNIX98 for old glibc

Otherwise PTHREAD_MUTEX_RECURSIVE isn't defined and we get an error
with old glibc.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoRelease v1.1.4
Jaroslav Kysela [Fri, 12 May 2017 08:01:45 +0000 (10:01 +0200)]
Release v1.1.4

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
7 years agoconf: topology: Fix index mismatch for skl and bxt
Subhransu S. Prusty [Wed, 10 May 2017 08:16:53 +0000 (13:46 +0530)]
conf: topology: Fix index mismatch for skl and bxt

The topology index in the conf is set to 1, where the driver expects index
set to 0. Fix the inconsistency.

Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Fix issue in parsing routes when generating topology binary
Fuwei Tang [Fri, 5 May 2017 07:57:20 +0000 (15:57 +0800)]
topology: Fix issue in parsing routes when generating topology binary

We missed parsing the index value, which is used as a use case indicator, when
processing the route objects.

This patch fixes the bug.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Tested-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf: Allow dynamic top-level config directory
Takashi Iwai [Tue, 2 May 2017 22:09:28 +0000 (00:09 +0200)]
conf: Allow dynamic top-level config directory

Currently the top-level config directory is specified only via
configure script option, and is fixed after that.  It's inconvenient
when the library is moved to another base directory, or if you want to
use a library code (e.g. with $LD_PRELOAD) with the incompatible
config setups.

This patch allows user to override the top-level config path via the
environment varialbe, $ALSA_CONFIG_DIR.  For that, a new helper
function, snd_config_topdir(), was introduced, and the codes referring
to the top config dir have been modified to handle it dynamically.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf: Remove dmix.direct_memory_access setup
Takashi Iwai [Wed, 3 May 2017 07:42:02 +0000 (09:42 +0200)]
conf: Remove dmix.direct_memory_access setup

The commit [22eca6468b4a: pcm: dmix: Allow disabling x86
optimizations] introduced the new flag for dmix & co,
direct_memory_access.  However, it turned out that such an addition of
the new flag in the default pcm definition causes an error when it's
used with old alsa-lib codes.  Although the code added here is
correct, per se, and it works as expected, it's not wise to break the
configuration with old stuff -- even if the usage is somehow incorrect
and should be avoided.

Since the usage of the new flag is only for HDMI LPE audio, and the
usage of dmix itself should be limited with that hardware, this patch
removes the setup so that it works with the old alsa-lib again.  We
may introduce the dmix behavior change in a smarter way, e.g. passing
some flag from the hardware driver so that it works more generically
without the manual fiddling of config files.

Bugzilla: http://bugzilla.opensuse.org/show_bug.cgi?id=1037021
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Allow a data section to contain multiple tuples objects
Mengdong Lin [Thu, 27 Apr 2017 06:46:00 +0000 (14:46 +0800)]
topology: Allow a data section to contain multiple tuples objects

It's easy to use a vendor tuples object to define a C structure instance as
vendor specific parameter for kernel drivers. And sometimes the kernel drivers
may want a group of structures. So this patch will allow user to define multiple
vendor tuples objects in a data section, to avoid defining multiple data
sections and each data section only has 1 vendor tuples object.

There is no ABI change in this patch.

Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Use recursive mutex
Takashi Iwai [Fri, 21 Apr 2017 18:36:40 +0000 (20:36 +0200)]
ALSA: pcm: Use recursive mutex

The recent thread-safety pthread implementation caused deadlocks in
some situations, e.g. when an external plugin calls snd_pcm_state() in
its callback.  One can avoid the deadlock by carefully using the
unlocked version, but it's often error-prone, and it might be still
problem with the old binaries.

In this patch, we initialize the pthread mutex as recursive for fixing
such a problem.

Suggested-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agohwdep: add support for MOTU FireWire series and RME Fireface series
Takashi Sakamoto [Fri, 21 Apr 2017 15:28:01 +0000 (00:28 +0900)]
hwdep: add support for MOTU FireWire series and RME Fireface series

Drivers for MOTU FireWire series and RME Fireface series were newly added
to v4.12 kernel. Like the other drivers in ALSA firewire stack, they also
support HwDep interface.

This commit add entries for the drivers.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agohwdep: add Line6 USB series support
Takashi Sakamoto [Fri, 21 Apr 2017 15:28:00 +0000 (00:28 +0900)]
hwdep: add Line6 USB series support

Drivers for Line6 USB series was firstly added to staging directory at
development period of v2.6.30 kernel. At v4.9 kernel development, they
were moved to sound directory. The drivers include HwDep interface, while
header in user space library has never been updated for an entry
corresponding to the drivers.

This commit adds the entry.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotimer: obsolete legacy rtctimer instance
Takashi Sakamoto [Fri, 21 Apr 2017 15:27:59 +0000 (00:27 +0900)]
timer: obsolete legacy rtctimer instance

At v4.7 development, ALSA timer interface dropped device instance based on
legacy rtctimer implementation. User space applications should not use the
device instance.

This commit adds comments to notify a corresponding macro should not be
used anymore.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Group elements with the same index value into a block
Fuwei Tang [Thu, 13 Apr 2017 06:52:47 +0000 (14:52 +0800)]
topology: Group elements with the same index value into a block

Topology objects(widgets,controls) with different index value should be grouped
into different blocks and the block headers contain the index value.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Reviewed-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Look up references for an object based on its index
Fuwei Tang [Thu, 13 Apr 2017 06:52:46 +0000 (14:52 +0800)]
topology: Look up references for an object based on its index

We can distinguish different use cases by the object index value, the default
value is 0, meaning applicable for all use cases, defined by macro "SND_TOLG_INDEX_ALL".
An element can only refer to other elements for "all" use cases or the same use
cases, i.e. it can only refer to elements with index value "SND_TOLG_INDEX_ALL"
or the same index value as itself.
The object list has been sorted in ascending order of index, so when we look up
a reference for an object, we traverse the object list it depends on, if we have
not found the reference until index of the object list is greater than index of
the object, we give up and return an error.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Reviewed-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Remove code parsing index value in paring each object
Fuwei Tang [Thu, 13 Apr 2017 06:52:45 +0000 (14:52 +0800)]
topology: Remove code parsing index value in paring each object

We insert a new element into the object list based on its index value, so we parse
index value in "tplg_elem_new_common" before insert it, and then remove code
parsing index value in parsing each object.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Reviewed-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agotopology: Insert new element based on its index value
Fuwei Tang [Thu, 13 Apr 2017 06:52:44 +0000 (14:52 +0800)]
topology: Insert new element based on its index value

When creating a new element, insert it into the list in the ascending order of
index value.

Signed-off-by: Fuwei Tang <fuweix.tang@intel.com>
Reviewed-by: Mengdong Lin <mengdong.lin@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm: dmix: Disable var_periodsize as default
Takashi Iwai [Mon, 10 Apr 2017 09:47:02 +0000 (11:47 +0200)]
pcm: dmix: Disable var_periodsize as default

The recently added variable period-size feature for dmix & co seems
causing a regression on some old applications; e.g. Audacious aborts
with an error:

  ALSA error: snd_pcm_hw_params_set_buffer_time_near failed: Invalid argument.

As a quick fix, disable the feature as default.  One can still enable
it via asoundrc.

Bugzilla: https://bugzilla.opensuse.org/show_bug.cgi?id=1033179
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm:plugin: Fix sound capture via MMAP access
Timo Wischer [Tue, 4 Apr 2017 06:30:18 +0000 (12:00 +0530)]
pcm:plugin: Fix sound capture via MMAP access

Distorted sound is heard if the capture device of an ioplug plugin is used,
which is accessed through any ALSA plugin (like copy, linear, ...) via MMAP access.
E.g. aplay -> loop -> copy -> arecord -M -> aplay -> hw:0
As mentioned in the ALSA API (see pcm/pcm.c:942):
The function #snd_pcm_avail_update() have to be called
before any mmap begin+commit operation.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoplugin:dshare: wrong state reporting
Andreas Pape [Tue, 4 Apr 2017 06:29:52 +0000 (11:59 +0530)]
plugin:dshare: wrong state reporting

If plugin dshare detects underrun, it reports this to the user
via return value -EPIPE and setting dshare state to 'xrun' which is correct.
But, if user after this wants to check the stream state, it is misleadingly
reported as 'running' instead of 'xrun'.
With this behavior aplay e.g. will not do a proper underrun handling
(restarting stream) but terminates streaming.
This is due to plugin dshare always returns state of the slave pcm,
in pcm_ops->state() which is not correct.

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm:file: delegate htimestamping to slave instead of always getting real_htimestamp
Andreas Pape [Thu, 23 Mar 2017 11:40:45 +0000 (17:10 +0530)]
pcm:file: delegate htimestamping to slave instead of always getting real_htimestamp

purpose of this fix, is to read most accurate timestamps.

 From documentation of /src/pcm/pcm.c, we can see:
 """" \par Timestamp mode

 The timestamp mode specifies, if timestamps are activated. Currently, only #SND_PCM_TSTAMP_NONE and #SND_PCM_TSTAMP_MMAP modes are known.
 The mmap mode means that timestamp is taken on every period time boundary. Corresponding position in the ring buffer assigned to timestamp can be obtained using #snd_pcm_htimestamp() function. """"

 As snd_pcm_generic_htimestamp() internally calls snd_pcm_htimestamp() to read time, so accurate timestamp can be read from snd_pcm_generic_htimestamp().

 Also, in case of pcm_file, if the underlying slave is hardware, then we would wish to read elapsed hardware time, as it will be the most accurate, as opposed to the elapsed wall time.
 This will provide pcm_file with the most accurate timestamps.

 Following are the timesamps read with timestamp enabled, for with fix and without fix scenarios:

 1> With fix:
:~#time aplay --enable-tstamp -Dhtstamp_test --period-time=5000 -v -fdat /dev/urandom
Playing raw data '/dev/urandom' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
File PCM (file=/tmp/swarate_out.wav)
Final file PCM (file=/tmp/swarate_out.wav)
..

Slave: Hardware PCM card 0 'imx6q-sabresd-wm8962' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 24000
  period_size  : 240
  period_time  : 5000
  tstamp_mode  : ENABLE
  .
  .
Before sleep = 142:409.807623
After sleep = 142:409.807623
Before sleep = 142:414.806016 (calling snd_pcm_htimestamp(handle, &avail, &tstamp_before))
sleep of 2 milisec
After sleep = 142:414.806016 (calling snd_pcm_htimestamp(handle, &avail, &tstamp_after)
From the above timestamps, we can see that slave has returned the same timestamps, as --period-time choosen is 5msec.

2> Without this fix:
The timestamps are returned with realtime value.

:~# time aplay --enable-tstamp -Dhtstamp_test --period-time=5000 -v -fdat /dev/urandom
Playing raw data '/dev/urandom' : Signed 16 bit Little Endian, Rate 48000 Hz, Stereo
File PCM (file=/tmp/swarate_out.wav)
Final file PCM (file=/tmp/swarate_out.wav)
.
.
Slave: Hardware PCM card 0 'imx6q-sabresd-wm8962' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 48000
  exact rate   : 48000 (48000/1)
  msbits       : 16
  buffer_size  : 24000
  period_size  : 240
  period_time  : 5000
  tstamp_mode  : ENABLE
.
.
Before sleep = 241:136.875845 (calling snd_pcm_htimestamp(handle, &avail, &tstamp_before))
sleep of 2 milisec
After sleep = 241:139.076376 (calling snd_pcm_htimestamp(handle, &avail, &tstamp_after)

We can observe here, the timestamps shows time diff of ~2ms, which is the time gap of sleep duration.
Before sleep = 241:139.617588
After sleep = 241:141.746845
Before sleep = 241:142.291618
After sleep = 241:144.406406
Before sleep = 241:144.951421
After sleep = 241:147.066118
Before sleep = 241:147.623421
After sleep = 241:149.740573

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agopcm:plug: save converter config
Andreas Pape [Tue, 21 Mar 2017 12:58:18 +0000 (18:28 +0530)]
pcm:plug: save converter config

Passed config is freed after call to open, thus it is invalid when
trying to extract the converter name. So config entry is saved
for later usage.

Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Mounesh Sutar <sutar.mounesh@gmail.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoconf/cards: add VC4-HDMI card
Boris Brezillon [Thu, 2 Mar 2017 10:49:33 +0000 (11:49 +0100)]
conf/cards: add VC4-HDMI card

Add a conf file for the VC4-HDMI sound card.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agorawmidi: virtual: fix reading into a small buffer
Clemens Ladisch [Sat, 18 Mar 2017 22:10:33 +0000 (23:10 +0100)]
rawmidi: virtual: fix reading into a small buffer

In the special case for handling partial messages, the pointer
calculations were wrong, which would result in data corruption.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agodmix plugin: drain - quickfix for the previous patch
Jaroslav Kysela [Mon, 20 Mar 2017 07:41:53 +0000 (08:41 +0100)]
dmix plugin: drain - quickfix for the previous patch