Commit graph

979 commits

Author SHA1 Message Date
Jaroslav Kysela
1ad660ddee ucm: docs - remove DigitalMic, it does not have sense
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-05 17:01:31 +01:00
Jaroslav Kysela
555a5dbdab ucm: docs - add Mic/DigitalMic and multiple devices comments
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-05 16:59:05 +01:00
Jaroslav Kysela
a0fc4447bb ucm: docs - add JackCTL, rearrange JackControl and JackDev
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-03 15:01:04 +01:00
Jaroslav Kysela
2a286ca9a8 use-case: docs - add PlaybackMixerCopy and CaptureMixerCopy
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-02 11:58:05 +01:00
Jaroslav Kysela
4dddcf733d ucm: docs - allow spaces in device names for JackHWMute
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-12-02 11:56:30 +01:00
Jaroslav Kysela
ebdd2b6cdb ucm: add _identifiers list
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-30 20:31:55 +01:00
Jaroslav Kysela
2cb44791c3 use-case: add priority values from pulseaudio
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-28 18:10:43 +01:00
Jaroslav Kysela
659ecf6ff0 use-case: improve comment for mixer elements
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-28 14:58:36 +01:00
Jaroslav Kysela
eee55a5267 ucm: rename mixer element identifiers
To my knowledge, no software is using the mixer element identifiers.
Rename them to be more consistent with the mixer API and add
Master element identifier and type.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-27 15:03:06 +01:00
Jaroslav Kysela
ca251e3518 include/sound/Makefile.am: remove asoundef.h
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-25 16:16:13 +01:00
Jaroslav Kysela
bcd334f58f local.h: remove sound/asoundef.h dependency 2019-11-25 10:36:32 +01:00
Jaroslav Kysela
2b40312d00 asoundef.h: add CEA861_AUDIO_INFOFRAME defines
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-25 10:36:05 +01:00
Jaroslav Kysela
0aece285a7 include/sound: sync with the kernel v5.4
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-25 10:34:27 +01:00
Jaroslav Kysela
1a4b362115 ucm: use-case.h - add <alsa/asoundlib.h> include
It is required for snd_ctl_elem_id_t and snd_mixer_selem_id_t.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-23 15:39:49 +01:00
Jaroslav Kysela
4c021697f1 conf: implement snd_config_add_before() and snd_config_add_after()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 16:56:05 +01:00
Jaroslav Kysela
4724158c0a ucm: change the If block parsing
- evaluate always If before the other blocks
2019-11-14 15:13:38 +01:00
Curtis Malainey
35e737f2ec ucm: docs: Add MinBufferLevel value
Allows ucm to override minimum buffer level for platforms that
incorrectly report their buffer level.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Curtis Malainey
eab3835c36 ucm: docs: Add EDID File value
Add a sys path to the EDID file for the corresponding HDMI device so
userspace can use if needed

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
e6fbc84c16 use-case header file: add more references to correct ASCII ID parsers for CTL/mixer IDs
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
5c88b18371 ucm: add snd_use_case_parse_selem_id()
and add strict ucm_id checks to snd_use_case_parse_ctl_elem_id()

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
4ce38a5ff4 mixer: simple - add snd_mixer_selem_id_parse() from amixer
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
cd4b07ffbd ucm: add snd_use_case_parse_ctl_elem_id()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
8a36e38dc4 ucm: add If condition block
The syntax is simple:

If./any-if-identificator/ {
  Condition {
    Type /type_here/
    /optional defines/
  }
  True {
    /block used when condition is evaluated as true/
  }
  False {
    /block used when condition is evaluated as false/
  }
}

The Type "ControlExists" is implemented:

Condition {
  Type ControlExists
  Device "hw:${CardId}"
  Control "iface=CARD,name='Headphone Jack'"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:37 +01:00
Jaroslav Kysela
be6deb927f ucm: extend snd_use_case_mgr_open() to address the sound card directly
Some clients like pulseaudio wants to access the multiple instances
of sound cards. This patch adds prefixes like "hw:" to the card_name
argument to handle this. The card index (value) or card identification
(string) can be used for this prefix.

Also the prefix "strict:" was added to avoid the driver name and
driver long name matching. It might be useable for use case
configurations which are not bound to the one sound card.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:10:43 +01:00
Jaroslav Kysela
f600310954 conf: improve the include paths code
- various cleanups (more straight code and allocations)
- do not add the base config path /usr/share/alsa to the
  explicit include list of directories
  (it's not wanted for ucm configs)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-10 13:05:53 +01:00
Jaroslav Kysela
63ffd41d5f pcm: the maximal rate is 768000Hz, fix the remain code
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-25 13:43:31 +02:00
Michael Forney
0baf7b377c Use __func__ instead of __FUNCTION__
They are equivalent, but __func__ is in C99. __FUNCTION__ exists only
for backwards compatibility with old gcc versions.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-06-12 08:52:07 +02:00
Jaroslav Kysela
8ab0393b42 rawmidi: use snd_dlobj_cache_get2() in rawmidi open (coverity)
Use proper reference counting for the dynamic symbol.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-05-24 21:25:50 +02:00
Jaroslav Kysela
5366bdb4fb add support for GCC's LTO 2019-04-09 12:44:14 +02:00
Takashi Iwai
fc0e54c3cc Drop -I$includedir/alsa from alsa.pc
We used to put the additional include path $includedir/alsa in
pkgconfig just because some applications have included asoundlib.h
like
  #include <asoundlib.h>
although the canonical form should be
  #include <alsa/asoundlib.h>

However, adding this include path is significantly dangerous due to
possible conflicts of file names like version.h.  It's already the
reason to discourage people using alsa.pc for the packages.

In this patch, the additional include path from alsa.pc is dropped
finally.  At the same time, as a rescue plan for the programs
including via <asoundlib.h>, a stub header file is provided in
include/sound/asoundlib.h.  It just includes alsa/asoundlib.h with a
warning to suggest for replacing with alsa/asoundlib.h.
Actually this is the same file as we install into sys/asoundlib.h, so
the whole changes are very minimal here.

Acked-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-03-28 08:01:34 +01:00
Jaroslav Kysela
1755df1d9e add snd_strlcpy() and use it everywhere
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-03-25 16:46:05 +01:00
Jaroslav Kysela
1e5ecbc806 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>
2019-01-07 13:15:34 +01:00
Timo Wischer
ee64b4b83a 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>
2018-12-10 11:53:41 +01:00
Takashi Iwai
c9fcf98369 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>
2018-11-29 09:40:10 +01:00
Andre Guedes
fd13267637 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>
2018-10-02 17:56:51 +02:00
Takashi Sakamoto
60d74ce517 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>
2018-10-02 17:16:14 +02:00
Guillaume Blanc
b0fc685115 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>
2018-07-06 17:07:13 +02:00
Timo Wischer
2972f2f966 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>
2018-07-03 16:36:34 +02:00
Takashi Sakamoto
5eb78219f6 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>
2018-05-15 18:03:11 +02:00
Kirill Marinushkin
7cf73b56e4 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>
2018-04-20 09:27:29 +02:00
Kirill Marinushkin
bdb709ab2a 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>
2018-04-20 09:27:20 +02:00
Kirill Marinushkin
3778a30bb0 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>
2018-04-20 09:27:11 +02:00
Jaroslav Kysela
7f084af4e4 a set of fixes to reduce gcc warnings
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2018-03-27 15:16:41 +02:00
Timo Wischer
22618077e7 pcm: Provide areas_copy function which handles buffer wrap around
The already existing areas_copy functions do not care about the end of
the source and destination buffer.
Therefore the caller has to take care that the requested offset+size
is not exceeding any buffer limit.

This additional function will take care about the end of an buffer
and will continue at the beginning of the buffer.
For example this is required when copying between buffers with
different sizes (not multiple of).
This is often the case in IO plugins like the JACK plugin.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-03-13 22:13:15 +01:00
Timo Wischer
df2452cc6a pcm: ioplug: Provide hw_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>
2018-03-13 22:12:02 +01:00
Timo Wischer
543a9eac5d pcm: ioplug: Use boundary for wrap around
if requested by the IO plugin

Without this changes an IO plugin is not able to report
that buffer_size frames were read from the buffer.
When the buffer was full this is a valid action and
has not to be handled as an under run.

For example when the hw_ptr will be updated with
hw_ptr += buffer_size
and it is using the buffer_size as wrap around
hw_ptr %= buffer_size
would result in the same value as before the add operation.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-02-24 11:41:22 +01:00
Takashi Iwai
de52ee3bb6 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>
2018-01-04 15:29:57 +01:00
Maciej S. Szmigiero
d67e42c139 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>
2017-12-18 15:40:36 +01:00
Maciej S. Szmigiero
22e6b3c200 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>
2017-12-18 15:40:14 +01:00
Jaroslav Kysela
c051036e17 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>
2017-11-27 21:48:20 +01:00