alsa-lib.git
4 days agopcm: dshare: Fix overflow when slave_hw_ptr rolls over boundary master
Brendan Shanks [Mon, 11 Feb 2019 19:51:26 +0000 (11:51 -0800)]
pcm: dshare: Fix overflow when slave_hw_ptr rolls over boundary

In snd_pcm_dshare_sync_area() when 'slave_hw_ptr' rolls over
'slave_boundary', the wrong variable is checked ('dshare->slave_hw_ptr' vs
the local 'slave_hw_ptr'). In some cases, this results in 'slave_hw_ptr'
not rolling over correctly. 'slave_size' and 'size' are then much too
large, and the for loop blocks for several minutes copying samples.

This was likely only triggered on 32-bit systems, since the PCM boundary
is computed based on LONG_MAX and is much larger on 64-bit systems.

This same change was made to pcm_dmix in commit
6c7f60f7a982fdba828e4530a9d7aa0aa2b704ae ("Fix boundary overlap”) from
June 2005.

Signed-off-by: Brendan Shanks <brendan.shanks@teradek.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 days agoucm: bytcr/PlatformEnableSeq.conf update some comments
Hans de Goede [Sun, 3 Feb 2019 11:37:41 +0000 (12:37 +0100)]
ucm: bytcr/PlatformEnableSeq.conf update some comments

Commit f91cc3c7d6b7 ("Update chtrt5645 ucm variants to use
bytcr/PlatformEnableSeq.conf component") updated the
following 2 comments:

 # codec0_out settings (used if SSP2 is connected to aif1)
 # modem_out settings (used if SSP0 is connected to aif2)

Specifically it added the " to aif1" resp. " to aif2" part of the comments.

This is not correct, AIF1 / AIF2 are something which is present on
Realtek codecs only, and either one can be used indepedent of
SSP0 or SSP2 being used (the comments in the chtrt5645 UCM profile
before this change were wrong / outdated).

Besides there not being any relationship between SSP0 or SSP2 being
used, bytcr/PlatformEnableSeq.conf is also used with other codecs,
e.g. the ESS8316 codec where this is not applicable at all.

Therefor this commit removes the " to aif?" part of the comments again
to avoid confusing people reading this in the future.

Cc: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 weeks agoucm: Add ucm files for DB820c board
Srinivas Kandagatla [Tue, 29 Jan 2019 10:48:28 +0000 (10:48 +0000)]
ucm: Add ucm files for DB820c board

DB820c board is based of MSM8996 Qualcomm SoC, which has support for both
Digital and Analog audio. Digital audio is over HDMI and analog is over
WCD9335 codec via SLIMbus.

Board itself has HDMI port, a 3.5mm audio Jack and an Audio expansion
connector.
This patch adds support for HDMI port and 3.5mm jack.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

3 weeks agoRevert "conf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio"
Jaroslav Kysela [Fri, 25 Jan 2019 11:09:31 +0000 (12:09 +0100)]
Revert "conf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio"

This reverts commit d8013619c942dd996c32337a9ade429bfaf455ee.

The USB driver defines identical profile as for WD15.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 weeks agoconf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio
Hui Wang [Tue, 27 Nov 2018 01:36:28 +0000 (09:36 +0800)]
conf/ucm: Add a UCM profile for Dell WD19 Dock USB-audio

USB-audio device on Dell WD19 docking station provides two individual
output PCM streams, one for headphone Jack and another for speaker out
Jack. A UCM profile gives the proper roles for these.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agopcm: Preserve period_event in snd_pcm_hw_sw_params() call
Takashi Iwai [Wed, 9 Jan 2019 11:02:56 +0000 (12:02 +0100)]
pcm: Preserve period_event in snd_pcm_hw_sw_params() call

snd_pcm_hw_sw_params() in pcm_hw.c tries to abuse the reserved bits
for passing period_Event flag.  In this hackish way, we clear the
reserved bits at beginning, and restore before returning.  However,
the code paths that return earlier don't restore the value, hence when
user calls this function twice, it may pass an unexpected value.

This patch fixes the failure, restoring the value always before
returning from the function.

Reported-by: Jamey Sharp <jamey@minilop.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

5 weeks agoRelease v1.1.8 v1.1.8
Jaroslav Kysela [Mon, 7 Jan 2019 12:55:38 +0000 (13:55 +0100)]
Release v1.1.8

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoconf: rename snd_conf_load1() to _snd_config_load_with_include()
Jaroslav Kysela [Mon, 7 Jan 2019 12:15:32 +0000 (13:15 +0100)]
conf: rename snd_conf_load1() to _snd_config_load_with_include()

Always free the include path which must be mallocated by the caller.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoconf/ucm: bytcht-es8316: Add long-name UCM profiles
Hans de Goede [Thu, 3 Jan 2019 13:50:15 +0000 (14:50 +0100)]
conf/ucm: bytcht-es8316: Add long-name UCM profiles

After recent kernel work, the kernel now sets a long-name for bytcht-es8316
boards which indicates if a single (mono) speaker or stereo speakers are
used and if in1 or in2 is used for the internal mic (the headset mic will
be on the other input).

This commit adds UCM profiles for bytcht-es8316 boards using these new
long-names, based on the generic bytcht-es8316 profile.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoconf/ucm: Add UCM profile for bytcht-es8316 boards
Hans de Goede [Thu, 3 Jan 2019 13:50:14 +0000 (14:50 +0100)]
conf/ucm: Add UCM profile for bytcht-es8316 boards

Add an UCM profile for Bay Trail and Cherry Trail boards with an
ES8316 codec.

Re-use the existing platform enable and disable sequences for BYT/CHT SST
support and add a codecs/es8316 dir with codec specific enable / disable
sequences for the various inputs and outputs.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoCreate device component for rt5645 Internal Analog Mic UCM
Russell Parker [Sun, 6 Jan 2019 03:47:15 +0000 (19:47 -0800)]
Create device component for rt5645 Internal Analog Mic UCM

Since the Internal Analog Microphone device configuration is
identical for the rt5645 and rt5645 mono speaker UCMs, move
the entire definition to a component.

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoFactor out rt5645 variants Headset+Digital Mic UCM shared {en,dis}able sequences
Russell Parker [Sun, 6 Jan 2019 03:47:14 +0000 (19:47 -0800)]
Factor out rt5645 variants Headset+Digital Mic UCM shared {en,dis}able sequences

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoFactor out rt5645 variants Speaker+Headphones shared UCM enable sequences
Russell Parker [Sun, 6 Jan 2019 03:47:13 +0000 (19:47 -0800)]
Factor out rt5645 variants Speaker+Headphones shared UCM enable sequences

Move common enable sequences for rt5645 variants and rt5650
UCM configurations into a shared component. The corresponding
disable sequences are only two lines each and do not seem worth
creating components for.

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoCreate shared {En,Dis}ableSeq.conf components for rt5645 variants
Russell Parker [Sun, 6 Jan 2019 03:47:12 +0000 (19:47 -0800)]
Create shared {En,Dis}ableSeq.conf components for rt5645 variants

Factor out the common enable and disable sequences used
in rt5645 variants, including the rt5650. Move the sequences
into a new component directory codecs/rt5645/ along with
a Makefile.

Some lines like
    cset "name='Stereo1 ADC1 Mux' 1"
and
    cset "name='I2S2 Func Switch' on"
are not set set in the chtrt5650 UCM sequences and thus are not present
in the new component, in order to maximize reuse.

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agoUpdate chtrt5645 ucm variants to use bytcr/PlatformEnableSeq.conf component
Russell Parker [Sun, 6 Jan 2019 03:47:11 +0000 (19:47 -0800)]
Update chtrt5645 ucm variants to use bytcr/PlatformEnableSeq.conf component

The Lenovo Ideapad Miix 320, Asus T100HA, and chtrt5645 mono variant
UCM configurations have not been updated to make use of the shared
bytcr/PlatfromEnableSeq.conf sequence. This commit deletes those
command sequences and loads the shared component directly.

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

5 weeks agocontrol: fix the assert() in snd_ctl_elem_set_bytes
Jaroslav Kysela [Mon, 7 Jan 2019 08:08:46 +0000 (09:08 +0100)]
control: fix the assert() in snd_ctl_elem_set_bytes

Allow to write to the whole array (512 bytes).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 weeks agoconf/ucm: bytcr-rt5651: Document mono speaker wiring
Hans de Goede [Tue, 1 Jan 2019 11:32:46 +0000 (12:32 +0100)]
conf/ucm: bytcr-rt5651: Document mono speaker wiring

During my recent work on the bytcht-es8316 UCM profile I realized that the
bytcr-rt5651 devices with a single speaker use a differential setup just
like the es8316 does. The tell-tale here is the speaker going quiet when
playing the exact same sound on both channels when things are configured
for stereo speakers.

I've run some tests and the rt5651 does have a special mono balanced out
mode for its line-out but using this results in the same sound (and the
same loudness / volume of the sound) as our current solution, so adding
support for this to the kernel buys us nothing.

This commit makes no changes, it just documents my findings in a big
comment for future reference.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: bytcr-rt5651: Add bytcr-rt5651-stereo-spk-dmic-mic config
Hans de Goede [Mon, 24 Dec 2018 15:05:04 +0000 (16:05 +0100)]
conf/ucm: bytcr-rt5651: Add bytcr-rt5651-stereo-spk-dmic-mic config

Add a config for boards which use a digital mic as internal mic,
combined with having the headset mic on in2.

An example of such a board is the Point of View TAB-P1006W-232 (v1.0) tablet.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: bytcr-rt5651: Add digital mic support
Hans de Goede [Mon, 24 Dec 2018 15:05:03 +0000 (16:05 +0100)]
conf/ucm: bytcr-rt5651: Add digital mic support

Add a new ucm/codecs/rt5651/DigitalMic.conf snippet for digital mic support
and include this in the default non board-specific bytcr-rt5651.conf.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: bytcr-rt5651: Add support for a headset-mic on IN2
Hans de Goede [Mon, 24 Dec 2018 15:05:02 +0000 (16:05 +0100)]
conf/ucm: bytcr-rt5651: Add support for a headset-mic on IN2

The first design with the headset-mic on IN2 rather then the
default / reference-design IN3 has shown up.

Add a new ucm/codecs/rt5651/IN2-HeadsetMic.conf snippet to deal with this
and include this in the default non board-specific bytcr-rt5651.conf.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: bytcr-rt5651: Enable Stereo? ADC MIXL ADC? switches when enabling inputs
Hans de Goede [Mon, 24 Dec 2018 15:05:01 +0000 (16:05 +0100)]
conf/ucm: bytcr-rt5651: Enable Stereo? ADC MIXL ADC? switches when enabling inputs

Explicitly enable the right 'Stereo? ADC MIXL ADC?' when selecting an input,
rather then just enabling them all in ucm/codecs/rt5651/EnableSeq.conf .

This is a preparation patch for adding digital mic support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: kblrt5660: Add ucm setting for Dell Edge IoT platform
Hui Wang [Mon, 24 Dec 2018 08:34:46 +0000 (16:34 +0800)]
conf/ucm: kblrt5660: Add ucm setting for Dell Edge IoT platform

The new generation of Dell Edge IoT platform is based on Intel
Kabylake platform, and the audio codec is ALC3277 which is 100%
compatible with RT5660 in I2S mode.

The audio design on this IoT platform is as below:
 - Intel kabylake platform
 - connect the codec ALC3277 via SSP0
 - line-out and line-in with Micbias jacks
 - line-out mute control and jack detection of line-out and line-in
 - two HDMI ports with audio capability

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 weeks agoconf/ucm: chtrt5650: Add UCM config for chtrt5650
Russell Parker [Sun, 30 Dec 2018 05:35:26 +0000 (21:35 -0800)]
conf/ucm: chtrt5650: Add UCM config for chtrt5650

Add a UCM configuration for the rt5650 codec. Tested on
a Samsung Chromebook 3. Adapted with minor modifications
from GitHub user evan-a-a's gist:
https://gist.github.com/evan-a-a/86b2a698708074530e2d0ee7c6498767

Signed-off-by: Russell Parker <russell.parker7@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 weeks agopcm: ioplug: Fix the regression of pulse plugin drain
Takashi Iwai [Wed, 19 Dec 2018 13:23:38 +0000 (14:23 +0100)]
pcm: ioplug: Fix the regression of pulse plugin drain

The recent change to support the drain via polling caused a regression
for pulse plugin; with speaker-test -c2 -twav with pulse, it leads to
either no sounds or stall.

The only sensible behavior change in the commit wrt pulse plugin is
that now it starts the stream before calling drain callback.  This
supposed to be correct, but it seems hitting a pulse plugin bug.

The start before drain callback is only a matter of consistency, and
since this doesn't work for the single existing plugin using drain
callback, we don't need to stick with this behavior.

For addressing the regression, we check the presence of the drain
callback and start the stream only when it doesn't exist, i.e. only in
drain-via-poll mode.

Fixes: ce2095c41f28 ("pcm: ioplug: Implement proper drain behavior")
Reported-by: Diego Viola <diego.viola@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 months agopcm: extplug: Keep format and channels the same if requested
Timo Wischer [Mon, 10 Dec 2018 10:33:16 +0000 (11:33 +0100)]
pcm: extplug: Keep format and channels the same if requested

Without this patch it is not possible to link the channel and format
parameter if snd_pcm_extplug_set_param_*() or
snd_pcm_extplug_set_slave_param_*() is called. Therefore the client and
slave parameter can differ. So the extplug has to implement conversion.

To avoid this the new snd_pcm_extplug_set_param_link() function can be
called.
As a reproduction sceanrio the following extplug source code can be used:

===
static snd_pcm_sframes_t my_transfer(snd_pcm_extplug_t *e,
const snd_pcm_channel_area_t *da, snd_pcm_uframes_t dof,
const snd_pcm_channel_area_t *sa, snd_pcm_uframes_t sof,
snd_pcm_uframes_t s) {
return s;
}
static const snd_pcm_extplug_callback_t my_own_callback = {
.transfer = my_transfer
};
SND_PCM_PLUGIN_DEFINE_FUNC(my_plug) {
snd_config_iterator_t i, next;
snd_config_t *slave = NULL;
snd_pcm_extplug_t *myplug;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
if (snd_config_get_id(n, &id) < 0)
continue;
if (strcmp(id, "comment") == 0 || strcmp(id, "type") == 0)
continue;
if (strcmp(id, "slave") == 0) {
slave = n;
continue;
}
return -EINVAL;
}
myplug = calloc(1, sizeof(*myplug));
myplug->version = SND_PCM_EXTPLUG_VERSION;
myplug->callback = &my_own_callback;
snd_pcm_extplug_create(myplug, name, root, slave, stream, mode);

snd_pcm_extplug_set_param_minmax(myplug,
SND_PCM_EXTPLUG_HW_CHANNELS, 1, 16);
// snd_pcm_extplug_set_param_link(myplug, SND_PCM_EXTPLUG_HW_CHANNELS, 1);

*pcmp = myplug->pcm;
return 0;
}
SND_PCM_PLUGIN_SYMBOL(my_plug);
===

To use this plugin the following ALSA configuration is required:

pcm.myplug {
    type my_plug
    slave.pcm hw:Dummy
}

With this configuration without this patch
snd_pcm_hw_params_get_channels_max() will always return 16 channels
independent of the supported channels of the dummy device. Due to that for
example the start up of JACK would fail:

$ modprobe snd_dummy
$ jackd -d alsa -P myplug
ALSA: cannot set channel count to 16 for playback
ALSA: cannot configure playback channel

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 months agoucm: Set default include path
Takashi Iwai [Wed, 28 Nov 2018 15:25:41 +0000 (16:25 +0100)]
ucm: Set default include path

Many UCM profiles include the UCM profile components under ucm/*
subdirectories and thusly put <searchdir:ucm> at each place.  This is
rather cumbersome.

This patch makes the UCM parser to set the default include path, so
that each profile no longer needs to set searchdir.  All the
<searchdir:ucm> lines currently found in the profiles are removed
gracefully, too.

For the needed implementation, a new helper,
_snd_config_load_with_include() is introduced.  It's not exported,
only for the use inside alsa-lib.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 months agoconf: Move UCM profile snippets into components subdirectory
Takashi Iwai [Tue, 27 Nov 2018 12:55:04 +0000 (13:55 +0100)]
conf: Move UCM profile snippets into components subdirectory

We have placed UCM profile snippets to be included by the main config
files also in the same directory, src/conf/ucm, it confuses alsaucm
program that scans over all subdirectories.  It thinks such a file is
also the main config file, and spews errors like:
  % alsaucm
  ALSA lib utils.c:67:(uc_mgr_config_load) could not open configuration file /usr/share/alsa/ucm/bytcr/bytcr.conf
  ALSA lib parser.c:1427:(load_master_config) error: could not parse configuration for card bytcr
  alsaucm: unable to obtain card list: No such file or directory

Actually we already defined the subdirectory for such components, and
they are skipped at parsing the main configs.  So we just need to move
the files there -- this is what's done here.

One more thing done here is to add a new component subdirectory,
platforms, for definitions bytcr/* that don't match with neither the
existing ones (codecs nor dsps).

Suggested-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jaroslav Kysela <perex@perex.cz>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 months agoconf: USB-Audio: Add Dell WD19 Dock in the IEC958 blacklist
Hui Wang [Wed, 28 Nov 2018 09:16:45 +0000 (17:16 +0800)]
conf: USB-Audio: Add Dell WD19 Dock in the IEC958 blacklist

This Dock doesn't have IEC958 physical output, so add it to the
blacklist to prevent it being opened.

[ Also adding WD15 Dock entry that has the same problem -- tiwai ]

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

2 months agopcm: dshare: Fix segfault when not binding channel 0
Kirill Marinushkin [Tue, 20 Nov 2018 20:43:44 +0000 (21:43 +0100)]
pcm: dshare: Fix segfault when not binding channel 0

Configuration to reproduce:

~~~~
pcm.share_right {
  type dshare
  ipc_key 73
  ipc_perm 0666
  slave {
    pcm "hw:0,0"
  }
  bindings {
    # the seagfault happens when we don't bind channel 0
    1 1
  }
}
~~~~

Execute to reproduce:

~~~~
$ aplay -D plug:share_right test.wav
Playing WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Segmentation fault
~~~~

For channels whithout binding, values are set to UINT_MAX in function
`snd_pcm_direct_parse_bindings()`:

~~~~
for (chn = 0; chn < count; chn++)
bindings[chn] = UINT_MAX; /* don't route */
~~~~

But, these values are not checked when playing, which causes the segfault.

This commit fixes the issue.

Signed-off-by: Kirill Marinushkin <kmarinushkin@birdec.tech>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

3 months agopcm: dmix: Add option to allow alignment of slave pointers
Laxmi Devi [Tue, 13 Nov 2018 07:43:00 +0000 (08:43 +0100)]
pcm: dmix: Add option to allow alignment of slave pointers

These changes are required due to the kernel
commit 07b7acb51d283d8469696c906b91f1882696a4d4
("ASoC: rsnd: update pointer more accurate")

Issue is that snd_pcm_wait() goes back to waiting because the hw_ptr
is not period aligned. Therefore snd_pcm_wait() will block for a longer
time as required.

With these rcar driver changes the exact position of the dma is returned.
During snd_pcm_start they read hw_ptr as reference, and this hw_ptr
is now not period aligned, and is a little ahead over the period while it
is read. Therefore when the avail is calculated during snd_pcm_wait(),
it is missing the avail_min by a few frames.

An additional option hw_ptr_alignment is provided to dmix configuration,
to allow the user to configure the slave application and hw pointer
alignment at startup

[ Slight indentation and parentheses removals by tiwai ]

Signed-off-by: Laxmi Devi <Laxmi.Devi@in.bosch.com>
Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

3 months agoutils/alsa.m4: conditionally enable libdl in AM_PATH_ALSA m4 macro
Thomas De Schampheleire [Thu, 1 Nov 2018 14:40:07 +0000 (15:40 +0100)]
utils/alsa.m4: conditionally enable libdl in AM_PATH_ALSA m4 macro

The AM_PATH_ALSA macro in utils/alsa.m4 unconditionally uses
-ldl. This breaks compilation of alsa-utils (and probably other
packages using this macro) for targets that do not support dynamic
loading.

This patch updates the macro to check if dlopen is available, and use
that result to conditionally add -ldl to the list of libraries.

Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

3 months agoREADME.md: add link to www.alsa-project.org
Jaroslav Kysela [Wed, 24 Oct 2018 15:33:10 +0000 (17:33 +0200)]
README.md: add link to www.alsa-project.org

3 months agoinitial version of README.md for github
Jaroslav Kysela [Wed, 24 Oct 2018 14:13:48 +0000 (16:13 +0200)]
initial version of README.md for github

3 months agoinitial version of .travis.yml file
Jaroslav Kysela [Tue, 23 Oct 2018 15:21:16 +0000 (17:21 +0200)]
initial version of .travis.yml file

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 months agopcm: interval: Interpret (x x+1] correctly and return x+1
Timo Wischer [Thu, 18 Oct 2018 11:33:24 +0000 (13:33 +0200)]
pcm: interval: Interpret (x x+1] correctly and return x+1

Without this change an interval of (x x+1] will be interpreted as an
empty interval but the right value would be x+1.
This leads to a failing snd_pcm_hw_params() call which returns -EINVAL.

An example issue log is given in the following:
snd_pcm_hw_params failed with err -22 (Invalid argument)
ACCESS: MMAP_NONINTERLEAVED
FORMAT: S16_LE
SUBFORMAT: STD
SAMPLE_BITS: 16
FRAME_BITS: 16
CHANNELS: 1
RATE: 16000
PERIOD_TIME: (15999 16000]
PERIOD_SIZE: (255 256]
PERIOD_BYTES: (510 512]
PERIODS: [2 3)
BUFFER_TIME: 32000
BUFFER_SIZE: 512
BUFFER_BYTES: 1024

In case of (x x+1) we have to interpret it anyway as a single value of x to
compensate rounding issues.
For example the period size will result in an interval of (352 353) when
the period time is 16ms and the sample rate 22050 Hz
(16ms * 22,05 kHz = 352,8 frames). But 352 has to be chosen to allow a
buffer size of 705 (32ms * 22,05 kHz = 705,6 frames) which has to be >= 2x
period size to avoid Xruns. The buffer size will not end up with an
interval of (705 706) simular to the period size because
snd_pcm_rate_hw_refine_cchange() calls snd_interval_floor() for the buffer
size. Therefore this value will be interpreted as an integer interval
instead of a real interval further on.

This issue seems to exist since the change of 9bb985c38 ("pcm:
snd_interval_refine_first/last: exclude value only if also excluded
before")

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 months agotest/audio_time: remove unused variables
Jaroslav Kysela [Tue, 23 Oct 2018 08:20:20 +0000 (10:20 +0200)]
test/audio_time: remove unused variables

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 months agotest: rename code to more approriate mixtest
Jaroslav Kysela [Tue, 23 Oct 2018 08:18:24 +0000 (10:18 +0200)]
test: rename code to more approriate mixtest

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 months agotest/code: make it work again
Jaroslav Kysela [Tue, 23 Oct 2018 08:17:12 +0000 (10:17 +0200)]
test/code: make it work again

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

3 months agotest/latecy: fix typo in tstamp compare
Jaroslav Kysela [Tue, 23 Oct 2018 08:03:17 +0000 (10:03 +0200)]
test/latecy: fix typo in tstamp compare

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

4 months agoconf/ucm/Dell-WD15-Dock: Fix incorrect device names
Takashi Iwai [Thu, 18 Oct 2018 07:38:38 +0000 (09:38 +0200)]
conf/ucm/Dell-WD15-Dock: Fix incorrect device names

The device name string for Dell WD15 (and its variants) dock is set as
"WD15Dock", while the actual device name to be used is "Dock".

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1112292
Fixes: 8ebb40c96970 ("conf/ucm: Add a UCM profile for Dell WD15 Dock USB-audio")
Signed-off-by: Takashi Iwai <tiwai@suse.de>

4 months agoRelease v1.1.7 v1.1.7
Jaroslav Kysela [Tue, 16 Oct 2018 08:08:35 +0000 (10:08 +0200)]
Release v1.1.7

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

4 months agoioplug: Fix comment in struct snd_pcm_ioplug
Andre Guedes [Fri, 28 Sep 2018 21:33:35 +0000 (14:33 -0700)]
ioplug: Fix comment in struct snd_pcm_ioplug

This patch fixes the comment about 'pcm' field in 'struct
snd_pcm_ioplug' which wrongly refers to snd_pcm_extplug_create().

Signed-off-by: Andre Guedes <andre.guedes@intel.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

4 months agotimer: fix wrong comment to refer to 'SNDRV_TIMER_PSFLG_*'
Takashi Sakamoto [Sat, 29 Sep 2018 14:21:43 +0000 (23:21 +0900)]
timer: fix wrong comment to refer to 'SNDRV_TIMER_PSFLG_*'

ALSA timer core has a comment referring to 'SNDRV_MIXER_PSFLG_*' in
a definition of 'struct snd_timer_params' of UAPI header. I can see
this in initial state of ALSA timer core, at least in
'alsa-driver-0.4.0.tar.gz'.

This commit fixes the comment.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

5 months agoseq: Fix signedness in MIDI encoder/decoder
Takashi Iwai [Thu, 23 Aug 2018 06:34:37 +0000 (08:34 +0200)]
seq: Fix signedness in MIDI encoder/decoder

The qlen field of struct snd_midi_event was declared as size_t while
status_events[] assigns the qlen to -1 indicating to skip.  This leads
to the misinterpretation since size_t is unsigned, hence it passes the
check "dev.qlen > 0" incorrectly in snd_midi_event_encode_byte(),
which eventually results in a memory corruption.

Also, snd_midi_event_decode() doesn't consider about a negative qlen
value and tries to copy the size as is.

This patch fixes these issues: the first one is addressed by simply
replacing size_t with ssize_t in snd_midi_event struct.  For the
latter, a check "qlen <= 0" is added to bail out; this is also good as
a slight optimization.

Reported-by: Prashant Malani <pmalani@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

5 months agocontrol_hw: Fix issue when applying seccomp policy
Hsin-Yu Chao [Fri, 17 Aug 2018 03:12:27 +0000 (11:12 +0800)]
control_hw: Fix issue when applying seccomp policy

When seccomp policy is applied to filter ioctl syscall with
SNDRV_CTL_IOCTL_TLV_COMMAND, SNDRV_CTL_IOCTL_TLV_READ and
SNDRV_CTL_IOCTL_TLV_WRITE in whiltelist, alsa-lib still breaks
in at snd_ctl_hw_elem_tlv().

The problem behind is because ioctl() takes unsigned long cmd
argument, and the signed bit of local int variable could cause
0xff bytes appended after casted to unsigned long.
In kernel, seccomp data struct takes 64 bits argument to check
against seccomp rules, these unexpected 0xff bytes could make
the rule check fail.

Fix the problem by passing unsigned int to ioctl.

Signed-off-by: Hsin-Yu Chao <hychao@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

6 months agoconf/ucm: bytcr-rt5640: Improve human readable input/output names
Hans de Goede [Wed, 8 Aug 2018 09:05:43 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5640: Improve human readable input/output names

The Comment field is displayed tot the end user in various UIs as such
names like MonoSpeaker and DigitalMics without any spaces are no good.

Also the names themselves as well as how they get displayed in the
typical UI (in separate input / output tabs) makes the adding of
playback and capture to the comment superfluous and this looks weird
in the UI, so drop it.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Add bytcr-rt5651-mono-spk-in2-mic-hp-swapped config
Hans de Goede [Wed, 8 Aug 2018 09:05:42 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Add bytcr-rt5651-mono-spk-in2-mic-hp-swapped config

Add a longname profile for devices with a mono speaker, the Internal Mic
hooked up to IN2 and the left and right channels of their headphones
output swapped.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Add long-name UCM profiles
Hans de Goede [Wed, 8 Aug 2018 09:05:41 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Add long-name UCM profiles

After recent kernel work, the kernel now sets a long-name for bytcr-rt5651
boards which indicates if a single (mono) speaker or stereo speakers are
used and if in1, in2, or in1 and 2 are used for the internal mic(s) (the
headset mic sofar is always on in3).

This commit adds UCM profiles for bytcr-rt5651 boards using these new
long-names, based on the generic bytcr-rt5651 profile.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Add mono speaker output profile
Hans de Goede [Wed, 8 Aug 2018 09:05:40 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Add mono speaker output profile

Many rt5651 devices only have a single speaker and even though there is
some external mixing done on the PCB, the quality of that mixing is quite
poor and various sounds come out garbled when relying on the on PCB mixing.

Using the codecs builtin mixer to mix left + right to the left output works
much better. This commits adds a new MonoSpeaker.conf output profile which
allows this.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Split into 1 .conf file per input / output
Hans de Goede [Wed, 8 Aug 2018 09:05:39 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Split into 1 .conf file per input / output

Split the bytcr-rt5651 config into 1 .conf file per input / output as
has already been done for the bytcr-rt5640 and the chtnau8824 profiles.

This allows easy creation of long-name profiles with the specific input /
output combinations found on a board without needing to copy and paste
things.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Add support for mic input on various pins
Hans de Goede [Wed, 8 Aug 2018 09:05:38 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Add support for mic input on various pins

Note this commit replaces the pre-existing "Handset Microphone" and
"Main Microphone" options, these come from the first commit of the
bytcr-rt5651 UCM profile and were based on wrong assumptions about the
input mappings. None of the existing devices has the Hand/Headset mic
on IN1 as these options assumed.

The rt5651 is used in various configurations with the Internal Mic(s)
hooked up to IN1, IN2, or to IN1 and IN2 and the Headset Mic hooked up
to IN3.

Add support for all these to the generic bytcr-rt5651 profile and name
them accotding to their input + functions.

A follow up commit will add specialized longname configs which
will only expose the inputs actually used on the board with that
longname.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Fix ADC and Mic capture volumes
Hans de Goede [Wed, 8 Aug 2018 09:05:37 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Fix ADC and Mic capture volumes

Fix ADC and Mic capture volumes, so that the microphone inputs actually
work.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Use generic SSP enable + disable sequence, support SSP0
Hans de Goede [Wed, 8 Aug 2018 09:05:36 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Use generic SSP enable + disable sequence, support SSP0

Use the generic SSP enable sequence from bytcr/PlatformEnableSeq.conf,
for boards using SSP2 this is identical the code it replaces and this
adds support for boards using SSP0.

This fixes sound not working on Bay Trail CR tablets with a rt5651 codec.

This commit also calls the generic disable sequence on shutdown
(this is new).

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Change Speaker/Headphone en/disable sequences to fix switching
Hans de Goede [Wed, 8 Aug 2018 09:05:35 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Change Speaker/Headphone en/disable sequences to fix switching

pulseaudio will run the DisableSequence of the current playback device
before running the EnableSequence of the new playback device.

This causes the Platform Clock and BIAS to temporarily get turned off which
on the rt5651 breaks audio-streams which are playing when switching.

This commit moves the disabling to the EnableSequence of the other device
fixing this.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Start with all outputs and inputs disabled
Hans de Goede [Wed, 8 Aug 2018 09:05:34 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Start with all outputs and inputs disabled

Start with all switches disabled, so that e.g. the
LOUT L/R Playback Switches are not left enabled when starting with
headphones plugged in.

This fixes the platform clock being kept on by these in some cases.

While at also move the IN? Boost and IF1 ASRC Switch lines around
a bit to match the order from https://github.com/plbossart/UCM so
the profiles can be more easily compared.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Configure all volumes at 0dB
Hans de Goede [Wed, 8 Aug 2018 09:05:33 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Configure all volumes at 0dB

The volumes are taken from this commit:
https://github.com/plbossart/UCM/commit/753e2430cd0e6cafbf10c6b29b689dbd32ac5250

That commit also adds line-in support, so it has not been
taken in its entirety.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5651: Do not use both DAC1 and HPVOL inputs for HP
Hans de Goede [Wed, 8 Aug 2018 09:05:32 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5651: Do not use both DAC1 and HPVOL inputs for HP

The headphones can either be driven directly from DAC1, or through
the HP volume mixer chain to allow volume control, both can be enabled
at the same time, but this should not be done.

Mix only DAC1 to the headphones and not the HP volume path, there
are 2 reasons to choice the DAC1 path;
1) It is the power-on-reset default
2) We don't expose the volume control to e.g. pulseaudio anyways so it
   is not useful

While at it also move the "HPO MIX DAC1" and "HPO MIX HPVOL" entries up a
bit so that they are no longer inbetween the "HPO L Playback Switch" and
"HPO R Playback Switch" entries.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

6 months agoconf/ucm: bytcr-rt5645: Use the generic bytcr/PlatformEnableSeq.conf
Hans de Goede [Wed, 8 Aug 2018 09:05:31 +0000 (11:05 +0200)]
conf/ucm: bytcr-rt5645: Use the generic bytcr/PlatformEnableSeq.conf

Use the generic Intel SSP bytcr/PlatformEnableSeq.conf file, it is
identical to all the cset statements this commit removes.

Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

7 months agopcm: ioplug: Transfer all available data
Rob Duncan [Mon, 16 Jul 2018 23:35:23 +0000 (16:35 -0700)]
pcm: ioplug: Transfer all available data

The snd_pcm_mmap_begin() call returns the amount of contiguous data,
which is less than the total available if it wraps around the buffer
boundary.

If we don't handle this split we leave stale data in the buffer that
should have been overwritten, as well as unread data in the io_plugin
that gets transferred on a subsequent call at the wrong offset.

Signed-off-by: Rob Duncan <rduncan@teslamotors.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

7 months agopcm: Fix header guard in pcm_plugin.h
Guillaume Blanc [Fri, 6 Jul 2018 13:22:06 +0000 (15:22 +0200)]
pcm: Fix header guard in pcm_plugin.h

Signed-off-by: Guillaume Blanc <guillaume.blanc@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

7 months agopcm: rate: Add error check for snd_pcm_avail_update()
Timo Wischer [Wed, 4 Jul 2018 13:39:49 +0000 (15:39 +0200)]
pcm: rate: Add error check for snd_pcm_avail_update()

Without these changes a negative error code returned by
snd_pcm_avail_update() will be not handled correctly.

With this patch the returned error code of snd_pcm_avail_update() will be
returned by snd_pcm_rate_avail_update().

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

7 months agopcm: ioplug: Provide avail helper function for plugins
Timo Wischer [Tue, 3 Jul 2018 13:59:21 +0000 (15:59 +0200)]
pcm: ioplug: Provide avail helper function for plugins

This function can be called without calling snd_pcm_avail_update().

The call to snd_pcm_avail_update() can take some time.
Therefore some developers would not like to call it from a real-time
context (e.g. from JACK client context).

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

7 months agopcm: snd_interval_refine_first/last: exclude value only if also excluded before
Timo Wischer [Mon, 2 Jul 2018 14:53:06 +0000 (16:53 +0200)]
pcm: snd_interval_refine_first/last: exclude value only if also excluded before

Without this commit the following intervals [x y), (x y) were be
replaced to (y-1 y) by snd_interval_refine_last(). This was also done if
y-1 is part of the previous interval.
With this changes it will be replaced with [y-1 y) in case of y-1 is
part of the previous interval. A similar behavior will be used for
snd_interval_refine_first().

This solves the issue reported here:
https://bugzilla.opensuse.org/show_bug.cgi?id=1033179
and work arounded with commit
e736715 ("pcm: dmix: Disable var_periodsize as default").

I am able to reproduce the issue with a simplified aplay use case using
the following configuration:
pcm_slave.adr3_tdm_8ch {
    pcm {
        type hw
        card "Loopback"
        device 0
    }
    rate 48000
    period_size 128
    buffer_size 1024
    channels 2
}

pcm.dshare_Playback_3 {
    type dmix
    ipc_key 600
    ipc_perm 0660
    ipc_gid audio
    var_periodsize true
    slave adr3_tdm_8ch
}

pcm.AdevAcousticoutSpeech {
    type rate
    slave.pcm dshare_Playback_3
    slave.rate 48000
}

$ modprobe snd_aloop
$ aplay -v --period-size=352 -c2 -fS16_LE -r22500 -DAdevAcousticoutSpeech /dev/urandom
...
Rule 9 (0xffff91d1f230): PERIODS=(0 2) -> NONE BUFFER_SIZE=480 PERIOD_SIZE=[240 240]
refine_soft 'AdevAcousticoutSpeech' (end--22)
...
aplay: ../../alsa-utils-1.1.5/aplay/aplay.c:1390: set_params: Assertion `err >= 0' failed.
Aborted by signal Aborted...

The following stack trace shows where the -EINVAL will be thrown:
__snd_pcm_hw_params_set_period_size_near()
snd1_pcm_hw_param_set_near()
snd1_pcm_hw_param_set_last()
snd1_pcm_hw_refine_slave()
snd1_pcm_hw_refine_soft()
snd_pcm_hw_rule_div()
snd1_interval_refine()

This issue exists due to PERIODS does not include 2
Rule 9 (0xffff91d1f230): PERIODS=(0 9) -> (0 2) BUFFER_SIZE=[120 480]
PERIOD_SIZE=(240 241)
because of an invalid integer inverval of PERIOD_SIZE of (240 241).
This interval is set by snd_interval_refine_last().

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

7 months agopcm: Define refine mask bits explicitly (and fix missing DSD support)
Takashi Iwai [Thu, 28 Jun 2018 05:59:46 +0000 (07:59 +0200)]
pcm: Define refine mask bits explicitly (and fix missing DSD support)

Instead of the expanded bit numbers like 0x81ffffff, list up the all
supported PCM bits explicitly for refine_masks[] in pcm_params.c.
This makes easier to update any additional formats or other
parameters, and easier to spot out missing ones.

Actually the GSM and DSD formats were missing; with this commit, they
are supported properly now.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

8 months agoconf/ucm: VEYRON-I2S: Add internal speakers and mic, other fixes
Urja Rannikko [Wed, 6 Jun 2018 17:52:42 +0000 (17:52 +0000)]
conf/ucm: VEYRON-I2S: Add internal speakers and mic, other fixes

Other fixes include output/input names (comments) for UIs (pavucontrol)
to display, and Playback/CapturePCM entries so pulseaudio initializes
correctly on this hardware.

Signed-off-by: Urja Rannikko <urjaman@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agopcm: dmix: Fix hwptr updates at status call
Takashi Iwai [Tue, 12 Jun 2018 11:47:01 +0000 (13:47 +0200)]
pcm: dmix: Fix hwptr updates at status call

In the commit 38a2d2eda880 ("pcm: dmix: Do not discard slave reported
delay in status result"), the PCM dmix hwptr update code was rewritten
to follow the slave PCM hwptr update.  This is based on the similar
change in PCM dshare, the commit faf53c197cab.

There was a bug in the commit 38a2d2eda880 regarding the PCM state
change, and it was addressed in commit 3752e6b8733d ("pcm: dmix: Fix
the inconsistent PCM state").  However, we've hit yet another bug in
this commit.  Namely, the hwptr update was forgotten in the
snd_pcm_dmix_sync_ptr0() function.  So the hwptr value passed from
snd_pcm_dmix_status() isn't properly stored, and it screws up at some
long run occasionally.

This patch covers the bug by replacing with the right value.

Fixes: 38a2d2eda880 ("pcm: dmix: Do not discard slave reported delay in status result")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200013
Signed-off-by: Takashi Iwai <tiwai@suse.de>

8 months agoconf/ucm: chtnau8824: Add Cube iWork8 Air and Pipo W2S specific profiles
Hans de Goede [Thu, 31 May 2018 15:10:26 +0000 (17:10 +0200)]
conf/ucm: chtnau8824: Add Cube iWork8 Air and Pipo W2S specific profiles

The Cube iWork8 Air and Pipo W2S tablets both only have a single speaker.
Add long-name profiles for them which are identical to the default
chtnau8824 profile, except that they include the nau8824/MonoSpeaker.conf
snippet instead of the nau8824/Speaker.conf one.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agoconf/ucm: chtnau8824: Add UCM profile for chtnau8824 boards
Hans de Goede [Thu, 31 May 2018 15:10:25 +0000 (17:10 +0200)]
conf/ucm: chtnau8824: Add UCM profile for chtnau8824 boards

Add UCM profile for chtnau8824 boards based on:
https://github.com/plbossart/UCM/blob/master/chtnau8824

Split into multiple files in the same way as this was done for the
bytcr-rt5640 support, re-using the existing ucm/PlatformEnableSeq.conf
and ucm/PlatformDisableSeq.conf files for the SST mixer settings.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agoconf/ucm: bytcr-rt5640: Add default DisableSequence
Hans de Goede [Thu, 31 May 2018 15:10:24 +0000 (17:10 +0200)]
conf/ucm: bytcr-rt5640: Add default DisableSequence

Add a disable sequence powering off the SST mixer elements, loosely
based on the default DisableSequence from:
https://github.com/plbossart/UCM/blob/master/chtnau8824/HiFi.conf

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agoconf/ucm: bytcr-rt5640: Add long-name UCM profiles
Hans de Goede [Thu, 31 May 2018 15:10:23 +0000 (17:10 +0200)]
conf/ucm: bytcr-rt5640: Add long-name UCM profiles

With a recently merged kernel commit, the kernel now sets a long-name for
bytcr-rt5640 boards which indicates if a single (mono) speaker or stereo
speakers are used and wether dmic1, in1 or in3 is used for the internal
mic (the headset mic sofar is always in2).

This commit adds UCM profiles for bytcr-rt5640 boards using these new
long-names, based on the generic bytcr-rt5640 profile.

The added profiles have the unnecessary input / output options from the
generic profile removed leaving only 2 input and 2 output options, which
are automatically switched between by e.g. pulse based on jack-detect.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agoconf/ucm: bytcr-rt5640: Add generic bytcr-rt5640 UCM profile
Hans de Goede [Thu, 31 May 2018 15:10:22 +0000 (17:10 +0200)]
conf/ucm: bytcr-rt5640: Add generic bytcr-rt5640 UCM profile

This commit adds the generic UCM profile for bytcr-rt5640 boards from:
https://github.com/plbossart/UCM, plus the fixes from this pull-req:
https://github.com/plbossart/UCM/pull/31

The profile has been split up into separate per input / output files to
allow for creation of long-name profiles with the specific input / output
combinations found on a board without needing to copy and paste things.

Note this profile exports all inputs and both stereo/mono speaker setups
even though a typical device will not use all. Ideally a long-name based
device specific profile made up of the various parts should be used
instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agopcm ioplug: fix some coverity issues (switch, missing unlock in snd_pcm_ioplug_drain())
Jaroslav Kysela [Wed, 23 May 2018 08:36:17 +0000 (10:36 +0200)]
pcm ioplug: fix some coverity issues (switch, missing unlock in snd_pcm_ioplug_drain())

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agopcm: add missing flags initialization for the fallback control data
Jaroslav Kysela [Wed, 23 May 2018 08:33:40 +0000 (10:33 +0200)]
pcm: add missing flags initialization for the fallback control data

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

8 months agoconf: USB-audio: Fix for Xonar U7 SPDIF device
Takashi Iwai [Tue, 22 May 2018 12:10:59 +0000 (14:10 +0200)]
conf: USB-audio: Fix for Xonar U7 SPDIF device

Add the entry for Xonar U7 to make SPDIF working on it.

Reported-by: Steve Banks <eassbank@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agotest: use position offset macro of TLV data
Takashi Sakamoto [Tue, 15 May 2018 12:36:39 +0000 (21:36 +0900)]
test: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agopcm: softvol: use position offset macro of TLV data
Takashi Sakamoto [Tue, 15 May 2018 12:36:38 +0000 (21:36 +0900)]
pcm: softvol: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agopcm: hw: use position offset macro of TLV data
Takashi Sakamoto [Tue, 15 May 2018 12:36:37 +0000 (21:36 +0900)]
pcm: hw: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agohcontrol: use position offset macro of TLV data
Takashi Sakamoto [Tue, 15 May 2018 12:36:36 +0000 (21:36 +0900)]
hcontrol: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agocontrol: use position offset macro of TLV data
Takashi Sakamoto [Tue, 15 May 2018 12:36:35 +0000 (21:36 +0900)]
control: use position offset macro of TLV data

A series of SNDRV_CTL_TLVO_XXX macro was introduced for position offset
of TLV data. This commit applies a code optimization.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agocontrol: add a series of macro for offset of several types of TLV
Takashi Sakamoto [Tue, 15 May 2018 12:36:34 +0000 (21:36 +0900)]
control: add a series of macro for offset of several types of TLV

In development period for Linux v4.18, a series of SNDRV_CTL_TLVO_XXX
macro was introduced to kernel stuffs for position offset of TLV data.

This commit adds these macros to backport header in this library.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconfigure: Fix forgotten ucm entry
Takashi Iwai [Thu, 3 May 2018 06:40:20 +0000 (08:40 +0200)]
configure: Fix forgotten ucm entry

The previous commit forgot to add to configure.ac.  Fix it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: Add a UCM profile for Dell WD15 Dock USB-audio
Takashi Iwai [Wed, 2 May 2018 14:23:21 +0000 (16:23 +0200)]
conf/ucm: Add a UCM profile for Dell WD15 Dock USB-audio

USB-audio device on Dell WD15 docking station provides two individual
PCM streams, one for headphone and another for line out.  A UCM
profile gives the proper roles for these.

Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: chtrt5645: At config for the Lenovo Ideapad Miix 320
Hans de Goede [Sat, 28 Apr 2018 19:52:00 +0000 (21:52 +0200)]
conf/ucm: chtrt5645: At config for the Lenovo Ideapad Miix 320

The Lenovo Ideapad Miix 320 uses a digital mic connected to the DMIC2 input
(unlike the Asus T100HA which has it connected to the DMIC1 input), add a
long-name config specific for the Miix 320, which is a copy of the standard
chtrt5645 config with the internal analog mic section replaced with one
for a digital mic connected to the DMIC2 input.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: chtrt5645: At config for the Asus T100HA
Hans de Goede [Sat, 28 Apr 2018 19:51:59 +0000 (21:51 +0200)]
conf/ucm: chtrt5645: At config for the Asus T100HA

The Asus T100HA uses a digital mic rather then an analog one, add
long-name config specific for the T100HA, which is a copy of the standard
chtrt5645 config with the internal analog mic section replaced with one
for the digital mic found on the Asus T100HA.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: chtrt5645: Fix recording from internal analog microphone
Hans de Goede [Sat, 28 Apr 2018 19:51:58 +0000 (21:51 +0200)]
conf/ucm: chtrt5645: Fix recording from internal analog microphone

The internal analog mic switch is called 'Int Analog Mic Switch'
(not 'Int Mic Switch') and is connected to BST2 not BST1.

Also change the analog mic volume levels so that we get better
audio / less noise.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: chtrt5645: Microphone recording fixes
Pierre-Louis Bossart [Sat, 28 Apr 2018 19:51:57 +0000 (21:51 +0200)]
conf/ucm: chtrt5645: Microphone recording fixes

Apply microphone recording changes from:
https://github.com/plbossart/UCM.git

Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
[hdegoede@redhat.com: Drop non generic DMIC changes]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: chtrt5645: Cleanup and playback fixes
Pierre-Louis Bossart [Sat, 28 Apr 2018 19:51:56 +0000 (21:51 +0200)]
conf/ucm: chtrt5645: Cleanup and playback fixes

Apply cleanup and playback fixes changes from:
https://github.com/plbossart/UCM.git

Cc: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
[hdegoede@redhat.com: Modify commit msg and paths for merging into alsa-lib]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoconf/ucm: increase the input volume for LineIn
Hui Wang [Wed, 2 May 2018 06:08:06 +0000 (14:08 +0800)]
conf/ucm: increase the input volume for LineIn

Otherwise, the boost value is 0, and the sound captured from that
LineIn jack is too weak for users.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

9 months agoucm: adding the folder of card_long_name when finding verb conf file
Hui Wang [Wed, 2 May 2018 06:08:05 +0000 (14:08 +0800)]
ucm: adding the folder of card_long_name when finding verb conf file

The board configuration file and verb conf file are allowed to be
in the folder named of card_long_name, so when finding the verb conf
file, we need to check if it is in the folder of card_long_name or
card_name.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>

9 months agopcm: softvol: Allow up to 90 dB of gain
Ricard Wanderlof [Wed, 18 Apr 2018 15:03:09 +0000 (17:03 +0200)]
pcm: softvol: Allow up to 90 dB of gain

The gain algorithm used in softvol can handle gain factors of up to
32767 which is slightly more than 90 dB, so allow a max_dB of 90 dB.
This doesn't affect existing asound.conf files, but does allow a
max_dB of up to 90 dB when needed.

Tested using Audacity that there is no undue distorsion or other
artefacts when 90 dB of gain is applied to a suitable signal (i.e.
a signal quiet enough not be clipped whan applying 90 dB of gain).

Signed-off-by: Ricard Wanderlof <ricardw@axis.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoASoC: topology: Add alias conf parameter names for hw_configs
Kirill Marinushkin [Mon, 16 Apr 2018 18:26:41 +0000 (20:26 +0200)]
ASoC: topology: Add alias conf parameter names for hw_configs

Currently, some parameter names in conf differ from field names in struct.
These look like typos.

This commit suggests to add aliases for such parameters, so that the names
in conf are similar to names in struct. This solution is backwards
compatible.

If the difference between conf names and struct names is done on purpose -
this commit can be dropped.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoASoC: topology: Add definitions for mclk_direction values
Kirill Marinushkin [Mon, 16 Apr 2018 18:26:40 +0000 (20:26 +0200)]
ASoC: topology: Add definitions for mclk_direction values

Current comment makes not clear the direction of mclk. Previously, similar
description caused a misunderstanding for bclk_master and fsync_master.

This commit solves the potential confusion the same way it is solved for
bclk_master and fsync_master.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: alsa-devel@alsa-project.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoASoC: topology: Add missing clock gating parameter when parsing hw_configs
Kirill Marinushkin [Mon, 16 Apr 2018 18:26:39 +0000 (20:26 +0200)]
ASoC: topology: Add missing clock gating parameter when parsing hw_configs

Clock gating parameter is a part of `dai_fmt`. It is supported by
`alsa-lib` when creating a topology binary file, but ignored by kernel
when loading this topology file.

After applying this commit, the clock gating parameter is not ignored any
more. This solution is backwards compatible. The existing behaviour is
not broken, because by default the parameter value is 0 and is ignored.

snd_soc_tplg_hw_config.clock_gated = 0 => no effect
snd_soc_tplg_hw_config.clock_gated = 1 => SND_SOC_DAIFMT_GATED
snd_soc_tplg_hw_config.clock_gated = 2 => SND_SOC_DAIFMT_CONT

For example, the following config, based on
alsa-lib/src/conf/topology/broadwell/broadwell.conf, is now supported:

~~~~
SectionHWConfig."CodecHWConfig" {
        id "1"
        format "I2S"            # physical audio format.
        pm_gate_clocks "true"   # clock can be gated
}

SectionLink."Codec" {

        # used for binding to the physical link
        id "0"

        hw_configs [
                "CodecHWConfig"
        ]

        default_hw_conf_id "1"
}
~~~~

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Pan Xiuli <xiuli.pan@linux.intel.com>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

9 months agoASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()
Kirill Marinushkin [Mon, 16 Apr 2018 18:26:38 +0000 (20:26 +0200)]
ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()

The values of bclk and fsync are inverted WRT the codec. But the existing
solution already works for Broadwell, see the alsa-lib config:

`alsa-lib/src/conf/topology/broadwell/broadwell.conf`

This commit provides the backwards-compatible solution to fix this misuse.
This commit goes in pair with the corresponding patch for linux.

Signed-off-by: Kirill Marinushkin <k.marinushkin@gmail.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Tested-by: Pan Xiuli <xiuli.pan@linux.intel.com>
Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
Cc: alsa-devel@alsa-project.org
Signed-off-by: Takashi Iwai <tiwai@suse.de>

10 months agoconfigure: remove src/conf/alsa.conf.d/Makefile
Jaroslav Kysela [Tue, 10 Apr 2018 06:57:07 +0000 (08:57 +0200)]
configure: remove src/conf/alsa.conf.d/Makefile

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

10 months agoconf: remove alsa.conf.d from the datadir
Jaroslav Kysela [Wed, 4 Apr 2018 08:02:49 +0000 (10:02 +0200)]
conf: remove alsa.conf.d from the datadir

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

10 months agoalsa.conf: change the location for add-on configs to /etc/alsa/conf.d
Jaroslav Kysela [Wed, 4 Apr 2018 07:58:12 +0000 (09:58 +0200)]
alsa.conf: change the location for add-on configs to /etc/alsa/conf.d

The add-on configuration files should be placed to a volatile place.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

10 months agoRelease v1.1.6 v1.1.6
Jaroslav Kysela [Tue, 3 Apr 2018 07:01:36 +0000 (09:01 +0200)]
Release v1.1.6

Signed-off-by: Jaroslav Kysela <perex@perex.cz>

10 months agoconf: USB-Audio: Add second S/PDIF device on Phiree U2SX
Bruno Pagani [Sun, 1 Apr 2018 17:11:20 +0000 (19:11 +0200)]
conf: USB-Audio: Add second S/PDIF device on Phiree U2SX

Phiree U2SX is the successor of Phiree U2 and has the same unusual
configuration.

See ea865bba4615d906144ae5d4f72a4aad2baffe1f for reference.

Signed-off-by: Bruno Pagani <bruno.n.pagani@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

10 months agopcm: ioplug: Implement proper drain behavior
Takashi Iwai [Thu, 29 Mar 2018 07:51:46 +0000 (09:51 +0200)]
pcm: ioplug: Implement proper drain behavior

This patch fixes the draining behavior of ioplug in the following
ways:

- When no draining ioplug callback is defined, implement the draining
  loop using snd_pcm_wait*() and sync with the drain finishes.
  This is equivalent with the implementation in the kernel write().
  Similarly as in kernel code, for non-blocking mode, it returns
  immediately after setting DRAINING state.

- The hw_ptr update function checks the PCM state and stops the stream
  if the draining finishes.

- When draining ioplug callback is defined, leave the whole draining
  operation to it.  The callback is supposed to return -EAGAIN for
  non-blocking case, too.

- When an error happens during draining, it drops the stream, for a
  safety reason.

Signed-off-by: Takashi Iwai <tiwai@suse.de>