Attributes can have constraints set for valid values, min
or max values. If the attribute value is set in an object,
the value must be validated against the set constraints.
An example for attribute constraint would be:
DefineAttribute."direction" {
constraints {
valid_values [
"playback"
"capture"
]
tuple_values [
0
1
]
}
}
where the tuple_values array would translate the valid_values of
playback as 0 and capture as 1.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Object attributes can be set in multiple places. Search for
the attribute value in the following order:
1. Value set in object instance
2. Default value set in the object's class definition
3. Inherited value from the parent object
4. Value set in the object instance embedded in the parent object
5. Value set in the object instance embedded in the parent class definition
Mandatory attributes must be found in one of the above, resulting
in an error if not found.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add support for pre-processing object instances in the input
config. An object's attributes can be set in multiple places
such as, within the object instance, default values in the class
defnition, inherited from a parent object or explicitly set
in a parent object. Before converting the object config into
the relevant section in the existing syntax, all the attribute
values must be consolidated into one place so that it is easy
to verify if all mandatory attributes are set.
Also, the name of the object will be constructed from the
attributes defined in the attributes.constructor[] config
in the class definition and the unique attribute's value
must be set from the value passed in the object instance.
This patch create a temporary config for each object instance
and populates its unique attribute value. The rest of the steps
will be added in the following patches.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Some attributes have valid values that need to be converted
to integer tuple values before it is appended to the
object's private data:
For ex, the buffer widget object's "caps" attribute has the
following definition:
DefineAttribute."caps" {
type "string"
# Token reference and type
token_ref "sof_tkn_buffer.word"
constraints {
value_ref "sof_tkn_mem"
valid_values [
"dai"
"host"
"pass"
"comp"
]
tuple_values [
113
113
113
65
]
}
}
Depending on the user input, the value string values for "caps"
will be converted to the appropriate tuple values.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Some attributes may have the token_ref set which is
used to look up the token value for the tuple data
that is appended to the object's private data.
For example, in the buffer widget object:
DefineAttribute."size" {
# Token reference and type
token_ref "sof_tkn_buffer.word"
}
The token_ref must include the reference to the vendor
token object name followed by the type of the tuple.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a helper function to get attribute type from the
attribute definition and convert them to SND_CONFIG_TYPE_*
values. When no type if provided for an attribute, type
defaults to integer.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Every class must have a unique attribute that will be used
to instantiate the object. The value provided for this
attribute must be unique within the same alsaconf node for
objects of the same class. Add a helper function to get the
name of the attribute that must have a unique value in the
object instance.
For example, when instantiating 2 buffer widgets within a pipeline,
they must be given unique instance attribute values as:
Object.Widget.buffer.0{} and Object.Widget.buffer.1{}.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add helper functions to check if an attribute is
mandatory, immutable or unique in the class definition.
ex: for a host widget component, these are defined
as follows:
attributes {
#
# host objects instantiated within the same alsaconf node must have unique
# direction attribute
#
unique "direction"
mandatory [
"type"
"stream_name"
]
immutable [
"uuid"
]
}
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a helper function look up attribute definition in the
"DefineAttribute" config in the class definition.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a helper function to look up the class definition for
an object. ex: for an object instance, Object.Widget.pga.0{}, the
function returns the config pointing to Class.Widget.pga{} in
the input conf.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The pre-processor needs to concatinate strings separated
by '.' for building object names from constructor attribute
values and searching for configs with ID's containing strings
separate by '.'. Add a helper function to concat strings in
the specified input format.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a couple of helper functions for searching config by ID and
creating and adding configs to a parent config.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Add a couple of helper functions to print debug messages
and the generated config.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This patch adds support for pre-processing the Topology2.0.
The '-p' switch add pre-processing support during compilation
and the '-P' switch is for converting the Topology2.0
configuration file into the existing syntax.
Topology2.0 is a high level keyword extension on top of the existing ALSA
conf topology format designed to:
1) Simplify the ALSA conf topology definitions by providing high level
"classes" so topology designers need to write less config for common
object definitions.
2) Allow simple reuse of objects. Define once and reuse (like M4) with
the ability to alter objects configuration attributes from defaults.
3) Allow data type and value verification. This is not done today and
frequently crops up in FW bug reports.
Common Topology Classes
-----------------------
Topology today has some common classes that are often reused throughout
with slightly altered configurations. i.e. widgets (components),
pipelines, dais and controls.
Topology2.0 introduces the high level concept of reusable "class" like
definition for that can be used to create topology objects.
Common Topology Attributes
--------------------------
Topology defines a lot of attributes per object with different types
and constraints. Today there is no easy way to validate type or
constraints and this can lead to many hard to find problems in FW at
runtime.
A new keyword "DefineAttribute" has been added to define attribute
constraints such as min value, max value, enum_values etc. This
then allows alsatplg to validate each topology object attribute.
Topology Classes define the list of attributes that they use and
whether the attribute is mandatory, can be overridden by parent users
or is immutable. This also helps alsatplg emit the appropriate errors
for attribute misuse.
Class constructor attributes
----------------------------
Some attributes in the class definition are declared as constructor
attributes and these will be used to construct the name of the object.
For ex: for the host widget, the index and direction are constructor
attributes and the name for the widget is derived as follows:
host.1.playback or host.2.capture etc.
Attribute Inheritance:
----------------------
One of the key features of Topology2.0 is how the attribute values are
propagated from a parent object to a child object. For ex: a pipeline
object can pass down the pipeline_id attribute to all its widgets.
Inheritance is implicit when an object and its embedded child objects
have matching names for a attribute/argument. Attribute values
set explicitly in an object instance always has precedence over
the values inherited from the parent object.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1
1
1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In timer-based scheduling model, event waiting is just to measure time
elapse since no event is expected to occur. However, as a result to
applying commit e5e6a7838b, -ETIMEDOUT returns in the case and
the caller handles it as error. This results in disorder of the
scheduling model.
This commit fixes the regression so that the -ETIMEDOUT case is expected.
Reported-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/alsa-devel/687f9871-7484-1370-04d1-9c968e86f72b@linux.intel.com/
Fixes: e5e6a7838b ("axfer: return ETIMEDOUT when no event occurs after waiter expiration")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
card_select.c:129:28: warning: ‘%d’ directive writing between 1 and 10 bytes into a region of size 5 [-Wformat-overflow=]
129 | sprintf(buf, "sysdefault:%d", number);
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The /var/lib/alsa/card<NUMBER>.conf.d directories should be emptied
when the card is initialized. Implement this functionality directly
to alsactl.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
It may be possible that the controls are quickly added and
removed, thus the "hard" fail is not optimal here.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Terminating stream with CTRL-C will set in_aborting flag which is used to leave any
write/read loop on the ALSA device.
After ending the read/write loop aplay tries to drain the stream which is not required and can also lead to malfunctions:
-If user interrupts a blocked/non responsive PCM (e.g. usb uac2 gadget which does not consume data
due to stream stopped by host) it will successfully terminate the write loop but will hang again in drain call.
This would require to hit CTRL-C again to unblock which should be avoided.
Aplay currently anyhow allows signal handler to get invoked only once.
Signed-off-by: Andreas Pape <apape@de.adit-jv.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
These formats are sometimes advertised by drivers, e.g. SOF.
The format is 3 bytes packed in 32-bit container, with the MSB zeroed
out.
sample: 0x00123456
S24_LE format:
b0 56
b1 34
b2 12
b3 00
S24_BE format:
b0 00
b1 12
b2 34
b3 56
I only tested the S24_LE format with the SOF driver, S24_BE was added
for symmetry only.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit reduces test case for maximum number of samples per frame so
that overall time is shortened. The count of total iteration is also
reduced by one quarter.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This reverts commit e1551de8dd since tests
run for in-memory files now.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit reduces test case for maximum number of frame count so that
overall time is shortened. The count of total iteration is still the same.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The mapper test program writes audio data frame to files, and read
them from the files, then validate them. For the operations, usage of
any in-memory file is good to shorten time of overall operations.
This commit uses shm by memfd_create().
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In mapper test program, two set of file descriptors open to the same files
for container builder and parser contexts, however the same file descriptor
is available for the case.
This commit arranges to use the same file descriptor for the contexts.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
The container test program writes audio data frame to file, and read
them from the file, then validate them. For the operations, usage of
any in-memory file is good to shorten time of overall operations.
This commit uses shm via memfd_create(). As a result, overall time to
run is shorten one half of before, depending on machine environment.
I note that we can achieve the same result by using O_TMPFILE flag in
open(2) system call, however the implementation of O_TMPFILE is to add
i-node without name on underling file system, thus it has overhead
depending on implementation in each file system. On the other hand,
memfd_create() is directly relevant to shm and expected to be less
overhead.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In container test program, two file descriptors open to the same file
for builder and parser contexts, however the same file descriptor is
available for the case.
This commit arranges to use the same file descriptor for the contexts.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This is a preparation to use memfd_create(2) system call for test programs
of axfer. The system call was introduced at Linux kernel v3.17 and
relatively new.
For safe, this commit adds detection of memfd_create() in autotools side
so that application can handle the case not to detect.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit closes file descriptor outside of container module so
that maintenance of lifetime for the descriptor is delegated to container
user.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Internal container module operates file descriptor to media file. For
this purpose, the structure has fd member and any file operation is done
internally. However, the case to use special file descriptor such as
memfd requires to maintain file descriptor externally.
This commit opens file descriptor outside of container module. The
internal APIs to initialize container get an argument for the file
descriptor instead of file path.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit unifies duplicated code to allocate for container structure.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit arranges assignment to fd member after checking file
descriptor.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Current implementation sets stdio member in a condition branch, however
it's convenient to set it always regardless of any condition.
This commit arranges assignment to the member.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
In internal container module, any file descriptor is expected as
non-blocking mode. Current implementation distinguish the case of
standard input and output from the case to open actual file since
O_NONBLOCK is used for the latter case. However, in both cases,
fcntl(2) is available to set non-blocking mode to the file descriptor.
This commit arranges to use fcntl(2) for both cases.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Take the card iterator idea from the monitor code and
use it for all card loops. It reduces the code duplications
and makes things easy to review.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Also remove extra snd_config_update_free_global() call for dump-state.
There's a global call in the main() function.
Signed-off-by: Jaroslav Kysela <perex@perex.cz>