aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/hda/hda_jack.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2020-01-14ALSA: hda: correct kernel-doc parameter descriptionsPierre-Louis Bossart1-0/+2
make W=1 throws warnings, provide missing documentation Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Link: https://lore.kernel.org/r/20200113211405.28070-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-19ALSA: hda - Add DP-MST jack supportNikhil Mahale1-41/+106
This patch adds DP-MST jack support which will be used on NVIDIA platforms. Today, DP-MST audio is supported only if the codec has acomp support. This patch makes it possible to add DP-MST support for non-acomp codecs. For the codecs supporting DP-MST audio, each pin can contain several device entries. Each device entry is a virtual pin, described by pin_nid and dev_id in struct hdmi_spec_per_pin. For monitor hotplug event handling, non-acomp codecs enable and register jack-detection for every hdmi_spec_per_pin. This patch updates every relevant function in hda_jack.h and its implementation in hda_jack.c, to consider dev_id along with pin_nid. Changes to the HD Audio specification to support DP-MST audio are described in the Intel Document Change Notification (DCN) number HDA040-A. From HDA040-A, "For the case of multi stream capable Digital Display Pin Widget, [the Get Pin Sense verb] can be used to read a specific Device Entry state as reported in Get Device List Entry verb." This patch updates the read_pin_sense() function to take the dev_id as an argument and pass it as a parameter to the Get Pin Sense verb. Bits 15 through 20 from the Unsolicited Response for intrinsic events contain the index of the Device Entry that generated the event. This patch updates the Unsolicited Response event handlers to extract the device entry index from the response and pass it to snd_hda_jack_tbl_get_from_tag(). This patch updates snd_hda_jack_tbl_new() to take a dev_id argument and store it in the jack structure, and to make sure not to generate a different tag when called more than once for the same nid. Signed-off-by: Nikhil Mahale <nmahale@nvidia.com> Link: https://lore.kernel.org/r/20191119084710.29267-3-nmahale@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-11-19ALSA: hda - Rename snd_hda_pin_sense to snd_hda_jack_pin_senseNikhil Mahale1-4/+4
s/snd_hda_pin_sense/snd_hda_jack_pin_sense/g This aligns the snd_hda_pin_sense function name with the names of other functions in hda_jack.h. Signed-off-by: Nikhil Mahale <nmahale@nvidia.com> Reviewed-by: Aaron Plattner <aplattner@nvidia.com> Link: https://lore.kernel.org/r/20191119084710.29267-2-nmahale@nvidia.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-07-08Merge tag 'asoc-v5.3' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linusTakashi Iwai1-5/+1
ASoC: Updates for v5.3 This is a very big update, mainly thanks to Morimoto-san's refactoring work and some fairly large new drivers. - Lots more work on moving towards a component based framework from Morimoto-san. - Support for force disconnecting muxes from Jerome Brunet. - New drivers for Cirrus Logic CS47L35, CS47L85 and CS47L90, Conexant CX2072X, Realtek RT1011 and RT1308. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-06-11ALSA: hda: fix a mask for unsolicited event tagsGuennadi Liakhovetski1-1/+1
Response tag only occupies 6 bits, not 7. This bug is harmless, since the value has just been shifted to the right by 26 bits, so this is only a cosmetic fix. Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2019-05-24treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 46Thomas Gleixner1-5/+1
Based on 1 normalized pattern(s): this driver is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 5 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190520170858.461662648@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-07ALSA: hda - Add jack button supportTakashi Iwai1-8/+32
Extend some structs to add the support for jack button changes. Now snd_hda_jack_add_kctl() receives two more arguments: the jack type and the jack keymaps. Both are optional, and when zero are passed, the function behaves just like before. For reporting button state changes, you'd need to update jack->button_state bits accordingly, typically in the jack callback. Then the value OR'ed with button_state and the jack plug state is passed to snd_jack_report(). Note that currently the code assumes only the one-shot button events, i.e. it tries to send the button release soon after sending the button event. If a driver really supports the button release handling by itself, we may need to introduce some flag to control this behavior in future. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-12-07ALSA: hda - Add jack pointer and unsolicited event bits to callbackTakashi Iwai1-5/+11
For allowing the callee to evaluate the associated jack information and the unsolicited event data, add the new fields to hda_jack_callback. They can be used, for example, to retrieve the headset button state in the callback. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2018-08-30ALSA: hda: move hda_codec.h to include/soundPierre-Louis Bossart1-1/+1
As suggested by Takashi, move this header file to make it easier to include from e.g. the Intel Skylake driver in follow-up patches Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2016-02-09ALSA: hda - Fix bad dereference of jack objectTakashi Iwai1-1/+1
The hda_jack_tbl entries are managed by snd_array for allowing multiple jacks. It's good per se, but the problem is that struct hda_jack_callback keeps the hda_jack_tbl pointer. Since snd_array doesn't preserve each pointer at resizing the array, we can't keep the original pointer but have to deduce the pointer at each time via snd_array_entry() instead. Actually, this resulted in the deference to the wrong pointer on codecs that have many pins such as CS4208. This patch replaces the pointer to the NID value as the search key. As an unexpected good side effect, this even simplifies the code, as only NID is needed in most cases. Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-11-12ALSA: hda - Simplify phantom jack handling for HDMI/DPTakashi Iwai1-16/+2
The HDMI codec parser may create a phantom jack, but the helper function snd_hda_jack_add_kctl() treats always as a normal jack. This is superfluous as the jack query is executed at each time the jack sync is performed. Since the HDMI codec parser is the only caller of this function, it's easier to change back this directly calling the original __snd_hda_jack_add_kctl() with phantom_jack parameter. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-27ALSA: hda - Update to use the new jack kctls methodJie Yang1-65/+25
Jack snd_kcontrols can now be created during snd_jack_new() or by later calling snd_jack_add_new_kctls(). This patch creates the jacks during the initialisation stage for both phantom and non phantom jacks. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-27ALSA: jack: extend snd_jack_new to support phantom jackJie Yang1-1/+1
Dont create input devices for phantom jacks. Here, we extend snd_jack_new() to support phantom jack creating: pass in a bool param for [non-]phantom flag, and a bool param initial_jack to indicate whether we need to create a kctl at this stage. We can also add a kctl to the jack after its created meaning we can now integrate the HDA and ASoC jacks. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-04-27ALSA: Jack: handle jack embedded kcontrol creating within ctljackJie Yang1-1/+1
This patch adds a static method get_available_index() to allocate the index of new jack kcontrols and also adds jack_kctl_name_gen() which is used to ensure compatibility with jack naming by removing " Jack" from some incorrectly passed names. Signed-off-by: Jie Yang <yang.jie@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2015-03-03ALSA: hda - Add card field to hda_codec structTakashi Iwai1-4/+4
Allow the codec object to have an individual card pointer. Not only this simplifies the redirections in many places, also this will allow us to make each codec assigned to a different card object. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-29ALSA: hda - More kerneldoc commentsTakashi Iwai1-0/+39
Put more kerneldoc comments to the exported functions. Still the generic parser code and the HD-audio controller code aren't covered yet, though. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-10-29ALSA: hda - Correct kerneldoc commentsTakashi Iwai1-0/+21
Complete the missing parameters and fix anything wrong there. Just comment changes. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-16ALSA: hda - Allow multiple callbacks for jackTakashi Iwai1-20/+38
So far, hda_jack infrastructure allows only one callback per jack, and this makes things slightly complicated when a driver wants to assign multiple tasks to a jack, e.g. the standard auto-mute with a power up/down sequence. This can be simplified if the hda_jack accepts multiple callbacks. This patch is such an extension: the callback-specific part (the function and private_data) is split to another struct from hda_jack_tbl, and multiple such objects can be assigned to a single hda_jack_tbl entry. The new struct hda_jack_callback is passed to each callback function now, thus the patch became bigger than expected. But these changes are mostly trivial. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-15ALSA: hda - Make snd_hda_jack_detect_enable_callback() returning the jack objectTakashi Iwai1-7/+17
STAC/IDT driver calls snd_hda_jack_tbl_get() again after calling snd_hda_jack_detect_enable_callback(). For simplifying this, let's make snd_hda_jack_detect_enable_callback() returning the pointer while handling the error with the standard IS_ERR() & co. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-11ALSA: hda - Make snd_hda_jack_tbl_new() staticTakashi Iwai1-2/+1
It's called only in hda_jack.c, so make it local. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2014-09-11ALSA: hda - Get rid of action field from struct hda_jack_tblTakashi Iwai1-7/+3
The action value assigned to each hda_jack_tbl entry is mostly superfluous. The actually used values are either the widget NID or a value specific to the callback. The former case can be simply replaced by a reference to widget NID itself. The only place doing the latter is STAC/IDT codec driver for the powermap handling. But, the code doesn't need to check the action field at all -- the function jack_update_power() is called either with a specific pin or with NULL. So the check of jack->action can be removed completely there, too. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-12-19ALSA: hda - Kill EXPORT_SYMBOL_HDA()Takashi Iwai1-15/+15
Replace all with the standard EXPORT_SYMBOL_GPL(). Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-11-07ALSA: hda - Add a block_report flag to jacksDavid Henningsson1-1/+1
If the jack should not be reported to userspace (e g, because it is in some transitional state), one can set this flag. Signed-off-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-08-05ALSA: hda - Fix jack gating when auto_{mute,mic} is suppressed.Chih-Chung Chang1-2/+2
The snd_hda_jack_set_gating_jack() call didn't work when auto_{mute,mic} is suppressed because (1) am_entry is not filled with nid of the mic pin. (2) The jacks are not created (by snd_hda_jack_detect_enable_callback) before the snd_hda_jack_set_gating_jack call. Now we use the first input pin nid directly, and create the jack if it doesn't exist yet. Signed-off-by: Chih-Chung Chang <chihchung@chromium.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-07-21ALSA: hda - Add snd_hda_jack_detect_state() helper functionTakashi Iwai1-6/+12
snd_hda_jack_detect() function returns a boolean value for a jack plugged in or not, but it also returns always true when the corresponding pin is phantom (i.e. fixed). This is OK in most cases, but it makes the generic parser misbehaving about the auto-mute or auto-mic switching, e.g. when one of headphone pins is a fixed. Namely, the driver decides whether to mute the speaker or not, just depending on the headphone plug state: if one of the headphone jacks is seen as active, then the speaker is muted. Thus this will result always in the muted speaker output. So, the problem is the function returns a boolean, after all, although we need to think of "phantom" jack. Now a new function, snd_hda_jack_detect_state() is introduced to return these tristates. The generic parser uses this function for checking the headphone or mic jack states. Meanwhile, the behavior of snd_hda_jack_detect() is kept as is, for keeping compatibility in other driver codes. Acked-by: David Henningsson <david.henningsson@canonical.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-06-28ALSA: Replace the magic number 44 with constTakashi Iwai1-1/+1
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-04-11ALSA: hda - Handle Headphone Mic jack more genericDavid Henningsson1-13/+30
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-01-12ALSA: hda - Allow jack detection when polling is enabledTakashi Iwai1-1/+2
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-12ALSA: hda - Add codec->inv_jack_detect flagTakashi Iwai1-1/+5
Yet another broken hardware workaround: there are hardware indicating the inverted jack detection bit result. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28ALSA: hda - Call snd_array_init() early and only onceTakashi Iwai1-1/+0
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-19ALSA: hda - Allow jack state to depend on another jackDylan Reid1-9/+63
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-10-17ALSA: hda - Don't enable unsol for jacks we're pollingDavid Henningsson1-0/+2
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-15ALSA: hda - Implement a poll loop for jacks as a module parameterDavid Henningsson1-0/+22
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-06ALSA: hda - make a generic unsol event handlerDavid Henningsson1-2/+30
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-09-07ALSA: hda - Remove ignore_misc_bitDavid Henningsson1-3/+2
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-07-17ALSA: hda - Fix index number conflicts of phantom jacksTakashi Iwai1-15/+30
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-06-14ALSA: HDA: Create phantom jacks for fixed inputs and outputsDavid Henningsson1-18/+41
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-05-08ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.cTakashi Iwai1-0/+1
Just code shuffles. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-13ALSA: hda - Add codec->no_jack_detect flagTakashi Iwai1-0/+2
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-13ALSA: hda - Make is_jack_detectable() as non-inlinedTakashi Iwai1-0/+14
It's a bit too big and used too often as an inline function. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-01-31ALSA: HDA: Fix jack creation for codecs with front and rear Line InDavid Henningsson1-9/+15
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>
2011-12-01ALSA: hda - Integrate input-jack stuff into kctl-jackTakashi Iwai1-99/+60
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-11-16ALSA: hda - Give more unique names by snd_hda_get_pin_label()Takashi Iwai1-12/+12
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-16ALSA: hda - Add missing inclusion of linux/export.hTakashi Iwai1-0/+1
This is needed newly since 3.2... Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16ALSA: hda - Add missing initialization of kctl jack statusTakashi Iwai1-0/+2
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-16ALSA: hda/jack - Fix the assignment of input jack-typeTakashi Iwai1-0/+1
The type field was lost during the transition. Restored. Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-11-16ALSA: hda/jack - Fix NULL-dereference at probingTakashi Iwai1-1/+3
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-16ALSA: HDA: Jack: Export required functions from hda_jack.cDavid Henningsson1-0/+2
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-16ALSA: hda - Merge input-jack helpers to hda_jack.cTakashi Iwai1-1/+96
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-16ALSA: Introduce common helper functions for jack-detection controlTakashi Iwai1-48/+8
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>