Commit Graph

26818 Commits

Author SHA1 Message Date
Takashi Iwai 9f2cf73ed6 ASoC: bytcr_rt5640: Allow quirk set via module option
The bytcr-rt5640 driver has a few quirk setups depending on the board,
where the quirk value is set by DMI matching.  When you have a new
device to add the support, you often experience to try the different
quirk by trial-and-error.  Or, you may have a development model that
still has no proper DMI string.  In either case, you'd need to compile
the driver at each time.

This patch introduces a module option to override the quirk value on
the fly.  User can boot like snd-soc-sst-bytcr-rt5640.quirk=0x4004 to
override the default value without recompilation.  It's a raw value,
so user needs to check the source code for the meaning of each bit.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-24 18:48:07 +01:00
Takashi Iwai 861886d338 ASoC: Call snd_soc_set_dmi_name() unconditionally
Since recently UCM can pick up a configuration specific to the board
via card longname field, and we introduced a helper function
snd_soc_set_dmi_name() for that.  So far, it was used only in one
place (sound/soc/intel/boards/broadwell.c), but it should be more
widely applied.

This patch puts a big hammer for that: it lets snd_soc_register_card()
calling snd_soc_set_dmi_name() unconditionally, so that all x86
devices get the better longname string.  This would have no impact for
other systems without DMI support, as snd_soc_set_dmi_name() is no-op
on them.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-24 18:47:17 +01:00
Takashi Iwai 1f5a4535db ASoC: Provide a dummy wrapper of snd_soc_set_dmi_name()
For systems without DMI, it makes no sense to have the code.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-24 18:47:10 +01:00
Fabio Estevam 8f7206d69a ASoC: imx-wm8962: Remove global variables
Currently the following variables are global:
- card_priv, sample_rate and sample_format

,which is not a good idea as it prevents the usage of multiple
instances.

Make sample_rate and sample_format part of the imx_priv structure
and allocate imx_priv via the standard devm_kzalloc() mechanism
inside the probe function.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-24 18:45:18 +01:00
Takashi Iwai 610793fe2b Merge branch 'topic/hda-dual-codecs' into for-next 2017-04-24 09:24:15 +02:00
Sylwester Nawrocki aba611fc4c ASoC: samsung: Add Odroid ASoC machine driver
This dedicated driver allows to support SoC specific clock
settings and helps to ensure proper number of channels gets
negotiated in multicodec system configurations.

Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:27:58 +01:00
Linus Walleij 97c52eb969 ASoC: qcom: move clock names into LPASS variant struct
The clock names for the two supported codecs are either
"mi2s-*" name variants generated by code. This naming scheme
does not work for platforms like MSM8660 which has I2S channels
named CODEC_I2S_SPKR (rather than just "MI2S tertiary" and other
repetitive names) and consequently have clocks named
"codec-i2s-spkr-osr-clk" and similar.

Skip the runtime generation of clock names and replace it with
name lookup tables encoded into the variant data.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:07:45 +01:00
Charles Keepax 06bdf385f6 ASoC: cs35l35: Allow user to configure IMON SCALE
On the chip the IMON signal is a full 24-bits however normally only
some of the bits will be sent over the bus. The chip provides a field
to select which bits of the IMON will be sent back, this is the only
feedback signal that has this feature.

Add an additional entry to the cirrus,imon device tree property to
allow the IMON scale parameter to be passed.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:01:38 +01:00
Dan Carpenter 550b349af0 ASoC: Intel: Skylake: Fix a couple user after free bugs
We need to use the _safe() version of list_for_each_entry() here because
of the kfree(modules).

Fixes: b8c722ddd5 ("ASoC: Intel: Skylake: Add support for deferred DSP module bind")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 18:00:33 +01:00
Stefan Agner 24dbd9edb6 ASoC: fsl_asrc_dma: use correct direction enum type
The direction argument is of type enum dma_transfer_direction, and
not enum dma_data_direction. The enumeration values are the same
so this did not had an effect in practise.

Signed-off-by: Stefan Agner <stefan@agner.ch>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 17:59:34 +01:00
Arnd Bergmann 362c59436c ASoC: mediatek: add I2C dependency for CS42XX8
We should not select drivers that depend on I2C when that is disabled,
as it results in a build error:

warning: (SND_SOC_MT2701_WM8960) selects SND_SOC_WM8960 which has unmet direct dependencies (SOUND && !M68K && !UML && SND && SND_SOC && I2C)
sound/soc/codecs/wm8960.c:1469:1: error: data definition has no type or storage class [-Werror]
sound/soc/codecs/wm8960.c:1469:1: error: type defaults to 'int' in declaration of 'module_i2c_driver' [-Werror=implicit-int]

Fixes: 8625c1dbd8 ("ASoC: mediatek: Add mt2701-wm8960 machine driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 17:58:34 +01:00
Dan Carpenter e6a33532af ASoC: Intel: Skylake: Uninitialized variable in probe_codec()
My static checker complains that if snd_hdac_bus_get_response() returns
-EIO then "res" is uninitialized.  Fix this by initializing it to -1 so
that the error is handled correctly.

Fixes: d8c2dab838 ("ASoC: Intel: Add Skylake HDA audio driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 17:57:38 +01:00
Marek Vasut e8dffe6c20 ASoC: rsnd: Fix possible NULL pointer dereference
25165f79ad
("ASoC: rsnd: enable clock-frequency for both 44.1kHz/48kHz")
supports both 44.1kHz/48kHz clock-frequency settings for ADG
which will be used for AUDIO_OLKOUTn.
But some board doesn't need it, thus, it is not mandatory.

But, above patch didn't care about the case of "clock-frequency" DT
property was not present.
This patch ignores ADG settings if AUDIO_OLKOUTn was not used.

Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com>
[Kuninori: tidyup not to break non AUDIO_OLKOUTn case]
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 17:51:48 +01:00
kbuild test robot 75f9e4adb5 ASoC: rsnd: fix semicolon.cocci warnings
sound/soc/sh/rcar/adg.c:462:54-55: Unneeded semicolon

 Remove unneeded semicolon.

Generated by: scripts/coccinelle/misc/semicolon.cocci

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-21 16:30:35 +01:00
Takashi Iwai 56798e6b3a ALSA: hda - Use a helper function for renaming kctl names
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 10:52:59 +02:00
Takashi Iwai 7beb3a6e93 ALSA: hda - Support Gigabyte Gaming board with dual Realtek codecs
This patch adds some workarounds to make Gigabyte GA-AX370 Gaming 5
board working without the conflicts of kctls, etc.  In general, the
dual codec configs result in the conflicts of the following stuff:
- Master controls
- Capture controls
- Analog loopback controls
In addition, the auto-mute and the auto-mic can't work well among
multiple codecs.

The current "solution" is to disable all these features, and use UCM
for a better PulseAudio management.  For a dedicated UCM profile, the
patch overrides the card longname so that the system an get a unique
profile path.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195305
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 10:52:46 +02:00
Mikhail Paulyshka fc7438b1eb ALSA: hda - Fix headset microphone detection for ASUS N551 and N751
Headset microphone does not work out of the box on ASUS Nx51
laptops. This patch fixes it.

Patch tested on Asus N551 laptop. Asus N751 part is not tested, but
according to [1] this laptop uses the same audiosystem.

1. https://bugzilla.kernel.org/show_bug.cgi?id=117781

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195437
Signed-off-by: Mikhail Paulyshka <me@mixaill.tk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-21 08:52:42 +02:00
Takashi Sakamoto e3a973c69b ALSA: fireface: obsolete usage of ktime_set() for zero assignment
In development period for Linux v4.10, ktime_t became an alias of s64,
instead of union. I forgot it. We can just assign zero, instead of usage
of ktime_set(0, 0).

Fixes: 1917429578 ("ALSA: fireface: add transaction support")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-20 15:00:54 +02:00
Arnd Bergmann fa8323bf49 ALSA: firewire-motu: mark trace helpers as __maybe_unused
Two functions were introduced for the purpose of tracing but cause warnings
when tracing is disabled:

sound/firewire/motu/amdtp-motu.c:284:13: error: 'copy_message' defined but not used [-Werror=unused-function]
 static void copy_message(u64 *frames, __be32 *buffer, unsigned int data_blocks,
sound/firewire/motu/amdtp-motu.c:271:13: error: 'copy_sph' defined but not used [-Werror=unused-function]
 static void copy_sph(u32 *frames, __be32 *buffer, unsigned int data_blocks,

Marking them as __maybe_unused will do the right thing here.

Fixes: 17909c1b30 ("ALSA: firewire-motu: add tracepoints for SPH in IEC 61883-1 fashion")
Fixes: c6b0b9e65f ("ALSA: firewire-motu: add tracepoints for messages for unique protocol")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-20 12:50:45 +02:00
Kuninori Morimoto 25165f79ad ASoC: rsnd: enable clock-frequency for both 44.1kHz/48kHz
Current clock-frequency allows only 1 clock, but ADG can
handle both 44.1kHz/48kHz base clocks. This patch enables these.

On Salvator-X board, AUDIO_CLKOUT which is generated by ADG
is connected to ak4613 MCKI, and it should be synchronized with
LRCK. Thus, we need both 44.1kHz/48kHz base clock-frequency.
Otherwise, either one sounds strange in high frequency sound.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-19 17:32:46 +01:00
Kuninori Morimoto 9ca5e57d78 ASoC: rsnd: rsnd_mod_make_sure() is not under DEBUG
rsnd_mod_make_sure() will be used any situation,
thus, under DEBUG is not realistic.
This patch move it to non DEBUG area

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-19 17:32:46 +01:00
Kuninori Morimoto 4898b61e40 ASoC: ak4613: use snd_soc_update_bits() to avoid Reserve bit on I/O CTRL
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-19 17:23:47 +01:00
Jerónimo Borque 5cd5b1bdfb ALSA: hda - Add HP ZBook 15u G3 Conexant CX20724 GPIO mute leds
The HP ZBook 15u G3 has a Conexant CX20724 with mute led on GPIO1 and
mic mute led on GPIO2.
Adding CXT_FIXUP_MUTE_LED_GPIO inspired on patch_realtek's one.

Signed-off-by: Jerónimo Borque <jeronimo@borque.com.ar>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-19 18:00:56 +02:00
Charles Keepax fbeea237af ASoC: cs35l35: Correct some register defaults
Correct some minor errors in the register defaults.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:59:18 +01:00
Colin Ian King d7766aa57a ASoC: topology: use j for internal loop counter
Currently variable i is being for 2 nested for loops. Fix this by
using integer loop counter j for the inside for loop.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:53:40 +01:00
Nicole Faerber 67e03ff3f3 ASoC: codecs: rt5670: add Thinkpad Tablet 10 quirk
The Thinkpad Tablet tablet has a similar audio setup as the Intel Braswell
platform.
A quirk is needed to detect the platform and setup the platform data
properly:

Manufacturer: LENOVO
        Product Name: 20C1CTO1WW
        Version: ThinkPad 10

Manufacturer: LENOVO
	Product Name: 20C3001VHH
	Version: ThinkPad 10

Manufacturer: LENOVO
	Product Name: 20C10024GE
	Version: ThinkPad Tablet B

Manufacturer: LENOVO
    	Product Name: 20359
    	Version: Lenovo Miix 2 10

Signed-off-by: Nicole Faerber <nicole.faerber@id3p.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:19:04 +01:00
Pierre-Louis Bossart beb5989a8c ASoC: Intel: Atom: update Thinkpad 10 quirk
There are multiple skews of the same Lenovo audio hardware
based on the Realtek RT5670 codec.

Manufacturer: LENOVO
        Product Name: 20C1CTO1WW
        Version: ThinkPad 10

Manufacturer: LENOVO
	Product Name: 20C3001VHH
	Version: ThinkPad 10

Manufacturer: LENOVO
	Product Name: 20C10024GE
	Version: ThinkPad Tablet B

Manufacturer: LENOVO
	Product Name: 20359
	Version: Lenovo Miix 2 10

For all these devices, the same quirk is used to force
the machine driver to be based on RT5670 instead of RT5640
as indicated by the BIOS.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=96691
Tested-by: Nicole Faerber <nicole.faerber@dpin.de>
Tested-by: Viacheslav Ostroukh <v.dev@ostroukh.me>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:19:04 +01:00
John Hsu babd658503 ASoC: nau8540: fix tab conversion problem
Fix the tab converting to space problem.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-18 18:05:19 +01:00
Mauro Carvalho Chehab a5f8661df0 ALSA: usb-audio: replace /proc/bus/usb by /dev/bus/usb
The /proc/bus/usb devices don't exist anymore, since when we
got rid of usbfs. Those devices are now seen at
/dev/bus/usb.

Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-17 10:23:55 +02:00
Douglas Anderson 7952b4baff ASoC: rt5514: Unconfuse the rt5514 at probe / resume time
The rt5514 can get confused and incorrectly detect a start bit if the
SCL/SDA lines happen to both go low and then high again.  This
situation has been seen to happen at reboot time and is also
theoretically possible during suspend/resume if the rt5514 keeps power
but we shut down the i2c connection.

When this happens the rt5514 is confused about the state of the i2c
bus and won't recognize its own address.  That will lead to the rt5514
incorrectly NAKing the first transfer.

A single i2c transfer to any address should be enough to get the
rt5514 out of this funky state.

It is currently believed that this problem should be fixed in the
rt5514 driver itself because it seems that the i2c controller in the
rt5514 is easily confused.  Most i2c devices wouldn't detect a start
bit in this case.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-14 18:11:37 +01:00
Douglas Anderson 0a78b248c3 ASoC: rt5514: Avoid relying on uninitialized "val" value
In rt5514_i2c_probe() if the regmap_read(RT5514_VENDOR_ID2) fails then
"val" may be left as uninitialized.  Current code relies on "val" not
being RT5514_DEVICE_ID, but that's potentially unsafe.

Let's check for errors from regmap_read() and also explicitly init the
value do we're not passing a possibly uninitialized int to printk.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-14 18:11:37 +01:00
Douglas Anderson d0c02e14e4 ASoC: rt5514: Mark rt5514_i2c_driver as static
There's no reason for rt5514_i2c_driver to be non-static.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-14 18:11:37 +01:00
Takashi Sakamoto ae369e559f ALSA: firewire-tascam: support drain callback for MIDI playback substream
ALSA driver for TASCAM FireWire series transfers MIDI messages in system
workqueue. In current design of the driver, applications should wait for
sequence of transmission when they close ALSA rawmidi character devices.
However, when considering design of rawmidi interface, it's preferable
to wait in drain ioctl.

This commit adds support for the drain ioctl to wait for the end of
the transmission.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:43 +02:00
Takashi Sakamoto 1f94205d22 ALSA: firewire-tascam: move message parameters for async midi port
Units on TASCAM FireWire series handle MIDI messages with support for
running status. Drivers for the series should remember current running
status and transfer valid MIDI messages. For this purpose, current
ALSA driver for the series has some members in its top-level structure.
This is due to better abstraction of async midi port. Nowadays, the
abstraction was localized just for the driver.

This commit moves the members to structure for async midi port.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:40 +02:00
Takashi Sakamoto 3e7dc65ca0 ALSA: firewire-tascam: initialize parameters at open of rawmidi character devices
In current design of ALSA driver for TASCAM FireWire series, initialization
of members in asymc midi port structure is done at device probing. Some of
the members should be initialized every time to use rawmidi devices because
they're changed in sequence of transmission for MIDI messages.

This commit adds a new function to initialize them. Invariant parameters
during object lifetime are kept as is.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:38 +02:00
Takashi Sakamoto 98a00d3602 ALSA: firewire-tascam: use fixed-length array for message cache to async midi port
ALSA driver for TASCAM FireWire series internally allocates 4 byte buffer
for asynchronous transaction to transfer MIDI messages. However, the buffer
can be allocated with memory object of parent structure.

This commit adds 4 byte array as a member of the structure and obsoletes
the redundant allocation. This is deallocated with memory object of parent
structure.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:36 +02:00
Takashi Sakamoto 27badc4c10 ALSA: firewire-tascam: use the same address for asynchronous transaction for MIDI message
Units on TASCAM FireWire series receive MIDI messages by asynchronous
transactions on IEEE 1394 bus. Although the transaction is sent to a
certain register, current ALSA driver for this series has a redundant design.

This commit use the same address for the transaction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:33 +02:00
Takashi Sakamoto 38d5826142 ALSA: firewire-tascam: send fixed-length transaction for async midi port
TASCAM FireWire series uses asynchronous transactions with fixed length
payload for MIDI messaging. On the other hand, ALSA driver for the series
has a redundant design to handle different length of payload.

This commit removes the redundant abstraction.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:31 +02:00
Takashi Sakamoto 9bae2150d0 ALSA: firewire-tascam: remove callback function from async midi port
As a result of localization of async midi port, ALSA driver for TASCAM
FireWire series can call helper function directly instead of callback
registration.

This commit removes the redundant design.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:29 +02:00
Takashi Sakamoto 531f471834 ALSA: firewire-lib/firewire-tascam: localize async midi port
In Linux kernel 4.4, firewire-lib got a feature called as 'async midi port'
for transmission of MIDI message via IEEE 1394 asynchronous communication,
however actual consumer of this feature is ALSA driver for TASCAM FireWire
series only. When adding this feature, I assumed that ALSA driver for
Digi00x might also be a consumer, actually it's not.

This commit moves the feature from firewire-lib to firewire-tascam module.
Two minor kernel APIs are removed.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 14:50:26 +02:00
Takashi Iwai 1900d947b5 Merge branch 'for-linus' into for-next
Back-merge to prepare for applying more FireWire updates.
2017-04-14 09:01:04 +02:00
Takashi Sakamoto 1e0f8f68f7 ALSA: usb-line6: constify snd_kcontrol_new strucutre array
In kernel APIs of ALSA control interface, drivers can create a control
element set by a call of snd_ctl_new1() with a template. This template
is known to have const qualifier in general cases.

This commit adds the qualifier to template array, for safer program and
runtime. Application of this change moves the symbol from .data section
to .rodata section.

Cc: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 08:57:56 +02:00
Takashi Sakamoto dfb00a5693 ALSA: firewire-lib: fix inappropriate assignment between signed/unsigned type
An abstraction of asynchronous transaction for transmission of MIDI
messages was introduced in Linux v4.4. Each driver can utilize this
abstraction to transfer MIDI messages via fixed-length payload of
transaction to a certain unit address. Filling payload of the transaction
is done by callback. In this callback, each driver can return negative
error code, however current implementation assigns the return value to
unsigned variable.

This commit changes type of the variable to fix the bug.

Reported-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: <stable@vger.kernel.org> # 4.4+
Fixes: 585d7cba5e ("ALSA: firewire-lib: add helper functions for asynchronous transactions to transfer MIDI messages")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-14 08:57:25 +02:00
Takashi Iwai 4e7655fd4f ALSA: seq: Don't break snd_use_lock_sync() loop by timeout
The snd_use_lock_sync() (thus its implementation
snd_use_lock_sync_helper()) has the 5 seconds timeout to break out of
the sync loop.  It was introduced from the beginning, just to be
"safer", in terms of avoiding the stupid bugs.

However, as Ben Hutchings suggested, this timeout rather introduces a
potential leak or use-after-free that was apparently fixed by the
commit 2d7d54002e ("ALSA: seq: Fix race during FIFO resize"):
for example, snd_seq_fifo_event_in() -> snd_seq_event_dup() ->
copy_from_user() could block for a long time, and snd_use_lock_sync()
goes timeout and still leaves the cell at releasing the pool.

For fixing such a problem, we remove the break by the timeout while
still keeping the warning.

Suggested-by: Ben Hutchings <ben.hutchings@codethink.co.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-13 14:13:25 +02:00
Ander Conselvan De Oliveira a87a4d23e8 ALSA: hda: Move common haswell init to a helper
Geminilake vendor nid is different from other Skylake variants, but rest
of the initialization code is same.

So a variable is added in hdmi_spec to store the platform specific vendor
nid and move the initialization code to a helper function to be used by
both platform specific init.

Fixes: 126cfa2f5e ("ALSA: hda: Add Geminilake HDMI codec ID")
Signed-off-by: Ander Conselvan De Oliveira <ander.conselvan.de.oliveira@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Jaikrishna Nemallapudi <jaikrishnax.nemallapudi@intel.com>
Cc: Senthilnathan Veppur <senthilnathanx.veppur@intel.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-13 10:23:22 +02:00
Jeeja KP b8c722ddd5 ASoC: Intel: Skylake: Add support for deferred DSP module bind
Module at the end of DSP pipeline that needs to be connected to a module
in another pipeline are represented as a PGA(leaf node) and in PGA event
handler these modules are bound/unbounded. Modules other than PGA leaf
can be connected directly or via switch to a module in another pipeline.
Example: reference path.

To support the deferred DSP module bind, following changes are done:
o When the path is enabled, the destination module that needs to be
bound may not be initialized. If the module is not initialized, add
these modules in a deferred bind list.
o When the destination module is initialized, check for these modules
in deferred bind list. If found, bind them.
o When the destination module is deleted, Unbind the modules.
o When the source module is deleted, remove the entry from the deferred
bind list.

Signed-off-by: Jeeja KP <jeeja.kp@intel.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-12 16:57:52 +01:00
Fabio Estevam f2a3ee0125 ASoC: fsl_esai: Remove unneeded definition
There is no need for defining FSL_ESAI_RATES locally as the standard
SNDRV_PCM_RATE_8000_192000 definition can be used instead.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-12 16:44:50 +01:00
Bhumika Goyal 49c41e1f23 ALSA: line6: constify snd_kcontrol_new structures
Declare snd_kcontrol_new strcutures as const as they are only passed as
an argument to the function snd_ctl_new1. This argument is of type const,
so snd_kcontrol_new structures having this property can be made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct snd_kcontrol_new x@p={...};

@ok@
identifier r.x;
position p;
@@
snd_ctl_new1(&x@p,...)

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct snd_kcontrol_new x;

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-12 15:35:16 +02:00
Bhumika Goyal 8fdaebbb83 ALSA: usb-audio: constify snd_kcontrol_new structures
Declare snd_kcontrol_new strcutures as const as they are only passed as
an argument to the function snd_ctl_new1. This argument is of type const,
so snd_kcontrol_new structures having this property can be made const too.
Done using Coccinelle:

@r disable optional_qualifier@
identifier x;
position p;
@@
static struct snd_kcontrol_new x@p={...};

@ok@
identifier r.x;
position p;
@@
snd_ctl_new1(&x@p,...)

@bad@
position p != {r.p,ok.p};
identifier r.x;
@@
x@p

@depends on !bad disable optional_qualifier@
identifier r.x;
@@
+const
struct snd_kcontrol_new x;

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-12 15:34:44 +02:00
Takashi Sakamoto f91c9d7610 ALSA: firewire-lib: cache maximum length of payload to reduce function calls
During packet streaming, maximum length of payload for isochronous packet
is invariable, therefore no need to recalculate. Current ALSA IEC 61883-1/6
engine calls a function to calculate it 8,000 or more times per second
for incoming packet processing.

This commit adds a member to have maximum length of payload into 'struct
amdtp_stream', to reduces the function calls. At first callback from
isochronous context, the length is calculated and stored for later
processing.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-12 15:34:21 +02:00
Subhransu S. Prusty 12ee4022f6 ALSA: hda: Add Geminilake id to SKL_PLUS
Geminilake is Skylake family platform. So add it's id to skl_plus check.

Fixes: 126cfa2f5e ("ALSA: hda: Add Geminilake HDMI codec ID")
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Cc: Senthilnathan Veppur <senthilnathanx.veppur@intel.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-12 07:16:48 +02:00
Takashi Iwai b7c5ac88e8 Merge branch 'for-linus' into for-next 2017-04-12 07:16:07 +02:00
John Stultz e6d56d21bd ASoC: hisilicon: Use devm_snd_soc_register_component
Per feedback from Mark Brown, this patch updates the hi6210-i2s
driver to use devm_snd_soc_register_component which simplifies
the logic a bit.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 21:20:55 +01:00
John Stultz 16c1c089b2 ASoC: hisilicon: Address style nit to use break in final default of switch statement
Mark Brown suggested a style change to use break in the final
default of a switch statement, so this patch addresses that.

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 21:20:51 +01:00
John Stultz da13d7462b ASoC: hisilicon: Add error returns even for cases that shouldn't happen.
This patch addresses feedback from Mark Brown, adding a few
extra error returns in cases that shouldn't happen

Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 21:20:44 +01:00
Fabio Estevam 6f2daf82fa ASoC: tas2552: Return the real error code
In the case of error in tas2552_codec_probe() we should better
propagate the real error code instead of always returning '-EIO'.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 19:35:58 +01:00
Mousumi Jana b6e38b2944 ASoC: topology: Fix to store enum text values
Add missing enum texts store in soc_enum.

Signed-off-by: Mousumi Jana <mousumix.jana@intel.com>
Signed-off-by: Pardha Saradhi K <pardha.saradhi.kesapragada@intel.com>
Signed-off-by: Kranthikumar, GudishaX <gudishax.kranthikumar@intel.com>
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 19:35:28 +01:00
Bard Liao 97c415a6f6 ASoC: rt5665: move rt5665_set_jack_detect to .set_jack
Now, we can use .set_jack callback function on codec level. So we
don't need export rt5665_set_jack_detect.

Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-11 17:05:20 +01:00
Mark Brown b8d4f7a30b Merge branch 'topic/jack' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rt5665 2017-04-11 16:58:30 +01:00
Takashi Sakamoto c6b0b9e65f ALSA: firewire-motu: add tracepoints for messages for unique protocol
MOTU units transfer/receive messages in each data block of their
isochronous packet payload. A part of content in the message is cleard for
MIDI message transmission, while the rest is unknown yet. Additional
features are required to assist users and developers to reveal the
details.

This commit adds tracepoints for the purpose. The tracepoints are designed
for MOTU's protocol version 2 and 3 (Protocol version 1 is not upstreamed
yet). In the tracepoints, events are probed to gather first two 24 bit
data chunks of each data block. The chunks are formatted into elements
of 64 bit array with padding in MSB.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-11 08:30:47 +02:00
Takashi Sakamoto 17909c1b30 ALSA: firewire-motu: add tracepoints for SPH in IEC 61883-1 fashion
Unique protocol is used for MOTU FireWire series. In this protocol,
data block format is not compliant to AM824 in IEC 61883-1/6. Each of
the data block consists of 24 bit data chunks, except for a first
quadlet. The quadlet is used for source packet header (SPH) described
in IEC 61883-1.

The sequence of SPH seems to represent presentation timestamp
corresponding to included data. Developers have experienced that invalid
sequence brings disorder of units in the series.

Unfortunately, current implementation of ALSA IEC 61883-1/6 engine and
firewire-motu driver brings periodical noises to the units at sampling
transmission frequency based on 44.1 kHz. The engine generates the SPH with
even interval and this mechanism seems not to be suitable to the units.
Further work is required for this issue and infrastructure is preferable
to assist the work.

This commit adds tracepoints for the purpose. In the tracepoints, events
are probed to gather the SPHs from each data blocks.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-11 08:30:45 +02:00
Takashi Sakamoto b164d2fd6e ALSA: firewire_lib: add tracepoints for packets without CIP headers
Unique protocol is used for RME Fireface series. In this protocol,
payload format for isochronous packet is not compliant to CIP in
IEC 61883-1/6. The packet includes data blocks just with data channels,
without headers and any metadata.

In previous commits, ALSA IEC 61883-1/6 engine supports this protocol.
However, tracepoints are not supported yet, unlike implementation for
IEC 61883-1/6 protocol. This commit adds support of tracepoints for
the protocol.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-11 08:30:43 +02:00
Fabio Estevam 570c70a60f ASoC: sgtl5000: Allow LRCLK pad drive strength to be changed
Introduce the "lrclk-strength" property to allow LRCLK pad drive strength
to be changed via device tree.

When running a stress playback loop test on a mx6dl wandboard channel
swap can be noticed on about 10% of the times.

While debugging this issue I noticed that when probing the SGTL5000
LRCLK pin with the scope the swap did not happen. After removing
the probe the swap started to happen again.

After changing the LRCLK pad drive strength to the maximum value the
issue is gone.

Same fix works on a mx6dl Colibri board as well.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Tested-by: Max Krummenacher <max.krummenacher@toradex.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-10 20:21:46 +01:00
Bard Liao d7344010d1 ASoC: jack: add snd_soc_codec_set_jack
There are many codecs with the capability of jack detection. Usually,
we create a jack on machine driver but there is no common function for
machine driver to deliver the jack pointer to codec driver.
snd_soc_codec_set_jack can be used for delivering the jack pointer to
codec driver and enable the jack detection function. To make it work,
codec driver need to define a callback function to receive the jack
pointer and do all necessary procedure for enabling jack detection.

Signed-off-by: Bard Liao <bardliao@realtek.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-10 19:46:09 +01:00
Andy Green 0bf750f4cb ASoC: hisilicon: Add hi6210 i2s audio driver
Add driver for hi6210 i2s controller found on hi6220 boards.

Signed-off-by: Andy Green <andy.green@linaro.org>
[jstultz: Forward ported to mainline, fairly major rework
 based on suggestions from Mark Brown]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-10 19:40:13 +01:00
Fabio Estevam c6682fedee ASoC: fsl_ssi: Use the tolower() function
Code can be simplified by using the standard tolower() funtion.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Acked-by: Timur Tabi <timur@tabi.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-10 18:49:17 +01:00
Fabio Estevam 580556774a ASoC: fsl_ssi: Remove FSLSSI_I2S_RATES definition
The comment for the FSLSSI_I2S_RATES definition states that the
driver currently only supports I2S slave mode, which is no longer
correct.

As FSLSSI_I2S_RATES is the same as the standard SNDRV_PCM_RATE_CONTINUOUS,
just remove its definition and its comments to make the code simpler.

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Acked-by: Timur Tabi <timur@tabi.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-10 18:48:49 +01:00
Takashi Iwai 7480316c26 ALSA: hda - Allow to enable/disable vmaster build explicitly
Another preliminary patch for the dual-codec support: since the
support of vmaster over multiple codecs is difficult, simply disable
it by a new flag to hda_codec struct.  A new user hint is added as
well for consistency.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-10 17:45:27 +02:00
Takashi Iwai 9f3dadb156 ALSA: hda - A new flag to enforce prefix to each pin
This is a preliminary patch for a smooth multi-codec support, and it
introduces a new flag, force_pin_prefix, to struct hda_codec.
This flag is used to force to add the pin location prefix to each
input pin.  For example, when there is only one microphone pin,
usually the auto-parser assigns the string "Mic".  With this flag on,
it'll be like "Front Mic".  Also, the creation of "Master" or "PCM"
playback volume for a single pin is suppressed, too.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195305
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-10 17:44:39 +02:00
Takashi Iwai ff21b250e9 Merge branch 'for-linus' into for-next 2017-04-10 17:12:01 +02:00
Libin Yang 1f9d3d9869 ALSA: hda - set intel audio clock to a proper value
On some Intel platforms, the audio clock may not be set correctly
with initial setting. This will cause the audio playback/capture
rates wrong.

This patch checks the audio clock setting and will set it to a
proper value if it is set incorrectly.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188411

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-07 10:39:21 +02:00
Libin Yang dde5bff541 ALSA: hda - add more ML register definitions
This patch refines the definition of AZX_MLCTL_SPA and AZX_MLCTL_CPA
and add more definitions of ML registers

Signed-off-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-07 10:39:18 +02:00
Arnaud Pouliquen d05d862ead ASoC: STI: Fix null ptr deference in IRQ handler
With RTlinux a race condition has been found that leads to NULL ptr crash:
- On CPU 0: uni_player_irq_handler is called to treat XRUN
 "(player->state == UNIPERIF_STATE_STOPPED)" is FALSE so status is checked,
 dev_err(player->dev, "FIFO underflow error detected") is printed
and then snd_pcm_stream_lock should be called to lock stream for stopping.
- On CPU 1: application stop and close the stream.
Issue is that the stop and shutdown functions are executed while
"FIFO underflow error detected" is printed.
So when CPU 0 calls snd_pcm_stream_lock, player->substream is already null.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 19:29:07 +01:00
Charles Keepax 77b329d194 ASoC: cs35l35: Correct handling of PDN_DONE with external boost
When using an external boost supply the PDN_DONE bit is not set, update
the handling in this case to use to use an appropriate fixed delay.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 19:27:56 +01:00
Charles Keepax 2c84afb52e ASoC: cs35l35: Improve power down time
Shorten the time it takes to power down the amp by disabling the volume
ramp whilst doing the final shutdown. The driver has already muted the
amplifier at this stage so doing the volume ramp serves no purpose.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
Acked-by: Brian Austin <brian.austin@cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 19:27:52 +01:00
Daniel Baluta 303e8954af ASoC: codec: wm8960: Stop when a matching PLL freq is found
When a matching PLL freq is found, searching continues even this is
not necessary. The problem was introduced with the following refactoring
commit 84fdc00d51 ("ASoC: codec: wm9860: Refactor PLL out freq search)

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 19:26:41 +01:00
Ryan Lee 7c0c200071 ASoC: Add support for Maxim Integrated MAX98927 Amplifier
Signed-off-by: Ryan Lee <ryans.lee@maximintegrated.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 19:25:57 +01:00
Kuninori Morimoto 32973dcf71 ASoC: rsnd: merge rsnd_kctrl_new_m/s/e into rsnd_kctrl_new()
Current rsnd driver is using rsnd_kctrl_new_m/s/e function,
but the differences are very few.
This patch merge these rsnd_kctrl_new_m/s/e into rsnd_kctrl_new

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 11:50:18 +01:00
Mark Brown 3a37471551 Merge branch 'fix/rcar' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-rcar 2017-04-06 11:50:04 +01:00
Kuninori Morimoto fc99d23f6d ASoC: rsnd: tidyup src->convert_rate reset timing
Current src->convert_rate will be set on .hw_param, and
be reset on .quit timing.
But, .hw_param will not be called again if user did Ctrl-Z + fg.
It should be reset on initial of .hw_param to keep its value.
Here, ctu.c already do this.
This patch solves this issue, other wise, MIXed sound will be
strange if user did like below.

	> aplay -D plughw:0,0 sound_44100.wav &
	> aplay -D plughw:0,1 sound_96000.wav
	> Ctrl-Z
	> fg # 96kHz will be played as 44.1kHz

Reported-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tested-by: Hiroyuki Yokoyama <hiroyuki.yokoyama.vx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
2017-04-06 11:47:15 +01:00
Takashi Sakamoto 7e1621de14 ALSA: firewire-lib/bebob/oxfw: improve response evaluation for AV/C commands
In ALSA firewire stack, some AV/C commands are supported, including
vendor's extensions. Drivers includes response parser of each command,
according to its requirements, while the parser is written with loose
fashion in two points; error check and length check. This doesn't cause
any issues such as kernel corruption, but should be improved.

This commit modifies evaluations of return value on each parsers.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:37:23 +02:00
Takashi Sakamoto 5b33504bad ALSA: firewire-motu: remove invalid bitshift for register value
In protocol version 3, drivers can read current sampling clock status from
register 0x'ffff'f000'0b14. 8 bits of LSB of this register represents type
of signal as source of clock.

Current driver code includes invalid bitshift to handle the parameter. This
commit fixes the bug.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 5992e30034 ("ALSA: firewire-motu: add support for MOTU 828mk3 (FireWire/Hybrid) as a model with protocol version 3")
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:36:11 +02:00
Takashi Sakamoto 3d016d57fd ALSA: oxfw: fix regression to handle Stanton SCS.1m/1d
At a commit 6c29230e2a ("ALSA: oxfw: delayed registration of sound
card"), ALSA oxfw driver fails to handle SCS.1m/1d, due to -EBUSY at a call
of snd_card_register(). The cause is that the driver manages to register
two rawmidi instances with the same device number 0. This is a regression
introduced since kernel 4.7.

This commit fixes the regression, by fixing up device property after
discovering stream formats.

Fixes: 6c29230e2a ("ALSA: oxfw: delayed registration of sound card")
Cc: <stable@vger.kernel.org> # 4.7+
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:35:14 +02:00
Takashi Sakamoto fdb2b2eee6 ALSA: firewire-digi00x: remove transaction handler for unknown purpose
For digi00x series, asynchronous transaction is not used to transfer MIDI
messages to/from control surface. One of transction handlers in my previous
work loses its practical meaning.

This commit removes the handler. I note that unit of console type
transfers 0x00001000 to registered address of host space when switching
to 'standalone' mode. Then the unit generates bus reset.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:34:13 +02:00
Takashi Sakamoto 0c3f15f39c ALSA: firewire-digi00x: allow user space applications to read/write MIDI messages for all ports
At a commit c5fcee0373 ("ALSA: firewire-digi00x: add MIDI operations for
MIDI control port"), I described that MIDI messages for control surface is
transferred by a different way from the messages for physical ports.
However, this is wrong. MIDI messages to/from all of MIDI ports are
transferred by isochronous packets.

This commit removes codes to transfer MIDI messages via asynchronous
transaction, from MIDI handling layer.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:34:11 +02:00
Takashi Sakamoto 8820a4cf0c ALSA: firewire-digi00x: handle all MIDI messages on streaming packets
At a commit 9dc5d31cdc ("ALSA: firewire-digi00x: handle MIDI messages in
isochronous packets"), a functionality to handle MIDI messages on
isochronous packet was supported. But this includes some of my
misunderstanding. This commit is to fix them.

For digi00x series, first data channel of data blocks in rx/tx packet
includes MIDI messages. The data channel has 0x80 in 8 bit of its MSB,
however it's against IEC 61883-6. Unique data format is applied:
 - Upper 4 bits of LSB represent port number.
  - 0x0: port 1.
  - 0x2: port 2.
  - 0xe: console port.
 - Lower 4 bits of LSB represent the number of included MIDI message bytes;
   0x0/0x1/0x2.
 - Two bytes of middle of this data channel have MIDI bytes.

Especially, MIDI messages from/to console surface are also transferred by
isochronous packets, as well as physical MIDI ports.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:34:10 +02:00
Takashi Sakamoto 13e005f9f9 ALSA: firewire-digi00x: add support for console models of Digi00x series
Digi00x series includes two types of unit; rack and console. As long as
reading information on config rom of Digi 002 console, 'MODEL_ID' field
has a different value from the one on Digi 002 rack.

We've already got a test report from users with Digi 003 rack. We can
assume that console type and rack type has different value in the field.

This commit adds a device entry for console type. For following commits,
this commit also adds a member to 'struct snd_digi00x' to identify console
type.

$ cd linux-firewire-utils/src
$ python2 ./crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  0404f9d0  bus_info_length 4, crc_length 4, crc 63952
404  31333934  bus_name "1394"
408  60647002  irmc 0, cmc 1, isc 1, bmc 0, cyc_clk_acc 100, max_rec 7 (256)
40c  00a07e00  company_id 00a07e     |
410  00a30000  device_id 0000a30000  | EUI-64 00a07e0000a30000

               root directory
               -----------------------------------------------------------------
414  00058a39  directory_length 5, crc 35385
418  0c0043a0  node capabilities
41c  04000001  hardware version
420  0300a07e  vendor
424  81000007  --> descriptor leaf at 440
428  d1000001  --> unit directory at 42c

               unit directory at 42c
               -----------------------------------------------------------------
42c  00046674  directory_length 4, crc 26228
430  120000a3  specifier id
434  13000001  version
438  17000001  model
43c  81000007  --> descriptor leaf at 458

               descriptor leaf at 440
               -----------------------------------------------------------------
440  00055913  leaf_length 5, crc 22803
444  000050f2  descriptor_type 00, specifier_ID 50f2
448  80000000
44c  44696769
450  64657369
454  676e0000

               descriptor leaf at 458
               -----------------------------------------------------------------
458  0004a6fd  leaf_length 4, crc 42749
45c  00000000  textual descriptor
460  00000000  minimal ASCII
464  44696769  "Digi"
468  20303032  " 002"

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:34:08 +02:00
Takashi Sakamoto 76fdb3a9e1 ALSA: fireface: add support for Fireface 400
Fireface 400 is a second model of RME Fireface series, released in 2006.
This commit adds support for this model.

This model supports 8 analog channels, 2 S/PDIF channels and 8 ADAT
channels in both of tx/rx packet. The number of ADAT channels differs
depending on each mode of sampling transmission frequency.

$ python2 linux-firewire-utils/src/crpp < /sys/bus/firewire/devices/fw1/config_rom
               ROM header and bus information block
               -----------------------------------------------------------------
400  04107768  bus_info_length 4, crc_length 16, crc 30568 (should be 61311)
404  31333934  bus_name "1394"
408  20009002  irmc 0, cmc 0, isc 1, bmc 0, cyc_clk_acc 0, max_rec 9 (1024)
40c  000a3501  company_id 000a35     |
410  1bd0862a  device_id 011bd0862a  | EUI-64 000a35011bd0862a

               root directory
               -----------------------------------------------------------------
414  000485ec  directory_length 4, crc 34284
418  03000a35  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  000314c4  directory_length 3, crc 5316
42c  12000a35  specifier id
430  13000002  version
434  17101800  model

               eui-64 leaf at 438
               -----------------------------------------------------------------
438  000261a8  leaf_length 2, crc 25000
43c  000a3501  company_id 000a35     |
440  1bd0862a  device_id 011bd0862a  | EUI-64 000a35011bd0862a

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:54 +02:00
Takashi Sakamoto f656edd5fb ALSA: fireface: add hwdep interface
This commit adds hwdep interface so as the other drivers for audio and
music units on IEEE 1394 have.

This interface is designed for mixer/control applications. By using this
interface, an application can get information about firewire node, can
lock/unlock kernel streaming and can get notification at starting/stopping
kernel streaming.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:49 +02:00
Takashi Sakamoto 4b316436ab ALSA: fireface: add support for PCM functionality
This commit adds PCM functionality to transmit/receive PCM frames on
isochronous packet streaming. This commit enables userspace applications
to start/stop packet streaming via ALSA PCM interface.

Sampling rate requested by applications is used as sampling transmission
frequency of IEC 61883-1/6packet streaming. As I described in followed
commits, units in this series manages sampling clock frequency
independently of sampling transmission frequency, and they supports
resampling between their packet streaming/data block processing layer and
sampling data processing layer. This commit take this driver to utilize
these features for usability.

When internal clock is selected as source signal of sampling clock, this
driver allows user space applications to start PCM substreams at any rate
which packet streaming engine supports as sampling transmission frequency.
In this case, this driver expects units to perform resampling PCM frames
for rx/tx packets when sampling clock frequency and sampling transmission
frequency are mismatched. This is for daily use cases.

When any external clock is selected as the source signal, this driver
gets configured sampling rate from units, then restricts available
sampling rate to the rate for PCM applications. This is for studio use
cases.

Models in this series supports 64.0/128.0 kHz of sampling rate, however
these frequencies are not supported by IEC 61883-6 as sampling transmission
frequency. Therefore, packet streaming engine of ALSA firewire stack can't
handle them. When units are configured to use any external clock as source
signal of sampling clock and one of these unsupported rate is configured
as rate of the sampling clock, this driver returns EIO to user space
applications.

Anyway, this driver doesn't voluntarily configure parameters of sampling
clock. It's better for users to work with appropriate user space
implementations to configure the parameters in advance of usage.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:46 +02:00
Takashi Sakamoto 75d6d89897 ALSA: fireface: add stream management functionality
This commit adds management functionality for packet streaming.

As long as investigating Fireface 400, there're three modes depending
on sampling transmission frequency. The number of data channels in each
data block is different depending on the mode. The set of available
data channels for each mode might be different for each protocol and
model.

The length of registers for the number of isochronous channel is just
three bits, therefore 0-7ch are available.

When bus reset occurs on IEEE 1394 bus, the device discontinues to
transmit packets. This commit aborts PCM substreams at bus reset handler.

As I described in followed commits, The device manages its sampling clock
independently of sampling transmission frequency against IEC 61883-6.
Thus, it's a lower cost to change the sampling transmission frequency,
while data fetch between streaming layer and DSP require larger buffer
for resampling. As a result, device latency might tend to be larger than
ASICs for IEC 61883-1/6 such as DM1000/DM1100/DM1500 (BeBoB),
DiceII/TCD2210/TCD2220/TCD3070 and OXFW970/971.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:44 +02:00
Takashi Sakamoto 6fb7db902b ALSA: fireface: add unique data processing layer
As long as investigating Fireface 400, format of payload of each
isochronous packet is not IEC 61883-1/6, thus its format of data block
is not AM824. The remarkable points of the format are:
 * The payload just consists of some data channels of quadlet size without
   CIP header.
 * Each data channels includes data aligned to little endian order.
 * One data channel consists of two parts; 8 bit ancillary field and 24 bit
   PCM frame.

Due to lack of CIP headers, rx/tx packets include no CIP headers and
different way to check packet discontinuity. For tx packet, the ancillary
field is used for counter. However, the way of counting is different
depending on positions of data channels. At 44.1 kHz, ancillary field in:
 * 1st/6th/9th/10th/14th/17th data channels: not used for this purpose.
 * 2nd/18th data channels: incremented every data block (0x00-0xff).
 * 3rd/4th/5th/11th/12th/13th data channels: incremented every 256 data
   blocks (0x00-0x07).
 * 7th/8th/15th/16th data channels: incremented per the number of data
   blocks in a packet. The increment can occur per packet (0x00-0xff).

For tx packet, tag of each isochronous packet is used for this purpose.
The value of tag cyclically changes between 0, 1, 2 and 3 in this order.
The interval is different depending on sampling transmission frequency.
At 44.1/48.0 kHz, it's 256 data blocks. At 88.2 kHz, it's 96 data blocks.

The number of data blocks in tx packet is exactly the same as
SYT_INTERVAL. There's no empty packet or no-data packet, thus the
throughput is not 8,000 packets per sec. On the other hand, the one in
rx packet is 8,000 packets per sec, thus the number of data blocks is
different between each packet, depending on sampling transmission
frequency:
 * 44.1 kHz: 5 or 6
 * 48.0 kHz: 5 or 6 or 7
 * 88.2 kHz: 10 or 11 or 12

This commit adds data processing layer to satisfy the above specification
in a policy of 'best effort'. Although PCM frames are handled for
intermediate buffer to user space, the ancillary data is not handled at all
to reduce CPU usage, thus counter is not checked. 0 is always used for tag
of isochronous packet. Furthermore, the packet streaming layer is
responsible for calculation of the number of data blocks for each packet,
thus it's not exactly the same sequence from the above observation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:42 +02:00
Takashi Sakamoto 3b196c394d ALSA: firewire-lib: add no-header packet processing
As long as investigating Fireface 400, IEC 61883-1/6 is not applied to
its packet streaming protocol. Remarks of the specific protocol are:
 * Each packet doesn't include CIP headers.
 * 64,0 and 128,0 kHz are supported.
 * The device doesn't necessarily transmit 8,000 packets per second.
 * 0, 1, 2, 3 are used as tag for rx isochronous packets, however 0 is
   used for tx isochronous packets.

On the other hand, there's a common feature. The number of data blocks
transferred in a second is the same as sampling transmission frequency.
Current ALSA IEC 61883-1/6 engine already has a method to calculate it and
this driver can utilize it for rx packets, as well as tx packets.

This commit adds support for the transferring protocol. CIP_NO_HEADERS
flag is newly added. When this flag is set:
 * Both of 0 (without CIP header) and 1 (with CIP header) are used as tag
   to handle incoming isochronous packet.
 * 0 (without CIP header) is used as tag to transfer outgoing isochronous
   packet.
 * Skip CIP header evaluation.
 * Use unique way to calculate the quadlets of isochronous packet payload.

In ALSA PCM interface, 128.0 kHz is not supported, and the ALSA
IEC 61883-1/6 engine doesn't support 64.0 kHz. These modes are dropped.

The sequence of rx packet has a remarkable quirk about tag. This will be
described in later commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:40 +02:00
Takashi Sakamoto ff0fb5aaa8 ALSA: firewire-lib: use the same prototype for functions to handle packet
Audio and music units of RME Fireface series use its own protocol for
isochronous packets to transfer data. This protocol requires ALSA IEC
61883-1/6 engine to have alternative functions.

This commit is a preparation for the protocol.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:38 +02:00
Takashi Sakamoto d3fc7aac11 ALSA: fireface: add proc node to help debugging
Drivers can retrieve the state and configuration of clock by read
transactions.

This commit allows protocol abstraction layer to to dump the
information for debugging, via proc interface.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:36 +02:00
Takashi Sakamoto ff2c293efa ALSA: fireface: add support for MIDI functionality
In previous commit, fireface driver supports unique transaction mechanism
for MIDI feature. This commit adds MIDI functionality for userspace
applications.

As I wrote in a followed commit, user space applications get some
requirement from this driver. It should not touch a register to which
units transmit MIDI messages. It should configure a register in which
MIDI transmission is controlled.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:34 +02:00
Takashi Sakamoto 1917429578 ALSA: fireface: add transaction support
As long as investigating Fireface 400, MIDI messages are transferred by
asynchronous communication over IEEE 1394 bus.

Fireface 400 receives MIDI messages by write transactions to two addresses;
0x'0000'0801'8000 and 0x'0000'0801'9000. Each of two seems to correspond to
MIDI port 1 and 2.

Fireface 400 transfers MIDI messages by write transactions to certain
addresses which configured by drivers. The drivers can decide upper 4 byte
of the addresses by write transactions to 0x'0000'0801'03f4. For the rest
part of the address, drivers can select from below options:
 * 0x'0000'0000
 * 0x'0000'0080
 * 0x'0000'0100
 * 0x'0000'0180

Selected options are represented in register 0x'0000'0801'051c as bit
flags. Due to this mechanism, drivers are restricted to use addresses on
'Memory space' of IEEE 1222, even if transactions to the address have
some side effects.

This commit adds transaction support for MIDI messaging, based on my
assumption that the similar mechanism is used on the other protocols. To
receive asynchronous transactions, the driver allocates a range of address
in 'Memory space'. I apply a strategy to use 0x'0000'0000 as lower 4 byte
of the address. When getting failure from Linux FireWire subsystem, this
driver retries to allocate addresses.

Unfortunately, read transaction to address 0x'0000'0801'051c returns zero
always, however write transactions have effects to the other features such
as status of sampling clock. For this reason, this commit delegates a task
to configure this register to user space applications. The applications
should set 3rd bit in LSB in little endian order.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:31 +02:00
Takashi Sakamoto 53eb086750 ALSA: fireface: add an abstraction layer for model-specific protocols
As of 2016, RME discontinued its Fireface series, thus it's OK for us
to focus on released firmwares to drive known units.

As long as investigating Fireface 400 with Windows driver and comparing
the result to FFADO implementation, I can see these firmwares have
different register assignments. On the other hand, according to manuals
of each models, features relevant to packet streaming seem to be common,
because GUIs for these models have the same options. It's reasonable to
assume an abstraction layer of protocols to communicate to each models.

This commit adds the abstraction layer for the protocols. This layer
includes some functions to operate common features of models in this
series.

In IEC 61883-1/6, the sequence of packet can transfer timing information
to synchronize receivers to transmitters. Units of each node on IEEE 1394
bus can generate transmitter's timing clock by handling value of SYT field
in CIP header with high-precision clock. For audio and music units on
IEEE 1394 bus, this recovered clock is designed to used for sampling clock
to capture/generate PCM frames on DSP/ADC/DAC. (Actually, in this world,
there's no units to implement this specification as is, as long as I
know).

Fireface series doesn't use this mechanism. Besides, It doesn't use
isochronous packet with CIP header. It uses internal crystal unit as its
initial sampling clock. When detecting input signals which can be
available for sampling clock (e.g. ADAT input), drivers can configure
units to use the signals as source of sampling clock. When something goes
wrong, e.g. frequency mismatching between the signal and configured value,
units fallback to the other detected signals alternatively. When detecting
no alternatives, internal crystal unit is used as source of sampling
clock. On manual of Fireface 400, this mechanism is described as
'Autosync'.

On the units, packet streaming is controlled by write transactions to
certain registers. Format of the packet, e.g. the number of data channels
in a data block, is also configured by the same manner. For this purpose,
.begin_session and .finish_session is added.

The remarkable point of this protocol is to allow drivers to configure
arbitrary sampling transmission frequency; e.g. 12.345 Hz. As long as I
know, there's no actual DAC/ADC chips which support this kind of
capability. I think a pair of packet streaming layer and data block
processing layer is isolated from sampling data processing layer in a
point of governed clock. In short, between these parts, resampling layer
exists. Actually, for Fireface 400, write transactions to
0x'0000'8010'051c has an effect to change sampling clock frequency with
base frequencies (32.0/44.1/48.0 kHz) and its multipliers (x2/x4),
regardless of sampling transmission frequency.

For this reason, the abstraction layer doesn't handle parameters for
sampling clock. Instead, each implementation of .begin_session is
expected to configure sampling transmission frequency.

For packet streaming layer, it's enough to get current selection of
source signals for the sampling clock and its frequency. In the
abstraction layer, when internal crystal is selected, drivers can sets
arbitrary sampling frequency, else they should follow configured
frequency. For this purpose, .get_clock is added.

Drivers are allows to bank up data fetching from a pair of packet
streaming/data block processing layer and sampling data processing layer.
This feature seems to suppress noises at starting/stopping packet
streaming. For this purpose, .switch_fetching_mode is added.

As I described in the above, units have remarkable mechanism to manage
sampling clock and process sampling data. For debugging purpose,
.dump_sync_status and .dump_clock_config are added. I don't have a need
to common interface to represent the status and configuration,
developers can add actual implementation of the abstraction layer as they
like.

Unlike PCM frames, MIDI messages are transferred by asynchronous
communication over IEEE 1394 bus, thus target addresses are important for
this feature. The .midi_high_addr_reg, .midi_rx_port_0_reg and
.midi_rx_port_1_reg are for this purpose. I'll describe them in following
commit.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:30 +02:00
Takashi Sakamoto ed90f91a17 ALSA: fireface: add model specific structure
RME Fireface series has several models and their specifications are
different. Currently, we find no way to retrieve the specifications
from actual devices and need to implement them in this driver.

This commit adds a structure to describe model specific data. This
structure has an identical name for each unit, and maximum number of
data channels in each mode. I'll describe about the mode in following
commits.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:28 +02:00
Takashi Sakamoto 324540c4e0 ALSA: fireface: postpone sound card registration
Just after appearing on IEEE 1394 bus, this unit generates several bus
resets. This is due to loading firmware from on-board flash memory and
initialize hardware. It's better to postpone sound card registration.

This commit schedules workqueue to process actual probe processing
2 seconds after the last bus-reset. The card instance is kept at unit
probe callback and released at card free callback. Therefore, when the
actual probe processing fails, the memory block is wasted. This is due to
simplify driver implementation.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2017-04-05 21:31:26 +02:00