Commit graph

367 commits

Author SHA1 Message Date
Colin Guthrie
90634d6028 alsa-mixer: Whoops, forgot to git-add this in a previous. 2011-06-26 14:51:31 +01:00
Colin Guthrie
0698d223a6 alsa-mixer: Add UAC1.0 Sennheiser Dongle to the usb-headset profile.
Reported by Sean McNamara
2011-06-26 14:22:06 +01:00
Colin Guthrie
9352898b72 alsa-mixer: Add an mixer profile exception for a BT Agile handset 2011-06-25 13:02:02 +01:00
David Henningsson
1c38b5d478 alsa-mixer: Add workaround for some USB headsets
This is a workaround - these usb headsets have one output volume
control only, labeled "Speaker". This causes the default profile
set to not control the volume at all, which is a bug. Workaround
that by creating a separate profile set.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-06-25 12:53:44 +01:00
Maarten Bosmans
dd9265ac78 Remove unnecessary #includes 2011-06-22 23:12:20 +01:00
Juho Hämäläinen
4eb513cbf4 alsa-mixer: select nearest alsa volume step in sync-volume mode 2011-06-22 22:45:27 +01:00
Colin Guthrie
1e7c4dd3e6 alsa-mixer: When setting hw volume, always round up with playback and down with capture.
The previous logic in ade0a6f884
does not work with for input volumes.

This was discussed on the mailing list:

https://tango.0pointer.de/pipermail/pulseaudio-discuss/2011-May/010091.html

This approach can introduce a problem when setting the volumes
for sources. What follows is Tanu Kaskinen's analysis:

[quote]
I'll quote the log:

D: protocol-native.c: Client pavucontrol changes volume of source alsa_input.pci-0000_00_1b.0.analog-stereo.
D: alsa-source.c: Requested volume: 0:  45% 1:  45%
D: alsa-source.c:            in dB: 0: -20.71 dB 1: -20.71 dB
D: alsa-source.c: Got hardware volume: 0:  45% 1:  45%
D: alsa-source.c:               in dB: 0: -21.00 dB 1: -21.00 dB
D: alsa-source.c: Calculated software volume: 0: 101% 1: 101% (accurate-enough=no)
D: alsa-source.c:                      in dB: 0: 0.29 dB 1: 0.29 dB
D: source.c: Volume going up to 29273 at 270475970821
D: source.c: Volume change to 29273 at 270475970821 was written 34 usec late
D: alsa-source.c: Written HW volume did not match with the request: 0: 45% 1:  45% (request) != 0:  42% 1:  42%
D: alsa-source.c:                                            in dB: 0: -21.00 dB 1: -21.00 dB (request) != 0: -22.50 dB 1: -22.50 dB

Looking at the last line, the requested volume seems to hit exactly the
right step (-21.00dB), but for some reason Alsa decides to choose
something else. I'm pretty sure that this happens because of rounding
errors. In the first phase we ask Alsa what dB value we should set, and
it returns -21.00 dB. The value is given as a long int, but we convert
that to pa_cvolume. Then when we set the volume, we convert the
pa_cvolume value back to a long integer. At this point I believe it gets
converted to -2101. This is not visible in the debug message for some
reason - the rounding algorithm must be different from what was used
with the pa_cvolume -> long conversion.
[/quote]

The commit after this contains a patch that addresses this issue.
2011-06-22 22:45:27 +01:00
Colin Guthrie
d1a628855d alsa: Remove unneeded include 2011-06-22 22:45:27 +01:00
Colin Guthrie
dffc4d18d3 capture: Implement per-stream volume control for capture streams.
This piggy backs onto the previous changes for protocol 22 and
thus does not bump the version. This and the previous commits should be
seen as mostly atomic. Apologies for any bisecting issues this causes
(although I would expect these to be minimal)
2011-06-22 22:45:27 +01:00
Colin Guthrie
dc6c272625 alsa-sink: Some trivial tidyups
Mostly typo fixes but also a change to make a function relating
to sink inputs use more generic variable names.
2011-06-22 21:53:19 +01:00
Lu Guanqun
6efa693fe7 alsa-mixer: Fix the assumption that volume is always positive
Add a variable to track whether the actual volume is set or not.
Suppose this:
	min volume: -126	max volume: 0
then when user wants to set some constant volume to -10, it would fail.

While the alsa values are typically positive, some values are "funky"
and have negative values. It is desirable to fix this at the alsa
level so that the numbers are positive, but it's not technically
invalid, and thus we have to support it.

Discussed here:
http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/9832
and
http://thread.gmane.org/gmane.linux.alsa.devel/85459
2011-05-30 11:22:21 +01:00
Arun Raghavan
4fb68b91ac core: Factor out passthrough checks into their own functions
Since we currently have two mechanisms to signal a passthrough
connection (non-PCM format or PA_SINK_INPUT_PASSTHROUGH flag), we move
all the related checks into functions and use those everywhere.

This makes things more consistent, and should we decide to get rid of
the flag, we only need to change pa_sink_input_*_is_passthrough()
accordingly.
2011-05-02 11:55:39 +05:30
Arun Raghavan
49b10ba694 alsa: Reconfigure sink sample rate for passthrough inputs
When a passthrough sink-input is added, we need to reconfigure the
sink's sample rate since no resampling occurs. We revert to the original
rate when the passthrough sink-input is removed.
2011-05-02 11:55:38 +05:30
Arun Raghavan
20f1fa17be alsa-mixer: Remove passthrough profiles
These aren't used any more - we handle passthrough mode in the iec958*
profiles now.
2011-05-02 11:55:38 +05:30
Arun Raghavan
71ec9577cf sink: Remove PASSTHROUGH flag
This removes the passthrough flag from sinks since we will drop
exclusively passthrough sinks in favour of providing a list of formats
supported by each sink. We can still determine whether a sink is in
passthrough mode by checking if any non-PCM streams are attached to it.
2011-05-02 11:54:48 +05:30
Tanu Kaskinen
b14f0d79f6 alsa: Fix log output to inform about positive base volumes correctly.
This fix was done for _set_port_cb() already, but the first fix didn't fix
setup_mixer(). Now that's done too.
2011-04-04 13:34:18 +01:00
Tanu Kaskinen
fce93eb625 alsa-mixer: Check that the kernel driver returns consistent limits with both snd_mixer_selem_get_*_dB_range() and _ask_*_vol_dB().
The check is inspired by a driver that returned higher dB limit from
snd_mixer_selem_get_playback_dB_range() than what _ask_playback_vol_dB()
returned at maximum integer volume.
2011-03-30 09:23:15 +01:00
Tanu Kaskinen
44623a347d alsa-mixer: Make sure that SND_MIXER_SCHN_UNKNOWN isn't used when indexing e->masks.
SND_MIXER_SCHN_UNKNOWN is defined as -1, so that's not a good array index...
2011-03-30 09:21:58 +01:00
Tanu Kaskinen
5270785238 alsa-mixer: Make probing elements with more than two volume channels fail.
This is just a quick hack to prevent array overflow. Correct fix would be to
implement support for more channels.
2011-03-30 09:20:56 +01:00
Tanu Kaskinen
77da2c4bcf alsa-mixer: Get rid of a compiler warning.
On 64-bit systems LONG_MAX is greater than the largest possible value of a
uint32_t variable, which caused the compiler to warn about a comparison that is
always false. On 32-bit systems pa_atou() can return a value that will overflow
when assigned to e->volume_limit, which has type long, so the comparison was
necessary.

This dilemma is resolved by using pa_atol() instead of pa_atou().
2011-03-28 09:52:55 +01:00
Maarten Bosmans
93348331bb Move compile-time checks around pa_run_from_build_tree to core-util
To make the code cleaner and have the checks all in one place.
2011-03-24 09:12:27 +00:00
Tanu Kaskinen
8b8f62047b alsa-mixer: Refactoring: merge element_mute_volume(), element_zero_volume() and element_apply_constant_volume() into a single function. 2011-03-20 12:42:27 +00:00
Tanu Kaskinen
e1c289cc6b alsa-mixer: Implement constant volume.
This change makes it possible to configure an arbitrary constant volume for a
volume element in the path configuration, which is applied when the path is
selected. Note: this is only useful when the exact hardware and driver are
known beforehand.
2011-03-20 12:42:27 +00:00
Maarten Bosmans
7c011e7688 Get rid of some warnings: -Wunsafe-loop-optimizations
pulsecore/core-util.c: In function ‘pa_hexstr’:
pulsecore/core-util.c:1858: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]

modules/alsa/alsa-mixer.c: In function ‘pa_alsa_decibel_fix_dump’:
modules/alsa/alsa-mixer.c:3678: warning: cannot optimize possibly infinite loops [-Wunsafe-loop-optimizations]
modules/alsa/alsa-mixer.c: In function ‘pa_alsa_path_set_new’:
modules/alsa/alsa-mixer.c:2640: warning: cannot optimize loop, the loop counter may overflow [-Wunsafe-loop-optimizations]
2011-03-20 11:29:25 +00:00
Maarten Bosmans
26366664c1 Update PA_MODULE_USAGE to be in line with actual implementation 2011-03-18 12:07:02 +00:00
Daniel Mack
5a4176409c alsa: Add two more ALSA audio card profiles
This adds profiles for Native Instruments recently announced
"Trator Audio 6" and "Traktor Audio 10".
2011-03-18 09:36:43 +00:00
Maarten Bosmans
ecf09f2cd6 Fix up according to Coding Style
Only whitespace changes in here
2011-03-11 11:49:35 +00:00
Tanu Kaskinen
5715b2af30 alsa-mixer: When figuring out the max_dB of a path, use only channels that are used by the path elements.
Without this, p->max_dB could never be less than 0 dB, because the loop at the
end of pa_alsa_path_probe() would reset p->max_dB to 0 as soon as the loop
encountered a channel that wasn't touched by any element.

There was a similar issue for p->min_dB too (it could never be more than 0 dB),
which is also fixed by this patch.
2011-03-11 13:41:28 +02:00
Tanu Kaskinen
064780d9de alsa-mixer: Implement support for setting element specific upper limits for volume.
This feature is mainly useful in embedded systems that have built-in speakers.
In such situations the full audio path is known beforehand, so it's possible to
know what is the maximum sensible volume, and any higher volume can be
disabled.

The volume limit is set in path configuration files in the [Element] section,
using option "volume-limit". The value is the desired maximum volume step of
the volume element.
2011-03-11 13:40:51 +02:00
Tanu Kaskinen
973813485f alsa-card: Print the profile set configuration when loading the card. 2011-03-11 13:39:50 +02:00
Tanu Kaskinen
00a05a8272 alsa-mixer: Add a default case for a switch, so that the compiler won't complain about unhandled cases. 2011-03-11 13:38:05 +02:00
Tanu Kaskinen
e01a28cd53 alsa-mixer: Use decibel fixes when getting and setting decibel volumes. 2011-03-11 13:37:17 +02:00
Tanu Kaskinen
4842077a1e alsa-mixer: Add DecibelFix section to the profile set config file format.
This commit only implements the parser, the decibel fix data is not yet used
for anything.
2011-03-11 13:34:24 +02:00
Colin Guthrie
f4a2a8ebfe alsa-mixer: Fix a git-am cockup in b0f72311
It seems git managed to mess up a git-am with a patch from
David which moved where this function was called element_probe
to within itself (recursive which could normally lead to an
infinite loop, but as it was now never called from anywhere else,
this didn't happen).

Thank you to Maarten for spotting and following up the issue.
2011-03-04 09:50:27 +00:00
David Henningsson
7b366a52c3 alsa-mixer: Add support for "Line Boost" element
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-28 13:30:51 +00:00
David Henningsson
dbdb4607b0 alsa-mixer: Make sure capture source and input source use right path
Make sure that mic and line (with common names) use the specific
path instead of the analog-input one.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:55:55 +00:00
David Henningsson
65317c8241 alsa-mixer: Fixup "Mic"/"Line"/"analog-input" paths to work with the new paths
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:55:39 +00:00
David Henningsson
3618268757 alsa-mixer: Add new paths for Internal Mic, Front Mic, Rear Mic and Dock Mic
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:54:59 +00:00
David Henningsson
ade0a6f884 alsa-mixer: always round towards 0 dB
Always round towards 0 dB. Also add a few debug comments to aid
troubleshooting.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:54:48 +00:00
David Henningsson
b0f72311cf alsa-mixer: add required-any and required-* for enum options
Now you can add required-any to elements in a path and the path
will be valid as long as at least one of the elements are present.
Also you can have required, required-any and required-absent in
element options, causing a path to be unsupported if an option is
(not) present (simplified example: to skip line in path if
"Capture source" doesn't have a "Line In" option).

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:48:11 +00:00
David Henningsson
0ce3017b74 alsa-mixer: Add a few well-known descriptions
Add front mic, rear mic, and docking line-in. These are likely to be
present on modern hda chips, for reference see
linux-2.6/sound/pci/hda/hda_codec.c:hda_get_input_pin_label

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2011-02-25 15:47:56 +00:00
Tanu Kaskinen
624152dac3 alsa-card: Add a new modarg "profile_set" for giving the card a custom profile set configuration file. 2011-02-25 15:44:57 +00:00
Tanu Kaskinen
46359043c4 alsa-mixer: Fix path set building when using the element-output or element-input mapping options in profile set configuration.
When creating synthesized paths, pa_alsa_path_set_new() created duplicate
elements for each path, and one of the duplicate elements would be marked as
required absent. That made path probing fail. While debugging this, I noticed
also that pa_alsa_path_synthesize() didn't initialize p->last_element properly.
2011-02-25 15:44:44 +00:00
Pierre-Louis Bossart
051d82133f alsa: disable period wakeups in tsched mode if possible
This patch reflects a new capability that Lennart was wishing
for. Wish granted...

Re-submitting it now that alsa-lib 1.0.24
provides additional entry points to disable period
wakeups in timer-scheduling mode if hardware can
work without it (HDAudio, oxygen and Intel SST).

    Example with standard playback on HDAudio output
    Before change:

    Top causes for wakeups:
       3.8% (  5.4)   [hda_intel] <interrupt>
       2.8% (  4.0)   alsa-sink

    After change:
    Top causes for wakeups:
       2.3% (  3.0)   alsa-sink

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
2011-02-01 09:41:02 +00:00
Maarten Bosmans
974af43507 build: Don't include empty Makefile.am in subdirs 2011-01-31 12:40:43 +00:00
Lennart Poettering
1250b5d735 ratelimit: fix log levels of log suppression messages
When logging a suppression message do so on the same log level as the
suppressed messages.

Cherry picked by Colin Guthrie from ec5a785712
with a couple of additional changes due to extra limiting in master
that was not present in stable-queue.
2011-01-31 11:36:24 +00:00
Jyri Sarha
aefa94f052 alsa-sink: Don't assume we were able to enable hw-volume or sync-volume (v1.1)
This patch also disables mixer callback code if we do not have neither
HW-volume or HW-mute.
2011-01-15 13:26:21 +00:00
Jyri Sarha
98db3dffb6 alsa-sink: Fix double use of string 2011-01-15 13:26:07 +00:00
Zhang Wanming
0c0c285e79 Fix typos 2010-12-20 11:07:30 +00:00
Colin Guthrie
3e28f60592 build-sys: Replace dummy Makefiles with proper Makefile.am's
This is needed to better support out of tree builds (including
distcheck) and to ensure the necessary folders are created in the
build tree on configure and also works around an intl-tools bug
(https://bugs.launchpad.net/intltool/+bug/605826)

The Makefile.am's used are minimal (and in some cases completely
blank). At present they do not include anything interesting
with the majority of the real work still done by the monolitic
src/Makefile.am

It may make sense to start splitting out src/Makefile.am into
smaller chunks but this commit makes the minimum changes to address
the issues that result from using make distcheck and other out of
tree builds.

Note: This 'breaks' the ability to type make in e.g. the src/modules
folder and have all of PA rebuilt accordingly (this is because the
static Makefiles previously present just did a "make -C ..") which
was purportedly for use in emacs. But I'm sure there will be a better
and more robust way to configure emacs to do your builds properly if
this behaviour is still desirable.
2010-12-05 15:58:59 +00:00