ASoC: SOF: core: modify the signature for snd_sof_create_page_table
authorRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Wed, 4 Dec 2019 21:15:48 +0000 (15:15 -0600)
committerMark Brown <broonie@kernel.org>
Mon, 9 Dec 2019 18:38:01 +0000 (18:38 +0000)
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>
Link: https://lore.kernel.org/r/20191204211556.12671-6-pierre-louis.bossart@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/core.c
sound/soc/sof/pcm.c
sound/soc/sof/sof-priv.h
sound/soc/sof/trace.c
sound/soc/sof/utils.c

index 805918d..6a7f342 100644 (file)
@@ -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"
@@ -214,64 +213,6 @@ out:
 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.
  */
 static int sof_machine_check(struct snd_sof_dev *sdev)
index 549238a..9fd73ef 100644 (file)
@@ -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);
 }
 
index 31f0eb3..18dd832 100644 (file)
@@ -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);
 
index b0e4556..4bb6503 100644 (file)
@@ -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;
 
index 2ac4c3d..9831eb5 100644 (file)
@@ -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);