Commit graph

35 commits

Author SHA1 Message Date
Takashi Iwai
8ae3124b8f ALSA: hda/ca0132 - Fix possible invalid DMA channel deallocation
... in the error path in dspxfr_image().

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:49:38 +01:00
Takashi Iwai
549e8292a1 ALSA: hda/ca0132 - Fix possible NULL dereference
Spotted by smatch,
  sound/pci/hda/patch_ca0132.c:1950 dspxfr_image() error: potential
  null dereference 'dma_engine'.  (kzalloc returns null)
  sound/pci/hda/patch_ca0132.c:1950 dspxfr_image() error: we
  previously assumed 'dma_engine' could be null (see line 1857)

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:42:15 +01:00
Takashi Iwai
425a7880e8 ALSA: hda/ca0132 - Fix another smatch warning
sound/pci/hda/patch_ca0132.c:1781 dspxfr_one_seg() info: why not
propagate 'status' from dsp_dma_stop() instead of (-5)?

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:41:21 +01:00
Takashi Iwai
b645d79619 ALSA: hda/ca0132 - Fix superfluous unsigned check
Fix a warning by smatch,
 sound/pci/hda/patch_ca0132.c:714 dspio_send() warn: always true
 condition '(res >= 0) => (0-u32max >= 0)'

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:39:29 +01:00
Takashi Iwai
a0c041cb6f ALSA: hda/ca0132 - Use snd_hda_set_pin_ctl() helper again
The recent update of ca0132 driver replaced the pinctl setup to the
direct write via snd_hda_codec_write() again.  This should be covered
by snd_hda_set_pin_ctl() to be safer.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:13:31 +01:00
Takashi Iwai
15e4ba666c Revert "ALSA: hda - Add firmware caching to CA0132 codec"
This reverts commit c3b4eea262.

Since the recent firmware loader code supports caching at S3/S4 by
itself, we don't have to handle f/w caching in the driver.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:09:27 +01:00
Ian Minett
406261ce99 ALSA: hda/ca0132: Fix potential init errors and update module description
Handle a potential dma_engine alloc error and fix the possible use of an
uninitialized status variable in dspxfr_one_seg(). Also correct the initial
sampling rate for Mic 1.
Update the module description.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:01:16 +01:00
Ian Minett
441aa6a016 ALSA: hda/ca0132: Shuffle to group together related code
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:01:01 +01:00
Ian Minett
e90f29e442 ALSA: hda/ca0132: Code shuffle to group similar functions.
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:00:45 +01:00
Ian Minett
44f0c9782c ALSA: hda/ca0132: Add tuning controls
This patch adds the controls used for tuning the DSP effects.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 17:00:31 +01:00
Ian Minett
a73d511c48 ALSA: hda/ca0132: Add unsol handler for DSP and jack detection
This patch adds the unsolicited response handler for incoming DSP responses and
jack detection reporting, and routines for reading the incoming DSP response.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 16:59:56 +01:00
Ian Minett
825315bc5b ALSA: hda/ca0132: Add PCM enhancements
Remove the playback PCM open callback.
PCM stream setup and cleanup functions are added for use by PCM callbacks.
Delay stream cleanup if effects are on, to allow time for any effects tail to
finish.
Add the analog capture PCM callbacks.
Change the max channels of analog playback to 6.
Add two new PCMs: AMic2 and What-U-Hear.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 16:59:21 +01:00
Ian Minett
a7e76271bd ALSA: hda/ca0132: Add DSP mixer controls and helpers
This patch adds the kcontrols for the DSP effects, playback and recording
source selection.
ca0132_is_vnode_effective() checks whether virtual node settings have
taken effect.
The control change helpers ca0132_pe_switch_set(), ca0132_voicefx_set()
and ca0132_cvoice_switch_set() are added to toggle playback / capture
DSP effects, ca0132_voicefx_info(), _get() and _put() are added for
input path DSP effect value access. The volume helpers are updated to
volume_info(), _get() and _set() to use the virtual nodes.
The redundant headphone and speaker switches and ct_extension function
are removed.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 16:58:12 +01:00
Ian Minett
5aaca44d8d ALSA: hda/ca0132: Init chip, DSP effects and mixer settings
This patch adds the framework to set effect parameters: ca0132_effects_set()
and ca0132_setup_defaults() are general functions for parameter setting and
initializing to default values. dspio_set_param() and dspio_set_uint_param()
are lower-level fns to simplify setting individual DSP parameters via an
SCP buffer transfer to the firmware.
The CA0132 chip parameter init code is added in ca0132_init_params().
In chipio_[write,read]_data(), the current chip address is auto-incremented
if no error has occurred.
ca0132_select_out() selects the current output. If autodetect is enabled,
use headphones (if jack detected) or speakers (if no jack).
ca0132_select_mic() selects the current mic in. If autodetect is enabled,
use exterior mic (if jack detected) or built-in mic (if no jack).
Init digital mic and switch between dmic and amic with ca0132_init_dmic(),
ca0132_set_dmic(). amic2 is initialized in ca0132_init_analog_mic2().
Finally, add verb tables for configuring DSP firmware.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 16:57:56 +01:00
Ian Minett
ef6b2eada3 ALSA: hda/ca0132: Add new definitions and structs for DSP
This patch adds definitions and structs used for configuring DSP effects,
virtual nodes, effect tuning controls, and mixer control helpers.
The effect structs are also initialized.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2013-01-15 16:57:42 +01:00
Takashi Iwai
cdc83c59e5 ALSA: hda - Remove superfluous zero-clear memset in patch_ca0132.c
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:32 +01:00
Takashi Iwai
063bca0968 ALSA: hda - Fix NULL dereference in error path of patch_ca0132.c
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:29 +01:00
Ian Minett
e97249dd6d ALSA: hda - Remove unnecessary struct hda_stream_format from CA0132
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:26 +01:00
Ian Minett
4861af8075 ALSA: hda - Update chipio functions and DSP write wait timeout
Tidy up and condense chipio_write_address|addx() functions.
Improve dspio_write_wait() to use jiffies for timeout calc.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:23 +01:00
Ian Minett
d5c21b88e8 ALSA: hda - Add comments and descriptions to CA0132 functions
Add comments and descriptions to functions.
Bump dsp_free_ports() to below dsp_allocate_ports_format() to group the
alloc functions together for commenting.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:18 +01:00
Ian Minett
c3b4eea262 ALSA: hda - Add firmware caching to CA0132 codec
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:15 +01:00
Ian Minett
01ef7dbffb ALSA: hda - Update CA0132 codec to load DSP firmware binary
This patch adds the code needed to fetch the DSP binary image from the local
firmware install location and transfer it over to the chip using the new DSP
loader bus ops.
Actual DSP effect controls, parameters and mixers are to be included later.

- Add calls to new DSP loader system to transfer firmware to the hardware.
- Add chip read/write routines, DSP I/O, SCP packet format helper functions and
  transfer DMA management.
- Add guard around DSP download to ensure loader config switch is enabled.

The general scheme for downloading the DSP is as follows:
1) If DSP firmware loader is enabled, ca0132_download_dsp() is called
to start the process.
2) Driver requests DSP image using request_firmware().
3) Driver sets up the streaming DMA for DSP image download
with dspload_image() and dspxfr_image(), which in turn calls the DSP loader
op snd_hda_codec_load_dsp_prepare() to ready the system.
4) DSP image will consist of 1 or more segments, each transferred in sequence
by a call to dspxfr_one_seg() and snd_hda_codec_load_dsp_trigger().
5) Once complete, the loader state is cleaned up with
snd_hda_codec_load_dsp_cleanup().

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:12 +01:00
Ian Minett
4aa3bb0c52 ALSA: hda - Add DSP firmware enums and defs to CA0132 codec
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:09 +01:00
Ian Minett
bcd109c086 ALSA: hda - Add CA0132 register definitions file
Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-11-28 08:47:06 +01:00
David Henningsson
c41999a239 ALSA: hda - don't create dysfunctional mixer controls for ca0132
It's possible that these amps are settable somehow, e g through
secret codec verbs, but for now, don't create the controls (as
they won't be working anyway, and cause errors in amixer).

Cc: stable@kernel.org
BugLink: https://bugs.launchpad.net/bugs/1038651
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-08-20 11:33:23 +02:00
Takashi Iwai
8e13fc1c5f ALSA: hda - Add missing SPDIF I/O setup for CA0132
CA0132 driver had some codes to handle the S/PDIF I/O, but the actual
setups of pins and converters were missing.  Now the pins are added.

Also, fixed a few points triggering invalid codec verbs and mixer
elements since the digital I/O audio widgets on CA0132 have no amp.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-08-08 17:27:50 +02:00
Takashi Iwai
27ebeb0b1b ALSA: hda - Use the standard PCM ops for CA0132
Now with the workaround using codec->pcm_format_first flag, we can
clean up the home-baked codes in patch_ca0132.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-08-08 17:25:02 +02:00
Takashi Iwai
55cf87fe0e ALSA: hda - Fix superfluous "-in" suffix from CA0132 capture items
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-08-08 17:15:55 +02:00
Takashi Iwai
128bc4ba8c ALSA: hda - Move BIOS pin-parser code to hda_auto_parser.c
Just code shuffles.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-05-08 18:01:33 +02:00
Takashi Iwai
4740860b53 ALSA: hda - Add snd_hda_get_default_vref() helper function
Add a new helper function to guess the default VREF pin control bits
for mic in.  This can be used to set the pin control value safely
matching with the actual pin capabilities.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-20 13:06:53 +02:00
Takashi Iwai
cdd03cedc5 ALSA: hda - Introduce snd_hda_set_pin_ctl*() helper functions
For setting the pin-control values more safely to match with the
actual pin capability bits, a copule of new helper functions,
snd_hda_set_pin_ctl() and snd_hda_set_pin_ctl_cache(), are
introduced.  These are simple replacement of the codec verb write with
AC_VERB_SET_PIN_WIDGET but do more sanity checks and filter out
superfluous pin-control bits if they don't fit with the corresponding
pin capabilities.

Some codecs are screwed up or ignore the command when such a wrong bit
is set.  These helpers will avoid such secret errors.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-04-20 12:38:48 +02:00
Takashi Iwai
b97f6bfdd1 ALSA: hda - Fix error handling in patch_ca0132.c
In patch_ca0132.c, the error returned from chipio_write() isn't checked
always.  Also, the power-up/down sequence isn't tracked properly in some
error paths.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2012-02-07 11:05:07 +01:00
Paul Gortmaker
da155d5b40 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.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
2011-10-31 19:31:21 -04:00
Takashi Iwai
efb9f469b6 ALSA: hda - Fix a compile error in patch_ca0132.c for the recent SPDIF change
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-21 07:44:51 +02:00
Ian Minett
95c6e9cb77 ALSA: hda - Add Creative CA0132 HDA codec support
Create patch_ca0132.c, to add support for devices featuring the
Creative CA0132 HD-audio codec.

This driver implements :-
* 1 playback subdevice to headphone and speaker
* 2 capture subdevices:
   i - Mic-in
   ii- Line-in
* mixer device

Advanced DSP features are not yet included.
Developed and maintained by Creative Labs, Inc.

Signed-off-by: Ian Minett <ian_minett@creativelabs.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2011-06-21 07:31:25 +02:00