ALSA: pcm - add support for hostless audio

Allow some PCM devices to be hostless, i.e. there is no PCM data transferred
to or from the host CPU. This can be used to minimise power on systems since
the CPU can idle/sleep during the PCM device operation (e.g. a phone call
where the DAI is between a MODEM and DSP)

TODO: cleanup, look at adding a read/write blocker.

Change-Id: I36f521a77f4426d38713739e4313b99c6f506089
Singed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
ALSA: pcm - reject calls to open backend PCMs (temporary)

This stops userspace opening backlemd PCMs.

TODO: rework for upstream.

Change-Id: I579dcbf608cb30561dbb9fe7cb709190d3068111
Signed-off-by: Liam Girdwood <lrg@ti.com>
ALSA: pcm - Export snd_pcm_lib_default_mmap() helper

Export the default mmap function, snd_pcm_lib_default_mmap().
The upcoming non-snooping support in HD-audio driver will use this
to override the mmap method.

Change-Id: I9e93bb240dfc3302f26c86e0b072abf38186d913
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: pcm - remove the dead code from snd_pcm_open_file()

The rpcm_file parameter is never used in current ALSA code, so remove
it to make it cleaner.

Change-Id: Iae08c17a22b865d38fb8a24803ad2e48de0bf457
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound: Add module.h to the previously silent sound users

Lots of sound drivers were getting module.h via the implicit presence
of it in <linux/device.h> but we are going to clean that up.  So
fix up those users now.

Change-Id: I5cc8cd4356f6217a91155c2dec2df575747ba623
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
ALSA: core: Add support to handle compressed audio IOCTLs

This is needed to support the compressed audio till the
compressed core is done with development.

Change-Id: Ida1dff0d6952241809ea23b6b9de6e07c71305bb
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
ALSA: pcm - Avoid GFP_ATOMIC in snd_pcm_link()

GFP_ATOMIC is used in snd_pcm_link() just because the kmalloc is
called inside a lock.  Since this function isn't too critical for
speed and is rarely called in practice, better to allocate the chunk
at first before spinlock and free it in error paths, so that
GFP_KERNEL can be used.

Change-Id: I3d9d27db884150fe612c860aec0fb54892a443d7
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: core: Add support to handle compressed audio IOCTLs for capture

This is needed to support the compressed audio capture so that the
IOCTL commands for capture can pass to the ALSA SOC audio driver

Change-Id: I78c796275946e6e02f61aeab6579f3e9362f208b
Signed-off-by: Subhash Chandra Bose Naripeddy <snariped@codeaurora.org>
ALSA: PCM: Fix some races at disconnection

commit 9b0573c07f278e9888c352aa9724035c75784ea0 upstream.

Fix races at PCM disconnection:
- while a PCM device is being opened or closed
- while the PCM state is being changed without lock in prepare,
  hw_params, hw_free ops

Change-Id: Ie2d8ffeeb507b15e4214385eafd2a945ee393cd8
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ALSA: core: add support for compress_offload

This patch adds core.c, the file which implements the ioctls and
registers the devices

Change-Id: I7c31f7bc9b56ef117f01ef50661d7d0ac5988ada
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: Fix memory leak on error in snd_compr_set_params()

If copy_from_user() does not return 0 we'll leak the memory we
allocated for 'params' when that variable goes out of scope.

Also a small CodingStyle cleanup: Use braces on both branches of
if/else when one branch needs it.

Change-Id: If27c4802cd2a8f7aa456ea9df42966846abaf96a
Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
ALSA: Add a reference counter to card instance

commit a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85 upstream.

For more strict protection for wild disconnections, a refcount is
introduced to the card instance, and let it up/down when an object is
referred via snd_lookup_*() in the open ops.

The free-after-last-close check is also changed to check this refcount
instead of the empty list, too.

Change-Id: I07c1145df28f0e7b51491c4c2e2d881ea5872707
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ALSA: Avoid endless sleep after disconnect

commit 0914f7961babbf28aaa2f19b453951fb4841c03f upstream.

When disconnect callback is called, each component should wake up
sleepers and check card->shutdown flag for avoiding the endless sleep
blocking the proper resource release.

Change-Id: I69a42da9e46e9b3659558e0b90d0aec9ce7904c9
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ALSA: Fix card refcount unbalance

commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f upstream.

There are uncovered cases whether the card refcount introduced by the
commit a0830dbd isn't properly increased or decreased:
- OSS PCM and mixer success paths
- When lookup function gets NULL

This patch fixes these places.

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

Change-Id: I2ad443e03838bb572064a5dc9fdf39e7fb8b2dd0
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
ALSA: core: add compress parameter definations

The patch adds the various definations used to define the encoder
and decoder parameters

Change-Id: Iac1f483b40c05a4b3ad75936fb44f94150ae0488
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
headers: include linux/types.h where appropriate

This addresses some header check warnings.  DRM headers which include
"drm.h" have been excluded, as they indirectly include types.h.

Change-Id: I087dd4a2230ad15a5484eff4a51f4dfe9346f559
Signed-off-by: Bobby Powers <bobbypowers@gmail.com>
Cc: Chris Ball <cjb@laptop.org>
Cc: Dave Airlie <airlied@linux.ie>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
compress: add API header and driver header files

This patch adds the header files for ioctl definations and header file for
driver APIs for lower level device drivers to use

Change-Id: I9d35b1a34aab0aaee8f8b3cd3d9fad1c2d633158
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
compress: add compress parameter definations

The patch adds the various definations used to define the encoder and decoder
parameters

Change-Id: Iaf4cced5e4a89ecb92337e2f9cf45b62c23945e7
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
compress: add the core file

This patch ads core.c, the file which implements the ioctls and
registers the devices

Change-Id: I30a1d8b561ecd15b6a862d6948368394edd49665
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>
Fixes for 1. fixes for comments recieved on alsa-devel

2. cosmetic edits
	s/period/fragment
	corrected comments
	fixed parameters and descriptors
3. More cosmetic edits and checkpatch fixes

Squash the commits

Change-Id: I6c849673d58e8c8314c0d1e48f55c7660dcca54c
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Signed-off-by: Asish Bhattacharya <asishb@codeaurora.org>