Commit graph

1944 commits

Author SHA1 Message Date
Jaroslav Kysela
1a32420577 alsatplg: use standard include/asoundlib.h instead direct headers
BugLink: https://github.com/alsa-project/alsa-lib/pull/169
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-09-03 08:49:03 +02:00
folkert van heusden
9a8fcec5aa amidi: add timestamp option for dump
Added -T / --timestamp option (with parameter "realtime", "monotonic" or "raw") which prints
a timestamp before each received message when using the --dump mode.

Fixes: https://github.com/alsa-project/alsa-utils/pull/108
Signed-off-by: Folkert van Heusden <mail@vanheusden.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-24 12:05:52 +02:00
Takashi Iwai
dea51861a8 aplay: Fix out-of-bound access in stereo VU meter drawing
The left channel drawing of a stereo VU meter has a bug where it may
access a negative array index.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-24 10:06:05 +02:00
Takashi Iwai
2efe124c31 aplay: Handle upper bound in peak calculations
Make sure that the calculated max_peak[] won't go beyond the sample
max resolution.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-24 10:00:26 +02:00
Takashi Iwai
d9b3133815 aplay: Don't pass most negative integer to abs() in peak calculations
The return value from abs() for the most negative integer is
undefined.  Cap it properly for the 32bit sample handling.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-24 09:58:29 +02:00
Takashi Iwai
5c4bf63a94 aplay: Handle 16bit sample negative overflow in peak calculations
The handling of 16bit samples in the peak calculations has a bug when
a sample with 0x8000 is passed.  As abs() treats 32bit int, it returns
0x8000.  And yet the code stores back into 16bit value again.

To fix that overflow, use 32bit value (i.e. val instead of sval) for
the further calculations.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-24 09:53:53 +02:00
Takashi Iwai
0ea7bfea83 aplay: Fix conversion of unsigned samples in peak calculation
The XOR with the mask has to be applied before calculating abs value.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-08-24 09:51:39 +02:00
Yunhao Tian
ce05208085 alsaloop: Support "Capture Pitch 1000000" rate shift
In Linux 5.14, a new feedback mechanism for USB Audio
Gadget is introduced (commit e89bb428), along with a
new control element "Capture Pitch 1000000". This patch
adds support for this feature. Note that this property
seems to be the reverse of PCM Rate Shift, so we have
to take reciprocal of pitch.

Signed-off-by: Yunhao Tian <t123yh@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:55:36 +02:00
braph
2b9bfacca7 Added configuration information to manual page
Added sections FILES and CONFIGURATION.
Removed section BUGS, because the described terminal issues have been fixed.

Signed-off-by: braph <braph93@gmx.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:50:47 +02:00
Ranjani Sridharan
a1c2275090 topology:pre-process-object: merge object config with parent object config
An object can be declared within a class definition as follows:

Class.Pipeline.volume-playback {
	Object.Widget.pga.0 {
		ramp_step_ms 250
	}
}

While instantiating the volume-pipeline class, the pga object
could be modified as follows:

Object.Pipeline.volume-playback.0 {
	Object.Widget.pga.0 {
		format "s24le"
	}
}

When building the pga.0 object in the class definition, merge
the attributes declared in the volume-playback.0 object to create
a new config as follows to make sure that all attributes are
set for the pga object.

	Object.Widget.pga.0 {
		ramp_step_ms 250
                format "s24le"
        }

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
814dc3b19e pre-process-object: set tlv name if config exists already
Do not create TLV config if it exists already. Just
set the string value with the name name.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
b13a940618 pre-process-dapm: add data section for kcontrols
Allow support for adding data section for kcontrols.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
3d55a99ccd topology: pre-processor: fix typo in pre_process_config()
Fix typo in config variable name. Should be n2 instead of n.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
c1f0ec46b4 topology: pre-process-object: dont create if section already exists
Skip creating section when it exists already.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
3c81766242 pre-process-object: skip parent update if parent is NULL
Nothing to do for top-level objects with no parent.
Also, add access to the bytes control template.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
268f599d24 pre-process-dapm: fix source and sink for DAPM routes
Switch source and sink widgets in the DAPM route.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Ranjani Sridharan
48ebb1dc0c topology: pre-process-object: Add support for pre-process objects with no builder
Some objects just need tobe processed to add their attributes
to the private data section of their parent objects.
An example of this would be the pdm_config objects for
DMIC DAI's. Each pdm_config object's attributes need
to be added as separate arrays in the DAI object's
private data.

Modify the signature of tplg_add_object_data() to pass
the array_name parameter when multiple objects of the
same type in the same parent are processed.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Chao Song
b848786f42 topology: pre-process-dapm: update automatic attributes for buffer
Add the function to compute the value for the
"size" automatic attribute in the buffer objects.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Chao Song
88c6dd6cf4 topology: pre-process-object: add support for updating automatic attributes
Classes definitions in Topology2.0 can have attributes
qualified with the "automatic" constraint. Values for
these attributes will be calculated by the compiler.
This patch provides a generic method for defining automatic
attributes computation logic for different classes.

To update automatic attributes for a class, add an item
in object_build_map with auto_attr_updater defined, and then
add updating logic in the custom auto_attr_updater function.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-23 16:49:56 +02:00
Jaroslav Kysela
5471a0b285 aseqnet: add ipv6 support
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-09 20:24:44 +02:00
Jaroslav Kysela
c8e5762750 aseqnet: use getaddrinfo() instead obsolete gethostbyname()
- modernize code (preparation for IPv6)

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-08-09 18:11:37 +02:00
Jaroslav Kysela
f076518254 alsatplg: do not do NULL check for string arrays
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-18 10:15:46 +02:00
Jaroslav Kysela
0b8d2dfdcc alsatplg: fix memory-leak in tplg_construct_object_name()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-18 10:11:34 +02:00
Jaroslav Kysela
9e59c928af Release v1.2.5.1
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 12:28:46 +02:00
Jaroslav Kysela
fc7500c3c7 arecord: Inform users when 8-bit sampling is used on tty
When we reverted 0c5948e ("aplay: try to use 16-bit format to
increase capture quality"), we should also handle the original
problem somehow. This code shows a warning with a hint to
the right parameter.

Fixes: https://github.com/alsa-project/alsa-utils/issues/96
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 12:25:10 +02:00
Jaroslav Kysela
f35b66d8f1 Revert "aplay: try to use 16-bit format to increase capture quality"
This reverts commit 0c5948e98a.

Link: https://github.com/alsa-project/alsa-utils/issues/96
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 12:02:51 +02:00
Andrea Piras
0e21f4d864 added an option to aseqnet to optionally set the midi process name
This option allows to run multiple instances of aseqnet without having
to double check the assigned port number, since each one can get spawned
with a unique name.

Fixes: https://github.com/alsa-project/alsa-utils/pull/95
Signed-off-by: Andrea Piras <andrea.piras.85@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-14 12:00:44 +02:00
Andreas Müller
6a0d13ddb2 utils.c: Include limits.h explicitly to fix build on musl
Fixes:
| ../../alsa-utils-1.2.5/alsactl/utils.c: In function 'snd_card_clean_cfgdir':
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: error: 'PATH_MAX' undeclared (first use in this function)
|   309 |         char path[PATH_MAX];
|       |                   ^~~~~~~~
| ../../alsa-utils-1.2.5/alsactl/utils.c:309:19: note: each undeclared identifier is reported only once for each function it appears in

Fixes: https://github.com/alsa-project/alsa-utils/pull/92
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 19:13:47 +02:00
Sören Tempel
6018c2014a alsactl: load_state: Only delete config if one was loaded
If load_configuration fails with open_failed == true, load_state will
jump to the out label without config being initialized and pass this
uninitialized config value to snd_config_delete. This commit fixes this
issue by initializing config with NULL and checking if it is non-null
before invoking snd_config_delete.

Fixes: https://github.com/alsa-project/alsa-utils/pull/94
Fixes: f138117 ("alsactl: load_state() - initialize config variable for the open_failed case")
BugLink: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 19:06:19 +02:00
Jaroslav Kysela
f138117a45 alsactl: load_state() - initialize config variable for the open_failed case
Fixes: https://github.com/alsa-project/alsa-utils/issues/93
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-07 17:21:58 +02:00
Jaroslav Kysela
c58f981e15 topology: fix few coverity detected defects
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:19:41 +02:00
Jaroslav Kysela
74ad91245f axfer: fix wrong calloc() item size in allocate_containers()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:12:06 +02:00
Jaroslav Kysela
cd2f779b8d alsactl: fix lock_fd unlock in load_configuration() - error path
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:08:18 +02:00
Jaroslav Kysela
646d6ff094 alsactl: state - fix ‘item’ may be used uninitialized gcc warning
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:04:50 +02:00
Jaroslav Kysela
2bc595e7bd alsactl: check for error values from snd_config_get...()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 10:04:00 +02:00
Jaroslav Kysela
511dd7a597 alsactl: init() - return error value from snd_card_iterator_sinit() call
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 09:56:20 +02:00
Jaroslav Kysela
d6d566a9ee alsactl: return error value in dump_config_tree()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-04 09:53:56 +02:00
Chao Song
3d7a6facd9 topology: fix potential null pointer from strchr
This patch adds check to the return pointer from strchr,
because it may be null and cause segment fault, if component
is not properly constructed.

Fixes: https://github.com/alsa-project/alsa-utils/pull/91
Signed-off-by: Chao Song <chao.song@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-02 16:55:57 +02:00
Jaroslav Kysela
78212445de alsactl: fix the nested iteration
There may be nested iterations for hw: card names.
Handle this card name in snd_card_iterator_sinit().

BugLink: https://github.com/alsa-project/alsa-lib/issues/142
Fixes: eefc2c6 ("alsactl: use card iterator functions for all card loops")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-06-01 17:49:27 +02:00
Jaroslav Kysela
ef62ab34fc Release v1.2.5
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-27 19:18:36 +02:00
Jaroslav Kysela
62f97bd3a7 amixer: Makefile - add volume_mapping.h to noinst_HEADERS
Fixes: dc20c4b ("amixer: add the volume_mapping.h link")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:58:53 +02:00
Jaroslav Kysela
dc20c4b512 amixer: add the volume_mapping.h link
Fixes: 75e644d ("amixer: link volume_mapping.c from alsamixer to amixer")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:48:00 +02:00
Jaroslav Kysela
8037d4812e topology: some whitespace fixups
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:36:46 +02:00
Ranjani Sridharan
1832f6f254 topology: pre-process-object: add support for prepocessing child objects
Add support for processing object instances embedded
within objects and classes. For example:
		Object.Control.mixer."0" {
			#Channel register and shift for Front Left/Right
			Object.Base.channel."fl" {
				shift	0
			}
			Object.Base.channel."fr" {
			}

			Object.Base.tlv."vtlv_m64s2" {
				Object.Base.scale."m64s2" {
					mute	1
				}
			}

			Object.Base.ops."ctl" {
				info 	"volsw"
				#256 binds the mixer control to volume get/put handlers
				get 	256
				put 	256
			}
		}

and pga class embeds the mixer objects as follows:
Class.Widget."pga" {
...
Object.Control {
		mixer."0" {...}
		mixer."1" {...}
}

The pre-processor starts with the top-pevel PGA widget object
and processes the mixer objects in the class definition.
This will recursively pre-processes its child objects to add the channels,
tlv and ops.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
df6cfa77e3 topology: pre-process-dai: add support for pcm_caps objects
Add support for processing pcm_caps objects.
For ex:

Object.PCM.pcm."0" {
	name	"Port0"
	direction	"duplex"
	Object.Base.fe_dai."Port 0" {}
	Object.PCM.pcm_caps."playback" {
		name "Port0 Playback"
	}
	Object.PCM.pcm_caps."capture" {
		name "Port0 Capture"
	}
}

Would convert into:
SectionPCMCapabilities {
        'Port0 Playback' {
                formats 'S32_LE,S24_LE,S16_LE'
                rate_min 48000
                rate_max 48000
                channels_min 2
                channels_max 2
                periods_min 2
                periods_max 16
                period_size_min 192
                period_size_max 16384
                buffer_size_min 65536
                buffer_size_max 65536
        }
        'Port0 Capture' {
                formats 'S32_LE,S24_LE,S16_LE'
                rate_min 48000
                rate_max 48000
                channels_min 2
                channels_max 2
                periods_min 2
                periods_max 16
                period_size_min 192
                period_size_max 16384
                buffer_size_min 65536
                buffer_size_max 65536
        }
}

and the SectionPCM updated as follows:
SectionPCM {
        Port0 {
                id 0
                dai {
                        'Port 0' {
                                id 0
                        }
                }
                pcm {
                        playback {
                                capabilities 'Port0 Playback'
                        }
                        capture {
                                capabilities 'Port0 Capture'
                        }
                }
        }
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
3719c80a4d topology: pre-process-dai: add support for fe_dai objects
Add support for fe_dai objects:

For ex:

Object.PCM.pcm."0" {
	name	"Port0"
	direction	"duplex"
	Object.Base.fe_dai."Port 0" {}
}

will be converted to update the SectionPCM as follows:

SectionPCM {
        Port0 {
                id 0
                dai {
                        'Port 0' {
				id 0
			}
                }
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
4bc386bb71 topology: pre-process-dai: add support for hwcfg objects
Add supprt for hwcfg objects:
For ex:
Object.Base.hw_config."SSP0 hw_config 0" {
		id		0
		mclk_freq	24000000
		bclk_freq	4800000
		tdm_slot_width	25
	}

would get converted to:

SectionHWConfig {
        'SSP0 hw_config 0' {
                id 0
                format I2S
                bclk codec_consumer
                bclk_freq 4800000
                fsync codec_consumer
                fsync_freq 48000
                mclk codec_mclk_in
                mclk_freq 24000000
                tdm_slots 2
                tdm_slot_width 25
                tx_slots 3
                rx_slots 3
        }
}

and the corresponding SectionBE will be updated with the hwcfgs reference as:

	hw_configs [
		'SSP0 hw_config 0'
        ]

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
b0be235024 topology: pre-process-dai: add support for PCM and BE DAI objects
Add support for pre-processing PCM and BE DAI objects:

Object.PCM.pcm."0" {
	name	"Port0"
	direction	"duplex"
}

will be converted to:

SectionPCM.'Port0' {}

The capabilities and dai configs will be added those objects are pre-processed.

An ex of DAI object would be:
Object.Dai.SSP."0" {
	direction		"duplex"
	stream_name		"NoCodec-0"
	id 			0
	default_hw_conf_id	0
	format			"s24le"
	quirks			"lbm_mode"
	sample_bits		24
}

converted to:
SectionBE {
        'SSP.0.duplex' {
                id 0
                stream_name NoCodec-0
                default_hw_conf_id 0
                data [
                        'SSP.0.duplex.sof_tkn_intel_ssp.word'
                        'SSP.0.duplex.sof_tkn_dai.word'
                        'SSP.0.duplex.sof_tkn_dai.string'
                        'SSP.0.duplex.sof_tkn_intel_ssp.short'
                ]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
758e4dba81 topology: pre-process-dapm: add support for route objects
DAPM route objects such as:
Object.Base.route."1" {
	source	"dai.SSP.0.dai.capture"
	sink	"buffer.2.1"
}

will be converted to:

SectionGraph."Endpoint.route.1" {
	index 0
	lines [
		"dai.SSP.0.capture, , buffer.2.1"
	]
}

If the source/sink names are references to objects within a parent pipeline
object, the index attribute value can be skipped and it will be
populated when the object is pre-processed

Object.Pipeline.volume-capture."1" {
	Object.Base.route."1" {
		source	"pga..0"
		sink	"buffer..0"
	}
}

The reference pga..0 will need to be resolved to
get the widget name pga.1.0 and buffer..0 will
be resolved to buffer.1.0 before creating the SectionGraph as follows:

SectionGraph."volume-capture.1.route.1" {
	index 2
	lines [
		"pga.1.0, , buffer.1.0"
	]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00
Ranjani Sridharan
79033ceae4 topology: pre-process-dapm: add support for widget control objects
Add support for pre-processing mixer and byte control objects.
For ex: a pga widget with a mixer control as follows:

Object.pga"0" {
	...
	mixer.0 {
		index 2
		max 32
		name "2 MasterPlaybackControl"
			Object.Base.channel."fl" {
				shift	0
			}
			Object.Base.channel."fr" {
			}

			Object.Base.tlv."vtlv_m64s2" {
				Object.Base.scale."m64s2" {
					mute	1
				}
			}

			Object.Base.ops."ctl" {
				info 	"volsw"
				#256 binds the mixer control to volume get/put handlers
				get 	256
				put 	256
			}

		access [
			read_write
			tlv_read
		]
	}
}

Would be converted to:

SectionControlMixer.'2 Master Playback Volume' {
	index 2
	max 32
	channel {
		fl {
			reg 1
		}
		fr {
			reg 1
			shift 1
		}
	}
	tlv	"vtlv_m64s2"
	ops.0 {
		info volsw
		get 256
		put 256
	}
	access [
		read_write
		tlv_read
	]
}

and the SectionWidget for pga.2.0 would be updated to add the mixer references as follows:
SectionWidget.'pga.2.0' {
...
	mixer [
		"2 Master Playback Volume"
	]
}

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:51 +02:00