* Re: [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function
@ 2019-04-22 3:15 S.j. Wang
2019-04-22 3:23 ` Nicolin Chen
0 siblings, 1 reply; 5+ messages in thread
From: S.j. Wang @ 2019-04-22 3:15 UTC (permalink / raw)
To: Nicolin Chen
Cc: timur, Xiubo.Lee, festevam, broonie, alsa-devel, linuxppc-dev,
linux-kernel
Hi
>
>
> On Mon, Apr 22, 2019 at 02:32:35AM +0000, S.j. Wang wrote:
> > When we want to support more sample rate, for example 12kHz/24kHz
> we
> > need update the process_option table, if we want to support more
> > sample rate next time, the table need to be updated again. which is
> > not flexible.
> >
> > We got a function fsl_asrc_sel_proc to replace the table, which can
> > give the pre-processing and post-processing options according to the
> > sample rate.
> >
> > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
>
> A couple of more small comments.
>
> And please add this when you resend:
> Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
>
> > + * Unsupport cases: Tsout > 8.125 * Tsin, Tsout > 16.125 * Tsin
>
> Since we have a ratio validation somewhere else, it's okay to drop this line -
> - it may confuse people since the function no longer checks these
> unsupported cases.
I add this for may be in the future we forget the limitation. Just for a reminder.
Best regards
Wang shengjiu
>
> > +static int fsl_asrc_sel_proc(int inrate, int outrate,
>
> I think "void" type should be just fine as we made sure there is no
> unsupported cases running in this function.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function
2019-04-22 3:15 [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
@ 2019-04-22 3:23 ` Nicolin Chen
0 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-04-22 3:23 UTC (permalink / raw)
To: S.j. Wang
Cc: timur, Xiubo.Lee, festevam, broonie, alsa-devel, linuxppc-dev,
linux-kernel
On Mon, Apr 22, 2019 at 03:15:34AM +0000, S.j. Wang wrote:
> Hi
>
> >
> >
> > On Mon, Apr 22, 2019 at 02:32:35AM +0000, S.j. Wang wrote:
> > > When we want to support more sample rate, for example 12kHz/24kHz
> > we
> > > need update the process_option table, if we want to support more
> > > sample rate next time, the table need to be updated again. which is
> > > not flexible.
> > >
> > > We got a function fsl_asrc_sel_proc to replace the table, which can
> > > give the pre-processing and post-processing options according to the
> > > sample rate.
> > >
> > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> >
> > A couple of more small comments.
> >
> > And please add this when you resend:
> > Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
> >
> > > + * Unsupport cases: Tsout > 8.125 * Tsin, Tsout > 16.125 * Tsin
> >
> > Since we have a ratio validation somewhere else, it's okay to drop this line -
> > - it may confuse people since the function no longer checks these
> > unsupported cases.
>
> I add this for may be in the future we forget the limitation. Just for a reminder.
Okay. Let's use something more practical like:
+* Make sure to exclude following unsupported cases before calling the function:
+* 1) outrate > 8.125 * inrate
+* 2) outrate > 16.125 * inrate
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function
@ 2019-04-22 3:34 S.j. Wang
0 siblings, 0 replies; 5+ messages in thread
From: S.j. Wang @ 2019-04-22 3:34 UTC (permalink / raw)
To: Nicolin Chen
Cc: timur, Xiubo.Lee, festevam, broonie, alsa-devel, linuxppc-dev,
linux-kernel
Hi
>
>
> On Mon, Apr 22, 2019 at 03:15:34AM +0000, S.j. Wang wrote:
> > Hi
> >
> > >
> > >
> > > On Mon, Apr 22, 2019 at 02:32:35AM +0000, S.j. Wang wrote:
> > > > When we want to support more sample rate, for example
> 12kHz/24kHz
> > > we
> > > > need update the process_option table, if we want to support more
> > > > sample rate next time, the table need to be updated again. which
> > > > is not flexible.
> > > >
> > > > We got a function fsl_asrc_sel_proc to replace the table, which
> > > > can give the pre-processing and post-processing options according
> > > > to the sample rate.
> > > >
> > > > Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> > >
> > > A couple of more small comments.
> > >
> > > And please add this when you resend:
> > > Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
> > >
> > > > + * Unsupport cases: Tsout > 8.125 * Tsin, Tsout > 16.125 * Tsin
> > >
> > > Since we have a ratio validation somewhere else, it's okay to drop
> > > this line -
> > > - it may confuse people since the function no longer checks these
> > > unsupported cases.
> >
> > I add this for may be in the future we forget the limitation. Just for a
> reminder.
>
> Okay. Let's use something more practical like:
>
> +* Make sure to exclude following unsupported cases before calling the
> function:
> +* 1) outrate > 8.125 * inrate
> +* 2) outrate > 16.125 * inrate
Ok.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function
2019-04-22 2:32 ` [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
@ 2019-04-22 2:57 ` Nicolin Chen
0 siblings, 0 replies; 5+ messages in thread
From: Nicolin Chen @ 2019-04-22 2:57 UTC (permalink / raw)
To: S.j. Wang
Cc: timur, Xiubo.Lee, festevam, broonie, alsa-devel, linuxppc-dev,
linux-kernel
On Mon, Apr 22, 2019 at 02:32:35AM +0000, S.j. Wang wrote:
> When we want to support more sample rate, for example 12kHz/24kHz
> we need update the process_option table, if we want to support more
> sample rate next time, the table need to be updated again. which
> is not flexible.
>
> We got a function fsl_asrc_sel_proc to replace the table, which can
> give the pre-processing and post-processing options according to
> the sample rate.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
A couple of more small comments.
And please add this when you resend:
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
> + * Unsupport cases: Tsout > 8.125 * Tsin, Tsout > 16.125 * Tsin
Since we have a ratio validation somewhere else, it's okay to
drop this line -- it may confuse people since the function no
longer checks these unsupported cases.
> +static int fsl_asrc_sel_proc(int inrate, int outrate,
I think "void" type should be just fine as we made sure there
is no unsupported cases running in this function.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function
2019-04-22 2:32 [PATCH V5 0/3] Support more sample rate in asrc S.j. Wang
@ 2019-04-22 2:32 ` S.j. Wang
2019-04-22 2:57 ` Nicolin Chen
0 siblings, 1 reply; 5+ messages in thread
From: S.j. Wang @ 2019-04-22 2:32 UTC (permalink / raw)
To: timur, nicoleotsuka, Xiubo.Lee, festevam, broonie, alsa-devel
Cc: linuxppc-dev, linux-kernel
When we want to support more sample rate, for example 12kHz/24kHz
we need update the process_option table, if we want to support more
sample rate next time, the table need to be updated again. which
is not flexible.
We got a function fsl_asrc_sel_proc to replace the table, which can
give the pre-processing and post-processing options according to
the sample rate.
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
---
sound/soc/fsl/fsl_asrc.c | 70 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 50 insertions(+), 20 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c
index ea035c12a325..4675ea4e8204 100644
--- a/sound/soc/fsl/fsl_asrc.c
+++ b/sound/soc/fsl/fsl_asrc.c
@@ -26,24 +26,6 @@
#define pair_dbg(fmt, ...) \
dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__)
-/* Sample rates are aligned with that defined in pcm.h file */
-static const u8 process_option[][12][2] = {
- /* 8kHz 11.025kHz 16kHz 22.05kHz 32kHz 44.1kHz 48kHz 64kHz 88.2kHz 96kHz 176kHz 192kHz */
- {{0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 5512Hz */
- {{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 8kHz */
- {{0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 11025Hz */
- {{1, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 16kHz */
- {{1, 2}, {1, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 22050Hz */
- {{1, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0},}, /* 32kHz */
- {{2, 2}, {2, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 44.1kHz */
- {{2, 2}, {2, 2}, {2, 1}, {2, 1}, {0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 48kHz */
- {{2, 2}, {2, 2}, {2, 2}, {2, 1}, {1, 2}, {0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0},}, /* 64kHz */
- {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 88.2kHz */
- {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 96kHz */
- {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 176kHz */
- {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 192kHz */
-};
-
/* Corresponding to process_option */
static int supported_input_rate[] = {
5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200,
@@ -80,6 +62,51 @@
static unsigned char *clk_map[2];
/**
+ * Select the pre-processing and post-processing options
+ * Unsupport cases: Tsout > 8.125 * Tsin, Tsout > 16.125 * Tsin
+ *
+ * inrate: input sample rate
+ * outrate: output sample rate
+ * pre_proc: return value for pre-processing option
+ * post_proc: return value for post-processing option
+ */
+static int fsl_asrc_sel_proc(int inrate, int outrate,
+ int *pre_proc, int *post_proc)
+{
+ bool post_proc_cond2;
+ bool post_proc_cond0;
+
+ /* select pre_proc between [0, 2] */
+ if (inrate * 8 > 33 * outrate)
+ *pre_proc = 2;
+ else if (inrate * 8 > 15 * outrate) {
+ if (inrate > 152000)
+ *pre_proc = 2;
+ else
+ *pre_proc = 1;
+ } else if (inrate < 76000)
+ *pre_proc = 0;
+ else if (inrate > 152000)
+ *pre_proc = 2;
+ else
+ *pre_proc = 1;
+
+ /* Condition for selection of post-processing */
+ post_proc_cond2 = (inrate * 15 > outrate * 16 && outrate < 56000) ||
+ (inrate > 56000 && outrate < 56000);
+ post_proc_cond0 = inrate * 23 < outrate * 8;
+
+ if (post_proc_cond2)
+ *post_proc = 2;
+ else if (post_proc_cond0)
+ *post_proc = 0;
+ else
+ *post_proc = 1;
+
+ return 0;
+}
+
+/**
* Request ASRC pair
*
* It assigns pair by the order of A->C->B because allocation of pair B,
@@ -239,6 +266,7 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
u32 inrate, outrate, indiv, outdiv;
u32 clk_index[2], div[2];
int in, out, channels;
+ int pre_proc, post_proc;
struct clk *clk;
bool ideal;
@@ -377,11 +405,13 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair)
ASRCTR_IDRi_MASK(index) | ASRCTR_USRi_MASK(index),
ASRCTR_IDR(index) | ASRCTR_USR(index));
+ fsl_asrc_sel_proc(inrate, outrate, &pre_proc, &post_proc);
+
/* Apply configurations for pre- and post-processing */
regmap_update_bits(asrc_priv->regmap, REG_ASRCFG,
ASRCFG_PREMODi_MASK(index) | ASRCFG_POSTMODi_MASK(index),
- ASRCFG_PREMOD(index, process_option[in][out][0]) |
- ASRCFG_POSTMOD(index, process_option[in][out][1]));
+ ASRCFG_PREMOD(index, pre_proc) |
+ ASRCFG_POSTMOD(index, post_proc));
return fsl_asrc_set_ideal_ratio(pair, inrate, outrate);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-22 3:34 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-22 3:15 [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
2019-04-22 3:23 ` Nicolin Chen
-- strict thread matches above, loose matches on Subject: below --
2019-04-22 3:34 S.j. Wang
2019-04-22 2:32 [PATCH V5 0/3] Support more sample rate in asrc S.j. Wang
2019-04-22 2:32 ` [PATCH V5 2/3] ASoC: fsl_asrc: replace the process_option table with function S.j. Wang
2019-04-22 2:57 ` Nicolin Chen
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).