Re: [PATCH 2/4] ASoC: SAMSUNG: Add I2S0 internal dma driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 9, 2011 at 1:39 PM, Sangbeom Kim <sbkim73@xxxxxxxxxxx> wrote:
> I2S in Exynos4 and S5PC110(S5PV210) has a internal dma.
> It can be used low power audio mode and 2nd channel transfer.

For my convenience, could you please tell how does it differ from my
original implementation?  Most things look same, except for a few
variables.


> @@ -16,6 +17,7 @@ obj-$(CONFIG_SND_S3C_I2SV2_SOC) += snd-soc-s3c-i2s-v2.o
> Âobj-$(CONFIG_SND_SAMSUNG_SPDIF) += snd-soc-samsung-spdif.o
> Âobj-$(CONFIG_SND_SAMSUNG_PCM) += snd-soc-pcm.o
> Âobj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-i2s.o
> +obj-$(CONFIG_SND_SAMSUNG_I2S) += snd-soc-idma.o

Please check that building only for s3c64xx doesn't break by this.



> +
> +static struct idma_info {
> +    spinlock_t   Âlock;
> +    void       __iomem Â*regs;
> +    int       trigger_stat;
The role of trigger_stat is not necessary.

> +
> + Â Â Â /* Start address0 of I2S internal DMA operation. */
> + Â Â Â val = readl(idma.regs + I2SSTR0);
Why read when you immediately overwrite it ?
> + Â Â Â val = LP_TXBUFF_ADDR;
> + Â Â Â writel(val, idma.regs + I2SSTR0);
> +


> +static int idma_hw_params(struct snd_pcm_substream *substream,
> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct snd_pcm_hw_params *params)
> +{
> + Â Â Â struct snd_pcm_runtime *runtime = substream->runtime;
> + Â Â Â struct idma_ctrl *prtd = substream->runtime->private_data;
> +
> + Â Â Â pr_debug("Entered %s\n", __func__);
can we have all the pr_debug's converted to dev_debug ?


> + Â Â Â snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);
> + Â Â Â runtime->dma_bytes = params_buffer_bytes(params);
> + Â Â Â memset(runtime->dma_area, 0, runtime->dma_bytes);
Is it really needed ?

> +
> + Â Â Â if (iisahb & AHB_LVL0INT)
> + Â Â Â Â Â Â Â val = AHB_CLRLVL0INT;
> + Â Â Â else
> + Â Â Â Â Â Â Â val = 0;
  val = (iisahb & AHB_LVL0INT) ? AHB_CLRLVL0INT : 0;     looks better

> +
> + Â Â Â if (val) {
> + Â Â Â Â Â Â Â iisahb |= val;
> + Â Â Â Â Â Â Â writel(iisahb, idma.regs + I2SAHB);
> +
> + Â Â Â Â Â Â Â addr = readl(idma.regs + I2SLVL0ADDR);
> + Â Â Â Â Â Â Â addr += prtd->periodsz;
> +
> + Â Â Â Â Â Â Â if (addr >= prtd->end)
> + Â Â Â Â Â Â Â Â Â Â Â addr = LP_TXBUFF_ADDR;
This will break if ring buffer is not a multiple of period size.
Either set the constraint in open or do modulo operation here.

> +
> +static int idma_close(struct snd_pcm_substream *substream)
> +{
> + Â Â Â struct snd_pcm_runtime *runtime = substream->runtime;
> + Â Â Â struct idma_ctrl *prtd = runtime->private_data;
> +
> + Â Â Â pr_debug("Entered %s, prtd = %p\n", __func__, prtd);
> +
> + Â Â Â free_irq(IRQ_I2S0, prtd);
> +
> + Â Â Â if (!prtd)
> + Â Â Â Â Â Â Â pr_err("idma_close called with prtd == NULL\n");
> +
> + Â Â Â kfree(prtd);

Also       runtime->private_data = NULL;

> diff --git a/sound/soc/samsung/idma.h b/sound/soc/samsung/idma.h
> new file mode 100644
> index 0000000..2b0ac37
> --- /dev/null
> +++ b/sound/soc/samsung/idma.h
> @@ -0,0 +1,28 @@
> +/*
> + * idma.h Â-- ÂI2S0's Internal Dma driver
> + *
> + * Copyright (c) 2010 Samsung Electronics Co. Ltd
Copyright 2011 ?

> +/* idma_state */
> +#define LPAM_DMA_STOP Â Â0
> +#define LPAM_DMA_START Â 1
These are internal to idma.c, please move them there.
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SoC Development]     [Linux Rockchip Development]     [Linux USB Development]     [Video for Linux]     [Linux Audio Users]     [Linux SCSI]     [Yosemite News]

  Powered by Linux