Re: [PATCH 2/2] ASoC: codec: mediatek: add mt6359 codec driver

From: Mark Brown
Date: Thu Mar 12 2020 - 15:08:10 EST


On Thu, Mar 12, 2020 at 02:43:07PM +0800, Eason Yen wrote:
> On Wed, 2020-03-11 at 12:12 +0000, Mark Brown wrote:
> > On Wed, Mar 11, 2020 at 05:22:24PM +0800, Eason Yen wrote:
> > > On Mon, 2020-03-09 at 13:13 +0000, Mark Brown wrote:

> > > The following functions are used to set:
> > > - playback_gpio_set/playback_gpio_reset
> > > - capture_gpio_set/capture_gpio_reset
> > > - vow_gpio_set/vow_gpio_reset

> > This sounds like it should be handled at the machine driver level, it's
> > possible some system integrator will wire things up differently.

> machine driver will set default at booting stage to execute
> mt6359_mtkaif_calibration_enable and mt6359_mtkaif_calibration_disable.

> And at runtime stage, it is triggered by mt_dl_gpio_event and
> mt_ul_gpio_event while playback or capture.

What I'm suggesting is moving those to the machine driver (you could
provide helpers in the CODEC driver for the common case I guess... I'd
need to review).

> OK. So it is better to fix mic_type (ACC/DMIC/DCC/DCC_*) at init stage
> because it will not be changed at runtime.

> And use another dpam mux or kcontrol to enable/disable vow for low power
> scenario.

> Is it right?

Yes.

> enum {
> LO_MUX_OPEN = 0,
> LO_MUX_L_DAC,
> LO_MUX_3RD_DAC,
> LO_MUX_TEST_MODE,
> LO_MUX_MASK = 0x3,
> };
>
> static const char * const lo_in_mux_map[] = {
> "Open", "Playback_L_DAC", "Playback", "Test Mode"
> };
>
> static SOC_ENUM_SINGLE_DECL(lo_in_mux_map_enum,
> SND_SOC_NOPM, 0, lo_in_mux_map);
>
> static const struct snd_kcontrol_new lo_in_mux_control =
> SOC_DAPM_ENUM("LO Select", lo_in_mux_map_enum);

That looks OK.

> > > > > +static int mt_delay_250_event(struct snd_soc_dapm_widget *w,
> > > > > + struct snd_kcontrol *kcontrol,
> > > > > + int event)
> > > > > +{
> > > > > + switch (event) {
> > > > > + case SND_SOC_DAPM_POST_PMU:
> > > > > + case SND_SOC_DAPM_PRE_PMD:
> > > > > + usleep_range(250, 270);

> > > > Why would having a sleep before power down be useful?

> > > It is based on designer's control sequence to add some delay while
> > > PMU/PMD.

> > But how does the designer know when the sequence starts? Don't they
> > mean to have a delay *after* power down?

> For PMU, designer think
> "AUD_CK" --> wait at least 250ms --> "AUDIF_CK" --> next ...

> For PMD, designer think
> "AUDIF_CK" --> wait at least 250ms --> "AUD_CK" --> next ...

I think you need some comments about this in the code, it looks like a
mistake - it relies on the use of sequenced widgets, you should
reference that.

Attachment: signature.asc
Description: PGP signature