History log of /linux-master/sound/pci/hda/hda_jack.h
Revision Date Author Comments
# 37c4fd0d 17-Nov-2021 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Do disconnect jacks at codec unbind

The HD-audio codec driver remove may happen also at dynamically
unbinding during operation, hence it needs manual triggers of
snd_device_disconnect() calls, while it's missing for the jack objects
that are associated with the codec.

This patch adds the manual disconnection call for jacks when the
remove happens without card->shutdown (i.e. not under the full
removal).

Link: https://lore.kernel.org/r/20211117133040.20272-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 04f7791b 05-Mar-2021 Hui Wang <hui.wang@canonical.com>

ALSA: hda - bind headset buttons to the headphone jack

With the HDA driver, if the headset buttons are supported, an audio
Jack will be created for them. This audio Jack is a bit confusing to
users since it can't report headphone/mic insertion events but it
claims to support these events.

And in addition, the driver already builds a headphone Jack and a mic
Jack, and most of those buttons are used for headphone playback, so
do some change to bind those buttons to the headphone Jack. After this
change, the key events are generated from NID 0x55, and are reported
to the input layer via headphone jack (NID 0x21).

If there is no headphone Jack, then build an audio jack to support
those buttons same as previously.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
Link: https://lore.kernel.org/r/20210305092608.109599-1-hui.wang@canonical.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 74610eaf 02-Sep-2020 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: (cosmetic) align function parameters

Fix cppcheck warnings and use same names in headers and C code.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20200902212133.30964-12-pierre-louis.bossart@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 5204a05d 19-Nov-2019 Nikhil Mahale <nmahale@nvidia.com>

ALSA: hda - Add DP-MST jack support

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>


# 80b917a8 19-Nov-2019 Nikhil Mahale <nmahale@nvidia.com>

ALSA: hda - Rename snd_hda_pin_sense to snd_hda_jack_pin_sense

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>


# 62810dbd 20-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 46

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>


# 911761c2 28-Nov-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add jack button support

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>


# e6ce180f 28-Nov-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add jack pointer and unsolicited event bits to callback

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>


# 2ebab40e 09-Feb-2016 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix bad dereference of jack object

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>


# 909cadc6 12-Nov-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Simplify phantom jack handling for HDMI/DP

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>


# 2ba2dfa1 27-Apr-2015 Jie Yang <yang.jie@intel.com>

ALSA: hda - Update to use the new jack kctls method

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>


# 95a962c3 29-Oct-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - More kerneldoc comments

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>


# a5062dee 23-Sep-2014 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - add explicit include of err.h

Since every caller of snd_hda_jack_detect_enable_callback needs to
use the macros from err.h, it makes sense to include it directly
from hda_jack.h.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 1a4f69d5 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow multiple callbacks for jack

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>


# bda17b82 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make snd_hda_jack_detect_enable_callback() returning the jack object

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>


# 81965f1f 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make snd_hda_jack_tbl_new() static

It's called only in hda_jack.c, so make it local.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 62f949bf 11-Sep-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Get rid of action field from struct hda_jack_tbl

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>


# 0f568959 07-Nov-2013 David Henningsson <david.henningsson@canonical.com>

ALSA: hda - Add a block_report flag to jacks

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>


# 60ea8ca2 19-Jul-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_jack_detect_state() helper function

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>


# 0619ba8c 19-Nov-2012 Dylan Reid <dgreid@chromium.org>

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>


# 26a6cb6c 09-Oct-2012 David Henningsson <david.henningsson@canonical.com>

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>


# 954df2a9 25-Sep-2012 David Henningsson <david.henningsson@canonical.com>

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>


# 80c8bfbe 04-Jun-2012 David Henningsson <david.henningsson@canonical.com>

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>


# 128bc4ba 07-May-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.c

Just code shuffles.

Signed-off-by: Takashi Iwai <tiwai@suse.de>


# a9c74173 13-Feb-2012 Takashi Iwai <tiwai@suse.de>

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>


# aad37dbd 02-Nov-2011 Takashi Iwai <tiwai@suse.de>

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>


# 35be544a 02-Nov-2011 Takashi Iwai <tiwai@suse.de>

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>


# 3a93897e 27-Oct-2011 Takashi Iwai <tiwai@suse.de>

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>


# 01a61e12 27-Oct-2011 Takashi Iwai <tiwai@suse.de>

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>


# 1835a0f9 27-Oct-2011 Takashi Iwai <tiwai@suse.de>

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>