Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit a1fd0f41 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'asoc/topic/wm2200', 'asoc/topic/wm5100',...

Merge remote-tracking branches 'asoc/topic/wm2200', 'asoc/topic/wm5100', 'asoc/topic/wm8350', 'asoc/topic/wm8400' and 'asoc/topic/wm8510' into asoc-next
Loading
Loading
Loading
Loading
+76 −81
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ struct wm2200_priv {
	struct wm_adsp dsp[2];
	struct regmap *regmap;
	struct device *dev;
	struct snd_soc_codec *codec;
	struct snd_soc_component *component;
	struct wm2200_pdata pdata;
	struct regulator_bulk_data core_supplies[WM2200_NUM_CORE_SUPPLIES];

@@ -1550,14 +1550,14 @@ static const struct snd_soc_dapm_route wm2200_dapm_routes[] = {
	WM2200_MIXER_ROUTES("LHPF2", "LHPF2"),
};

static int wm2200_probe(struct snd_soc_codec *codec)
static int wm2200_probe(struct snd_soc_component *component)
{
	struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec);
	struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component);
	int ret;

	wm2200->codec = codec;
	wm2200->component = component;

	ret = snd_soc_add_codec_controls(codec, wm_adsp_fw_controls, 2);
	ret = snd_soc_add_component_controls(component, wm_adsp_fw_controls, 2);
	if (ret != 0)
		return ret;

@@ -1566,7 +1566,7 @@ static int wm2200_probe(struct snd_soc_codec *codec)

static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	int lrclk, bclk, fmt_val;

	lrclk = 0;
@@ -1580,7 +1580,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
		fmt_val = 2;
		break;
	default:
		dev_err(codec->dev, "Unsupported DAI format %d\n",
		dev_err(component->dev, "Unsupported DAI format %d\n",
			fmt & SND_SOC_DAIFMT_FORMAT_MASK);
		return -EINVAL;
	}
@@ -1599,7 +1599,7 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
		bclk |= WM2200_AIF1_BCLK_MSTR;
		break;
	default:
		dev_err(codec->dev, "Unsupported master mode %d\n",
		dev_err(component->dev, "Unsupported master mode %d\n",
			fmt & SND_SOC_DAIFMT_MASTER_MASK);
		return -EINVAL;
	}
@@ -1621,15 +1621,15 @@ static int wm2200_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
		return -EINVAL;
	}

	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR |
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1, WM2200_AIF1_BCLK_MSTR |
			    WM2200_AIF1_BCLK_INV, bclk);
	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2,
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2,
			    WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV,
			    lrclk);
	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_3,
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_3,
			    WM2200_AIF1TX_LRCLK_MSTR | WM2200_AIF1TX_LRCLK_INV,
			    lrclk);
	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_5,
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_5,
			    WM2200_AIF1_FMT_MASK, fmt_val);

	return 0;
@@ -1698,8 +1698,8 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream,
			    struct snd_pcm_hw_params *params,
			    struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = dai->component;
	struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component);
	int i, bclk, lrclk, wl, fl, sr_code;
	int *bclk_rates;

@@ -1711,7 +1711,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream,
	if (fl < 0)
		return fl;

	dev_dbg(codec->dev, "Word length %d bits, frame length %d bits\n",
	dev_dbg(component->dev, "Word length %d bits, frame length %d bits\n",
		wl, fl);

	/* Target BCLK rate */
@@ -1720,7 +1720,7 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream,
		return bclk;

	if (!wm2200->sysclk) {
		dev_err(codec->dev, "SYSCLK has no rate set\n");
		dev_err(component->dev, "SYSCLK has no rate set\n");
		return -EINVAL;
	}

@@ -1728,13 +1728,13 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream,
		if (wm2200_sr_code[i] == params_rate(params))
			break;
	if (i == ARRAY_SIZE(wm2200_sr_code)) {
		dev_err(codec->dev, "Unsupported sample rate: %dHz\n",
		dev_err(component->dev, "Unsupported sample rate: %dHz\n",
			params_rate(params));
		return -EINVAL;
	}
	sr_code = i;

	dev_dbg(codec->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n",
	dev_dbg(component->dev, "Target BCLK is %dHz, using %dHz SYSCLK\n",
		bclk, wm2200->sysclk);

	if (wm2200->sysclk % 4000)
@@ -1746,38 +1746,38 @@ static int wm2200_hw_params(struct snd_pcm_substream *substream,
		if (bclk_rates[i] >= bclk && (bclk_rates[i] % bclk == 0))
			break;
	if (i == WM2200_NUM_BCLK_RATES) {
		dev_err(codec->dev,
		dev_err(component->dev,
			"No valid BCLK for %dHz found from %dHz SYSCLK\n",
			bclk, wm2200->sysclk);
		return -EINVAL;
	}

	bclk = i;
	dev_dbg(codec->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]);
	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_1,
	dev_dbg(component->dev, "Setting %dHz BCLK\n", bclk_rates[bclk]);
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_1,
			    WM2200_AIF1_BCLK_DIV_MASK, bclk);

	lrclk = bclk_rates[bclk] / params_rate(params);
	dev_dbg(codec->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk);
	dev_dbg(component->dev, "Setting %dHz LRCLK\n", bclk_rates[bclk] / lrclk);
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK ||
	    wm2200->symmetric_rates)
		snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_7,
		snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_7,
				    WM2200_AIF1RX_BCPF_MASK, lrclk);
	else
		snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_6,
		snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_6,
				    WM2200_AIF1TX_BCPF_MASK, lrclk);

	i = (wl << WM2200_AIF1TX_WL_SHIFT) | wl;
	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
		snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_9,
		snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_9,
				    WM2200_AIF1RX_WL_MASK |
				    WM2200_AIF1RX_SLOT_LEN_MASK, i);
	else
		snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_8,
		snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_8,
				    WM2200_AIF1TX_WL_MASK |
				    WM2200_AIF1TX_SLOT_LEN_MASK, i);

	snd_soc_update_bits(codec, WM2200_CLOCKING_4,
	snd_soc_component_update_bits(component, WM2200_CLOCKING_4,
			    WM2200_SAMPLE_RATE_1_MASK, sr_code);

	return 0;
@@ -1788,10 +1788,10 @@ static const struct snd_soc_dai_ops wm2200_dai_ops = {
	.hw_params = wm2200_hw_params,
};

static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id,
static int wm2200_set_sysclk(struct snd_soc_component *component, int clk_id,
			     int source, unsigned int freq, int dir)
{
	struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec);
	struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component);
	int fval;

	switch (clk_id) {
@@ -1799,7 +1799,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id,
		break;

	default:
		dev_err(codec->dev, "Unknown clock %d\n", clk_id);
		dev_err(component->dev, "Unknown clock %d\n", clk_id);
		return -EINVAL;
	}

@@ -1810,7 +1810,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id,
	case WM2200_CLKSRC_BCLK1:
		break;
	default:
		dev_err(codec->dev, "Invalid source %d\n", source);
		dev_err(component->dev, "Invalid source %d\n", source);
		return -EINVAL;
	}

@@ -1820,7 +1820,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id,
		fval = 2;
		break;
	default:
		dev_err(codec->dev, "Invalid clock rate: %d\n", freq);
		dev_err(component->dev, "Invalid clock rate: %d\n", freq);
		return -EINVAL;
	}

@@ -1828,7 +1828,7 @@ static int wm2200_set_sysclk(struct snd_soc_codec *codec, int clk_id,
	 * match.
	 */

	snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK |
	snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_FREQ_MASK |
			    WM2200_SYSCLK_SRC_MASK,
			    fval << WM2200_SYSCLK_FREQ_SHIFT | source);

@@ -1936,23 +1936,23 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
	return 0;
}

static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
static int wm2200_set_fll(struct snd_soc_component *component, int fll_id, int source,
			  unsigned int Fref, unsigned int Fout)
{
	struct i2c_client *i2c = to_i2c_client(codec->dev);
	struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec);
	struct i2c_client *i2c = to_i2c_client(component->dev);
	struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component);
	struct _fll_div factors;
	int ret, i, timeout;
	unsigned long time_left;

	if (!Fout) {
		dev_dbg(codec->dev, "FLL disabled");
		dev_dbg(component->dev, "FLL disabled");

		if (wm2200->fll_fout)
			pm_runtime_put(codec->dev);
			pm_runtime_put(component->dev);

		wm2200->fll_fout = 0;
		snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1,
		snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1,
				    WM2200_FLL_ENA, 0);
		return 0;
	}
@@ -1963,7 +1963,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
	case WM2200_FLL_SRC_BCLK:
		break;
	default:
		dev_err(codec->dev, "Invalid FLL source %d\n", source);
		dev_err(component->dev, "Invalid FLL source %d\n", source);
		return -EINVAL;
	}

@@ -1972,44 +1972,44 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
		return ret;

	/* Disable the FLL while we reconfigure */
	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0);
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1, WM2200_FLL_ENA, 0);

	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_2,
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_2,
			    WM2200_FLL_OUTDIV_MASK | WM2200_FLL_FRATIO_MASK,
			    (factors.fll_outdiv << WM2200_FLL_OUTDIV_SHIFT) |
			    factors.fll_fratio);
	if (factors.theta) {
		snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3,
		snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3,
				    WM2200_FLL_FRACN_ENA,
				    WM2200_FLL_FRACN_ENA);
		snd_soc_update_bits(codec, WM2200_FLL_EFS_2,
		snd_soc_component_update_bits(component, WM2200_FLL_EFS_2,
				    WM2200_FLL_EFS_ENA,
				    WM2200_FLL_EFS_ENA);
	} else {
		snd_soc_update_bits(codec, WM2200_FLL_CONTROL_3,
		snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_3,
				    WM2200_FLL_FRACN_ENA, 0);
		snd_soc_update_bits(codec, WM2200_FLL_EFS_2,
		snd_soc_component_update_bits(component, WM2200_FLL_EFS_2,
				    WM2200_FLL_EFS_ENA, 0);
	}

	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK,
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_4, WM2200_FLL_THETA_MASK,
			    factors.theta);
	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK,
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_6, WM2200_FLL_N_MASK,
			    factors.n);
	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_7,
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_7,
			    WM2200_FLL_CLK_REF_DIV_MASK |
			    WM2200_FLL_CLK_REF_SRC_MASK,
			    (factors.fll_refclk_div
			     << WM2200_FLL_CLK_REF_DIV_SHIFT) | source);
	snd_soc_update_bits(codec, WM2200_FLL_EFS_1,
	snd_soc_component_update_bits(component, WM2200_FLL_EFS_1,
			    WM2200_FLL_LAMBDA_MASK, factors.lambda);

	/* Clear any pending completions */
	try_wait_for_completion(&wm2200->fll_lock);

	pm_runtime_get_sync(codec->dev);
	pm_runtime_get_sync(component->dev);

	snd_soc_update_bits(codec, WM2200_FLL_CONTROL_1,
	snd_soc_component_update_bits(component, WM2200_FLL_CONTROL_1,
			    WM2200_FLL_ENA, WM2200_FLL_ENA);

	if (i2c->irq)
@@ -2017,7 +2017,7 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
	else
		timeout = 50;

	snd_soc_update_bits(codec, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA,
	snd_soc_component_update_bits(component, WM2200_CLOCKING_3, WM2200_SYSCLK_ENA,
			    WM2200_SYSCLK_ENA);

	/* Poll for the lock; will use the interrupt to exit quickly */
@@ -2032,10 +2032,10 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
			msleep(1);
		}

		ret = snd_soc_read(codec,
		ret = snd_soc_component_read32(component,
				   WM2200_INTERRUPT_RAW_STATUS_2);
		if (ret < 0) {
			dev_err(codec->dev,
			dev_err(component->dev,
				"Failed to read FLL status: %d\n",
				ret);
			continue;
@@ -2044,8 +2044,8 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
			break;
	}
	if (i == timeout) {
		dev_err(codec->dev, "FLL lock timed out\n");
		pm_runtime_put(codec->dev);
		dev_err(component->dev, "FLL lock timed out\n");
		pm_runtime_put(component->dev);
		return -ETIMEDOUT;
	}

@@ -2053,29 +2053,29 @@ static int wm2200_set_fll(struct snd_soc_codec *codec, int fll_id, int source,
	wm2200->fll_fref = Fref;
	wm2200->fll_fout = Fout;

	dev_dbg(codec->dev, "FLL running %dHz->%dHz\n", Fref, Fout);
	dev_dbg(component->dev, "FLL running %dHz->%dHz\n", Fref, Fout);

	return 0;
}

static int wm2200_dai_probe(struct snd_soc_dai *dai)
{
	struct snd_soc_codec *codec = dai->codec;
	struct wm2200_priv *wm2200 = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = dai->component;
	struct wm2200_priv *wm2200 = snd_soc_component_get_drvdata(component);
	unsigned int val = 0;
	int ret;

	ret = snd_soc_read(codec, WM2200_GPIO_CTRL_1);
	ret = snd_soc_component_read32(component, WM2200_GPIO_CTRL_1);
	if (ret >= 0) {
		if ((ret & WM2200_GP1_FN_MASK) != 0) {
			wm2200->symmetric_rates = true;
			val = WM2200_AIF1TX_LRCLK_SRC;
		}
	} else {
		dev_err(codec->dev, "Failed to read GPIO 1 config: %d\n", ret);
		dev_err(component->dev, "Failed to read GPIO 1 config: %d\n", ret);
	}

	snd_soc_update_bits(codec, WM2200_AUDIO_IF_1_2,
	snd_soc_component_update_bits(component, WM2200_AUDIO_IF_1_2,
			    WM2200_AIF1TX_LRCLK_SRC, val);

	return 0;
@@ -2106,22 +2106,18 @@ static struct snd_soc_dai_driver wm2200_dai = {
	.ops = &wm2200_dai_ops,
};

static const struct snd_soc_codec_driver soc_codec_wm2200 = {
static const struct snd_soc_component_driver soc_component_wm2200 = {
	.probe			= wm2200_probe,

	.idle_bias_off = true,
	.ignore_pmdown_time = true,
	.set_sysclk		= wm2200_set_sysclk,
	.set_pll		= wm2200_set_fll,

	.component_driver = {
	.controls		= wm2200_snd_controls,
	.num_controls		= ARRAY_SIZE(wm2200_snd_controls),
	.dapm_widgets		= wm2200_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(wm2200_dapm_widgets),
	.dapm_routes		= wm2200_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(wm2200_dapm_routes),
	},
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};

static irqreturn_t wm2200_irq(int irq, void *data)
@@ -2408,7 +2404,7 @@ static int wm2200_i2c_probe(struct i2c_client *i2c,
	pm_runtime_enable(&i2c->dev);
	pm_request_idle(&i2c->dev);

	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_wm2200,
	ret = devm_snd_soc_register_component(&i2c->dev, &soc_component_wm2200,
				     &wm2200_dai, 1);
	if (ret != 0) {
		dev_err(&i2c->dev, "Failed to register CODEC: %d\n", ret);
@@ -2435,7 +2431,6 @@ static int wm2200_i2c_remove(struct i2c_client *i2c)
{
	struct wm2200_priv *wm2200 = i2c_get_clientdata(i2c);

	snd_soc_unregister_codec(&i2c->dev);
	if (i2c->irq)
		free_irq(i2c->irq, wm2200);
	if (wm2200->pdata.reset)
+127 −133

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@
#include <sound/soc.h>
#include <linux/regmap.h>

int wm5100_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack);
int wm5100_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);

#define WM5100_CLK_AIF1     1
#define WM5100_CLK_AIF2     2
+88 −95
Original line number Diff line number Diff line
@@ -256,8 +256,8 @@ static void wm8350_pga_work(struct work_struct *work)
static int pga_event(struct snd_soc_dapm_widget *w,
		     struct snd_kcontrol *kcontrol, int event)
{
	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
	struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
	struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component);
	struct wm8350_output *out;

	switch (w->shift) {
@@ -299,8 +299,8 @@ static int pga_event(struct snd_soc_dapm_widget *w,
static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol,
				  struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component);
	struct wm8350_output *out = NULL;
	struct soc_mixer_control *mc =
		(struct soc_mixer_control *)kcontrol->private_value;
@@ -334,16 +334,16 @@ static int wm8350_put_volsw_2r_vu(struct snd_kcontrol *kcontrol,
		return ret;

	/* now hit the volume update bits (always bit 8) */
	val = snd_soc_read(codec, reg);
	snd_soc_write(codec, reg, val | WM8350_OUT1_VU);
	val = snd_soc_component_read32(component, reg);
	snd_soc_component_write(component, reg, val | WM8350_OUT1_VU);
	return 1;
}

static int wm8350_get_volsw_2r(struct snd_kcontrol *kcontrol,
			       struct snd_ctl_elem_value *ucontrol)
{
	struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol);
	struct wm8350_data *wm8350_priv = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = snd_soc_kcontrol_component(kcontrol);
	struct wm8350_data *wm8350_priv = snd_soc_component_get_drvdata(component);
	struct wm8350_output *out1 = &wm8350_priv->out1;
	struct wm8350_output *out2 = &wm8350_priv->out2;
	struct soc_mixer_control *mc =
@@ -753,8 +753,8 @@ static const struct snd_soc_dapm_route wm8350_dapm_routes[] = {
static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
				 int clk_id, unsigned int freq, int dir)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = codec_dai->component;
	struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = wm8350_data->wm8350;
	u16 fll_4;

@@ -769,9 +769,9 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai,
	case WM8350_MCLK_SEL_PLL_32K:
		wm8350_set_bits(wm8350, WM8350_CLOCK_CONTROL_1,
				WM8350_MCLK_SEL);
		fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) &
		fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) &
		    ~WM8350_FLL_CLK_SRC_MASK;
		snd_soc_write(codec, WM8350_FLL_CONTROL_4, fll_4 | clk_id);
		snd_soc_component_write(component, WM8350_FLL_CONTROL_4, fll_4 | clk_id);
		break;
	}

@@ -788,44 +788,44 @@ static int wm8350_set_dai_sysclk(struct snd_soc_dai *codec_dai,

static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct snd_soc_component *component = codec_dai->component;
	u16 val;

	switch (div_id) {
	case WM8350_ADC_CLKDIV:
		val = snd_soc_read(codec, WM8350_ADC_DIVIDER) &
		val = snd_soc_component_read32(component, WM8350_ADC_DIVIDER) &
		    ~WM8350_ADC_CLKDIV_MASK;
		snd_soc_write(codec, WM8350_ADC_DIVIDER, val | div);
		snd_soc_component_write(component, WM8350_ADC_DIVIDER, val | div);
		break;
	case WM8350_DAC_CLKDIV:
		val = snd_soc_read(codec, WM8350_DAC_CLOCK_CONTROL) &
		val = snd_soc_component_read32(component, WM8350_DAC_CLOCK_CONTROL) &
		    ~WM8350_DAC_CLKDIV_MASK;
		snd_soc_write(codec, WM8350_DAC_CLOCK_CONTROL, val | div);
		snd_soc_component_write(component, WM8350_DAC_CLOCK_CONTROL, val | div);
		break;
	case WM8350_BCLK_CLKDIV:
		val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) &
		val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
		    ~WM8350_BCLK_DIV_MASK;
		snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div);
		snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
		break;
	case WM8350_OPCLK_CLKDIV:
		val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) &
		val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
		    ~WM8350_OPCLK_DIV_MASK;
		snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div);
		snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
		break;
	case WM8350_SYS_CLKDIV:
		val = snd_soc_read(codec, WM8350_CLOCK_CONTROL_1) &
		val = snd_soc_component_read32(component, WM8350_CLOCK_CONTROL_1) &
		    ~WM8350_MCLK_DIV_MASK;
		snd_soc_write(codec, WM8350_CLOCK_CONTROL_1, val | div);
		snd_soc_component_write(component, WM8350_CLOCK_CONTROL_1, val | div);
		break;
	case WM8350_DACLR_CLKDIV:
		val = snd_soc_read(codec, WM8350_DAC_LR_RATE) &
		val = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) &
		    ~WM8350_DACLRC_RATE_MASK;
		snd_soc_write(codec, WM8350_DAC_LR_RATE, val | div);
		snd_soc_component_write(component, WM8350_DAC_LR_RATE, val | div);
		break;
	case WM8350_ADCLR_CLKDIV:
		val = snd_soc_read(codec, WM8350_ADC_LR_RATE) &
		val = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) &
		    ~WM8350_ADCLRC_RATE_MASK;
		snd_soc_write(codec, WM8350_ADC_LR_RATE, val | div);
		snd_soc_component_write(component, WM8350_ADC_LR_RATE, val | div);
		break;
	default:
		return -EINVAL;
@@ -836,14 +836,14 @@ static int wm8350_set_clkdiv(struct snd_soc_dai *codec_dai, int div_id, int div)

static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) &
	struct snd_soc_component *component = codec_dai->component;
	u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) &
	    ~(WM8350_AIF_BCLK_INV | WM8350_AIF_LRCLK_INV | WM8350_AIF_FMT_MASK);
	u16 master = snd_soc_read(codec, WM8350_AI_DAC_CONTROL) &
	u16 master = snd_soc_component_read32(component, WM8350_AI_DAC_CONTROL) &
	    ~WM8350_BCLK_MSTR;
	u16 dac_lrc = snd_soc_read(codec, WM8350_DAC_LR_RATE) &
	u16 dac_lrc = snd_soc_component_read32(component, WM8350_DAC_LR_RATE) &
	    ~WM8350_DACLRC_ENA;
	u16 adc_lrc = snd_soc_read(codec, WM8350_ADC_LR_RATE) &
	u16 adc_lrc = snd_soc_component_read32(component, WM8350_ADC_LR_RATE) &
	    ~WM8350_ADCLRC_ENA;

	/* set master/slave audio interface */
@@ -896,10 +896,10 @@ static int wm8350_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt)
		return -EINVAL;
	}

	snd_soc_write(codec, WM8350_AI_FORMATING, iface);
	snd_soc_write(codec, WM8350_AI_DAC_CONTROL, master);
	snd_soc_write(codec, WM8350_DAC_LR_RATE, dac_lrc);
	snd_soc_write(codec, WM8350_ADC_LR_RATE, adc_lrc);
	snd_soc_component_write(component, WM8350_AI_FORMATING, iface);
	snd_soc_component_write(component, WM8350_AI_DAC_CONTROL, master);
	snd_soc_component_write(component, WM8350_DAC_LR_RATE, dac_lrc);
	snd_soc_component_write(component, WM8350_ADC_LR_RATE, adc_lrc);
	return 0;
}

@@ -907,10 +907,10 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params,
				struct snd_soc_dai *codec_dai)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct wm8350_data *wm8350_data = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = codec_dai->component;
	struct wm8350_data *wm8350_data = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = wm8350_data->wm8350;
	u16 iface = snd_soc_read(codec, WM8350_AI_FORMATING) &
	u16 iface = snd_soc_component_read32(component, WM8350_AI_FORMATING) &
	    ~WM8350_AIF_WL_MASK;

	/* bit size */
@@ -928,7 +928,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream,
		break;
	}

	snd_soc_write(codec, WM8350_AI_FORMATING, iface);
	snd_soc_component_write(component, WM8350_AI_FORMATING, iface);

	/* The sloping stopband filter is recommended for use with
	 * lower sample rates to improve performance.
@@ -947,7 +947,7 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream,

static int wm8350_mute(struct snd_soc_dai *dai, int mute)
{
	struct snd_soc_codec *codec = dai->codec;
	struct snd_soc_component *component = dai->component;
	unsigned int val;

	if (mute)
@@ -955,7 +955,7 @@ static int wm8350_mute(struct snd_soc_dai *dai, int mute)
	else
		val = 0;

	snd_soc_update_bits(codec, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val);
	snd_soc_component_update_bits(component, WM8350_DAC_MUTE, WM8350_DAC_MUTE_ENA, val);

	return 0;
}
@@ -1024,8 +1024,8 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai,
			  int pll_id, int source, unsigned int freq_in,
			  unsigned int freq_out)
{
	struct snd_soc_codec *codec = codec_dai->codec;
	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
	struct snd_soc_component *component = codec_dai->component;
	struct wm8350_data *priv = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = priv->wm8350;
	struct _fll_div fll_div;
	int ret = 0;
@@ -1050,17 +1050,17 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai,
		fll_div.ratio);

	/* set up N.K & dividers */
	fll_1 = snd_soc_read(codec, WM8350_FLL_CONTROL_1) &
	fll_1 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_1) &
	    ~(WM8350_FLL_OUTDIV_MASK | WM8350_FLL_RSP_RATE_MASK | 0xc000);
	snd_soc_write(codec, WM8350_FLL_CONTROL_1,
	snd_soc_component_write(component, WM8350_FLL_CONTROL_1,
			   fll_1 | (fll_div.div << 8) | 0x50);
	snd_soc_write(codec, WM8350_FLL_CONTROL_2,
	snd_soc_component_write(component, WM8350_FLL_CONTROL_2,
			   (fll_div.ratio << 11) | (fll_div.
						    n & WM8350_FLL_N_MASK));
	snd_soc_write(codec, WM8350_FLL_CONTROL_3, fll_div.k);
	fll_4 = snd_soc_read(codec, WM8350_FLL_CONTROL_4) &
	snd_soc_component_write(component, WM8350_FLL_CONTROL_3, fll_div.k);
	fll_4 = snd_soc_component_read32(component, WM8350_FLL_CONTROL_4) &
	    ~(WM8350_FLL_FRAC | WM8350_FLL_SLOW_LOCK_REF);
	snd_soc_write(codec, WM8350_FLL_CONTROL_4,
	snd_soc_component_write(component, WM8350_FLL_CONTROL_4,
			   fll_4 | (fll_div.k ? WM8350_FLL_FRAC : 0) |
			   (fll_div.ratio == 8 ? WM8350_FLL_SLOW_LOCK_REF : 0));

@@ -1074,10 +1074,10 @@ static int wm8350_set_fll(struct snd_soc_dai *codec_dai,
	return 0;
}

static int wm8350_set_bias_level(struct snd_soc_codec *codec,
static int wm8350_set_bias_level(struct snd_soc_component *component,
				 enum snd_soc_bias_level level)
{
	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
	struct wm8350_data *priv = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = priv->wm8350;
	struct wm8350_audio_platform_data *platform =
		wm8350->codec.platform_data;
@@ -1101,7 +1101,7 @@ static int wm8350_set_bias_level(struct snd_soc_codec *codec,
		break;

	case SND_SOC_BIAS_STANDBY:
		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF) {
		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_OFF) {
			ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies),
						    priv->supplies);
			if (ret != 0)
@@ -1310,7 +1310,7 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data)
/**
 * wm8350_hp_jack_detect - Enable headphone jack detection.
 *
 * @codec:  WM8350 codec
 * @component:  WM8350 component
 * @which:  left or right jack detect signal
 * @jack:   jack to report detection events on
 * @report: value to report
@@ -1318,10 +1318,10 @@ static irqreturn_t wm8350_hpr_jack_handler(int irq, void *data)
 * Enables the headphone jack detection of the WM8350.  If no report
 * is specified then detection is disabled.
 */
int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which,
int wm8350_hp_jack_detect(struct snd_soc_component *component, enum wm8350_jack which,
			  struct snd_soc_jack *jack, int report)
{
	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
	struct wm8350_data *priv = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = priv->wm8350;
	int ena;

@@ -1389,7 +1389,7 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data)
/**
 * wm8350_mic_jack_detect - Enable microphone jack detection.
 *
 * @codec:         WM8350 codec
 * @component:         WM8350 component
 * @jack:          jack to report detection events on
 * @detect_report: value to report when presence detected
 * @short_report:  value to report when microphone short detected
@@ -1397,11 +1397,11 @@ static irqreturn_t wm8350_mic_handler(int irq, void *data)
 * Enables the microphone jack detection of the WM8350.  If both reports
 * are specified as zero then detection is disabled.
 */
int wm8350_mic_jack_detect(struct snd_soc_codec *codec,
int wm8350_mic_jack_detect(struct snd_soc_component *component,
			   struct snd_soc_jack *jack,
			   int detect_report, int short_report)
{
	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
	struct wm8350_data *priv = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = priv->wm8350;

	priv->mic.jack = jack;
@@ -1455,26 +1455,26 @@ static struct snd_soc_dai_driver wm8350_dai = {
	.ops = &wm8350_dai_ops,
};

static  int wm8350_codec_probe(struct snd_soc_codec *codec)
static  int wm8350_component_probe(struct snd_soc_component *component)
{
	struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
	struct wm8350 *wm8350 = dev_get_platdata(component->dev);
	struct wm8350_data *priv;
	struct wm8350_output *out1;
	struct wm8350_output *out2;
	int ret, i;

	if (wm8350->codec.platform_data == NULL) {
		dev_err(codec->dev, "No audio platform data supplied\n");
		dev_err(component->dev, "No audio platform data supplied\n");
		return -EINVAL;
	}

	priv = devm_kzalloc(codec->dev, sizeof(struct wm8350_data),
	priv = devm_kzalloc(component->dev, sizeof(struct wm8350_data),
			    GFP_KERNEL);
	if (priv == NULL)
		return -ENOMEM;

	snd_soc_codec_init_regmap(codec, wm8350->regmap);
	snd_soc_codec_set_drvdata(codec, priv);
	snd_soc_component_init_regmap(component, wm8350->regmap);
	snd_soc_component_set_drvdata(component, priv);

	priv->wm8350 = wm8350;

@@ -1497,9 +1497,9 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
	wm8350_set_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);

	/* Enable robust clocking mode in ADC */
	snd_soc_write(codec, WM8350_SECURITY, 0xa7);
	snd_soc_write(codec, 0xde, 0x13);
	snd_soc_write(codec, WM8350_SECURITY, 0);
	snd_soc_component_write(component, WM8350_SECURITY, 0xa7);
	snd_soc_component_write(component, 0xde, 0x13);
	snd_soc_component_write(component, WM8350_SECURITY, 0);

	/* read OUT1 & OUT2 volumes */
	out1 = &priv->out1;
@@ -1552,10 +1552,10 @@ static int wm8350_codec_probe(struct snd_soc_codec *codec)
	return 0;
}

static int  wm8350_codec_remove(struct snd_soc_codec *codec)
static void wm8350_component_remove(struct snd_soc_component *component)
{
	struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec);
	struct wm8350 *wm8350 = dev_get_platdata(codec->dev);
	struct wm8350_data *priv = snd_soc_component_get_drvdata(component);
	struct wm8350 *wm8350 = dev_get_platdata(component->dev);

	wm8350_clear_bits(wm8350, WM8350_JACK_DETECT,
			  WM8350_JDL_ENA | WM8350_JDR_ENA);
@@ -1578,44 +1578,37 @@ static int wm8350_codec_remove(struct snd_soc_codec *codec)
	flush_delayed_work(&priv->pga_work);

	wm8350_clear_bits(wm8350, WM8350_POWER_MGMT_5, WM8350_CODEC_ENA);

	return 0;
}

static const struct snd_soc_codec_driver soc_codec_dev_wm8350 = {
	.probe =	wm8350_codec_probe,
	.remove =	wm8350_codec_remove,
static const struct snd_soc_component_driver soc_component_dev_wm8350 = {
	.probe			= wm8350_component_probe,
	.remove			= wm8350_component_remove,
	.set_bias_level		= wm8350_set_bias_level,
	.suspend_bias_off = true,

	.component_driver = {
	.controls		= wm8350_snd_controls,
	.num_controls		= ARRAY_SIZE(wm8350_snd_controls),
	.dapm_widgets		= wm8350_dapm_widgets,
	.num_dapm_widgets	= ARRAY_SIZE(wm8350_dapm_widgets),
	.dapm_routes		= wm8350_dapm_routes,
	.num_dapm_routes	= ARRAY_SIZE(wm8350_dapm_routes),
	},
	.suspend_bias_off	= 1,
	.idle_bias_on		= 1,
	.use_pmdown_time	= 1,
	.endianness		= 1,
	.non_legacy_dai_naming	= 1,
};

static int wm8350_probe(struct platform_device *pdev)
{
	return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8350,
	return devm_snd_soc_register_component(&pdev->dev,
			&soc_component_dev_wm8350,
			&wm8350_dai, 1);
}

static int wm8350_remove(struct platform_device *pdev)
{
	snd_soc_unregister_codec(&pdev->dev);
	return 0;
}

static struct platform_driver wm8350_codec_driver = {
	.driver = {
		   .name = "wm8350-codec",
		   },
	.probe = wm8350_probe,
	.remove = wm8350_remove,
};

module_platform_driver(wm8350_codec_driver);
+2 −2

File changed.

Preview size limit exceeded, changes collapsed.

Loading