From: Mark Brown <broonie@kernel.org>
To: Koro Chen <koro.chen@mediatek.com>
Cc: robh+dt@kernel.org, matthias.bgg@gmail.com, perex@perex.cz,
tiwai@suse.de, srv_heupstream@mediatek.com,
linux-mediatek@lists.infradead.org, s.hauer@pengutronix.de,
galak@codeaurora.org, lgirdwood@gmail.com,
devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org
Subject: Re: [RESEND RFC PATCH 3/3] ASoC: mediatek: Add AFE platform driver
Date: Sat, 18 Apr 2015 18:51:39 +0100 [thread overview]
Message-ID: <20150418175139.GG26185@sirena.org.uk> (raw)
In-Reply-To: <1428653649-38200-4-git-send-email-koro.chen@mediatek.com>
[-- Attachment #1: Type: text/plain, Size: 2683 bytes --]
On Fri, Apr 10, 2015 at 04:14:09PM +0800, Koro Chen wrote:
> + if (memif->use_sram) {
> + struct snd_dma_buffer *dma_buf = &substream->dma_buffer;
> + int size = params_buffer_bytes(params);
> +
> + memif->buffer_size = size;
> + memif->phys_buf_addr = afe->sram_phy_address;
> +
> + dma_buf->bytes = size;
> + dma_buf->area = (unsigned char *)afe->sram_address;
> + dma_buf->addr = afe->sram_phy_address;
> + dma_buf->dev.type = SNDRV_DMA_TYPE_DEV;
> + dma_buf->dev.dev = substream->pcm->card->dev;
> + snd_pcm_set_runtime_buffer(substream, dma_buf);
> + } else {
> + ret = snd_pcm_lib_malloc_pages(substream,
> + params_buffer_bytes(params));
> + if (ret < 0)
> + return ret;
> +
> + memif->phys_buf_addr = substream->runtime->dma_addr;
> + memif->buffer_size = substream->runtime->dma_bytes;
> + }
Ah, so the SRAM is directly memory mappable. Nice. But we have a
limited amount of it so need to allocate it to a device somehow based on
some factor I guess?
> +static int mtk_afe_set_adda_dac_out(struct mtk_afe *afe, uint32_t rate)
> +{
> + u32 audio_i2s_dac = 0;
> + u32 con0, con1;
> +
> + /* set dl src2 */
> + con0 = (mtk_afe_adda_fs(rate) << 28) | (0x03 << 24) | (0x03 << 11);
> +
> + /* 8k or 16k voice mode */
> + if (con0 == 0 || con0 == 3)
> + con0 |= 0x01 << 5;
This all looks a bit magic, some defines would not go amiss here.
> + /* SA suggests to apply -0.3db to audio/speech path */
> + con0 = con0 | (0x01 << 1);
> + con1 = 0xf74f0000;
More magic numbers! This also suggests that there is a volume control
lurking in here which could usefully be exposed to applications?
> +static void mtk_afe_pmic_shutdown(struct mtk_afe *afe,
> + struct snd_pcm_substream *substream)
> +{
> + /* output */
> + regmap_update_bits(afe->regmap, AFE_ADDA_DL_SRC2_CON0, 1, 0);
> + regmap_update_bits(afe->regmap, AFE_I2S_CON1, 1, 0);
> +
> + /* input */
> + regmap_update_bits(afe->regmap, AFE_ADDA_UL_SRC_CON0, 1, 0);
> + /* disable ADDA */
> + regmap_update_bits(afe->regmap, AFE_ADDA_UL_DL_CON0, 1, false);
> +}
This is looking like exposing the routing and using DAPM might save a
bunch of code? Overall my main thought looking at the code here and
what the hardware was described as doing is that it'd all be simpler if
it were a DPCM based thing using DAPM for power. I think I'd like to
see a strong reason for not using at least DPCM.
> + if (rate == MTK_AFE_I2S_RATE_8K)
> + voice_mode = 0;
> + else if (rate == MTK_AFE_I2S_RATE_16K)
> + voice_mode = 1;
> + else if (rate == MTK_AFE_I2S_RATE_32K)
> + voice_mode = 2;
> + else if (rate == MTK_AFE_I2S_RATE_48K)
> + voice_mode = 3;
This should be a switch statement.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
next prev parent reply other threads:[~2015-04-18 17:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1428653649-38200-1-git-send-email-koro.chen@mediatek.com>
[not found] ` <1428653649-38200-2-git-send-email-koro.chen@mediatek.com>
2015-04-18 17:34 ` [RESEND RFC PATCH 1/3] ASoC: mediatek: Add binding support for AFE driver Mark Brown
2015-04-20 4:37 ` Sascha Hauer
2015-04-20 20:48 ` Mark Brown
2015-04-21 9:49 ` Sascha Hauer
2015-04-21 10:14 ` Mark Brown
2015-04-21 10:15 ` Koro Chen
2015-04-21 10:56 ` Mark Brown
2015-04-22 3:17 ` Koro Chen
2015-04-30 20:12 ` Mark Brown
2015-05-04 1:57 ` Koro Chen
[not found] ` <1428653649-38200-3-git-send-email-koro.chen@mediatek.com>
2015-04-18 17:37 ` [RESEND RFC PATCH 2/3] ASoC: mediatek: Add AFE connection control Mark Brown
2015-04-20 4:50 ` Sascha Hauer
2015-04-20 20:52 ` Mark Brown
2015-04-21 5:50 ` Sascha Hauer
2015-04-21 10:15 ` Mark Brown
[not found] ` <1428653649-38200-4-git-send-email-koro.chen@mediatek.com>
2015-04-18 17:51 ` Mark Brown [this message]
2015-04-20 6:22 ` [RESEND RFC PATCH 3/3] ASoC: mediatek: Add AFE platform driver Koro Chen
2015-04-20 20:55 ` Mark Brown
2015-04-21 2:27 ` Koro Chen
2015-04-21 10:05 ` 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=20150418175139.GG26185@sirena.org.uk \
--to=broonie@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=devicetree@vger.kernel.org \
--cc=galak@codeaurora.org \
--cc=koro.chen@mediatek.com \
--cc=lgirdwood@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=perex@perex.cz \
--cc=robh+dt@kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=srv_heupstream@mediatek.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