]> Git Repo - linux.git/commitdiff
Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc...
authorMark Brown <[email protected]>
Fri, 10 Nov 2017 21:31:29 +0000 (21:31 +0000)
committerMark Brown <[email protected]>
Fri, 10 Nov 2017 21:31:29 +0000 (21:31 +0000)
1  2  3  4  5  6 
sound/soc/samsung/i2s.c
sound/soc/sunxi/sun8i-codec.c

diff --combined sound/soc/samsung/i2s.c
index de783c6d2a7091a4de73c8c8a3d55e05d9493f7c,8d5e1861abb1151194c127224d78938f01628e03,10a4da06c0a1477388758f30b2aaf61ae8a5ef12,10a4da06c0a1477388758f30b2aaf61ae8a5ef12,10a4da06c0a1477388758f30b2aaf61ae8a5ef12,10a4da06c0a1477388758f30b2aaf61ae8a5ef12..233f1c9a4b6cc0c99200a70c411a8d8df0c29741
@@@@@@@ -552,11 -552,11 -552,8 -552,8 -552,8 -552,8 +552,11 @@@@@@@ static int i2s_set_sysclk(struct snd_so
                        }
      
                        ret = clk_prepare_enable(i2s->op_clk);
  ----                  if (ret)
  ++++                  if (ret) {
  ++++                          clk_put(i2s->op_clk);
  ++++                          i2s->op_clk = NULL;
                                goto err;
  ++++                  }
                        i2s->rclk_srcrate = clk_get_rate(i2s->op_clk);
      
                        /* Over-ride the other's */
@@@@@@@ -1099,6 -1099,7 -1096,6 -1096,6 -1096,6 -1096,6 +1099,7 @@@@@@@ static struct i2s_dai *i2s_alloc_dai(st
        i2s->pdev = pdev;
        i2s->pri_dai = NULL;
        i2s->sec_dai = NULL;
+ ++++  i2s->i2s_dai_drv.id = 1;
        i2s->i2s_dai_drv.symmetric_rates = 1;
        i2s->i2s_dai_drv.probe = samsung_i2s_dai_probe;
        i2s->i2s_dai_drv.remove = samsung_i2s_dai_remove;
        i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS;
      
        if (!sec) {
+ ++++          i2s->i2s_dai_drv.name = SAMSUNG_I2S_DAI;
                i2s->i2s_dai_drv.capture.channels_min = 1;
                i2s->i2s_dai_drv.capture.channels_max = 2;
                i2s->i2s_dai_drv.capture.rates = i2s_dai_data->pcm_rates;
                i2s->i2s_dai_drv.capture.formats = SAMSUNG_I2S_FMTS;
+ ++++  } else {
+ ++++          i2s->i2s_dai_drv.name = SAMSUNG_I2S_DAI_SEC;
        }
        return i2s;
      }
@@@@@@@ -1288,7 -1292,6 -1285,6 -1285,6 -1285,6 -1285,6 +1292,7 @@@@@@@ static int samsung_i2s_probe(struct pla
                        }
                }
        }
 +++++  quirks &= ~(QUIRK_SEC_DAI | QUIRK_SUPPORTS_IDMA);
      
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        pri_dai->addr = devm_ioremap_resource(&pdev->dev, res);
index 50a9e077f01b2372f1fe20d4ebd1179e208fa69d,5723c3404f6bd6a896aed90b8b37d143de26c075,abfb710df7cbceb54c9fc60ab7502f088d630874,abfb710df7cbceb54c9fc60ab7502f088d630874,b3329692e3dc05636fb01c61a751efa62d52216c,abfb710df7cbceb54c9fc60ab7502f088d630874..3dd183be08a40f8dc271f16eebab7f8d71ef0e1e
      #define SUN8I_SYS_SR_CTRL_AIF2_FS_MASK            GENMASK(11, 8)
      #define SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK     GENMASK(5, 4)
      #define SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK     GENMASK(8, 6)
 +++++#define SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK     GENMASK(12, 9)
      
      struct sun8i_codec {
        struct device   *dev;
@@@@@@@ -171,11 -170,11 -170,11 -170,11 -170,11 -170,11 +171,11 @@@@@@@ static int sun8i_set_fmt(struct snd_soc
      
        /* clock masters */
        switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) {
 --- -  case SND_SOC_DAIFMT_CBS_CFS: /* DAI Slave */
 --- -          value = 0x0; /* Codec Master */
 +++ +  case SND_SOC_DAIFMT_CBS_CFS: /* Codec slave, DAI master */
 +++ +          value = 0x1;
                break;
 --- -  case SND_SOC_DAIFMT_CBM_CFM: /* DAI Master */
 --- -          value = 0x1; /* Codec Slave */
 +++ +  case SND_SOC_DAIFMT_CBM_CFM: /* Codec Master, DAI slave */
 +++ +          value = 0x0;
                break;
        default:
                return -EINVAL;
        regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
                           BIT(SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV),
                           value << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_INV);
++++ +
++++ +  /*
++++ +   * It appears that the DAI and the codec don't share the same
++++ +   * polarity for the LRCK signal when they mean 'normal' and
++++ +   * 'inverted' in the datasheet.
++++ +   *
++++ +   * Since the DAI here is our regular i2s driver that have been
++++ +   * tested with way more codecs than just this one, it means
++++ +   * that the codec probably gets it backward, and we have to
++++ +   * invert the value here.
++++ +   */
        regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
                           BIT(SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV),
---- -                     value << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV);
++++ +                     !value << SUN8I_AIF1CLK_CTRL_AIF1_LRCK_INV);
      
        /* DAI format */
        switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) {
        return 0;
      }
      
 +++++struct sun8i_codec_clk_div {
 +++++  u8      div;
 +++++  u8      val;
 +++++};
 +++++
 +++++static const struct sun8i_codec_clk_div sun8i_codec_bclk_div[] = {
 +++++  { .div = 1,     .val = 0 },
 +++++  { .div = 2,     .val = 1 },
 +++++  { .div = 4,     .val = 2 },
 +++++  { .div = 6,     .val = 3 },
 +++++  { .div = 8,     .val = 4 },
 +++++  { .div = 12,    .val = 5 },
 +++++  { .div = 16,    .val = 6 },
 +++++  { .div = 24,    .val = 7 },
 +++++  { .div = 32,    .val = 8 },
 +++++  { .div = 48,    .val = 9 },
 +++++  { .div = 64,    .val = 10 },
 +++++  { .div = 96,    .val = 11 },
 +++++  { .div = 128,   .val = 12 },
 +++++  { .div = 192,   .val = 13 },
 +++++};
 +++++
 +++++static u8 sun8i_codec_get_bclk_div(struct sun8i_codec *scodec,
 +++++                             unsigned int rate,
 +++++                             unsigned int word_size)
 +++++{
 +++++  unsigned long clk_rate = clk_get_rate(scodec->clk_module);
 +++++  unsigned int div = clk_rate / rate / word_size / 2;
 +++++  unsigned int best_val = 0, best_diff = ~0;
 +++++  int i;
 +++++
 +++++  for (i = 0; i < ARRAY_SIZE(sun8i_codec_bclk_div); i++) {
 +++++          const struct sun8i_codec_clk_div *bdiv = &sun8i_codec_bclk_div[i];
 +++++          unsigned int diff = abs(bdiv->div - div);
 +++++
 +++++          if (diff < best_diff) {
 +++++                  best_diff = diff;
 +++++                  best_val = bdiv->val;
 +++++          }
 +++++  }
 +++++
 +++++  return best_val;
 +++++}
 +++++
      static int sun8i_codec_hw_params(struct snd_pcm_substream *substream,
                                 struct snd_pcm_hw_params *params,
                                 struct snd_soc_dai *dai)
      {
        struct sun8i_codec *scodec = snd_soc_codec_get_drvdata(dai->codec);
        int sample_rate;
 +++++  u8 bclk_div;
      
        /*
         * The CPU DAI handles only a sample of 16 bits. Configure the
                           SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_MASK,
                           SUN8I_AIF1CLK_CTRL_AIF1_WORD_SIZ_16);
      
 +++++  bclk_div = sun8i_codec_get_bclk_div(scodec, params_rate(params), 16);
 +++++  regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
 +++++                     SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV_MASK,
 +++++                     bclk_div << SUN8I_AIF1CLK_CTRL_AIF1_BCLK_DIV);
 +++++
        regmap_update_bits(scodec->regmap, SUN8I_AIF1CLK_CTRL,
                           SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_MASK,
                           SUN8I_AIF1CLK_CTRL_AIF1_LRCK_DIV_16);
@@@@@@@ -392,7 -341,7 -341,7 -341,7 -352,7 -341,7 +403,7 @@@@@@@ static const struct snd_soc_dapm_route 
          "AIF1 Slot 0 Right"},
      };
      
 -    static struct snd_soc_dai_ops sun8i_codec_dai_ops = {
 +    static const struct snd_soc_dai_ops sun8i_codec_dai_ops = {
        .hw_params = sun8i_codec_hw_params,
        .set_fmt = sun8i_set_fmt,
      };
@@@@@@@ -411,7 -360,7 -360,7 -360,7 -371,7 -360,7 +422,7 @@@@@@@ static struct snd_soc_dai_driver sun8i_
        .ops = &sun8i_codec_dai_ops,
      };
      
 -    static struct snd_soc_codec_driver sun8i_soc_codec = {
 +    static const struct snd_soc_codec_driver sun8i_soc_codec = {
        .component_driver = {
                .dapm_widgets           = sun8i_codec_dapm_widgets,
                .num_dapm_widgets       = ARRAY_SIZE(sun8i_codec_dapm_widgets),
This page took 0.099376 seconds and 4 git commands to generate.