All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
To: Mark Brown <broonie@kernel.org>
Cc: Linux-ALSA <alsa-devel@alsa-project.org>, Lars-Peter <lars@metafoo.de>
Subject: [SAMPLE 6/6] ASoC: convert codec to compoent on sn95031
Date: Fri, 1 Sep 2017 06:37:13 +0000	[thread overview]
Message-ID: <87inh3j5hq.wl%kuninori.morimoto.gx@renesas.com> (raw)
In-Reply-To: <87r2vrj5lz.wl%kuninori.morimoto.gx@renesas.com>

Now we can replace Codec to Component. Let's do it.
Intel mfld_machine is using sn95031, but there is no
compile method...

Note:
	xxx_codec_xxx()		->	xxx_component_xxx()
	.idle_bias_off = 1	->	.idle_bias_on = 0
	.ignore_pmdown_time = 0	->	.pmdown_time = 1
	-			->	.endianness = 1
	-			->	.non_legacy_dai_naming = 1

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 sound/soc/codecs/sn95031.c            | 219 ++++++++++++++++------------------
 sound/soc/codecs/sn95031.h            |   2 +-
 sound/soc/intel/boards/mfld_machine.c |  12 +-
 3 files changed, 112 insertions(+), 121 deletions(-)

diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c
index 887923e..1a03088 100644
--- a/sound/soc/codecs/sn95031.c
+++ b/sound/soc/codecs/sn95031.c
@@ -46,16 +46,16 @@
 /* adc helper functions */
 
 /* enables mic bias voltage */
-static void sn95031_enable_mic_bias(struct snd_soc_codec *codec)
+static void sn95031_enable_mic_bias(struct snd_soc_component *component)
 {
-	snd_soc_write(codec, SN95031_VAUD, BIT(2)|BIT(1)|BIT(0));
-	snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(2), BIT(2));
+	snd_soc_component_write(component, SN95031_VAUD, BIT(2)|BIT(1)|BIT(0));
+	snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(2), BIT(2));
 }
 
 /* Enable/Disable the ADC depending on the argument */
-static void configure_adc(struct snd_soc_codec *sn95031_codec, int val)
+static void configure_adc(struct snd_soc_component *sn95031, int val)
 {
-	int value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1);
+	int value = snd_soc_component_read32(sn95031, SN95031_ADC1CNTL1);
 
 	if (val) {
 		/* Enable and start the ADC */
@@ -65,7 +65,7 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val)
 		/* Just stop the ADC */
 		value &= (~SN95031_ADC_START);
 	}
-	snd_soc_write(sn95031_codec, SN95031_ADC1CNTL1, value);
+	snd_soc_component_write(sn95031, SN95031_ADC1CNTL1, value);
 }
 
 /*
@@ -78,19 +78,19 @@ static void configure_adc(struct snd_soc_codec *sn95031_codec, int val)
  * Context: can sleep
  *
  */
-static int find_free_channel(struct snd_soc_codec *sn95031_codec)
+static int find_free_channel(struct snd_soc_component *sn95031)
 {
 	int i, value;
 
 	/* check whether ADC is enabled */
-	value = snd_soc_read(sn95031_codec, SN95031_ADC1CNTL1);
+	value = snd_soc_component_read32(sn95031, SN95031_ADC1CNTL1);
 
 	if ((value & SN95031_ADC_ENBL) == 0)
 		return 0;
 
 	/* ADC is already enabled; Looking for an empty channel */
 	for (i = 0; i <	SN95031_ADC_CHANLS_MAX; i++) {
-		value = snd_soc_read(sn95031_codec,
+		value = snd_soc_component_read32(sn95031,
 				SN95031_ADC_CHNL_START_ADDR + i);
 		if (value & SN95031_STOPBIT_MASK)
 			break;
@@ -99,14 +99,14 @@ static int find_free_channel(struct snd_soc_codec *sn95031_codec)
 }
 
 /* Initialize the ADC for reading micbias values. Can sleep. */
-static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec)
+static int sn95031_initialize_adc(struct snd_soc_component *sn95031)
 {
 	int base_addr, chnl_addr;
 	int value;
 	int channel_index;
 
 	/* Index of the first channel in which the stop bit is set */
-	channel_index = find_free_channel(sn95031_codec);
+	channel_index = find_free_channel(sn95031);
 	if (channel_index < 0) {
 		pr_err("No free ADC channels");
 		return channel_index;
@@ -116,9 +116,9 @@ static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec)
 
 	if (!(channel_index == 0 || channel_index ==  SN95031_ADC_LOOP_MAX)) {
 		/* Reset stop bit for channels other than 0 and 12 */
-		value = snd_soc_read(sn95031_codec, base_addr);
+		value = snd_soc_component_read32(sn95031, base_addr);
 		/* Set the stop bit to zero */
-		snd_soc_write(sn95031_codec, base_addr, value & 0xEF);
+		snd_soc_component_write(sn95031, base_addr, value & 0xEF);
 		/* Index of the first free channel */
 		base_addr++;
 		channel_index++;
@@ -126,35 +126,35 @@ static int sn95031_initialize_adc(struct snd_soc_codec *sn95031_codec)
 
 	/* Since this is the last channel, set the stop bit
 	   to 1 by ORing the DIE_SENSOR_CODE with 0x10 */
-	snd_soc_write(sn95031_codec, base_addr,
+	snd_soc_component_write(sn95031, base_addr,
 				SN95031_AUDIO_DETECT_CODE | 0x10);
 
 	chnl_addr = SN95031_ADC_DATA_START_ADDR + 2 * channel_index;
 	pr_debug("mid_initialize : %x", chnl_addr);
-	configure_adc(sn95031_codec, 1);
+	configure_adc(sn95031, 1);
 	return chnl_addr;
 }
 
 
 /* reads the ADC registers and gets the mic bias value in mV. */
-static unsigned int sn95031_get_mic_bias(struct snd_soc_codec *codec)
+static unsigned int sn95031_get_mic_bias(struct snd_soc_component *component)
 {
-	u16 adc_adr = sn95031_initialize_adc(codec);
+	u16 adc_adr = sn95031_initialize_adc(component);
 	u16 adc_val1, adc_val2;
 	unsigned int mic_bias;
 
-	sn95031_enable_mic_bias(codec);
+	sn95031_enable_mic_bias(component);
 
 	/* Enable the sound card for conversion before reading */
-	snd_soc_write(codec, SN95031_ADC1CNTL3, 0x05);
+	snd_soc_component_write(component, SN95031_ADC1CNTL3, 0x05);
 	/* Re-toggle the RRDATARD bit */
-	snd_soc_write(codec, SN95031_ADC1CNTL3, 0x04);
+	snd_soc_component_write(component, SN95031_ADC1CNTL3, 0x04);
 
 	/* Read the higher bits of data */
 	msleep(1000);
-	adc_val1 = snd_soc_read(codec, adc_adr);
+	adc_val1 = snd_soc_component_read32(component, adc_adr);
 	adc_adr++;
-	adc_val2 = snd_soc_read(codec, adc_adr);
+	adc_val2 = snd_soc_component_read32(component, adc_adr);
 
 	/* Adding lower two bits to the higher bits */
 	mic_bias = (adc_val1 << 2) + (adc_val2 & 3);
@@ -186,7 +186,7 @@ static int sn95031_write(void *ctx, unsigned int reg, unsigned int value)
 	.reg_write = sn95031_write,
 };
 
-static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
+static int sn95031_set_vaud_bias(struct snd_soc_component *component,
 		enum snd_soc_bias_level level)
 {
 	switch (level) {
@@ -194,30 +194,30 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
 		break;
 
 	case SND_SOC_BIAS_PREPARE:
-		if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_STANDBY) {
+		if (snd_soc_component_get_bias_level(component) == SND_SOC_BIAS_STANDBY) {
 			pr_debug("vaud_bias powering up pll\n");
 			/* power up the pll */
-			snd_soc_write(codec, SN95031_AUDPLLCTRL, BIT(5));
+			snd_soc_component_write(component, SN95031_AUDPLLCTRL, BIT(5));
 			/* enable pcm 2 */
-			snd_soc_update_bits(codec, SN95031_PCM2C2,
+			snd_soc_component_update_bits(component, SN95031_PCM2C2,
 					BIT(0), BIT(0));
 		}
 		break;
 
 	case SND_SOC_BIAS_STANDBY:
-		switch (snd_soc_codec_get_bias_level(codec)) {
+		switch (snd_soc_component_get_bias_level(component)) {
 		case SND_SOC_BIAS_OFF:
 			pr_debug("vaud_bias power up rail\n");
 			/* power up the rail */
-			snd_soc_write(codec, SN95031_VAUD,
+			snd_soc_component_write(component, SN95031_VAUD,
 					BIT(2)|BIT(1)|BIT(0));
 			msleep(1);
 			break;
 		case SND_SOC_BIAS_PREPARE:
 			/* turn off pcm */
 			pr_debug("vaud_bias power dn pcm\n");
-			snd_soc_update_bits(codec, SN95031_PCM2C2, BIT(0), 0);
-			snd_soc_write(codec, SN95031_AUDPLLCTRL, 0);
+			snd_soc_component_update_bits(component, SN95031_PCM2C2, BIT(0), 0);
+			snd_soc_component_write(component, SN95031_AUDPLLCTRL, 0);
 			break;
 		default:
 			break;
@@ -227,7 +227,7 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
 
 	case SND_SOC_BIAS_OFF:
 		pr_debug("vaud_bias _OFF doing rail shutdown\n");
-		snd_soc_write(codec, SN95031_VAUD, BIT(3));
+		snd_soc_component_write(component, SN95031_VAUD, BIT(3));
 		break;
 	}
 
@@ -237,18 +237,18 @@ static int sn95031_set_vaud_bias(struct snd_soc_codec *codec,
 static int sn95031_vhs_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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		pr_debug("VHS SND_SOC_DAPM_EVENT_ON doing rail startup now\n");
 		/* power up the rail */
-		snd_soc_write(codec, SN95031_VHSP, 0x3D);
-		snd_soc_write(codec, SN95031_VHSN, 0x3F);
+		snd_soc_component_write(component, SN95031_VHSP, 0x3D);
+		snd_soc_component_write(component, SN95031_VHSN, 0x3F);
 		msleep(1);
 	} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
 		pr_debug("VHS SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n");
-		snd_soc_write(codec, SN95031_VHSP, 0xC4);
-		snd_soc_write(codec, SN95031_VHSN, 0x04);
+		snd_soc_component_write(component, SN95031_VHSP, 0xC4);
+		snd_soc_component_write(component, SN95031_VHSN, 0x04);
 	}
 	return 0;
 }
@@ -256,16 +256,16 @@ static int sn95031_vhs_event(struct snd_soc_dapm_widget *w,
 static int sn95031_vihf_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 snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
 		pr_debug("VIHF SND_SOC_DAPM_EVENT_ON doing rail startup now\n");
 		/* power up the rail */
-		snd_soc_write(codec, SN95031_VIHF, 0x27);
+		snd_soc_component_write(component, SN95031_VIHF, 0x27);
 		msleep(1);
 	} else if (SND_SOC_DAPM_EVENT_OFF(event)) {
 		pr_debug("VIHF SND_SOC_DAPM_EVENT_OFF doing rail shutdown\n");
-		snd_soc_write(codec, SN95031_VIHF, 0x24);
+		snd_soc_component_write(component, SN95031_VIHF, 0x24);
 	}
 	return 0;
 }
@@ -273,7 +273,7 @@ static int sn95031_vihf_event(struct snd_soc_dapm_widget *w,
 static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w,
 			struct snd_kcontrol *k, int event)
 {
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 	unsigned int ldo = 0, clk_dir = 0, data_dir = 0;
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
@@ -282,16 +282,16 @@ static int sn95031_dmic12_event(struct snd_soc_dapm_widget *w,
 		data_dir = BIT(7);
 	}
 	/* program DMIC LDO, clock and set clock */
-	snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
-	snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(0), clk_dir);
-	snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(7), data_dir);
+	snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
+	snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(0), clk_dir);
+	snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(7), data_dir);
 	return 0;
 }
 
 static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w,
 			struct snd_kcontrol *k, int event)
 {
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 	unsigned int ldo = 0, clk_dir = 0, data_dir = 0;
 
 	if (SND_SOC_DAPM_EVENT_ON(event)) {
@@ -300,23 +300,23 @@ static int sn95031_dmic34_event(struct snd_soc_dapm_widget *w,
 		data_dir = BIT(1);
 	}
 	/* program DMIC LDO, clock and set clock */
-	snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
-	snd_soc_update_bits(codec, SN95031_DMICBUF0123, BIT(2), clk_dir);
-	snd_soc_update_bits(codec, SN95031_DMICBUF45, BIT(1), data_dir);
+	snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(5)|BIT(4), ldo);
+	snd_soc_component_update_bits(component, SN95031_DMICBUF0123, BIT(2), clk_dir);
+	snd_soc_component_update_bits(component, SN95031_DMICBUF45, BIT(1), data_dir);
 	return 0;
 }
 
 static int sn95031_dmic56_event(struct snd_soc_dapm_widget *w,
 			struct snd_kcontrol *k, int event)
 {
-	struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm);
+	struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
 	unsigned int ldo = 0;
 
 	if (SND_SOC_DAPM_EVENT_ON(event))
 		ldo = BIT(7)|BIT(6);
 
 	/* program DMIC LDO */
-	snd_soc_update_bits(codec, SN95031_MICBIAS, BIT(7)|BIT(6), ldo);
+	snd_soc_component_update_bits(component, SN95031_MICBIAS, BIT(7)|BIT(6), ldo);
 	return 0;
 }
 
@@ -651,18 +651,18 @@ static SOC_ENUM_SINGLE_DECL(sn95031_dmic56_cfg_enum,
 /* speaker and headset mutes, for audio pops and clicks */
 static int sn95031_pcm_hs_mute(struct snd_soc_dai *dai, int mute)
 {
-	snd_soc_update_bits(dai->codec,
+	snd_soc_component_update_bits(dai->component,
 			SN95031_HSLVOLCTRL, BIT(7), (!mute << 7));
-	snd_soc_update_bits(dai->codec,
+	snd_soc_component_update_bits(dai->component,
 			SN95031_HSRVOLCTRL, BIT(7), (!mute << 7));
 	return 0;
 }
 
 static int sn95031_pcm_spkr_mute(struct snd_soc_dai *dai, int mute)
 {
-	snd_soc_update_bits(dai->codec,
+	snd_soc_component_update_bits(dai->component,
 			SN95031_IHFLVOLCTRL, BIT(7), (!mute << 7));
-	snd_soc_update_bits(dai->codec,
+	snd_soc_component_update_bits(dai->component,
 			SN95031_IHFRVOLCTRL, BIT(7), (!mute << 7));
 	return 0;
 }
@@ -683,7 +683,7 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream,
 	default:
 		return -EINVAL;
 	}
-	snd_soc_update_bits(dai->codec, SN95031_PCM2C2,
+	snd_soc_component_update_bits(dai->component, SN95031_PCM2C2,
 			BIT(4)|BIT(5), format);
 
 	switch (params_rate(params)) {
@@ -701,7 +701,7 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream,
 		pr_err("ERR rate %d\n", params_rate(params));
 		return -EINVAL;
 	}
-	snd_soc_update_bits(dai->codec, SN95031_PCM1C1, BIT(7), rate);
+	snd_soc_component_update_bits(dai->component, SN95031_PCM1C1, BIT(7), rate);
 
 	return 0;
 }
@@ -776,31 +776,31 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream,
 },
 };
 
-static inline void sn95031_disable_jack_btn(struct snd_soc_codec *codec)
+static inline void sn95031_disable_jack_btn(struct snd_soc_component *component)
 {
-	snd_soc_write(codec, SN95031_BTNCTRL2, 0x00);
+	snd_soc_component_write(component, SN95031_BTNCTRL2, 0x00);
 }
 
-static inline void sn95031_enable_jack_btn(struct snd_soc_codec *codec)
+static inline void sn95031_enable_jack_btn(struct snd_soc_component *component)
 {
-	snd_soc_write(codec, SN95031_BTNCTRL1, 0x77);
-	snd_soc_write(codec, SN95031_BTNCTRL2, 0x01);
+	snd_soc_component_write(component, SN95031_BTNCTRL1, 0x77);
+	snd_soc_component_write(component, SN95031_BTNCTRL2, 0x01);
 }
 
-static int sn95031_get_headset_state(struct snd_soc_codec *codec,
+static int sn95031_get_headset_state(struct snd_soc_component *component,
 	struct snd_soc_jack *mfld_jack)
 {
-	int micbias = sn95031_get_mic_bias(codec);
+	int micbias = sn95031_get_mic_bias(component);
 
 	int jack_type = snd_soc_jack_get_type(mfld_jack, micbias);
 
 	pr_debug("jack type detected = %d\n", jack_type);
 	if (jack_type == SND_JACK_HEADSET)
-		sn95031_enable_jack_btn(codec);
+		sn95031_enable_jack_btn(component);
 	return jack_type;
 }
 
-void sn95031_jack_detection(struct snd_soc_codec *codec,
+void sn95031_jack_detection(struct snd_soc_component *component,
 	struct mfld_jack_data *jack_data)
 {
 	unsigned int status;
@@ -815,11 +815,11 @@ void sn95031_jack_detection(struct snd_soc_codec *codec,
 		status = SND_JACK_HEADSET | SND_JACK_BTN_1;
 	} else if (jack_data->intr_id & 0x4) {
 		pr_debug("headset or headphones inserted\n");
-		status = sn95031_get_headset_state(codec, jack_data->mfld_jack);
+		status = sn95031_get_headset_state(component, jack_data->mfld_jack);
 	} else if (jack_data->intr_id & 0x8) {
 		pr_debug("headset or headphones removed\n");
 		status = 0;
-		sn95031_disable_jack_btn(codec);
+		sn95031_disable_jack_btn(component);
 	} else {
 		pr_err("unidentified interrupt\n");
 		return;
@@ -833,98 +833,89 @@ void sn95031_jack_detection(struct snd_soc_codec *codec,
 }
 EXPORT_SYMBOL_GPL(sn95031_jack_detection);
 
-/* codec registration */
-static int sn95031_codec_probe(struct snd_soc_codec *codec)
+/* component registration */
+static int sn95031_component_probe(struct snd_soc_component *component)
 {
-	pr_debug("codec_probe called\n");
+	pr_debug("component_probe called\n");
 
 	/* PCM interface config
 	 * This sets the pcm rx slot conguration to max 6 slots
 	 * for max 4 dais (2 stereo and 2 mono)
 	 */
-	snd_soc_write(codec, SN95031_PCM2RXSLOT01, 0x10);
-	snd_soc_write(codec, SN95031_PCM2RXSLOT23, 0x32);
-	snd_soc_write(codec, SN95031_PCM2RXSLOT45, 0x54);
-	snd_soc_write(codec, SN95031_PCM2TXSLOT01, 0x10);
-	snd_soc_write(codec, SN95031_PCM2TXSLOT23, 0x32);
+	snd_soc_component_write(component, SN95031_PCM2RXSLOT01, 0x10);
+	snd_soc_component_write(component, SN95031_PCM2RXSLOT23, 0x32);
+	snd_soc_component_write(component, SN95031_PCM2RXSLOT45, 0x54);
+	snd_soc_component_write(component, SN95031_PCM2TXSLOT01, 0x10);
+	snd_soc_component_write(component, SN95031_PCM2TXSLOT23, 0x32);
 	/* pcm port setting
 	 * This sets the pcm port to slave and clock at 19.2Mhz which
 	 * can support 6slots, sampling rate set per stream in hw-params
 	 */
-	snd_soc_write(codec, SN95031_PCM1C1, 0x00);
-	snd_soc_write(codec, SN95031_PCM2C1, 0x01);
-	snd_soc_write(codec, SN95031_PCM2C2, 0x0A);
-	snd_soc_write(codec, SN95031_HSMIXER, BIT(0)|BIT(4));
+	snd_soc_component_write(component, SN95031_PCM1C1, 0x00);
+	snd_soc_component_write(component, SN95031_PCM2C1, 0x01);
+	snd_soc_component_write(component, SN95031_PCM2C2, 0x0A);
+	snd_soc_component_write(component, SN95031_HSMIXER, BIT(0)|BIT(4));
 	/* vendor vibra workround, the vibras are muted by
 	 * custom register so unmute them
 	 */
-	snd_soc_write(codec, SN95031_SSR5, 0x80);
-	snd_soc_write(codec, SN95031_SSR6, 0x80);
-	snd_soc_write(codec, SN95031_VIB1C5, 0x00);
-	snd_soc_write(codec, SN95031_VIB2C5, 0x00);
+	snd_soc_component_write(component, SN95031_SSR5, 0x80);
+	snd_soc_component_write(component, SN95031_SSR6, 0x80);
+	snd_soc_component_write(component, SN95031_VIB1C5, 0x00);
+	snd_soc_component_write(component, SN95031_VIB2C5, 0x00);
 	/* configure vibras for pcm port */
-	snd_soc_write(codec, SN95031_VIB1C3, 0x00);
-	snd_soc_write(codec, SN95031_VIB2C3, 0x00);
+	snd_soc_component_write(component, SN95031_VIB1C3, 0x00);
+	snd_soc_component_write(component, SN95031_VIB2C3, 0x00);
 
 	/* soft mute ramp time */
-	snd_soc_write(codec, SN95031_SOFTMUTE, 0x3);
+	snd_soc_component_write(component, SN95031_SOFTMUTE, 0x3);
 	/* fix the initial volume at 1dB,
 	 * default in +9dB,
 	 * 1dB give optimal swing on DAC, amps
 	 */
-	snd_soc_write(codec, SN95031_HSLVOLCTRL, 0x08);
-	snd_soc_write(codec, SN95031_HSRVOLCTRL, 0x08);
-	snd_soc_write(codec, SN95031_IHFLVOLCTRL, 0x08);
-	snd_soc_write(codec, SN95031_IHFRVOLCTRL, 0x08);
+	snd_soc_component_write(component, SN95031_HSLVOLCTRL, 0x08);
+	snd_soc_component_write(component, SN95031_HSRVOLCTRL, 0x08);
+	snd_soc_component_write(component, SN95031_IHFLVOLCTRL, 0x08);
+	snd_soc_component_write(component, SN95031_IHFRVOLCTRL, 0x08);
 	/* dac mode and lineout workaround */
-	snd_soc_write(codec, SN95031_SSR2, 0x10);
-	snd_soc_write(codec, SN95031_SSR3, 0x40);
+	snd_soc_component_write(component, SN95031_SSR2, 0x10);
+	snd_soc_component_write(component, SN95031_SSR3, 0x40);
 
 	return 0;
 }
 
-static const struct snd_soc_codec_driver sn95031_codec = {
-	.probe		= sn95031_codec_probe,
-	.set_bias_level	= sn95031_set_vaud_bias,
-	.idle_bias_off	= true,
-
-	.component_driver = {
-		.controls		= sn95031_snd_controls,
-		.num_controls		= ARRAY_SIZE(sn95031_snd_controls),
-		.dapm_widgets		= sn95031_dapm_widgets,
-		.num_dapm_widgets	= ARRAY_SIZE(sn95031_dapm_widgets),
-		.dapm_routes		= sn95031_audio_map,
-		.num_dapm_routes	= ARRAY_SIZE(sn95031_audio_map),
-	},
+static const struct snd_soc_component_driver sn95031_component = {
+	.probe			= sn95031_component_probe,
+	.set_bias_level		= sn95031_set_vaud_bias,
+	.controls		= sn95031_snd_controls,
+	.num_controls		= ARRAY_SIZE(sn95031_snd_controls),
+	.dapm_widgets		= sn95031_dapm_widgets,
+	.num_dapm_widgets	= ARRAY_SIZE(sn95031_dapm_widgets),
+	.dapm_routes		= sn95031_audio_map,
+	.num_dapm_routes	= ARRAY_SIZE(sn95031_audio_map),
+	.pmdown_time		= 1,
+	.endianness		= 1,
+	.non_legacy_dai_naming	= 1,
 };
 
 static int sn95031_device_probe(struct platform_device *pdev)
 {
 	struct regmap *regmap;
 
-	pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev));
+	pr_debug("component device probe called for %s\n", dev_name(&pdev->dev));
 
 	regmap = devm_regmap_init(&pdev->dev, NULL, NULL, &sn95031_regmap);
 	if (IS_ERR(regmap))
 		return PTR_ERR(regmap);
 
-	return snd_soc_register_codec(&pdev->dev, &sn95031_codec,
+	return devm_snd_soc_register_component(&pdev->dev, &sn95031_component,
 			sn95031_dais, ARRAY_SIZE(sn95031_dais));
 }
 
-static int sn95031_device_remove(struct platform_device *pdev)
-{
-	pr_debug("codec device remove called\n");
-	snd_soc_unregister_codec(&pdev->dev);
-	return 0;
-}
-
 static struct platform_driver sn95031_codec_driver = {
 	.driver		= {
 		.name		= "sn95031",
 	},
 	.probe		= sn95031_device_probe,
-	.remove		= sn95031_device_remove,
 };
 
 module_platform_driver(sn95031_codec_driver);
diff --git a/sound/soc/codecs/sn95031.h b/sound/soc/codecs/sn95031.h
index 7651fe4..1e9fa62 100644
--- a/sound/soc/codecs/sn95031.h
+++ b/sound/soc/codecs/sn95031.h
@@ -127,7 +127,7 @@ struct mfld_jack_data {
 	struct snd_soc_jack *mfld_jack;
 };
 
-extern void sn95031_jack_detection(struct snd_soc_codec *codec,
+extern void sn95031_jack_detection(struct snd_soc_component *component,
 	struct mfld_jack_data *jack_data);
 
 #endif
diff --git a/sound/soc/intel/boards/mfld_machine.c b/sound/soc/intel/boards/mfld_machine.c
index 6f44acf..74f86d9 100644
--- a/sound/soc/intel/boards/mfld_machine.c
+++ b/sound/soc/intel/boards/mfld_machine.c
@@ -53,7 +53,7 @@ enum soc_mic_bias_zones {
 
 static unsigned int	hs_switch;
 static unsigned int	lo_dac;
-static struct snd_soc_codec *mfld_codec;
+static struct snd_soc_component *mfld_codec;
 
 struct mfld_mc_private {
 	void __iomem *int_base;
@@ -173,28 +173,28 @@ static int lo_set_switch(struct snd_kcontrol *kcontrol,
 		pr_debug("set vibra path\n");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "VIB1OUT");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "VIB2OUT");
-		snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0);
+		snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0);
 		break;
 
 	case 1:
 		pr_debug("set hs  path\n");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "Headphones");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "EPOUT");
-		snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22);
+		snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x22);
 		break;
 
 	case 2:
 		pr_debug("set spkr path\n");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTL");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "IHFOUTR");
-		snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44);
+		snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x44);
 		break;
 
 	case 3:
 		pr_debug("set null path\n");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTL");
 		snd_soc_dapm_disable_pin_unlocked(dapm, "LINEOUTR");
-		snd_soc_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66);
+		snd_soc_component_update_bits(mfld_codec, SN95031_LOCTL, 0x66, 0x66);
 		break;
 	}
 
@@ -271,7 +271,7 @@ static int mfld_init(struct snd_soc_pcm_runtime *runtime)
 		return ret_val;
 	}
 
-	mfld_codec = runtime->codec;
+	mfld_codec = runtime->codec_dai->component;
 
 	/* we want to check if anything is inserted at boot,
 	 * so send a fake event to codec and it will read adc
-- 
1.9.1

  parent reply	other threads:[~2017-09-01  6:37 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01  5:25 Prepare to covert Codec/Platform into Component Kuninori Morimoto
2017-09-01  5:28 ` [PATCH 00/13] ASoC add new necessary features for Conversion Kuninori Morimoto
2017-09-01  5:31   ` [PATCH 01/13] ASoC: add Component level pcm_new/pcm_free v2 Kuninori Morimoto
2017-09-27 17:13     ` Applied "ASoC: add Component level pcm_new/pcm_free v2" to the asoc tree Mark Brown
2017-09-01  5:31   ` [PATCH 02/13] ASoC: add Component level set_bias_level Kuninori Morimoto
2017-09-27 17:13     ` Applied "ASoC: add Component level set_bias_level" to the asoc tree Mark Brown
2017-09-01  5:32   ` [PATCH 03/13] ASoC: soc-core: add component lookup functions Kuninori Morimoto
2017-09-01  5:32   ` [PATCH 04/13] ASoC: soc-core: add snd_soc_add_component() Kuninori Morimoto
2017-10-10  9:19     ` Applied "ASoC: soc-core: add snd_soc_add_component()" to the asoc tree Mark Brown
2017-09-01  5:33   ` [PATCH 05/13] ASoC: snd_soc_component_driver has snd_pcm_ops Kuninori Morimoto
2017-09-01  5:33   ` [PATCH 06/13] ASoC: snd_soc_component_driver has snd_compr_ops Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has snd_compr_ops" to the asoc tree Mark Brown
2017-09-01  5:33   ` [PATCH 07/13] ASoC: snd_soc_component_driver has pmdown_time Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has pmdown_time" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 08/13] ASoC: snd_soc_component_driver has endianness Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has endianness" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 09/13] ASoC: snd_soc_component_driver has non_legacy_dai_naming Kuninori Morimoto
2017-10-23  9:43     ` Applied "ASoC: snd_soc_component_driver has non_legacy_dai_naming" to the asoc tree Mark Brown
2017-09-01  5:34   ` [PATCH 10/13] ASoC: add snd_soc_component_read32 Kuninori Morimoto
2017-09-01  5:35   ` [PATCH 11/13] ASoC: add snd_soc_component_xxx_bias_level() Kuninori Morimoto
2017-09-01  5:35   ` [PATCH 12/13] ASoC: add snd_soc_component_cache_sync() Kuninori Morimoto
2017-11-08 21:32     ` Applied "ASoC: add snd_soc_component_cache_sync()" to the asoc tree Mark Brown
2017-09-01  5:36   ` [PATCH 13/13] ASoC: add snd_soc_dapm_kcontrol_component() Kuninori Morimoto
2017-11-08 21:32     ` Applied "ASoC: add snd_soc_dapm_kcontrol_component()" to the asoc tree Mark Brown
2017-09-01  5:42 ` [PATCH 0/6] ASoC don't use codec hw_write/read Kuninori Morimoto
2017-09-01  5:40   ` [PATCH -/-] ASoC: remove codec hw_write/control_data Kuninori Morimoto
2018-05-09  9:45     ` Applied "ASoC: remove codec hw_write/control_data" to the asoc tree Mark Brown
2017-09-01  5:44   ` [PATCH 1/6] ASoC: don't use codec hw_write on uda1380 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on uda1380" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 2/6] ASoC: don't use codec hw_write on tlv320dac33 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on tlv320dac33" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 3/6] ASoC: don't use codec hw_write on cx20442/omap-ams-delta Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on cx20442/omap-ams-delta" to the asoc tree Mark Brown
2017-09-01  5:45   ` [PATCH 4/6] ASoC: don't use codec hw_write on twl6040 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on twl6040" to the asoc tree Mark Brown
2017-09-01  5:46   ` [PATCH 5/6] ASoC: don't use codec hw_write on max98926 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on max98926" to the asoc tree Mark Brown
2017-09-01  5:46   ` [PATCH 6/6] ASoC: don't use codec hw_write on max98927 Kuninori Morimoto
2017-11-27 18:52     ` Applied "ASoC: don't use codec hw_write on max98927" to the asoc tree Mark Brown
2017-09-01  6:05 ` [PATCH 00/19] ASoC: cleanup Codec reg_cache Kuninori Morimoto
2017-09-01  6:06   ` [PATCH 01/19] ASoC: use internal reg_cache on uda1380 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: use internal reg_cache on uda1380" to the asoc tree Mark Brown
2017-09-01  6:06   ` [PATCH 02/19] ASoC: use internal reg_cache on tlv320dac33 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: use internal reg_cache on tlv320dac33" to the asoc tree Mark Brown
2017-09-01  6:06   ` [PATCH 03/19] ASoC: cx20442: don't use reg_cache Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: cx20442: don't use reg_cache" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 04/19] ASoC: don't use snd_soc_write/read on twl6040 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: don't use snd_soc_write/read on twl6040" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 05/19] ASoC: don't use snd_soc_write/read on twl4030 Kuninori Morimoto
2017-11-27 18:51     ` Applied "ASoC: don't use snd_soc_write/read on twl4030" to the asoc tree Mark Brown
2017-09-01  6:07   ` [PATCH 06/19] ASoC: use snd_soc_component_init_regmap() on wm8998 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8998" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 07/19] ASoC: use snd_soc_component_init_regmap() on wm8997 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8997" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 08/19] ASoC: use snd_soc_component_init_regmap() on wm8994 Kuninori Morimoto
2017-12-04 18:50     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8994" to the asoc tree Mark Brown
2017-09-01  6:08   ` [PATCH 09/19] ASoC: use snd_soc_component_init_regmap() on wm8400 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8400" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 10/19] ASoC: use snd_soc_component_init_regmap() on wm8350 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm8350" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 11/19] ASoC: use snd_soc_component_init_regmap() on wm5110 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm5110" to the asoc tree Mark Brown
2017-09-01  6:09   ` [PATCH 12/19] ASoC: use snd_soc_component_init_regmap() on wm5102 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on wm5102" to the asoc tree Mark Brown
2017-09-01  6:10   ` [PATCH 13/19] ASoC: use snd_soc_component_init_regmap() on si476x Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on si476x" to the asoc tree Mark Brown
2017-09-01  6:10   ` [PATCH 14/19] ASoC: use snd_soc_component_init_regmap() on mc13783 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on mc13783" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 15/19] ASoC: use snd_soc_component_init_regmap() on cq93vc Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on cq93vc" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 16/19] ASoC: use snd_soc_component_init_regmap() on cs47l24 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on cs47l24" to the asoc tree Mark Brown
2017-09-01  6:11   ` [PATCH 17/19] ASoC: use snd_soc_component_init_regmap() on 88pm860x Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on 88pm860x" to the asoc tree Mark Brown
2017-09-01  6:12   ` [PATCH 18/19] ASoC: use snd_soc_component_init_regmap() on msm8916 Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on msm8916" to the asoc tree Mark Brown
2017-09-01  6:12   ` [PATCH 19/19] ASoC: use snd_soc_component_init_regmap() on atmel-classd Kuninori Morimoto
2017-12-04 18:49     ` Applied "ASoC: use snd_soc_component_init_regmap() on atmel-classd" to the asoc tree Mark Brown
2017-09-01  6:13   ` [PATCH --/--] ASoC: remove codec reg_cache Kuninori Morimoto
2017-09-01  6:14   ` [PATCH --/--] ASoC: remove .get_regmap Kuninori Morimoto
2017-09-01  6:23 ` [SAMPLE 0/4] ASoC: don't use rtd->codec Kuninori Morimoto
2017-09-01  6:24   ` [SAMPLE 1/4] ASoC: don't use rtd->codec on soc_dev_attr_is_visible() Kuninori Morimoto
2017-12-05 12:47     ` Applied "ASoC: don't use rtd->codec on soc_dev_attr_is_visible()" to the asoc tree Mark Brown
2017-09-01  6:25   ` [SAMPLE 2/4] ASoC: don't use rtd->codec on snd_soc_new_compress() Kuninori Morimoto
2017-09-01  6:25   ` [SAMPLE 3/4] ASoC: don't use rtd->codec on fsl-asoc-card Kuninori Morimoto
2017-12-05 12:47     ` Applied "ASoC: don't use rtd->codec on fsl-asoc-card" to the asoc tree Mark Brown
2017-09-01  6:25   ` [SAMPLE 4/4] ASoC: don't use rtd->codec on intel/skylake Kuninori Morimoto
2017-12-05 12:46     ` Applied "ASoC: don't use rtd->codec on intel/skylake" to the asoc tree Mark Brown
2017-09-01  6:27 ` [SAMPLE 0/6] ASoC: replace platform to component Kuninori Morimoto
2017-09-01  6:28   ` [SAMPLE 1/6] ASoC: replace platform to component on soc-utils Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 2/6] ASoC: replace platform to component on soc-generic-dmaengine-pcm Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 3/6] ASoC: replace platform to component on intel/atom Kuninori Morimoto
2017-09-01  6:29   ` [SAMPLE 4/6] ASoC: replace platform to component on renesas/siu Kuninori Morimoto
2018-02-12 12:30     ` Applied "ASoC: sh: siu: replace platform to component" to the asoc tree Mark Brown
2017-09-01  6:30   ` [SAMPLE 5/6] ASoC: replace platform to component on atmel-xxx Kuninori Morimoto
2017-09-01  6:30   ` [SAMPLE 6/6] ASoC: replace platform to component on amd/acp Kuninori Morimoto
2017-09-01  6:31   ` [SAMPLE -/-] ASoC: remove platform related things Kuninori Morimoto
2017-09-01  6:34 ` [SAMPLE 0/6] ASoC: convert codec to compoent Kuninori Morimoto
2017-09-01  6:35   ` [SAMPLE 1/6] ASoC: convert codec to compoent on hdac_hdmi/nau8825/rt286/rt298/da7219 Kuninori Morimoto
2017-09-01  6:35   ` [PATCH 2/6] ASoC: convert codec to compoent on arizona/cs47l24/wm5102/wm5110/wm8997/wm8998/wm_adsp Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 3/6] ASoC: convert codec to compoent on mc13783 Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 4/6] ASoC: convert codec to compoent on sgtl5000 Kuninori Morimoto
2017-09-01  6:36   ` [SAMPLE 5/6] ASoC: convert codec to compoent on stac9766 Kuninori Morimoto
2017-09-01  6:37   ` Kuninori Morimoto [this message]
2017-09-01  6:37   ` [SAMPLE -/0] ASoC: remove Codec related code Kuninori Morimoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87inh3j5hq.wl%kuninori.morimoto.gx@renesas.com \
    --to=kuninori.morimoto.gx@renesas.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.