Commit graph

60 commits

Author SHA1 Message Date
Lu Guanqun
e1bfee2673 intel_sst: set default output and input device
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:59:01 -07:00
Chandramouli Narayanan
231c63839f intel_sst: fix runtime pm issue
Use correct api for enabling/disabling runtime pm.  Additionally,
fix runtime suspend/resume to not duplicate pci core functions

Signed-off-by: Chandramouli Narayanan <chandramouli.narayanan@intel.com>
Tested-by: Kristen Carlson Accardi <kristen@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:59:00 -07:00
Andy CH Lin
5dda7f27c1 intel_sst: intelmid_v2_control: correct jack event type
Correct event type of audio jack while receiving long press event.

Signed-off-by: Andy CH Lin <andy_ch_lin@wistron.com>
Signed-off-by: Jekyll Lai <jekyll_lai@wistron.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:44 -07:00
Wu Fengguang
a482050294 intel_sst: MRST can only do 16bit recording
Fix bug

	$ arecord -D dsnoop -r 48000 -f S16_LE 1.wav
	ALSA lib pcm_direct.c:980:(snd1_pcm_direct_initialize_slave) unable to install hw params
	ALSA lib pcm_dsnoop.c:604:(snd_pcm_dsnoop_open) unable to initialize slave
	arecord: main:654: audio open error: Interrupted system call

Root cause is, the driver is reporting 32-bit capture capability
that is not supported by the MRST hardware. So the dsnoop plugin
end up requesting 32-bit capture which fails.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:43 -07:00
Wu Fengguang
3ca13bdb3c intel_sst: MRST can only do mono recording
Fix bug

	$ arecord -Dplughw -c2
	Recording WAVE 'stdin' : Unsigned 8 bit, Rate 8000 Hz, Stereo
	arecord: set_params:1116: Unable to install hw params:
	ACCESS:  RW_INTERLEAVED
	FORMAT:  U8
	SUBFORMAT:  STD
	SAMPLE_BITS: 8
	FRAME_BITS: 16
	CHANNELS: 2
	[...]

Root cause is, the driver is reporting 2-channel capture capability
that is not supported by the MRST hardware. So the plughw plugin
end up requesting 2-channel capture which fails.

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:43 -07:00
Feng Tang
f2b5ea1feb intel_sst: make sure the sst_drop_stream() get called when needed
When "aplay test.wav", if we "ctrl+z" to suspend it, the last piece of
sound will be played endlessly. So we need make sure the drop_stream
is called in such a case.

Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:42 -07:00
Lu Guanqun
e51a34f3e8 intel_sst: return correct output/input device id
Without this patch, the change of output/input device can't be reflected
correctly. The mismatch reflects insane design, and should be fixed when
switching to the ASoC framework.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Acked-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:28 -07:00
Lu Guanqun
24298b0e66 intel_sst: move jack detection related configs to init time
The old policy will not enable MIC2BIAS on Moorstown platform
by default, it's only enabled when the user selects HS_MIC as input source.
Therefore when user selects DMIC and then inserts the jack,
no interrupt will be generated to notify the driver about the
jack insertion event and to take action to auto mute the speaker.

The new policy will enable this bit by default,
then no matter what the output device is, an interrupt will be generated.

This behaviour is more likely what a user expects.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Reviewed-by: Wu Fengguang <fengguang.wu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:28 -07:00
xingchao
59bd2abe07 intel_sst: Headphone Automute support
When detected a Jack event, Audio sound routes between internal speaker
and headphone/headset automatically.

Signed-off-by: xingchao <xingchao.wang@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:27 -07:00
Lu Guanqun
26d3b2d973 intel_sst: Enable recording via DMIC
We may need to make some of this board specific eventually

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:27 -07:00
Lu Guanqun
9d9bb3c3fb intel_sst: Enable recording via HS_MIC
We may need to make some of this board specific eventually.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:26 -07:00
Lu Guanqun
cd573917c3 intel_sst: Set de-bounce time
In order to make jack detection behave properly, we have to set
the de-bounce time, otherwise, some weird events happens:
e.g. no plug-out event seen.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:26 -07:00
Ramesh Babu K V
8a251ff2fc intel_sst: rework jack implementation
This patch fixes the below issues w.r.t jack implementation

a) The current jack implementation in driver is implemented
   in intelmid.c. It has moved to vendor files for better managebility
b) Cleaned up jack reporting per upstream comments
c) Implemented jack for msic, added code to read adc and deduce jack
   type based on mic bias
d) Support detection of american headset

Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
[Corrections]
Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:58:09 -07:00
Sitanshu Nanavati
eb02c700d2 intel_sst: DMIC routing
This patch adds support for configuring and routing the
DMICs (assigned HW route to DMICs)

Signed-off-by: Sitanshu Nanavati <sitanshu.nanavati@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:56 -07:00
Vinod Koul
2784a80c97 intel_sst: parameter tuning ioctl
This patch adds new IOCTL for application interface.

Using parameter tuning IOCTL, application can fine
tune the audio firmware for it's requirement.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:55 -07:00
Dharageswari R
5572a44829 intel_sst: Line out support
This patch adds the support for lineout. The
lineout input can be selected as any input channel
by using a new alsa mixer kcontrol.

Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:54 -07:00
Vinod Koul
c3e25a24b5 intel_sst: ignore IRQ when suspended
The irq for audio is shared, so when device is supended driver should
not the read register and ignore the interrupt.

This patch ignores interrupts when device is suspended.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:54 -07:00
Vinod Koul
1bea302c2f intel_sst: fix unload bugs
The current driver remove was erroneous and causes
errors when unloading or loading second time

This patch fixes both of these issues

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:53 -07:00
Vinod Koul
b06a584c21 intel_sst: MSIC codec power optimisation
This patch adds power optimization for the msic codec and ensure
codec is completely powered off when codec is idle.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:55:52 -07:00
Lu Guanqun
6c550053cb sst: fix compile error
Add several include files to fix the below compile error.

drivers/staging/intel_sst/intelmid.c: In function ‘snd_intelmad_sst_register’:
drivers/staging/intel_sst/intelmid.c:805:2: error: ‘sst_drv_ctx’ undeclared (first use in this function)
drivers/staging/intel_sst/intelmid.c:805:2: note: each undeclared identifier is reported only once for each function it appears in

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:54:44 -07:00
Vinod Koul
afe9194d58 intel_sst: Save audio state across D3 on Medfield
During suspend and runtime_suspend audio dsp will be in D3 state
and will loose its context.

This patch adds support in driver to save the dsp context
and restore this context during resume

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Ramesh Babu K V <ramesh.babu@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:52:10 -07:00
Lu Guanqun
31dea73851 sst: make register_sst_card more self-contained
register_sst_card is used in ASoC code with field `scard_ops` being NULL.
Without this patch, there will be NULL dereference.

Signed-off-by: Lu Guanqun <guanqun.lu@intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-05-10 12:51:58 -07:00
Joe Perches
9fc86028fa staging: Remove unnecessary semicolons when if (foo) {...};
Done via perl script:

$ cat remove_semi_if.pl
my $match_balanced_parentheses = qr/(\((?:[^\(\)]++|(?-1))*\))/;
my $match_balanced_braces      = qr/(\{(?:[^\{\}]++|(?-1))*\})/;

foreach my $file (@ARGV) {
    my $f;
    my $text;
    my $oldtext;

    next if ((-d $file));

    open($f, '<', $file)
	or die "$P: Can't open $file for read\n";
    $oldtext = do { local($/) ; <$f> };
    close($f);

    next if ($oldtext eq "");

    $text = $oldtext;

    my $count = 0;
    do {
	$count = 0;
	$count += $text =~ s@\b(if\s*${match_balanced_parentheses}\s*)${match_balanced_braces}\s*;@"$1$3"@egx;
    } while ($count > 0);

    if ($text ne $oldtext) {
	my $newfile = $file;

	open($f, '>', $newfile)
	    or die "$P: Can't open $newfile for write\n";
	print $f $text;
	close($f);
    }
}

$

Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-04-25 16:58:34 -07:00
Julia Lawall
48c59f4b91 drivers/staging/intel_sst/intel_sst_app_interface.c: introduce missing kfree
Stream_bufs is initialized at the beginning of the function, and then the
#ifdef code declares a new variable with the same name and initializes
that.  If the if in the ifdef is taken, the then branch returns, implying
that the first stream_bufs is never used and is leaked.  The first
initialization is thus moved down after the ifdef.

The semantic match that finds the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
statement S;
expression E;
identifier f,f1,l;
position p1,p2;
expression *ptr != NULL;
@@

x@p1 = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...x...+> }
(
x->f1 = E
|
 (x->f1 == NULL || ...)
|
 f(...,x->f1,...)
)
...>
(
 return \(0\|<+...x...+>\|ptr\);
|
 return@p2 ...;
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

print "* file: %s kmalloc %s return %s" % (p1[0].file,p1[0].line,p2[0].line)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-04-20 14:11:45 -07:00
Lucas De Marchi
25985edced Fix common misspellings
Fixes generated by 'codespell' and manually reviewed.

Signed-off-by: Lucas De Marchi <lucas.demarchi@profusion.mobi>
2011-03-31 11:26:23 -03:00
Uwe Kleine-König
3173a5ecd8 staging/trivial: fix typos concerning "select"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-02-18 13:30:12 -08:00
Uwe Kleine-König
d9fed669ac staging/trivial: fix typos concerning "initiali[zs]e"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-02-18 13:30:11 -08:00
Uwe Kleine-König
1bf8240c07 staging/trivial: fix typos concerning "function"
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-02-18 13:30:10 -08:00
Harsha Priya
454f1419f1 staging: sst: Fix for dmic capture on v2 pmic
currently capture through dmic captures only silence

This patch configurs the dmic registers to capture properly

Signed-off-by: Harsha Priya <priya.harsha@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-02-02 15:06:14 -08:00
Greg Kroah-Hartman
ea3398a1ae Staging: Merge 2.6.37-rc5 into staging-next
This was done to handle a number of conflicts in the batman-adv
and winbond drivers properly.  It also now allows us to fix up the sysfs
attributes properly that were not in the .37 release due to them being
only in this tree at the time.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-12-07 10:47:56 -08:00
Randy Dunlap
8956110dbb staging: fix intel_sst/intelmid sound build
SND_INTELMID selects 3 SND_* kconfig symbols, but that is useless
if the SOUND & SND symbols in their hierarchy are not enabled,
so make this symbol depend on SOUND & SND.

ERROR: "snd_pcm_period_elapsed" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_card_create" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_hw_constraint_integer" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_device_new" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_set_ops" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_jack_new" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_lib_free_pages" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_lib_ioctl" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_lib_malloc_pages" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_ctl_new1" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_lib_preallocate_pages_for_all" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_card_free" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_card_register" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_jack_report" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_pcm_new" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!
ERROR: "snd_ctl_add" [drivers/staging/intel_sst/snd-intelmid.ko] undefined!

Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-29 11:38:50 -08:00
Vinod Koul
62877913ba Staging: sst: add ioctls for post processing algorithm interface
This patch adds two new ioctls to intel_sst_ctrl device.
This i/f can be used by application to send algorithm parameters

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
[This will need further discussion in the context of the final ALSA interface
 but is fine for staging, ie anyone who relies on it should expect changes
 Also fixed a missing kmalloc fail check]
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-29 11:14:05 -08:00
Vinod Koul
79a35ad573 Staging: sst: Construct fw string name runtime
The firmware name for each platform is appended by PCI id of device.
This patch makes use of pci id to construct the string rather than
hardcode the string.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-29 11:13:55 -08:00
Vinod Koul
964c6975e8 Staging: sst: Add runtime PM support
This adds runtime PM support for audio driver.
This also fixes LPA audio mode for moorestown platform

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-29 11:13:32 -08:00
Greg Kroah-Hartman
8d7ee9c498 Merge branch 'master' into work 2010-11-29 10:44:22 -08:00
Vinod Koul
b21bded7c0 sst: log error returned by scu ipc read/write
scu ipc driver fails sometimes to read/write. This add logs with register
addr and ret code when these errors occur.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-19 17:44:07 -08:00
Vinod Koul
90abe60b32 sst: Firmware error codes force number values
To avoid mismatch in driver and firmware error codes assign specfic values
to each enum.

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-19 17:44:07 -08:00
Vinod Koul
6f6ffec188 sst: Change the SST driver PCM interface
The PCM interface in SST driver is cmds only, this patch changes the interface to open, close and cmd interface.
This allows SST driver to keep easy track of handles open

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-19 17:43:47 -08:00
Vinod Koul
24aee93c37 sst: remove rest of aava bits and aava related code
This removes the remaining bit of aava dependent and related bits from driver

Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-17 13:16:34 -08:00
Arnd Bergmann
451a3c24b0 BKL: remove extraneous #include <smp_lock.h>
The big kernel lock has been removed from all these files at some point,
leaving only the #include.

Remove this too as a cleanup.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-11-17 08:59:32 -08:00
Dan Carpenter
3251627c94 Staging: intel_sst: fix memory leak
The original code set "str_info->decode_ibuf" to NULL so the kfree() is
no-op.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Harsha Priya <priya.harsha@intel.com>
Acked-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-16 12:25:53 -08:00
Joe Perches
859171ca92 drivers/staging: Remove unnecessary semicolons
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-16 12:06:47 -08:00
Greg Kroah-Hartman
491acf0032 Staging: Merge 2.6.37-rc2 into staging-next
This was necessary in order  to resolve some conflicts that happened
between -rc1 and -rc2 with the following files:
	drivers/staging/bcm/Bcmchar.c
	drivers/staging/intel_sst/intel_sst_app_interface.c

All should be resolved now.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-16 10:44:50 -08:00
Joe Perches
d0f40c5041 Staging: intel_sst: Use pr_fmt, fix misspellings
Remove leading "sst: " from format strings.
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Prefix is changed from "sst: " to "snd_intel_sst: "
Add missing newlines
Trim trailing spaces after newlines
Fix several different misspellings

Signed-off-by: Joe Perches <joe@perches.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 15:14:38 -08:00
Dan Carpenter
4fc718a4b0 Staging: sst: add some __user anotations
This silences all the sparse warnings in intel_sst_app_interface.c.
It was just a matter of adding __user annotations, I didn't find any
real bugs here.  Quite a few of these were needed for stuff I added
earlier, sorry about that.

I removed a couple casts to (void *) that caused a warning like:
	drivers/staging/intel_sst/intel_sst_app_interface.c:606:27:
		warning: cast removes address space of expression
For example sst_drv_ctx->mailbox is already declared as
"void __iomem *mailbox" so casting it to void pointer isn't necessary
and it makes sparse complain because it removes the __user attribute.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 13:31:49 -08:00
Dan Carpenter
08da782b1a Staging: sst: user pointers in intel_sst_mmap_play_capture()
There were some places in intel_sst_mmap_play_capture() that
dereferenced user pointers instead of copying the data to the kernel.

I removed the BUG_ON(!mmap_buf) and BUG_ON(!buf_entry) since those are
never possible in the current code.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Cc: Vinod Koul <vinod.koul@intel.com>
Cc: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 13:31:48 -08:00
Dan Carpenter
e9f25689a8 Staging: sst: fixups in SNDRV_SST_STREAM_DECODE
This is another patch about copying data to the kernel before using it.

SNDRV_SST_STREAM_DECODE is sort of tricky because we need to do a
copy_from_user() that gives us another two pointers and we have copy
those.  Those again give us some more pointers that we have to copy.

Besides those problems, the code had a stack overflow:
-	struct snd_sst_buff_entry ibuf_temp[param->ibufs->entries],
-		obuf_temp[param->obufs->entries];
param->ibufs->entries comes from the user.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 13:30:49 -08:00
Dan Carpenter
bc704e31ed Staging: sst: more dereferencing user pointers
This is another patch about making a copy of the data into kernel space
before using it.  It is easy to trigger a kernel oops in the original
code.  If you passed a NULL to SNDRV_SST_SET_TARGET_DEVICE then it
called BUG_ON().  And SNDRV_SST_DRIVER_INFO would let you write the
information to arbitrary memory locations which is a security violation.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 13:30:48 -08:00
Dan Carpenter
3b97eed201 Staging: sst: dereferencing user pointers
This code dereferences user supplied pointers directly instead of doing
a copy_from_user().  Some kernel configs put user and kernel memory in
different address spaces so this code isn't portable.  Also the user
memory could be swapped out or in this case the pointer could just be
NULL leading to an oops.

Another thing is that it makes permission tests like this sort of
meaningless.
	if (minor == STREAM_MODULE && rec_mute->stream_id == 0) {
		retval = -EPERM;
		break;
	}
The user could set stream_id to 1 for the test and then change it later.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-11-09 13:30:48 -08:00
Dan Carpenter
388b2b97ba Staging: sst: more copy_to_user() changes
Vinod wanted the copy_to_user() calls in this format:
	if (copy_to_user())
		retval = -EFAULT;
instead of this:
	retval = copy_to_user();
	if (retval)
		retval = -EFAULt;

I've done that for the whole intel_sst_app_interface.c file.  In the
process I noticed a couple more places that returned -EBUSY or -EAGAIN
instead of -EFAULT.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2010-10-15 15:42:26 -07:00