History log of /linux-master/sound/pci/hda/hda_hwdep.c
Revision Date Author Comments
# 897c8882 16-Aug-2023 Takashi Iwai <tiwai@suse.de>

ALSA: hwdep: Don't embed device

Like control and PCM devices, it's better to avoid the embedded struct
device for hwdep (although it's more or less well working), too.
Change it to allocate via snd_device_alloc(), and free the memory at
the common snd_hwdep_free().

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Tested-by: Curtis Malainey <cujomalainey@chromium.org>
Link: https://lore.kernel.org/r/20230816160252.23396-5-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>


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

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

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 this driver is distributed in the hope
that it will be useful but without any warranty without even the
implied warranty of merchantability or fitness for a particular
purpose see the gnu general public license for more details you
should have received a copy of the gnu general public license along
with this program if not write to the free software foundation inc
59 temple place suite 330 boston ma 02111 1307 usa

extracted by the scancode license scanner the SPDX license identifier

GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 18 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/20190520170857.186505395@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>


# be57bfff 22-Aug-2018 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: move hda_codec.h to include/sound

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>


# b4af16d6 22-Aug-2018 Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

ALSA: hda: move hda_codec.h to include/sound

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>


# 69fa6f19 23-Apr-2018 Takashi Iwai <tiwai@suse.de>

ALSA: hda: Hardening for potential Spectre v1

As recently Smatch suggested, one place in HD-audio hwdep ioctl codes
may expand the array directly from the user-space value with
speculation:
sound/pci/hda/hda_local.h:467 get_wcaps() warn: potential spectre issue 'codec->wcaps'

As get_wcaps() itself is a fairly frequently called inline function,
and there is only one single call with a user-space value, we replace
only the latter one to open-code locally with array_index_nospec()
hardening in this patch.

BugLink: https://marc.info/?l=linux-kernel&m=152411496503418&w=2
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 6efdd851 27-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add card field to hda_codec struct

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>


# 327ef4f0 17-Feb-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Decouple PCM and hwdep devices from codec object

This is a preliminary patch for the hda_bus implementation, removing
the parent device setup to codec device. Since the bus and the class
devices can't be crossed over, leave the sound devices to the default
parent device as is.

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


# 7b461600 29-Jan-2015 Takashi Iwai <tiwai@suse.de>

ALSA: hwdep: Embed struct device

Like the previous patch, this one embeds the device object into hwdep
object. For a proper object lifecycle, it's freed in the release
callback.

This also allows us to create sysfs entries via passing to the groups
field of the device without explicit function calls. Since each
driver can see the device and touch its groups field directly, we
don't need to delegate in hwdep core any longer. So, remove the
groups field from snd_hwdep, and let the user (in this case only
hda_hwdep.c) modify the device groups.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 648a8d27 25-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add sysfs to codec object, too

We have currently sysfs attributes for each hwdep, but basically these
should belong to the codec itself, per se. Let's add them to the
codec object while keeping them for hwdep as is for compatibility.

While we are at it, split the sysfs-related stuff into a separate
source file, hda_sysfs.c, and keep only the stuff necessary for hwdep
in hda_hwdep.c.

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


# 13aeaf68 24-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Create own device struct for each codec

As the HD-audio is treated individually in each codec driver, it's
more convenient to assign an own struct device to each codec object.
Then we'll be able to use dev_err() more easily for each codec, for
example.

For achieving it, this patch just creates an object "hdaudioCxDy".
It belongs to sound class instead of creating a new bus, just for
simplicity, at this stage. No pm ops is implemented in the device
struct level but currently it's merely a container. The PCM and hwdep
devices are now children of this codec device.

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


# f806bdb2 25-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hwdep: Take private_data as drvdata for sysfs

For referring to a different object from sysfs ops, take hwdep
private_data as stored via dev_set_drvdata() at creating the device
object. In that way, the same sysfs ops can be used by different
device types.

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


# caa751ba 25-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: Create sysfs attribute files via groups

Instead of calling each time device_create_file(), create the groups
of sysfs attribute files at once in a normal way. Add a new helper
function, snd_get_device(), to return the associated device object,
so that we can handle the sysfs addition locally.

Since the sysfs file addition is done differently now,
snd_add_device_sysfs_file() helper function is removed.

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


# 1f85a0f0 15-Feb-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Remove superfluous inclusion of linux/pci.h

Some codec drivers still have it since using PCI_VENDOR_ID_*.

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


# 8e3ae6f7 07-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add consistent tag names for firmware patch

Some tags used in the firmware patch file are inconsistent with hwdep
sysfs file names, such as, the firmware patch takes [hint] tag while
sysfs file is */hints. This makes even me referring back to the
document often. Let's provide the same tag names as sysfs for
reducing confusions.

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


# d81e397c 07-Jan-2014 Takashi Iwai <tiwai@suse.de>

ALSA: hda - firmware patch code cleanup

Just a code refactoring: the need_codec flag in hda_patch_item struct
can be removed by checking the current mode instead. No functional
change.

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


# 2698ea98 17-Dec-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Kill EXPORT_SYMBOL_HDA()

Replace all with the standard EXPORT_SYMBOL_GPL().

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


# b785a492 19-Jul-2013 Jingoo Han <jg1.han@samsung.com>

ALSA: replace strict_strto*() with kstrto*()

The usage of strict_strto*() is not preferred, because
strict_strto*() is obsolete. Thus, kstrto*() should be
used.

Signed-off-by: Jingoo Han <jg1.han@samsung.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# bc759721 11-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add snd_hda_get_int_hint() helper function

It'll be used in hda_generic.c, too.

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


# 09b70e85 10-Jan-2013 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Protect user-defined arrays via mutex

The pincfgs, init_verbs and hints set by sysfs or patch might be
changed dynamically on the fly, thus we need to protect it.
Add a simple protection via a mutex.

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


# 6a0f56a7 06-Dec-2012 Takashi Iwai <tiwai@suse.de>

ALSA: Remove the rest of __devinit* in comments

Remove the leftover __devinit* in comments.
They have been commented out because they couldn't fit with __dev*
although they should have matched.

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


# 83012a7c 24-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Clean up CONFIG_SND_HDA_POWER_SAVE

CONFIG_SND_HDA_POWER_SAVE is no longer an experimental feature and its
behavior can be well controlled via the default value and module
parameter. Let's just replace it with the standard CONFIG_PM.

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


# 4918cdab 08-Aug-2012 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Load firmware in hda_intel.c

This is a preliminary work for the deferred probing for
request_firmware() errors at init.

This patch moves the call of request_firmware() to hda_intel.c, and
call it in the earlier stage of probing rather than
azx_probe_continue().

Tested-by: Thierry Reding <thierry.reding@avionic-design.de>
Reviewed-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# 359f9098 01-Nov-2011 Alexander Stein <alexander.stein@systec-electronic.com>

ALSA: hda_hwdep: Fix possible buffer overflow

If a line in the firmware file is larger than the given buffer size (and
so the firmware file size), size is set to a value larger than the actual
buffer size. This results in an overflow in the buffer passed.

Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# d81a6d71 22-Sep-2011 Paul Gortmaker <paul.gortmaker@windriver.com>

sound: Add export.h for THIS_MODULE/EXPORT_SYMBOL where needed

These aren't modules, but they do make use of these macros, so
they will need export.h to get that definition. Previously,
they got it via the implicit module.h inclusion.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>


# ef940b04 28-Sep-2011 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow patching with any vendor/subsystem ids

In the ugly real world, there area really broken devices that don't set
codec SSID correctly. In such a case, the ID can be random, thus the
patching won't work reliably.

For applying the patch forcibly to such a device, the driver will skip
the vendor and/or subsystem ID checks when zero or a negative number is
given in [codec] section.

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


# 2385b789 02-Jun-2010 David Henningsson <diwic@ubuntu.com>

ALSA: hda - Ensure codec patch files are checked for the correct codec ID

Signed-off-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>


# b09f3e78 27-Jan-2010 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Allow override more fields via patch loader

Allow the override of vendor-id, subsystem-id, revision-id and chip name
via patch loading. Updated the document, too.

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


# 014c41fc 27-Dec-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Use strict_strtoul()

Rewrite the codes to use strict_strtoul() instead of simple_strtoul().

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


# e7d2860b 14-Dec-2009 André Goddard Rosa <andre.goddard@gmail.com>

tree-wide: convert open calls to remove spaces to skip_spaces() lib function

Makes use of skip_spaces() defined in lib/string.c for removing leading
spaces from strings all over the tree.

It decreases lib.a code size by 47 bytes and reuses the function tree-wide:
text data bss dec hex filename
64688 584 592 65864 10148 (TOTALS-BEFORE)
64641 584 592 65817 10119 (TOTALS-AFTER)

Also, while at it, if we see (*str && isspace(*str)), we can be sure to
remove the first condition (*str) as the second one (isspace(*str)) also
evaluates to 0 whenever *str == 0, making it redundant. In other words,
"a char equals zero is never a space".

Julia Lawall tried the semantic patch (http://coccinelle.lip6.fr) below,
and found occurrences of this pattern on 3 more files:
drivers/leds/led-class.c
drivers/leds/ledtrig-timer.c
drivers/video/output.c

@@
expression str;
@@

( // ignore skip_spaces cases
while (*str && isspace(*str)) { \(str++;\|++str;\) }
|
- *str &&
isspace(*str)
)

Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Julia Lawall <julia@diku.dk>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Cc: Neil Brown <neilb@suse.de>
Cc: Kyle McMartin <kyle@mcmartin.ca>
Cc: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Cc: David Howells <dhowells@redhat.com>
Cc: <linux-ext4@vger.kernel.org>
Cc: Samuel Ortiz <samuel@sortiz.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# a2f6309e 11-Nov-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add power on/off counter

Added the power on/off counter and expose via sysfs files.
The sysfs files, power_on_acct and power_off_acct, are created under
each codec hwdep sysfs directory (e.g. /sys/class/sound/hwC0D0).
The files show the msec length of the codec power-on and power-off,
respectively.

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


# 4ea6fbc8 17-Jun-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add patch module option

Added the patch module option to apply a "patch" as a firmware to
modify pin configurations or give additional hints to the driver
before actually initializing and configuring the codec.

This can be used as a workaround when the BIOS doesn't give sufficient
information or give wrong information that doesn't match with the real
hardware setup, until it's fixed statically in the driver via a quirk.

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


# 812a2cca 16-May-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Split codec->name to vendor and chip name strings

Split the name string in hda_codec struct to vendor_name and chip_name
strings to be stored directly from the preset name.
Since mostly only the chip name is referred in many patch_*.c, this
results in the reduction of many codes in the end.

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


# bb6ac72f 13-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - power up before codec initialization

Change the power state of each widget before starting the initialization
work so that all verbs are executed properly.

Also, keep power-up during hwdep reconfiguration.

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


# ab1726f9 02-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add show for init_verbs and hints sysfs entries

Added the show method for init_verbs and hints hwdep sysfs entries.
They show the current values.

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


# 43b62713 02-Mar-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add hint string helper functions

Added snd_hda_get_hint() and snd_hda_get_bool_hint() helper functions
to retrieve a hint value.

Internally, the hint is stored in a pair of two strings, key and val.

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


# a65d629c 23-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add pseudo device-locking for clear/reconfig

Added the pseudo device-locking using card->shutdown flag to avoid
the crash via clear/reconfig during operations.

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


# 346ff70f 23-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Rename {override,cur}_pin with {user,driver}_pin

Rename from override_pin and cur_pin with user_pin and driver_pin,
respectively, to be a bit more intuitive.

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


# 3be14149 20-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add generic pincfg initialization

Added the generic pincfg cache and save/restore functions.
Also introduced the pin-overriding via hwdep sysfs.

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


# 55290e19 20-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix parse of init_verbs sysfs entry

Fixed the parse of init_verbs hwdep sysfs entry.
Simplieied using sscanf.

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


# 26a74f1f 11-Feb-2009 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Register (new) devices at reconfig

The devices that have been newly added during reconfig must be
registered. Otherwise they won't be visible to user-space.

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


# 1289e9e8 27-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Modularize HD-audio driver

Split the monolithc HD-audio driver into several pieces:
- snd-hda-intel HD-audio PCI controller driver; loaded via udev
- snd-hda-codec HD-audio codec bus driver
- snd-hda-codec-* Specific HD-audio codec drivers

When built as modules, snd-hda-codec (that is invoked by snd-hda-intel)
looks up the codec vendor ID and loads the corresponding codec module
automatically via request_module().

When built in a kernel, each codec drivers are statically hooked up
before probing the PCI.

This patch adds appropriate EXPORT_SYMBOL_GPL()'s and the module
information for each driver, and driver-linking codes between
codec-bus and codec drivers.

TODO:
- Avoid EXPORT_SYMBOL*() when built-in kernel
- Restore __devinit appropriately depending on the condition

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


# 529bd6c4 27-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Fix PCM reconfigure

The reconfiguration of PCM affected all PCM streams on the bus, but
this this should be done rather only for the target codec.

This patch does the following:
- introduce bitmap indicating the PCM device usages on a hda_bus
- refactor the PCM build functions
- fix __devinit prefix in some fucntions
- add a proper ifdef around HDA-reconfig-specific functions

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


# e7ee058c 21-Nov-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Make CONFIG_SND_HDA_RECONFIG for codec reconfiguration

Make the codec re-configuration feature selectable via Kconfig,
CONFIG_SND_HDA_RECONFIG.
Also mark it as experimental (as it really is).

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


# 1e1be432 30-Jul-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add hints for reconfig

This patch adds the "hints" for reconfiguring codecs. The hints
are simply string arrays and can be freely used/parsed by the codec
patch. The hints can be input via hwdep sysfs files.

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


# 11aeff08 30-Jul-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add init_verbs entries

This patch enables the additional init verbs for each codec. The verbs
can be entered via hwdep sysfs file. These verbs are executed at
reconfiguring the codec for non-standard setups like overriding
the pin-defcfg.

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


# d7ffba19 30-Jul-2008 Takashi Iwai <tiwai@suse.de>

ALSA: hda - Add sysfs entries to hwdep devices

Added the sysfs entries to hwdep devices so that the new features
like reconfiguration can be done via sysfs.

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


# 62cf872a 19-May-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Replace CONFIG_SND_DEBUG_DETECT with CONFIG_SND_DEBUG_VERBOSE

Replace CONFIG_SND_DEBUG_DETECT with CONFIG_SND_DEBUG_VERBOSE to
represent its meaning more better. This config isn't provided only
for the detection but for more verbose debug prints in general.

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


# 9004acc7 08-Jan-2008 Takashi Iwai <tiwai@suse.de>

[ALSA] Remove sound/driver.h

This header file exists only for some hacks to adapt alsa-driver
tree. It's useless for building in the kernel. Let's move a few
lines in it to sound/core.h and remove it.
With this patch, sound/driver.h isn't removed but has just a single
compile warning to include it. This should be really killed in
future.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>


# 312d045c 31-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Fix compile warning in snd_hwdep_ioctl_compat()

Fix missing cast:
sound/pci/hda/hda_hwdep.c:86: warning: passing argument 4 of 'hda_hwdep_ioctl' makes integer from pointer without a cast

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>


# 2807314d 27-Jul-2007 Takashi Iwai <tiwai@suse.de>

[ALSA] hda-intel - Add hwdep interface

Added a hwdep interface for each codec (enabled per kconfig).
This interface can be used for reading/writing HD-audio verbs
and other purposes as future extensions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>