All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
@ 2016-05-31  8:43 Pietro
  2016-05-31 12:29 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Pietro @ 2016-05-31  8:43 UTC (permalink / raw)
  To: alsa-devel

Hi,
 
I'm an owner of a 2 in 1 Netbook with an Atom X5 Z8300 SoC with rt5651 codec (Cube iWork 11).
 
To get audio working I Added these lines of code to the ./soc/intel/atom/sst/sst_acpi.c file:
 
--- ./soc/intel/atom/sst/sst_acpi.c.old 2016-05-31 09:05:40.045682194 +0200
+++ ./soc/intel/atom/sst/sst_acpi.c     2016-05-31 09:07:26.829324148 +0200
@@ -342,9 +342,12 @@
                                                &chv_platform_data },
        {"193C9890", "cht-bsw-max98090", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
                                                &chv_platform_data },
+       {"10EC5651", "bytcr_rt5651", "intel/fw_sst_0f28.bin", "bytcr_rt5651", NULL,
+                                               &byt_rvp_platform_data },
        {},
 };
 
+
 static const struct acpi_device_id sst_acpi_ids[] = {
        { "80860F28", (unsigned long)&sst_acpi_bytcr},
        { "808622A8", (unsigned long) &sst_acpi_chv},
 
 
 
 
Then i added the UCM files linked in these archive:
https://github.com/plbossart/UCM/tree/master/bytcr-rt5651 
 
 
 
With this configuration, audio seems to work, but is 'slow': Playback speed is at slow motion, and seconds move slowly (Tried with aplay and audacious with many sound files, using directly Alsa and Pulseaudio with no differencies).
 
This seems to be a DSP Clock problem. Have you got any suggestions to solve this problem?
 
Thanks,
Pietro

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31  8:43 Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree Pietro
@ 2016-05-31 12:29 ` Pierre-Louis Bossart
  2016-05-31 20:11   ` Pietro
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2016-05-31 12:29 UTC (permalink / raw)
  To: Pietro, alsa-devel

On 5/31/16 3:43 AM, Pietro wrote:
> Hi,
>
> I'm an owner of a 2 in 1 Netbook with an Atom X5 Z8300 SoC with rt5651 codec (Cube iWork 11).
>
> To get audio working I Added these lines of code to the ./soc/intel/atom/sst/sst_acpi.c file:
>
> --- ./soc/intel/atom/sst/sst_acpi.c.old 2016-05-31 09:05:40.045682194 +0200
> +++ ./soc/intel/atom/sst/sst_acpi.c     2016-05-31 09:07:26.829324148 +0200
> @@ -342,9 +342,12 @@
>                                                 &chv_platform_data },
>         {"193C9890", "cht-bsw-max98090", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
>                                                 &chv_platform_data },
> +       {"10EC5651", "bytcr_rt5651", "intel/fw_sst_0f28.bin", "bytcr_rt5651", NULL,
> +                                               &byt_rvp_platform_data },
>         {},
>  };

use the same as for rt5640 on cht:

/* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
{"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", 
NULL, &chv_platform_data },

>
> +
>  static const struct acpi_device_id sst_acpi_ids[] = {
>         { "80860F28", (unsigned long)&sst_acpi_bytcr},
>         { "808622A8", (unsigned long) &sst_acpi_chv},
>
>
>
>
> Then i added the UCM files linked in these archive:
> https://github.com/plbossart/UCM/tree/master/bytcr-rt5651
>
>
>
> With this configuration, audio seems to work, but is 'slow': Playback speed is at slow motion, and seconds move slowly (Tried with aplay and audacious with many sound files, using directly Alsa and Pulseaudio with no differencies).
>
> This seems to be a DSP Clock problem. Have you got any suggestions to solve this problem?

we've had this report before with rt5640 but it's unclear what might 
cause this. the codec is configured as slave and uses the bit clock as 
source for its PLL.
the easiest fix in this case would be to use the 19.2 MCLK which is 
enabled by default on CHT, see examples in cht-bsw-rt5645 (look at 
platform clock control and everything with set_sys_clk, but keep the 2 
slots). We will add this on baytrail as well at some point when we have 
a clock framework driver for the MCLK control.

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31 12:29 ` Pierre-Louis Bossart
@ 2016-05-31 20:11   ` Pietro
  2016-05-31 20:27     ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Pietro @ 2016-05-31 20:11 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel

Hi,

Thanks for your reply.

I've tried to change the fw from fw_sst_0f28 to fw_sst_22a8, but I got an error -16 (obviously the firmware is present :) )

Anyway I followed your suggestions and patched bytcr_rt5651.c this way:

--- bytcr_rt5651.c.old  2016-05-31 22:00:46.424790660 +0200
+++ bytcr_rt5651.c      2016-05-31 21:56:25.908502708 +0200
@@ -31,11 +31,76 @@
 #include "../../codecs/rt5651.h"
 #include "../atom/sst-atom-controls.h"
 
+#define CHT_PLAT_CLK_3_HZ       19200000
+#define CHT_CODEC_DAI_5651   "rt5651-aif1"
+
+struct cht_acpi_card {
+        char *codec_id;
+        int codec_type;
+        struct snd_soc_card *soc_card;
+};
+
+struct cht_mc_private {
+        struct snd_soc_jack jack;
+        struct cht_acpi_card *acpi_card;
+};
+--- bytcr_rt5651.c.old  2016-05-31 22:00:46.424790660 +0200
+++ bytcr_rt5651.c      2016-05-31 21:56:25.908502708 +0200
@@ -31,11 +31,76 @@
 #include "../../codecs/rt5651.h"
 #include "../atom/sst-atom-controls.h"
 
+#define CHT_PLAT_CLK_3_HZ       19200000
+#define CHT_CODEC_DAI_5651   "rt5651-aif1"
+
+struct cht_acpi_card {
+        char *codec_id;
+        int codec_type;
+        struct snd_soc_card *soc_card;
+};
+
+struct cht_mc_private {
+        struct snd_soc_jack jack;
+        struct cht_acpi_card *acpi_card;
+};
+
+
+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
+{
+        struct snd_soc_pcm_runtime *rtd;
+
+        list_for_each_entry(rtd, &card->rtd_list, list) {
+                if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI_5651,
+                             strlen(CHT_CODEC_DAI_5651)))
+                        return rtd->codec_dai;
+        }
+        return NULL;
+}
+
+static int platform_clock_control(struct snd_soc_dapm_widget *w,
+                struct snd_kcontrol *k, int  event)
+{
+        struct snd_soc_dapm_context *dapm = w->dapm;
+        struct snd_soc_card *card = dapm->card;
+        struct snd_soc_dai *codec_dai;
+        int ret;
+
+        codec_dai = cht_get_codec_dai(card);
+        if (!codec_dai) {
+                dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
+                return -EIO;
+        }
+
+        if (!SND_SOC_DAPM_EVENT_OFF(event))
+                return 0;
+
+        /* Set codec sysclk source to its internal clock because codec PLL will
+         * be off when idle and MCLK will also be off by ACPI when codec is
+         * runtime suspended. Codec needs clock for jack detection and button
+         * press.
+         */
+        ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_RCCLK,
+                        0, SND_SOC_CLOCK_IN);
+        if (ret < 0) {
+                dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+                return ret;
+        }
+
+        return 0;
+}
+
+
+
+
 static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = {
        SND_SOC_DAPM_HP("Headphone", NULL),
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
        SND_SOC_DAPM_MIC("Internal Mic", NULL),
        SND_SOC_DAPM_SPK("Speaker", NULL),
+        SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
+                        platform_clock_control, SND_SOC_DAPM_POST_PMD),
+
 };
 
 static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
@@ -52,6 +117,9 @@
        {"Headphone", NULL, "HPOR"},
        {"Speaker", NULL, "LOUTL"},
        {"Speaker", NULL, "LOUTR"},
+        {"Headphone", NULL, "Platform Clock"},
+       {"Speaker", NULL, "Platform Clock"},
+
 };
 
 static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic1_map[] = {
@@ -93,7 +161,15 @@
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        int ret;
 
-       snd_soc_dai_set_bclk_ratio(codec_dai, 50);
+        /* set codec PLL source to the 19.2MHz platform clock (MCLK) */
+        ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_MCLK,
+                                  CHT_PLAT_CLK_3_HZ, params_rate(params) * 512);
+        if (ret < 0) {
+                dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
+                return ret;
+        }
+
+//     snd_soc_dai_set_bclk_ratio(codec_dai, 50);
 
        ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1,
                                     params_rate(params) * 512,
@@ -103,13 +179,13 @@
                return ret;
        }
 
-       ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
-                                 params_rate(params) * 50,
-                                 params_rate(params) * 512);
-       if (ret < 0) {
-               dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
-               return ret;
-       }
+//     ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
+//                               params_rate(params) * 50,
+//                               params_rate(params) * 512);
+//     if (ret < 0) {
+//             dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
+//             return ret;
+//     }
 
        return 0;
 }

+
+static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
+{
+        struct snd_soc_pcm_runtime *rtd;
+
+        list_for_each_entry(rtd, &card->rtd_list, list) {
+                if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI_5651,
+                             strlen(CHT_CODEC_DAI_5651)))
+                        return rtd->codec_dai;
+        }
+        return NULL;
+}
+
+static int platform_clock_control(struct snd_soc_dapm_widget *w,
+                struct snd_kcontrol *k, int  event)
+{
+        struct snd_soc_dapm_context *dapm = w->dapm;
+        struct snd_soc_card *card = dapm->card;
+        struct snd_soc_dai *codec_dai;
+        int ret;
+
+        codec_dai = cht_get_codec_dai(card);
+        if (!codec_dai) {
+                dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
+                return -EIO;
+        }
+
+        if (!SND_SOC_DAPM_EVENT_OFF(event))
+                return 0;
+
+        /* Set codec sysclk source to its internal clock because codec PLL will
+         * be off when idle and MCLK will also be off by ACPI when codec is
+         * runtime suspended. Codec needs clock for jack detection and button
+         * press.
+         */
+        ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_RCCLK,
+                        0, SND_SOC_CLOCK_IN);
+        if (ret < 0) {
+                dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
+                return ret;
+        }
+
+        return 0;
+}
+
+
+
+
 static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = {
        SND_SOC_DAPM_HP("Headphone", NULL),
        SND_SOC_DAPM_MIC("Headset Mic", NULL),
        SND_SOC_DAPM_MIC("Internal Mic", NULL),
        SND_SOC_DAPM_SPK("Speaker", NULL),
+        SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
+                        platform_clock_control, SND_SOC_DAPM_POST_PMD),
+
 };
 
 static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
@@ -52,6 +117,9 @@
        {"Headphone", NULL, "HPOR"},
        {"Speaker", NULL, "LOUTL"},
        {"Speaker", NULL, "LOUTR"},
+        {"Headphone", NULL, "Platform Clock"},
+       {"Speaker", NULL, "Platform Clock"},
+
 };
 
 static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic1_map[] = {
@@ -93,7 +161,15 @@
        struct snd_soc_dai *codec_dai = rtd->codec_dai;
        int ret;
 
-       snd_soc_dai_set_bclk_ratio(codec_dai, 50);
+        /* set codec PLL source to the 19.2MHz platform clock (MCLK) */
+        ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_MCLK,
+                                  CHT_PLAT_CLK_3_HZ, params_rate(params) * 512);
+        if (ret < 0) {
+                dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
+                return ret;
+        }
+
+//     snd_soc_dai_set_bclk_ratio(codec_dai, 50);
 
        ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1,
                                     params_rate(params) * 512,
@@ -103,13 +179,13 @@
                return ret;
        }
 
-       ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
-                                 params_rate(params) * 50,
-                                 params_rate(params) * 512);
-       if (ret < 0) {
-               dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
-               return ret;
-       }
+//     ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
+//                               params_rate(params) * 50,
+//                               params_rate(params) * 512);
+//     if (ret < 0) {
+//             dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
+//             return ret;
+//     }
 
        return 0;
 }


But I still have the same problem: Audio plays slowly.

It seems the DSP is clocked at 19.2, but the system is still clocked for 25, and these changes doesn't seem to have effects...


On Tuesday 31 May 2016 07:29:19 Pierre-Louis Bossart wrote:
> On 5/31/16 3:43 AM, Pietro wrote:
> > Hi,
> >
> > I'm an owner of a 2 in 1 Netbook with an Atom X5 Z8300 SoC with rt5651 codec (Cube iWork 11).
> >
> > To get audio working I Added these lines of code to the ./soc/intel/atom/sst/sst_acpi.c file:
> >
> > --- ./soc/intel/atom/sst/sst_acpi.c.old 2016-05-31 09:05:40.045682194 +0200
> > +++ ./soc/intel/atom/sst/sst_acpi.c     2016-05-31 09:07:26.829324148 +0200
> > @@ -342,9 +342,12 @@
> >                                                 &chv_platform_data },
> >         {"193C9890", "cht-bsw-max98090", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
> >                                                 &chv_platform_data },
> > +       {"10EC5651", "bytcr_rt5651", "intel/fw_sst_0f28.bin", "bytcr_rt5651", NULL,
> > +                                               &byt_rvp_platform_data },
> >         {},
> >  };
> 
> use the same as for rt5640 on cht:
> 
> /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
> {"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", 
> NULL, &chv_platform_data },
> 
> >
> > +
> >  static const struct acpi_device_id sst_acpi_ids[] = {
> >         { "80860F28", (unsigned long)&sst_acpi_bytcr},
> >         { "808622A8", (unsigned long) &sst_acpi_chv},
> >
> >
> >
> >
> > Then i added the UCM files linked in these archive:
> > https://github.com/plbossart/UCM/tree/master/bytcr-rt5651
> >
> >
> >
> > With this configuration, audio seems to work, but is 'slow': Playback speed is at slow motion, and seconds move slowly (Tried with aplay and audacious with many sound files, using directly Alsa and Pulseaudio with no differencies).
> >
> > This seems to be a DSP Clock problem. Have you got any suggestions to solve this problem?
> 
> we've had this report before with rt5640 but it's unclear what might 
> cause this. the codec is configured as slave and uses the bit clock as 
> source for its PLL.
> the easiest fix in this case would be to use the 19.2 MCLK which is 
> enabled by default on CHT, see examples in cht-bsw-rt5645 (look at 
> platform clock control and everything with set_sys_clk, but keep the 2 
> slots). We will add this on baytrail as well at some point when we have 
> a clock framework driver for the MCLK control.
> 

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31 20:11   ` Pietro
@ 2016-05-31 20:27     ` Pierre-Louis Bossart
  2016-05-31 20:56       ` Pietro
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2016-05-31 20:27 UTC (permalink / raw)
  To: Pietro; +Cc: alsa-devel

the changes look ok
>
> But I still have the same problem: Audio plays slowly.
>
>
>
> It seems the DSP is clocked at 19.2, but the system is still clocked for
> 25, and these changes doesn't seem to have effects...

no, CHT doesn't have a 25 MHz clock at all so that's just not physically 
possible.

Can you try:
- tracing to make sure you are actually on a CHT device
- pastebin dmesg somewhere
- sudo cat /sys/bus/acpi/devices/10EC5651:01/status
- enabling DSP loopbacks to see if the DSP consumes data at the right 
rate. look at the UCM file and change
cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on
if you record and loopback on USB output this should play at the right 
speed.

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31 20:27     ` Pierre-Louis Bossart
@ 2016-05-31 20:56       ` Pietro
  2016-05-31 22:26         ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Pietro @ 2016-05-31 20:56 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel

Hi,
Here are the answers:

- tracing to make sure you are actually on a CHT device
  The device should be CHT (The processor is an Atom X3-Z8300). Can it be that the processor is an X3 series, but the platform is BT and not a CHT? I know many manifacturers simply upgraded their notebooks series from BT to CHT by changing the CPU and mantaining all the other components the same (For example the Audio codec).
  How can I trace this?

- pastebin dmesg somewhere
  Here is it: http://pastebin.com/FnpAD1kg

- sudo cat /sys/bus/acpi/devices/10EC5651:01/status
  Here are the results:
  /sys/bus/acpi/devices/10EC5651:00/status 
    Returns 15

  /sys/bus/acpi/devices/10EC5651:01/status 
    Returns 0

- enabling DSP loopbacks to see if the DSP consumes data at the right  rate. look at the UCM file and change cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on if you record and loopback on USB output this should play at the right speed.
  I've changed the value in the HiFi file, but no changes.
  How can i enable DSP loopbacks? I'm not an alsa developer so I need some help here :)

Please let me know if you need other informations.

On Tuesday 31 May 2016 15:27:45 Pierre-Louis Bossart wrote:
> the changes look ok
> >
> > But I still have the same problem: Audio plays slowly.
> >
> >
> >
> > It seems the DSP is clocked at 19.2, but the system is still clocked for
> > 25, and these changes doesn't seem to have effects...
> 
> no, CHT doesn't have a 25 MHz clock at all so that's just not physically 
> possible.
> 
> Can you try:
> - tracing to make sure you are actually on a CHT device
> - pastebin dmesg somewhere
> - sudo cat /sys/bus/acpi/devices/10EC5651:01/status
> - enabling DSP loopbacks to see if the DSP consumes data at the right 
> rate. look at the UCM file and change
> cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on
> if you record and loopback on USB output this should play at the right 
> speed.
> 
> 
> 

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31 20:56       ` Pietro
@ 2016-05-31 22:26         ` Pierre-Louis Bossart
  2016-06-01  8:38           ` Pietro
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2016-05-31 22:26 UTC (permalink / raw)
  To: Pietro; +Cc: alsa-devel

On 5/31/16 3:56 PM, Pietro wrote:
> Hi,
> Here are the answers:
>
> - tracing to make sure you are actually on a CHT device
>   The device should be CHT (The processor is an Atom X3-Z8300). Can it be that the processor is an X3 series, but the platform is BT and not a CHT? I know many manifacturers simply upgraded their notebooks series from BT to CHT by changing the CPU and mantaining all the other components the same (For example the Audio codec).
>   How can I trace this?

you see a lot of references to cherrytrail-cr and 22A8, the right ID.
>
> - pastebin dmesg somewhere
>   Here is it: http://pastebin.com/FnpAD1kg

You have lots of errors or warnings in there. Not sure why, i have 
machines that don't behave as badly.

I am not sure why using the CHT firmware leads to an error, somehow you 
probably have a combination of issues. I would really start there, if 
the regular firmware doesn't work for you something is very wrong.

> - sudo cat /sys/bus/acpi/devices/10EC5651:01/status
>   Here are the results:
>   /sys/bus/acpi/devices/10EC5651:00/status
>     Returns 15

this matches what the machine driver expects so that's good.
>
>   /sys/bus/acpi/devices/10EC5651:01/status
>     Returns 0
>
> - enabling DSP loopbacks to see if the DSP consumes data at the right  rate. look at the UCM file and change cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on if you record and loopback on USB output this should play at the right speed.
>   I've changed the value in the HiFi file, but no changes.
>   How can i enable DSP loopbacks? I'm not an alsa developer so I need some help here :)

you need to record to enable the loopback while you play...
>
> Please let me know if you need other informations.

can you extract the DSDT and pastebin it as well?

>
> On Tuesday 31 May 2016 15:27:45 Pierre-Louis Bossart wrote:
>> the changes look ok
>>>
>>> But I still have the same problem: Audio plays slowly.
>>>
>>>
>>>
>>> It seems the DSP is clocked at 19.2, but the system is still clocked for
>>> 25, and these changes doesn't seem to have effects...
>>
>> no, CHT doesn't have a 25 MHz clock at all so that's just not physically
>> possible.
>>
>> Can you try:
>> - tracing to make sure you are actually on a CHT device
>> - pastebin dmesg somewhere
>> - sudo cat /sys/bus/acpi/devices/10EC5651:01/status
>> - enabling DSP loopbacks to see if the DSP consumes data at the right
>> rate. look at the UCM file and change
>> cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on
>> if you record and loopback on USB output this should play at the right
>> speed.
>>
>>
>>
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-05-31 22:26         ` Pierre-Louis Bossart
@ 2016-06-01  8:38           ` Pietro
  2016-06-01 15:13             ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Pietro @ 2016-06-01  8:38 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel

Hi,

The Kernel error messages should be related to the Intel DRM graphics, so I don't care about them (at least for now).

Anyway I don't know if tese warning can in some way be related to my problem:

[    9.565990] rt5651 i2c-10EC5651:00: ASoC: mux INL1 Mux has no paths
[    9.586586] rt5651 i2c-10EC5651:00: ASoC: mux INR1 Mux has no paths
[    9.586596] rt5651 i2c-10EC5651:00: ASoC: mux INL2 Mux has no paths
[    9.586601] rt5651 i2c-10EC5651:00: ASoC: mux INR2 Mux has no paths
[   12.646035] sst-mfld-platform sst-mfld-platform: Slot control: codec_out tx interleaver slot 0 doesn't have DAPM widget!!!
[   12.649356] sst-mfld-platform sst-mfld-platform: Slot control: codec_out tx interleaver slot 1 doesn't have DAPM widget!!!
[   12.652673] sst-mfld-platform sst-mfld-platform: Slot control: codec_out tx interleaver slot 2 doesn't have DAPM widget!!!
[   12.656323] sst-mfld-platform sst-mfld-platform: Slot control: codec_out tx interleaver slot 3 doesn't have DAPM widget!!!
[   12.659868] sst-mfld-platform sst-mfld-platform: Slot control: codec_in rx deinterleaver codec_in0_0 doesn't have DAPM widget!!!
[   12.663456] sst-mfld-platform sst-mfld-platform: Slot control: codec_in rx deinterleaver codec_in0_1 doesn't have DAPM widget!!!

-------------


For your convenience I've extracted the DSDT from Android and Linux, because they seem to differ. Here they are:

DSDT Linux: http://paste.ubuntu.com/16885538/
DSDT Android: http://paste.ubuntu.com/16885557/

And this is the dmesg from android: http://pastebin.com/nY5mtW76


Here are the Firmware Blobs I'm currently using:
	http://pastebin.com/UKN0c0as (Fw listing)
	https://drive.google.com/file/d/0By5f76WVVa0Eb3RacGZRbzNGeFU/view?usp=sharing (Fw blobs)

When I'll return home I'll try to record and play and let you know.

Thanks,
Pietro

On Tuesday 31 May 2016 17:26:30 Pierre-Louis Bossart wrote:
> On 5/31/16 3:56 PM, Pietro wrote:
> > Hi,
> > Here are the answers:
> >
> > - tracing to make sure you are actually on a CHT device
> >   The device should be CHT (The processor is an Atom X3-Z8300). Can it be that the processor is an X3 series, but the platform is BT and not a CHT? I know many manifacturers simply upgraded their notebooks series from BT to CHT by changing the CPU and mantaining all the other components the same (For example the Audio codec).
> >   How can I trace this?
> 
> you see a lot of references to cherrytrail-cr and 22A8, the right ID.
> >
> > - pastebin dmesg somewhere
> >   Here is it: http://pastebin.com/FnpAD1kg
> 
> You have lots of errors or warnings in there. Not sure why, i have 
> machines that don't behave as badly.
> 
> I am not sure why using the CHT firmware leads to an error, somehow you 
> probably have a combination of issues. I would really start there, if 
> the regular firmware doesn't work for you something is very wrong.
> 
> > - sudo cat /sys/bus/acpi/devices/10EC5651:01/status
> >   Here are the results:
> >   /sys/bus/acpi/devices/10EC5651:00/status
> >     Returns 15
> 
> this matches what the machine driver expects so that's good.
> >
> >   /sys/bus/acpi/devices/10EC5651:01/status
> >     Returns 0
> >
> > - enabling DSP loopbacks to see if the DSP consumes data at the right  rate. look at the UCM file and change cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on if you record and loopback on USB output this should play at the right speed.
> >   I've changed the value in the HiFi file, but no changes.
> >   How can i enable DSP loopbacks? I'm not an alsa developer so I need some help here :)
> 
> you need to record to enable the loopback while you play...
> >
> > Please let me know if you need other informations.
> 
> can you extract the DSDT and pastebin it as well?
> 
> >
> > On Tuesday 31 May 2016 15:27:45 Pierre-Louis Bossart wrote:
> >> the changes look ok
> >>>
> >>> But I still have the same problem: Audio plays slowly.
> >>>
> >>>
> >>>
> >>> It seems the DSP is clocked at 19.2, but the system is still clocked for
> >>> 25, and these changes doesn't seem to have effects...
> >>
> >> no, CHT doesn't have a 25 MHz clock at all so that's just not physically
> >> possible.
> >>
> >> Can you try:
> >> - tracing to make sure you are actually on a CHT device
> >> - pastebin dmesg somewhere
> >> - sudo cat /sys/bus/acpi/devices/10EC5651:01/status
> >> - enabling DSP loopbacks to see if the DSP consumes data at the right
> >> rate. look at the UCM file and change
> >> cset "name='pcm1_out mix 0 pcm0_in Switch' off" to on
> >> if you record and loopback on USB output this should play at the right
> >> speed.
> >>
> >>
> >>
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> 

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-06-01  8:38           ` Pietro
@ 2016-06-01 15:13             ` Pierre-Louis Bossart
  2016-06-01 21:43               ` Pietro
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2016-06-01 15:13 UTC (permalink / raw)
  To: Pietro; +Cc: alsa-devel

On 6/1/16 3:38 AM, Pietro wrote:
> Hi,
>
>
>
> The Kernel error messages should be related to the Intel DRM graphics,
> so I don't care about them (at least for now).
>
>
>
> Anyway I don't know if tese warning can in some way be related to my
> problem:
>
>
>
> [ 9.565990] rt5651 i2c-10EC5651:00: ASoC: mux INL1 Mux has no paths
>
> [ 9.586586] rt5651 i2c-10EC5651:00: ASoC: mux INR1 Mux has no paths
>
> [ 9.586596] rt5651 i2c-10EC5651:00: ASoC: mux INL2 Mux has no paths
>
> [ 9.586601] rt5651 i2c-10EC5651:00: ASoC: mux INR2 Mux has no paths

probably the config is incorrect, I didn't enable capture in the UCM file

>
> [ 12.646035] sst-mfld-platform sst-mfld-platform: Slot control:
> codec_out tx interleaver slot 0 doesn't have DAPM widget!!!
>
> [ 12.649356] sst-mfld-platform sst-mfld-platform: Slot control:
> codec_out tx interleaver slot 1 doesn't have DAPM widget!!!
>
> [ 12.652673] sst-mfld-platform sst-mfld-platform: Slot control:
> codec_out tx interleaver slot 2 doesn't have DAPM widget!!!
>
> [ 12.656323] sst-mfld-platform sst-mfld-platform: Slot control:
> codec_out tx interleaver slot 3 doesn't have DAPM widget!!!
>
> [ 12.659868] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> rx deinterleaver codec_in0_0 doesn't have DAPM widget!!!
>
> [ 12.663456] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> rx deinterleaver codec_in0_1 doesn't have DAPM widget!!!

this last warning is fixed upstream.

> For your convenience I've extracted the DSDT from Android and Linux,
> because they seem to differ. Here they are:
>
>
>
> DSDT Linux: http://paste.ubuntu.com/16885538/
>
> DSDT Android: http://paste.ubuntu.com/16885557/

DSDT is OS independent so that doesn't make sense.
Just to be clear, is this an Android tablet on which you are installing 
ubuntu?
And did you try to use the firmware from upstream or from the Android 
distribution?

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-06-01 15:13             ` Pierre-Louis Bossart
@ 2016-06-01 21:43               ` Pietro
  2016-06-01 21:58                 ` Pierre-Louis Bossart
  0 siblings, 1 reply; 12+ messages in thread
From: Pietro @ 2016-06-01 21:43 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel

Hi,

Sorry for the wrong information:
the 2 DSDTs were decompiled using different iasl versions (20140828 for Android vs 20150717 for Linux), giving apparently different results (the functions were decoded differently, but the keys were the same).

The tablet is a dual boot Windows+Android (Surely based on AndroidIA, with a Patched gmin kernel... Obviously the sources were not provided by the manifacturer).

I've made some tests using both the firmware included in Android, and the upstream ones, with no apparent results (Always slow Audio).

But when you suggested me to use the fw_sst_22a8.bin I was trying to load the Android one, giving me load errors. Now I've tried the upstream one and it works with correct timing settings (!!)

Then I've tried to restore the 4.5.2 stock bytcr_rt5651.c, but this gave me inconsistent playback: The speed was right, but there were continue audio artifacts (like the ones given by a bad resampler, to give you an idea).
Using the patched driver, following your suggestion (patching it exatcly as I've wrote in the past E-Mails), solved this issue, so now the Audio is correctly played.

In the following days I'll make some tests (For example audio recording, switch between Headset and Speakers Etc.) and let you know if I'll find other issues.

Thanks for your continuous support, I've really appreciated it.

Pietro


On Wednesday 01 June 2016 10:13:17 Pierre-Louis Bossart wrote:
> On 6/1/16 3:38 AM, Pietro wrote:
> > Hi,
> >
> >
> >
> > The Kernel error messages should be related to the Intel DRM graphics,
> > so I don't care about them (at least for now).
> >
> >
> >
> > Anyway I don't know if tese warning can in some way be related to my
> > problem:
> >
> >
> >
> > [ 9.565990] rt5651 i2c-10EC5651:00: ASoC: mux INL1 Mux has no paths
> >
> > [ 9.586586] rt5651 i2c-10EC5651:00: ASoC: mux INR1 Mux has no paths
> >
> > [ 9.586596] rt5651 i2c-10EC5651:00: ASoC: mux INL2 Mux has no paths
> >
> > [ 9.586601] rt5651 i2c-10EC5651:00: ASoC: mux INR2 Mux has no paths
> 
> probably the config is incorrect, I didn't enable capture in the UCM file
> 
> >
> > [ 12.646035] sst-mfld-platform sst-mfld-platform: Slot control:
> > codec_out tx interleaver slot 0 doesn't have DAPM widget!!!
> >
> > [ 12.649356] sst-mfld-platform sst-mfld-platform: Slot control:
> > codec_out tx interleaver slot 1 doesn't have DAPM widget!!!
> >
> > [ 12.652673] sst-mfld-platform sst-mfld-platform: Slot control:
> > codec_out tx interleaver slot 2 doesn't have DAPM widget!!!
> >
> > [ 12.656323] sst-mfld-platform sst-mfld-platform: Slot control:
> > codec_out tx interleaver slot 3 doesn't have DAPM widget!!!
> >
> > [ 12.659868] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> > rx deinterleaver codec_in0_0 doesn't have DAPM widget!!!
> >
> > [ 12.663456] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> > rx deinterleaver codec_in0_1 doesn't have DAPM widget!!!
> 
> this last warning is fixed upstream.
> 
> > For your convenience I've extracted the DSDT from Android and Linux,
> > because they seem to differ. Here they are:
> >
> >
> >
> > DSDT Linux: http://paste.ubuntu.com/16885538/
> >
> > DSDT Android: http://paste.ubuntu.com/16885557/
> 
> DSDT is OS independent so that doesn't make sense.
> Just to be clear, is this an Android tablet on which you are installing 
> ubuntu?
> And did you try to use the firmware from upstream or from the Android 
> distribution?
> 
> 

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-06-01 21:43               ` Pietro
@ 2016-06-01 21:58                 ` Pierre-Louis Bossart
  2016-06-02  8:58                   ` Pietro
  0 siblings, 1 reply; 12+ messages in thread
From: Pierre-Louis Bossart @ 2016-06-01 21:58 UTC (permalink / raw)
  To: Pietro; +Cc: alsa-devel

On 6/1/16 4:43 PM, Pietro wrote:
> Hi,
>
> Sorry for the wrong information:
> the 2 DSDTs were decompiled using different iasl versions (20140828 for Android vs 20150717 for Linux), giving apparently different results (the functions were decoded differently, but the keys were the same).
>
> The tablet is a dual boot Windows+Android (Surely based on AndroidIA, with a Patched gmin kernel... Obviously the sources were not provided by the manifacturer).
>
> I've made some tests using both the firmware included in Android, and the upstream ones, with no apparent results (Always slow Audio).
>
> But when you suggested me to use the fw_sst_22a8.bin I was trying to load the Android one, giving me load errors. Now I've tried the upstream one and it works with correct timing settings (!!)
>
> Then I've tried to restore the 4.5.2 stock bytcr_rt5651.c, but this gave me inconsistent playback: The speed was right, but there were continue audio artifacts (like the ones given by a bad resampler, to give you an idea).
> Using the patched driver, following your suggestion (patching it exatcly as I've wrote in the past E-Mails), solved this issue, so now the Audio is correctly played.
>
> In the following days I'll make some tests (For example audio recording, switch between Headset and Speakers Etc.) and let you know if I'll find other issues.
>
> Thanks for your continuous support, I've really appreciated it.

Good to hear!
Yes as a general rule mixing upstream drivers with Android firmware and 
vice-versa is not a good idea, and using the MCLK is the only way to 
solve audio quality issues, it's however not enabled on every board 
unfortunately. When we have the clock driver I will make this the 
default and use quirks to go back to bit-clock based PLL configs.
If you want to send me a patch I can merge it with the rest of Baytrail 
cleanups still being worked on.

>
> Pietro
>
>
> On Wednesday 01 June 2016 10:13:17 Pierre-Louis Bossart wrote:
>> On 6/1/16 3:38 AM, Pietro wrote:
>>> Hi,
>>>
>>>
>>>
>>> The Kernel error messages should be related to the Intel DRM graphics,
>>> so I don't care about them (at least for now).
>>>
>>>
>>>
>>> Anyway I don't know if tese warning can in some way be related to my
>>> problem:
>>>
>>>
>>>
>>> [ 9.565990] rt5651 i2c-10EC5651:00: ASoC: mux INL1 Mux has no paths
>>>
>>> [ 9.586586] rt5651 i2c-10EC5651:00: ASoC: mux INR1 Mux has no paths
>>>
>>> [ 9.586596] rt5651 i2c-10EC5651:00: ASoC: mux INL2 Mux has no paths
>>>
>>> [ 9.586601] rt5651 i2c-10EC5651:00: ASoC: mux INR2 Mux has no paths
>>
>> probably the config is incorrect, I didn't enable capture in the UCM file
>>
>>>
>>> [ 12.646035] sst-mfld-platform sst-mfld-platform: Slot control:
>>> codec_out tx interleaver slot 0 doesn't have DAPM widget!!!
>>>
>>> [ 12.649356] sst-mfld-platform sst-mfld-platform: Slot control:
>>> codec_out tx interleaver slot 1 doesn't have DAPM widget!!!
>>>
>>> [ 12.652673] sst-mfld-platform sst-mfld-platform: Slot control:
>>> codec_out tx interleaver slot 2 doesn't have DAPM widget!!!
>>>
>>> [ 12.656323] sst-mfld-platform sst-mfld-platform: Slot control:
>>> codec_out tx interleaver slot 3 doesn't have DAPM widget!!!
>>>
>>> [ 12.659868] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
>>> rx deinterleaver codec_in0_0 doesn't have DAPM widget!!!
>>>
>>> [ 12.663456] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
>>> rx deinterleaver codec_in0_1 doesn't have DAPM widget!!!
>>
>> this last warning is fixed upstream.
>>
>>> For your convenience I've extracted the DSDT from Android and Linux,
>>> because they seem to differ. Here they are:
>>>
>>>
>>>
>>> DSDT Linux: http://paste.ubuntu.com/16885538/
>>>
>>> DSDT Android: http://paste.ubuntu.com/16885557/
>>
>> DSDT is OS independent so that doesn't make sense.
>> Just to be clear, is this an Android tablet on which you are installing
>> ubuntu?
>> And did you try to use the firmware from upstream or from the Android
>> distribution?
>>
>>
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>

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

* Re: Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-06-01 21:58                 ` Pierre-Louis Bossart
@ 2016-06-02  8:58                   ` Pietro
  0 siblings, 0 replies; 12+ messages in thread
From: Pietro @ 2016-06-02  8:58 UTC (permalink / raw)
  To: Pierre-Louis Bossart; +Cc: alsa-devel

Hi, 
You can find the full patch here:
http://pastebin.com/uFYq4UAL[1] 

I've patched it against the 4.7RC1 tree. I have tested it only on 4.5.2, but I don't think there will be significant differences between 4.5.2 and 4.7RC1 trunks (I only noticed the add of RT5640 support for cherryview). Anyway I'll let you know if I'll find some problems.


Pietro

On Wednesday 01 June 2016 16:58:35 Pierre-Louis Bossart wrote:
> On 6/1/16 4:43 PM, Pietro wrote:
> > Hi,
> >
> > Sorry for the wrong information:
> > the 2 DSDTs were decompiled using different iasl versions (20140828 for Android vs 20150717 for Linux), giving apparently different results (the functions were decoded differently, but the keys were the same).
> >
> > The tablet is a dual boot Windows+Android (Surely based on AndroidIA, with a Patched gmin kernel... Obviously the sources were not provided by the manifacturer).
> >
> > I've made some tests using both the firmware included in Android, and the upstream ones, with no apparent results (Always slow Audio).
> >
> > But when you suggested me to use the fw_sst_22a8.bin I was trying to load the Android one, giving me load errors. Now I've tried the upstream one and it works with correct timing settings (!!)
> >
> > Then I've tried to restore the 4.5.2 stock bytcr_rt5651.c, but this gave me inconsistent playback: The speed was right, but there were continue audio artifacts (like the ones given by a bad resampler, to give you an idea).
> > Using the patched driver, following your suggestion (patching it exatcly as I've wrote in the past E-Mails), solved this issue, so now the Audio is correctly played.
> >
> > In the following days I'll make some tests (For example audio recording, switch between Headset and Speakers Etc.) and let you know if I'll find other issues.
> >
> > Thanks for your continuous support, I've really appreciated it.
> 
> Good to hear!
> Yes as a general rule mixing upstream drivers with Android firmware and 
> vice-versa is not a good idea, and using the MCLK is the only way to 
> solve audio quality issues, it's however not enabled on every board 
> unfortunately. When we have the clock driver I will make this the 
> default and use quirks to go back to bit-clock based PLL configs.
> If you want to send me a patch I can merge it with the rest of Baytrail 
> cleanups still being worked on.
> 
> >
> > Pietro
> >
> >
> > On Wednesday 01 June 2016 10:13:17 Pierre-Louis Bossart wrote:
> >> On 6/1/16 3:38 AM, Pietro wrote:
> >>> Hi,
> >>>
> >>>
> >>>
> >>> The Kernel error messages should be related to the Intel DRM graphics,
> >>> so I don't care about them (at least for now).
> >>>
> >>>
> >>>
> >>> Anyway I don't know if tese warning can in some way be related to my
> >>> problem:
> >>>
> >>>
> >>>
> >>> [ 9.565990] rt5651 i2c-10EC5651:00: ASoC: mux INL1 Mux has no paths
> >>>
> >>> [ 9.586586] rt5651 i2c-10EC5651:00: ASoC: mux INR1 Mux has no paths
> >>>
> >>> [ 9.586596] rt5651 i2c-10EC5651:00: ASoC: mux INL2 Mux has no paths
> >>>
> >>> [ 9.586601] rt5651 i2c-10EC5651:00: ASoC: mux INR2 Mux has no paths
> >>
> >> probably the config is incorrect, I didn't enable capture in the UCM file
> >>
> >>>
> >>> [ 12.646035] sst-mfld-platform sst-mfld-platform: Slot control:
> >>> codec_out tx interleaver slot 0 doesn't have DAPM widget!!!
> >>>
> >>> [ 12.649356] sst-mfld-platform sst-mfld-platform: Slot control:
> >>> codec_out tx interleaver slot 1 doesn't have DAPM widget!!!
> >>>
> >>> [ 12.652673] sst-mfld-platform sst-mfld-platform: Slot control:
> >>> codec_out tx interleaver slot 2 doesn't have DAPM widget!!!
> >>>
> >>> [ 12.656323] sst-mfld-platform sst-mfld-platform: Slot control:
> >>> codec_out tx interleaver slot 3 doesn't have DAPM widget!!!
> >>>
> >>> [ 12.659868] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> >>> rx deinterleaver codec_in0_0 doesn't have DAPM widget!!!
> >>>
> >>> [ 12.663456] sst-mfld-platform sst-mfld-platform: Slot control: codec_in
> >>> rx deinterleaver codec_in0_1 doesn't have DAPM widget!!!
> >>
> >> this last warning is fixed upstream.
> >>
> >>> For your convenience I've extracted the DSDT from Android and Linux,
> >>> because they seem to differ. Here they are:
> >>>
> >>>
> >>>
> >>> DSDT Linux: http://paste.ubuntu.com/16885538/
> >>>
> >>> DSDT Android: http://paste.ubuntu.com/16885557/
> >>
> >> DSDT is OS independent so that doesn't make sense.
> >> Just to be clear, is this an Android tablet on which you are installing
> >> ubuntu?
> >> And did you try to use the firmware from upstream or from the Android
> >> distribution?
> >>
> >>
> >
> > _______________________________________________
> > Alsa-devel mailing list
> > Alsa-devel@alsa-project.org
> > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
> >
> 


--------
[1] http://pastebin.com/uFYq4UAL

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

* Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree
  2016-01-04 23:20 [PATCH v2 2/8] ASoC: Intel: add bytct-rt5651 machine driver Pierre-Louis Bossart
@ 2016-01-05 17:49 ` Mark Brown
  0 siblings, 0 replies; 12+ messages in thread
From: Mark Brown @ 2016-01-05 17:49 UTC (permalink / raw)
  To: Pierre-Louis Bossart, Mark Brown; +Cc: alsa-devel

The patch

   ASoC: Intel: add bytct-rt5651 machine driver

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 2bd5bd15a51858866d792c678f0fe9280c4e8fa7 Mon Sep 17 00:00:00 2001
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Date: Mon, 4 Jan 2016 17:20:24 -0600
Subject: [PATCH] ASoC: Intel: add bytct-rt5651 machine driver

based on bytcr-rt5640 with changes only on codec side
Quirk logic is kept as placeholder.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/intel/Kconfig               |  12 ++
 sound/soc/intel/atom/sst/sst_acpi.c   |   3 +
 sound/soc/intel/boards/Makefile       |   2 +
 sound/soc/intel/boards/bytcr_rt5651.c | 332 ++++++++++++++++++++++++++++++++++
 4 files changed, 349 insertions(+)
 create mode 100644 sound/soc/intel/boards/bytcr_rt5651.c

diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index 337e178c1acb..803f95e40679 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -103,6 +103,18 @@ config SND_SOC_INTEL_BYTCR_RT5640_MACH
           Say Y if you have such a device
           If unsure select "N".
 
+config SND_SOC_INTEL_BYTCR_RT5651_MACH
+        tristate "ASoC Audio driver for Intel Baytrail and Baytrail-CR with RT5651 codec"
+	depends on X86 && I2C
+	select SND_SOC_RT5651
+	select SND_SST_MFLD_PLATFORM
+	select SND_SST_IPC_ACPI
+	help
+          This adds support for ASoC machine driver for Intel(R) Baytrail and Baytrail-CR
+          platforms with RT5651 audio codec.
+          Say Y if you have such a device
+          If unsure select "N".
+
 config SND_SOC_INTEL_CHT_BSW_RT5672_MACH
         tristate "ASoC Audio driver for Intel Cherrytrail & Braswell with RT5672 codec"
         depends on X86_INTEL_LPSS && I2C
diff --git a/sound/soc/intel/atom/sst/sst_acpi.c b/sound/soc/intel/atom/sst/sst_acpi.c
index f424460b917e..b6ea0a58f9d3 100644
--- a/sound/soc/intel/atom/sst/sst_acpi.c
+++ b/sound/soc/intel/atom/sst/sst_acpi.c
@@ -316,6 +316,9 @@ static int sst_acpi_remove(struct platform_device *pdev)
 static struct sst_acpi_mach sst_acpi_bytcr[] = {
 	{"10EC5640", "bytcr_rt5640", "intel/fw_sst_0f28.bin", "bytcr_rt5640", NULL,
 						&byt_rvp_platform_data },
+	{"10EC5651", "bytcr_rt5651", "intel/fw_sst_0f28.bin", "bytcr_rt5651", NULL,
+						&byt_rvp_platform_data },
+
 	{},
 };
 
diff --git a/sound/soc/intel/boards/Makefile b/sound/soc/intel/boards/Makefile
index 2485ea9434ad..3310c0f9c356 100644
--- a/sound/soc/intel/boards/Makefile
+++ b/sound/soc/intel/boards/Makefile
@@ -3,6 +3,7 @@ snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o
 snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o
 snd-soc-sst-broadwell-objs := broadwell.o
 snd-soc-sst-bytcr-rt5640-objs := bytcr_rt5640.o
+snd-soc-sst-bytcr-rt5651-objs := bytcr_rt5651.o
 snd-soc-sst-cht-bsw-rt5672-objs := cht_bsw_rt5672.o
 snd-soc-sst-cht-bsw-rt5645-objs := cht_bsw_rt5645.o
 snd-soc-sst-cht-bsw-max98090_ti-objs := cht_bsw_max98090_ti.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o
 obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o
 obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5640_MACH) += snd-soc-sst-bytcr-rt5640.o
+obj-$(CONFIG_SND_SOC_INTEL_BYTCR_RT5651_MACH) += snd-soc-sst-bytcr-rt5651.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5672_MACH) += snd-soc-sst-cht-bsw-rt5672.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_RT5645_MACH) += snd-soc-sst-cht-bsw-rt5645.o
 obj-$(CONFIG_SND_SOC_INTEL_CHT_BSW_MAX98090_TI_MACH) += snd-soc-sst-cht-bsw-max98090_ti.o
diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c
new file mode 100644
index 000000000000..1c95ccc886c4
--- /dev/null
+++ b/sound/soc/intel/boards/bytcr_rt5651.c
@@ -0,0 +1,332 @@
+/*
+ *  bytcr_rt5651.c - ASoc Machine driver for Intel Byt CR platform
+ *  (derived from bytcr_rt5640.c)
+ *
+ *  Copyright (C) 2015 Intel Corp
+ *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; version 2 of the License.
+ *
+ *  This program is distributed in the hope that it will be useful, but
+ *  WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  General Public License for more details.
+ *
+ * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/acpi.h>
+#include <linux/device.h>
+#include <linux/dmi.h>
+#include <linux/slab.h>
+#include <sound/pcm.h>
+#include <sound/pcm_params.h>
+#include <sound/soc.h>
+#include <sound/jack.h>
+#include "../../codecs/rt5651.h"
+#include "../atom/sst-atom-controls.h"
+
+static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = {
+	SND_SOC_DAPM_HP("Headphone", NULL),
+	SND_SOC_DAPM_MIC("Headset Mic", NULL),
+	SND_SOC_DAPM_MIC("Internal Mic", NULL),
+	SND_SOC_DAPM_SPK("Speaker", NULL),
+};
+
+static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
+	{"AIF1 Playback", NULL, "ssp2 Tx"},
+	{"ssp2 Tx", NULL, "codec_out0"},
+	{"ssp2 Tx", NULL, "codec_out1"},
+	{"codec_in0", NULL, "ssp2 Rx"},
+	{"codec_in1", NULL, "ssp2 Rx"},
+	{"ssp2 Rx", NULL, "AIF1 Capture"},
+
+	{"Headset Mic", NULL, "micbias1"}, /* lowercase for rt5651 */
+	{"IN2P", NULL, "Headset Mic"},
+	{"Headphone", NULL, "HPOL"},
+	{"Headphone", NULL, "HPOR"},
+	{"Speaker", NULL, "LOUTL"},
+	{"Speaker", NULL, "LOUTR"},
+};
+
+static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic1_map[] = {
+	{"DMIC1", NULL, "Internal Mic"},
+};
+
+static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic2_map[] = {
+	{"DMIC2", NULL, "Internal Mic"},
+};
+
+static const struct snd_soc_dapm_route byt_rt5651_intmic_in1_map[] = {
+	{"Internal Mic", NULL, "micbias1"},
+	{"IN1P", NULL, "Internal Mic"},
+};
+
+enum {
+	BYT_RT5651_DMIC1_MAP,
+	BYT_RT5651_DMIC2_MAP,
+	BYT_RT5651_IN1_MAP,
+};
+
+#define BYT_RT5651_MAP(quirk)	((quirk) & 0xff)
+#define BYT_RT5651_DMIC_EN	BIT(16)
+
+static unsigned long byt_rt5651_quirk = BYT_RT5651_DMIC1_MAP |
+					BYT_RT5651_DMIC_EN;
+
+static const struct snd_kcontrol_new byt_rt5651_controls[] = {
+	SOC_DAPM_PIN_SWITCH("Headphone"),
+	SOC_DAPM_PIN_SWITCH("Headset Mic"),
+	SOC_DAPM_PIN_SWITCH("Internal Mic"),
+	SOC_DAPM_PIN_SWITCH("Speaker"),
+};
+
+static int byt_rt5651_aif1_hw_params(struct snd_pcm_substream *substream,
+					struct snd_pcm_hw_params *params)
+{
+	struct snd_soc_pcm_runtime *rtd = substream->private_data;
+	struct snd_soc_dai *codec_dai = rtd->codec_dai;
+	int ret;
+
+	snd_soc_dai_set_bclk_ratio(codec_dai, 50);
+
+	ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1,
+				     params_rate(params) * 512,
+				     SND_SOC_CLOCK_IN);
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't set codec clock %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
+				  params_rate(params) * 50,
+				  params_rate(params) * 512);
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static const struct dmi_system_id byt_rt5651_quirk_table[] = {
+	{}
+};
+
+static int byt_rt5651_init(struct snd_soc_pcm_runtime *runtime)
+{
+	int ret;
+	struct snd_soc_card *card = runtime->card;
+	const struct snd_soc_dapm_route *custom_map;
+	int num_routes;
+
+	card->dapm.idle_bias_off = true;
+
+	dmi_check_system(byt_rt5651_quirk_table);
+	switch (BYT_RT5651_MAP(byt_rt5651_quirk)) {
+	case BYT_RT5651_IN1_MAP:
+		custom_map = byt_rt5651_intmic_in1_map;
+		num_routes = ARRAY_SIZE(byt_rt5651_intmic_in1_map);
+		break;
+	case BYT_RT5651_DMIC2_MAP:
+		custom_map = byt_rt5651_intmic_dmic2_map;
+		num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic2_map);
+		break;
+	default:
+		custom_map = byt_rt5651_intmic_dmic1_map;
+		num_routes = ARRAY_SIZE(byt_rt5651_intmic_dmic1_map);
+	}
+
+	ret = snd_soc_add_card_controls(card, byt_rt5651_controls,
+					ARRAY_SIZE(byt_rt5651_controls));
+	if (ret) {
+		dev_err(card->dev, "unable to add card controls\n");
+		return ret;
+	}
+	snd_soc_dapm_ignore_suspend(&card->dapm, "Headphone");
+	snd_soc_dapm_ignore_suspend(&card->dapm, "Speaker");
+
+	return ret;
+}
+
+static const struct snd_soc_pcm_stream byt_rt5651_dai_params = {
+	.formats = SNDRV_PCM_FMTBIT_S24_LE,
+	.rate_min = 48000,
+	.rate_max = 48000,
+	.channels_min = 2,
+	.channels_max = 2,
+};
+
+static int byt_rt5651_codec_fixup(struct snd_soc_pcm_runtime *rtd,
+			    struct snd_pcm_hw_params *params)
+{
+	struct snd_interval *rate = hw_param_interval(params,
+			SNDRV_PCM_HW_PARAM_RATE);
+	struct snd_interval *channels = hw_param_interval(params,
+						SNDRV_PCM_HW_PARAM_CHANNELS);
+	int ret;
+
+	/* The DSP will covert the FE rate to 48k, stereo, 24bits */
+	rate->min = rate->max = 48000;
+	channels->min = channels->max = 2;
+
+	/* set SSP2 to 24-bit */
+	params_set_format(params, SNDRV_PCM_FORMAT_S24_LE);
+
+	/*
+	 * Default mode for SSP configuration is TDM 4 slot, override config
+	 * with explicit setting to I2S 2ch 24-bit. The word length is set with
+	 * dai_set_tdm_slot() since there is no other API exposed
+	 */
+	ret = snd_soc_dai_set_fmt(rtd->cpu_dai,
+				  SND_SOC_DAIFMT_I2S     |
+				  SND_SOC_DAIFMT_NB_IF   |
+				  SND_SOC_DAIFMT_CBS_CFS
+				  );
+
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't set format to I2S, err %d\n", ret);
+		return ret;
+	}
+
+	ret = snd_soc_dai_set_tdm_slot(rtd->cpu_dai, 0x3, 0x3, 2, 24);
+	if (ret < 0) {
+		dev_err(rtd->dev, "can't set I2S config, err %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+}
+
+static unsigned int rates_48000[] = {
+	48000,
+};
+
+static struct snd_pcm_hw_constraint_list constraints_48000 = {
+	.count = ARRAY_SIZE(rates_48000),
+	.list  = rates_48000,
+};
+
+static int byt_rt5651_aif1_startup(struct snd_pcm_substream *substream)
+{
+	return snd_pcm_hw_constraint_list(substream->runtime, 0,
+			SNDRV_PCM_HW_PARAM_RATE,
+			&constraints_48000);
+}
+
+static struct snd_soc_ops byt_rt5651_aif1_ops = {
+	.startup = byt_rt5651_aif1_startup,
+};
+
+static struct snd_soc_ops byt_rt5651_be_ssp2_ops = {
+	.hw_params = byt_rt5651_aif1_hw_params,
+};
+
+static struct snd_soc_dai_link byt_rt5651_dais[] = {
+	[MERR_DPCM_AUDIO] = {
+		.name = "Audio Port",
+		.stream_name = "Audio",
+		.cpu_dai_name = "media-cpu-dai",
+		.codec_dai_name = "snd-soc-dummy-dai",
+		.codec_name = "snd-soc-dummy",
+		.platform_name = "sst-mfld-platform",
+		.ignore_suspend = 1,
+		.nonatomic = true,
+		.dynamic = 1,
+		.dpcm_playback = 1,
+		.dpcm_capture = 1,
+		.ops = &byt_rt5651_aif1_ops,
+	},
+	[MERR_DPCM_DEEP_BUFFER] = {
+		.name = "Deep-Buffer Audio Port",
+		.stream_name = "Deep-Buffer Audio",
+		.cpu_dai_name = "deepbuffer-cpu-dai",
+		.codec_dai_name = "snd-soc-dummy-dai",
+		.codec_name = "snd-soc-dummy",
+		.platform_name = "sst-mfld-platform",
+		.ignore_suspend = 1,
+		.nonatomic = true,
+		.dynamic = 1,
+		.dpcm_playback = 1,
+		.ops = &byt_rt5651_aif1_ops,
+	},
+	[MERR_DPCM_COMPR] = {
+		.name = "Compressed Port",
+		.stream_name = "Compress",
+		.cpu_dai_name = "compress-cpu-dai",
+		.codec_dai_name = "snd-soc-dummy-dai",
+		.codec_name = "snd-soc-dummy",
+		.platform_name = "sst-mfld-platform",
+	},
+	/* CODEC<->CODEC link */
+	/* back ends */
+	{
+		.name = "SSP2-Codec",
+		.be_id = 1,
+		.cpu_dai_name = "ssp2-port",
+		.platform_name = "sst-mfld-platform",
+		.no_pcm = 1,
+		.codec_dai_name = "rt5651-aif1",
+		.codec_name = "i2c-10EC5651:00",
+		.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF
+						| SND_SOC_DAIFMT_CBS_CFS,
+		.be_hw_params_fixup = byt_rt5651_codec_fixup,
+		.ignore_suspend = 1,
+		.nonatomic = true,
+		.dpcm_playback = 1,
+		.dpcm_capture = 1,
+		.init = byt_rt5651_init,
+		.ops = &byt_rt5651_be_ssp2_ops,
+	},
+};
+
+/* SoC card */
+static struct snd_soc_card byt_rt5651_card = {
+	.name = "bytcr-rt5651",
+	.owner = THIS_MODULE,
+	.dai_link = byt_rt5651_dais,
+	.num_links = ARRAY_SIZE(byt_rt5651_dais),
+	.dapm_widgets = byt_rt5651_widgets,
+	.num_dapm_widgets = ARRAY_SIZE(byt_rt5651_widgets),
+	.dapm_routes = byt_rt5651_audio_map,
+	.num_dapm_routes = ARRAY_SIZE(byt_rt5651_audio_map),
+	.fully_routed = true,
+};
+
+static int snd_byt_rt5651_mc_probe(struct platform_device *pdev)
+{
+	int ret_val = 0;
+
+	/* register the soc card */
+	byt_rt5651_card.dev = &pdev->dev;
+
+	ret_val = devm_snd_soc_register_card(&pdev->dev, &byt_rt5651_card);
+
+	if (ret_val) {
+		dev_err(&pdev->dev, "devm_snd_soc_register_card failed %d\n",
+			ret_val);
+		return ret_val;
+	}
+	platform_set_drvdata(pdev, &byt_rt5651_card);
+	return ret_val;
+}
+
+static struct platform_driver snd_byt_rt5651_mc_driver = {
+	.driver = {
+		.name = "bytcr_rt5651",
+		.pm = &snd_soc_pm_ops,
+	},
+	.probe = snd_byt_rt5651_mc_probe,
+};
+
+module_platform_driver(snd_byt_rt5651_mc_driver);
+
+MODULE_DESCRIPTION("ASoC Intel(R) Baytrail CR Machine driver for RT5651");
+MODULE_AUTHOR("Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:bytcr_rt5651");
-- 
2.7.0.rc3

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

end of thread, other threads:[~2016-06-02  8:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31  8:43 Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree Pietro
2016-05-31 12:29 ` Pierre-Louis Bossart
2016-05-31 20:11   ` Pietro
2016-05-31 20:27     ` Pierre-Louis Bossart
2016-05-31 20:56       ` Pietro
2016-05-31 22:26         ` Pierre-Louis Bossart
2016-06-01  8:38           ` Pietro
2016-06-01 15:13             ` Pierre-Louis Bossart
2016-06-01 21:43               ` Pietro
2016-06-01 21:58                 ` Pierre-Louis Bossart
2016-06-02  8:58                   ` Pietro
  -- strict thread matches above, loose matches on Subject: below --
2016-01-04 23:20 [PATCH v2 2/8] ASoC: Intel: add bytct-rt5651 machine driver Pierre-Louis Bossart
2016-01-05 17:49 ` Applied "ASoC: Intel: add bytct-rt5651 machine driver" to the asoc tree Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.