Commit graph

164 commits

Author SHA1 Message Date
Jaroslav Kysela
75e644df81 amixer: link volume_mapping.c from alsamixer to amixer
... otherwise automake complains

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-25 18:26:36 +02:00
Jaroslav Kysela
bc80344625 amixer: don't show help on argument parsing error
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-05-10 16:32:01 +02:00
Jaroslav Kysela
0a6b63a2c4 amixer/alsamixer: use sysdefault:<CARD> devices instead hw:<CARD>
The alsa-lib 1.2.5 introduced a new scheme for the default control
devices.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-04-06 20:25:58 +02:00
Jaroslav Kysela
204ae460a1 amixer: cleanups for valgrind
Call snd_config_update_free_global() to check the memory
leaks and wrong memory access.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-30 13:32:34 +02:00
Jaroslav Kysela
69276d4a6c amixer: print error when snd_hctl_handle_events() fails
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>
2021-03-29 11:36:19 +02:00
Matt Campbell
c47e93fa7e amixer: Expand on channel docs in man page
Add missing channel params to the amixer man page. Also call out that
the channel param must come before the value to take effect.

signed-off-by: Matthew Campbell <mcampbell@izotope.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2021-03-05 21:14:12 +01:00
Jaroslav Kysela
640d01319b amixer: retype to double in convert_prange1() like in convert_prange()
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-05 17:59:31 +02:00
Jaroslav Kysela
361734165e amixer: improve the raw percentual volume rounding
In commit "ae9ddeb63443cc2c46e0f0b915466cca0f800372" the rint() was
changed to ceil(). Revert it back. The rint() rounding is more precise
for most cases.

Also, handle the special case where the percentual value is greather
then zero. Set the min + 1 value in this case.

At last, fix the return value in convert_prange() when range is zero.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2020-06-05 17:01:04 +02:00
Michael Forney
646b3b1c0b Use %lli for long long in printf
The `L` length modifier only applies to floating-point conversion
specifiers, and `ll` is used for `long long` integers.

Although glibc accepts %Li, musl does not and returns EINVAL.

Signed-off-by: Michael Forney <mforney@mforney.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2020-02-10 12:39:17 +01:00
Rosen Penev
80fd81f4a8 treewide: Fix printf formats
Found with cppcheck

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-20 19:46:17 +01:00
Rosen Penev
5e6df5ae4b treewide: sys/poll to poll
Fixes warning on musl:

warning redirecting incorrect #include <sys/poll.h> to <poll.h>

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-20 19:44:02 +01:00
Jaroslav Kysela
5828279b5d amixer: do not double LF for container type
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-10-31 17:33:00 +01:00
Milton Vandersloot
551cc37fc6 amixer: define _GNU_SOURCE to get exp10
Get rid of a warning about implicit declaration of exp10, which is
behind _GNU_SOURCE as a non-standard feature. The same problem was fixed
for alsamixer in commit 116488e5f2.

Signed-off-by: Milton Vandersloot <miltonvandersloot@fake-box.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-04-06 08:58:49 +02:00
Jaroslav Kysela
b1e3d945b7 Change FSF address (Franklin Street)
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2017-11-14 14:28:53 +01:00
Vinod Koul
18d5f52a61 amixer: skip showing asoc tlv byte controls
ASoC TLV Byte controls are very large size controls so we should add new
options for these. So skip dumping contents for these.

$amixer -c0 cget numid=16
numid=16,iface=MIXER,name='mdl params'
  ; type=BYTES,access=-----RW-,values=30336
  ; ASoC TLV Byte control, skipping bytes dump

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-01-29 07:26:56 +01:00
Takashi Sakamoto
f3abdeea00 amixer: expand local storage for item name according to kernel code
According to kernel code (snd_ctl_elem_init_enum_names() in
sound/core/control.c), the maximum length of item name is 63 characters
(+ 1 terminator = 64 bytes). But current amixer implementation
uses 40 bytes. This causes name truncation and fail to operation.

This commit fixes this bug by expanding the length of local variables.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-09 08:11:05 +02:00
Peter Meerwald
1a19ec1538 amixer: Don't set only the first item in sset_enum()
Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-05 11:05:44 +01:00
Takashi Iwai
088593c039 amixer: Parse the value more strictly
So far amixer allows some unexpected suffix and assumes as a raw
absolute value without returning an error.  This is rather dangerous,
e.g. user might not notice that a completely wrong value was set when
the command line included a typo.

This patch makes the parser a bit more strict: it doesn't allow any
longer invalid suffixes, instead either returns an error or skips the
invalid value, depending on the operation mode.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-23 10:04:24 +01:00
Takashi Iwai
45a334e71c amixer: Make "dB" case-insensitive in set commands
We don't have to be necessarily too strict about case-sensitivity of
"dB" suffix used in set commands.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-11-23 09:45:44 +01:00
Jaroslav Kysela
0a6c9e80f7 Makefiles - use AM_CPPFLAGS instead INCLUDES
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2014-05-07 10:55:59 +02:00
Anssi Hannula
f1e991e813 amixer: fix indentation when printing container TLV contents
decode_tlv() adds indentation in the beginning, with the expectation
that the TLV will be printed on the line afterwards in a switch-case.

However, in the case of a container TLV the switch-case simply adds
another level of indentation and calls decode_tlv() for the inner TLVs.
This causes the first inner TLV to be printed with too much indentation
and double '|'.

Fix that by printing "container" and a newline for container TLVs, so
that the result is as follows:
  : values=0,0,0,0,0,0,0,0
  | container
    | chmap-variable=FL,FR
    | chmap-variable=FL,FR,LFE
    | chmap-variable=FL,FR,FC

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-02 17:36:02 +02:00
Anssi Hannula
180283e230 amixer: actually print all TLVs in a container TLV
Due to a wrong indexing of tlv[] decode_tlv() always skips to the end of
the container TLV since the used tlv[1] contains the container TLV size
instead of the intended element size.

This causes, for example, only the first HDMI channel map TLV to be
shown.

Fix the indexing to actually use the element size.

Signed-off-by: Anssi Hannula <anssi.hannula@iki.fi>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-10-01 12:23:45 +02:00
David Henningsson
9fe90a020c amixer: Print TLV of channel map controls
Previously these were written as "unk-25..." which wasn't very user friendly.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-06-14 13:38:23 +02:00
Jaroslav Kysela
c80a38dbf5 amixer: fix print_dB for -0.99 .. -0.01 range
The first number is 0 when input dB (hundreds) is in range -99 .. -1 .
The printed number was positive in this case. This patch fixes this issue.

Reported-by: Tom Becker <GTBecker@RighTime.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-05-28 08:43:30 +02:00
Jaroslav Kysela
d61924fd24 amixer: Fix the hctl elem search bug
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-05-27 16:40:26 +02:00
Jordi Mallach
093a371a27 Several formatting fixes for manpages.
Fix many occurrences of unescaped “-”.
Fix minor English issue.

Signed-off-by: Jordi Mallach <jordi@debian.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-05-16 10:38:13 +02:00
Jaroslav Kysela
e2eab09c1d amixer: Use the alsa-lib functions for id print and parse and value parse
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2013-04-09 18:38:58 +02:00
Takashi Iwai
bfcb26f9f7 amixer: Fix dB value outputs in amixer contents
Add missing cast to signed int for DB_MINMAX* types.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-31 17:47:50 +01:00
Takashi Iwai
d6da86117b amixer: Fix parsing container TLV entries
Fix the wrong calculation of the size of a container TLV entry, which
resulted in "TLV size error" messages.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-26 16:16:16 +01:00
Clemens Ladisch
da1c24a24c amixer: fix rounding of relative changes
When doing control changes by a relative amount, amixer used the wrong
rounding direction, which would make it possible to stay at the same raw
value if the step was not big enough to reach the next value.

Reported-by: Honza Javorek <jan.javorek@gmail.com>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2012-11-13 21:54:20 +01:00
Takashi Iwai
8824d0824d amixer, alsamixer: Add description of volume-mapping
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-19 16:05:06 +01:00
Takashi Iwai
a2b66855e6 amixer: Add the support for mapped volumes like alsamixer
When -M option is given, amixer handles the volumes in percent unit
with the mapping more intuitive to human ears just like in alsamixer.

The -R option is to take the raw value as the volume percentage.
This mode is still used as default.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-03-12 10:56:22 +01:00
Lars-Peter Clausen
8709ffe841 alsa-utils: amixer: Fix SND_CTL_TLVT_DB_RANGE handling
Current support for handling SND_CTL_TLVT_DB_RANGE in amixer is completely
broken. This patch fixes it.

Reported-by: Daniel Mack <zonque@gmail.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-16 14:57:27 +02:00
Jaroslav Kysela
87c58b59b5 amixer: fix parsing of control ID name
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-10-05 10:02:45 +02:00
Jaroslav Kysela
f45aa72cd6 amixer: add support for TLV dB minmax types
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2010-02-10 11:52:53 +01:00
Clemens Ladisch
cdc496addb amixer: fix display of unreadable control elements
When an element is marked as not readble, do not try to read it and then
complain about the error, but just ignore it.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
2010-02-01 13:22:39 +01:00
Diego E. 'Flameeyes' Pettenò
6232f1c96c Make some static tables and strings constants.
By doing this we move them from the .data section to .rodata setion,
or from .data.rel to .data.rel.ro.

The .rodata section is mapped directly from the on-disk file, which is
always a save, while .data.rel.ro is mapped directly when using
prelink, which is a save in a lot of cases.

Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
2008-11-21 13:10:02 +01:00
Diego E. 'Flameeyes' Pettenò
ca1ea1e904 Mark static the functions not used outside their unit.
This way the compiler can assume more information about their
interface for optimisation.

Signed-off-by: Diego E. 'Flameeyes' Pettenò <flameeyes@gmail.com>
2008-11-21 13:09:56 +01:00
Jaroslav Kysela
ec73719ec6 amixer - fixed TLV dBscale and added dBrange parsing
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2008-08-14 14:57:43 +02:00
Jaroslav Kysela
48de580a7b Changed Jaroslav Kysela's e-mail from perex@suse.cz to perex@perex.cz 2007-10-15 10:25:17 +02:00
Takashi Iwai
4b16370c01 amixer - Allow to pass enum item string for cset, too
cset accepts only integer values as indices, so far, but it's a bit
unfriendly.  Now it accepts the item name as a string argument, too.
The index can be given using numbers as fallback.
2007-07-31 17:29:45 +02:00
Takashi Iwai
fea8dbf020 Ignore errors with -s option
Ignore non-fatal errors when stdin is parsed with -s option.
2007-07-24 15:19:34 +02:00
Jaroslav Kysela
8d0fb15b2b amixer/alsamixer - updated go scripts for debugging 2007-07-11 10:12:24 +02:00
Takashi Iwai
50d240e688 amixer - Fix selection of enum items
The item names with channel specifier cannot be chosen correctly
via amixer sset.  For example, 'Front Mic' is handled as 'Mic' since
the channel specificier 'Front' is omitted.

The idea of channel specifier is basically non-sense for enum items,
and this also makes the code very messy.

The patch fixes the behavior of enum items and gives the code clean-up
for sset command.
2007-07-09 16:37:35 +02:00
Takashi Iwai
3f17db2ef5 amixer - show iec958 status bits in contents command
Show first 4 bytes of iec958 status bits for elements with
SND_CTL_ELEM_TYPE_IEC958 in contents command.
2007-04-05 17:23:42 +02:00
James Courtier-Dutton
fb219cacb6 Implement Playback/Capture enum. 2006-10-13 22:25:33 +01:00
Jaroslav Kysela
6d59cea271 amixer - remove beep on errors in arguments
See bug#1247
2006-10-04 10:21:29 +02:00
Jaroslav Kysela
a70208290b amixer: sset - check if command is valid
See bug#532
2006-10-04 09:47:41 +02:00
Takashi Iwai
b4897f7856 Add linear-volume handling in amixer
Added the handling of linear-volume in amixer TLV decoder.
2006-08-28 13:28:46 +02:00
Takashi Iwai
ae9ddeb634 Add handling of dB to amixer
Added the dB value handling to amixer sset command.
Also, simplify the parser code.

Updated man page for dB suffix and some examples.
2006-08-25 12:00:14 +02:00