From mboxrd@z Thu Jan 1 00:00:00 1970 From: Takashi Iwai Subject: Re: [PATCH 3/6] ASoC: Intel: Add Haswell and Broadwell PCM platform driver Date: Fri, 21 Feb 2014 08:28:49 +0100 Message-ID: References: <1392932927-9725-1-git-send-email-liam.r.girdwood@linux.intel.com> <1392932927-9725-3-git-send-email-liam.r.girdwood@linux.intel.com> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 55B59261737 for ; Fri, 21 Feb 2014 08:28:50 +0100 (CET) In-Reply-To: <1392932927-9725-3-git-send-email-liam.r.girdwood@linux.intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Liam Girdwood Cc: alsa-devel@alsa-project.org, Mark Brown List-Id: alsa-devel@alsa-project.org 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