alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>,
	Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [alsa-devel] [PATCH v2 05/13] ASoC: SOF: core: modify the signature for snd_sof_create_page_table
Date: Wed,  4 Dec 2019 15:15:48 -0600	[thread overview]
Message-ID: <20191204211556.12671-6-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20191204211556.12671-1-pierre-louis.bossart@linux.intel.com>

From: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>

Modify the signature for snd_sof_create_page_table to
take struct device pointer as an argument instead of
struct snd_sof_dev as this will be used by both the SOF
core device and its clients. Also, move the definition
out of core.c to utils.c.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/core.c     | 59 ---------------------------------------
 sound/soc/sof/pcm.c      |  2 +-
 sound/soc/sof/sof-priv.h |  2 +-
 sound/soc/sof/trace.c    |  4 +--
 sound/soc/sof/utils.c    | 60 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 64 insertions(+), 63 deletions(-)

diff --git a/sound/soc/sof/core.c b/sound/soc/sof/core.c
index 805918d3bcc0..6a7f342203e9 100644
--- a/sound/soc/sof/core.c
+++ b/sound/soc/sof/core.c
@@ -10,7 +10,6 @@
 
 #include <linux/firmware.h>
 #include <linux/module.h>
-#include <asm/unaligned.h>
 #include <sound/soc.h>
 #include <sound/sof.h>
 #include "sof-priv.h"
@@ -213,64 +212,6 @@ void snd_sof_get_status(struct snd_sof_dev *sdev, u32 panic_code,
 }
 EXPORT_SYMBOL(snd_sof_get_status);
 
-/*
- * Generic buffer page table creation.
- * Take the each physical page address and drop the least significant unused
- * bits from each (based on PAGE_SIZE). Then pack valid page address bits
- * into compressed page table.
- */
-
-int snd_sof_create_page_table(struct snd_sof_dev *sdev,
-			      struct snd_dma_buffer *dmab,
-			      unsigned char *page_table, size_t size)
-{
-	int i, pages;
-
-	pages = snd_sgbuf_aligned_pages(size);
-
-	dev_dbg(sdev->dev, "generating page table for %p size 0x%zx pages %d\n",
-		dmab->area, size, pages);
-
-	for (i = 0; i < pages; i++) {
-		/*
-		 * The number of valid address bits for each page is 20.
-		 * idx determines the byte position within page_table
-		 * where the current page's address is stored
-		 * in the compressed page_table.
-		 * This can be calculated by multiplying the page number by 2.5.
-		 */
-		u32 idx = (5 * i) >> 1;
-		u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
-		u8 *pg_table;
-
-		dev_vdbg(sdev->dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
-
-		pg_table = (u8 *)(page_table + idx);
-
-		/*
-		 * pagetable compression:
-		 * byte 0     byte 1     byte 2     byte 3     byte 4     byte 5
-		 * ___________pfn 0__________ __________pfn 1___________  _pfn 2...
-		 * .... ....  .... ....  .... ....  .... ....  .... ....  ....
-		 * It is created by:
-		 * 1. set current location to 0, PFN index i to 0
-		 * 2. put pfn[i] at current location in Little Endian byte order
-		 * 3. calculate an intermediate value as
-		 *    x = (pfn[i+1] << 4) | (pfn[i] & 0xf)
-		 * 4. put x at offset (current location + 2) in LE byte order
-		 * 5. increment current location by 5 bytes, increment i by 2
-		 * 6. continue to (2)
-		 */
-		if (i & 1)
-			put_unaligned_le32((pg_table[0] & 0xf) | pfn << 4,
-					   pg_table);
-		else
-			put_unaligned_le32(pfn, pg_table);
-	}
-
-	return pages;
-}
-
 /*
  * SOF Driver enumeration.
  */
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 549238a98b2a..9fd73ef08904 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -33,7 +33,7 @@ static int create_page_table(struct snd_soc_component *component,
 	if (!spcm)
 		return -EINVAL;
 
-	return snd_sof_create_page_table(sdev, dmab,
+	return snd_sof_create_page_table(sdev->dev, dmab,
 		spcm->stream[stream].page_table.area, size);
 }
 
diff --git a/sound/soc/sof/sof-priv.h b/sound/soc/sof/sof-priv.h
index 31f0eb31598a..18dd832f2053 100644
--- a/sound/soc/sof/sof-priv.h
+++ b/sound/soc/sof/sof-priv.h
@@ -499,7 +499,7 @@ int snd_sof_set_d0_substate(struct snd_sof_dev *sdev,
 
 void snd_sof_new_platform_drv(struct snd_sof_dev *sdev);
 
-int snd_sof_create_page_table(struct snd_sof_dev *sdev,
+int snd_sof_create_page_table(struct device *dev,
 			      struct snd_dma_buffer *dmab,
 			      unsigned char *page_table, size_t size);
 
diff --git a/sound/soc/sof/trace.c b/sound/soc/sof/trace.c
index b0e4556c8536..4bb65030819d 100644
--- a/sound/soc/sof/trace.c
+++ b/sound/soc/sof/trace.c
@@ -250,8 +250,8 @@ int snd_sof_init_trace(struct snd_sof_dev *sdev)
 	}
 
 	/* create compressed page table for audio firmware */
-	ret = snd_sof_create_page_table(sdev, &sdev->dmatb, sdev->dmatp.area,
-					sdev->dmatb.bytes);
+	ret = snd_sof_create_page_table(sdev->dev, &sdev->dmatb,
+					sdev->dmatp.area, sdev->dmatb.bytes);
 	if (ret < 0)
 		goto table_err;
 
diff --git a/sound/soc/sof/utils.c b/sound/soc/sof/utils.c
index 2ac4c3da0320..9831eb57df6c 100644
--- a/sound/soc/sof/utils.c
+++ b/sound/soc/sof/utils.c
@@ -10,6 +10,7 @@
 
 #include <linux/io-64-nonatomic-lo-hi.h>
 #include <linux/platform_device.h>
+#include <asm/unaligned.h>
 #include <sound/soc.h>
 #include <sound/sof.h>
 #include "sof-priv.h"
@@ -110,3 +111,62 @@ void sof_block_read(struct snd_sof_dev *sdev, u32 bar, u32 offset, void *dest,
 	memcpy_fromio(dest, src, size);
 }
 EXPORT_SYMBOL(sof_block_read);
+
+/*
+ * Generic buffer page table creation.
+ * Take the each physical page address and drop the least significant unused
+ * bits from each (based on PAGE_SIZE). Then pack valid page address bits
+ * into compressed page table.
+ */
+
+int snd_sof_create_page_table(struct device *dev,
+			      struct snd_dma_buffer *dmab,
+			      unsigned char *page_table, size_t size)
+{
+	int i, pages;
+
+	pages = snd_sgbuf_aligned_pages(size);
+
+	dev_dbg(dev, "generating page table for %p size 0x%zx pages %d\n",
+		dmab->area, size, pages);
+
+	for (i = 0; i < pages; i++) {
+		/*
+		 * The number of valid address bits for each page is 20.
+		 * idx determines the byte position within page_table
+		 * where the current page's address is stored
+		 * in the compressed page_table.
+		 * This can be calculated by multiplying the page number by 2.5.
+		 */
+		u32 idx = (5 * i) >> 1;
+		u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
+		u8 *pg_table;
+
+		dev_vdbg(dev, "pfn i %i idx %d pfn %x\n", i, idx, pfn);
+
+		pg_table = (u8 *)(page_table + idx);
+
+		/*
+		 * pagetable compression:
+		 * byte 0     byte 1     byte 2     byte 3     byte 4     byte 5
+		 * ___________pfn 0__________ __________pfn 1___________  _pfn 2...
+		 * .... ....  .... ....  .... ....  .... ....  .... ....  ....
+		 * It is created by:
+		 * 1. set current location to 0, PFN index i to 0
+		 * 2. put pfn[i] at current location in Little Endian byte order
+		 * 3. calculate an intermediate value as
+		 *    x = (pfn[i+1] << 4) | (pfn[i] & 0xf)
+		 * 4. put x at offset (current location + 2) in LE byte order
+		 * 5. increment current location by 5 bytes, increment i by 2
+		 * 6. continue to (2)
+		 */
+		if (i & 1)
+			put_unaligned_le32((pg_table[0] & 0xf) | pfn << 4,
+					   pg_table);
+		else
+			put_unaligned_le32(pfn, pg_table);
+	}
+
+	return pages;
+}
+EXPORT_SYMBOL(snd_sof_create_page_table);
-- 
2.20.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  parent reply	other threads:[~2019-12-04 21:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-04 21:15 [alsa-devel] [PATCH v2 00/13] ASoC: SOF: initial cleanup for DT and multi-client support Pierre-Louis Bossart
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 01/13] ASoC: intel/skl/hda - export number of digital microphones via control components Pierre-Louis Bossart
2019-12-09 18:59   ` [alsa-devel] Applied "ASoC: intel/skl/hda - export number of digital microphones via control components" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 02/13] ASoC: Intel - use control components to describe card config Pierre-Louis Bossart
2019-12-09 18:59   ` [alsa-devel] Applied "ASoC: Intel - use control components to describe card config" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 03/13] ASoC: Intel - do not describe I/O configuration in the long card name Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: Intel - do not describe I/O configuration in the long card name" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 04/13] ASoC: SOF: topology: remove snd_sof_init_topology() Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: topology: remove snd_sof_init_topology()" to the asoc tree Mark Brown
2019-12-04 21:15 ` Pierre-Louis Bossart [this message]
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: core: modify the signature for snd_sof_create_page_table" " Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 06/13] ASoC: SOF: core: move check for runtime callbacks to core Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: core: move check for runtime callbacks to core" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 07/13] ASoC: SOF: Introduce default_fw_filename member in sof_dev_desc Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: Introduce default_fw_filename member in sof_dev_desc" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 08/13] ASoC: SOF: partition audio-related parts from SOF core Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: partition audio-related parts from SOF core" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 09/13] ASoC: SOF: intel: hda: Modify signature for hda_codec_probe_bus() Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: intel: hda: Modify signature for hda_codec_probe_bus()" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 10/13] ASoC: SOF: Make creation of machine device from SOF core optional Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: Make creation of machine device from SOF core optional" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 11/13] ASoC: SOF: remove nocodec_fw_filename Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: remove nocodec_fw_filename" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 12/13] ASoC: SOF: Remove unused drv_name in sof_pdata Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: Remove unused drv_name in sof_pdata" to the asoc tree Mark Brown
2019-12-04 21:15 ` [alsa-devel] [PATCH v2 13/13] ASoC: SOF: nocodec: Amend arguments for sof_nocodec_setup() Pierre-Louis Bossart
2019-12-09 18:58   ` [alsa-devel] Applied "ASoC: SOF: nocodec: Amend arguments for sof_nocodec_setup()" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191204211556.12671-6-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).