Message ID | cover.1585726761.git.shengjiu.wang@nxp.com |
---|---|
Headers | show |
Series | ASoC: Add new module driver for new ASRC | expand |
On Wed, Apr 01, 2020 at 04:45:34PM +0800, Shengjiu Wang wrote: > In order to move common structure to fsl_asrc_common.h > we change the name of asrc_priv to asrc, the asrc_priv > will be used by new struct fsl_asrc_priv. > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
On Wed, Apr 01, 2020 at 04:45:36PM +0800, Shengjiu Wang wrote: > In order to align with new ESARC, we add new property fsl,asrc-format. > The fsl,asrc-format can replace the fsl,asrc-width, driver > can accept format from devicetree, don't need to convert it to > format through width. > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com> > --- > sound/soc/fsl/fsl-asoc-card.c | 21 ++++++++++++--------- > 1 file changed, 12 insertions(+), 9 deletions(-) > > diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c > index bb33601fab84..a0f5eb27d61a 100644 > --- a/sound/soc/fsl/fsl-asoc-card.c > +++ b/sound/soc/fsl/fsl-asoc-card.c > @@ -680,17 +680,20 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) > goto asrc_fail; > } > > - ret = of_property_read_u32(asrc_np, "fsl,asrc-width", &width); > + ret = of_property_read_u32(asrc_np, "fsl,asrc-format", &priv->asrc_format); > if (ret) { > - dev_err(&pdev->dev, "failed to get output rate\n"); > - ret = -EINVAL; > - goto asrc_fail; > - } > + /* Fallback to old binding; translate to asrc_format */ > + ret = of_property_read_u32(asrc_np, "fsl,asrc-width", &width); > + if (ret) { > + dev_err(&pdev->dev, "failed to get output width\n"); Should warn 'format' over 'width', since it's preferable. > + return ret; Should goto asrc_fail as we did prior to the change. And some of lines are over 80 characters. Let's try this: ret = of_property_read_u32(asrc_np, "fsl,asrc-format", &priv->asrc_format); if (ret) { /* Fallback to old binding; translate to asrc_format */ ret = of_property_read_u32(asrc_np, "fsl,asrc-width", &width); if (ret) { dev_err(&pdev->dev, "failed to decide output format\n"); goto asrc_fail; } if (width == 24) priv->asrc_format = SNDRV_PCM_FORMAT_S24_LE; else priv->asrc_format = SNDRV_PCM_FORMAT_S16_LE; }
Just some small comments. On Wed, Apr 01, 2020 at 04:45:37PM +0800, Shengjiu Wang wrote: > In order to align with new ESARC, we add new property fsl,asrc-format. > The fsl,asrc-format can replace the fsl,asrc-width, driver > can accept format from devicetree, don't need to convert it to > format through width. > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> > --- > sound/soc/fsl/fsl_asrc.c | 40 ++++++++++++++++++++++-------------- > sound/soc/fsl/fsl_asrc.h | 4 ++-- > sound/soc/fsl/fsl_asrc_dma.c | 15 +++++++++++--- > 3 files changed, 39 insertions(+), 20 deletions(-) > > diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c > index 4d3e51bfa949..eea19e2b723b 100644 > --- a/sound/soc/fsl/fsl_asrc.c > +++ b/sound/soc/fsl/fsl_asrc.c > @@ -1052,16 +1047,31 @@ static int fsl_asrc_probe(struct platform_device *pdev) > return ret; > } > > - ret = of_property_read_u32(np, "fsl,asrc-width", > - &asrc->asrc_width); > + ret = of_property_read_u32(np, "fsl,asrc-format", &asrc->asrc_format); > if (ret) { > - dev_err(&pdev->dev, "failed to get output width\n"); > - return ret; > + ret = of_property_read_u32(np, "fsl,asrc-width", &width); > + if (ret) { > + dev_err(&pdev->dev, "failed to get output width\n"); Similar to the comments against sound card driver: "failed to decide output format" > + return ret; > + } > + > + switch (width) { > + case 16: > + asrc->asrc_format = SNDRV_PCM_FORMAT_S16_LE; > + break; > + case 24: > + asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; > + break; > + default: > + dev_warn(&pdev->dev, "unsupported width, switching to 24bit\n"); Should match what the code does after the change: + dev_warn(&pdev->dev, + "unsupported width, use default S24_LE\n"); > + asrc->asrc_format = SNDRV_PCM_FORMAT_S24_LE; > + break; > + } > } > > - if (asrc->asrc_width != 16 && asrc->asrc_width != 24) { > - dev_warn(&pdev->dev, "unsupported width, switching to 24bit\n"); > - asrc->asrc_width = 24; > + if (!(FSL_ASRC_FORMATS & (1ULL << asrc->asrc_format))) { > + dev_warn(&pdev->dev, "unsupported format, switching to S24_LE\n"); Could fit 80 characters: + dev_warn(&pdev->dev, "unsupported width, use default S24_LE\n"); > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > index 5fe83aece25b..b15946e03380 100644 > --- a/sound/soc/fsl/fsl_asrc_dma.c > +++ b/sound/soc/fsl/fsl_asrc_dma.c > @@ -230,10 +230,19 @@ static int fsl_asrc_dma_hw_params(struct snd_soc_component *component, > return -EINVAL; > } > > - if (asrc->asrc_width == 16) > + bits = snd_pcm_format_physical_width(asrc->asrc_format); Can we just use 'width' to match the function name?
On Wed, Apr 01, 2020 at 04:45:38PM +0800, Shengjiu Wang wrote: > static int fsl_asrc_probe(struct platform_device *pdev) > { > struct device_node *np = pdev->dev.of_node; > struct fsl_asrc *asrc; > + struct fsl_asrc_priv *asrc_priv; Could we move it before "struct fsl_asrc *asrc;"? > diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h > new file mode 100644 > index 000000000000..5c93ccdfc30a > --- /dev/null > +++ b/sound/soc/fsl/fsl_asrc_common.h > +#define PAIR_CTX_NUM 0x4 > +#define PAIR_PRIVAT_SIZE 0x400 "PRIVAT_" => "PRIVATE_" > +/** > + * fsl_asrc_pair: ASRC common data "fsl_asrc_pair" => "fsl_asrc" > + */ > +struct fsl_asrc { > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > index b15946e03380..5cf0468ce6e3 100644 > --- a/sound/soc/fsl/fsl_asrc_dma.c > +++ b/sound/soc/fsl/fsl_asrc_dma.c > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > return ret; > } > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the define in this file too, rather than in the header file. And could fit 80 characters: + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL);
On Wed, Apr 01, 2020 at 04:45:40PM +0800, Shengjiu Wang wrote: > EASRC (Enhanced Asynchronous Sample Rate Converter) is a new IP module > found on i.MX8MN. It is different with old ASRC module. > > The primary features for the EASRC are as follows: > - 4 Contexts - groups of channels with an independent time base > - Fully independent and concurrent context control > - Simultaneous processing of up to 32 audio channels > - Programmable filter charachteristics for each context > - 32, 24, 20, and 16-bit fixed point audio sample support > - 32-bit floating point audio sample support > - 8kHz to 384kHz sample rate > - 1/16 to 8x sample rate conversion ratio > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com> > Signed-off-by: Cosmin-Gabriel Samoila <cosmin.samoila@nxp.com> Overall, looks good to me. Please add: Acked-by: Nicolin Chen <nicoleotsuka@gmail.com> > diff --git a/sound/soc/fsl/fsl_easrc.c b/sound/soc/fsl/fsl_easrc.c > +static int fsl_easrc_normalize_filter(struct fsl_asrc *easrc, > + * If exponent is zero (value == 0), or 7ff (value == NaNs) [...] > + if (exp == 0 || exp == 0x7ff) { [...] > + if ((shift > 0 && exp >= 2047) || > + (shift < 0 && exp <= 0)) { Could fit into one line, and would be probably nicer to re-use "0x7ff" matching previous places, instead of "2047".
Hi On Tue, Apr 7, 2020 at 7:50 AM Nicolin Chen <nicoleotsuka@gmail.com> wrote: > > On Wed, Apr 01, 2020 at 04:45:38PM +0800, Shengjiu Wang wrote: > > > static int fsl_asrc_probe(struct platform_device *pdev) > > { > > struct device_node *np = pdev->dev.of_node; > > struct fsl_asrc *asrc; > > + struct fsl_asrc_priv *asrc_priv; > > Could we move it before "struct fsl_asrc *asrc;"? > > > diff --git a/sound/soc/fsl/fsl_asrc_common.h b/sound/soc/fsl/fsl_asrc_common.h > > new file mode 100644 > > index 000000000000..5c93ccdfc30a > > --- /dev/null > > +++ b/sound/soc/fsl/fsl_asrc_common.h > > > +#define PAIR_CTX_NUM 0x4 > > +#define PAIR_PRIVAT_SIZE 0x400 > > "PRIVAT_" => "PRIVATE_" > > > +/** > > + * fsl_asrc_pair: ASRC common data > > "fsl_asrc_pair" => "fsl_asrc" > > > + */ > > +struct fsl_asrc { > > > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > > index b15946e03380..5cf0468ce6e3 100644 > > --- a/sound/soc/fsl/fsl_asrc_dma.c > > +++ b/sound/soc/fsl/fsl_asrc_dma.c > > > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > > return ret; > > } > > > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the > define in this file too, rather than in the header file. > > And could fit 80 characters: > > + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); I will use a function pointer int (*get_pair_priv_size)(void) to avoid definition of PAIR_PRIVATE_SIZE. which is not safe. best regards wang shengjiu
On Sat, Apr 11, 2020 at 01:49:43PM +0800, Shengjiu Wang wrote: > > > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > > > index b15946e03380..5cf0468ce6e3 100644 > > > --- a/sound/soc/fsl/fsl_asrc_dma.c > > > +++ b/sound/soc/fsl/fsl_asrc_dma.c > > > > > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > > > return ret; > > > } > > > > > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > > > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the > > define in this file too, rather than in the header file. > > > > And could fit 80 characters: > > > > + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > I will use a function pointer > int (*get_pair_priv_size)(void) Since it's the size of pair or cts structure, could be just a size_t variable?
On Sun, Apr 12, 2020 at 10:08 AM Nicolin Chen <nicoleotsuka@gmail.com> wrote: > > On Sat, Apr 11, 2020 at 01:49:43PM +0800, Shengjiu Wang wrote: > > > > > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > > > > index b15946e03380..5cf0468ce6e3 100644 > > > > --- a/sound/soc/fsl/fsl_asrc_dma.c > > > > +++ b/sound/soc/fsl/fsl_asrc_dma.c > > > > > > > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > > > > return ret; > > > > } > > > > > > > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > > > > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > > > If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the > > > define in this file too, rather than in the header file. > > > > > > And could fit 80 characters: > > > > > > + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > I will use a function pointer > > int (*get_pair_priv_size)(void) > > Since it's the size of pair or cts structure, could be just a > size_t variable? Yes, should be "size_t (*get_pair_priv_size)(void)" best regards wang shengjiu
On Mon, Apr 13, 2020 at 11:16:31AM +0800, Shengjiu Wang wrote: > On Sun, Apr 12, 2020 at 10:08 AM Nicolin Chen <nicoleotsuka@gmail.com> wrote: > > > > On Sat, Apr 11, 2020 at 01:49:43PM +0800, Shengjiu Wang wrote: > > > > > > > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > > > > > index b15946e03380..5cf0468ce6e3 100644 > > > > > --- a/sound/soc/fsl/fsl_asrc_dma.c > > > > > +++ b/sound/soc/fsl/fsl_asrc_dma.c > > > > > > > > > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > > > > > return ret; > > > > > } > > > > > > > > > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > > > > > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > > > > > If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the > > > > define in this file too, rather than in the header file. > > > > > > > > And could fit 80 characters: > > > > > > > > + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > > I will use a function pointer > > > int (*get_pair_priv_size)(void) > > > > Since it's the size of pair or cts structure, could be just a > > size_t variable? > > Yes, should be "size_t (*get_pair_priv_size)(void)" Does it have to be a function? -- how about this: struct pair { ... size_t private_size; void *private; }; probe/or-somewhere() { ... pair->private = pair_priv; pair->private_size = sizeof(*pair_priv); ... }
On Mon, Apr 13, 2020 at 12:31 PM Nicolin Chen <nicoleotsuka@gmail.com> wrote: > > On Mon, Apr 13, 2020 at 11:16:31AM +0800, Shengjiu Wang wrote: > > On Sun, Apr 12, 2020 at 10:08 AM Nicolin Chen <nicoleotsuka@gmail.com> wrote: > > > > > > On Sat, Apr 11, 2020 at 01:49:43PM +0800, Shengjiu Wang wrote: > > > > > > > > > diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c > > > > > > index b15946e03380..5cf0468ce6e3 100644 > > > > > > --- a/sound/soc/fsl/fsl_asrc_dma.c > > > > > > +++ b/sound/soc/fsl/fsl_asrc_dma.c > > > > > > > > > > > @@ -311,11 +311,12 @@ static int fsl_asrc_dma_startup(struct snd_soc_component *component, > > > > > > return ret; > > > > > > } > > > > > > > > > > > > - pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); > > > > > > + pair = kzalloc(sizeof(struct fsl_asrc_pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > > > > > > > If we only use the PAIR_PRIVATE_SIZE here, maybe we can put the > > > > > define in this file too, rather than in the header file. > > > > > > > > > > And could fit 80 characters: > > > > > > > > > > + pair = kzalloc(sizeof(*pair) + PAIR_PRIVAT_SIZE, GFP_KERNEL); > > > > > > > I will use a function pointer > > > > int (*get_pair_priv_size)(void) > > > > > > Since it's the size of pair or cts structure, could be just a > > > size_t variable? > > > > Yes, should be "size_t (*get_pair_priv_size)(void)" > > Does it have to be a function? -- how about this: > > struct pair { > ... > size_t private_size; > void *private; > }; > > probe/or-somewhere() { > ... > pair->private = pair_priv; we need to know the size of pair_priv before allocate memory. > pair->private_size = sizeof(*pair_priv); > ... > } In fsl_asrc_dma_startup, we need to allocate memory for pair and pair->privateļ¼but we don't know the object, so we don't know the size of private, so function pointer is better. best regards wang shengjiu