mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 18:12:03 +02:00
ASoC: codecs: Use guard() for mutex & spin locks - part 2
bui duc phuc <phucduc.bui@gmail.com> says: This series converts mutex and spinlock handling in ASoC codec drivers to use the guard() and scoped_guard() helpers. Compile-tested only. Link: https://patch.msgid.link/20260721102600.523199-1-phucduc.bui@gmail.com
This commit is contained in:
commit
baf390a9dc
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/acpi.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/property.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
|
|
@ -216,13 +217,10 @@ static int da7213_volsw_locked_get(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
ret = snd_soc_get_volsw(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
guard(mutex)(&da7213->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_get_volsw(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7213_volsw_locked_put(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -230,13 +228,10 @@ static int da7213_volsw_locked_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
ret = snd_soc_put_volsw(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
guard(mutex)(&da7213->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_put_volsw(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7213_enum_locked_get(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -244,13 +239,10 @@ static int da7213_enum_locked_get(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
ret = snd_soc_get_enum_double(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
guard(mutex)(&da7213->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_get_enum_double(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7213_enum_locked_put(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -258,13 +250,10 @@ static int da7213_enum_locked_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7213_priv *da7213 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
ret = snd_soc_put_enum_double(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
guard(mutex)(&da7213->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_put_enum_double(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
/* ALC */
|
||||
|
|
@ -465,9 +454,8 @@ static int da7213_tonegen_freq_get(struct snd_kcontrol *kcontrol,
|
|||
__le16 val;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val));
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
scoped_guard(mutex, &da7213->ctrl_lock)
|
||||
ret = regmap_raw_read(da7213->regmap, reg, &val, sizeof(val));
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -499,12 +487,11 @@ static int da7213_tonegen_freq_put(struct snd_kcontrol *kcontrol,
|
|||
*/
|
||||
val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
|
||||
|
||||
mutex_lock(&da7213->ctrl_lock);
|
||||
guard(mutex)(&da7213->ctrl_lock);
|
||||
ret = regmap_raw_read(da7213->regmap, reg, &val_old, sizeof(val_old));
|
||||
if (ret == 0 && (val_old != val_new))
|
||||
ret = regmap_raw_write(da7213->regmap, reg,
|
||||
&val_new, sizeof(val_new));
|
||||
mutex_unlock(&da7213->ctrl_lock);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/clkdev.h>
|
||||
#include <linux/clk-provider.h>
|
||||
|
|
@ -256,13 +257,10 @@ static int da7219_volsw_locked_get(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
ret = snd_soc_get_volsw(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
guard(mutex)(&da7219->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_get_volsw(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -270,13 +268,10 @@ static int da7219_volsw_locked_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
ret = snd_soc_put_volsw(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
guard(mutex)(&da7219->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_put_volsw(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -284,13 +279,10 @@ static int da7219_enum_locked_get(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
ret = snd_soc_get_enum_double(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
guard(mutex)(&da7219->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_get_enum_double(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -298,13 +290,10 @@ static int da7219_enum_locked_put(struct snd_kcontrol *kcontrol,
|
|||
{
|
||||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
ret = snd_soc_put_enum_double(kcontrol, ucontrol);
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
guard(mutex)(&da7219->ctrl_lock);
|
||||
|
||||
return ret;
|
||||
return snd_soc_put_enum_double(kcontrol, ucontrol);
|
||||
}
|
||||
|
||||
/* ALC */
|
||||
|
|
@ -422,9 +411,8 @@ static int da7219_tonegen_freq_get(struct snd_kcontrol *kcontrol,
|
|||
__le16 val;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val));
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
scoped_guard(mutex, &da7219->ctrl_lock)
|
||||
ret = regmap_raw_read(da7219->regmap, reg, &val, sizeof(val));
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
@ -456,12 +444,11 @@ static int da7219_tonegen_freq_put(struct snd_kcontrol *kcontrol,
|
|||
*/
|
||||
val_new = cpu_to_le16(ucontrol->value.integer.value[0]);
|
||||
|
||||
mutex_lock(&da7219->ctrl_lock);
|
||||
guard(mutex)(&da7219->ctrl_lock);
|
||||
ret = regmap_raw_read(da7219->regmap, reg, &val_old, sizeof(val_old));
|
||||
if (ret == 0 && (val_old != val_new))
|
||||
ret = regmap_raw_write(da7219->regmap, reg,
|
||||
&val_new, sizeof(val_new));
|
||||
mutex_unlock(&da7219->ctrl_lock);
|
||||
&val_new, sizeof(val_new));
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
|
@ -1167,15 +1154,12 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
|||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&da7219->pll_lock);
|
||||
guard(mutex)(&da7219->pll_lock);
|
||||
|
||||
if ((da7219->clk_src == clk_id) && (da7219->mclk_rate == freq)) {
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
if (da7219->clk_src == clk_id && da7219->mclk_rate == freq)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((freq < 2000000) || (freq > 54000000)) {
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
if (freq < 2000000 || freq > 54000000) {
|
||||
dev_err(codec_dai->dev, "Unsupported MCLK value %d\n",
|
||||
freq);
|
||||
return -EINVAL;
|
||||
|
|
@ -1193,7 +1177,6 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
|||
break;
|
||||
default:
|
||||
dev_err(codec_dai->dev, "Unknown clock source %d\n", clk_id);
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
|
@ -1203,17 +1186,13 @@ static int da7219_set_dai_sysclk(struct snd_soc_dai *codec_dai,
|
|||
freq = clk_round_rate(da7219->mclk, freq);
|
||||
ret = clk_set_rate(da7219->mclk, freq);
|
||||
if (ret) {
|
||||
dev_err(codec_dai->dev, "Failed to set clock rate %d\n",
|
||||
freq);
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
dev_err(codec_dai->dev, "Failed to set clock rate %d\n", freq);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
da7219->mclk_rate = freq;
|
||||
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1296,13 +1275,10 @@ static int da7219_set_dai_pll(struct snd_soc_dai *codec_dai, int pll_id,
|
|||
{
|
||||
struct snd_soc_component *component = codec_dai->component;
|
||||
struct da7219_priv *da7219 = snd_soc_component_get_drvdata(component);
|
||||
int ret;
|
||||
|
||||
mutex_lock(&da7219->pll_lock);
|
||||
ret = da7219_set_pll(component, source, fout);
|
||||
mutex_unlock(&da7219->pll_lock);
|
||||
guard(mutex)(&da7219->pll_lock);
|
||||
|
||||
return ret;
|
||||
return da7219_set_pll(component, source, fout);
|
||||
}
|
||||
|
||||
static int da7219_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <linux/module.h>
|
||||
#include <linux/acpi.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
|
|
@ -620,15 +621,15 @@ static irqreturn_t es8316_irq(int irq, void *data)
|
|||
struct snd_soc_component *comp = es8316->component;
|
||||
unsigned int flags;
|
||||
|
||||
mutex_lock(&es8316->lock);
|
||||
guard(mutex)(&es8316->lock);
|
||||
|
||||
regmap_read(es8316->regmap, ES8316_GPIO_FLAG, &flags);
|
||||
if (flags == 0x00)
|
||||
goto out; /* Powered-down / reset */
|
||||
return IRQ_HANDLED; /* Powered-down / reset */
|
||||
|
||||
/* Catch spurious IRQ before set_jack is called */
|
||||
if (!es8316->jack)
|
||||
goto out;
|
||||
return IRQ_HANDLED;
|
||||
|
||||
if (es8316->jd_inverted)
|
||||
flags ^= ES8316_GPIO_FLAG_HP_NOT_INSERTED;
|
||||
|
|
@ -681,8 +682,6 @@ static irqreturn_t es8316_irq(int irq, void *data)
|
|||
}
|
||||
}
|
||||
|
||||
out:
|
||||
mutex_unlock(&es8316->lock);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
|
|
@ -699,18 +698,16 @@ static void es8316_enable_jack_detect(struct snd_soc_component *component,
|
|||
es8316->jd_inverted = device_property_read_bool(component->dev,
|
||||
"everest,jack-detect-inverted");
|
||||
|
||||
mutex_lock(&es8316->lock);
|
||||
scoped_guard(mutex, &es8316->lock) {
|
||||
es8316->jack = jack;
|
||||
|
||||
es8316->jack = jack;
|
||||
if (es8316->jack->status & SND_JACK_MICROPHONE)
|
||||
es8316_enable_micbias_for_mic_gnd_short_detect(component);
|
||||
|
||||
if (es8316->jack->status & SND_JACK_MICROPHONE)
|
||||
es8316_enable_micbias_for_mic_gnd_short_detect(component);
|
||||
|
||||
snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE,
|
||||
ES8316_GPIO_ENABLE_INTERRUPT,
|
||||
ES8316_GPIO_ENABLE_INTERRUPT);
|
||||
|
||||
mutex_unlock(&es8316->lock);
|
||||
snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE,
|
||||
ES8316_GPIO_ENABLE_INTERRUPT,
|
||||
ES8316_GPIO_ENABLE_INTERRUPT);
|
||||
}
|
||||
|
||||
/* Enable irq and sync initial jack state */
|
||||
enable_irq(es8316->irq);
|
||||
|
|
@ -726,7 +723,7 @@ static void es8316_disable_jack_detect(struct snd_soc_component *component)
|
|||
|
||||
disable_irq(es8316->irq);
|
||||
|
||||
mutex_lock(&es8316->lock);
|
||||
guard(mutex)(&es8316->lock);
|
||||
|
||||
snd_soc_component_update_bits(component, ES8316_GPIO_DEBOUNCE,
|
||||
ES8316_GPIO_ENABLE_INTERRUPT, 0);
|
||||
|
|
@ -737,8 +734,6 @@ static void es8316_disable_jack_detect(struct snd_soc_component *component)
|
|||
}
|
||||
|
||||
es8316->jack = NULL;
|
||||
|
||||
mutex_unlock(&es8316->lock);
|
||||
}
|
||||
|
||||
static int es8316_set_jack(struct snd_soc_component *component,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Authors: David Yang <yangxiaohua@everest-semi.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
|
@ -790,7 +791,7 @@ static void es8326_jack_button_handler(struct work_struct *work)
|
|||
if (!(es8326->jack->status & SND_JACK_HEADSET)) /* Jack unplugged */
|
||||
return;
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
|
||||
switch (iface) {
|
||||
case 0x93:
|
||||
|
|
@ -845,7 +846,6 @@ static void es8326_jack_button_handler(struct work_struct *work)
|
|||
}
|
||||
es8326_disable_micbias(es8326->component);
|
||||
}
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static void es8326_jack_detect_handler(struct work_struct *work)
|
||||
|
|
@ -855,7 +855,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
struct snd_soc_component *comp = es8326->component;
|
||||
unsigned int iface;
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
iface = snd_soc_component_read(comp, ES8326_HPDET_STA);
|
||||
dev_dbg(comp->dev, "gpio flag %#04x", iface);
|
||||
|
||||
|
|
@ -873,7 +873,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
regmap_update_bits(es8326->regmap, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, (es8326->jd_inverted ?
|
||||
~es8326->jack_pol : es8326->jack_pol));
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((iface & ES8326_HPINSERT_FLAG) == 0) {
|
||||
|
|
@ -930,7 +930,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
queue_delayed_work(system_dfl_wq, &es8326->jack_detect_work,
|
||||
msecs_to_jiffies(400));
|
||||
es8326->hp = 1;
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
if (es8326->jack->status & SND_JACK_HEADSET) {
|
||||
/* detect button */
|
||||
|
|
@ -939,7 +939,7 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
(ES8326_INT_SRC_PIN9 | ES8326_INT_SRC_BUTTON));
|
||||
es8326_enable_micbias(es8326->component);
|
||||
queue_delayed_work(system_dfl_wq, &es8326->button_press_work, 10);
|
||||
goto exit;
|
||||
return;
|
||||
}
|
||||
if ((iface & ES8326_HPBUTTON_FLAG) == 0x01) {
|
||||
dev_dbg(comp->dev, "Headphone detected\n");
|
||||
|
|
@ -958,8 +958,6 @@ static void es8326_jack_detect_handler(struct work_struct *work)
|
|||
usleep_range(10000, 15000);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static irqreturn_t es8326_irq(int irq, void *dev_id)
|
||||
|
|
@ -1200,13 +1198,12 @@ static void es8326_enable_jack_detect(struct snd_soc_component *component,
|
|||
{
|
||||
struct es8326_priv *es8326 = snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
if (es8326->jd_inverted)
|
||||
snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
|
||||
es8326->jack = jack;
|
||||
|
||||
mutex_unlock(&es8326->lock);
|
||||
scoped_guard(mutex, &es8326->lock) {
|
||||
if (es8326->jd_inverted)
|
||||
snd_soc_component_update_bits(component, ES8326_HPDET_TYPE,
|
||||
ES8326_HP_DET_JACK_POL, ~es8326->jack_pol);
|
||||
es8326->jack = jack;
|
||||
}
|
||||
es8326_irq(es8326->irq, es8326);
|
||||
}
|
||||
|
||||
|
|
@ -1219,13 +1216,12 @@ static void es8326_disable_jack_detect(struct snd_soc_component *component)
|
|||
return; /* Already disabled (or never enabled) */
|
||||
cancel_delayed_work_sync(&es8326->jack_detect_work);
|
||||
|
||||
mutex_lock(&es8326->lock);
|
||||
guard(mutex)(&es8326->lock);
|
||||
if (es8326->jack->status & SND_JACK_MICROPHONE) {
|
||||
es8326_disable_micbias(component);
|
||||
snd_soc_jack_report(es8326->jack, 0, SND_JACK_HEADSET);
|
||||
}
|
||||
es8326->jack = NULL;
|
||||
mutex_unlock(&es8326->lock);
|
||||
}
|
||||
|
||||
static int es8326_set_jack(struct snd_soc_component *component,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/soundwire/sdw.h>
|
||||
|
|
@ -500,16 +501,19 @@ static int es9356_power_state(struct snd_soc_dai *dai, unsigned char ps, unsigne
|
|||
}
|
||||
|
||||
/* power state changes are not independent across functions */
|
||||
mutex_lock(&es9356->pde_lock);
|
||||
ret = es9356_pde_transition_delay(es9356, func, pde_entity, ps?ps0:ps3);
|
||||
if (ret) {
|
||||
regmap_write(es9356->regmap,
|
||||
SDW_SDCA_CTL(func, pde_entity, ES9356_SDCA_CTL_REQ_POWER_STATE, 0), ps?ps3:ps0);
|
||||
es9356_pde_transition_delay(es9356, func, pde_entity, ps?ps3:ps0);
|
||||
} else
|
||||
dev_dbg(component->dev, "%s PDE is already %d\n", __func__, ps?ps0:ps3);
|
||||
|
||||
mutex_unlock(&es9356->pde_lock);
|
||||
scoped_guard(mutex, &es9356->pde_lock) {
|
||||
ret = es9356_pde_transition_delay(es9356, func, pde_entity, ps ? ps0 : ps3);
|
||||
if (ret) {
|
||||
regmap_write(es9356->regmap,
|
||||
SDW_SDCA_CTL(func, pde_entity,
|
||||
ES9356_SDCA_CTL_REQ_POWER_STATE, 0),
|
||||
ps ? ps3 : ps0);
|
||||
es9356_pde_transition_delay(es9356, func, pde_entity, ps ? ps3 : ps0);
|
||||
} else {
|
||||
dev_dbg(component->dev, "%s PDE is already %d\n", __func__,
|
||||
ps ? ps0 : ps3);
|
||||
}
|
||||
}
|
||||
|
||||
if (rate)
|
||||
regmap_write(es9356->regmap,
|
||||
|
|
@ -1091,9 +1095,8 @@ static int es9356_sdca_dev_system_suspend(struct device *dev)
|
|||
{
|
||||
struct es9356_sdw_priv *es9356 = dev_get_drvdata(dev);
|
||||
|
||||
mutex_lock(&es9356->disable_irq_lock);
|
||||
es9356->disable_irq = true;
|
||||
mutex_unlock(&es9356->disable_irq_lock);
|
||||
scoped_guard(mutex, &es9356->disable_irq_lock)
|
||||
es9356->disable_irq = true;
|
||||
|
||||
return es9356_sdca_dev_suspend(dev);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Copyright (C) 2016-2025 Shanghai FourSemi Semiconductor Co.,Ltd.
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c.h>
|
||||
|
|
@ -770,9 +771,8 @@ static int fs210x_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
if (fs210x->devid == FS2105S_DEVICE_ID && fs210x->srate == 16000)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
ret = fs210x_set_hw_params(fs210x);
|
||||
mutex_unlock(&fs210x->lock);
|
||||
scoped_guard(mutex, &fs210x->lock)
|
||||
ret = fs210x_set_hw_params(fs210x);
|
||||
if (ret)
|
||||
dev_err(fs210x->dev, "Failed to set hw params: %d\n", ret);
|
||||
|
||||
|
|
@ -789,15 +789,11 @@ static int fs210x_dai_mute(struct snd_soc_dai *dai, int mute, int stream)
|
|||
|
||||
fs210x = snd_soc_component_get_drvdata(dai->component);
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
|
||||
if (!fs210x->is_inited || fs210x->is_suspended) {
|
||||
mutex_unlock(&fs210x->lock);
|
||||
return 0;
|
||||
scoped_guard(mutex, &fs210x->lock) {
|
||||
if (!fs210x->is_inited || fs210x->is_suspended)
|
||||
return 0;
|
||||
}
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
if (mute) {
|
||||
cancel_delayed_work_sync(&fs210x->fault_check_work);
|
||||
cancel_delayed_work_sync(&fs210x->start_work);
|
||||
|
|
@ -816,15 +812,11 @@ static int fs210x_dai_trigger(struct snd_pcm_substream *substream,
|
|||
|
||||
fs210x = snd_soc_component_get_drvdata(dai->component);
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
|
||||
if (!fs210x->is_inited || fs210x->is_suspended || fs210x->is_playing) {
|
||||
mutex_unlock(&fs210x->lock);
|
||||
return 0;
|
||||
scoped_guard(mutex, &fs210x->lock) {
|
||||
if (!fs210x->is_inited || fs210x->is_suspended || fs210x->is_playing)
|
||||
return 0;
|
||||
}
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
switch (cmd) {
|
||||
case SNDRV_PCM_TRIGGER_START:
|
||||
case SNDRV_PCM_TRIGGER_RESUME:
|
||||
|
|
@ -852,13 +844,11 @@ static void fs210x_start_work(struct work_struct *work)
|
|||
|
||||
fs210x = container_of(work, struct fs210x_priv, start_work.work);
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
|
||||
ret = fs210x_dev_play(fs210x);
|
||||
if (ret)
|
||||
dev_err(fs210x->dev, "Failed to start playing: %d\n", ret);
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
}
|
||||
|
||||
static void fs210x_fault_check_work(struct work_struct *work)
|
||||
|
|
@ -869,15 +859,13 @@ static void fs210x_fault_check_work(struct work_struct *work)
|
|||
|
||||
fs210x = container_of(work, struct fs210x_priv, fault_check_work.work);
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
scoped_guard(mutex, &fs210x->lock) {
|
||||
if (!fs210x->is_inited || fs210x->is_suspended || !fs210x->is_playing)
|
||||
return;
|
||||
|
||||
if (!fs210x->is_inited || fs210x->is_suspended || !fs210x->is_playing) {
|
||||
mutex_unlock(&fs210x->lock);
|
||||
return;
|
||||
ret = fs210x_reg_read(fs210x, FS210X_05H_ANASTAT, &status);
|
||||
}
|
||||
|
||||
ret = fs210x_reg_read(fs210x, FS210X_05H_ANASTAT, &status);
|
||||
mutex_unlock(&fs210x->lock);
|
||||
if (ret)
|
||||
return;
|
||||
|
||||
|
|
@ -990,7 +978,7 @@ static int fs210x_effect_scene_get(struct snd_kcontrol *kcontrol,
|
|||
if (fs210x->scene_id < 1)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
/*
|
||||
* FS210x has scene(s) as below:
|
||||
* init scene: id = 0
|
||||
|
|
@ -999,7 +987,6 @@ static int fs210x_effect_scene_get(struct snd_kcontrol *kcontrol,
|
|||
*/
|
||||
index = fs210x->scene_id - 1;
|
||||
ucontrol->value.integer.value[0] = index;
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1018,7 +1005,7 @@ static int fs210x_effect_scene_put(struct snd_kcontrol *kcontrol,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
|
||||
/*
|
||||
* FS210x has scene(s) as below:
|
||||
|
|
@ -1028,17 +1015,14 @@ static int fs210x_effect_scene_put(struct snd_kcontrol *kcontrol,
|
|||
*/
|
||||
scene_id = ucontrol->value.integer.value[0] + 1;
|
||||
scene_count = fs210x->amp_lib.scene_count - 1; /* Skip init scene */
|
||||
if (scene_id < 1 || scene_id > scene_count) {
|
||||
mutex_unlock(&fs210x->lock);
|
||||
if (scene_id < 1 || scene_id > scene_count)
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
if (scene_id != fs210x->scene_id)
|
||||
is_changed = true;
|
||||
|
||||
if (fs210x->is_suspended) {
|
||||
fs210x->scene_id = scene_id;
|
||||
mutex_unlock(&fs210x->lock);
|
||||
return is_changed;
|
||||
}
|
||||
|
||||
|
|
@ -1046,8 +1030,6 @@ static int fs210x_effect_scene_put(struct snd_kcontrol *kcontrol,
|
|||
if (ret)
|
||||
dev_err(fs210x->dev, "Failed to set scene: %d\n", ret);
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
if (!ret && is_changed)
|
||||
return 1;
|
||||
|
||||
|
|
@ -1061,12 +1043,10 @@ static int fs210x_playback_event(struct snd_soc_dapm_widget *w,
|
|||
struct fs210x_priv *fs210x = snd_soc_component_get_drvdata(cmpnt);
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
|
||||
if (fs210x->is_suspended) {
|
||||
mutex_unlock(&fs210x->lock);
|
||||
if (fs210x->is_suspended)
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
|
|
@ -1087,8 +1067,6 @@ static int fs210x_playback_event(struct snd_soc_dapm_widget *w,
|
|||
break;
|
||||
}
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1219,11 +1197,9 @@ static int fs210x_probe(struct snd_soc_component *cmpnt)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
ret = fs210x_init_chip(fs210x);
|
||||
mutex_unlock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
|
||||
return ret;
|
||||
return fs210x_init_chip(fs210x);
|
||||
}
|
||||
|
||||
static void fs210x_remove(struct snd_soc_component *cmpnt)
|
||||
|
|
@ -1250,15 +1226,15 @@ static int fs210x_suspend(struct snd_soc_component *cmpnt)
|
|||
|
||||
regcache_cache_only(fs210x->regmap, true);
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
fs210x->cur_scene = NULL;
|
||||
fs210x->is_inited = false;
|
||||
fs210x->is_playing = false;
|
||||
fs210x->is_suspended = true;
|
||||
scoped_guard(mutex, &fs210x->lock) {
|
||||
fs210x->cur_scene = NULL;
|
||||
fs210x->is_inited = false;
|
||||
fs210x->is_playing = false;
|
||||
fs210x->is_suspended = true;
|
||||
|
||||
gpiod_set_value_cansleep(fs210x->gpio_sdz, 1); /* Active */
|
||||
fsleep(30000); /* >= 30ms */
|
||||
mutex_unlock(&fs210x->lock);
|
||||
gpiod_set_value_cansleep(fs210x->gpio_sdz, 1); /* Active */
|
||||
fsleep(30000); /* >= 30ms */
|
||||
}
|
||||
|
||||
cancel_delayed_work_sync(&fs210x->start_work);
|
||||
cancel_delayed_work_sync(&fs210x->fault_check_work);
|
||||
|
|
@ -1287,14 +1263,11 @@ static int fs210x_resume(struct snd_soc_component *cmpnt)
|
|||
return ret;
|
||||
}
|
||||
|
||||
mutex_lock(&fs210x->lock);
|
||||
guard(mutex)(&fs210x->lock);
|
||||
|
||||
fs210x->is_suspended = false;
|
||||
ret = fs210x_init_chip(fs210x);
|
||||
|
||||
mutex_unlock(&fs210x->lock);
|
||||
|
||||
return ret;
|
||||
return fs210x_init_chip(fs210x);
|
||||
}
|
||||
#else
|
||||
#define fs210x_suspend NULL
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -537,10 +538,11 @@ static struct hdac_hdmi_port *hdac_hdmi_get_port_from_cvt(
|
|||
continue;
|
||||
|
||||
list_for_each_entry(port, &pcm->port_list, head) {
|
||||
mutex_lock(&pcm->lock);
|
||||
ret = hdac_hdmi_query_port_connlist(hdev,
|
||||
port->pin, port);
|
||||
mutex_unlock(&pcm->lock);
|
||||
scoped_guard(mutex, &pcm->lock) {
|
||||
ret = hdac_hdmi_query_port_connlist(hdev,
|
||||
port->pin,
|
||||
port);
|
||||
}
|
||||
if (ret < 0)
|
||||
continue;
|
||||
|
||||
|
|
@ -640,11 +642,11 @@ static void hdac_hdmi_pcm_close(struct snd_pcm_substream *substream,
|
|||
pcm = hdac_hdmi_get_pcm_from_cvt(hdmi, dai_map->cvt);
|
||||
|
||||
if (pcm) {
|
||||
mutex_lock(&pcm->lock);
|
||||
pcm->chmap_set = false;
|
||||
memset(pcm->chmap, 0, sizeof(pcm->chmap));
|
||||
pcm->channels = 0;
|
||||
mutex_unlock(&pcm->lock);
|
||||
scoped_guard(mutex, &pcm->lock) {
|
||||
pcm->chmap_set = false;
|
||||
memset(pcm->chmap, 0, sizeof(pcm->chmap));
|
||||
pcm->channels = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (dai_map->port)
|
||||
|
|
@ -922,7 +924,7 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,
|
|||
if (port == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&hdmi->pin_mutex);
|
||||
guard(mutex)(&hdmi->pin_mutex);
|
||||
list_for_each_entry(pcm, &hdmi->pcm_list, head) {
|
||||
if (list_empty(&pcm->port_list))
|
||||
continue;
|
||||
|
|
@ -945,12 +947,10 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,
|
|||
list_add_tail(&port->head, &pcm->port_list);
|
||||
if (port->eld.monitor_present && port->eld.eld_valid) {
|
||||
hdac_hdmi_jack_report_sync(pcm, port, true);
|
||||
mutex_unlock(&hdmi->pin_mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex_unlock(&hdmi->pin_mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -1274,67 +1274,65 @@ static void hdac_hdmi_present_sense(struct hdac_hdmi_pin *pin,
|
|||
* In case of non MST pin, get_eld info API expectes port
|
||||
* to be -1.
|
||||
*/
|
||||
mutex_lock(&hdmi->pin_mutex);
|
||||
port->eld.monitor_present = false;
|
||||
scoped_guard(mutex, &hdmi->pin_mutex) {
|
||||
port->eld.monitor_present = false;
|
||||
|
||||
if (pin->mst_capable)
|
||||
port_id = port->id;
|
||||
if (pin->mst_capable)
|
||||
port_id = port->id;
|
||||
|
||||
size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id,
|
||||
&port->eld.monitor_present,
|
||||
port->eld.eld_buffer,
|
||||
ELD_MAX_SIZE);
|
||||
size = snd_hdac_acomp_get_eld(hdev, pin->nid, port_id,
|
||||
&port->eld.monitor_present,
|
||||
port->eld.eld_buffer,
|
||||
ELD_MAX_SIZE);
|
||||
|
||||
if (size > 0) {
|
||||
size = min(size, ELD_MAX_SIZE);
|
||||
if (hdac_hdmi_parse_eld(hdev, port) < 0)
|
||||
size = -EINVAL;
|
||||
}
|
||||
|
||||
eld_valid = port->eld.eld_valid;
|
||||
|
||||
if (size > 0) {
|
||||
port->eld.eld_valid = true;
|
||||
port->eld.eld_size = size;
|
||||
} else {
|
||||
port->eld.eld_valid = false;
|
||||
port->eld.eld_size = 0;
|
||||
}
|
||||
|
||||
eld_changed = (eld_valid != port->eld.eld_valid);
|
||||
|
||||
pcm = hdac_hdmi_get_pcm(hdev, port);
|
||||
|
||||
if (!port->eld.monitor_present || !port->eld.eld_valid) {
|
||||
|
||||
dev_dbg(&hdev->dev, "%s: disconnect for pin:port %d:%d\n",
|
||||
__func__, pin->nid, port->id);
|
||||
|
||||
/*
|
||||
* PCMs are not registered during device probe, so don't
|
||||
* report jack here. It will be done in usermode mux
|
||||
* control select.
|
||||
*/
|
||||
if (pcm) {
|
||||
hdac_hdmi_jack_report(pcm, port, false);
|
||||
schedule_work(&port->dapm_work);
|
||||
if (size > 0) {
|
||||
size = min(size, ELD_MAX_SIZE);
|
||||
if (hdac_hdmi_parse_eld(hdev, port) < 0)
|
||||
size = -EINVAL;
|
||||
}
|
||||
|
||||
mutex_unlock(&hdmi->pin_mutex);
|
||||
return;
|
||||
}
|
||||
eld_valid = port->eld.eld_valid;
|
||||
|
||||
if (port->eld.monitor_present && port->eld.eld_valid) {
|
||||
if (pcm) {
|
||||
hdac_hdmi_jack_report(pcm, port, true);
|
||||
schedule_work(&port->dapm_work);
|
||||
if (size > 0) {
|
||||
port->eld.eld_valid = true;
|
||||
port->eld.eld_size = size;
|
||||
} else {
|
||||
port->eld.eld_valid = false;
|
||||
port->eld.eld_size = 0;
|
||||
}
|
||||
|
||||
print_hex_dump_debug("ELD: ", DUMP_PREFIX_OFFSET, 16, 1,
|
||||
port->eld.eld_buffer, port->eld.eld_size, false);
|
||||
eld_changed = (eld_valid != port->eld.eld_valid);
|
||||
|
||||
pcm = hdac_hdmi_get_pcm(hdev, port);
|
||||
|
||||
if (!port->eld.monitor_present || !port->eld.eld_valid) {
|
||||
|
||||
dev_dbg(&hdev->dev, "%s: disconnect for pin:port %d:%d\n",
|
||||
__func__, pin->nid, port->id);
|
||||
|
||||
/*
|
||||
* PCMs are not registered during device probe, so don't
|
||||
* report jack here. It will be done in usermode mux
|
||||
* control select.
|
||||
*/
|
||||
if (pcm) {
|
||||
hdac_hdmi_jack_report(pcm, port, false);
|
||||
schedule_work(&port->dapm_work);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (port->eld.monitor_present && port->eld.eld_valid) {
|
||||
if (pcm) {
|
||||
hdac_hdmi_jack_report(pcm, port, true);
|
||||
schedule_work(&port->dapm_work);
|
||||
}
|
||||
|
||||
print_hex_dump_debug("ELD: ", DUMP_PREFIX_OFFSET, 16, 1,
|
||||
port->eld.eld_buffer, port->eld.eld_size, false);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&hdmi->pin_mutex);
|
||||
|
||||
if (eld_changed && pcm)
|
||||
snd_ctl_notify(hdmi->card,
|
||||
|
|
@ -1795,13 +1793,12 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdev, int pcm_idx,
|
|||
if (list_empty(&pcm->port_list))
|
||||
return;
|
||||
|
||||
mutex_lock(&pcm->lock);
|
||||
guard(mutex)(&pcm->lock);
|
||||
pcm->chmap_set = true;
|
||||
memcpy(pcm->chmap, chmap, ARRAY_SIZE(pcm->chmap));
|
||||
list_for_each_entry(port, &pcm->port_list, head)
|
||||
if (prepared)
|
||||
hdac_hdmi_setup_audio_infoframe(hdev, pcm, port);
|
||||
mutex_unlock(&pcm->lock);
|
||||
}
|
||||
|
||||
static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdev, int pcm_idx)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
* Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
|
||||
* Author: Jyri Sarha <jsarha@ti.com>
|
||||
*/
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/string.h>
|
||||
#include <sound/core.h>
|
||||
|
|
@ -452,31 +453,30 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
|
|||
if (!((has_playback && tx) || (has_capture && !tx)))
|
||||
return 0;
|
||||
|
||||
mutex_lock(&hcp->lock);
|
||||
guard(mutex)(&hcp->lock);
|
||||
if (hcp->busy) {
|
||||
dev_err(dai->dev, "Only one simultaneous stream supported!\n");
|
||||
mutex_unlock(&hcp->lock);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (hcp->hcd.ops->audio_startup) {
|
||||
ret = hcp->hcd.ops->audio_startup(dai->dev->parent, hcp->hcd.data);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (tx && hcp->hcd.ops->get_eld) {
|
||||
ret = hcp->hcd.ops->get_eld(dai->dev->parent, hcp->hcd.data,
|
||||
hcp->eld, sizeof(hcp->eld));
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
|
||||
snd_parse_eld(dai->dev, &hcp->eld_parsed,
|
||||
hcp->eld, sizeof(hcp->eld));
|
||||
|
||||
ret = snd_pcm_hw_constraint_eld(substream->runtime, hcp->eld);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
|
||||
/* Select chmap supported */
|
||||
hdmi_codec_eld_chmap(hcp);
|
||||
|
|
@ -484,8 +484,6 @@ static int hdmi_codec_startup(struct snd_pcm_substream *substream,
|
|||
|
||||
hcp->busy = true;
|
||||
|
||||
err:
|
||||
mutex_unlock(&hcp->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -503,9 +501,8 @@ static void hdmi_codec_shutdown(struct snd_pcm_substream *substream,
|
|||
hcp->chmap_idx = HDMI_CODEC_CHMAP_IDX_UNKNOWN;
|
||||
hcp->hcd.ops->audio_shutdown(dai->dev->parent, hcp->hcd.data);
|
||||
|
||||
mutex_lock(&hcp->lock);
|
||||
guard(mutex)(&hcp->lock);
|
||||
hcp->busy = false;
|
||||
mutex_unlock(&hcp->lock);
|
||||
}
|
||||
|
||||
static int hdmi_codec_fill_codec_params(struct snd_soc_dai *dai,
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
// Author: Herve Codina <herve.codina@bootlin.com>
|
||||
|
||||
#include <linux/bitrev.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/gpio/driver.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
|
|
@ -413,12 +414,12 @@ static int idt821034_kctrl_gain_get(struct snd_kcontrol *kcontrol,
|
|||
|
||||
ch = IDT821034_ID_GET_CHAN(mc->reg);
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
if (IDT821034_ID_IS_OUT(mc->reg))
|
||||
val = idt821034->amps.ch[ch].amp_out.gain;
|
||||
else
|
||||
val = idt821034->amps.ch[ch].amp_in.gain;
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
scoped_guard(mutex, &idt821034->mutex) {
|
||||
if (IDT821034_ID_IS_OUT(mc->reg))
|
||||
val = idt821034->amps.ch[ch].amp_out.gain;
|
||||
else
|
||||
val = idt821034->amps.ch[ch].amp_in.gain;
|
||||
}
|
||||
|
||||
ucontrol->value.integer.value[0] = val & mask;
|
||||
if (invert)
|
||||
|
|
@ -456,7 +457,7 @@ static int idt821034_kctrl_gain_put(struct snd_kcontrol *kcontrol,
|
|||
|
||||
ch = IDT821034_ID_GET_CHAN(mc->reg);
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
if (IDT821034_ID_IS_OUT(mc->reg)) {
|
||||
amp = &idt821034->amps.ch[ch].amp_out;
|
||||
|
|
@ -466,22 +467,18 @@ static int idt821034_kctrl_gain_put(struct snd_kcontrol *kcontrol,
|
|||
gain_type = IDT821034_GAIN_TX;
|
||||
}
|
||||
|
||||
if (amp->gain == val) {
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
if (amp->gain == val)
|
||||
return 0;
|
||||
|
||||
if (!amp->is_muted) {
|
||||
ret = idt821034_set_gain_channel(idt821034, ch, gain_type, val);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
}
|
||||
|
||||
amp->gain = val;
|
||||
ret = 1; /* The value changed */
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int idt821034_kctrl_mute_get(struct snd_kcontrol *kcontrol,
|
||||
|
|
@ -495,11 +492,11 @@ static int idt821034_kctrl_mute_get(struct snd_kcontrol *kcontrol,
|
|||
|
||||
ch = IDT821034_ID_GET_CHAN(id);
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
is_muted = IDT821034_ID_IS_OUT(id) ?
|
||||
idt821034->amps.ch[ch].amp_out.is_muted :
|
||||
idt821034->amps.ch[ch].amp_in.is_muted;
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
scoped_guard(mutex, &idt821034->mutex) {
|
||||
is_muted = IDT821034_ID_IS_OUT(id) ?
|
||||
idt821034->amps.ch[ch].amp_out.is_muted :
|
||||
idt821034->amps.ch[ch].amp_in.is_muted;
|
||||
}
|
||||
|
||||
ucontrol->value.integer.value[0] = !is_muted;
|
||||
|
||||
|
|
@ -521,7 +518,7 @@ static int idt821034_kctrl_mute_put(struct snd_kcontrol *kcontrol,
|
|||
ch = IDT821034_ID_GET_CHAN(id);
|
||||
is_mute = !ucontrol->value.integer.value[0];
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
if (IDT821034_ID_IS_OUT(id)) {
|
||||
amp = &idt821034->amps.ch[ch].amp_out;
|
||||
|
|
@ -531,21 +528,17 @@ static int idt821034_kctrl_mute_put(struct snd_kcontrol *kcontrol,
|
|||
gain_type = IDT821034_GAIN_TX;
|
||||
}
|
||||
|
||||
if (amp->is_muted == is_mute) {
|
||||
ret = 0;
|
||||
goto end;
|
||||
}
|
||||
if (amp->is_muted == is_mute)
|
||||
return 0;
|
||||
|
||||
ret = idt821034_set_gain_channel(idt821034, ch, gain_type,
|
||||
is_mute ? 0 : amp->gain);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
amp->is_muted = is_mute;
|
||||
ret = 1; /* The value changed */
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const DECLARE_TLV_DB_LINEAR(idt821034_gain_in, -300, 1300);
|
||||
|
|
@ -623,24 +616,20 @@ static int idt821034_power_event(struct snd_soc_dapm_widget *w,
|
|||
struct idt821034 *idt821034 = snd_soc_component_get_drvdata(component);
|
||||
unsigned int id = w->shift;
|
||||
u8 power, mask;
|
||||
int ret;
|
||||
u8 ch;
|
||||
|
||||
ch = IDT821034_ID_GET_CHAN(id);
|
||||
mask = IDT821034_ID_IS_OUT(id) ? IDT821034_CONF_PWRUP_RX : IDT821034_CONF_PWRUP_TX;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
power = idt821034_get_channel_power(idt821034, ch);
|
||||
if (SND_SOC_DAPM_EVENT_ON(event))
|
||||
power |= mask;
|
||||
else
|
||||
power &= ~mask;
|
||||
ret = idt821034_set_channel_power(idt821034, ch, power);
|
||||
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
|
||||
return ret;
|
||||
return idt821034_set_channel_power(idt821034, ch, power);
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget idt821034_dapm_widgets[] = {
|
||||
|
|
@ -717,9 +706,9 @@ static int idt821034_dai_set_tdm_slot(struct snd_soc_dai *dai,
|
|||
ch = 0;
|
||||
while (mask && ch < IDT821034_NB_CHANNEL) {
|
||||
if (mask & 0x1) {
|
||||
mutex_lock(&idt821034->mutex);
|
||||
ret = idt821034_set_channel_ts(idt821034, ch, IDT821034_CH_RX, slot);
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
scoped_guard(mutex, &idt821034->mutex)
|
||||
ret = idt821034_set_channel_ts(idt821034, ch,
|
||||
IDT821034_CH_RX, slot);
|
||||
if (ret) {
|
||||
dev_err(dai->dev, "ch%u set tx tdm slot failed (%d)\n",
|
||||
ch, ret);
|
||||
|
|
@ -742,9 +731,9 @@ static int idt821034_dai_set_tdm_slot(struct snd_soc_dai *dai,
|
|||
ch = 0;
|
||||
while (mask && ch < IDT821034_NB_CHANNEL) {
|
||||
if (mask & 0x1) {
|
||||
mutex_lock(&idt821034->mutex);
|
||||
ret = idt821034_set_channel_ts(idt821034, ch, IDT821034_CH_TX, slot);
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
scoped_guard(mutex, &idt821034->mutex)
|
||||
ret = idt821034_set_channel_ts(idt821034, ch,
|
||||
IDT821034_CH_TX, slot);
|
||||
if (ret) {
|
||||
dev_err(dai->dev, "ch%u set rx tdm slot failed (%d)\n",
|
||||
ch, ret);
|
||||
|
|
@ -769,9 +758,8 @@ static int idt821034_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|||
{
|
||||
struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
|
||||
u8 conf;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
conf = idt821034_get_codec_conf(idt821034);
|
||||
|
||||
|
|
@ -785,13 +773,10 @@ static int idt821034_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
|
|||
default:
|
||||
dev_err(dai->dev, "Unsupported DAI format 0x%x\n",
|
||||
fmt & SND_SOC_DAIFMT_FORMAT_MASK);
|
||||
ret = -EINVAL;
|
||||
goto end;
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = idt821034_set_codec_conf(idt821034, conf);
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
|
||||
return idt821034_set_codec_conf(idt821034, conf);
|
||||
}
|
||||
|
||||
static int idt821034_dai_hw_params(struct snd_pcm_substream *substream,
|
||||
|
|
@ -800,9 +785,8 @@ static int idt821034_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
{
|
||||
struct idt821034 *idt821034 = snd_soc_component_get_drvdata(dai->component);
|
||||
u8 conf;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
conf = idt821034_get_codec_conf(idt821034);
|
||||
|
||||
|
|
@ -816,13 +800,10 @@ static int idt821034_dai_hw_params(struct snd_pcm_substream *substream,
|
|||
default:
|
||||
dev_err(dai->dev, "Unsupported PCM format 0x%x\n",
|
||||
params_format(params));
|
||||
ret = -EINVAL;
|
||||
goto end;
|
||||
return -EINVAL;
|
||||
}
|
||||
ret = idt821034_set_codec_conf(idt821034, conf);
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
|
||||
return idt821034_set_codec_conf(idt821034, conf);
|
||||
}
|
||||
|
||||
static const unsigned int idt821034_sample_bits[] = {8};
|
||||
|
|
@ -897,11 +878,11 @@ static int idt821034_reset_audio(struct idt821034 *idt821034)
|
|||
int ret;
|
||||
u8 i;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
ret = idt821034_set_codec_conf(idt821034, 0);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
for (i = 0; i < IDT821034_NB_CHANNEL; i++) {
|
||||
idt821034->amps.ch[i].amp_out.gain = IDT821034_GAIN_OUT_INIT_RAW;
|
||||
|
|
@ -909,24 +890,21 @@ static int idt821034_reset_audio(struct idt821034 *idt821034)
|
|||
ret = idt821034_set_gain_channel(idt821034, i, IDT821034_GAIN_RX,
|
||||
idt821034->amps.ch[i].amp_out.gain);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
idt821034->amps.ch[i].amp_in.gain = IDT821034_GAIN_IN_INIT_RAW;
|
||||
idt821034->amps.ch[i].amp_in.is_muted = false;
|
||||
ret = idt821034_set_gain_channel(idt821034, i, IDT821034_GAIN_TX,
|
||||
idt821034->amps.ch[i].amp_in.gain);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
ret = idt821034_set_channel_power(idt821034, i, 0);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int idt821034_component_probe(struct snd_soc_component *component)
|
||||
|
|
@ -965,7 +943,7 @@ static int idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
|
|||
u8 slic_raw;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
slic_raw = idt821034_get_written_slic_raw(idt821034, ch);
|
||||
if (val)
|
||||
|
|
@ -974,8 +952,6 @@ static int idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
|
|||
slic_raw &= ~mask;
|
||||
ret = idt821034_write_slic_raw(idt821034, ch, slic_raw);
|
||||
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
|
||||
if (ret)
|
||||
dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
|
||||
offset, ch, mask, ret);
|
||||
|
|
@ -991,9 +967,8 @@ static int idt821034_chip_gpio_get(struct gpio_chip *c, unsigned int offset)
|
|||
u8 slic_raw;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
ret = idt821034_read_slic_raw(idt821034, ch, &slic_raw);
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
scoped_guard(mutex, &idt821034->mutex)
|
||||
ret = idt821034_read_slic_raw(idt821034, ch, &slic_raw);
|
||||
if (ret) {
|
||||
dev_err(&idt821034->spi->dev, "get gpio %d (%u, 0x%x) failed (%d)\n",
|
||||
offset, ch, mask, ret);
|
||||
|
|
@ -1015,9 +990,8 @@ static int idt821034_chip_get_direction(struct gpio_chip *c, unsigned int offset
|
|||
struct idt821034 *idt821034 = gpiochip_get_data(c);
|
||||
u8 slic_dir;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
slic_dir = idt821034_get_slic_conf(idt821034, ch);
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
|
||||
return slic_dir & mask ? GPIO_LINE_DIRECTION_IN : GPIO_LINE_DIRECTION_OUT;
|
||||
}
|
||||
|
|
@ -1034,7 +1008,7 @@ static int idt821034_chip_direction_input(struct gpio_chip *c, unsigned int offs
|
|||
if (mask & ~(IDT821034_SLIC_IO1_IN | IDT821034_SLIC_IO0_IN))
|
||||
return -EPERM;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
slic_conf = idt821034_get_slic_conf(idt821034, ch) | mask;
|
||||
|
||||
|
|
@ -1044,7 +1018,6 @@ static int idt821034_chip_direction_input(struct gpio_chip *c, unsigned int offs
|
|||
offset, ch, mask, ret);
|
||||
}
|
||||
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1060,7 +1033,7 @@ static int idt821034_chip_direction_output(struct gpio_chip *c, unsigned int off
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
slic_conf = idt821034_get_slic_conf(idt821034, ch) & ~mask;
|
||||
|
||||
|
|
@ -1070,7 +1043,6 @@ static int idt821034_chip_direction_output(struct gpio_chip *c, unsigned int off
|
|||
offset, ch, mask, ret);
|
||||
}
|
||||
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1079,24 +1051,22 @@ static int idt821034_reset_gpio(struct idt821034 *idt821034)
|
|||
int ret;
|
||||
u8 i;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
guard(mutex)(&idt821034->mutex);
|
||||
|
||||
/* IO0 and IO1 as input for all channels and output IO set to 0 */
|
||||
for (i = 0; i < IDT821034_NB_CHANNEL; i++) {
|
||||
ret = idt821034_set_slic_conf(idt821034, i,
|
||||
IDT821034_SLIC_IO1_IN | IDT821034_SLIC_IO0_IN);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
ret = idt821034_write_slic_raw(idt821034, i, 0);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
}
|
||||
ret = 0;
|
||||
end:
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int idt821034_gpio_init(struct idt821034 *idt821034)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
// Copyright (c) 2022, The Linux Foundation. All rights reserved.
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/export.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -71,21 +72,16 @@ EXPORT_SYMBOL_GPL(lpass_macro_pds_exit);
|
|||
|
||||
void lpass_macro_set_codec_version(enum lpass_codec_version version)
|
||||
{
|
||||
mutex_lock(&lpass_codec_mutex);
|
||||
guard(mutex)(&lpass_codec_mutex);
|
||||
lpass_codec_version = version;
|
||||
mutex_unlock(&lpass_codec_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lpass_macro_set_codec_version);
|
||||
|
||||
enum lpass_codec_version lpass_macro_get_codec_version(void)
|
||||
{
|
||||
enum lpass_codec_version ver;
|
||||
guard(mutex)(&lpass_codec_mutex);
|
||||
|
||||
mutex_lock(&lpass_codec_mutex);
|
||||
ver = lpass_codec_version;
|
||||
mutex_unlock(&lpass_codec_mutex);
|
||||
|
||||
return ver;
|
||||
return lpass_codec_version;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(lpass_macro_get_codec_version);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Cirrus Logic International Semiconductor Ltd.
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/gcd.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -513,7 +514,7 @@ int madera_domain_clk_ev(struct snd_soc_dapm_widget *w,
|
|||
* We can't rely on the DAPM mutex for locking because we need a lock
|
||||
* that can safely be called in hw_params
|
||||
*/
|
||||
mutex_lock(&priv->rate_lock);
|
||||
guard(mutex)(&priv->rate_lock);
|
||||
|
||||
switch (event) {
|
||||
case SND_SOC_DAPM_PRE_PMU:
|
||||
|
|
@ -532,8 +533,6 @@ int madera_domain_clk_ev(struct snd_soc_dapm_widget *w,
|
|||
|
||||
madera_debug_dump_domain_groups(priv);
|
||||
|
||||
mutex_unlock(&priv->rate_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(madera_domain_clk_ev);
|
||||
|
|
@ -875,9 +874,8 @@ static int madera_adsp_rate_get(struct snd_kcontrol *kcontrol,
|
|||
const int adsp_num = e->shift_l;
|
||||
int item;
|
||||
|
||||
mutex_lock(&priv->rate_lock);
|
||||
cached_rate = priv->adsp_rate_cache[adsp_num];
|
||||
mutex_unlock(&priv->rate_lock);
|
||||
scoped_guard(mutex, &priv->rate_lock)
|
||||
cached_rate = priv->adsp_rate_cache[adsp_num];
|
||||
|
||||
item = snd_soc_enum_val_to_item(e, cached_rate);
|
||||
ucontrol->value.enumerated.item[0] = item;
|
||||
|
|
@ -893,7 +891,6 @@ static int madera_adsp_rate_put(struct snd_kcontrol *kcontrol,
|
|||
struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
|
||||
const int adsp_num = e->shift_l;
|
||||
const unsigned int item = ucontrol->value.enumerated.item[0];
|
||||
int ret = 0;
|
||||
|
||||
if (item >= e->items)
|
||||
return -EINVAL;
|
||||
|
|
@ -903,22 +900,20 @@ static int madera_adsp_rate_put(struct snd_kcontrol *kcontrol,
|
|||
* maintain consistent behaviour that rate domains cannot be changed
|
||||
* while in use since this is a hardware requirement
|
||||
*/
|
||||
mutex_lock(&priv->rate_lock);
|
||||
guard(mutex)(&priv->rate_lock);
|
||||
|
||||
if (!madera_can_change_grp_rate(priv, priv->adsp[adsp_num].cs_dsp.base)) {
|
||||
dev_warn(priv->madera->dev,
|
||||
"Cannot change '%s' while in use by active audio paths\n",
|
||||
kcontrol->id.name);
|
||||
ret = -EBUSY;
|
||||
return -EBUSY;
|
||||
} else if (priv->adsp_rate_cache[adsp_num] != e->values[item]) {
|
||||
/* Volatile register so defer until the codec is powered up */
|
||||
priv->adsp_rate_cache[adsp_num] = e->values[item];
|
||||
ret = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
mutex_unlock(&priv->rate_lock);
|
||||
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct soc_enum madera_adsp_rate_enum[] = {
|
||||
|
|
@ -1061,15 +1056,13 @@ int madera_rate_put(struct snd_kcontrol *kcontrol,
|
|||
* Prevent the domain powering up while we're checking whether it's
|
||||
* safe to change rate domain
|
||||
*/
|
||||
mutex_lock(&priv->rate_lock);
|
||||
guard(mutex)(&priv->rate_lock);
|
||||
|
||||
val = snd_soc_component_read(component, e->reg);
|
||||
val >>= e->shift_l;
|
||||
val &= e->mask;
|
||||
if (snd_soc_enum_item_to_val(e, item) == val) {
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
if (snd_soc_enum_item_to_val(e, item) == val)
|
||||
return 0;
|
||||
|
||||
if (!madera_can_change_grp_rate(priv, e->reg)) {
|
||||
dev_warn(priv->madera->dev,
|
||||
|
|
@ -1082,8 +1075,6 @@ int madera_rate_put(struct snd_kcontrol *kcontrol,
|
|||
ret = snd_soc_put_enum_double(kcontrol, ucontrol);
|
||||
madera_spin_sysclk(priv);
|
||||
}
|
||||
out:
|
||||
mutex_unlock(&priv->rate_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -3041,12 +3032,11 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream,
|
|||
if ((cur & MADERA_AIF1_RATE_MASK) == (tar & MADERA_AIF1_RATE_MASK))
|
||||
return 0;
|
||||
|
||||
mutex_lock(&priv->rate_lock);
|
||||
guard(mutex)(&priv->rate_lock);
|
||||
|
||||
if (!madera_can_change_grp_rate(priv, base + MADERA_AIF_RATE_CTRL)) {
|
||||
madera_aif_warn(dai, "Cannot change rate while active\n");
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
/* Guard the rate change with SYSCLK cycles */
|
||||
|
|
@ -3055,9 +3045,6 @@ static int madera_hw_params_rate(struct snd_pcm_substream *substream,
|
|||
MADERA_AIF1_RATE_MASK, tar);
|
||||
madera_spin_sysclk(priv);
|
||||
|
||||
out:
|
||||
mutex_unlock(&priv->rate_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
* Copyright 2011 Maxim Integrated Products
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -1532,15 +1533,17 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
|
|||
regsave = snd_soc_component_read(component, M98095_088_CFG_LEVEL);
|
||||
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0);
|
||||
|
||||
mutex_lock(&max98095->lock);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
|
||||
m98095_eq_band(component, channel, 0, coef_set->band1);
|
||||
m98095_eq_band(component, channel, 1, coef_set->band2);
|
||||
m98095_eq_band(component, channel, 2, coef_set->band3);
|
||||
m98095_eq_band(component, channel, 3, coef_set->band4);
|
||||
m98095_eq_band(component, channel, 4, coef_set->band5);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0);
|
||||
mutex_unlock(&max98095->lock);
|
||||
scoped_guard(mutex, &max98095->lock) {
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
|
||||
M98095_SEG, M98095_SEG);
|
||||
m98095_eq_band(component, channel, 0, coef_set->band1);
|
||||
m98095_eq_band(component, channel, 1, coef_set->band2);
|
||||
m98095_eq_band(component, channel, 2, coef_set->band3);
|
||||
m98095_eq_band(component, channel, 3, coef_set->band4);
|
||||
m98095_eq_band(component, channel, 4, coef_set->band5);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
|
||||
M98095_SEG, 0);
|
||||
}
|
||||
|
||||
/* Restore the original on/off state */
|
||||
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave);
|
||||
|
|
@ -1683,12 +1686,14 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
|
|||
regsave = snd_soc_component_read(component, M98095_088_CFG_LEVEL);
|
||||
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, 0);
|
||||
|
||||
mutex_lock(&max98095->lock);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, M98095_SEG);
|
||||
m98095_biquad_band(component, channel, 0, coef_set->band1);
|
||||
m98095_biquad_band(component, channel, 1, coef_set->band2);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG, M98095_SEG, 0);
|
||||
mutex_unlock(&max98095->lock);
|
||||
scoped_guard(mutex, &max98095->lock) {
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
|
||||
M98095_SEG, M98095_SEG);
|
||||
m98095_biquad_band(component, channel, 0, coef_set->band1);
|
||||
m98095_biquad_band(component, channel, 1, coef_set->band2);
|
||||
snd_soc_component_update_bits(component, M98095_00F_HOST_CFG,
|
||||
M98095_SEG, 0);
|
||||
}
|
||||
|
||||
/* Restore the original on/off state */
|
||||
snd_soc_component_update_bits(component, M98095_088_CFG_LEVEL, regmask, regsave);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Author: Argus Lin <argus.lin@mediatek.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/of.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/kthread.h>
|
||||
|
|
@ -398,14 +399,13 @@ static void mt6359_accdet_work(struct work_struct *work)
|
|||
struct mt6359_accdet *priv =
|
||||
container_of(work, struct mt6359_accdet, accdet_work);
|
||||
|
||||
mutex_lock(&priv->res_lock);
|
||||
guard(mutex)(&priv->res_lock);
|
||||
priv->pre_accdet_status = priv->accdet_status;
|
||||
check_jack_btn_type(priv);
|
||||
|
||||
if (priv->jack_plugged &&
|
||||
priv->pre_accdet_status != priv->accdet_status)
|
||||
mt6359_accdet_jack_report(priv);
|
||||
mutex_unlock(&priv->res_lock);
|
||||
}
|
||||
|
||||
static void mt6359_accdet_jd_work(struct work_struct *work)
|
||||
|
|
@ -416,7 +416,7 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
|
|||
struct mt6359_accdet *priv =
|
||||
container_of(work, struct mt6359_accdet, jd_work);
|
||||
|
||||
mutex_lock(&priv->res_lock);
|
||||
guard(mutex)(&priv->res_lock);
|
||||
if (priv->jd_sts == M_PLUG_IN) {
|
||||
priv->jack_plugged = true;
|
||||
|
||||
|
|
@ -450,7 +450,6 @@ static void mt6359_accdet_jd_work(struct work_struct *work)
|
|||
|
||||
if (priv->caps & ACCDET_PMIC_EINT_IRQ)
|
||||
recover_eint_setting(priv);
|
||||
mutex_unlock(&priv->res_lock);
|
||||
}
|
||||
|
||||
static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
||||
|
|
@ -459,7 +458,7 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
|||
unsigned int irq_val = 0, val = 0, value = 0;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&priv->res_lock);
|
||||
guard(mutex)(&priv->res_lock);
|
||||
regmap_read(priv->regmap, ACCDET_IRQ_ADDR, &irq_val);
|
||||
|
||||
if (irq_val & ACCDET_IRQ_MASK_SFT) {
|
||||
|
|
@ -474,7 +473,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
|||
1000);
|
||||
if (ret) {
|
||||
dev_err(priv->dev, "%s(), ret %d\n", __func__, ret);
|
||||
mutex_unlock(&priv->res_lock);
|
||||
return IRQ_NONE;
|
||||
}
|
||||
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
|
||||
|
|
@ -498,7 +496,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
|||
if (ret) {
|
||||
dev_err(priv->dev, "%s(), ret %d\n", __func__,
|
||||
ret);
|
||||
mutex_unlock(&priv->res_lock);
|
||||
return IRQ_NONE;
|
||||
}
|
||||
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
|
||||
|
|
@ -521,7 +518,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
|||
if (ret) {
|
||||
dev_err(priv->dev, "%s(), ret %d\n", __func__,
|
||||
ret);
|
||||
mutex_unlock(&priv->res_lock);
|
||||
return IRQ_NONE;
|
||||
}
|
||||
regmap_update_bits(priv->regmap, ACCDET_IRQ_ADDR,
|
||||
|
|
@ -540,7 +536,6 @@ static irqreturn_t mt6359_accdet_irq(int irq, void *data)
|
|||
|
||||
queue_work(priv->jd_workqueue, &priv->jd_work);
|
||||
}
|
||||
mutex_unlock(&priv->res_lock);
|
||||
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
* Copyright 2014 Linaro Ltd
|
||||
*/
|
||||
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/clk.h>
|
||||
|
|
@ -399,10 +399,9 @@ static int pcm512x_digital_playback_switch_get(struct snd_kcontrol *kcontrol,
|
|||
struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
|
||||
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
ucontrol->value.integer.value[0] = !(pcm512x->mute & 0x4);
|
||||
ucontrol->value.integer.value[1] = !(pcm512x->mute & 0x2);
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -414,7 +413,7 @@ static int pcm512x_digital_playback_switch_put(struct snd_kcontrol *kcontrol,
|
|||
struct pcm512x_priv *pcm512x = snd_soc_component_get_drvdata(component);
|
||||
int ret, changed = 0;
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
|
||||
if ((pcm512x->mute & 0x4) == (ucontrol->value.integer.value[0] << 2)) {
|
||||
pcm512x->mute ^= 0x4;
|
||||
|
|
@ -430,13 +429,10 @@ static int pcm512x_digital_playback_switch_put(struct snd_kcontrol *kcontrol,
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to update digital mute: %d\n", ret);
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
|
|
@ -1465,7 +1461,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
int ret;
|
||||
unsigned int mute_det;
|
||||
|
||||
mutex_lock(&pcm512x->mutex);
|
||||
guard(mutex)(&pcm512x->mutex);
|
||||
|
||||
if (mute) {
|
||||
pcm512x->mute |= 0x1;
|
||||
|
|
@ -1475,7 +1471,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to set digital mute: %d\n", ret);
|
||||
goto unlock;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_read_poll_timeout(pcm512x->regmap,
|
||||
|
|
@ -1488,7 +1484,7 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
if (ret != 0) {
|
||||
dev_err(component->dev,
|
||||
"Failed to update digital mute: %d\n", ret);
|
||||
goto unlock;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_read_poll_timeout(pcm512x->regmap,
|
||||
|
|
@ -1499,9 +1495,6 @@ static int pcm512x_mute(struct snd_soc_dai *dai, int mute, int direction)
|
|||
200, 10000);
|
||||
}
|
||||
|
||||
unlock:
|
||||
mutex_unlock(&pcm512x->mutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
// Author: Shenghao Ding <shenghao-ding@ti.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include <linux/firmware.h>
|
||||
#include <linux/gpio/consumer.h>
|
||||
|
|
@ -605,7 +606,7 @@ static int pcmdev_get_volsw(struct snd_kcontrol *kcontrol,
|
|||
unsigned int reg = mc->reg;
|
||||
unsigned int val;
|
||||
|
||||
mutex_lock(&pcm_dev->codec_lock);
|
||||
guard(mutex)(&pcm_dev->codec_lock);
|
||||
|
||||
if (pcm_dev->chip_id == PCM1690) {
|
||||
ret = pcmdev_dev_read(pcm_dev, dev_no, PCM1690_REG_MODE_CTRL,
|
||||
|
|
@ -613,18 +614,18 @@ static int pcmdev_get_volsw(struct snd_kcontrol *kcontrol,
|
|||
if (ret) {
|
||||
dev_err(pcm_dev->dev, "%s: read mode err=%d\n",
|
||||
__func__, ret);
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
val &= PCM1690_REG_MODE_CTRL_DAMS_MSK;
|
||||
/* Set to wide-range mode, before using vol ctrl. */
|
||||
if (!val && vol_ctrl_type == PCMDEV_PCM1690_VOL_CTRL) {
|
||||
ucontrol->value.integer.value[0] = -25500;
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
/* Set to fine mode, before using fine vol ctrl. */
|
||||
if (val && vol_ctrl_type == PCMDEV_PCM1690_FINE_VOL_CTRL) {
|
||||
ucontrol->value.integer.value[0] = -12750;
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -632,15 +633,14 @@ static int pcmdev_get_volsw(struct snd_kcontrol *kcontrol,
|
|||
if (ret) {
|
||||
dev_err(pcm_dev->dev, "%s: read err=%d\n",
|
||||
__func__, ret);
|
||||
goto out;
|
||||
return ret;
|
||||
}
|
||||
|
||||
val = (val >> shift) & mask;
|
||||
val = (val > max) ? max : val;
|
||||
val = mc->invert ? max - val : val;
|
||||
ucontrol->value.integer.value[0] = val;
|
||||
out:
|
||||
mutex_unlock(&pcm_dev->codec_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -678,7 +678,7 @@ static int pcmdev_put_volsw(struct snd_kcontrol *kcontrol,
|
|||
unsigned int val, val_mask;
|
||||
unsigned int reg = mc->reg;
|
||||
|
||||
mutex_lock(&pcm_dev->codec_lock);
|
||||
guard(mutex)(&pcm_dev->codec_lock);
|
||||
val = ucontrol->value.integer.value[0] & mask;
|
||||
val = (val > max) ? max : val;
|
||||
val = mc->invert ? max - val : val;
|
||||
|
|
@ -702,7 +702,7 @@ static int pcmdev_put_volsw(struct snd_kcontrol *kcontrol,
|
|||
__func__, rc);
|
||||
else
|
||||
rc = 1;
|
||||
mutex_unlock(&pcm_dev->codec_lock);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
@ -1645,9 +1645,8 @@ static void pcmdevice_comp_remove(struct snd_soc_component *codec)
|
|||
|
||||
if (!pcm_dev)
|
||||
return;
|
||||
mutex_lock(&pcm_dev->codec_lock);
|
||||
guard(mutex)(&pcm_dev->codec_lock);
|
||||
pcmdevice_config_info_remove(pcm_dev);
|
||||
mutex_unlock(&pcm_dev->codec_lock);
|
||||
}
|
||||
|
||||
static const struct snd_soc_dapm_widget pcmdevice_dapm_widgets[] = {
|
||||
|
|
@ -1890,9 +1889,9 @@ static int pcmdevice_mute(struct snd_soc_dai *dai, int mute, int stream)
|
|||
else
|
||||
block_type = PCMDEVICE_BIN_BLK_PRE_POWER_UP;
|
||||
|
||||
mutex_lock(&pcm_dev->codec_lock);
|
||||
guard(mutex)(&pcm_dev->codec_lock);
|
||||
pcmdevice_select_cfg_blk(pcm_dev, pcm_dev->cur_conf, block_type);
|
||||
mutex_unlock(&pcm_dev->codec_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
// Author: Herve Codina <herve.codina@bootlin.com>
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/unaligned.h>
|
||||
#include <linux/clk.h>
|
||||
#include <linux/firmware.h>
|
||||
|
|
@ -1704,13 +1705,11 @@ static int peb2466_chip_gpio_update_bits(struct peb2466 *peb2466, unsigned int x
|
|||
* So, a specific cache value is used.
|
||||
*/
|
||||
|
||||
mutex_lock(&peb2466->gpio.lock);
|
||||
guard(mutex)(&peb2466->gpio.lock);
|
||||
|
||||
cache = peb2466_chip_gpio_get_cache(peb2466, xr_reg);
|
||||
if (!cache) {
|
||||
ret = -EINVAL;
|
||||
goto end;
|
||||
}
|
||||
if (!cache)
|
||||
return -EINVAL;
|
||||
|
||||
tmp = *cache;
|
||||
tmp &= ~mask;
|
||||
|
|
@ -1718,14 +1717,11 @@ static int peb2466_chip_gpio_update_bits(struct peb2466 *peb2466, unsigned int x
|
|||
|
||||
ret = regmap_write(peb2466->regmap, xr_reg, tmp);
|
||||
if (ret)
|
||||
goto end;
|
||||
return ret;
|
||||
|
||||
*cache = tmp;
|
||||
ret = 0;
|
||||
|
||||
end:
|
||||
mutex_unlock(&peb2466->gpio.lock);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
|
@ -79,17 +80,17 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
unsigned int cur_wp, remain_data;
|
||||
u8 buf[8];
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
guard(mutex)(&rt5514_dsp->dma_lock);
|
||||
if (!rt5514_dsp->substream) {
|
||||
dev_err(rt5514_dsp->dev, "No pcm substream\n");
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
runtime = rt5514_dsp->substream->runtime;
|
||||
period_bytes = snd_pcm_lib_period_bytes(rt5514_dsp->substream);
|
||||
if (!period_bytes) {
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
if (rt5514_dsp->buf_size % period_bytes)
|
||||
|
|
@ -111,7 +112,7 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
|
||||
if (remain_data < period_bytes) {
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,9 +147,6 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
snd_pcm_period_elapsed(rt5514_dsp->substream);
|
||||
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
|
||||
done:
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
}
|
||||
|
||||
static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp)
|
||||
|
|
@ -216,7 +214,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
|
|||
snd_soc_component_get_drvdata(component);
|
||||
u8 buf[8];
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
guard(mutex)(&rt5514_dsp->dma_lock);
|
||||
rt5514_dsp->substream = substream;
|
||||
rt5514_dsp->dma_offset = 0;
|
||||
|
||||
|
|
@ -225,8 +223,6 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
|
|||
if (buf[0] & RT5514_IRQ_STATUS_BIT)
|
||||
rt5514_schedule_copy(rt5514_dsp);
|
||||
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -236,9 +232,8 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component,
|
|||
struct rt5514_dsp *rt5514_dsp =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
rt5514_dsp->substream = NULL;
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
scoped_guard(mutex, &rt5514_dsp->dma_lock)
|
||||
rt5514_dsp->substream = NULL;
|
||||
|
||||
cancel_delayed_work_sync(&rt5514_dsp->copy_work);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Bard Liao <bardliao@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -3323,92 +3324,89 @@ static void rt5645_jack_detect_work(struct work_struct *work)
|
|||
if (!rt5645->component)
|
||||
return;
|
||||
|
||||
mutex_lock(&rt5645->jd_mutex);
|
||||
|
||||
switch (rt5645->pdata.jd_mode) {
|
||||
case 0: /* Not using rt5645 JD */
|
||||
if (rt5645->gpiod_hp_det) {
|
||||
gpio_state = gpiod_get_value(rt5645->gpiod_hp_det);
|
||||
if (rt5645->pdata.inv_hp_pol)
|
||||
gpio_state ^= 1;
|
||||
dev_dbg(rt5645->component->dev, "gpio_state = %d\n",
|
||||
gpio_state);
|
||||
report = rt5645_jack_detect(rt5645->component, gpio_state);
|
||||
}
|
||||
snd_soc_jack_report(rt5645->hp_jack,
|
||||
report, SND_JACK_HEADPHONE);
|
||||
snd_soc_jack_report(rt5645->mic_jack,
|
||||
report, SND_JACK_MICROPHONE);
|
||||
mutex_unlock(&rt5645->jd_mutex);
|
||||
return;
|
||||
case 4:
|
||||
val = snd_soc_component_read(rt5645->component, RT5645_A_JD_CTRL1) & 0x0020;
|
||||
break;
|
||||
default: /* read rt5645 jd1_1 status */
|
||||
val = snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (!val && (rt5645->jack_type == 0)) { /* jack in */
|
||||
report = rt5645_jack_detect(rt5645->component, 1);
|
||||
} else if (!val && rt5645->jack_type == SND_JACK_HEADSET) {
|
||||
/* for push button and jack out */
|
||||
btn_type = 0;
|
||||
if (snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x4) {
|
||||
/* button pressed */
|
||||
report = SND_JACK_HEADSET;
|
||||
btn_type = rt5645_button_detect(rt5645->component);
|
||||
/* rt5650 can report three kinds of button behavior,
|
||||
one click, double click and hold. However,
|
||||
currently we will report button pressed/released
|
||||
event. So all the three button behaviors are
|
||||
treated as button pressed. */
|
||||
switch (btn_type) {
|
||||
case 0x8000:
|
||||
case 0x4000:
|
||||
case 0x2000:
|
||||
report |= SND_JACK_BTN_0;
|
||||
break;
|
||||
case 0x1000:
|
||||
case 0x0800:
|
||||
case 0x0400:
|
||||
report |= SND_JACK_BTN_1;
|
||||
break;
|
||||
case 0x0200:
|
||||
case 0x0100:
|
||||
case 0x0080:
|
||||
report |= SND_JACK_BTN_2;
|
||||
break;
|
||||
case 0x0040:
|
||||
case 0x0020:
|
||||
case 0x0010:
|
||||
report |= SND_JACK_BTN_3;
|
||||
break;
|
||||
case 0x0000: /* unpressed */
|
||||
break;
|
||||
default:
|
||||
dev_err(rt5645->component->dev,
|
||||
"Unexpected button code 0x%04x\n",
|
||||
btn_type);
|
||||
break;
|
||||
scoped_guard(mutex, &rt5645->jd_mutex) {
|
||||
switch (rt5645->pdata.jd_mode) {
|
||||
case 0: /* Not using rt5645 JD */
|
||||
if (rt5645->gpiod_hp_det) {
|
||||
gpio_state = gpiod_get_value(rt5645->gpiod_hp_det);
|
||||
if (rt5645->pdata.inv_hp_pol)
|
||||
gpio_state ^= 1;
|
||||
dev_dbg(rt5645->component->dev, "gpio_state = %d\n",
|
||||
gpio_state);
|
||||
report = rt5645_jack_detect(rt5645->component, gpio_state);
|
||||
}
|
||||
snd_soc_jack_report(rt5645->hp_jack,
|
||||
report, SND_JACK_HEADPHONE);
|
||||
snd_soc_jack_report(rt5645->mic_jack,
|
||||
report, SND_JACK_MICROPHONE);
|
||||
return;
|
||||
case 4:
|
||||
val = snd_soc_component_read(rt5645->component, RT5645_A_JD_CTRL1) & 0x0020;
|
||||
break;
|
||||
default: /* read rt5645 jd1_1 status */
|
||||
val = snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x1000;
|
||||
break;
|
||||
}
|
||||
if (btn_type == 0)/* button release */
|
||||
report = rt5645->jack_type;
|
||||
else {
|
||||
mod_timer(&rt5645->btn_check_timer,
|
||||
msecs_to_jiffies(100));
|
||||
}
|
||||
} else {
|
||||
/* jack out */
|
||||
report = 0;
|
||||
snd_soc_component_update_bits(rt5645->component,
|
||||
RT5645_INT_IRQ_ST, 0x1, 0x0);
|
||||
rt5645_jack_detect(rt5645->component, 0);
|
||||
}
|
||||
|
||||
mutex_unlock(&rt5645->jd_mutex);
|
||||
if (!val && rt5645->jack_type == 0) { /* jack in */
|
||||
report = rt5645_jack_detect(rt5645->component, 1);
|
||||
} else if (!val && rt5645->jack_type == SND_JACK_HEADSET) {
|
||||
/* for push button and jack out */
|
||||
btn_type = 0;
|
||||
if (snd_soc_component_read(rt5645->component, RT5645_INT_IRQ_ST) & 0x4) {
|
||||
/* button pressed */
|
||||
report = SND_JACK_HEADSET;
|
||||
btn_type = rt5645_button_detect(rt5645->component);
|
||||
/*
|
||||
* rt5650 can report three kinds of button behavior,
|
||||
* one click, double click and hold. However,
|
||||
* currently we will report button pressed/released
|
||||
* event. So all the three button behaviors are
|
||||
* treated as button pressed.
|
||||
*/
|
||||
switch (btn_type) {
|
||||
case 0x8000:
|
||||
case 0x4000:
|
||||
case 0x2000:
|
||||
report |= SND_JACK_BTN_0;
|
||||
break;
|
||||
case 0x1000:
|
||||
case 0x0800:
|
||||
case 0x0400:
|
||||
report |= SND_JACK_BTN_1;
|
||||
break;
|
||||
case 0x0200:
|
||||
case 0x0100:
|
||||
case 0x0080:
|
||||
report |= SND_JACK_BTN_2;
|
||||
break;
|
||||
case 0x0040:
|
||||
case 0x0020:
|
||||
case 0x0010:
|
||||
report |= SND_JACK_BTN_3;
|
||||
break;
|
||||
case 0x0000: /* unpressed */
|
||||
break;
|
||||
default:
|
||||
dev_err(rt5645->component->dev,
|
||||
"Unexpected button code 0x%04x\n",
|
||||
btn_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (btn_type == 0)/* button release */
|
||||
report = rt5645->jack_type;
|
||||
else
|
||||
mod_timer(&rt5645->btn_check_timer,
|
||||
msecs_to_jiffies(100));
|
||||
} else {
|
||||
/* jack out */
|
||||
report = 0;
|
||||
snd_soc_component_update_bits(rt5645->component,
|
||||
RT5645_INT_IRQ_ST, 0x1, 0x0);
|
||||
rt5645_jack_detect(rt5645->component, 0);
|
||||
}
|
||||
}
|
||||
|
||||
snd_soc_jack_report(rt5645->hp_jack, report, SND_JACK_HEADPHONE);
|
||||
snd_soc_jack_report(rt5645->mic_jack, report, SND_JACK_MICROPHONE);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Bard Liao <bardliao@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -1208,7 +1209,7 @@ static void rt5665_jack_detect_handler(struct work_struct *work)
|
|||
usleep_range(10000, 15000);
|
||||
}
|
||||
|
||||
mutex_lock(&rt5665->calibrate_mutex);
|
||||
guard(mutex)(&rt5665->calibrate_mutex);
|
||||
|
||||
val = snd_soc_component_read(rt5665->component, RT5665_AJD1_CTRL) & 0x0010;
|
||||
if (!val) {
|
||||
|
|
@ -1274,8 +1275,6 @@ static void rt5665_jack_detect_handler(struct work_struct *work)
|
|||
schedule_delayed_work(&rt5665->jd_check_work, 0);
|
||||
else
|
||||
cancel_delayed_work_sync(&rt5665->jd_check_work);
|
||||
|
||||
mutex_unlock(&rt5665->calibrate_mutex);
|
||||
}
|
||||
|
||||
static const char * const rt5665_clk_sync[] = {
|
||||
|
|
@ -4564,7 +4563,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
|
|||
{
|
||||
int value, count;
|
||||
|
||||
mutex_lock(&rt5665->calibrate_mutex);
|
||||
guard(mutex)(&rt5665->calibrate_mutex);
|
||||
|
||||
regcache_cache_bypass(rt5665->regmap, true);
|
||||
|
||||
|
|
@ -4601,7 +4600,8 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
|
|||
pr_err("HP Calibration Failure\n");
|
||||
regmap_write(rt5665->regmap, RT5665_RESET, 0);
|
||||
regcache_cache_bypass(rt5665->regmap, false);
|
||||
goto out_unlock;
|
||||
rt5665->calibration_done = true;
|
||||
return;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
|
@ -4620,7 +4620,8 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
|
|||
pr_err("MONO Calibration Failure\n");
|
||||
regmap_write(rt5665->regmap, RT5665_RESET, 0);
|
||||
regcache_cache_bypass(rt5665->regmap, false);
|
||||
goto out_unlock;
|
||||
rt5665->calibration_done = true;
|
||||
return;
|
||||
}
|
||||
|
||||
count++;
|
||||
|
|
@ -4635,9 +4636,7 @@ static void rt5665_calibrate(struct rt5665_priv *rt5665)
|
|||
regmap_write(rt5665->regmap, RT5665_BIAS_CUR_CTRL_8, 0xa602);
|
||||
regmap_write(rt5665->regmap, RT5665_ASRC_8, 0x0120);
|
||||
|
||||
out_unlock:
|
||||
rt5665->calibration_done = true;
|
||||
mutex_unlock(&rt5665->calibrate_mutex);
|
||||
}
|
||||
|
||||
static void rt5665_calibrate_handler(struct work_struct *work)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Bard Liao <bardliao@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -986,7 +987,7 @@ static void rt5668_jack_detect_handler(struct work_struct *work)
|
|||
return;
|
||||
}
|
||||
|
||||
mutex_lock(&rt5668->calibrate_mutex);
|
||||
guard(mutex)(&rt5668->calibrate_mutex);
|
||||
|
||||
val = snd_soc_component_read(rt5668->component, RT5668_AJD1_CTRL)
|
||||
& RT5668_JDH_RS_MASK;
|
||||
|
|
@ -1053,8 +1054,6 @@ static void rt5668_jack_detect_handler(struct work_struct *work)
|
|||
schedule_delayed_work(&rt5668->jd_check_work, 0);
|
||||
else
|
||||
cancel_delayed_work_sync(&rt5668->jd_check_work);
|
||||
|
||||
mutex_unlock(&rt5668->calibrate_mutex);
|
||||
}
|
||||
|
||||
static const struct snd_kcontrol_new rt5668_snd_controls[] = {
|
||||
|
|
@ -2356,7 +2355,7 @@ static void rt5668_calibrate(struct rt5668_priv *rt5668)
|
|||
{
|
||||
int value, count;
|
||||
|
||||
mutex_lock(&rt5668->calibrate_mutex);
|
||||
guard(mutex)(&rt5668->calibrate_mutex);
|
||||
|
||||
rt5668_reset(rt5668->regmap);
|
||||
regmap_write(rt5668->regmap, RT5668_PWR_ANLG_1, 0xa2bf);
|
||||
|
|
@ -2400,9 +2399,6 @@ static void rt5668_calibrate(struct rt5668_priv *rt5668)
|
|||
/* restore settings */
|
||||
regmap_write(rt5668->regmap, RT5668_STO1_ADC_MIXER, 0xc0c4);
|
||||
regmap_write(rt5668->regmap, RT5668_PWR_DIG_1, 0x0000);
|
||||
|
||||
mutex_unlock(&rt5668->calibrate_mutex);
|
||||
|
||||
}
|
||||
|
||||
static int rt5668_i2c_probe(struct i2c_client *i2c)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
|
@ -133,9 +134,8 @@ static int rt5677_spi_hw_params(
|
|||
struct rt5677_dsp *rt5677_dsp =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&rt5677_dsp->dma_lock);
|
||||
guard(mutex)(&rt5677_dsp->dma_lock);
|
||||
rt5677_dsp->substream = substream;
|
||||
mutex_unlock(&rt5677_dsp->dma_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -147,9 +147,8 @@ static int rt5677_spi_hw_free(
|
|||
struct rt5677_dsp *rt5677_dsp =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&rt5677_dsp->dma_lock);
|
||||
guard(mutex)(&rt5677_dsp->dma_lock);
|
||||
rt5677_dsp->substream = NULL;
|
||||
mutex_unlock(&rt5677_dsp->dma_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -311,17 +310,17 @@ static void rt5677_spi_copy_work(struct work_struct *work)
|
|||
int ret = 0;
|
||||
|
||||
/* Ensure runtime->dma_area buffer does not go away while copying. */
|
||||
mutex_lock(&rt5677_dsp->dma_lock);
|
||||
guard(mutex)(&rt5677_dsp->dma_lock);
|
||||
if (!rt5677_dsp->substream) {
|
||||
dev_err(rt5677_dsp->dev, "No pcm substream\n");
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
runtime = rt5677_dsp->substream->runtime;
|
||||
|
||||
if (rt5677_spi_mic_write_offset(&mic_write_offset)) {
|
||||
dev_err(rt5677_dsp->dev, "No mic_write_offset\n");
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
/* If this is the first time that we've asked for streaming data after
|
||||
|
|
@ -355,7 +354,7 @@ static void rt5677_spi_copy_work(struct work_struct *work)
|
|||
ret = rt5677_spi_copy(rt5677_dsp, copy_bytes);
|
||||
if (ret) {
|
||||
dev_err(rt5677_dsp->dev, "Copy failed %d\n", ret);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
rt5677_dsp->avail_bytes += copy_bytes;
|
||||
if (rt5677_dsp->avail_bytes >= period_bytes) {
|
||||
|
|
@ -367,8 +366,6 @@ static void rt5677_spi_copy_work(struct work_struct *work)
|
|||
|
||||
delay = bytes_to_frames(runtime, period_bytes) / runtime->rate;
|
||||
schedule_delayed_work(&rt5677_dsp->copy_work, secs_to_jiffies(delay));
|
||||
done:
|
||||
mutex_unlock(&rt5677_dsp->dma_lock);
|
||||
}
|
||||
|
||||
static int rt5677_spi_pcm_new(struct snd_soc_component *component,
|
||||
|
|
@ -507,10 +504,8 @@ int rt5677_spi_read(u32 addr, void *rxbuf, size_t len)
|
|||
header[3] = ((addr + offset) & 0x0000ff00) >> 8;
|
||||
header[4] = ((addr + offset) & 0x000000ff) >> 0;
|
||||
|
||||
mutex_lock(&spi_mutex);
|
||||
status |= spi_sync(g_spi, &m);
|
||||
mutex_unlock(&spi_mutex);
|
||||
|
||||
scoped_guard(mutex, &spi_mutex)
|
||||
status |= spi_sync(g_spi, &m);
|
||||
|
||||
/* Copy data back to caller buffer */
|
||||
rt5677_spi_reverse(cb + offset, len - offset, body, t[1].len);
|
||||
|
|
@ -564,9 +559,8 @@ int rt5677_spi_write(u32 addr, const void *txbuf, size_t len)
|
|||
offset += t.len;
|
||||
t.len += RT5677_SPI_HEADER + 1;
|
||||
|
||||
mutex_lock(&spi_mutex);
|
||||
status |= spi_sync(g_spi, &m);
|
||||
mutex_unlock(&spi_mutex);
|
||||
scoped_guard(mutex, &spi_mutex)
|
||||
status |= spi_sync(g_spi, &m);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
|
@ -591,10 +585,10 @@ void rt5677_spi_hotword_detected(void)
|
|||
return;
|
||||
}
|
||||
|
||||
mutex_lock(&rt5677_dsp->dma_lock);
|
||||
dev_info(rt5677_dsp->dev, "Hotword detected\n");
|
||||
rt5677_dsp->new_hotword = true;
|
||||
mutex_unlock(&rt5677_dsp->dma_lock);
|
||||
scoped_guard(mutex, &rt5677_dsp->dma_lock) {
|
||||
dev_info(rt5677_dsp->dev, "Hotword detected\n");
|
||||
rt5677_dsp->new_hotword = true;
|
||||
}
|
||||
|
||||
schedule_delayed_work(&rt5677_dsp->copy_work, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/bits.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/firmware.h>
|
||||
|
|
@ -564,46 +565,43 @@ static int rt5677_dsp_mode_i2c_write_addr(struct rt5677_priv *rt5677,
|
|||
struct snd_soc_component *component = rt5677->component;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&rt5677->dsp_cmd_lock);
|
||||
guard(mutex)(&rt5677->dsp_cmd_lock);
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
|
||||
addr >> 16);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set addr msb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
|
||||
addr & 0xffff);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set addr lsb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB,
|
||||
value >> 16);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set data msb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB,
|
||||
value & 0xffff);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set data lsb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
|
||||
opcode);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set op code value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
err:
|
||||
mutex_unlock(&rt5677->dsp_cmd_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -623,36 +621,33 @@ static int rt5677_dsp_mode_i2c_read_addr(
|
|||
int ret;
|
||||
unsigned int msb, lsb;
|
||||
|
||||
mutex_lock(&rt5677->dsp_cmd_lock);
|
||||
guard(mutex)(&rt5677->dsp_cmd_lock);
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_MSB,
|
||||
addr >> 16);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set addr msb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_ADDR_LSB,
|
||||
addr & 0xffff);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set addr lsb value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = regmap_write(rt5677->regmap_physical, RT5677_DSP_I2C_OP_CODE,
|
||||
0x0002);
|
||||
if (ret < 0) {
|
||||
dev_err(component->dev, "Failed to set op code value: %d\n", ret);
|
||||
goto err;
|
||||
return ret;
|
||||
}
|
||||
|
||||
regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_MSB, &msb);
|
||||
regmap_read(rt5677->regmap_physical, RT5677_DSP_I2C_DATA_LSB, &lsb);
|
||||
*value = (msb << 16) | lsb;
|
||||
|
||||
err:
|
||||
mutex_unlock(&rt5677->dsp_cmd_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -941,21 +936,20 @@ static void rt5677_dsp_work(struct work_struct *work)
|
|||
activity = false;
|
||||
|
||||
/* Don't turn off the DSP while handling irqs */
|
||||
mutex_lock(&rt5677->irq_lock);
|
||||
/* Set DSP CPU to Stop */
|
||||
regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1,
|
||||
RT5677_PWR_DSP_CPU, RT5677_PWR_DSP_CPU);
|
||||
scoped_guard(mutex, &rt5677->irq_lock) {
|
||||
/* Set DSP CPU to Stop */
|
||||
regmap_update_bits(rt5677->regmap, RT5677_PWR_DSP1,
|
||||
RT5677_PWR_DSP_CPU, RT5677_PWR_DSP_CPU);
|
||||
|
||||
rt5677_set_dsp_mode(rt5677, false);
|
||||
rt5677_set_dsp_mode(rt5677, false);
|
||||
|
||||
/* Disable and clear VAD interrupt */
|
||||
regmap_write(rt5677->regmap, RT5677_VAD_CTRL1, 0x2184);
|
||||
/* Disable and clear VAD interrupt */
|
||||
regmap_write(rt5677->regmap, RT5677_VAD_CTRL1, 0x2184);
|
||||
|
||||
/* Set GPIO1 pin back to be IRQ output for jack detect */
|
||||
regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1,
|
||||
RT5677_GPIO1_PIN_MASK, RT5677_GPIO1_PIN_IRQ);
|
||||
|
||||
mutex_unlock(&rt5677->irq_lock);
|
||||
/* Set GPIO1 pin back to be IRQ output for jack detect */
|
||||
regmap_update_bits(rt5677->regmap, RT5677_GPIO_CTRL1,
|
||||
RT5677_GPIO1_PIN_MASK, RT5677_GPIO1_PIN_IRQ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4997,11 +4991,11 @@ static int rt5677_read(void *context, unsigned int reg, unsigned int *val)
|
|||
|
||||
if (rt5677->is_dsp_mode) {
|
||||
if (reg > 0xff) {
|
||||
mutex_lock(&rt5677->dsp_pri_lock);
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
|
||||
reg & 0xff);
|
||||
rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
|
||||
mutex_unlock(&rt5677->dsp_pri_lock);
|
||||
scoped_guard(mutex, &rt5677->dsp_pri_lock) {
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
|
||||
reg & 0xff);
|
||||
rt5677_dsp_mode_i2c_read(rt5677, RT5677_PRIV_DATA, val);
|
||||
}
|
||||
} else {
|
||||
rt5677_dsp_mode_i2c_read(rt5677, reg, val);
|
||||
}
|
||||
|
|
@ -5019,12 +5013,12 @@ static int rt5677_write(void *context, unsigned int reg, unsigned int val)
|
|||
|
||||
if (rt5677->is_dsp_mode) {
|
||||
if (reg > 0xff) {
|
||||
mutex_lock(&rt5677->dsp_pri_lock);
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
|
||||
reg & 0xff);
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
|
||||
val);
|
||||
mutex_unlock(&rt5677->dsp_pri_lock);
|
||||
scoped_guard(mutex, &rt5677->dsp_pri_lock) {
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_INDEX,
|
||||
reg & 0xff);
|
||||
rt5677_dsp_mode_i2c_write(rt5677, RT5677_PRIV_DATA,
|
||||
val);
|
||||
}
|
||||
} else {
|
||||
rt5677_dsp_mode_i2c_write(rt5677, reg, val);
|
||||
}
|
||||
|
|
@ -5416,7 +5410,7 @@ static void rt5677_resume_irq_check(struct work_struct *work)
|
|||
* Without this explicit check, unplug the headset right after suspend
|
||||
* starts, then after resume the headset is still shown as plugged in.
|
||||
*/
|
||||
mutex_lock(&rt5677->irq_lock);
|
||||
guard(mutex)(&rt5677->irq_lock);
|
||||
for (i = 0; i < RT5677_IRQ_NUM; i++) {
|
||||
if (rt5677->irq_en & rt5677_irq_descs[i].enable_mask) {
|
||||
virq = irq_find_mapping(rt5677->domain, i);
|
||||
|
|
@ -5424,7 +5418,6 @@ static void rt5677_resume_irq_check(struct work_struct *work)
|
|||
handle_nested_irq(virq);
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt5677->irq_lock);
|
||||
}
|
||||
|
||||
static void rt5677_irq_bus_lock(struct irq_data *data)
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -670,12 +671,11 @@ static int rt5682_interrupt_callback(struct sdw_slave *slave,
|
|||
dev_dbg(&slave->dev,
|
||||
"%s control_port_stat=%x", __func__, status->control_port);
|
||||
|
||||
mutex_lock(&rt5682->disable_irq_lock);
|
||||
guard(mutex)(&rt5682->disable_irq_lock);
|
||||
if (status->control_port & 0x4 && !rt5682->disable_irq) {
|
||||
mod_delayed_work(system_power_efficient_wq,
|
||||
&rt5682->jack_detect_work, msecs_to_jiffies(rt5682->irq_work_delay_time));
|
||||
}
|
||||
mutex_unlock(&rt5682->disable_irq_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -746,11 +746,11 @@ static int rt5682_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt5682->disable_irq_lock);
|
||||
rt5682->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
mutex_unlock(&rt5682->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt5682->disable_irq_lock) {
|
||||
rt5682->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -770,12 +770,12 @@ static int rt5682_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt5682->disable_irq_lock);
|
||||
if (rt5682->disable_irq == true) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_INTMASK1, SDW_SCP_INT1_IMPL_DEF);
|
||||
rt5682->disable_irq = false;
|
||||
scoped_guard(mutex, &rt5682->disable_irq_lock) {
|
||||
if (rt5682->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_INTMASK1, SDW_SCP_INT1_IMPL_DEF);
|
||||
rt5682->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt5682->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT5682_PROBE_TIMEOUT);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Author: Bard Liao <bardliao@realtek.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -3125,7 +3126,7 @@ void rt5682_calibrate(struct rt5682_priv *rt5682)
|
|||
{
|
||||
int value, count;
|
||||
|
||||
mutex_lock(&rt5682->calibrate_mutex);
|
||||
guard(mutex)(&rt5682->calibrate_mutex);
|
||||
|
||||
rt5682_reset(rt5682);
|
||||
regmap_write(rt5682->regmap, RT5682_I2C_CTRL, 0x000f);
|
||||
|
|
@ -3175,8 +3176,6 @@ void rt5682_calibrate(struct rt5682_priv *rt5682)
|
|||
regmap_write(rt5682->regmap, RT5682_CALIB_ADC_CTRL, 0x2005);
|
||||
regmap_write(rt5682->regmap, RT5682_STO1_ADC_MIXER, 0xc0c4);
|
||||
regmap_write(rt5682->regmap, RT5682_CAL_REC, 0x0c0c);
|
||||
|
||||
mutex_unlock(&rt5682->calibrate_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(rt5682_calibrate);
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
// Author: Derek Fang <derek.fang@realtek.com>
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -648,7 +649,7 @@ static void rt5682s_sar_power_mode(struct snd_soc_component *component, int mode
|
|||
{
|
||||
struct rt5682s_priv *rt5682s = snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&rt5682s->sar_mutex);
|
||||
guard(mutex)(&rt5682s->sar_mutex);
|
||||
|
||||
switch (mode) {
|
||||
case SAR_PWR_SAVING:
|
||||
|
|
@ -695,8 +696,6 @@ static void rt5682s_sar_power_mode(struct snd_soc_component *component, int mode
|
|||
dev_err(component->dev, "Invalid SAR Power mode: %d\n", mode);
|
||||
break;
|
||||
}
|
||||
|
||||
mutex_unlock(&rt5682s->sar_mutex);
|
||||
}
|
||||
|
||||
static void rt5682s_enable_push_button_irq(struct snd_soc_component *component)
|
||||
|
|
@ -2534,7 +2533,7 @@ static int rt5682s_wclk_prepare(struct clk_hw *hw)
|
|||
if (!rt5682s_clk_check(rt5682s))
|
||||
return -EINVAL;
|
||||
|
||||
mutex_lock(&rt5682s->wclk_mutex);
|
||||
guard(mutex)(&rt5682s->wclk_mutex);
|
||||
|
||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||
RT5682S_PWR_VREF2 | RT5682S_PWR_FV2 | RT5682S_PWR_MB,
|
||||
|
|
@ -2556,8 +2555,6 @@ static int rt5682s_wclk_prepare(struct clk_hw *hw)
|
|||
|
||||
rt5682s->wclk_enabled = 1;
|
||||
|
||||
mutex_unlock(&rt5682s->wclk_mutex);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2570,7 +2567,7 @@ static void rt5682s_wclk_unprepare(struct clk_hw *hw)
|
|||
if (!rt5682s_clk_check(rt5682s))
|
||||
return;
|
||||
|
||||
mutex_lock(&rt5682s->wclk_mutex);
|
||||
guard(mutex)(&rt5682s->wclk_mutex);
|
||||
|
||||
if (!rt5682s->jack_type)
|
||||
snd_soc_component_update_bits(component, RT5682S_PWR_ANLG_1,
|
||||
|
|
@ -2585,8 +2582,6 @@ static void rt5682s_wclk_unprepare(struct clk_hw *hw)
|
|||
rt5682s_set_pllb_power(rt5682s, 0);
|
||||
|
||||
rt5682s->wclk_enabled = 0;
|
||||
|
||||
mutex_unlock(&rt5682s->wclk_mutex);
|
||||
}
|
||||
|
||||
static unsigned long rt5682s_wclk_recalc_rate(struct clk_hw *hw,
|
||||
|
|
@ -2997,7 +2992,7 @@ static void rt5682s_calibrate(struct rt5682s_priv *rt5682s)
|
|||
{
|
||||
unsigned int count, value;
|
||||
|
||||
mutex_lock(&rt5682s->calibrate_mutex);
|
||||
guard(mutex)(&rt5682s->calibrate_mutex);
|
||||
|
||||
regmap_write(rt5682s->regmap, RT5682S_PWR_ANLG_1, 0xaa80);
|
||||
usleep_range(15000, 20000);
|
||||
|
|
@ -3034,8 +3029,6 @@ static void rt5682s_calibrate(struct rt5682s_priv *rt5682s)
|
|||
regmap_write(rt5682s->regmap, RT5682S_PWR_DIG_1, 0x00c0);
|
||||
regmap_write(rt5682s->regmap, RT5682S_PWR_ANLG_1, 0x0800);
|
||||
regmap_write(rt5682s->regmap, RT5682S_GLB_CLK, 0x0000);
|
||||
|
||||
mutex_unlock(&rt5682s->calibrate_mutex);
|
||||
}
|
||||
|
||||
static const struct regmap_config rt5682s_regmap = {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/soundwire/sdw.h>
|
||||
|
|
@ -415,12 +416,11 @@ static int rt700_interrupt_callback(struct sdw_slave *slave,
|
|||
dev_dbg(&slave->dev,
|
||||
"%s control_port_stat=%x", __func__, status->control_port);
|
||||
|
||||
mutex_lock(&rt700->disable_irq_lock);
|
||||
guard(mutex)(&rt700->disable_irq_lock);
|
||||
if (status->control_port & 0x4 && !rt700->disable_irq) {
|
||||
mod_delayed_work(system_power_efficient_wq,
|
||||
&rt700->jack_detect_work, msecs_to_jiffies(250));
|
||||
}
|
||||
mutex_unlock(&rt700->disable_irq_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -499,11 +499,11 @@ static int rt700_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt700->disable_irq_lock);
|
||||
rt700->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
mutex_unlock(&rt700->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt700->disable_irq_lock) {
|
||||
rt700->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/soundwire/sdw_registers.h>
|
||||
|
|
@ -415,13 +416,13 @@ static int rt711_sdca_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt711_sdca->disable_irq_lock);
|
||||
rt711_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
mutex_unlock(&rt711_sdca->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt711_sdca->disable_irq_lock) {
|
||||
rt711_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
}
|
||||
|
||||
if (ret1 < 0 || ret2 < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -443,13 +444,15 @@ static int rt711_sdca_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt711->disable_irq_lock);
|
||||
if (rt711->disable_irq == true) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1, SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt711->disable_irq = false;
|
||||
scoped_guard(mutex, &rt711->disable_irq_lock) {
|
||||
if (rt711->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt711->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt711->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT711_PROBE_TIMEOUT);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -450,7 +451,7 @@ static void rt711_sdca_btn_check_handler(struct work_struct *work)
|
|||
|
||||
static void rt711_sdca_jack_init(struct rt711_sdca_priv *rt711)
|
||||
{
|
||||
mutex_lock(&rt711->calibrate_mutex);
|
||||
guard(mutex)(&rt711->calibrate_mutex);
|
||||
|
||||
if (rt711->hs_jack) {
|
||||
/* Enable HID1 event & set button RTC mode */
|
||||
|
|
@ -515,8 +516,6 @@ static void rt711_sdca_jack_init(struct rt711_sdca_priv *rt711)
|
|||
|
||||
dev_dbg(&rt711->slave->dev, "in %s disable\n", __func__);
|
||||
}
|
||||
|
||||
mutex_unlock(&rt711->calibrate_mutex);
|
||||
}
|
||||
|
||||
static int rt711_sdca_set_jack_detect(struct snd_soc_component *component,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/soundwire/sdw.h>
|
||||
|
|
@ -422,12 +423,11 @@ static int rt711_interrupt_callback(struct sdw_slave *slave,
|
|||
dev_dbg(&slave->dev,
|
||||
"%s control_port_stat=%x", __func__, status->control_port);
|
||||
|
||||
mutex_lock(&rt711->disable_irq_lock);
|
||||
guard(mutex)(&rt711->disable_irq_lock);
|
||||
if (status->control_port & 0x4 && !rt711->disable_irq) {
|
||||
mod_delayed_work(system_power_efficient_wq,
|
||||
&rt711->jack_detect_work, msecs_to_jiffies(250));
|
||||
}
|
||||
mutex_unlock(&rt711->disable_irq_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -509,11 +509,11 @@ static int rt711_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt711->disable_irq_lock);
|
||||
rt711->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
mutex_unlock(&rt711->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt711->disable_irq_lock) {
|
||||
rt711->disable_irq = true;
|
||||
ret = sdw_update_no_pm(slave, SDW_SCP_INTMASK1,
|
||||
SDW_SCP_INT1_IMPL_DEF, 0);
|
||||
}
|
||||
|
||||
if (ret < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -535,12 +535,12 @@ static int rt711_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt711->disable_irq_lock);
|
||||
if (rt711->disable_irq == true) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_INTMASK1, SDW_SCP_INT1_IMPL_DEF);
|
||||
rt711->disable_irq = false;
|
||||
scoped_guard(mutex, &rt711->disable_irq_lock) {
|
||||
if (rt711->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_INTMASK1, SDW_SCP_INT1_IMPL_DEF);
|
||||
rt711->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt711->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT711_PROBE_TIMEOUT);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/moduleparam.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -89,24 +90,24 @@ static int rt711_calibration(struct rt711_priv *rt711)
|
|||
struct regmap *regmap = rt711->regmap;
|
||||
int ret = 0;
|
||||
|
||||
mutex_lock(&rt711->calibrate_mutex);
|
||||
guard(mutex)(&rt711->calibrate_mutex);
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
|
||||
|
||||
dev = regmap_get_device(regmap);
|
||||
|
||||
/* Calibration manual mode */
|
||||
rt711_index_update_bits(regmap, RT711_VENDOR_REG, RT711_FSM_CTL,
|
||||
0xf, 0x0);
|
||||
0xf, 0x0);
|
||||
|
||||
/* trigger */
|
||||
rt711_index_update_bits(regmap, RT711_VENDOR_CALI,
|
||||
RT711_DAC_DC_CALI_CTL1, RT711_DAC_DC_CALI_TRIGGER,
|
||||
RT711_DAC_DC_CALI_TRIGGER);
|
||||
RT711_DAC_DC_CALI_CTL1, RT711_DAC_DC_CALI_TRIGGER,
|
||||
RT711_DAC_DC_CALI_TRIGGER);
|
||||
|
||||
/* wait for calibration process */
|
||||
rt711_index_read(regmap, RT711_VENDOR_CALI,
|
||||
RT711_DAC_DC_CALI_CTL1, &val);
|
||||
RT711_DAC_DC_CALI_CTL1, &val);
|
||||
|
||||
while (val & RT711_DAC_DC_CALI_TRIGGER) {
|
||||
if (loop >= 500) {
|
||||
|
|
@ -119,16 +120,15 @@ static int rt711_calibration(struct rt711_priv *rt711)
|
|||
|
||||
usleep_range(10000, 11000);
|
||||
rt711_index_read(regmap, RT711_VENDOR_CALI,
|
||||
RT711_DAC_DC_CALI_CTL1, &val);
|
||||
RT711_DAC_DC_CALI_CTL1, &val);
|
||||
}
|
||||
|
||||
/* depop mode */
|
||||
rt711_index_update_bits(regmap, RT711_VENDOR_REG,
|
||||
RT711_FSM_CTL, 0xf, RT711_DEPOP_CTL);
|
||||
RT711_FSM_CTL, 0xf, RT711_DEPOP_CTL);
|
||||
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
|
||||
mutex_unlock(&rt711->calibrate_mutex);
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
|
||||
|
||||
dev_dbg(dev, "%s calibration complete, ret=%d\n", __func__, ret);
|
||||
return ret;
|
||||
|
|
@ -362,24 +362,24 @@ static void rt711_jack_init(struct rt711_priv *rt711)
|
|||
{
|
||||
struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(rt711->component);
|
||||
|
||||
mutex_lock(&rt711->calibrate_mutex);
|
||||
guard(mutex)(&rt711->calibrate_mutex);
|
||||
/* power on */
|
||||
if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY)
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D0);
|
||||
|
||||
if (rt711->hs_jack) {
|
||||
/* unsolicited response & IRQ control */
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_MIC2_UNSOLICITED_ENABLE, 0x82);
|
||||
RT711_SET_MIC2_UNSOLICITED_ENABLE, 0x82);
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_HP_UNSOLICITED_ENABLE, 0x81);
|
||||
RT711_SET_HP_UNSOLICITED_ENABLE, 0x81);
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_INLINE_UNSOLICITED_ENABLE, 0x83);
|
||||
RT711_SET_INLINE_UNSOLICITED_ENABLE, 0x83);
|
||||
rt711_index_write(rt711->regmap, RT711_VENDOR_REG,
|
||||
0x10, 0x2420);
|
||||
0x10, 0x2420);
|
||||
rt711_index_write(rt711->regmap, RT711_VENDOR_REG,
|
||||
0x19, 0x2e11);
|
||||
0x19, 0x2e11);
|
||||
|
||||
switch (rt711->jd_src) {
|
||||
case RT711_JD1:
|
||||
|
|
@ -449,8 +449,7 @@ static void rt711_jack_init(struct rt711_priv *rt711)
|
|||
/* power off */
|
||||
if (snd_soc_dapm_get_bias_level(dapm) <= SND_SOC_BIAS_STANDBY)
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
|
||||
mutex_unlock(&rt711->calibrate_mutex);
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
|
||||
}
|
||||
|
||||
static int rt711_set_jack_detect(struct snd_soc_component *component,
|
||||
|
|
@ -511,7 +510,7 @@ static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol,
|
|||
unsigned int read_ll, read_rl;
|
||||
int i;
|
||||
|
||||
mutex_lock(&rt711->calibrate_mutex);
|
||||
guard(mutex)(&rt711->calibrate_mutex);
|
||||
|
||||
/* Can't use update bit function, so read the original value first */
|
||||
addr_h = mc->reg;
|
||||
|
|
@ -599,7 +598,6 @@ static int rt711_set_amp_gain_put(struct snd_kcontrol *kcontrol,
|
|||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE, AC_PWRST_D3);
|
||||
|
||||
mutex_unlock(&rt711->calibrate_mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -908,11 +906,11 @@ static int rt711_set_bias_level(struct snd_soc_component *component,
|
|||
break;
|
||||
|
||||
case SND_SOC_BIAS_STANDBY:
|
||||
mutex_lock(&rt711->calibrate_mutex);
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE,
|
||||
AC_PWRST_D3);
|
||||
mutex_unlock(&rt711->calibrate_mutex);
|
||||
scoped_guard(mutex, &rt711->calibrate_mutex) {
|
||||
regmap_write(rt711->regmap,
|
||||
RT711_SET_AUDIO_POWER_STATE,
|
||||
AC_PWRST_D3);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -427,13 +428,13 @@ static int rt712_sdca_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt712_sdca->disable_irq_lock);
|
||||
rt712_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
mutex_unlock(&rt712_sdca->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt712_sdca->disable_irq_lock) {
|
||||
rt712_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
}
|
||||
|
||||
if (ret1 < 0 || ret2 < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -455,14 +456,15 @@ static int rt712_sdca_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt712->disable_irq_lock);
|
||||
if (rt712->disable_irq == true) {
|
||||
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1, SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt712->disable_irq = false;
|
||||
scoped_guard(mutex, &rt712->disable_irq_lock) {
|
||||
if (rt712->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt712->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt712->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT712_PROBE_TIMEOUT);
|
||||
|
|
@ -473,22 +475,20 @@ static int rt712_sdca_dev_resume(struct device *dev)
|
|||
|
||||
regcache_cache_only(rt712->regmap, false);
|
||||
ret = regcache_sync(rt712->regmap);
|
||||
if (ret)
|
||||
goto err_sync;
|
||||
if (ret) {
|
||||
regcache_cache_only(rt712->regmap, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
regcache_cache_only(rt712->mbq_regmap, false);
|
||||
ret = regcache_sync(rt712->mbq_regmap);
|
||||
if (ret)
|
||||
goto err_sync;
|
||||
if (ret) {
|
||||
regcache_cache_only(rt712->mbq_regmap, true);
|
||||
regcache_cache_only(rt712->regmap, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_sync:
|
||||
regcache_cache_only(rt712->regmap, true);
|
||||
regcache_cache_only(rt712->mbq_regmap, true);
|
||||
regcache_mark_dirty(rt712->regmap);
|
||||
regcache_mark_dirty(rt712->mbq_regmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops rt712_sdca_pm = {
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/cleanup.h>
|
||||
#include <sound/core.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/init.h>
|
||||
|
|
@ -403,7 +404,7 @@ static void rt712_sdca_btn_check_handler(struct work_struct *work)
|
|||
|
||||
static void rt712_sdca_jack_init(struct rt712_sdca_priv *rt712)
|
||||
{
|
||||
mutex_lock(&rt712->calibrate_mutex);
|
||||
guard(mutex)(&rt712->calibrate_mutex);
|
||||
|
||||
if (rt712->hs_jack) {
|
||||
/* Enable HID1 event & set button RTC mode */
|
||||
|
|
@ -450,8 +451,6 @@ static void rt712_sdca_jack_init(struct rt712_sdca_priv *rt712)
|
|||
|
||||
dev_dbg(&rt712->slave->dev, "in %s disable\n", __func__);
|
||||
}
|
||||
|
||||
mutex_unlock(&rt712->calibrate_mutex);
|
||||
}
|
||||
|
||||
static int rt712_sdca_set_jack_detect(struct snd_soc_component *component,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -466,13 +467,13 @@ static int rt721_sdca_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt721_sdca->disable_irq_lock);
|
||||
rt721_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
mutex_unlock(&rt721_sdca->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt721_sdca->disable_irq_lock) {
|
||||
rt721_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
}
|
||||
|
||||
if (ret1 < 0 || ret2 < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -494,13 +495,15 @@ static int rt721_sdca_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt721->disable_irq_lock);
|
||||
if (rt721->disable_irq == true) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1, SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt721->disable_irq = false;
|
||||
scoped_guard(mutex, &rt721->disable_irq_lock) {
|
||||
if (rt721->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt721->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt721->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT721_PROBE_TIMEOUT);
|
||||
|
|
@ -511,22 +514,20 @@ static int rt721_sdca_dev_resume(struct device *dev)
|
|||
|
||||
regcache_cache_only(rt721->regmap, false);
|
||||
ret = regcache_sync(rt721->regmap);
|
||||
if (ret)
|
||||
goto err_sync;
|
||||
if (ret) {
|
||||
regcache_cache_only(rt721->regmap, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
regcache_cache_only(rt721->mbq_regmap, false);
|
||||
ret = regcache_sync(rt721->mbq_regmap);
|
||||
if (ret)
|
||||
goto err_sync;
|
||||
if (ret) {
|
||||
regcache_cache_only(rt721->mbq_regmap, true);
|
||||
regcache_cache_only(rt721->regmap, true);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
err_sync:
|
||||
regcache_cache_only(rt721->regmap, true);
|
||||
regcache_cache_only(rt721->mbq_regmap, true);
|
||||
regcache_mark_dirty(rt721->regmap);
|
||||
regcache_mark_dirty(rt721->mbq_regmap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct dev_pm_ops rt721_sdca_pm = {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// Copyright(c) 2024 Realtek Semiconductor Corp.
|
||||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <sound/core.h>
|
||||
#include <linux/delay.h>
|
||||
|
|
@ -289,7 +289,7 @@ static void rt721_sdca_jack_preset(struct rt721_sdca_priv *rt721)
|
|||
|
||||
static void rt721_sdca_jack_init(struct rt721_sdca_priv *rt721)
|
||||
{
|
||||
mutex_lock(&rt721->calibrate_mutex);
|
||||
guard(mutex)(&rt721->calibrate_mutex);
|
||||
if (rt721->hs_jack) {
|
||||
sdw_write_no_pm(rt721->slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
|
|
@ -309,7 +309,6 @@ static void rt721_sdca_jack_init(struct rt721_sdca_priv *rt721)
|
|||
rt_sdca_index_update_bits(rt721->mbq_regmap, RT721_HDA_SDCA_FLOAT,
|
||||
RT721_GE_REL_CTRL1, 0x4000, 0x4000);
|
||||
}
|
||||
mutex_unlock(&rt721->calibrate_mutex);
|
||||
}
|
||||
|
||||
static int rt721_sdca_set_jack_detect(struct snd_soc_component *component,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/device.h>
|
||||
#include <linux/module.h>
|
||||
|
|
@ -513,13 +514,13 @@ static int rt722_sdca_dev_system_suspend(struct device *dev)
|
|||
* deferred work completes and before the parent disables
|
||||
* interrupts on the link
|
||||
*/
|
||||
mutex_lock(&rt722_sdca->disable_irq_lock);
|
||||
rt722_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
mutex_unlock(&rt722_sdca->disable_irq_lock);
|
||||
scoped_guard(mutex, &rt722_sdca->disable_irq_lock) {
|
||||
rt722_sdca->disable_irq = true;
|
||||
ret1 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0, 0);
|
||||
ret2 = sdw_update_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8, 0);
|
||||
}
|
||||
|
||||
if (ret1 < 0 || ret2 < 0) {
|
||||
/* log but don't prevent suspend from happening */
|
||||
|
|
@ -541,13 +542,15 @@ static int rt722_sdca_dev_resume(struct device *dev)
|
|||
return 0;
|
||||
|
||||
if (!slave->unattach_request) {
|
||||
mutex_lock(&rt722->disable_irq_lock);
|
||||
if (rt722->disable_irq == true) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1, SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2, SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt722->disable_irq = false;
|
||||
scoped_guard(mutex, &rt722->disable_irq_lock) {
|
||||
if (rt722->disable_irq) {
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK1,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_0);
|
||||
sdw_write_no_pm(slave, SDW_SCP_SDCA_INTMASK2,
|
||||
SDW_SCP_SDCA_INTMASK_SDCA_8);
|
||||
rt722->disable_irq = false;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&rt722->disable_irq_lock);
|
||||
}
|
||||
|
||||
ret = sdw_slave_wait_for_init(slave, RT722_PROBE_TIMEOUT);
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
//
|
||||
//
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/bitops.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/dmi.h>
|
||||
|
|
@ -294,7 +295,7 @@ static void rt722_sdca_btn_check_handler(struct work_struct *work)
|
|||
|
||||
static void rt722_sdca_jack_init(struct rt722_sdca_priv *rt722)
|
||||
{
|
||||
mutex_lock(&rt722->calibrate_mutex);
|
||||
guard(mutex)(&rt722->calibrate_mutex);
|
||||
if (rt722->hs_jack) {
|
||||
/* set SCP_SDCA_IntMask1[0]=1 */
|
||||
sdw_write_no_pm(rt722->slave, SDW_SCP_SDCA_INTMASK1,
|
||||
|
|
@ -317,7 +318,6 @@ static void rt722_sdca_jack_init(struct rt722_sdca_priv *rt722)
|
|||
rt722_sdca_index_update_bits(rt722, RT722_VENDOR_HDA_CTL,
|
||||
RT722_GE_RELATED_CTL2, 0x4000, 0x4000);
|
||||
}
|
||||
mutex_unlock(&rt722->calibrate_mutex);
|
||||
}
|
||||
|
||||
static int rt722_sdca_set_jack_detect(struct snd_soc_component *component,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user