summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wm_adsp.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ASoC: wm_adsp: Don't overrun firmware file buffer when reading region dataRichard Fitzgerald2016-12-201-1/+24
| | | | | | | | | Protect against corrupt firmware files by ensuring that the length we get for the data in a region actually lies within the available firmware file data buffer. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: wm_adsp_buf_alloc should use kfree in error pathRichard Fitzgerald2016-12-121-1/+1
| | | | | | | buf was allocated by kzalloc() so it should be passed to kfree() Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Check return value from wm_adsp_buffer_initCharles Keepax2016-11-221-1/+6
| | | | | | | | | | We are not checking the return value from a call to wm_adsp_buffer_init it looks like this used to be returned at the bottom of the function but probably got missed when more error paths were added. This patch adds the appropriate error check. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Remove unused wm_coeff_ctl.kcontrolRichard Fitzgerald2016-11-221-3/+0
| | | | | | | The kcontrol pointer in wm_coeff_ctl is not used now. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Firmware controls should be added as codec controlsRichard Fitzgerald2016-11-221-4/+4
| | | | | | | | | | | | | | | | | | | | | | | We were adding firmware controls as card controls (using snd_soc_add_codec_controls). The DSP is part of a specific codec so we should be adding them as codec controls. Adding as codec controls also means that if the codec has a name_prefix it will be added to the control name, which won't happen when adding as a card control. As that was the only use of the card pointer in struct wm_adsp it can be removed. For ADSP2 codecs a wm_adsp2_codec_probe() was added since the original control handling was written, and that's the logical place to store a pointer to the codec rather than delaying it until the codec is powered-up. For ADSP1 we don't use a codec_probe() stage so the codec pointer initialization replaces the original card pointer initialization in wm_adsp1_event(). Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Only write shutdown controls for active firmwaresCharles Keepax2016-11-211-0/+3
| | | | | | | | | | | The control list may contain shutdown controls for firmwares that are not currently active, attempting to write this will at best fail. To avoid this issue we skip any control that is not active. Fixes: commit f4f0c4c60c39 ("ASoC: wm_adsp: Signal firmware shutdown through event control") Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: factor out getting base register for a controlRichard Fitzgerald2016-11-141-22/+24
| | | | | | | | | The lookup of the base register corresponding to a control is duplicated in read and write so factor it out into a separate function. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Support acknowledged controlsRichard Fitzgerald2016-11-111-8/+81
| | | | | | | | | | | | | | | This patch handles publishing acknowledged controls through ALSA. These controls allow user-side to send events to the firmware and wait for the firmware to acknowledge it. Note that although acked controls only operate in the direction host->firmware, and therefore they are write-only as seen from user- side code, we have to make them readable to account for all the code out there that assumes that ALSA controls are always readable (amixer for example.) Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Add support for SYSTEM firmware controlsStuart Henderson2016-11-111-10/+18
| | | | | | | | | | Add support for firmware controls marked SYSTEM. These are internal to the driver-firmware interface and do not have a user-accessible ALSA control. Signed-off-by: Stuart Henderson <stuarth@opensource.wolfsonmicro.com> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: factor out getting region name from typeRichard Fitzgerald2016-11-111-31/+22
| | | | | | | | This patch factors out converting a memory region type into a name string, mainly so that it can be used in log commands. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Signal firmware shutdown through event controlRichard Fitzgerald2016-11-111-0/+114
| | | | | | | | If the firmware has any system event signalling controls, signal them during DSP PRE_PMD to tell the firmware it is about to be stopped. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Remove duplicate set of kcontrol->ifaceRichard Fitzgerald2016-10-211-1/+0
| | | | | Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Allow preloader to do the final shutdown of the DSPCharles Keepax2016-09-261-15/+21
| | | | | | | | | | | | | | | The booting process for the DSP is clearly separated into two parts, the preloader brings up the core and downloads code, then the main widget starts the code actually executing. However the shutdown sequence is all handled with the main widget. To allow the preloading to be run independently of the main audio bring up it makes sense, and is generally just cleaner, for the preloader widget to shutdown those things it initialised. This patch moves the appropriate parts of the shutdown process into the preloader widget. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Put DSP into low power state between loading and runningCharles Keepax2016-09-261-1/+17
| | | | | | | | | Between when we load the DSP and when it actually starts running put the core into a lower power state where the memory is retained but nothing is clocked. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Use usleep_range for short delayCharles Keepax2016-09-261-1/+1
| | | | | | | | | Replace the 1ms msleep in wm_adsp2_ena with a usleep_range, as per normal guidance on delay functions. Also tighten up the delay a little as 1ms was quite generous. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Move control cache sync out of preloaderCharles Keepax2016-09-241-11/+11
| | | | | | | | | | | | | | | | As part of the work to download firmware before the audio path is brought up the DSP will be put into a low power state between downloading firmware to the core and starting it running. This will mean that the firmware ALSA controls are not accessible in the hardware during this period of time. To prepare for this change we gate access to the hardware in the ALSA control handlers on the DSP being running rather than simply booted and move the synchronisation of the control caches out of the preloader delayed work and into the main DAPM thread after the DSP will have been brought out of its low power state. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Separate concept of booted and runningCharles Keepax2016-09-241-11/+25
| | | | | | | | | | | | | | | | Currently the wm_adsp driver has a flag that indicates the DSP is "running", this flag is used to gate access to the hardware. However this flag is actually set in the firmware download thread after the firmware has been downloaded, but this is before the core is actually started running, so really it currently indicates that the core has been booted and is perhaps running. This patch clearly separates out the concepts of booted (firmware is downloaded) and running (code is executing on the DSP) within the wm_adsp driver. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-. Merge remote-tracking branches 'asoc/topic/arizona', 'asoc/topic/atmel', ↵Mark Brown2016-07-241-0/+5
|\ \ | | | | | | | | | 'asoc/topic/bt-sco', 'asoc/topic/compress' and 'asoc/topic/cs35l33' into asoc-next
| * | ASoC: wm_adsp: Specifically propagate voice trigger event to callerCharles Keepax2016-05-301-0/+5
| |/ | | | | | | | | | | | | | | | | | | | | | | The DSP uses an IRQ to indicate data is available on the compressed stream. For voice trigger use-cases the first such IRQ can be considered an indication that the user has spoken the key phrase triggering the firmware. Provide a means for the ADSP code to communicate back to the calling driver whether an IRQ should be considered as trigger event or not. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Disable DMAs before clearing the transfer lengthSimon Trimmer2016-06-221-3/+5
| | | | | | | | | | | | | | | | | | This patch reorders the clearing of the DMA masks to avoid potential artefacts being introduced. Signed-off-by: Simon Trimmer <simont@opensource.wolfsonmicro.com> Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Treat missing compressed buffer as a fatal errorCharles Keepax2016-06-131-10/+2
| | | | | | | | | | | | | | | | | | If the DSP is powered down whilst a compressed stream is being processed we should treat this as a fatal error, clearly the stream is no longer valid. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Use new snd_compr_stop_error to signal stream failureCharles Keepax2016-06-131-2/+9
|/ | | | | | | | | | If we encounter a fatal error on the compressed stream call the new snd_compr_stop_error to shutdown the stream and allow the core to inform user-space that the stream is no longer valid. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Reviewed-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Detach compressed stream on freeCharles Keepax2016-05-041-0/+22
| | | | | | | | | | | | | If someone powers down the DSP core (through routing changes say) whilst a compressed record is in progress we can end up using a freed pointer to the buffer object. When a compressed audio stream is triggered we attach it to a buffer on a physical DSP. This patch adds a detach of the buffer from the stream when the stream is freed or when the DSP is powered down which avoids the situation where we use a buffer when it is no longer valid. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Move compr_attach/attached functionsCharles Keepax2016-05-041-19/+19
| | | | | | | | | Move wm_adsp_compr_attach and wm_adsp_compr_attached functions so they will stay logically grouped with similar functions after some additional changes. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* Merge branch 'topic/arizona' of ↵Mark Brown2016-05-041-16/+36
|\ | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-adsp
| * ASoC: wm_adsp: factor out freeing of alg regionsRichard Fitzgerald2016-04-271-16/+16
| | | | | | | | | | | | | | Add a function to delete and free the contents of the alg_regions list. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| * ASoC: wm_adsp: free memory when unloaded or closedRichard Fitzgerald2016-04-271-0/+20
| | | | | | | | | | | | | | | | The patch adds a wm_adsp2_remove() function to ensure that memory is freed when the driver is unloaded or shut down. Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Add support for TLV based binary controlsCharles Keepax2016-05-021-20/+108
| | | | | | | | | | | | | | | | | | This patch adds support for the arbitrary length TLV based binary controls. This allows users to properly access controls that are more than 512 bytes in length. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Improve DSP error handlingCharles Keepax2016-04-061-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we encounter an error on the DSP side whilst user-space is waiting on the poll we should call snd_compr_fragment_elapsed, although data is not actually available we want to wake user-space such that the error can be propagated out quickly. Additionally some versions of the DSP firmware are not super consistent about actually generating an IRQ if they encounter an error, as such we will check the DSP error status every time we run out of available data as well, to ensure we catch it. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Factor out fetching of stream errors from the DSPCharles Keepax2016-04-061-9/+19
| | | | | | | | | | | | | | | | Factor out the reading of the DSP error flag into its own function to support further improvements to the code. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Show avail in bytes to match other messagesCharles Keepax2016-03-291-1/+1
| | | | | | | | | | | | | | | | | | All other debug messages talk about data on the compressed stream in bytes except avail which is shown in words. To avoid confusion show avail in bytes as well. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Fix some subtle races on compressed streamCharles Keepax2016-03-291-3/+12
|/ | | | | | | | | | Firstly, we should be locking the pwr_lock when we initialise the compressed buffer. Secondly, fixup a couple of places when we should be pulling pointers only under the pwr_lock as they may be affected by operations that take that lock. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
*-----. Merge remote-tracking branches 'asoc/topic/ab8500', 'asoc/topic/adau17x1', ↵Mark Brown2016-03-131-60/+71
|\ \ \ \ | | | | | | | | | | | | | | | 'asoc/topic/ads117x', 'asoc/topic/adsp' and 'asoc/topic/arizona' into asoc-next
| | | | * ASoC: wm_adsp: Add missing const from region definitionsCharles Keepax2016-02-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | | * ASoC: wm5110: Add support for audio trace firmwareCharles Keepax2016-01-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mainly this adds DAI links for the audio trace, however, it is also necessary to update the data IRQ handler to check more cores. We have the handler check every core so it should not be necessary to update this function if more compressed firmwares are added in the future. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | | * ASoC: wm_adsp: Move setting of DSP speed into CODEC specific codeCharles Keepax2016-01-291-25/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The ADSP code should be agnostic of which CODEC it runs upon, currently there is only one remaining part of the implementation that doesn't follow this. When the DSP is booted on ADSP2 we read ARIZONA_SYSTEM_CLOCK_1 and use that to set the initial speed for the DSP clock. This patch factors that out into CODEC specific code, leaving the ADSP code entirely CODEC agnostic. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | | * ASoC: wm_adsp: Add debug audio trace firmwareCharles Keepax2016-01-291-1/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The audio trace firmware allows the capture of arbitrary streams of audio from the DSP and commonly used for debugging other firmwares. This patch adds support for this firwmare into the ADSP driver. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | | * ASoC: wm_adsp: Use more generic naming for regions and caps definitionsCharles Keepax2016-01-291-6/+6
| | | |/ | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The region definition will be shared by most firmwares so give this a more generic name and whilst we are there improve the naming of the voice control capabilities array as well. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: Use correct local length in error messageCharles Keepax2016-03-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Fixes: 44029e9e1290 ("ASoC: wm_adsp: wm_coeff_{read|write}_control should use passed length") Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: wm_coeff_{read|write}_control should use passed lengthCharles Keepax2016-02-201-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | wm_coeff_{read|write}_control were using the control length rather than the length parameter passed to them. This is not causing any issues as the two values are currently always the same, but this needs fixed to allow future improvements. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: Fixup some odd line wrappingCharles Keepax2016-02-201-16/+7
| | | | | | | | | | | | | | | | | | | | Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: Explicitly set the control access flags in all casesCharles Keepax2016-02-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the case where the firmware does not tell us the access flags for the control, we let ALSA select a default (READWRITE). But really we should be applying the volatile flag in this case, as we will read the control from the DSP if it is on in this case. This patch explicitly sets the access flags in all cases. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: Avoid narrow race condition on compr pointerCharles Keepax2016-02-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a very small window between then wm_adsp_compr_free gets call and when the DSP is actually powered down. If we get an IRQ from the DSP in this window then the wm_adsp_compr pointer will be NULL. This patch adds a check for this into the IRQ handler to avoid any issues when this happens. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
| | | * ASoC: wm_adsp: Return sample rate in wm_adsp_compr_pointerCharles Keepax2016-02-021-0/+5
| | |/ | | | | | | | | | | | | | | | | | | | | | We should return a valid sample rate from the pointer callback, this patch adds this into the driver. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | / ASoC: wm_adsp: Fix enum ctl accesses in a wrong typeTakashi Iwai2016-03-011-4/+4
| |/ |/| | | | | | | | | | | | | | | | | | | The firmware ctls like "DSP1 Firmware" in wm_adsp codec driver are enum, while the current driver accesses wrongly via value.integer.value[]. They have to be via value.enumerated.item[] instead. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
* | ASoC: wm_adsp: Pull data through compressed readCharles Keepax2016-01-061-0/+138
| | | | | | | | | | | | | | | | | | Data is read in blocks of up to one fragment is size from the circular buffer on the DSP and is re-packed to remove the padding byte that exists in the DSP memory map. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* | ASoC: wm_adsp: Add a handler for the compressed IRQCharles Keepax2016-01-061-0/+188
|/ | | | | | | | | | | | Here support is added for responding to DSP IRQs that are used to indicate data being available on the DSP. The idea is that we check the amount of data available upon receipt of an IRQ and on subsequent calls to the pointer callback we recheck once less than one fragment is available (to avoid excessive SPI traffic), if there is truely less than one fragment available we ack the last IRQ and wait for a new one. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Attach buffers and streams togetherCharles Keepax2015-12-231-0/+62
| | | | | | | | | | | | | | The stream is created whilst the compressed stream is opened and a buffer is created when the DSP powers up. It is necessary at a point once both the DSP has powered up and the the stream has been opened to connect a stream to a buffer on the DSP. This is done in the trigger callback as this is after the DSP has been powered and obviously the stream must be open. Note that whilst the connect is currently trivial it is expected that this will get more complex when support for multiple buffers/streams per DSP is added. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Add code to locate and initialise compressed bufferCharles Keepax2015-12-231-0/+291
| | | | | | | | | | | | Add code that locates and initialises the buffer of compressed data on the DSP if the firmware supported compressed data capture. The buffer struct (wm_adsp_compr_buf) is kept separate from the stream struct (wm_adsp_compr) this will allow much easier support of multiple streams of data from the one DSP in the future, although support for this will not be added in this patch chain. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>
* ASoC: wm_adsp: Add support for opening a compressed streamCharles Keepax2015-12-231-3/+191
| | | | | | | | | Allow user-space to open a compressed stream, although no data will be passed yet, as part of this adding the ability to define supported capabilities per firmware and check these match the stream being opened. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Mark Brown <broonie@kernel.org>