aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2016-05-04 12:51:26 -0400
committerMark Brown <broonie@kernel.org>2016-05-04 12:51:26 -0400
commit0023f8a6d5c22b2bed0f21d79805c6baee397620 (patch)
tree036bb946ecc6b6a260a8bb9674b6a8bed9394ecb
parent9ee78757d5dae51decc881b293a39a605c9a6df2 (diff)
parent56574d541f93cf8c9449f9ecadc83d97323cfcec (diff)
Merge branch 'topic/arizona' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-adsp
-rw-r--r--sound/soc/codecs/arizona.c32
-rw-r--r--sound/soc/codecs/cs47l24.c5
-rw-r--r--sound/soc/codecs/wm5102.c4
-rw-r--r--sound/soc/codecs/wm5110.c6
-rw-r--r--sound/soc/codecs/wm_adsp.c52
-rw-r--r--sound/soc/codecs/wm_adsp.h1
6 files changed, 70 insertions, 30 deletions
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c
index 92d22a018d68..0239639823b1 100644
--- a/sound/soc/codecs/arizona.c
+++ b/sound/soc/codecs/arizona.c
@@ -221,6 +221,8 @@ int arizona_init_spk(struct snd_soc_codec *codec)
221 221
222 switch (arizona->type) { 222 switch (arizona->type) {
223 case WM8997: 223 case WM8997:
224 case CS47L24:
225 case WM1831:
224 break; 226 break;
225 default: 227 default:
226 ret = snd_soc_dapm_new_controls(dapm, &arizona_spkr, 1); 228 ret = snd_soc_dapm_new_controls(dapm, &arizona_spkr, 1);
@@ -1122,7 +1124,6 @@ int arizona_anc_ev(struct snd_soc_dapm_widget *w,
1122 int event) 1124 int event)
1123{ 1125{
1124 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 1126 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
1125 unsigned int mask = 0x3 << w->shift;
1126 unsigned int val; 1127 unsigned int val;
1127 1128
1128 switch (event) { 1129 switch (event) {
@@ -1136,7 +1137,7 @@ int arizona_anc_ev(struct snd_soc_dapm_widget *w,
1136 return 0; 1137 return 0;
1137 } 1138 }
1138 1139
1139 snd_soc_update_bits(codec, ARIZONA_CLOCK_CONTROL, mask, val); 1140 snd_soc_write(codec, ARIZONA_CLOCK_CONTROL, val);
1140 1141
1141 return 0; 1142 return 0;
1142} 1143}
@@ -2035,7 +2036,21 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
2035 init_ratio, Fref, refdiv); 2036 init_ratio, Fref, refdiv);
2036 2037
2037 while (div <= ARIZONA_FLL_MAX_REFDIV) { 2038 while (div <= ARIZONA_FLL_MAX_REFDIV) {
2038 for (ratio = init_ratio; ratio <= ARIZONA_FLL_MAX_FRATIO; 2039 /* start from init_ratio because this may already give a
2040 * fractional N.K
2041 */
2042 for (ratio = init_ratio; ratio > 0; ratio--) {
2043 if (target % (ratio * Fref)) {
2044 cfg->refdiv = refdiv;
2045 cfg->fratio = ratio - 1;
2046 arizona_fll_dbg(fll,
2047 "pseudo: found fref=%u refdiv=%d(%d) ratio=%d\n",
2048 Fref, refdiv, div, ratio);
2049 return ratio;
2050 }
2051 }
2052
2053 for (ratio = init_ratio + 1; ratio <= ARIZONA_FLL_MAX_FRATIO;
2039 ratio++) { 2054 ratio++) {
2040 if ((ARIZONA_FLL_VCO_CORNER / 2) / 2055 if ((ARIZONA_FLL_VCO_CORNER / 2) /
2041 (fll->vco_mult * ratio) < Fref) { 2056 (fll->vco_mult * ratio) < Fref) {
@@ -2061,17 +2076,6 @@ static int arizona_calc_fratio(struct arizona_fll *fll,
2061 } 2076 }
2062 } 2077 }
2063 2078
2064 for (ratio = init_ratio - 1; ratio > 0; ratio--) {
2065 if (target % (ratio * Fref)) {
2066 cfg->refdiv = refdiv;
2067 cfg->fratio = ratio - 1;
2068 arizona_fll_dbg(fll,
2069 "pseudo: found fref=%u refdiv=%d(%d) ratio=%d\n",
2070 Fref, refdiv, div, ratio);
2071 return ratio;
2072 }
2073 }
2074
2075 div *= 2; 2079 div *= 2;
2076 Fref /= 2; 2080 Fref /= 2;
2077 refdiv++; 2081 refdiv++;
diff --git a/sound/soc/codecs/cs47l24.c b/sound/soc/codecs/cs47l24.c
index 6b8b5571d3cc..e42ba0634634 100644
--- a/sound/soc/codecs/cs47l24.c
+++ b/sound/soc/codecs/cs47l24.c
@@ -1271,10 +1271,15 @@ static int cs47l24_probe(struct platform_device *pdev)
1271 1271
1272static int cs47l24_remove(struct platform_device *pdev) 1272static int cs47l24_remove(struct platform_device *pdev)
1273{ 1273{
1274 struct cs47l24_priv *cs47l24 = platform_get_drvdata(pdev);
1275
1274 snd_soc_unregister_platform(&pdev->dev); 1276 snd_soc_unregister_platform(&pdev->dev);
1275 snd_soc_unregister_codec(&pdev->dev); 1277 snd_soc_unregister_codec(&pdev->dev);
1276 pm_runtime_disable(&pdev->dev); 1278 pm_runtime_disable(&pdev->dev);
1277 1279
1280 wm_adsp2_remove(&cs47l24->core.adsp[1]);
1281 wm_adsp2_remove(&cs47l24->core.adsp[2]);
1282
1278 return 0; 1283 return 0;
1279} 1284}
1280 1285
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c
index a8b3e3f701f9..7a539e0529c0 100644
--- a/sound/soc/codecs/wm5102.c
+++ b/sound/soc/codecs/wm5102.c
@@ -2093,10 +2093,14 @@ static int wm5102_probe(struct platform_device *pdev)
2093 2093
2094static int wm5102_remove(struct platform_device *pdev) 2094static int wm5102_remove(struct platform_device *pdev)
2095{ 2095{
2096 struct wm5102_priv *wm5102 = platform_get_drvdata(pdev);
2097
2096 snd_soc_unregister_platform(&pdev->dev); 2098 snd_soc_unregister_platform(&pdev->dev);
2097 snd_soc_unregister_codec(&pdev->dev); 2099 snd_soc_unregister_codec(&pdev->dev);
2098 pm_runtime_disable(&pdev->dev); 2100 pm_runtime_disable(&pdev->dev);
2099 2101
2102 wm_adsp2_remove(&wm5102->core.adsp[0]);
2103
2100 return 0; 2104 return 0;
2101} 2105}
2102 2106
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c
index 83ba70fe16e6..dd87af1ffa23 100644
--- a/sound/soc/codecs/wm5110.c
+++ b/sound/soc/codecs/wm5110.c
@@ -2435,10 +2435,16 @@ static int wm5110_probe(struct platform_device *pdev)
2435 2435
2436static int wm5110_remove(struct platform_device *pdev) 2436static int wm5110_remove(struct platform_device *pdev)
2437{ 2437{
2438 struct wm5110_priv *wm5110 = platform_get_drvdata(pdev);
2439 int i;
2440
2438 snd_soc_unregister_platform(&pdev->dev); 2441 snd_soc_unregister_platform(&pdev->dev);
2439 snd_soc_unregister_codec(&pdev->dev); 2442 snd_soc_unregister_codec(&pdev->dev);
2440 pm_runtime_disable(&pdev->dev); 2443 pm_runtime_disable(&pdev->dev);
2441 2444
2445 for (i = 0; i < WM5110_NUM_ADSP; i++)
2446 wm_adsp2_remove(&wm5110->core.adsp[i]);
2447
2442 return 0; 2448 return 0;
2443} 2449}
2444 2450
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index f835277901d4..630ebcdaf46e 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -1037,6 +1037,13 @@ static void wm_adsp_ctl_work(struct work_struct *work)
1037 kfree(ctl_work); 1037 kfree(ctl_work);
1038} 1038}
1039 1039
1040static void wm_adsp_free_ctl_blk(struct wm_coeff_ctl *ctl)
1041{
1042 kfree(ctl->cache);
1043 kfree(ctl->name);
1044 kfree(ctl);
1045}
1046
1040static int wm_adsp_create_control(struct wm_adsp *dsp, 1047static int wm_adsp_create_control(struct wm_adsp *dsp,
1041 const struct wm_adsp_alg_region *alg_region, 1048 const struct wm_adsp_alg_region *alg_region,
1042 unsigned int offset, unsigned int len, 1049 unsigned int offset, unsigned int len,
@@ -1652,6 +1659,19 @@ static struct wm_adsp_alg_region *wm_adsp_create_region(struct wm_adsp *dsp,
1652 return alg_region; 1659 return alg_region;
1653} 1660}
1654 1661
1662static void wm_adsp_free_alg_regions(struct wm_adsp *dsp)
1663{
1664 struct wm_adsp_alg_region *alg_region;
1665
1666 while (!list_empty(&dsp->alg_regions)) {
1667 alg_region = list_first_entry(&dsp->alg_regions,
1668 struct wm_adsp_alg_region,
1669 list);
1670 list_del(&alg_region->list);
1671 kfree(alg_region);
1672 }
1673}
1674
1655static int wm_adsp1_setup_algs(struct wm_adsp *dsp) 1675static int wm_adsp1_setup_algs(struct wm_adsp *dsp)
1656{ 1676{
1657 struct wmfw_adsp1_id_hdr adsp1_id; 1677 struct wmfw_adsp1_id_hdr adsp1_id;
@@ -2082,7 +2102,6 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
2082 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 2102 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2083 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 2103 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
2084 struct wm_adsp *dsp = &dsps[w->shift]; 2104 struct wm_adsp *dsp = &dsps[w->shift];
2085 struct wm_adsp_alg_region *alg_region;
2086 struct wm_coeff_ctl *ctl; 2105 struct wm_coeff_ctl *ctl;
2087 int ret; 2106 int ret;
2088 unsigned int val; 2107 unsigned int val;
@@ -2162,13 +2181,8 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w,
2162 list_for_each_entry(ctl, &dsp->ctl_list, list) 2181 list_for_each_entry(ctl, &dsp->ctl_list, list)
2163 ctl->enabled = 0; 2182 ctl->enabled = 0;
2164 2183
2165 while (!list_empty(&dsp->alg_regions)) { 2184
2166 alg_region = list_first_entry(&dsp->alg_regions, 2185 wm_adsp_free_alg_regions(dsp);
2167 struct wm_adsp_alg_region,
2168 list);
2169 list_del(&alg_region->list);
2170 kfree(alg_region);
2171 }
2172 break; 2186 break;
2173 2187
2174 default: 2188 default:
@@ -2310,7 +2324,6 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
2310 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); 2324 struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
2311 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); 2325 struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec);
2312 struct wm_adsp *dsp = &dsps[w->shift]; 2326 struct wm_adsp *dsp = &dsps[w->shift];
2313 struct wm_adsp_alg_region *alg_region;
2314 struct wm_coeff_ctl *ctl; 2327 struct wm_coeff_ctl *ctl;
2315 int ret; 2328 int ret;
2316 2329
@@ -2361,13 +2374,7 @@ int wm_adsp2_event(struct snd_soc_dapm_widget *w,
2361 list_for_each_entry(ctl, &dsp->ctl_list, list) 2374 list_for_each_entry(ctl, &dsp->ctl_list, list)
2362 ctl->enabled = 0; 2375 ctl->enabled = 0;
2363 2376
2364 while (!list_empty(&dsp->alg_regions)) { 2377 wm_adsp_free_alg_regions(dsp);
2365 alg_region = list_first_entry(&dsp->alg_regions,
2366 struct wm_adsp_alg_region,
2367 list);
2368 list_del(&alg_region->list);
2369 kfree(alg_region);
2370 }
2371 2378
2372 if (wm_adsp_fw[dsp->fw].num_caps != 0) 2379 if (wm_adsp_fw[dsp->fw].num_caps != 0)
2373 wm_adsp_buffer_free(dsp); 2380 wm_adsp_buffer_free(dsp);
@@ -2432,6 +2439,19 @@ int wm_adsp2_init(struct wm_adsp *dsp)
2432} 2439}
2433EXPORT_SYMBOL_GPL(wm_adsp2_init); 2440EXPORT_SYMBOL_GPL(wm_adsp2_init);
2434 2441
2442void wm_adsp2_remove(struct wm_adsp *dsp)
2443{
2444 struct wm_coeff_ctl *ctl;
2445
2446 while (!list_empty(&dsp->ctl_list)) {
2447 ctl = list_first_entry(&dsp->ctl_list, struct wm_coeff_ctl,
2448 list);
2449 list_del(&ctl->list);
2450 wm_adsp_free_ctl_blk(ctl);
2451 }
2452}
2453EXPORT_SYMBOL_GPL(wm_adsp2_remove);
2454
2435int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream) 2455int wm_adsp_compr_open(struct wm_adsp *dsp, struct snd_compr_stream *stream)
2436{ 2456{
2437 struct wm_adsp_compr *compr; 2457 struct wm_adsp_compr *compr;
diff --git a/sound/soc/codecs/wm_adsp.h b/sound/soc/codecs/wm_adsp.h
index b61cb57e600f..feb61e2c4bb4 100644
--- a/sound/soc/codecs/wm_adsp.h
+++ b/sound/soc/codecs/wm_adsp.h
@@ -92,6 +92,7 @@ extern const struct snd_kcontrol_new wm_adsp_fw_controls[];
92 92
93int wm_adsp1_init(struct wm_adsp *dsp); 93int wm_adsp1_init(struct wm_adsp *dsp);
94int wm_adsp2_init(struct wm_adsp *dsp); 94int wm_adsp2_init(struct wm_adsp *dsp);
95void wm_adsp2_remove(struct wm_adsp *dsp);
95int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec); 96int wm_adsp2_codec_probe(struct wm_adsp *dsp, struct snd_soc_codec *codec);
96int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec); 97int wm_adsp2_codec_remove(struct wm_adsp *dsp, struct snd_soc_codec *codec);
97int wm_adsp1_event(struct snd_soc_dapm_widget *w, 98int wm_adsp1_event(struct snd_soc_dapm_widget *w,