summaryrefslogtreecommitdiff
path: root/src/ucm
Commit message (Collapse)AuthorAgeFilesLines
* ucm: fix crash when calling snd_use_case_geti() with no device or modifierAntonio Ospite2016-09-291-0/+8
| | | | | | | | | | | | | | | | | When calling snd_use_case_geti(uc_mgr, "_devstatus", &lvalue) the code ends up calling device_status(uc_mgr, NULL), which result in a crash in strcmp(dev->name, NULL), when there are enabled devices. This happens because snd_use_case_geti() allows a "_devstatus" identifier even if it's only supposed to allow the form "_devstatus/{device}". So check that the device name is not null. The same issue occurs with "_modstatus", this change fixes that as well. Signed-off-by: Antonio Ospite <ao2@ao2.it> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: add cset-tlvHsin-Yu Chao2016-04-133-13/+92
| | | | | | | | | | | | | | | This patch enables UCM to set a file in TLV format to kcontrol by: cset-tlv "name='<kcontrol-name>' <path-to-file>" This new 'cset-tlv' command will be used to write audio DSP to specific alsa control, where the driver expectes a file in TLV format. The TLV file to set to kcontrol will be checked first by file size not larger than 16 MB, and then examine if the length field reports correct number of bytes in the TLV file. Signed-off-by: Hsin-Yu Chao <hychao@chromium.org> Reviewed-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* Use alphasort where versionsort is not available.Thomas Klausner2016-03-031-1/+1
| | | | Signed-off-by: Takashi Iwai <tiwai@suse.de>
* fix _GNU_SOURCE handling & header inclusionMike Frysinger2015-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The configure script blindly adds -D_GNU_SOURCE to all build settings, even on non-GNU systems. This isn't too much of a big deal (even if it uses the wrong variable -- CFLAGS instead of CPPFLAGS), except that the alsa-lib source itself determines whether to use GNU features when this is defined (such as versionsort). So when we build on non-glibc systems, we get build failures like: src/ucm/parser.c:1268:18: error: 'versionsort' undeclared (first use in this function) #define SORTFUNC versionsort ^ src/ucm/parser.c:1272:54: note: in expansion of macro 'SORTFUNC' err = scandir(filename, &namelist, filename_filter, SORTFUNC); ^ The correct way to add these flags is to use the autoconf helper AC_USE_SYSTEM_EXTENSIONS. Unfortunately, that triggers some more bugs in the alsa build. This macro adds defines to config.h and not directly to CPPFLAGS, so it relies on files correctly including config.h before anything else. A number of alsa files do not do this leading to build failures. The fix there is to shuffle the includes around so that the local ones come first. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: fix some variable constness issuesTanu Kaskinen2015-02-171-14/+15
| | | | | | | | | | | | | I submitted earlier a patch that made the value parameter of snd_use_case_get() non-const, but as that changed the public API, the patch couldn't be accepted. This is the same patch, modifying the internal code so that there are fewer issues with constness, but the public API is left alone (a comment was added to the function documentation, though, so that hopefully nobody else will try to fix the same unfixable problem). Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: fix the logic of choosing the default cdevTanu Kaskinen2015-02-171-11/+23
| | | | | | | | | | | | | If the cdev has not been configured explicitly, use the PlaybackCTL or CaptureCTL value if one of them is set. If neither are set, or if both are set to different values, then there's no sensible default, so executing the sequence should fail. The previous code probably tried to implement this logic, but it was buggy. Also use more descriptive variable names than "cdev1" and "cdev2". Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: fix incorrect error code signTanu Kaskinen2015-02-171-2/+2
| | | | | | Reported-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Tanu Kaskinen <tanu.kaskinen@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: fix variable mixupTanu Kaskinen2015-02-111-1/+1
| | | | | | | | I assume the intention was to use cdev1 for PlaybackCTL and cdev2 for CaptureCTL, but cdev1 was being used for both and cdev2 was not used for anything. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: add binary configure file parseLu, Han2015-01-233-3/+73
| | | | | | | | | | | | | | | | with cset command, UCM set kcontrol parameters directly: cset "name='<KCONTROL_NAME>' 1<,2,3,...>" This patch enables UCM to set kcontrol with parameters from configure file: cset-bin-file "name='<KCONTROL_NAME>' <path/to/file>" where "cset-bin-file" is a newly added keyword alongside of "cset", to indicate cset with binary data in file. The binary data in file is parameter for audio DSPs, and it's just passed by UCM/ALSA as raw data. The data type of parameter elements must be byte, and the count must matches driver definition. Signed-off-by: Lu, Han <han.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Fix uninitialized err in snd_use_case_set()Takashi Iwai2014-11-211-2/+2
| | | | | | | | | | | The compiler warns like: main.c:1664:9: warning: 'err' may be used uninitialized in this function [-Wmaybe-uninitialized] and actually there are slight code paths that slip. This patch adds the proper initializations to 0 to return the success code in these code paths. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* autotools: update stylePatrick Welche2014-02-261-1/+1
| | | | | | | | | - rename configure.in to configure.ac - replace INCLUDES with AM_CPPFLAGS - modernize AM_INIT_AUTOMAKE invocation Signed-off-by: Patrick Welche <prlw1@cam.ac.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Fix segfault when device argument is missing from _sw{dev, mod}Juho Hämäläinen2013-05-241-1/+2
| | | | | Signed-off-by: Juho Hämäläinen <juho.hamalainen@tieto.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* all places: doxygen cleanupsJaroslav Kysela2013-04-081-17/+19
| | | | | | I see no errors with these changes using doxygen 1.8.1.1 . Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: Set uc_mgr->ctl to NULL after closing it.Tanu Kaskinen2013-01-281-0/+1
| | | | | | | | Fixes a double-free bug. Signed-off-by: Tanu Kaskinen <tanuk@iki.fi> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Add const to execute_cset() argumentTakashi Iwai2012-08-101-1/+1
| | | | | | | Now with the previous rewrite of execute_cset(), the cset string is no longer modified, thus we can pass const safely. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Improve cset command parsingTakashi Iwai2012-08-101-11/+13
| | | | | | | | | | | | The cset command parsing in ucm/main.c assumes implicitly that the argument contains no space, thus an example below wouldn't work: cset "name='Input Select' Digital Mic" This patch introduces a new internal API function __snd_ctl_ascii_elem_id_parse() to improve the cset parser. Reported-by: Tanu Kaskinen <tanu.kaskinen@digia.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Return NULL from get_list0() and get_list20() in case of empty lists.Tanu Kaskinen2012-08-011-2/+6
| | | | | | | | | | | alloc_str_list() sets the result to NULL too, so this patch makes the behavior more consistent. This also fixes a crash in PulseAudio, because PulseAudio assumes that snd_use_case_get_list() always initializes the result, and since snd_use_case_get_list() uses get_list20(), this assumption didn't hold. Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Add missing pthread.h includeArun Raghavan2012-07-171-0/+1
| | | | | | | Needed for the use of pthread_mutex_t Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* build: Fallback to alphasort() if versionsort() isn't availableArun Raghavan2012-07-171-1/+6
| | | | | | | | | versionsort() is a GNU-ism and can't be relied on for non-GNU systems. [modified to define SORTFUNC instead of copying lines by tiwai] Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: Handle repeat device and modifier enables/disablesArun Raghavan2012-05-291-28/+34
| | | | | | | | | | | | | Currently, enabling a device twice can cause it to be added to snd_use_case_mgr_t->active_devices twice, causing the list to become a loop and subsequent uses to result in an infinite loop. This patch makes sure we don't enable/disable a device twice, and avoid doing the same for modifiers. Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: add another sequence 'msleep'Lu Guanqun2011-08-222-1/+12
| | | | | | | | | | Thus, we have two sleep statements: msleep <milliseconds> usleep <microseconds> Signed-off-by: Lu Guanqun <guanqun.lu@intel.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: tivial code style fixLu Guanqun2011-08-191-1/+1
| | | | | Signed-off-by: Lu Guanqun <guanqun.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: fix seg fault in execute_cset()Lu Guanqun2011-08-191-1/+2
| | | | | | | | When there's no space in 'cset', 'pos' gets NULL, dereferencing 'pos' gets a seg fault. We need to be more robust. Signed-off-by: Lu Guanqun <guanqun.lu@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: get: Implement 'exact' value retrievalStephen Warren2011-06-081-30/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [=]<NAME>[/[<modifier>|</device>][/<verb>]] - value identifier <NAME> - Search starts at given modifier or device if any, else at a verb - Search starts at given verb if any, else current verb - Searches modifier/device, then verb, then defaults - Specify a leading "=" to search only the exact device/modifier/verb specified, and not search through each object in turn. - Examples: "PlaybackPCM/Play Music" "CapturePCM/SPDIF" From ValueDefaults only: "=Variable" From current active verb: "=Variable//" From verb "Verb": "=Variable//Verb" From "Modifier" in current active verb: "=Variable/Modifier/" From "Modifier" in "Verb": "=Variable/Modifier/Verb" Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: snd_use_case_get: Don't segfault when no current verbStephen Warren2011-06-081-0/+3
| | | | | | | | | get_value, called by snd_use_case_get, uses uc_mgr->active_verb without checking there is one, and hence can segfault. Fix this. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Allow querying of {Supported,Conflicting}DevicesStephen Warren2011-06-081-14/+92
| | | | | | | | | | | | | | | | | | | At any time, one can query: _supporteddevs/<modifier>|<device>/<verb> _conflictingdevs/<modifier>|<device>/<verb> If a verb is current, one can query: _supporteddevs/<modifier>|<device> _conflictingdevs/<modifier>|<device> Note that at most one of the supported/conflicting devs lists has any entries, and when neither is present, all devices are supported. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Disallow gets of undefined system propertiesStephen Warren2011-06-081-1/+14
| | | | | | | | | | | In UCM, there are various system-defined properties whose names start with "_". Explicitly prevent any gets from falling back to properties defined in a config file if the property name starts with "_", in order to reserve the entire "_" namespace for system-defined properties. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Implement ConflictingDevices, add device list to devicesStephen Warren2011-06-084-55/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | Wherever SupportedDevice can appear, also allow ConflictingDevice. Only one or the other (or neither) may be specified. When neither is specified, allow anything. Sometimes, listing ConflictingDevices may result in a shorter list than explicitly listing all SupportedDevices. Add support for SupportedDevice and ConflictingDevice to SectionDevice. This allows representing devices which are mutually exclusive, e.g. due to a mux that switches between capturing from two different microphones, without the possibility of mixing. Enhance is_modifier_supported to allow ignoring SupportedDevice and ConflictingDevice. This is useful when querying values from a SectionModifier; there's no reason we shouldn't be able to query values just because the current configuration would prevent enabling that device. The new is_device_supported is implemented similarly. Enhance switch_device to remove the old device from the current device list before querying for the new device, and add it back immediately afterwards. This allows the query for the new device to ignore any conflicts caused solely by the old device. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Deprecate index on Section{Device,Modifier}Stephen Warren2011-06-082-85/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The previous supported "legacy" syntax was: SectionDevice."Speaker".0 { SectionModifier."Capture Voice".0 { This change supports new syntax: SectionDevice."Speaker" { SectionModifier."Capture Voice" { ... but also allows the old syntax, iff the index is exactly "0". If an index is present, but not exactly "0", parsing will appear to succeed, but produce an empty device or modifier. When naming devices and modifiers, even if the legacy format is used, any index is not included in the name; i.e. both sets of syntax above name the device just "Speaker". The SupportedDevice list syntax still also accepts either "x" or "x.0", but internally strips ".0" from the tail of any device name. Any other name including "." is disallowed. Finally, when comparing device or modifier names, a simple exact string compare is now used, since no index data is ever present in device or modifier names. The one functional change introduced here is that a SupportedDevice entry of just "x" will now only ever match a single device. It previously acted as a wildcard for any device named "x.foo". Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Fix deadlock following failed get _verbStephen Warren2011-06-031-2/+4
| | | | | | | | | When querying the current verb without a verb set, snd_use_case_get bails out early without unlocking uc_mgr->mutex. This causes subsequent API calls to hang. Instead, s/return/goto __end/. Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* UCM: Fix typo in error messageStephen Warren2011-06-031-1/+1
| | | | | | | | parse_name_is_safe disallows dots in the name, so not is the correct word to use Signed-off-by: Stephen Warren <swarren@nvidia.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* UCM: fix memory leak when executing cset commandsBaek Chang2011-05-041-1/+10
| | | | | | | fix memory leak when executing cset commands. snd_ctl_elem's are allocated, but never free'ed Signed-off-by: Takashi Iwai <tiwai@suse.de>
* UCM: Fix LGPL licence ("how to receive" part referred GPL instead LGPL)Jaroslav Kysela2011-03-284-12/+12
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* UCM: Fix empty get_list - initialize returned pointer to NULLJaroslav Kysela2011-03-191-2/+4
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* UCM: comment fixes and fix myvalue initialization fix in add_values()Jaroslav Kysela2011-03-191-0/+1
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* alsa-lib: ucm: allow values to be read from devicesMargarita Olaya2011-03-181-7/+14
| | | | | | | | | This allows devices value to be read using the get_value(). Also fix a little formatting. Signed-off-by: Margarita Olaya Cabrera <magi@slimlogic.co.uk> Acked-by: Liam Girdwood <lrg@ti.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
* ucm: add more error messages for cdev and cset commandsJaroslav Kysela2011-01-311-2/+6
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: allow bind modifier to specific instances, other fixesJaroslav Kysela2011-01-313-16/+64
| | | | Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: make verb comments optionalPierre-Louis Bossart2011-01-291-3/+8
| | | | | | | avoid seg fault if no comment is provided Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: fix switch device & modifier when no transition is founducmLiam Girdwood2011-01-111-3/+3
| | | | | | | | Fix some logic bugs in switch device and switch modifier when transition sequences are not found. Also fix check for new device. Reported-by: w0806.kim@samsung.com Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: fix handling of cset with spaces in the control nameLiam Girdwood2010-12-221-1/+1
| | | | | Always terminate the cset command based on the last space found within the cset command since the control name may contain spaces.
* ucm: only select modifier when supported device is enabledLiam Girdwood2010-12-221-10/+44
| | | | | | | Make sure the supported device of a modifier is enabled before we enable the modifier. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: implement basic script exec functionalityLiam Girdwood2010-12-221-1/+3
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: check the correct return value for modifierLiam Girdwood2010-12-221-1/+1
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: check for valid value list before dereference.Liam Girdwood2010-12-221-0/+3
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: remove unused code.Liam Girdwood2010-12-221-2/+0
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: make sure active modifier and device lists are initialisedLiam Girdwood2010-12-221-0/+2
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: remove parse_device() and call parse_compound() directlyLiam Girdwood2010-12-221-8/+2
| | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
* ucm: modifiers names must be compound parseLiam Girdwood2010-12-221-4/+23
| | | | | | | | | | | | Modifier names must end in a .index to ensure we can support same named modifiers. However the modifier index will be for internal use only and the client will not use the index when setting modifier. The modifier selection for same name modifiers will be based upon supported device. Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
* ucm: removed unused 'active' member in struct use_case_deviceLiam Girdwood2010-12-221-2/+0
| | | | | Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk> Signed-off-by: Jaroslav Kysela <perex@perex.cz>