Commit Graph

28 Commits

Author SHA1 Message Date
Takashi Iwai 975cc02a90 ALSA: Replace the magic number 44 with const
The char arrays with size 44 are for the name string of
snd_ctl_elem_id.  Define the constant and replace the raw numbers with
it for clarifying better.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-06-28 12:14:44 +02:00
David Henningsson b26b511668 ALSA: hda - Handle Headphone Mic jack more generic
Now that we have a flag for headphone mics, we can use that flag
in the jack creation instead of creating the jack manually.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-04-11 11:59:41 +02:00
Takashi Iwai 76a19c69d9 ALSA: hda - Allow jack detection when polling is enabled
Let is_jack_detectable() return true when the jack polling is enabled
for the codec.  VT1708 uses the polling explicitly so we need to allow
it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:43:54 +01:00
Takashi Iwai 9cc159c664 ALSA: hda - Add codec->inv_jack_detect flag
Yet another broken hardware workaround: there are hardware indicating
the inverted jack detection bit result.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-12 08:43:21 +01:00
Takashi Iwai 361dab3ec2 ALSA: hda - Call snd_array_init() early and only once
This is a preliminary patch for introducing a protection to access
races of snd_array instances.  Call snd_array_init() appropriately
at the initialization time and don't call it twice.

Also the allocations of codec-spec structs are cleaned up by helper
functions in patch_sigmatel.c and patch_analog.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 09:03:39 +01:00
Dylan Reid 0619ba8c17 ALSA: hda - Allow jack state to depend on another jack
Introduce the concept of a "gated" jack.  The gated jack's pin sense
is
only valid when the "gating" jack is plugged.  This requires checking
the gating jack when the gated jack changes and re-checking the gated
jack when the gating jack is plugged/unplugged.

This allows handling of devices where the mic jack detect floats when
the headphone jack is unplugged.

[Rewritten for fixing the possible snd_array reallocation, covering
 the missing callback calls and jack sync operations, as well as some
 code cleanups -- tiwai]

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-19 19:49:58 +01:00
David Henningsson 34a9318772 ALSA: hda - Don't enable unsol for jacks we're polling
This will greatly reduce the frequency for detection errors in
those cases where the hardware is "flaky", i e, rapidly changing
between plugged and unplugged states even without user interaction.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-17 14:47:31 +02:00
David Henningsson 26a6cb6cca ALSA: hda - Implement a poll loop for jacks as a module parameter
Now that we have a generic unsol mechanism, we can implement a generic
poll loop, which can be used for debugging, or if a codec's unsol
mechanism is broken.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-15 09:58:28 +02:00
David Henningsson 954df2a968 ALSA: hda - make a generic unsol event handler
Moving towards less duplication of code between codecs - this patch
takes some of the common code of unsol event handling and makes it
generic.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-10-06 16:43:31 +02:00
David Henningsson 5fe8e1e671 ALSA: hda - Remove ignore_misc_bit
The purpose of this flag is unclear. If the problem is that some machines
have broken misc/NO_PRESENCE bits, they should be fixed by pin fixups.

In addition, this causes jack detection functionality to be flawed on
the M31EI, where there are two jacks without jack detection (which is
properly marked as NO_PRESENCE), but due to ignore_misc_bit, these
jacks are instead being reported as being present but always unplugged.

BugLink: https://bugs.launchpad.net/bugs/939161
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-09-07 12:41:38 +02:00
Takashi Iwai f46c329644 ALSA: hda - Fix index number conflicts of phantom jacks
Since some jack controls may be renamed as phantom jacks, the existing
check for index conflicts doesn't work because it simply compares the
name with the last used name, assuming that the controls with the same
name continue.  Thus, it would result in the duplicated controls when
two or more phantom jacks with the very same type exist, and the
driver gives up with an error.

This patch fixes the problem by checking the index number conflicts
more intensively (but dumbly).

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-07-17 16:55:56 +02:00
David Henningsson 80c8bfbe76 ALSA: HDA: Create phantom jacks for fixed inputs and outputs
PulseAudio sometimes have difficulties knowing that there is a
"Speaker" or "Internal Mic", if they have no individual volume
controls or selectors. As a result, only e g "Headphone" might
be created for a laptop, but no "Speaker".
To help out, create phantom jacks (that are always present,
at least for now) for "Speaker", "Internal Mic" etc, in case we
detect them.
The naming convention is e g "Speaker Phantom Jack".

In order not to pollute the /dev/input namespace with even more
devices, these are added to the kcontrols only, not the input devices.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-06-14 12:59:35 +02:00
Takashi Iwai 128bc4ba8c ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.c
Just code shuffles.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-05-08 18:01:33 +02:00
Takashi Iwai 71b1e9e43d ALSA: hda - Add codec->no_jack_detect flag
Add a new flag to indicate that the codec has no jack-detection cap.
This flag should be set for hardwares that have no jack-detect
implementation although the codec chip itself supports it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-13 12:06:09 +01:00
Takashi Iwai a9c74173f4 ALSA: hda - Make is_jack_detectable() as non-inlined
It's a bit too big and used too often as an inline function.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-13 12:06:03 +01:00
David Henningsson 05c3b36e53 ALSA: HDA: Fix jack creation for codecs with front and rear Line In
If a codec has both a front and a rear Line In, two controls both
named "Line Jack" will be created, which causes parsing to fail.
While a long term solution might be to name the jacks differently,
this extra check is consistent with what is already being done in many
auto-parsers, and will also protect against other cases when two
inputs have the same label.

BugLink: https://bugs.launchpad.net/bugs/923409
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-31 15:11:21 +01:00
Takashi Iwai 31ef225793 ALSA: hda - Integrate input-jack stuff into kctl-jack
Instead of managing input-jack stuff separately, call all stuff inside
the kctl-jack creation, deletion and report.  The caller no longer needs
to care about input-jack.

The better integration between input-jack and kctl-jack should be done
in the upper layer in near future, but for now, it's implemented locally
for more tests.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-12-01 17:47:54 +01:00
Takashi Iwai 201e06ffa9 ALSA: hda - Give more unique names by snd_hda_get_pin_label()
The function now gives more unique names for the output pins by adding
some prefix and suffix for the location and the channels.  Otherwise, it
can pass the index number.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 15:48:23 +01:00
Takashi Iwai bf815bf0a3 ALSA: hda - Add missing inclusion of linux/export.h
This is needed newly since 3.2...

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 14:28:33 +01:00
Takashi Iwai fc5b15f138 ALSA: hda - Add missing initialization of kctl jack status
Otherwise the jack kctls will report invalid values until the jack
is re-plugged.

Reported-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
Takashi Iwai 344b01aecd ALSA: hda/jack - Fix the assignment of input jack-type
The type field was lost during the transition.  Restored.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
Takashi Iwai cfc7c9d307 ALSA: hda/jack - Fix NULL-dereference at probing
At probing time, the elements that aren't assigned to kctl or jack may
be called.  Need proper NULL-checks.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
David Henningsson d1cb620081 ALSA: HDA: Jack: Export required functions from hda_jack.c
These two functions are being used by the codec-idt and codec-hdmi
modules, so they need to be exported properly.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
Takashi Iwai aad37dbd56 ALSA: hda - Merge input-jack helpers to hda_jack.c
We can use the very same table in hda_jack.c for managing the list for
input-jack elements, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:04 +01:00
Takashi Iwai 35be544af3 ALSA: Introduce common helper functions for jack-detection control
Now move the helper function for creating and reporting the jack-detection
to the common place.  The driver that needs this functionality should
select CONFIG_SND_KCTL_JACK kconfig.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:03 +01:00
Takashi Iwai 3a93897ea3 ALSA: hda - Manage unsol tags in hda_jack.c
Manage the tags assigned for unsolicited events dynamically together
with the jack-detection routines.  Basically this is almost same as what
we've done in patch_sigmatel.c.  Assign the new tag number for each new
unsol event, associate with the given NID and the action type, etc.

With this change, now all pins looked over in snd_hda_jack_add_kctls()
are actually enabled for detection now even if the pins aren't used for
jack-retasking by the driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:14:03 +01:00
Takashi Iwai 01a61e12b4 ALSA: hda - Create jack-detection kcontrols
Create kcontrols for pin jack-detections, which work similarly like
jack-input layer.  Each control will notify when the jack is plugged or
unplugged, and also user can read the value at any time via the normal
control API.

The control elements are created with iface=CARD, so that they won't
appear in the mixer apps.

So far, only the pins that enabled the jack-detection are registered.
For covering all pins, the transition of the common unsol-tag handling
would be needed.  Stay tuned.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:12:17 +01:00
Takashi Iwai 1835a0f9a2 ALSA: hda - Cache the jack-detection value
Introduce a table containing the pins and their jack-detection states
for avoiding the unnecessary verbs to check the pin status at each time.

When the unsol event is enabled via snd_hda_jack_detect_enable(), it
automatically adds the given NID to the table.  Then the driver supposes
that the codec driver will set the dirty flag appropariately when an
unsolicited event is invoked for that pin.

The behavior for reading other pins that aren't registered in the table
doesn't change.  Only the pins assigned to the table are cached, so far.

In near futre, this table can be extended to use the central place for
the unsolicited events of all pins, etc, and eventually include the
jack-detect kcontrols that replace the current input-jack stuff.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16 11:11:15 +01:00