alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/5] ASoC: wm_adsp: Factor out stripping padding from ADSP data
@ 2019-02-22 10:04 Charles Keepax
  2019-02-22 10:04 ` [PATCH 2/5] ASoC: wm_adsp: Reorder some functions for improved clarity Charles Keepax
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Charles Keepax @ 2019-02-22 10:04 UTC (permalink / raw)
  To: broonie; +Cc: stuarth, patches, alsa-devel, lgirdwood

In preparation for more refactoring add a helper function to strip the
padding from ADSP data.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 8d16a14cd2266..ae7e1f5d8d10a 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3231,6 +3231,21 @@ static inline int wm_adsp_buffer_write(struct wm_adsp_compr_buf *buf,
 				       buf->host_buf_ptr + field_offset, data);
 }
 
+static void wm_adsp_remove_padding(u32 *buf, int nwords, int data_word_size)
+{
+	u8 *pack_in = (u8 *)buf;
+	u8 *pack_out = (u8 *)buf;
+	int i, j;
+
+	/* Remove the padding bytes from the data read from the DSP */
+	for (i = 0; i < nwords; i++) {
+		for (j = 0; j < data_word_size; j++)
+			*pack_out++ = *pack_in++;
+
+		pack_in += sizeof(*buf) - data_word_size;
+	}
+}
+
 static int wm_adsp_legacy_host_buf_addr(struct wm_adsp_compr_buf *buf)
 {
 	struct wm_adsp_alg_region *alg_region;
@@ -3670,11 +3685,9 @@ EXPORT_SYMBOL_GPL(wm_adsp_compr_pointer);
 static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target)
 {
 	struct wm_adsp_compr_buf *buf = compr->buf;
-	u8 *pack_in = (u8 *)compr->raw_buf;
-	u8 *pack_out = (u8 *)compr->raw_buf;
 	unsigned int adsp_addr;
 	int mem_type, nwords, max_read;
-	int i, j, ret;
+	int i, ret;
 
 	/* Calculate read parameters */
 	for (i = 0; i < wm_adsp_fw[buf->dsp->fw].caps->num_regions; ++i)
@@ -3706,13 +3719,7 @@ static int wm_adsp_buffer_capture_block(struct wm_adsp_compr *compr, int target)
 	if (ret < 0)
 		return ret;
 
-	/* Remove the padding bytes from the data read from the DSP */
-	for (i = 0; i < nwords; i++) {
-		for (j = 0; j < WM_ADSP_DATA_WORD_SIZE; j++)
-			*pack_out++ = *pack_in++;
-
-		pack_in += sizeof(*(compr->raw_buf)) - WM_ADSP_DATA_WORD_SIZE;
-	}
+	wm_adsp_remove_padding(compr->raw_buf, nwords, WM_ADSP_DATA_WORD_SIZE);
 
 	/* update read index to account for words read */
 	buf->read_index += nwords;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2019-02-26 12:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-22 10:04 [PATCH 1/5] ASoC: wm_adsp: Factor out stripping padding from ADSP data Charles Keepax
2019-02-22 10:04 ` [PATCH 2/5] ASoC: wm_adsp: Reorder some functions for improved clarity Charles Keepax
2019-02-26 12:06   ` Applied "ASoC: wm_adsp: Reorder some functions for improved clarity" to the asoc tree Mark Brown
2019-02-22 10:04 ` [PATCH 3/5] ASoC: wm_adsp: Refactor compress stream initialisation Charles Keepax
2019-02-26 12:06   ` Applied "ASoC: wm_adsp: Refactor compress stream initialisation" to the asoc tree Mark Brown
2019-02-22 10:04 ` [PATCH 4/5] ASoC: wm_adsp: Add support for multiple compressed buffers Charles Keepax
2019-02-26 12:06   ` Applied "ASoC: wm_adsp: Add support for multiple compressed buffers" to the asoc tree Mark Brown
2019-02-22 10:04 ` [PATCH 5/5] ASoC: wm_adsp: Improve logging messages Charles Keepax
2019-02-26 12:06 ` Applied "ASoC: wm_adsp: Factor out stripping padding from ADSP data" to the asoc tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).