openwrt/staging/blogic.git
7 years agoALSA: seq: Allow the tristate build of OSS emulation
Takashi Iwai [Fri, 9 Jun 2017 12:06:46 +0000 (14:06 +0200)]
ALSA: seq: Allow the tristate build of OSS emulation

Currently OSS sequencer emulation is tied with ALSA sequencer core,
both are built in the same level; i.e. when CONFIG_SND_SEQUENCER=y,
the OSS sequencer emulation is also always built-in, even though the
functionality can be built as an individual module.

This patch changes the rule and allows users to build snd-seq-oss
module while others are built-in.  Essentially, it's just a few simple
changes in Kconfig and Makefile.  Some driver codes like opl3 need to
convert from the simple ifdef to IS_ENABLED().  But that's all.

You might wonder how about the dependency: right, it can be messy, but
it still works.  Since we rewrote the sequencer binding with the
standard bus, the driver can be bound at any time on demand.  So, the
synthesizer driver module can be loaded individually from the OSS
emulation core before/after it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: Make CONFIG_SND_OSSEMUL user-selectable
Takashi Iwai [Fri, 9 Jun 2017 11:56:05 +0000 (13:56 +0200)]
ALSA: Make CONFIG_SND_OSSEMUL user-selectable

Currently CONFIG_SND_OSSEMUL is selected by each config like
CONFIG_SND_PCM_OSS.  But, as see in the raw MIDI code that is built
conditionally with CONFIG_SND_OSSEMUL, we should rather make
CONFIG_SND_OSSEMUL user-selectable as the top kconfig item, and leave
the rest depending on it.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: use friendly name for id of PCM substream in trace print
Takashi Sakamoto [Fri, 9 Jun 2017 12:46:50 +0000 (21:46 +0900)]
ALSA: pcm: use friendly name for id of PCM substream in trace print

Use the same print format of snd_pcm_debug_name() for userspace tracing
program.

Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: add tracepoints for final selection process of hardware parameters
Takashi Sakamoto [Fri, 9 Jun 2017 12:46:49 +0000 (21:46 +0900)]
ALSA: pcm: add tracepoints for final selection process of hardware parameters

Results of ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE and
SNDRV_PCM_IOCTL_HW_PARAMS are different, because the latter has single
value for several parameters; e.g. channels of PCM substream. Selection
of the single value is done independently of application of constraints.
It's helpful for developers to trace the selection process.

This commit adds tracepoints to snd_pcm_hw_params_choose() for the
purpose.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: localize snd_pcm_hw_params_choose()
Takashi Sakamoto [Fri, 9 Jun 2017 12:46:48 +0000 (21:46 +0900)]
ALSA: pcm: localize snd_pcm_hw_params_choose()

As of v4.12, snd_pcm_hw_params_choose() is just called in a process
context of ioctl(2) with SNDRV_PCM_IOCTL_HW_PARAMS. The function locates
in a different file, which has no tracepoints.

This commit moves the function to a file with the tracepoints for later
commit.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: sparc: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:23:22 +0000 (14:23 +0200)]
ALSA: sparc: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: via82xx: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:23:13 +0000 (14:23 +0200)]
ALSA: via82xx: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: sonicvibes: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:55 +0000 (14:22 +0200)]
ALSA: sonicvibes: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme9652: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:43 +0000 (14:22 +0200)]
ALSA: rme9652: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hdspm: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:35 +0000 (14:22 +0200)]
ALSA: hdspm: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hdsp: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:26 +0000 (14:22 +0200)]
ALSA: hdsp: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme96: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:10 +0000 (14:22 +0200)]
ALSA: rme96: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme32: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:22:02 +0000 (14:22 +0200)]
ALSA: rme32: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: nm256: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:21:49 +0000 (14:21 +0200)]
ALSA: nm256: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: intel8x0: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:21:31 +0000 (14:21 +0200)]
ALSA: intel8x0: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: ice1724: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:20:52 +0000 (14:20 +0200)]
ALSA: ice1724: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: ice1712: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:20:40 +0000 (14:20 +0200)]
ALSA: ice1712: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hda: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:20:07 +0000 (14:20 +0200)]
ALSA: hda: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: es1938: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:19:56 +0000 (14:19 +0200)]
ALSA: es1938: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: ens137x: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:19:39 +0000 (14:19 +0200)]
ALSA: ens137x: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: fm801: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:19:28 +0000 (14:19 +0200)]
ALSA: fm801: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: emu10k1: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:19:20 +0000 (14:19 +0200)]
ALSA: emu10k1: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: cs46xx: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:19:05 +0000 (14:19 +0200)]
ALSA: cs46xx: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: cmipci: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:18:47 +0000 (14:18 +0200)]
ALSA: cmipci: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: bt87x: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:18:33 +0000 (14:18 +0200)]
ALSA: bt87x: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: azt3328: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:18:16 +0000 (14:18 +0200)]
ALSA: azt3328: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: au88x0: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:18:01 +0000 (14:18 +0200)]
ALSA: au88x0: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: atiixp: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:17:39 +0000 (14:17 +0200)]
ALSA: atiixp: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: ali5451: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:17:23 +0000 (14:17 +0200)]
ALSA: ali5451: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: parisc: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:17:04 +0000 (14:17 +0200)]
ALSA: parisc: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: wss: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:16:43 +0000 (14:16 +0200)]
ALSA: wss: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: sb: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:16:34 +0000 (14:16 +0200)]
ALSA: sb: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: gus: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:16:25 +0000 (14:16 +0200)]
ALSA: gus: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: es18xx: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:16:10 +0000 (14:16 +0200)]
ALSA: es18xx: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: es1688: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:15:49 +0000 (14:15 +0200)]
ALSA: es1688: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: cs423x: Constify hw_constraints
Takashi Iwai [Wed, 7 Jun 2017 12:12:16 +0000 (14:12 +0200)]
ALSA: cs423x: Constify hw_constraints

snd_pcm_hw_constraint_list(), *_ratnums() and *_ratdens() receive the
const pointers.  Constify the corresponding static objects for better
hardening.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: vx: vx_pcm: constify vx_pcm_playback_ops and vx_pcm_capture_ops.
Arvind Yadav [Fri, 9 Jun 2017 07:05:43 +0000 (12:35 +0530)]
ALSA: vx: vx_pcm: constify vx_pcm_playback_ops and vx_pcm_capture_ops.

File size before:
   text    data     bss     dec     hex filename
   7126     240       0    7366    1cc6 sound/drivers/vx/vx_pcm.o

File size After adding 'const':
   text    data     bss     dec     hex filename
   7382       0       0    7382    1cd6 sound/drivers/vx/vx_pcm.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA : pcsp: pcsp_lib: constify snd_pcsp_playback_ops
Arvind Yadav [Fri, 9 Jun 2017 06:09:56 +0000 (11:39 +0530)]
ALSA : pcsp: pcsp_lib: constify snd_pcsp_playback_ops

File size before:
   text    data     bss     dec     hex filename
   2027     168       1    2196     894 sound/drivers/pcsp/pcsp_lib.o

File size After:
   text    data     bss     dec     hex filename
   2155      40       1    2196     894 sound/drivers/pcsp/pcsp_lib.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: move fixup of info flag after selecting single parameters
Takashi Sakamoto [Fri, 9 Jun 2017 00:34:40 +0000 (09:34 +0900)]
ALSA: pcm: move fixup of info flag after selecting single parameters

When drivers register no flags about information of PCM hardware, ALSA
PCM core fixups it roughly. Currently, this operation places in a
function snd_pcm_hw_refine(). It can be moved to a function
fixup_unreferenced_params() because it doesn't affects operations
between these two functions.

This idea is better to bundle codes with similar purposes and this commit
achieves it.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: calculate non-mask/non-interval parameters always when possible
Takashi Sakamoto [Fri, 9 Jun 2017 00:34:39 +0000 (09:34 +0900)]
ALSA: pcm: calculate non-mask/non-interval parameters always when possible

A structure for parameters of PCM runtime has parameters which are
not classified as mask/interval type. They are decided only when
corresponding normal parameters have unique values.
 * struct snd_pcm_hw_params.msbits
 * struct snd_pcm_hw_params.rate_num
 * struct snd_pcm_hw_params.rate_den
 * struct snd_pcm_hw_params.fifo_size

Current implementation of hw_params ioctl sometimes doesn't decide these
parameters even if corresponding parameters are fixed, because these
parameters are evaluated before a call of snd_pcm_hw_params_choose().

This commit adds a helper function to process the parameters and call it
in proper positions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: use helper functions to refer parameters as constants
Takashi Sakamoto [Fri, 9 Jun 2017 00:34:38 +0000 (09:34 +0900)]
ALSA: pcm: use helper functions to refer parameters as constants

To fixup some parameters, ALSA PCM core refers the other parameters as
constants. There're some macros for this purpose.

This commit replaces codes with them.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: add comment about application of rule to PCM parameters
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:06 +0000 (06:37 +0900)]
ALSA: pcm: add comment about application of rule to PCM parameters

Drivers add rules of parameters to runtime of PCM substream, when
applications open ALSA PCM character device. When applications call
ioctl(2) with SNDRV_PCM_IOCTL_HW_REFINE or SNDRV_PCM_IOCTL_HW_PARAMS, the
rules are applied to the parameters and return the result to user space.

The rule can have dependency between parameters. Additionally, it can have
condition flags about application of rules. Userspace applications can
indicate the flags to suppress change of parameters.

This commit attempts to describe the mechanism.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: use helper functions to check whether parameters are determined
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:05 +0000 (06:37 +0900)]
ALSA: pcm: use helper functions to check whether parameters are determined

A commit 8bea869c5e56 ("ALSA: PCM midlevel: improve fifo_size handling")
allows drivers to implement calculation of fifo size in parameter
structure. This calculation runs only when two of the other parameters
have single value.

In ALSA PCM core, there're some helper functions for the case. This commit
applies the functions instead of value comparison.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: adaption of code formatting
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:04 +0000 (06:37 +0900)]
ALSA: pcm: adaption of code formatting

This commit modifies current for readability in below aspects:
 - use bool type variable instead of int type variable assigned to 0/1
 - move variable definition from loop to top of the function definition

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: remove function local variable with alternative evaluation
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:03 +0000 (06:37 +0900)]
ALSA: pcm: remove function local variable with alternative evaluation

A local variable is used to judge whether a parameter should be handled
due to reverse dependency of the other rules. However, this can be
obsoleted by check of a sentinel in dependency array.

This commit removes the local variable and check the sentinel to reduce
stack usage.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: use goto statement instead of while statement to reduce indentation
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:02 +0000 (06:37 +0900)]
ALSA: pcm: use goto statement instead of while statement to reduce indentation

In a process to calculate parameters of PCM substream, application of all
rules is iterated several times till parameter dependencies are satisfied.
In current implementation, two loops are used for the design, however this
brings two-level indentation and decline readability.

This commit attempts to reduce the indentation by using goto statement,
instead of outer while loop.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: add a helper function to apply parameter rules
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:01 +0000 (06:37 +0900)]
ALSA: pcm: add a helper function to apply parameter rules

Application of rules to parameters of PCM substream is done in a call of
snd_pcm_hw_refine(), while the function includes much codes and is not
enough friendly to readers.

This commit splits the codes to a separated function so that readers can
get it easily. I leave desicion into compilers to merge the function into
its callee.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: add a helper function to constrain interval-type parameters
Takashi Sakamoto [Thu, 8 Jun 2017 21:37:00 +0000 (06:37 +0900)]
ALSA: pcm: add a helper function to constrain interval-type parameters

Application of constraints to interval-type parameters for PCM substream
is done in a call of snd_pcm_hw_refine(), while the function includes
much codes and is not enough friendly to readers.

This commit splits the codes to a separated function so that readers can
get it easily. I leave desicion into compilers to merge the function into
its callee.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: add a helper function to constrain mask-type parameters
Takashi Sakamoto [Thu, 8 Jun 2017 21:36:59 +0000 (06:36 +0900)]
ALSA: pcm: add a helper function to constrain mask-type parameters

Application of constraints to mask-type parameters for PCM substream is
done in a call of snd_pcm_hw_refine(), while the function includes much
codes and is not enough friendly to readers.

This commit splits the codes to a separated function so that readers can
get it easily. I leave desicion into compilers to merge the function into
its callee.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: firewire: arrange common PCM info/constraints for AMDTP engine applications
Takashi Sakamoto [Thu, 8 Jun 2017 00:11:03 +0000 (09:11 +0900)]
ALSA: firewire: arrange common PCM info/constraints for AMDTP engine applications

In ALSA firewire stack, 8 drivers uses IEC 61883-1/6 engine for data
transmission. They have common PCM info/constraints and duplicated codes.

This commit unifies the codes into fireiwre-lib.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: obsolete RULES_DEBUG local macro
Takashi Sakamoto [Tue, 6 Jun 2017 23:46:45 +0000 (08:46 +0900)]
ALSA: pcm: obsolete RULES_DEBUG local macro

Added tracepoints obsoleted RULES_DEBUG local macro and relevant codes.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: enable parameter tracepoints only when CONFIG_SND_DEBUG is enabled
Takashi Sakamoto [Tue, 6 Jun 2017 23:46:44 +0000 (08:46 +0900)]
ALSA: pcm: enable parameter tracepoints only when CONFIG_SND_DEBUG is enabled

In a previous commit, tracepoints are added for PCM parameter processing.
As long as I know, this implementation increases size of relocatable
object by 35%. For vendors who are conscious of memory footprint, it
brings apparent disadvantage.

This commit utilizes CONFIG_SND_DEBUG configuration to enable/disable the
tracepoints.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: tracepoints for refining PCM parameters
Takashi Sakamoto [Tue, 6 Jun 2017 23:46:43 +0000 (08:46 +0900)]
ALSA: pcm: tracepoints for refining PCM parameters

When working for devices which support configurable modes for its data
transmission or which consists of several components, developers are
likely to use rules of parameters of PCM substream. However, there's no
infrastructure to assist their work.

In old days, ALSA PCM core got a local 'RULES_DEBUG' macro to debug
refinement of parameters for PCM substream. Although this is merely a
makeshift. With some modifications, we get the infrastructure.

This commit is for the purpose. Refinement of mask/interval type of
PCM parameters is probed as tracepoint events as 'hw_mask_param' and
'hw_interval_param' on existent 'snd_pcm' subsystem.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: timer: Wrap with spinlock for queue access
Takashi Iwai [Fri, 2 Jun 2017 15:35:30 +0000 (17:35 +0200)]
ALSA: timer: Wrap with spinlock for queue access

For accessing the snd_timer_user queue indices, we take tu->qlock.
But it's forgotten in a couple of places.

The one in snd_timer_user_params() should be safe without the
spinlock as the timer is already stopped.  But it's better for
consistency.

The one in poll is just a read-out, so it's not inevitably needed, but
it'd be good to make the result consistent, too.

Tested-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: timer: Improve user queue reallocation
Takashi Iwai [Fri, 2 Jun 2017 15:16:59 +0000 (17:16 +0200)]
ALSA: timer: Improve user queue reallocation

ALSA timer may reallocate the user queue upon request, and it happens
at three places for now: at opening, at SNDRV_TIMER_IOCTL_PARAMS, and
at SNDRV_TIMER_IOCTL_SELECT.  However, the last one,
snd_timer_user_tselect(), doesn't need to reallocate the buffer since
it doesn't change the queue size.  It does just because tu->tread
might have been changed before starting the timer.

Instead of *_SELECT ioctl, we should reallocate the queue at
SNDRV_TIMER_IOCTL_TREAD; then the timer is guaranteed to be stopped,
thus we can reassign the buffer more safely.

This patch implements that with a slight code refactoring.
Essentially, the patch achieves:
- Introduce realloc_user_queue() for (re-)allocating the ring buffer,
  and call it from all places.  Also, realloc_user_queue() uses
  kcalloc() for avoiding possible leaks.
- Add the buffer reallocation at SNDRV_TIMER_IOCTL_TREAD.  When it
  fails, tu->tread is restored to the old value, too.
- Drop the buffer reallocation at snd_timer_user_tselect().

Tested-by: Alexander Potapenko <glider@google.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoMerge branch 'for-linus' into for-next
Takashi Iwai [Wed, 7 Jun 2017 08:25:30 +0000 (10:25 +0200)]
Merge branch 'for-linus' into for-next

For applying more ALSA timer cleanups.

7 years agoALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT
Takashi Iwai [Fri, 2 Jun 2017 15:26:56 +0000 (17:26 +0200)]
ALSA: timer: Fix missing queue indices reset at SNDRV_TIMER_IOCTL_SELECT

snd_timer_user_tselect() reallocates the queue buffer dynamically, but
it forgot to reset its indices.  Since the read may happen
concurrently with ioctl and snd_timer_user_tselect() allocates the
buffer via kmalloc(), this may lead to the leak of uninitialized
kernel-space data, as spotted via KMSAN:

  BUG: KMSAN: use of unitialized memory in snd_timer_user_read+0x6c4/0xa10
  CPU: 0 PID: 1037 Comm: probe Not tainted 4.11.0-rc5+ #2739
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011
  Call Trace:
   __dump_stack lib/dump_stack.c:16
   dump_stack+0x143/0x1b0 lib/dump_stack.c:52
   kmsan_report+0x12a/0x180 mm/kmsan/kmsan.c:1007
   kmsan_check_memory+0xc2/0x140 mm/kmsan/kmsan.c:1086
   copy_to_user ./arch/x86/include/asm/uaccess.h:725
   snd_timer_user_read+0x6c4/0xa10 sound/core/timer.c:2004
   do_loop_readv_writev fs/read_write.c:716
   __do_readv_writev+0x94c/0x1380 fs/read_write.c:864
   do_readv_writev fs/read_write.c:894
   vfs_readv fs/read_write.c:908
   do_readv+0x52a/0x5d0 fs/read_write.c:934
   SYSC_readv+0xb6/0xd0 fs/read_write.c:1021
   SyS_readv+0x87/0xb0 fs/read_write.c:1018

This patch adds the missing reset of queue indices.  Together with the
previous fix for the ioctl/read race, we cover the whole problem.

Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: timer: Fix race between read and ioctl
Takashi Iwai [Fri, 2 Jun 2017 13:03:38 +0000 (15:03 +0200)]
ALSA: timer: Fix race between read and ioctl

The read from ALSA timer device, the function snd_timer_user_tread(),
may access to an uninitialized struct snd_timer_user fields when the
read is concurrently performed while the ioctl like
snd_timer_user_tselect() is invoked.  We have already fixed the races
among ioctls via a mutex, but we seem to have forgotten the race
between read vs ioctl.

This patch simply applies (more exactly extends the already applied
range of) tu->ioctl_lock in snd_timer_user_tread() for closing the
race window.

Reported-by: Alexander Potapenko <glider@google.com>
Tested-by: Alexander Potapenko <glider@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: fireface: constify ALSA specific operations
Takashi Sakamoto [Wed, 7 Jun 2017 00:38:06 +0000 (09:38 +0900)]
ALSA: fireface: constify ALSA specific operations

ALSA fireface driver has ALSA specific operations for MIDI/PCM data.
Structured data for the operations can be constified. Additionally,
The structured data can be function local.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: firewire: process packets in 'struct snd_pcm_ops.ack' callback
Takashi Sakamoto [Wed, 7 Jun 2017 00:38:05 +0000 (09:38 +0900)]
ALSA: firewire: process packets in 'struct snd_pcm_ops.ack' callback

In recent commit for ALSA PCM core, some arrangement is done for
'struct snd_pcm_ops.ack' callback. This is called when appl_ptr is
explicitly moved in intermediate buffer for PCM frames, except for
some cases described later.

For drivers in ALSA firewire stack, usage of this callback has a merit to
reduce latency between time of PCM frame queueing and handling actual
packets in recent isochronous cycle, because no need to wait for software
IRQ context from isochronous context of OHCI 1394.

If this works well in a case that mapped page frame is used for the
intermediate buffer, user process should execute some commands for ioctl(2)
to tell the number of handled PCM frames in the intermediate buffer just
after handling them. Therefore, at present, with a combination of below
conditions, this doesn't work as expected and user process should wait for
the software IRQ context as usual:
 - when ALSA PCM core judges page frame mapping is available for status
   data (struct snd_pcm_mmap_status) and control data
   (struct snd_pcm_mmap_control).
 - user process handles PCM frames by loop just with 'snd_pcm_mmap_begin()'
   and 'snd_pcm_mmap_commit()'.
 - user process uses PCM hw plugin in alsa-lib to operate I/O without
   'sync_ptr_ioctl' option.

Unfortunately, major use case include these three conditions.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoMerge tag 'asoc-fix-v4.12-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/broon...
Takashi Iwai [Tue, 6 Jun 2017 18:03:46 +0000 (20:03 +0200)]
Merge tag 'asoc-fix-v4.12-rc4' of git://git./linux/kernel/git/broonie/sound into for-linus

ASoC: Fixes for v4.12

This is the usual collection of device specific fixes, all accumilated
since the merge window, plus one fix from Takashi for a nasty use after
free bug that bit some things with deferred probe and an update to the
maintainer address for the former Wolfson parts.

7 years agoALSA: hda/realtek - Reorder ALC269 ASUS quirk entries
Takashi Iwai [Tue, 6 Jun 2017 10:33:17 +0000 (12:33 +0200)]
ALSA: hda/realtek - Reorder ALC269 ASUS quirk entries

A disorder is found in some ALC269 quirk entries for ASUS (1043:xxxx),
which should have been sorted in PCI SSID order.  Rearrange them, so
that I won't overlook the already existing entry like I did a couple
of times in the past...

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hda/realtek: Fix mic and headset jack sense on Asus X705UD
Chris Chiu [Mon, 5 Jun 2017 21:05:30 +0000 (15:05 -0600)]
ALSA: hda/realtek: Fix mic and headset jack sense on Asus X705UD

The ASUS X705UD laptop requires the known fixup ALC256_FIXUP_ASUS_MIC
in order to fix headphone jack sensing and to enable use of the internal
microphone.

Unfortunately jack sensing for the headset mic is still not working.

[rearranged the position to keep the PCI SSID order -- tiwai]

Signed-off-by: Chris Chiu <chiu@endlessm.com>
Signed-off-by: Daniel Drake <drake@endlessm.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: doc: Update copy_user, copy_kernel and fill_silence PCM ops
Takashi Iwai [Thu, 1 Jun 2017 20:36:02 +0000 (22:36 +0200)]
ALSA: doc: Update copy_user, copy_kernel and fill_silence PCM ops

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Build OSS writev/readv helpers conditionally
Takashi Iwai [Sun, 21 May 2017 17:08:57 +0000 (19:08 +0200)]
ALSA: pcm: Build OSS writev/readv helpers conditionally

The snd_pcm_oss_writev3() and snd_pcm_oss_readv3() are used only in
io.c with CONFIG_SND_PCM_OSS_PLUGINS=y.  Add an ifdef to reduce the
build of these functions.

Along with it, since they are called always for in-kernel copy, reduce
the argument and call snd_pcm_kernel_writev() and *_readv() directly
instead.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Kill set_fs() in PCM OSS layer
Takashi Iwai [Sun, 21 May 2017 08:14:42 +0000 (10:14 +0200)]
ALSA: pcm: Kill set_fs() in PCM OSS layer

This is the last-standing one: kill the set_fs() usage in PCM OSS
layer by replacing with the new API functions to deal with the direct
in-kernel buffer copying.

The code to fill the silence can be replaced even to a one-liner to
pass NULL buffer instead of the manual copying.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agousb: gadget: u_uac1: Kill set_fs() usage
Takashi Iwai [Sun, 21 May 2017 08:19:16 +0000 (10:19 +0200)]
usb: gadget: u_uac1: Kill set_fs() usage

With the new API to perform the in-kernel buffer copy, we can get rid
of set_fs() usage in this driver, finally.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Direct in-kernel read/write support
Takashi Iwai [Wed, 24 May 2017 16:23:20 +0000 (18:23 +0200)]
ALSA: pcm: Direct in-kernel read/write support

Now all materials are ready, let's allow the direct in-kernel
read/write, i.e. a kernel-space buffer is passed for read or write,
instead of the normal user-space buffer.  This feature is used by OSS
layer and UAC1 driver, for example.

The __snd_pcm_lib_xfer() takes in_kernel argument that indicates the
in-kernel buffer copy.  When this flag is set, another transfer code
is used.  It's either via copy_kernel PCM ops or the normal memcpy(),
depending on the driver setup.

As external API, snd_pcm_kernel_read(), *_write() and other variants
are provided.

That's all.  This support is really simple because of the code
refactoring until now.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Simplify snd_pcm_playback_silence()
Takashi Iwai [Wed, 24 May 2017 16:18:15 +0000 (18:18 +0200)]
ALSA: pcm: Simplify snd_pcm_playback_silence()

Use the existing silence helper codes for simplification.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Unify read/write loop
Takashi Iwai [Wed, 24 May 2017 20:36:23 +0000 (22:36 +0200)]
ALSA: pcm: Unify read/write loop

Both __snd_pcm_lib_read() and __snd_pcm_write() functions have almost
the same code to loop over samples.  For simplification, this patch
unifies both as the single helper, __snd_pcm_lib_xfer().

Other than that, there should be no functional change by this patch.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: More unification of PCM transfer codes
Takashi Iwai [Wed, 24 May 2017 16:15:26 +0000 (18:15 +0200)]
ALSA: pcm: More unification of PCM transfer codes

This patch proceeds more abstraction of PCM read/write loop codes.

For both interleaved and non-interleaved transfers, the same copy or
silence transfer code (which is defined as pcm_transfer_f) is used
now.  This became possible since we switched to byte size to copy_*
and fill_silence ops argument instead of frames.

And, for both read and write, we can use the same copy function (which
is defined as pcm_copy_f), just depending on whether interleaved or
non-interleaved mode.

The transfer function is determined at the beginning of the loop,
depending on whether the driver gives the specific copy ops or it's
the standard read/write.

Another bonus by this change is that we now guarantee the silencing
behavior when NULL buffer is passed to write helpers.  It'll simplify
some codes later.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Call directly the common read/write helpers
Takashi Iwai [Sun, 21 May 2017 07:35:21 +0000 (09:35 +0200)]
ALSA: pcm: Call directly the common read/write helpers

Make snd_pcm_lib_read() and *_write() static inline functions that
call the common helper functions directly.  This reduces a slight
amount of codes, and at the same time, it's a preparation for the
further cleanups / fixes.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Shuffle codes
Takashi Iwai [Wed, 24 May 2017 15:59:17 +0000 (17:59 +0200)]
ALSA: pcm: Shuffle codes

Just shuffle the codes, without any change otherwise.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Check PCM state by a common helper function
Takashi Iwai [Wed, 24 May 2017 15:51:30 +0000 (17:51 +0200)]
ALSA: pcm: Check PCM state by a common helper function

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Drop the old copy and silence ops
Takashi Iwai [Wed, 10 May 2017 20:21:52 +0000 (22:21 +0200)]
ALSA: pcm: Drop the old copy and silence ops

Now that all users of old copy and silence ops have been converted to
the new PCM ops, the old stuff can be retired and go away.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years ago[media] solo6x10: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 20:20:10 +0000 (22:20 +0200)]
[media] solo6x10: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
The device supports only 1 channel and 8bit sample, so it's always
bytes=frames, and we need no conversion of unit in the callback.
Also, it's a capture stream, thus no silence is needed.

Acked-by: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoASoC: blackfin: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 19:59:12 +0000 (21:59 +0200)]
ASoC: blackfin: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
In AC97 and I2S-TDM mode, we need to convert back to frames, but
otherwise the conversion is pretty straightforward.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: sh: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 19:57:16 +0000 (21:57 +0200)]
ALSA: sh: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
Fixed also the user-space buffer copy with the proper
copy_from_user*() variant.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: sb: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:34:45 +0000 (20:34 +0200)]
ALSA: sb: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
For avoiding the code redundancy, slightly hackish macros are
introduced.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: gus: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:33:05 +0000 (20:33 +0200)]
ALSA: gus: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
For simplifying the code a bit, two local helpers are introduced here:
get_bpos() and playback_copy_ack().

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hdsp: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:32:25 +0000 (20:32 +0200)]
ALSA: hdsp: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
The conversion is straightforward with standard helper functions.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme9652: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:31:41 +0000 (20:31 +0200)]
ALSA: rme9652: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
The conversion is straightforward with standard helper functions.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme96: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:30:34 +0000 (20:30 +0200)]
ALSA: rme96: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
The conversion is straightforward with standard helper functions, and
now we can drop the bytes <-> frames conversions in callbacks.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: rme32: Convert to the new PCM copy ops
Takashi Iwai [Wed, 10 May 2017 18:29:25 +0000 (20:29 +0200)]
ALSA: rme32: Convert to the new PCM copy ops

Replace the copy and the silence ops with the new ops.
The conversion is straightforward with standard helper functions, and
now we can drop the bytes <-> frames conversions in callbacks.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: korg1212: Convert to the new PCM ops
Takashi Iwai [Wed, 10 May 2017 18:19:17 +0000 (20:19 +0200)]
ALSA: korg1212: Convert to the new PCM ops

Replace the copy and the silence ops with the new PCM ops.
Although we can refactor this messy code, at this time, the changes
are kept as small as possible.  Let's clean up later.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: nm256: Convert to new PCM copy ops
Takashi Iwai [Wed, 10 May 2017 18:25:17 +0000 (20:25 +0200)]
ALSA: nm256: Convert to new PCM copy ops

Replace the copy and the silence ops with the new ops.
The conversion is straightforward with standard helper functions, and
now we can drop the bytes <-> frames conversions in callbacks.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: es1938: Convert to the new PCM copy ops
Takashi Iwai [Wed, 10 May 2017 18:16:36 +0000 (20:16 +0200)]
ALSA: es1938: Convert to the new PCM copy ops

Replace the copy ops with the new copy_user and copy_kernel ops.
It's used only for a capture stream (for some hardware workaround),
thus we need no silence operation.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: dummy: Convert to new PCM copy ops
Takashi Iwai [Wed, 10 May 2017 18:15:40 +0000 (20:15 +0200)]
ALSA: dummy: Convert to new PCM copy ops

It's a dummy ops, so just replacing it.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: Introduce copy_user, copy_kernel and fill_silence ops
Takashi Iwai [Wed, 10 May 2017 18:02:35 +0000 (20:02 +0200)]
ALSA: pcm: Introduce copy_user, copy_kernel and fill_silence ops

For supporting the explicit in-kernel copy of PCM buffer data, and
also for further code refactoring, three new PCM ops, copy_user,
copy_kernel and fill_silence, are introduced.  The old copy and
silence ops will be deprecated and removed later once when all callers
are converted.

The copy_kernel ops is the new one, and it's supposed to transfer the
PCM data from the given kernel buffer to the hardware ring-buffer (or
vice-versa depending on the stream direction), while the copy_user ops
is equivalent with the former copy ops, to transfer the data from the
user-space buffer.

The major difference of the new copy_* and fill_silence ops from the
previous ops is that the new ops take bytes instead of frames for size
and position arguments.  It has two merits: first, it allows the
callback implementation often simpler (just call directly memcpy() &
co), and second, it may unify the implementations of both interleaved
and non-interleaved cases, as we'll see in the later patch.

As of this stage, copy_kernel ops isn't referred yet, but only
copy_user is used.

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: hda - Fix applying MSI dual-codec mobo quirk
Takashi Iwai [Thu, 1 Jun 2017 07:35:30 +0000 (09:35 +0200)]
ALSA: hda - Fix applying MSI dual-codec mobo quirk

The previous commit [63691587f7b0: ALSA: hda - Apply dual-codec quirk
for MSI Z270-Gaming mobo] attempted to apply the existing dual-codec
quirk for a MSI mobo.  But it turned out that this isn't applied
properly due to the MSI-vendor quirk before this entry.  I overlooked
such two MSI entries just because they were put in the wrong position,
although we have a list ordered by PCI SSID numbers.

This patch fixes it by rearranging the unordered entries.

Fixes: 63691587f7b0 ("ALSA: hda - Apply dual-codec quirk for MSI Z270-Gaming mobo")
Reported-by: Rudolf Schmidt <info@rudolfschmidt.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: usb: Avoid VLA in mixer_us16x08.c
Takashi Iwai [Tue, 30 May 2017 21:24:45 +0000 (23:24 +0200)]
ALSA: usb: Avoid VLA in mixer_us16x08.c

This is another attempt to work around the VLA used in
mixer_us16x08.c.  Basically the temporary array is used individually
for two cases, and we can declare locally in each block, instead of
hackish max() usage.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: usb: Fix a typo in Tascam US-16x08 mixer element
Takashi Iwai [Tue, 30 May 2017 21:21:07 +0000 (23:21 +0200)]
ALSA: usb: Fix a typo in Tascam US-16x08 mixer element

A mixer element created in a quirk for Tascam US-16x08 contains a
typo: it should be "EQ MidLow Q" instead of "EQ MidQLow Q".

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195875
Fixes: d2bb390a2081 ("ALSA: usb-audio: Tascam US-16x08 DSP mixer quirk")
Cc: <stable@vger.kernel.org> # v4.11+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoRevert "ALSA: usb-audio: purge needless variable length array"
Takashi Iwai [Tue, 30 May 2017 07:23:41 +0000 (09:23 +0200)]
Revert "ALSA: usb-audio: purge needless variable length array"

This reverts commit 89b593c30e83 ("ALSA: usb-audio: purge needless
variable length array").  The patch turned out to cause a severe
regression, triggering an Oops at snd_usb_ctl_msg().  It was overseen
that snd_usb_ctl_msg() writes back the response to the given buffer,
while the patch changed it to a read-only const buffer.  (One should
always double-check when an extra pointer cast is present...)

As a simple fix, just revert the affected commit.  It was merely a
cleanup.  Although it brings VLA again, it's clearer as a fix.  We'll
address the VLA later in another patch.

Fixes: 89b593c30e83 ("ALSA: usb-audio: purge needless variable length array")
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195875
Cc: <stable@vger.kernel.org> # v4.11+
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: pcm: include pcm_local.h and remove some extraneous tabs
Colin Ian King [Tue, 30 May 2017 10:39:45 +0000 (11:39 +0100)]
ALSA: pcm: include pcm_local.h and remove some extraneous tabs

We need to include pcm_local.h to clean up some smatch warnings:

symbol 'snd_pcm_timer_done' was not declared. Should it be static?
symbol 'snd_pcm_timer_init' was not declared. Should it be static?
symbol 'snd_pcm_timer_resolution_change' was not declared. Should
  it be static?

Also remove some extraneous tabs on empty lines and replace space
intentation with a tab.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoALSA: declare snd_kcontrol_new structures as const
Bhumika Goyal [Sat, 27 May 2017 14:46:15 +0000 (20:16 +0530)]
ALSA: declare snd_kcontrol_new structures as const

Declare snd_kcontrol_new structures as const as they are only passed 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.
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;

Cross compiled these files:
sound/aoa/codecs/tas.c - powerpc
sound/mips/{hal2.c/sgio2audio.c} - mips
sound/ppc/{awacs.c/beep.c/tumbler.c} - powerpc
sound/soc/sh/siu_dai.c - sh
Could not find an architecture to compile sound/sh/aica.c.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Acked-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
7 years agoMerge remote-tracking branch 'asoc/fix/rt286' into asoc-linus
Mark Brown [Fri, 26 May 2017 11:42:28 +0000 (12:42 +0100)]
Merge remote-tracking branch 'asoc/fix/rt286' into asoc-linus

7 years agoMerge remote-tracking branches 'asoc/fix/atmel', 'asoc/fix/cirrus', 'asoc/fix/da7213...
Mark Brown [Fri, 26 May 2017 11:42:25 +0000 (12:42 +0100)]
Merge remote-tracking branches 'asoc/fix/atmel', 'asoc/fix/cirrus', 'asoc/fix/da7213', 'asoc/fix/free' and 'asoc/fix/jack' into asoc-linus

7 years agoMerge remote-tracking branch 'asoc/fix/rcar' into asoc-linus
Mark Brown [Fri, 26 May 2017 11:42:24 +0000 (12:42 +0100)]
Merge remote-tracking branch 'asoc/fix/rcar' into asoc-linus

7 years agoMerge remote-tracking branch 'asoc/fix/intel' into asoc-linus
Mark Brown [Fri, 26 May 2017 11:42:24 +0000 (12:42 +0100)]
Merge remote-tracking branch 'asoc/fix/intel' into asoc-linus

7 years agoASoC: rsnd: fixup parent_clk_name of AUDIO_CLKOUTx
Kuninori Morimoto [Fri, 26 May 2017 01:44:19 +0000 (01:44 +0000)]
ASoC: rsnd: fixup parent_clk_name of AUDIO_CLKOUTx

commit 25165f79adc7 ("ASoC: rsnd: enable clock-frequency for both
44.1kHz/48kHz") supported both 44.1kHz/48kHz for AUDIO_CLKOUTx,
but it didn't care its parent clock name.
This patch fixes it.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Signed-off-by: Mark Brown <broonie@kernel.org>