From: Mark Brown Date: Fri, 10 Nov 2017 21:31:29 +0000 (+0000) Subject: Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc... X-Git-Tag: v4.15-rc1~118^2~1^2~1 X-Git-Url: https://repo.jachan.dev/linux.git/commitdiff_plain/668f21b1808d632ff9336047799a8bc0ed811b60?hp=-c Merge remote-tracking branches 'asoc/topic/samsung', 'asoc/topic/sgtl5000', 'asoc/topic/stm32', 'asoc/topic/sunxi' and 'asoc/topic/tas571x' into asoc-next --- 668f21b1808d632ff9336047799a8bc0ed811b60 diff --combined sound/soc/samsung/i2s.c index de783c6d2a70,8d5e1861abb1,10a4da06c0a1,10a4da06c0a1,10a4da06c0a1,10a4da06c0a1..233f1c9a4b6c --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c @@@@@@@ -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; @@@@@@@ -1111,10 -1112,13 -1108,10 -1108,10 -1108,10 -1108,10 +1112,13 @@@@@@@ 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); diff --combined sound/soc/sunxi/sun8i-codec.c index 50a9e077f01b,5723c3404f6b,abfb710df7cb,abfb710df7cb,b3329692e3dc,abfb710df7cb..3dd183be08a4 --- a/sound/soc/sunxi/sun8i-codec.c +++ b/sound/soc/sunxi/sun8i-codec.c @@@@@@@ -73,7 -73,6 -73,6 -73,6 -73,6 -73,6 +73,7 @@@@@@@ #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; @@@@@@@ -198,9 -197,9 -197,9 -197,9 -197,20 -197,9 +198,20 @@@@@@@ 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) { @@@@@@@ -227,57 -226,12 -226,12 -226,12 -237,12 -226,12 +238,57 @@@@@@@ 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 @@@@@@@ -287,11 -241,6 -241,6 -241,6 -252,6 -241,6 +298,11 @@@@@@@ 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),