diff options
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r-- | sound/soc/codecs/da7213.c | 4 | ||||
-rw-r--r-- | sound/soc/codecs/max98371.c | 1 | ||||
-rw-r--r-- | sound/soc/codecs/nau8825.c | 78 | ||||
-rw-r--r-- | sound/soc/codecs/wm2000.c | 2 |
4 files changed, 36 insertions, 49 deletions
diff --git a/sound/soc/codecs/da7213.c b/sound/soc/codecs/da7213.c index e5527bc570ae..bcf1834c5648 100644 --- a/sound/soc/codecs/da7213.c +++ b/sound/soc/codecs/da7213.c | |||
@@ -1247,8 +1247,8 @@ static int da7213_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
1247 | return -EINVAL; | 1247 | return -EINVAL; |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | /* By default only 32 BCLK per WCLK is supported */ | 1250 | /* By default only 64 BCLK per WCLK is supported */ |
1251 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_32; | 1251 | dai_clk_mode |= DA7213_DAI_BCLKS_PER_WCLK_64; |
1252 | 1252 | ||
1253 | snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); | 1253 | snd_soc_write(codec, DA7213_DAI_CLK_MODE, dai_clk_mode); |
1254 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, | 1254 | snd_soc_update_bits(codec, DA7213_DAI_CTRL, DA7213_DAI_FORMAT_MASK, |
diff --git a/sound/soc/codecs/max98371.c b/sound/soc/codecs/max98371.c index cf0a39bb631a..02352ed8961c 100644 --- a/sound/soc/codecs/max98371.c +++ b/sound/soc/codecs/max98371.c | |||
@@ -412,6 +412,7 @@ static int max98371_i2c_remove(struct i2c_client *client) | |||
412 | 412 | ||
413 | static const struct i2c_device_id max98371_i2c_id[] = { | 413 | static const struct i2c_device_id max98371_i2c_id[] = { |
414 | { "max98371", 0 }, | 414 | { "max98371", 0 }, |
415 | { } | ||
415 | }; | 416 | }; |
416 | 417 | ||
417 | MODULE_DEVICE_TABLE(i2c, max98371_i2c_id); | 418 | MODULE_DEVICE_TABLE(i2c, max98371_i2c_id); |
diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c index 5c9707ac4bbf..2e59a85e360b 100644 --- a/sound/soc/codecs/nau8825.c +++ b/sound/soc/codecs/nau8825.c | |||
@@ -212,31 +212,6 @@ static const unsigned short logtable[256] = { | |||
212 | 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 | 212 | 0xfa2f, 0xfaea, 0xfba5, 0xfc60, 0xfd1a, 0xfdd4, 0xfe8e, 0xff47 |
213 | }; | 213 | }; |
214 | 214 | ||
215 | static struct snd_soc_dai *nau8825_get_codec_dai(struct nau8825 *nau8825) | ||
216 | { | ||
217 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(nau8825->dapm); | ||
218 | struct snd_soc_component *component = &codec->component; | ||
219 | struct snd_soc_dai *codec_dai, *_dai; | ||
220 | |||
221 | list_for_each_entry_safe(codec_dai, _dai, &component->dai_list, list) { | ||
222 | if (!strncmp(codec_dai->name, NUVOTON_CODEC_DAI, | ||
223 | strlen(NUVOTON_CODEC_DAI))) | ||
224 | return codec_dai; | ||
225 | } | ||
226 | return NULL; | ||
227 | } | ||
228 | |||
229 | static bool nau8825_dai_is_active(struct nau8825 *nau8825) | ||
230 | { | ||
231 | struct snd_soc_dai *codec_dai = nau8825_get_codec_dai(nau8825); | ||
232 | |||
233 | if (codec_dai) { | ||
234 | if (codec_dai->playback_active || codec_dai->capture_active) | ||
235 | return true; | ||
236 | } | ||
237 | return false; | ||
238 | } | ||
239 | |||
240 | /** | 215 | /** |
241 | * nau8825_sema_acquire - acquire the semaphore of nau88l25 | 216 | * nau8825_sema_acquire - acquire the semaphore of nau88l25 |
242 | * @nau8825: component to register the codec private data with | 217 | * @nau8825: component to register the codec private data with |
@@ -250,19 +225,26 @@ static bool nau8825_dai_is_active(struct nau8825 *nau8825) | |||
250 | * Acquires the semaphore without jiffies. If no more tasks are allowed | 225 | * Acquires the semaphore without jiffies. If no more tasks are allowed |
251 | * to acquire the semaphore, calling this function will put the task to | 226 | * to acquire the semaphore, calling this function will put the task to |
252 | * sleep until the semaphore is released. | 227 | * sleep until the semaphore is released. |
253 | * It returns if the semaphore was acquired. | 228 | * If the semaphore is not released within the specified number of jiffies, |
229 | * this function returns -ETIME. | ||
230 | * If the sleep is interrupted by a signal, this function will return -EINTR. | ||
231 | * It returns 0 if the semaphore was acquired successfully. | ||
254 | */ | 232 | */ |
255 | static void nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) | 233 | static int nau8825_sema_acquire(struct nau8825 *nau8825, long timeout) |
256 | { | 234 | { |
257 | int ret; | 235 | int ret; |
258 | 236 | ||
259 | if (timeout) | 237 | if (timeout) { |
260 | ret = down_timeout(&nau8825->xtalk_sem, timeout); | 238 | ret = down_timeout(&nau8825->xtalk_sem, timeout); |
261 | else | 239 | if (ret < 0) |
240 | dev_warn(nau8825->dev, "Acquire semaphone timeout\n"); | ||
241 | } else { | ||
262 | ret = down_interruptible(&nau8825->xtalk_sem); | 242 | ret = down_interruptible(&nau8825->xtalk_sem); |
243 | if (ret < 0) | ||
244 | dev_warn(nau8825->dev, "Acquire semaphone fail\n"); | ||
245 | } | ||
263 | 246 | ||
264 | if (ret < 0) | 247 | return ret; |
265 | dev_warn(nau8825->dev, "Acquire semaphone fail\n"); | ||
266 | } | 248 | } |
267 | 249 | ||
268 | /** | 250 | /** |
@@ -1205,6 +1187,8 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, | |||
1205 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 1187 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
1206 | unsigned int val_len = 0; | 1188 | unsigned int val_len = 0; |
1207 | 1189 | ||
1190 | nau8825_sema_acquire(nau8825, 2 * HZ); | ||
1191 | |||
1208 | switch (params_width(params)) { | 1192 | switch (params_width(params)) { |
1209 | case 16: | 1193 | case 16: |
1210 | val_len |= NAU8825_I2S_DL_16; | 1194 | val_len |= NAU8825_I2S_DL_16; |
@@ -1225,6 +1209,9 @@ static int nau8825_hw_params(struct snd_pcm_substream *substream, | |||
1225 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, | 1209 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL1, |
1226 | NAU8825_I2S_DL_MASK, val_len); | 1210 | NAU8825_I2S_DL_MASK, val_len); |
1227 | 1211 | ||
1212 | /* Release the semaphone. */ | ||
1213 | nau8825_sema_release(nau8825); | ||
1214 | |||
1228 | return 0; | 1215 | return 0; |
1229 | } | 1216 | } |
1230 | 1217 | ||
@@ -1234,6 +1221,8 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
1234 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 1221 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
1235 | unsigned int ctrl1_val = 0, ctrl2_val = 0; | 1222 | unsigned int ctrl1_val = 0, ctrl2_val = 0; |
1236 | 1223 | ||
1224 | nau8825_sema_acquire(nau8825, 2 * HZ); | ||
1225 | |||
1237 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1226 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
1238 | case SND_SOC_DAIFMT_CBM_CFM: | 1227 | case SND_SOC_DAIFMT_CBM_CFM: |
1239 | ctrl2_val |= NAU8825_I2S_MS_MASTER; | 1228 | ctrl2_val |= NAU8825_I2S_MS_MASTER; |
@@ -1282,6 +1271,9 @@ static int nau8825_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
1282 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, | 1271 | regmap_update_bits(nau8825->regmap, NAU8825_REG_I2S_PCM_CTRL2, |
1283 | NAU8825_I2S_MS_MASK, ctrl2_val); | 1272 | NAU8825_I2S_MS_MASK, ctrl2_val); |
1284 | 1273 | ||
1274 | /* Release the semaphone. */ | ||
1275 | nau8825_sema_release(nau8825); | ||
1276 | |||
1285 | return 0; | 1277 | return 0; |
1286 | } | 1278 | } |
1287 | 1279 | ||
@@ -1611,8 +1603,11 @@ static irqreturn_t nau8825_interrupt(int irq, void *data) | |||
1611 | * cess and restore changes if process | 1603 | * cess and restore changes if process |
1612 | * is ongoing when ejection. | 1604 | * is ongoing when ejection. |
1613 | */ | 1605 | */ |
1606 | int ret; | ||
1614 | nau8825->xtalk_protect = true; | 1607 | nau8825->xtalk_protect = true; |
1615 | nau8825_sema_acquire(nau8825, 0); | 1608 | ret = nau8825_sema_acquire(nau8825, 0); |
1609 | if (ret < 0) | ||
1610 | nau8825->xtalk_protect = false; | ||
1616 | } | 1611 | } |
1617 | /* Startup cross talk detection process */ | 1612 | /* Startup cross talk detection process */ |
1618 | nau8825->xtalk_state = NAU8825_XTALK_PREPARE; | 1613 | nau8825->xtalk_state = NAU8825_XTALK_PREPARE; |
@@ -2238,23 +2233,14 @@ static int __maybe_unused nau8825_suspend(struct snd_soc_codec *codec) | |||
2238 | static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) | 2233 | static int __maybe_unused nau8825_resume(struct snd_soc_codec *codec) |
2239 | { | 2234 | { |
2240 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); | 2235 | struct nau8825 *nau8825 = snd_soc_codec_get_drvdata(codec); |
2236 | int ret; | ||
2241 | 2237 | ||
2242 | regcache_cache_only(nau8825->regmap, false); | 2238 | regcache_cache_only(nau8825->regmap, false); |
2243 | regcache_sync(nau8825->regmap); | 2239 | regcache_sync(nau8825->regmap); |
2244 | if (nau8825_is_jack_inserted(nau8825->regmap)) { | 2240 | nau8825->xtalk_protect = true; |
2245 | /* If the jack is inserted, we need to check whether the play- | 2241 | ret = nau8825_sema_acquire(nau8825, 0); |
2246 | * back is active before suspend. If active, the driver has to | 2242 | if (ret < 0) |
2247 | * raise the protection for cross talk function to avoid the | 2243 | nau8825->xtalk_protect = false; |
2248 | * playback recovers before cross talk process finish. Other- | ||
2249 | * wise, the playback will be interfered by cross talk func- | ||
2250 | * tion. It is better to apply hardware related parameters | ||
2251 | * before starting playback or record. | ||
2252 | */ | ||
2253 | if (nau8825_dai_is_active(nau8825)) { | ||
2254 | nau8825->xtalk_protect = true; | ||
2255 | nau8825_sema_acquire(nau8825, 0); | ||
2256 | } | ||
2257 | } | ||
2258 | enable_irq(nau8825->irq); | 2244 | enable_irq(nau8825->irq); |
2259 | 2245 | ||
2260 | return 0; | 2246 | return 0; |
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index a67ea10f41a1..f2664396be6f 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
@@ -581,7 +581,7 @@ static int wm2000_anc_transition(struct wm2000_priv *wm2000, | |||
581 | if (anc_transitions[i].dest == ANC_OFF) | 581 | if (anc_transitions[i].dest == ANC_OFF) |
582 | clk_disable_unprepare(wm2000->mclk); | 582 | clk_disable_unprepare(wm2000->mclk); |
583 | 583 | ||
584 | return ret; | 584 | return 0; |
585 | } | 585 | } |
586 | 586 | ||
587 | static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) | 587 | static int wm2000_anc_set_mode(struct wm2000_priv *wm2000) |