At Thu, 20 Feb 2014 21:48:44 +0000, Liam Girdwood wrote:
+/* TLV used by both global and stream volumes */ +static const DECLARE_TLV_DB_SCALE(hsw_vol_tlv, -9000, 300, 1);
+/* System Pin has no volume control */ +static const struct snd_kcontrol_new hsw_volume_controls[] = {
- /* Global DSP volume */
- SOC_DOUBLE_EXT_TLV("Master Playback Volume", 0, 0, 8,
ARRAY_SIZE(volume_map) -1, 0,
hsw_volume_get, hsw_volume_put, hsw_vol_tlv),
- /* Offload 0 volume */
- SOC_DOUBLE_EXT_TLV("Media0 Playback Volume", 1, 0, 8,
ARRAY_SIZE(volume_map), 0,
hsw_stream_volume_get, hsw_stream_volume_put, hsw_vol_tlv),
Why -1 is for Master and not for others although they use the same TLV?
+/* Create DMA buffer page table for DSP */ +static int create_adsp_page_table(struct hsw_priv_data *pdata,
- struct snd_soc_pcm_runtime *rtd,
- unsigned char *dma_area, size_t size, int pcm, int stream)
+{
- int i, pages;
- if (size % PAGE_SIZE)
pages = (size / PAGE_SIZE) + 1;
- else
pages = size / PAGE_SIZE;
- dev_dbg(rtd->dev, "generating page table for %p size 0x%zu pages %d\n",
dma_area, size, pages);
- for (i = 0; i < pages; i++) {
u32 idx = (((i << 2) + i)) >> 1;
u32 pfn = (virt_to_phys(dma_area + i * PAGE_SIZE)) >> PAGE_SHIFT;
virt_to_phys() is bad, pretty unportable. And, this implementation doesn't use SG-buffer although the hardware can it obviously.
For managing SG-buffer, just use SNDRV_DMA_TPE_DEV_SG for preallocation, and change the page setup code like:
struct snd_dma_buffer *dmab = snd_pcm_get_dma_buf(substream)
.... pages = snd_sgbuf_aligned_pages(size); for (i = 0; i < pages; i++) { u32 idx = (((i << 2) + i)) >> 1; u32 pfn = snd_sgbuf_get_addr(dmab, i * PAGE_SIZE) >> PAGE_SHIFT;
The only other thing to change is to pass snd_pcm_sgbuf_ops_page to snd_pcm_ops.page. That's all.
Takashi