ASoC: Convert H1940 to table based init
Subsystems (3)
PATCH 1/5 ASoC: Convert H1940 to table based init
--- sound/soc/samsung/h1940_uda1380.c | 17 +++++------------ 1 files changed, 5 insertions(+), 12 deletions(-)
sound/soc/samsung/h1940_uda1380.c +5 -12
@@ -183,18 +183,6 @@ static int h1940_uda1380_init(struct snd_soc_pcm_runtime *rtd)struct snd_soc_dapm_context *dapm = &codec->dapm;int err; -/* Add h1940 specific widgets */ - err =snd_soc_dapm_new_controls (dapm, uda1380_dapm_widgets, -ARRAY_SIZE (uda1380_dapm_widgets)); -if (err) -return err; - -/* Set up h1940 specific audio path audio_mapnects */ - err =snd_soc_dapm_add_routes (dapm, audio_map, -ARRAY_SIZE (audio_map)); -if (err) -return err; -snd_soc_dapm_enable_pin (dapm,"Headphone Jack" );snd_soc_dapm_enable_pin (dapm,"Speaker" );snd_soc_dapm_enable_pin (dapm,"Mic Jack" );
@@ -229,6 +217,11 @@ static struct snd_soc_card h1940_asoc = { .name = "h1940", .dai_link = h1940_uda1380_dai, .num_links = ARRAY_SIZE(h1940_uda1380_dai), + + .dapm_widgets = uda1380_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), };static int __init h1940_init (void )
Signature · 1 line
1.7.6.3
PATCH 2/2 ASoC: Assign power_check when we allocate DAPM widgets
This ensures none of the rest of the code ever encounters a widget which does not have a power check function.
--- sound/soc/soc-dapm.c | 67 +++++++++++++++++++++++++++++--------------------- 1 files changed, 39 insertions(+), 28 deletions(-)
sound/soc/soc-dapm.c +39 -28
@@ -2138,48 +2138,21 @@ int snd_soc_dapm_new_widgets(struct snd_soc_dapm_context *dapm)case snd_soc_dapm_switch:case snd_soc_dapm_mixer:case snd_soc_dapm_mixer_named_ctl: - w->power_check = dapm_generic_check_power;dapm_new_mixer (w);break ;case snd_soc_dapm_mux:case snd_soc_dapm_virt_mux:case snd_soc_dapm_value_mux: - w->power_check = dapm_generic_check_power;dapm_new_mux (w);break ; -case snd_soc_dapm_adc: -case snd_soc_dapm_aif_out: - w->power_check = dapm_adc_check_power; -break ; -case snd_soc_dapm_dac: -case snd_soc_dapm_aif_in: - w->power_check = dapm_dac_check_power; -break ;case snd_soc_dapm_pga:case snd_soc_dapm_out_drv: - w->power_check = dapm_generic_check_power;dapm_new_pga (w);break ; -case snd_soc_dapm_input: -case snd_soc_dapm_output: -case snd_soc_dapm_micbias: -case snd_soc_dapm_spk: -case snd_soc_dapm_hp: -case snd_soc_dapm_mic: -case snd_soc_dapm_line: - w->power_check = dapm_generic_check_power; -break ; -case snd_soc_dapm_supply: - w->power_check = dapm_supply_check_power; -case snd_soc_dapm_vmid: -case snd_soc_dapm_pre: -case snd_soc_dapm_post: +default :break ; } -if (!w->power_check) - w->power_check = dapm_always_on_check_power; -/* Read the initial power state from the device */ if (w->reg >=0 ) { val =soc_widget_read (w, w->reg);
@@ -2668,6 +2641,44 @@ int snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,else snprintf (w->name, name_len,"%s" , widget->name); +switch (w->id) { +case snd_soc_dapm_switch: +case snd_soc_dapm_mixer: +case snd_soc_dapm_mixer_named_ctl: + w->power_check = dapm_generic_check_power; +break ; +case snd_soc_dapm_mux: +case snd_soc_dapm_virt_mux: +case snd_soc_dapm_value_mux: + w->power_check = dapm_generic_check_power; +break ; +case snd_soc_dapm_adc: +case snd_soc_dapm_aif_out: + w->power_check = dapm_adc_check_power; +break ; +case snd_soc_dapm_dac: +case snd_soc_dapm_aif_in: + w->power_check = dapm_dac_check_power; +break ; +case snd_soc_dapm_pga: +case snd_soc_dapm_out_drv: +case snd_soc_dapm_input: +case snd_soc_dapm_output: +case snd_soc_dapm_micbias: +case snd_soc_dapm_spk: +case snd_soc_dapm_hp: +case snd_soc_dapm_mic: +case snd_soc_dapm_line: + w->power_check = dapm_generic_check_power; +break ; +case snd_soc_dapm_supply: + w->power_check = dapm_supply_check_power; +break ; +default : + w->power_check = dapm_always_on_check_power; +break ; + } + dapm->n_widgets++; w->dapm = dapm; w->codec = dapm->codec;
Signature · 1 line
1.7.6.3
PATCH 2/5 ASoC: Convert Jive to table based init
In reply to Mark Brown--- sound/soc/samsung/jive_wm8750.c | 16 +++++----------- 1 files changed, 5 insertions(+), 11 deletions(-)
sound/soc/samsung/jive_wm8750.c +5 -11
@@ -111,17 +111,6 @@ static int jive_wm8750_init(struct snd_soc_pcm_runtime *rtd)snd_soc_dapm_nc_pin (dapm,"OUT3" );snd_soc_dapm_nc_pin (dapm,"MONO" ); -/* Add jive specific widgets */ - err =snd_soc_dapm_new_controls (dapm, wm8750_dapm_widgets, -ARRAY_SIZE (wm8750_dapm_widgets)); -if (err) { -printk (KERN_ERR "%s: failed to add widgets (%d)\n" , - __func__, err); -return err; - } - -snd_soc_dapm_add_routes (dapm, audio_map,ARRAY_SIZE (audio_map)); -return 0 ; }
@@ -141,6 +130,11 @@ static struct snd_soc_card snd_soc_machine_jive = { .name = "Jive", .dai_link = &jive_dai, .num_links = 1, + + .dapm_widgtets = wm8750_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8750_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), };static struct platform_device *jive_snd_device;
Signature · 1 line
1.7.6.3
Re: [PATCH 2/5] ASoC: Convert Jive to table based init
Quoted 3 lines · Mark Brown
Subject: [PATCH 2/5] ASoC: Convert Jive to table based init
Signed-off-by Mark Brown <[email protected]>
PATCH 3/5 ASoC: Convert RX1950 to table based init
In reply to Mark Brown--- sound/soc/samsung/rx1950_uda1380.c | 31 +++++++++++-------------------- 1 files changed, 11 insertions(+), 20 deletions(-)
sound/soc/samsung/rx1950_uda1380.c +11 -20
@@ -91,12 +91,6 @@ static struct snd_soc_dai_link rx1950_uda1380_dai[] = { }, }; -static struct snd_soc_card rx1950_asoc = { - .name ="rx1950" , - .dai_link = rx1950_uda1380_dai, - .num_links =ARRAY_SIZE (rx1950_uda1380_dai), -}; -/* rx1950 machine dapm widgets */ static const struct snd_soc_dapm_widget uda1380_dapm_widgets[] = {SND_SOC_DAPM_HP ("Headphone Jack" ,NULL ),
@@ -118,6 +112,17 @@ static const struct snd_soc_dapm_route audio_map[] = { {"VINM", NULL, "Mic Jack"}, }; +static struct snd_soc_card rx1950_asoc = { + .name ="rx1950" , + .dai_link = rx1950_uda1380_dai, + .num_links =ARRAY_SIZE (rx1950_uda1380_dai), + + .dapm_widgets = uda1380_dapm_widgets, + .num_dapm_widgets =ARRAY_SIZE (uda1380_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes =ARRAY_SIZE (audio_map), +}; +static struct platform_device *s3c24xx_snd_device;static int rx1950_startup (struct snd_pcm_substream *substream)
@@ -221,20 +226,6 @@ static int rx1950_uda1380_init(struct snd_soc_pcm_runtime *rtd)struct snd_soc_dapm_context *dapm = &codec->dapm;int err; -/* Add rx1950 specific widgets */ - err =snd_soc_dapm_new_controls (dapm, uda1380_dapm_widgets, -ARRAY_SIZE (uda1380_dapm_widgets)); - -if (err) -return err; - -/* Set up rx1950 specific audio path audio_mapnects */ - err =snd_soc_dapm_add_routes (dapm, audio_map, -ARRAY_SIZE (audio_map)); - -if (err) -return err; -snd_soc_dapm_enable_pin (dapm,"Headphone Jack" );snd_soc_dapm_enable_pin (dapm,"Speaker" );snd_soc_dapm_enable_pin (dapm,"Mic Jack" );
Signature · 1 line
1.7.6.3
Re: [PATCH 3/5] ASoC: Convert RX1950 to table based init
Quoted 3 lines · Mark Brown
Subject: [PATCH 3/5] ASoC: Convert RX1950 to table based init
Signed-off-by Mark Brown <[email protected]>
PATCH 4/5 ASoC: Convert SmartQ to table based init
In reply to Mark Brown--- sound/soc/samsung/smartq_wm8987.c | 21 +++++++-------------- 1 files changed, 7 insertions(+), 14 deletions(-)
sound/soc/samsung/smartq_wm8987.c +7 -14
@@ -154,20 +154,6 @@ static int smartq_wm8987_init(struct snd_soc_pcm_runtime *rtd)struct snd_soc_dapm_context *dapm = &codec->dapm;int err =0 ; -/* Add SmartQ specific widgets */ -snd_soc_dapm_new_controls (dapm, wm8987_dapm_widgets, -ARRAY_SIZE (wm8987_dapm_widgets)); - -/* add SmartQ specific controls */ - err =snd_soc_add_controls (codec, wm8987_smartq_controls, -ARRAY_SIZE (wm8987_smartq_controls)); - -if (err <0 ) -return err; - -/* setup SmartQ specific audio path */ -snd_soc_dapm_add_routes (dapm, audio_map,ARRAY_SIZE (audio_map)); -/* set endpoints to not connected */ snd_soc_dapm_nc_pin (dapm,"LINPUT1" );snd_soc_dapm_nc_pin (dapm,"RINPUT1" );
@@ -214,6 +200,13 @@ static struct snd_soc_card snd_soc_smartq = { .name = "SmartQ", .dai_link = smartq_dai, .num_links = ARRAY_SIZE(smartq_dai), + + .dapm_widgets = wm8987_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(wm8987_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), + .controls = wm8987_smartq_controls, + .num_controls = ARRAY_SIZE(wm8987_smartq_controls), };static struct platform_device *smartq_snd_device;
Signature · 1 line
1.7.6.3
Re: [PATCH 4/5] ASoC: Convert SmartQ to table based init
Quoted 3 lines · Mark Brown
Subject: [PATCH 4/5] ASoC: Convert SmartQ to table based init
Signed-off-by Mark Brown <[email protected]>
PATCH 5/5 ASoC: Convert SMDK WM8580 to table based DAPM init
In reply to Mark Brown--- sound/soc/samsung/smdk_wm8580.c | 39 +++++++-------------------------------- 1 files changed, 7 insertions(+), 32 deletions(-)
sound/soc/samsung/smdk_wm8580.c +7 -32
@@ -120,30 +120,24 @@ static struct snd_soc_ops smdk_ops = { };/* SMDK Playback widgets */ -static const struct snd_soc_dapm_widget wm8580_dapm_widgets_pbk[] = { +static const struct snd_soc_dapm_widget smdk_wm8580_dapm_widgets[] = {SND_SOC_DAPM_HP ("Front" ,NULL ),SND_SOC_DAPM_HP ("Center+Sub" ,NULL ),SND_SOC_DAPM_HP ("Rear" ,NULL ), -}; -/* SMDK Capture widgets */ -static const struct snd_soc_dapm_widget wm8580_dapm_widgets_cpt[] = {SND_SOC_DAPM_MIC ("MicIn" ,NULL ),SND_SOC_DAPM_LINE ("LineIn" ,NULL ), };/* SMDK-PAIFTX connections */ -static const struct snd_soc_dapm_route audio_map_tx[] = { +static const struct snd_soc_dapm_route smdk_wm8580_audio_map[] = {/* MicIn feeds AINL */ {"AINL" ,NULL ,"MicIn" },/* LineIn feeds AINL/R */ {"AINL" ,NULL ,"LineIn" }, {"AINR" ,NULL ,"LineIn" }, -}; -/* SMDK-PAIFRX connections */ -static const struct snd_soc_dapm_route audio_map_rx[] = {/* Front Left/Right are fed VOUT1L/R */ {"Front" ,NULL ,"VOUT1L" }, {"Front" ,NULL ,"VOUT1R" },
@@ -162,13 +156,6 @@ static int smdk_wm8580_init_paiftx(struct snd_soc_pcm_runtime *rtd)struct snd_soc_codec *codec = rtd->codec;struct snd_soc_dapm_context *dapm = &codec->dapm; -/* Add smdk specific Capture widgets */ -snd_soc_dapm_new_controls (dapm, wm8580_dapm_widgets_cpt, -ARRAY_SIZE (wm8580_dapm_widgets_cpt)); - -/* Set up PAIFTX audio path */ -snd_soc_dapm_add_routes (dapm, audio_map_tx,ARRAY_SIZE (audio_map_tx)); -/* Enabling the microphone requires the fitting of a 0R * resistor to connect the line from the microphone jack. */
@@ -177,21 +164,6 @@ static int smdk_wm8580_init_paiftx(struct snd_soc_pcm_runtime *rtd)return 0 ; } -static int smdk_wm8580_init_paifrx (struct snd_soc_pcm_runtime *rtd) -{ -struct snd_soc_codec *codec = rtd->codec; -struct snd_soc_dapm_context *dapm = &codec->dapm; - -/* Add smdk specific Playback widgets */ -snd_soc_dapm_new_controls (dapm, wm8580_dapm_widgets_pbk, -ARRAY_SIZE (wm8580_dapm_widgets_pbk)); - -/* Set up PAIFRX audio path */ -snd_soc_dapm_add_routes (dapm, audio_map_rx,ARRAY_SIZE (audio_map_rx)); - -return 0 ; -} -enum {PRI_PLAYBACK =0 ,PRI_CAPTURE ,
@@ -206,7 +178,6 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-playback", .platform_name = "samsung-audio", .codec_name = "wm8580.0-001b", - .init = smdk_wm8580_init_paifrx, .ops = &smdk_ops, }, [PRI_CAPTURE] = { /* Primary Capture i/f */
@@ -226,7 +197,6 @@ static struct snd_soc_dai_link smdk_dai[] = { .codec_dai_name = "wm8580-hifi-playback", .platform_name = "samsung-audio", .codec_name = "wm8580.0-001b", - .init = smdk_wm8580_init_paifrx, .ops = &smdk_ops, }, };
@@ -235,6 +205,11 @@ static struct snd_soc_card smdk = { .name = "SMDK-I2S", .dai_link = smdk_dai, .num_links = 2, + + .dapm_widgets = smdk_wm8580_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(smdk_wm8580_dapm_widgets), + .dapm_routes = smdk_wm8580_audio_map, + .num_dapm_routes = ARRAY_SIZE(smdk_wm8580_audio_map), };static struct platform_device *smdk_snd_device;
Signature · 1 line
1.7.6.3
Re: [PATCH 5/5] ASoC: Convert SMDK WM8580 to table based DAPM init
Quoted 4 lines · Mark Brown
Subject: [alsa-devel] [PATCH 5/5] ASoC: Convert SMDK WM8580 to table based DAPM init
Signed-off-by Mark Brown <[email protected]>
On Sun, Oct 09, 2011 at 07:28PM, Mark Brown wrote:
Minor question:
Is there any reason for adding new line?
Quoted 15 lines
sound/soc/samsung/h1940_uda1380.c +5
-1+ + .dapm_widgets = uda1380_dapm_widgets, + .num_dapm_widgets = ARRAY_SIZE(uda1380_dapm_widgets), + .dapm_routes = audio_map, + .num_dapm_routes = ARRAY_SIZE(audio_map), };static int __init h1940_init (void ) --1.7.6.3
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 2 lines · Sangbeom Kim
Minor question:
Is there any reason for adding new line?
To break up the big table - when they start getting too large they can be hard to read. Most of these ones aren't too big but keeping a similar pattern makes working over the whole tree easier.