OSDN Git Service

uclinux-h8/linux.git
6 years agoALSA: rawmidi: Tidy up coding styles
Takashi Iwai [Tue, 17 Jul 2018 20:32:52 +0000 (22:32 +0200)]
ALSA: rawmidi: Tidy up coding styles

Just minor coding style fixes like removal of superfluous white space,
adding missing blank lines, etc.  No actual code changes at all.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Tue, 17 Jul 2018 20:26:54 +0000 (22:26 +0200)]
Merge branch 'for-linus' into for-next

Back-merge for further cleanup / improvements on rawmidi and HD-audio
stuff.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: rawmidi: Change resized buffers atomically
Takashi Iwai [Tue, 17 Jul 2018 15:26:43 +0000 (17:26 +0200)]
ALSA: rawmidi: Change resized buffers atomically

The SNDRV_RAWMIDI_IOCTL_PARAMS ioctl may resize the buffers and the
current code is racy.  For example, the sequencer client may write to
buffer while it being resized.

As a simple workaround, let's switch to the resized buffer inside the
stream runtime lock.

Reported-by: syzbot+52f83f0ea8df16932f7f@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: emu8000: Use swap macro in snd_emu8000_sample_new
Gustavo A. R. Silva [Tue, 17 Jul 2018 15:06:10 +0000 (10:06 -0500)]
ALSA: emu8000: Use swap macro in snd_emu8000_sample_new

Make use of the swap macro and remove unnecessary variable *tmp*. This
makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: emu10k1_patch: Use swap macro in snd_emu10k1_sample_new
Gustavo A. R. Silva [Tue, 17 Jul 2018 15:00:43 +0000 (10:00 -0500)]
ALSA: emu10k1_patch: Use swap macro in snd_emu10k1_sample_new

Make use of the swap macro and remove unnecessary variable *tmp*. This
makes the code easier to read and maintain.

This code was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Add Panasonic CF-SZ6 headset jack quirk
YOKOTA Hiroshi [Sun, 1 Jul 2018 09:30:01 +0000 (18:30 +0900)]
ALSA: hda/realtek - Add Panasonic CF-SZ6 headset jack quirk

This adds some required quirk when uses headset or headphone on
Panasonic CF-SZ6.

Signed-off-by: YOKOTA Hiroshi <yokota.hgml@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda: add mute led support for HP ProBook 455 G5
Po-Hsu Lin [Mon, 16 Jul 2018 07:50:08 +0000 (15:50 +0800)]
ALSA: hda: add mute led support for HP ProBook 455 G5

Audio mute led does not work on HP ProBook 455 G5,
this can be fixed by using CXT_FIXUP_MUTE_LED_GPIO to support it.

BugLink: https://bugs.launchpad.net/bugs/1781763
Reported-by: James Buren
Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda: use PCI_BASE_CLASS_DISPLAY to replace PCI_CLASS_DISPLAY_VGA
Jim Qu [Mon, 16 Jul 2018 06:06:34 +0000 (14:06 +0800)]
ALSA: hda: use PCI_BASE_CLASS_DISPLAY to replace PCI_CLASS_DISPLAY_VGA

Except PCI_CLASS_DISPLAY_VGA, some PCI class is sometimes
PCI_CLASS_DISPLAY_3D or PCI_CLASS_DISPLAY_OTHER.

Signed-off-by: Jim Qu <Jim.Qu@amd.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-audio: Tidy up logic for Processing Unit min/max values
Jorge Sanjuan [Wed, 11 Jul 2018 12:37:55 +0000 (13:37 +0100)]
ALSA: usb-audio: Tidy up logic for Processing Unit min/max values

This patch refactors the processing units min/max calculation logic
for the mixer controls and fixes an issue where the Mode Select
checking of the Up/Down mixers doesn't differentiate between the
UAC1 and UAC2 Control Selector (0x02) and the UAC3 one which is
different (0x01).

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-audio: Unify virtual type units type to UAC3 values
Jorge Sanjuan [Wed, 11 Jul 2018 12:37:54 +0000 (13:37 +0100)]
ALSA: usb-audio: Unify virtual type units type to UAC3 values

The Audio Control interface descriptor subtypes do not match
across all the UAC versions. That makes reusability of the
"virtual type" (Mixer, Processors, Selectors, etc) terminals
difficult. It also makes the mixer get the default names for
the virtual terminals wrong due to the overlap.

This patch proposes an unified approach by always using the most
comprehensive spec version to define them all (in this case UAC3).

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-audio: Add support for Processing Units in UAC3
Jorge Sanjuan [Wed, 11 Jul 2018 12:37:53 +0000 (13:37 +0100)]
ALSA: usb-audio: Add support for Processing Units in UAC3

This patch adds support for the Processig Units defined in
the UAC3 spec. The main difference with the previous specs
is the lack of on/off switches in the controls for these
units and the addiction of the new Multi Function Processing
Unit.

The current version of the UAC3 spec doesn't define any
useful controls for the new Multi Function Processing Unit
so no control will get created once this unit is parsed.

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-audio: Processing Unit controls parsing in UAC2
Jorge Sanjuan [Wed, 11 Jul 2018 12:37:52 +0000 (13:37 +0100)]
ALSA: usb-audio: Processing Unit controls parsing in UAC2

Current support for UAC2 Processing Units does the parsing
as one control per bit in the bitmap. However, the UAC2 spec
defines the controls as bit pairs where b01 means read-only
and b11 means read/write control.

This patch fixes that and uses the helper functions for checking
controls readability/writability when the control is defined as
bit pairs (UAC2 and UAC3).

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-audio: Add support for Selector Units in UAC3
Jorge Sanjuan [Wed, 11 Jul 2018 12:37:51 +0000 (13:37 +0100)]
ALSA: usb-audio: Add support for Selector Units in UAC3

This patch add support for Selector Units and Clock Selector Units
defined in the new UAC3 spec.

Selector Units play a really important role in the new UAC3 spec as
Processing Units do not define an on/off switch control anymore.
This forces topology designers to add bypass paths in the topology
to enable/dissable the Processing Units.

Signed-off-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: cs46xx: remove redundant pointer 'ins'
Colin Ian King [Mon, 16 Jul 2018 09:03:15 +0000 (10:03 +0100)]
ALSA: cs46xx: remove redundant pointer 'ins'

Pointer 'ins' is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'ins' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: ali5451: remove redundant pointer 'codec'
Colin Ian King [Mon, 16 Jul 2018 08:57:38 +0000 (09:57 +0100)]
ALSA: ali5451: remove redundant pointer 'codec'

Pointer 'codec' is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'codec' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: sb8: remove redundant pointer runtime
Colin Ian King [Mon, 16 Jul 2018 08:52:56 +0000 (09:52 +0100)]
ALSA: sb8: remove redundant pointer runtime

Pointer runtime is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'runtime' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: gus: remove redundant pointer private_data
Colin Ian King [Mon, 16 Jul 2018 08:49:38 +0000 (09:49 +0100)]
ALSA: gus: remove redundant pointer private_data

Pointer private_data is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'private_data' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: es1688: remove redundant pointer chip
Colin Ian King [Mon, 16 Jul 2018 08:43:08 +0000 (09:43 +0100)]
ALSA: es1688: remove redundant pointer chip

Pointer chip is being assigned but is never used hence it is
redundant and can be removed.

Cleans up clang warning:
warning: variable 'chip' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: opl3: remove redundant pointer opl3
Colin Ian King [Mon, 16 Jul 2018 08:34:51 +0000 (09:34 +0100)]
ALSA: opl3: remove redundant pointer opl3

Variable opl3 is being assigned but is never used hence it is
redundant and can be removed.

Cleans up several clang warnings:
warning: variable 'opl3' set but not used [-Wunused-but-set-variable]

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Update a pci quirk device name
Alastair Bridgewater [Wed, 11 Jul 2018 22:09:46 +0000 (18:09 -0400)]
ALSA: hda/ca0132: Update a pci quirk device name

The PCI subsystem in question for this quirk rule has been
identified as a Gigabyte GA-Z170X-Gaming 7 motherboard.  Set the
device name appropriately.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Reviewed-by: Connor McAdams <conmanx360@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Add Recon3Di quirk for Gigabyte G1.Sniper Z97
Alastair Bridgewater [Wed, 11 Jul 2018 22:09:45 +0000 (18:09 -0400)]
ALSA: hda/ca0132: Add Recon3Di quirk for Gigabyte G1.Sniper Z97

These motherboards have Sound Core3D and apparently "support"
Recon3Di.  Added to the quirk list as QUIRK_R3DI.

Issue report, PCI Subsystem ID, and testing by a contributor on
IRC who wished to remain anonymous.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Reviewed-by: Connor McAdams <conmanx360@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: pcm: Fix snd_interval_refine first/last with open min/max
Timo Wischer [Tue, 10 Jul 2018 15:28:45 +0000 (17:28 +0200)]
ALSA: pcm: Fix snd_interval_refine first/last with open min/max

Without this commit the following intervals [x y), (x y) were be
replaced to (y-1 y) by snd_interval_refine_last(). This was also done
if y-1 is part of the previous interval.
With this changes it will be replaced with [y-1 y) in case of y-1 is
part of the previous interval. A similar behavior will be used for
snd_interval_refine_first().

This commit adapts the changes for alsa-lib of commit
9bb985c ("pcm: snd_interval_refine_first/last: exclude value only if
also excluded before")

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: pcm: Allow drivers to set R/W wait time.
Liam Girdwood [Fri, 6 Jul 2018 12:50:36 +0000 (13:50 +0100)]
ALSA: pcm: Allow drivers to set R/W wait time.

Currently ALSA core blocks userspace for about 10 seconds for PCM R/W IO.
This needs to be configurable for modern hardware like DSPs where no
pointer update in milliseconds can indicate terminal DSP errors.

Add a substream variable to set the wait time in ms. This allows userspace
and drivers to recover more quickly from terminal DSP errors.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - two more lenovo models need fixup of MIC_LOCATION
Hui Wang [Fri, 6 Jul 2018 07:14:11 +0000 (15:14 +0800)]
ALSA: hda/realtek - two more lenovo models need fixup of MIC_LOCATION

We have two new lenovo desktop models which need to apply the fixup of
ALC294_FIXUP_LENOVO_MIC_LOCATION, and they have the same pin cfg as
the machine with subsystem id:0x17aa3136, now use the pincfg table
to apply the fixup for them.

Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: pcm: Use snd_pcm_stop_xrun() for xrun injection
Takashi Iwai [Wed, 4 Jul 2018 13:08:05 +0000 (15:08 +0200)]
ALSA: pcm: Use snd_pcm_stop_xrun() for xrun injection

Basically the xrun injection routine can simply call the standard
helper snd_pcm_stop_xrun(), but with one exception: it may be called
even when the stream is closed.

Make snd_pcm_stop_xrun() more robust and check the NULL runtime state,
and simplify xrun injection code by calling it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: pcm: trace XRUN event at injection, too
Takashi Iwai [Wed, 4 Jul 2018 12:46:27 +0000 (14:46 +0200)]
ALSA: pcm: trace XRUN event at injection, too

The PCM xrun injection triggers directly snd_pcm_stop() without the
standard xrun handler, hence it's not recorded on the event buffer.
Ditto for snd_pcm_stop_xrun() call and SNDRV_PCM_IOCTL_XRUN ioctl.
They are inconvenient from the debugging POV.

Let's make them to trigger XRUN via the standard helper more
consistently.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoMerge branch 'topic/hda-core-intel' into for-next
Takashi Iwai [Tue, 3 Jul 2018 10:51:26 +0000 (12:51 +0200)]
Merge branch 'topic/hda-core-intel' into for-next

Merge the development branch for HD-audio ext bus refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Handle pm failure during hotplug
Chris Wilson [Wed, 27 Jun 2018 06:25:32 +0000 (07:25 +0100)]
ALSA: hda - Handle pm failure during hotplug

Obtaining the runtime pm wakeref can fail, especially in a hotplug
scenario where i915.ko has been unloaded. If we do not catch the
failure, we end up with an unbalanced pm.

v2 additions by tiwai:
hdmi_present_sense() checks the return value and handle only a
negative error case and bails out only if it's really still suspended.
Also, snd_hda_power_down() is called at the error path so that the
refcount is balanced.

Along with it, the spec->pcm_lock is taken outside
hdmi_present_sense() in the caller side, so that it won't cause
deadlock at reentrace via runtime resume.

v3 fix by tiwai:
Missing linux/pm_runtime.h is included.

References: 222bde03881c ("ALSA: hda - Fix mutex deadlock at HDMI/DP hotplug")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb-midi: use irqsave() in USB's complete callback
John Ogness [Sun, 1 Jul 2018 15:28:08 +0000 (17:28 +0200)]
ALSA: usb-midi: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: usb: caiaq: audio: use irqsave() in USB's complete callback
John Ogness [Sun, 1 Jul 2018 15:28:07 +0000 (17:28 +0200)]
ALSA: usb: caiaq: audio: use irqsave() in USB's complete callback

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Signed-off-by: John Ogness <john.ogness@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Acked-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: snd-aoa: add of_node_put() in error path
Nicholas Mc Guire [Fri, 29 Jun 2018 17:07:42 +0000 (19:07 +0200)]
ALSA: snd-aoa: add of_node_put() in error path

 Both calls to of_find_node_by_name() and of_get_next_child() return a
node pointer with refcount incremented thus it must be explicidly
decremented here after the last usage. As we are assured to have a
refcounted  np  either from the initial
of_find_node_by_name(NULL, name); or from the of_get_next_child(gpio, np)
in the while loop if we reached the error code path below, an
x of_node_put(np) is needed.

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: commit f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/hdmi - Don't fall back to generic when i915 binding fails
Takashi Iwai [Wed, 27 Jun 2018 07:54:46 +0000 (09:54 +0200)]
ALSA: hda/hdmi - Don't fall back to generic when i915 binding fails

When i915 component binding fails, it means that HDMI isn't applicable
anyway.  Although the probe with the generic HDMI parser would still
work, it's essentially useless, hence better to be left unbound.

This patch mimics the probe_id field at failing the i915 component
binding so that the generic HDMI won't be bound after that.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge
Kai-Heng Feng [Thu, 28 Jun 2018 07:28:24 +0000 (15:28 +0800)]
ALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge

This patch can make audio controller in AMD Raven Ridge gets runtime
suspended to D3, to save ~1W power when it's not in use.

Cc: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: add extended ops in the hdac_bus
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:58 +0000 (22:53 -0500)]
ALSA: hdac: add extended ops in the hdac_bus

Add extended ops in the hdac_bus to allow calling the ASoC HDAC library
ops to reuse the legacy HDA codec drivers with ASoC framework.
Extended ops are used by the legacy codec drivers to call into
hdac_hda library, in the subsequent patches..

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:57 +0000 (22:53 -0500)]
ALSA: hdac: remove memory allocation from snd_hdac_ext_bus_device_init

Remove memory allocation within snd_hdac_ext_bus_device_init, to make
its behaviour identical to snd_hdac_bus_device_init. So that caller
can allocate the parent data structure containing hdac_device.
This API change helps in reusing the legacy HDA codec drivers with
ASoC platform drivers.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda: split snd_hda_codec_new function
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:56 +0000 (22:53 -0500)]
ALSA: hda: split snd_hda_codec_new function

Split snd_hda_codec_new into two separate functions.
snd_hda_codec_device_init allocates memory and registers with bus.
snd_hda_codec_device_new initialializes the fields and performs
snd_device_new. This enables reuse of legacy HDA codec drivers as ASoC
codec drivers.

In addition mark some functions with EXPORT_SYMBOL_GPL so that it can
be called by ASoC wrapper around the legacy HDA driver (hdac_hda).

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: ext: add wait for codec to respond after link reset
Rakesh Ughreja [Sat, 2 Jun 2018 03:54:00 +0000 (22:54 -0500)]
ALSA: hdac: ext: add wait for codec to respond after link reset

As per HDA spec section 4.3 - Codec Discovery, the software shall wait
for atleast 521usec for codec to respond after link reset.
With the multi-link capability each link is turned ON/OFF individually.
Link controller drives reset signal when it is turned ON.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: Remove usage of struct hdac_ext_driver, use hdac_driver instead
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:51 +0000 (22:53 -0500)]
ALSA: hdac: Remove usage of struct hdac_ext_driver, use hdac_driver instead

This patch removes the hdac_ext_driver structure. The legacy and
enhanced HDaudio capabilities can be handled in a backward-compatible
way without separate definitions.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: Remove usage of struct hdac_ext_bus and use hdac_bus instead
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:50 +0000 (22:53 -0500)]
ALSA: hdac: Remove usage of struct hdac_ext_bus and use hdac_bus instead

This patch removes the hdac_ext_bus structure. The legacy and
enhanced HDaudio capabilities can be handled in a backward-compatible
way without separate definitions.

Follow-up patches in this series handle the driver definition.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hdac: Remove usage of struct hdac_ext_device and use hdac_device instead
Rakesh Ughreja [Sat, 2 Jun 2018 03:53:49 +0000 (22:53 -0500)]
ALSA: hdac: Remove usage of struct hdac_ext_device and use hdac_device instead

This patch removes the hdac_ext_device structure. The legacy and
enhanced HDaudio capabilities can be handled in a backward-compatible
way without separate definitions.

Follow-up patches in this series handle the bus and driver definitions.

Signed-off-by: Rakesh Ughreja <rakesh.a.ughreja@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Move in_pm accessors to HDA core
Takashi Iwai [Wed, 27 Jun 2018 07:03:51 +0000 (09:03 +0200)]
ALSA: hda - Move in_pm accessors to HDA core

The in_pm atomic in hdac_device is an important field used as a flag
as well as a refcount for PM.  The existing snd_hdac_power_up/down
helpers already refer to it in the HD-audio core code, while the code
to actually setting the value (atomic_inc() / _dec()) is open-coded in
HDA legacy side, which is hard to find.

This patch adds the helper functions to set/reset the in_pm counter to
HDA core and use them in HDA legacy side, for making it clearer who /
where the PM is managed.

There is no functional changes, just code refactoring.

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: intel_hdmi: Use strlcpy() instead of strncpy()
Takashi Iwai [Wed, 27 Jun 2018 12:59:00 +0000 (14:59 +0200)]
ALSA: intel_hdmi: Use strlcpy() instead of strncpy()

hdmi_lpe_audio_probe() copies the pcm name string via strncpy(), but
as a gcc8 warning suggests, it misses a NUL terminator, and unlikely
the expected result.

Use the proper one, strlcpy() instead.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Kill snd_hda_codec_update_cache()
Takashi Iwai [Wed, 27 Jun 2018 09:43:09 +0000 (11:43 +0200)]
ALSA: hda - Kill snd_hda_codec_update_cache()

snd_hda_codec_update_cache() used to serve for a slightly different
purpose from snd_hdac_write_cache(), but now both of them became
identical.

Let's unify and replace with the latter one consistently.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Comprehensive model list for ALC882 & co
Takashi Iwai [Tue, 26 Jun 2018 15:17:53 +0000 (17:17 +0200)]
ALSA: hda/realtek - Comprehensive model list for ALC882 & co

More comprehensive list of model strings for ALC882 & co.

Also corrected the subsection in models.rst, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Comprehensive model list for ALC262
Takashi Iwai [Tue, 26 Jun 2018 15:02:08 +0000 (17:02 +0200)]
ALSA: hda/realtek - Comprehensive model list for ALC262

Added a few missing entries for ALC262 model strings.
All about specific hardwares.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Comprehensive model list for ALC268
Takashi Iwai [Tue, 26 Jun 2018 14:56:41 +0000 (16:56 +0200)]
ALSA: hda/realtek - Comprehensive model list for ALC268

Add the missing entry for ALC268 model strings.
Only "spdif" was missing, and that's it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Comprehensive model list for ALC259 & co
Takashi Iwai [Tue, 26 Jun 2018 13:09:25 +0000 (15:09 +0200)]
ALSA: hda/realtek - Comprehensive model list for ALC259 & co

Like the previous commit for ALC662, let's give more comprehensive
list of model entries for ALC269 & co as well.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Comprehensive model list for ALC662 & co
Takashi Iwai [Tue, 26 Jun 2018 05:42:40 +0000 (07:42 +0200)]
ALSA: hda/realtek - Comprehensive model list for ALC662 & co

ALC662 and others have far more fixup entries than the model table.
Let's add more model string entries so that user can test / debug
without compiling kernels at each time.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: Fix references to Documentation/.*/MultiSound
Mauro Carvalho Chehab [Tue, 26 Jun 2018 09:24:40 +0000 (06:24 -0300)]
ALSA: Fix references to Documentation/.*/MultiSound

Now that the documentation/script file got restored, fix the
references within the Kernel tree.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: multisound.sh: update module namespace
Mauro Carvalho Chehab [Tue, 26 Jun 2018 09:24:39 +0000 (06:24 -0300)]
ALSA: multisound.sh: update module namespace

The modules for the cards described here changed their names.
Update accordingly.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA:: multisound.sh: fix script to make it build with modern tools
Mauro Carvalho Chehab [Tue, 26 Jun 2018 09:24:38 +0000 (06:24 -0300)]
ALSA:: multisound.sh: fix script to make it build with modern tools

The script is old and produce some warnings and errors, because
it lacks including stdlib.h and io.h is at sys/io.h.

Fix it to run with the tools found on modern Linux distros.

Tested building it on Fedora 28.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agosound: restore MultiSound script
Mauro Carvalho Chehab [Tue, 26 Jun 2018 09:24:37 +0000 (06:24 -0300)]
sound: restore MultiSound script

This script is mentioned at multisound Kconfig and files. As the
driver still exists, it probably makes sense to restore it.

Fixes: 727dede0ba8a ("sound: Retire OSS")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: seq: Fix UBSAN warning at SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT ioctl
Takashi Iwai [Mon, 25 Jun 2018 09:13:59 +0000 (11:13 +0200)]
ALSA: seq: Fix UBSAN warning at SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT ioctl

The kernel may spew a WARNING with UBSAN undefined behavior at
handling ALSA sequencer ioctl SNDRV_SEQ_IOCTL_QUERY_NEXT_CLIENT:

UBSAN: Undefined behaviour in sound/core/seq/seq_clientmgr.c:2007:14
signed integer overflow:
2147483647 + 1 cannot be represented in type 'int'
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x122/0x1c8 lib/dump_stack.c:113
 ubsan_epilogue+0x12/0x86 lib/ubsan.c:159
 handle_overflow+0x1c2/0x21f lib/ubsan.c:190
  __ubsan_handle_add_overflow+0x2a/0x31 lib/ubsan.c:198
 snd_seq_ioctl_query_next_client+0x1ac/0x1d0 sound/core/seq/seq_clientmgr.c:2007
 snd_seq_ioctl+0x264/0x3d0 sound/core/seq/seq_clientmgr.c:2144
 ....

It happens only when INT_MAX is passed there, as we're incrementing it
unconditionally.  So the fix is trivial, check the value with
INT_MAX.  Although the bug itself is fairly harmless, it's better to
fix it so that fuzzers won't hit this again later.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200211
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: timer: Fix UBSAN warning at SNDRV_TIMER_IOCTL_NEXT_DEVICE ioctl
Takashi Iwai [Mon, 25 Jun 2018 09:09:11 +0000 (11:09 +0200)]
ALSA: timer: Fix UBSAN warning at SNDRV_TIMER_IOCTL_NEXT_DEVICE ioctl

The kernel may spew a WARNING about UBSAN undefined behavior at
handling ALSA timer ioctl SNDRV_TIMER_IOCTL_NEXT_DEVICE:

UBSAN: Undefined behaviour in sound/core/timer.c:1524:19
signed integer overflow:
2147483647 + 1 cannot be represented in type 'int'
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x122/0x1c8 lib/dump_stack.c:113
 ubsan_epilogue+0x12/0x86 lib/ubsan.c:159
 handle_overflow+0x1c2/0x21f lib/ubsan.c:190
 __ubsan_handle_add_overflow+0x2a/0x31 lib/ubsan.c:198
 snd_timer_user_next_device sound/core/timer.c:1524 [inline]
 __snd_timer_user_ioctl+0x204d/0x2520 sound/core/timer.c:1939
 snd_timer_user_ioctl+0x67/0x95 sound/core/timer.c:1994
 ....

It happens only when a value with INT_MAX is passed, as we're
incrementing it unconditionally.  So the fix is trivial, check the
value with INT_MAX.  Although the bug itself is fairly harmless, it's
better to fix it so that fuzzers won't hit this again later.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200213
Reported-and-tested-by: Team OWL337 <icytxw@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Apply PRE_PROBE fixup after ALC269 codec variant setups
Takashi Iwai [Fri, 15 Jun 2018 09:55:02 +0000 (11:55 +0200)]
ALSA: hda/realtek - Apply PRE_PROBE fixup after ALC269 codec variant setups

Currently patch_alc269() calls the fixup with HDA_FIXUP_ACT_PRE_PROBE
before setting up the codec model-specific setups (e.g. setting
codec_variant or mixer_nid setup).  This is rather confusing as others
do call the *_PRE_PROBE fixup after such a setup.  Due to this
disorder, we have to override spec->shutup not at the usual
HDA_FIXUP_ACT_PRE_PROBE but the unusual HDA_FIXUP_ACT_PROBE time.

This patch corrects the fixup call orders in patch_alc269(), and also
corrects the action to set up spec->shutup accordingly.

No functional changes but just refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/via - Use standard verb containers
Takashi Iwai [Wed, 20 Jun 2018 15:27:50 +0000 (17:27 +0200)]
ALSA: hda/via - Use standard verb containers

In this patch, the remaining static init verbs in VIA codec driver are
converted to the standard snd_hda_add_verbs() calls.  The conversion
is straightforward, but one change to be noted is the place of calls:
since these verbs are supposed to be executed at the beginning of the
init / resume procedure, we need to add snd_hda_add_verbs() calls
before calling the other parsers.

This is merely a cleanup, no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/via - Simplify control management
Takashi Iwai [Wed, 20 Jun 2018 15:20:42 +0000 (17:20 +0200)]
ALSA: hda/via - Simplify control management

This patch replaces the control element creations in VIA codec driver
with the standard snd_hda_gen_add_kctl() calls as a cleanup.  There
are two major fields targeted by this patch: the beep controls and
static init controls.

The former is converted just like other codec drivers do.  The
spec->beep_amp field can be eliminated by this change as well.

The latter, static init controls, are replaced simply with explicit
snd_hda_gen_add_kctl() calls.

After these conversions, via_build_controls() becomes superfluous and
replaced with snd_hda_gen_build_controls(), too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/via - Rewrite with error goto
Takashi Iwai [Wed, 20 Jun 2018 20:36:17 +0000 (22:36 +0200)]
ALSA: hda/via - Rewrite with error goto

Currently VIA codec driver invokes via_free() at each place of the
error path.  Move the error handling to the end of each function
commonly and do goto-error as a standard idiom.

This is a preliminary patch for the further cleanups, and no
functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/cirrus - Simplify creation of new controls
Takashi Iwai [Wed, 20 Jun 2018 15:10:51 +0000 (17:10 +0200)]
ALSA: hda/cirrus - Simplify creation of new controls

This patch moves the mixer creation code in Cirrus codec driver from
its own build_controls callback to snd_hda_gen_add_kctl() for
simplification.

As a bonus, this allows us to remove the cs421x_build_controls as it
becomes identical with snd_hda_gen_build_controls().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/conexant - Clean up beep code
Takashi Iwai [Wed, 20 Jun 2018 15:06:58 +0000 (17:06 +0200)]
ALSA: hda/conexant - Clean up beep code

Like the previous commit for Realtek codec, the similar cleanup work
can be applied to Conexant codec, too.  A slight difference is that
the call of cx_auto_parse_beep() is moved after
snd_hda_gen_parse_auto_config().  It's not strictly needed, but it'd
be good to make the creation of such beep mixers at the end, which
matches with the former situation.

Along with this conversion, cx_auto_build_controls() becomes just
calling snd_hda_gen_build_controls(), so it's simply replaced with
snd_hda_gen_build_controls.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Use common helper for creating beep controls
Takashi Iwai [Wed, 20 Jun 2018 10:52:46 +0000 (12:52 +0200)]
ALSA: hda/realtek - Use common helper for creating beep controls

In the Realtek codec driver, we used to build kctl elements for beep
mixer in the own build_controls callback.  This is an open-code and
can be covered by the standard feature of the generic parser with
snd_hda_gen_add_kctl() instead.

Also, after the conversion, spec->beep_amp becomes superfluous; hence
it's removed along with the conversion.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Use common helper for creating ALC268 beep controls
Takashi Iwai [Wed, 20 Jun 2018 10:50:11 +0000 (12:50 +0200)]
ALSA: hda/realtek - Use common helper for creating ALC268 beep controls

The beep mixer controls are the only remaining stuff that uses
spec->mixers[] array, and they can be well converted to the standard
helper in the generic parser, snd_hda_gen_add_kctl().

This simplifies the code, especially the superfluous mixers and
num_mixers fields can be now removed from alc_spec.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Use common GPIO mask for ALC660VD ASUS fixup
Takashi Iwai [Tue, 19 Jun 2018 21:05:47 +0000 (23:05 +0200)]
ALSA: hda/realtek - Use common GPIO mask for ALC660VD ASUS fixup

The ALC660VD_FIX_ASUS_GPIO1 quirk requires to set up GPIO bit0 ON
while bit 1 OFF.  Implement the fixup function and convert from the
static init verbs.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Simplify Dell XPS13 GPIO handling
Takashi Iwai [Tue, 19 Jun 2018 21:04:03 +0000 (23:04 +0200)]
ALSA: hda/realtek - Simplify Dell XPS13 GPIO handling

Dell XPS13 has multi-step fixups, and one of them
(ALC288_FIXUP_DELL_XPS_13_GPIO6) corresponds to the management of GPIO
bit6 (0x40).  It used to be a static init verbs (to turn *off* the
bit6).

In this patch, we convert it as the gpio_mask and gpio_dir
initializations folded in the existing fixup function.  With this
change, ALC288_FIXUP_DELL_XPS_13_GPIO6 becomes superfluous, thus it's
removed.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Convert some manual GPIO setups
Takashi Iwai [Tue, 19 Jun 2018 21:00:03 +0000 (23:00 +0200)]
ALSA: hda/realtek - Convert some manual GPIO setups

This patch converts the remaining static init verbs for GPIO bits with
the common gpio_* fields management.  Only the verbs setting the GPIO
data bits are targeted in this patch.  The rest will be changed in
later patches.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Simplify mute LED GPIO handling
Takashi Iwai [Tue, 19 Jun 2018 20:47:30 +0000 (22:47 +0200)]
ALSA: hda/realtek - Simplify mute LED GPIO handling

Now we can simplify the mute LED GPIO handling as well.  Each fixup
dealing with GPIO for the mute LED controls defined the static init
verbs, and they are converted to the common GPIO bit fields with the
new helper, alc_fixup_hp_gpio_led().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Simplify alc885_fixup_macpro_gpio()
Takashi Iwai [Tue, 19 Jun 2018 20:34:26 +0000 (22:34 +0200)]
ALSA: hda/realtek - Simplify alc885_fixup_macpro_gpio()

The fixup for Macbook Pro is nothing but setting the GPIO bits as
usual but with one exception: it adds some delay at writing the GPIO
bits.

Add a flag to put the conditional delay in the common helper, and
clean up alc885_fixup_macpro_gpio() with the new flag.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Consolidate gpio_data and gpio_led
Takashi Iwai [Tue, 19 Jun 2018 20:32:29 +0000 (22:32 +0200)]
ALSA: hda/realtek - Consolidate gpio_data and gpio_led

Until now, two fields, gpio_data and gpio_led, coexist in alc_spec
although basically both of them serve for the same purpose -- the GPIO
data bits.

This patch consolidates both usages and eliminates the superfluous
gpio_led field.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Add GPIO data update helper
Takashi Iwai [Tue, 19 Jun 2018 20:28:22 +0000 (22:28 +0200)]
ALSA: hda/realtek - Add GPIO data update helper

For updating GPIO bits dynamically, provide a new helper, and use it
from the alc260 automute hook.  This helper will be used by other
places in future, too.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Manage GPIO bits commonly
Takashi Iwai [Tue, 19 Jun 2018 20:22:41 +0000 (22:22 +0200)]
ALSA: hda/realtek - Manage GPIO bits commonly

Currently the GPIO bits are managed by individual verbs in some cases
while toggled dynamically in other cases.  For simplifying the GPIO
management, define the GPIO mask, dir and data bits in alc_spec
fields, and refer to / set them consistently from all places.

As a first step, along with the definition of the new gpio_* fields,
this patch replaces the static verbs that are used at initialization
and fixups with the common helper functions.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Allow skipping spec->init_amp detection
Takashi Iwai [Thu, 21 Jun 2018 14:37:54 +0000 (16:37 +0200)]
ALSA: hda/realtek - Allow skipping spec->init_amp detection

Some devices have the overrides of spec->init_amp at
HDA_FIXUP_ACT_PROBE just because alc_ssid_check() gives the
false-positive values from the SSID.

For more consistent behavior, define the logic in the following way:

- Define ALC_INIT_UNDEFINED as the default value before calling
  alc_ssid_check()
- Each fixup may set up spec->init_amp with another value at
  HDA_FIXUP_ACT_PRE_PROBE
- At detection, check whether spec->init_amp is ALC_INIT_UNDEFINED or
  not; if it's different, we skip the detection

Also, it turned out that ASUS TX300 requires the spec->init_amp
override, too; currently it ignores the GPIO bits implicitly by its
static init verb, but this will be changed in the later patchset.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoMerge branch 'topic/ac97-bus' into for-next
Takashi Iwai [Mon, 25 Jun 2018 08:03:39 +0000 (10:03 +0200)]
Merge branch 'topic/ac97-bus' into for-next

6 years agoALSA: ac97: add codecs devicetree binding
Robert Jarzmik [Fri, 22 Jun 2018 19:28:34 +0000 (21:28 +0200)]
ALSA: ac97: add codecs devicetree binding

Add a devicetree binding for codecs. This is especially useful if the
AC97 bitclk clock is provided by the codec, as it has to be described in
the devicetree description for the ac97 bus code to aquire it.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: ac97: add bus binding for codecs
Robert Jarzmik [Fri, 22 Jun 2018 19:28:33 +0000 (21:28 +0200)]
ALSA: ac97: add bus binding for codecs

Add the generic ac97 bus binding, especially for ac97 codecs discovered
by ac97 hardware probing.

Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Fix the problem of two front mics on more machines
Hui Wang [Mon, 25 Jun 2018 06:40:56 +0000 (14:40 +0800)]
ALSA: hda/realtek - Fix the problem of two front mics on more machines

We have 3 more Lenovo machines, they all have 2 front mics on them,
so they need the fixup to change the location for one of two mics.

Among these 3 Lenovo machines, one of them has the same pin cfg as the
machine with subid 0x17aa3138, so use the pin cfg table to apply fixup
for them. The rest machines don't share the same pin cfg, so far use
the subid to apply fixup for them.

Fixes: a3dafb2200bf ("ALSA: hda/realtek - adjust the location of one mic")
Cc: <stable@vger.kernel.org>
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Add a quirk for FSC ESPRIMO U9210
Takashi Iwai [Fri, 22 Jun 2018 10:17:45 +0000 (12:17 +0200)]
ALSA: hda/realtek - Add a quirk for FSC ESPRIMO U9210

Fujitsu Seimens ESPRIMO Mobile U9210 requires the same fixup as H270
for the correct pin configs.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=200107
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: make array ca0132_alt_chmaps static
Colin Ian King [Thu, 21 Jun 2018 18:34:57 +0000 (19:34 +0100)]
ALSA: hda/ca0132: make array ca0132_alt_chmaps static

The array ca0132_alt_chmaps is local to the source and does not
need to be in global scope, so make it static.

Cleans up sparse warning:
warning: symbol 'ca0132_alt_chmaps' was not declared. Should it be
static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Simplify alc269_fixup_hp_line1_mic1_led()
Takashi Iwai [Tue, 19 Jun 2018 21:15:59 +0000 (23:15 +0200)]
ALSA: hda/realtek - Simplify alc269_fixup_hp_line1_mic1_led()

alc269_fixup_hp_line1_mic1_led() can be simplified more with the
existing helper code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Sanity check of unexpected cap_sync_hook override
Takashi Iwai [Tue, 19 Jun 2018 10:45:53 +0000 (12:45 +0200)]
ALSA: hda - Sanity check of unexpected cap_sync_hook override

There are a couple of places setting cap_sync_hook in the codec
drivers, and they just overwrite the value.  Add a sanity check via
WARN_ON() in case if an old non-NULL value is overridden and
forgotten.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/sigmatel - Use common helper for mic mute LED
Takashi Iwai [Tue, 19 Jun 2018 10:44:35 +0000 (12:44 +0200)]
ALSA: hda/sigmatel - Use common helper for mic mute LED

To simplify the code and to get the mic-mute LED behavior control, use
the new helper function for controlling the mic mute LED instead of
open-codes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Allow multiple ADCs for mic mute LED controls
Takashi Iwai [Tue, 19 Jun 2018 10:42:03 +0000 (12:42 +0200)]
ALSA: hda - Allow multiple ADCs for mic mute LED controls

Instead of refusing, allow the configuration with the multiple ADCs
(thus multiple capture switches) for enabling the mic mute LED.
This has been done for Sigmatel/IDT codecs, and we treat the OR-ed
values from all capture switches as the boolean condition.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/conexant - Use the mic-mute LED helper
Takashi Iwai [Tue, 19 Jun 2018 10:36:36 +0000 (12:36 +0200)]
ALSA: hda/conexant - Use the mic-mute LED helper

Convert to use the common helper for controlling the mic mute LED for
HP laptops, just as we've done for Realtek codecs.  This will give the
mic mute LED enum as gratis.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/realtek - Use the mic-mute LED helper for HP and others
Takashi Iwai [Tue, 19 Jun 2018 10:29:13 +0000 (12:29 +0200)]
ALSA: hda/realtek - Use the mic-mute LED helper for HP and others

Similar as the previous commit, convert to use the common helper for
controlling the mic mute LED for HP and other machines in the Realtek
codec driver, too.  This will give the mic mute LED enum as gratis.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Use the common helper for thinkpad_acpi mic mute LED handling
Takashi Iwai [Mon, 18 Jun 2018 15:28:45 +0000 (17:28 +0200)]
ALSA: hda - Use the common helper for thinkpad_acpi mic mute LED handling

Use the new common helper for setting up and controlling the mic mute
LED over thinkpad_acpi.  This also provides a new mixer enum "Mic
Mute-LED Mode" (that was present only for Dell models), which allows
user to choose the mic mute LED behavior.  For example, if you want
the mic mute LED turned on only while mic is on, choose "Follow
Capture" there.

Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Move mic mute LED helper to the generic parser
Takashi Iwai [Mon, 18 Jun 2018 15:26:12 +0000 (17:26 +0200)]
ALSA: hda - Move mic mute LED helper to the generic parser

Move the code for setting up and controlling the mic mute LED hook
from dell-wmi helper to the generic parser, so that it can be referred
from the multiple driver codes.

No functional change.

Tested-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI
Takashi Iwai [Thu, 21 Jun 2018 11:33:53 +0000 (13:33 +0200)]
ALSA: hda - Force to link down at runtime suspend on ATI/AMD HDMI

Henning Kühn reported that the discrete AMD GPU on his hybrid graphics
laptop no longer runtime-suspends due to the recent commit
07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller").

The root cause is that the HDMI codec on AMD GPU doesn't support
CLKSTOP and EPSS, which are currently mandatory for powering down the
HD-audio link at runtime suspend.  Because the HD-audio link is still
up, HD-audio controller driver blocks the transition to D3.

For addressing the regression, this patch adds a new flag to indicate
the forced link-down, and sets it for AMD HDMI codecs appropriately
in the codec driver.

Fixes: 07f4f97d7b4b ("vga_switcheroo: Use device link for HDA controller")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106957
Reported-by: Lukas Wunner <lukas@wunner.de>
Reported-and-tested-by: Henning Kühn <prg@cooco.de>
Cc: <stable@vger.kernel.org> # v4.17+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: lx6464es: Missing error code in snd_lx6464es_create()
Dan Carpenter [Thu, 21 Jun 2018 08:07:21 +0000 (11:07 +0300)]
ALSA: lx6464es: Missing error code in snd_lx6464es_create()

We forgot to set the error code on this error path.

Fixes: 4a23fc8cc068 ("ALSA: lx6464es: add error handling for pci_ioremap_bar")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: firewire-motu: add support for Motu Traveler
Takashi Sakamoto [Mon, 18 Jun 2018 12:07:55 +0000 (21:07 +0900)]
ALSA: firewire-motu: add support for Motu Traveler

This commit adds support for MOTU Traveler, launched in 2005, discontinued
quite before. As a result, transmission of PCM frame and MIDI messages is
available via ALSA PCM and RawMIDI/Sequencer interfaces.

This model supports sampling transmission frequency up to 192.0 kHz, and
AES/EBU on XLR interface and ADAT on optical interface. Unlike
Motu 828MkII, Windows driver can switch fetching mode for DSP, like
mute/unmute feature.

Although this commit enables high sampling transmission frequency, actual
sound from this model is not good. As long as I tested, it's silence at
176.4 kHz, and it includes hissing noise at 192.0 kHz. In my opinion, as I
reported at 3526ce7f9ba7 ('ALSA: firewire-motu: add MOTU specific protocol
layer'), timestamping on source packet header (SPH) may not still be good
for this model as well.

$ python2 crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  04106505  bus_info_length 4, crc_length 16, crc 25861
404  31333934  bus_name "1394"
408  20001000  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 1 (4)
40c  0001f200  company_id 0001f2     |
410  0001f32f  device_id 000001f32f  | EUI-64 0001f2000001f32f

               root directory
               -----------------------------------------------------------------
414  0004c65c  directory_length 4, crc 50780
418  030001f2  vendor
41c  0c0083c0  node capabilities per IEEE 1394
420  8d000006  --> eui-64 leaf at 438
424  d1000001  --> unit directory at 428

               unit directory at 428
               -----------------------------------------------------------------
428  00035955  directory_length 3, crc 22869
42c  120001f2  specifier id
430  13000009  version
434  17107800  model

               eui-64 leaf at 438
               -----------------------------------------------------------------
438  000206b2  leaf_length 2, crc 1714
43c  0001f200  company_id 0001f2     |
440  0001f32f  device_id 000001f32f  | EUI-64 0001f2000001f32f

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: firewire-motu: cancel chunk alignment for protocol version 2
Takashi Sakamoto [Mon, 18 Jun 2018 12:07:54 +0000 (21:07 +0900)]
ALSA: firewire-motu: cancel chunk alignment for protocol version 2

For MOTU protocol version 2, this driver arranges the number of data
chunks to align chunks to quadlet data channel. However, MOTU Traveler
has padding bytes in the end of data block at high clock mode.

This commit removes the arrangement. Fortunately, at low and middle clock
mode, supported model for v2 protocol (828mkII) gets no influence from this
change because all of combination for data chunks are just aligned to
quadlet data channel.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: firewire-motu: add a flag for AES/EBU on XLR interface
Takashi Sakamoto [Mon, 18 Jun 2018 12:07:53 +0000 (21:07 +0900)]
ALSA: firewire-motu: add a flag for AES/EBU on XLR interface

MOTU Traveler supports AES/EBU on XLR interface and data block of rx/tx
packet includes two chunk for the interface. This commit adds a flag
for this purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: firewire-motu: add a flag for chunks for main 1/2 out
Takashi Sakamoto [Mon, 18 Jun 2018 12:07:52 +0000 (21:07 +0900)]
ALSA: firewire-motu: add a flag for chunks for main 1/2 out

This driver explicitly assumes that all of supported models have main data
chunk separated from chunk for analog ports. However, MOTU Traveler doesn't
support the separated main data chunk.

This commit adds a flag for the separated main data chunk.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: firewire-motu: suppless consumption for unused element of array in stack
Takashi Sakamoto [Mon, 18 Jun 2018 12:07:51 +0000 (21:07 +0900)]
ALSA: firewire-motu: suppless consumption for unused element of array in stack

In MOTU firewire protocol, data block consists of 24 bit data chunks except
for one quadlet for source packet header (SPH). The number of data chunk in
a data block is different between three clock modes; low, middle and high.
When unit supports ADAT on optical interface, the data block includes some
chunks for ADAT channels. These ADAT chunks are unavailable at high mode.

This driver has local functions to calculate the number of ADAT chunks. But
They uses stack for three clock modes. This is useless for higher mode.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: line6: stop using get_seconds()
Arnd Bergmann [Mon, 18 Jun 2018 15:41:01 +0000 (17:41 +0200)]
ALSA: line6: stop using get_seconds()

The get_seconds() function is deprecated because it truncates the
timestamp to 32 bits, so all users should change to ktime_get_seconds()
or ktime_get_real_seconds().

The firmware interface for passing the timestamp is also limited to
32 bits, so this patch only has the cosmetic effect of avoiding the
old interface.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: ctxfi: use enum type CT_SUM_CTL where appropriate
Stefan Agner [Sun, 17 Jun 2018 13:46:49 +0000 (15:46 +0200)]
ALSA: ctxfi: use enum type CT_SUM_CTL where appropriate

Currently a variable of type enum CT_AMIXER_CTL is used for enum
CT_SUM_CTL values. This leads to warnings when using clang:
sound/pci/ctxfi/ctmixer.c:945:32: warning: implicit conversion from enumeration type
      'enum CT_SUM_CTL' to different enumeration type 'enum CT_AMIXER_CTL'
      [-Wenum-conversion]
        for (i = AMIXER_MASTER_F, j = SUM_IN_F;
                                    ~ ^~~~~~~~
sound/pci/ctxfi/ctmixer.c:975:29: warning: implicit conversion from enumeration type
      'enum CT_SUM_CTL' to different enumeration type 'enum CT_AMIXER_CTL'
      [-Wenum-conversion]
        for (i = AMIXER_PCM_F, j = SUM_IN_F; i <= AMIXER_PCM_S; i++, j++) {
                                 ~ ^~~~~~~~

Introduce enum CT_SUM_CTL k and it instead.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: ice1724: remove unused array
Stefan Agner [Sun, 17 Jun 2018 13:46:29 +0000 (15:46 +0200)]
ALSA: ice1724: remove unused array

This fixes a warning seen with clang:

sound/pci/ice1712/prodigy_hifi.c:321:28: warning: variable 'wm_vol' is not
      needed and will not be emitted [-Wunneeded-internal-declaration]
static const unsigned char wm_vol[256] = {
                           ^

Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Fix DMic data rate for Alienware M17x R4
Alastair Bridgewater [Sat, 16 Jun 2018 01:56:20 +0000 (21:56 -0400)]
ALSA: hda/ca0132: Fix DMic data rate for Alienware M17x R4

The commentary says to use various parameters, and lays out what
the mapping is...  The code used a 32KHz rate when the comment
says that it needs to use a 48KHz rate.  And this has been the
case since day one.

On the Alienware M17x R4, the DMic used to have exceptionally quiet
pickup and a lot of noise.  Changing the data rate fixes both of
these issues.

Searching the kernel bug tracker for ca0132-related issues shows no
mention of this being an issue for other hardware, and I have no
other hardware to test with, so a quirk is used to limit the effect
to just the M17x R4.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Restore PCM Analog Mic-In2
Alastair Bridgewater [Sat, 16 Jun 2018 01:56:19 +0000 (21:56 -0400)]
ALSA: hda/ca0132: Restore PCM Analog Mic-In2

Commit 009b8f979bf8cb5f7ec6d3dd7683585122ed10f8 conditionalized
adding the "CA0132 Analog Mic-In2" PCM with a comment to the
effect that, "desktops don't use this ADC", but the test was set
up such that the ADC was only created for desktops.  Invert the
test.

Fixes: 009b8f979bf8 ("ALSA: hda/ca0132: update core functions for sbz + r3di")
Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Don't test for QUIRK_NONE
Alastair Bridgewater [Sat, 16 Jun 2018 01:56:18 +0000 (21:56 -0400)]
ALSA: hda/ca0132: Don't test for QUIRK_NONE

QUIRK_NONE is, quite explicitly, the default case.  The entire
point of a quirks system is to allow "programming by difference"
from a given base case, which requires that merely defining a new
quirk for some piece of hardware should not change the behavior of
the driver for that hardware.  In turn, this means that testing
for QUIRK_NONE explicitly is a violation of that implicit contract.

Change a test for QUIRK_NONE and QUIRK_ALIENWARE to default, and
add a test for QUIRK_SBZ to disable the default behavior in that
instance.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Restore behavior of QUIRK_ALIENWARE
Alastair Bridgewater [Sat, 16 Jun 2018 01:56:17 +0000 (21:56 -0400)]
ALSA: hda/ca0132: Restore behavior of QUIRK_ALIENWARE

Commit e93ac30a32a6ba7ac3b4b2a4379af1dadb91e505 (ALSA: HDA/ca0132:
add extra init functions for r3di + sbz) introduced an extra
initialization function that was improperly guarded, taking effect
on systems with QUIRK_ALIENWARE, even though such systems were
supposedly not affected.

It may be that this piece of initialization should be done for all
systems, but that's not a call that I can make.

Fixes: e93ac30a32a6 ("ALSA: HDA/ca0132: add extra init functions for r3di + sbz")
Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
6 years agoALSA: hda/ca0132: Delete redundant UNSOL event requests
Alastair Bridgewater [Sat, 16 Jun 2018 01:56:16 +0000 (21:56 -0400)]
ALSA: hda/ca0132: Delete redundant UNSOL event requests

During ca0132_init(), ca0132_init_unsol() is run before the
spec->spec_init_verbs are written.  ca0132_init_unsol() calls
snd_hda_jack_detect_enable_callback(), which requests UNSOL events
for three or four nodes, two of which were also (redundantly)
requested by spec_init_verbs.

Kill the redundant AC_VERB_SET_UNSOLICITED_ENABLE verbs.

Signed-off-by: Alastair Bridgewater <alastair.bridgewater@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>