linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2 0/2] Support more sample rate in asrc
@ 2019-04-11  9:39 S.j. Wang
  2019-04-11  9:39 ` [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
  2019-04-11  9:39 ` [PATCH V2 2/2] ASoC: fsl_asrc: Unify the supported input and output rate S.j. Wang
  0 siblings, 2 replies; 7+ messages in thread
From: S.j. Wang @ 2019-04-11  9:39 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, alsa-devel
  Cc: linuxppc-dev, linux-kernel

Support more sample rate in asrc

Shengjiu Wang (2):
  ASoC: fsl_asrc: replace the process_option table with function
  ASoC: fsl_asrc: Unify the supported input and output rate

Changes in v2
- add more comments in code
- add commit "Unify the supported input and output rate"

 sound/soc/fsl/fsl_asrc.c | 116 ++++++++++++++++++++++++++++++++++-------------
 1 file changed, 85 insertions(+), 31 deletions(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 7+ messages in thread
* Re: [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function
@ 2019-04-17  9:04 S.j. Wang
  0 siblings, 0 replies; 7+ messages in thread
From: S.j. Wang @ 2019-04-17  9:04 UTC (permalink / raw)
  To: Nicolin Chen
  Cc: timur, Xiubo.Lee, festevam, broonie, alsa-devel, linuxppc-dev,
	linux-kernel

Hi

> 
> 
> On Thu, Apr 11, 2019 at 09:39:06AM +0000, S.j. Wang wrote:
> 
> > +/*
> > + * Select the pre-processing and post-processing options
> 
> By aligning with other function comments:
> /**
>  * Select the pre-processing and post-processing options
> 
> > + *
> > + * Fsin: input sample rate
> > + * Fsout: output sample rate
> 
> I would suggest to use inrate and outrate to keep naming consistent.
> 
> > + * pre_proc: return value for pre-processing option
> > + * post_proc: return value for post-processing option  */ static int
> > +fsl_asrc_sel_proc(int Fsin, int Fsout, int *pre_proc, int *post_proc)
> > +{
> > +     bool det_out_op2_cond;
> > +     bool det_out_op0_cond;
> 
> By looking at the comments below. Probably better to rename them
>         bool post_proc_cond2, post_proc_cond0;
> 
> > +     /* Codition for selection of post-processing */
> 
> "Codition" -> "Conditions"
> 
> > +     det_out_op2_cond = (((Fsin * 15 > Fsout * 16) & (Fsout < 56000)) |
> > +                                     ((Fsin > 56000) & (Fsout <
> > + 56000)));
> 
> Combining Daniel's comments + indentation alignment:
>         det_out_op2_cond = (Fsin * 15 > Fsout * 16 && Fsout < 56000) ||
>                            (Fsin > 56000 && Fsout < 56000);
> 
> > +     det_out_op0_cond = (Fsin * 23 < Fsout * 8);
> > +
> > +     /*
> > +      * unsupported case: Tsout>16.125*Tsin, and Tsout>8.125*Tsin.
> 
> Funny thing is that there'd be no point in checking the 16.125, if Tsout is
> bigger than 8.125 times of Tsin, i.e. only one condition:
>         Tsout > 8.125 * Tsin
> 
> > +      * Tsout>16.125*Tsin -> Fsin * 8 > 129 * Fsout
> > +      * Tsout>8.125*Tsin  -> Fsin * 8 > 65 * Fsout
> > +      * Tsout>4.125*Tsin  -> Fsin * 8 > 33 * Fsout
> > +      * Tsout>1.875*Tsin  -> Fsin * 8 > 15 * Fsout
> 
> Took me a while to understand what it is saying....
> 
> Better to write like this:
>         /* Does not support cases: Tsout > 8.125 * Tsin */
>         if (Fsin * 8 > 65 * Fsout) {
>                 pair_err("Does not support %d > 8.125 * %d\n", Fsout, Fsin);
>                 return -EINVAL;
>         }
> 
>         /* Otherwise, select pre_proc between [0, 2] */
>         if (Fsin * 8 > 33 * Fsout)
> > +             *pre_proc = 2;
> > +     else if (Fsin * 8 > 15 * Fsout) {
> > +             if (Fsin > 152000)
> > +                     *pre_proc = 2;
> > +             else
> > +                     *pre_proc = 1;
> > +     } else if (Fsin < 76000)
> > +             *pre_proc = 0;
> > +     else if (Fsin > 152000)
> > +             *pre_proc = 2;
> > +     else
> > +             *pre_proc = 1;
> 
> <== Would look better by moving post_cond calculations here.
> 
> > +     if (det_out_op2_cond)
> > +             *post_proc = 2;
> > +     else if (det_out_op0_cond)
> > +             *post_proc = 0;
> > +     else
> > +             *post_proc = 1;
> 
> And we could remove this check below:
> > +     /* unsupported options */
> > +     if (*pre_proc == 4 || *pre_proc == 5)
> > +             return -EINVAL;
> 
> So basically we are doing:
>         1) Error out unsupported cases
>         2) Select pre_proc
>         3) Calculate conditions for post_proc
>         4) Select post_proc
> 
> Thanks

Thanks for reviewing, will send v3.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-04-17  9:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-11  9:39 [PATCH V2 0/2] Support more sample rate in asrc S.j. Wang
2019-04-11  9:39 ` [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
2019-04-11 11:15   ` Daniel Baluta
2019-04-11 20:06   ` Nicolin Chen
2019-04-11  9:39 ` [PATCH V2 2/2] ASoC: fsl_asrc: Unify the supported input and output rate S.j. Wang
2019-04-11 20:11   ` Nicolin Chen
2019-04-17  9:04 [PATCH V2 1/2] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).