Unverified Commit 0140fc11 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: convert to snd_soc_dapm_xxx()

Merge series from Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>:

This patch-set convert many functions to snd_soc_dapm_xxx().
This is preparation to move struct snd_soc_dapm_context into soc-dapm.c.

For backport easy, this patch-set is added for each drivers.
parents 20772c4e 4422df67
Loading
Loading
Loading
Loading
+5 −9
Original line number Diff line number Diff line
@@ -34,8 +34,6 @@ static void arizona_haptics_work(struct work_struct *work)
						       struct arizona_haptics,
						       work);
	struct arizona *arizona = haptics->arizona;
	struct snd_soc_component *component =
		snd_soc_dapm_to_component(arizona->dapm);
	int ret;

	if (!haptics->arizona->dapm) {
@@ -65,7 +63,7 @@ static void arizona_haptics_work(struct work_struct *work)
			return;
		}

		ret = snd_soc_component_enable_pin(component, "HAPTICS");
		ret = snd_soc_dapm_enable_pin(arizona->dapm, "HAPTICS");
		if (ret != 0) {
			dev_err(arizona->dev, "Failed to start HAPTICS: %d\n",
				ret);
@@ -80,7 +78,7 @@ static void arizona_haptics_work(struct work_struct *work)
		}
	} else {
		/* This disable sequence will be a noop if already enabled */
		ret = snd_soc_component_disable_pin(component, "HAPTICS");
		ret = snd_soc_dapm_disable_pin(arizona->dapm, "HAPTICS");
		if (ret != 0) {
			dev_err(arizona->dev, "Failed to disable HAPTICS: %d\n",
				ret);
@@ -139,14 +137,12 @@ static int arizona_haptics_play(struct input_dev *input, void *data,
static void arizona_haptics_close(struct input_dev *input)
{
	struct arizona_haptics *haptics = input_get_drvdata(input);
	struct snd_soc_component *component;
	struct snd_soc_dapm_context *dapm = haptics->arizona->dapm;

	cancel_work_sync(&haptics->work);

	if (haptics->arizona->dapm) {
		component = snd_soc_dapm_to_component(haptics->arizona->dapm);
		snd_soc_component_disable_pin(component, "HAPTICS");
	}
	if (dapm)
		snd_soc_dapm_disable_pin(dapm, "HAPTICS");
}

static int arizona_haptics_probe(struct platform_device *pdev)
+2 −6
Original line number Diff line number Diff line
@@ -48,7 +48,6 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
	struct arizona_micsupp *micsupp =
		container_of(work, struct arizona_micsupp, check_cp_work);
	struct snd_soc_dapm_context *dapm = *micsupp->dapm;
	struct snd_soc_component *component;
	const struct regulator_desc *desc = micsupp->desc;
	unsigned int val;
	int ret;
@@ -61,14 +60,11 @@ static void arizona_micsupp_check_cp(struct work_struct *work)
	}

	if (dapm) {
		component = snd_soc_dapm_to_component(dapm);

		if ((val & (desc->enable_mask | desc->bypass_mask)) ==
		    desc->enable_mask)
			snd_soc_component_force_enable_pin(component,
							   "MICSUPP");
			snd_soc_dapm_force_enable_pin(dapm, "MICSUPP");
		else
			snd_soc_component_disable_pin(component, "MICSUPP");
			snd_soc_dapm_disable_pin(dapm, "MICSUPP");

		snd_soc_dapm_sync(dapm);
	}
+11 −5
Original line number Diff line number Diff line
@@ -807,6 +807,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
{
	int ret;
	struct snd_soc_component *comp;
	struct snd_soc_dapm_context *dapm;
	struct gbaudio_jack *jack = NULL;

	if (!gbcodec) {
@@ -815,6 +816,7 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
	}

	comp = gbcodec->component;
	dapm = snd_soc_component_to_dapm(comp);

	mutex_lock(&gbcodec->register_mutex);

@@ -833,18 +835,18 @@ int gbaudio_register_module(struct gbaudio_module_info *module)
	}

	if (module->dapm_widgets)
		snd_soc_dapm_new_controls(&comp->dapm, module->dapm_widgets,
		snd_soc_dapm_new_controls(dapm, module->dapm_widgets,
					  module->num_dapm_widgets);
	if (module->controls)
		snd_soc_add_component_controls(comp, module->controls,
					       module->num_controls);
	if (module->dapm_routes)
		snd_soc_dapm_add_routes(&comp->dapm, module->dapm_routes,
		snd_soc_dapm_add_routes(dapm, module->dapm_routes,
					module->num_dapm_routes);

	/* card already instantiated, create widgets here only */
	if (comp->card->instantiated) {
		gbaudio_dapm_link_component_dai_widgets(comp->card, &comp->dapm);
		gbaudio_dapm_link_component_dai_widgets(comp->card, dapm);
#ifdef CONFIG_SND_JACK
		/*
		 * register jack devices for this module
@@ -966,9 +968,11 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
#endif

	if (module->dapm_routes) {
		struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(comp);

		dev_dbg(comp->dev, "Removing %d routes\n",
			module->num_dapm_routes);
		snd_soc_dapm_del_routes(&comp->dapm, module->dapm_routes,
		snd_soc_dapm_del_routes(dapm, module->dapm_routes,
					module->num_dapm_routes);
	}
	if (module->controls) {
@@ -979,9 +983,11 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module)
						  module->num_controls);
	}
	if (module->dapm_widgets) {
		struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(comp);

		dev_dbg(comp->dev, "Removing %d widgets\n",
			module->num_dapm_widgets);
		gbaudio_dapm_free_controls(&comp->dapm, module->dapm_widgets,
		gbaudio_dapm_free_controls(dapm, module->dapm_widgets,
					   module->num_dapm_widgets);
	}

+5 −4
Original line number Diff line number Diff line
@@ -115,12 +115,13 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
{
	int i;
	struct snd_soc_dapm_widget *w, *tmp_w;
	struct snd_soc_card *card = snd_soc_dapm_to_card(dapm);

	mutex_lock(&dapm->card->dapm_mutex);
	mutex_lock(&card->dapm_mutex);
	for (i = 0; i < num; i++) {
		/* below logic can be optimized to identify widget pointer */
		w = NULL;
		list_for_each_entry(tmp_w, &dapm->card->widgets, list) {
		list_for_each_entry(tmp_w, &card->widgets, list) {
			if (tmp_w->dapm == dapm &&
			    !strcmp(tmp_w->name, widget->name)) {
				w = tmp_w;
@@ -128,7 +129,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
			}
		}
		if (!w) {
			dev_err(dapm->dev, "%s: widget not found\n",
			dev_err(card->dev, "%s: widget not found\n",
				widget->name);
			widget++;
			continue;
@@ -136,7 +137,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
		widget++;
		gbaudio_dapm_free_widget(w);
	}
	mutex_unlock(&dapm->card->dapm_mutex);
	mutex_unlock(&card->dapm_mutex);
	return 0;
}

+7 −7
Original line number Diff line number Diff line
@@ -380,7 +380,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,
	struct gbaudio_module_info *module;
	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
	struct device *codec_dev = widget->dapm->dev;
	struct device *codec_dev = snd_soc_dapm_to_dev(widget->dapm);
	struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
	struct gb_bundle *bundle;

@@ -393,7 +393,7 @@ static int gbcodec_mixer_dapm_ctl_get(struct snd_kcontrol *kcontrol,
	bundle = to_gb_bundle(module->dev);

	if (data->vcount == 2)
		dev_warn(widget->dapm->dev,
		dev_warn(codec_dev,
			 "GB: Control '%s' is stereo, which is not supported\n",
			 kcontrol->id.name);

@@ -429,7 +429,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
	struct gbaudio_module_info *module;
	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
	struct device *codec_dev = widget->dapm->dev;
	struct device *codec_dev = snd_soc_dapm_to_dev(widget->dapm);
	struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
	struct gb_bundle *bundle;

@@ -443,7 +443,7 @@ static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
	bundle = to_gb_bundle(module->dev);

	if (data->vcount == 2)
		dev_warn(widget->dapm->dev,
		dev_warn(codec_dev,
			 "GB: Control '%s' is stereo, which is not supported\n",
			 kcontrol->id.name);

@@ -712,7 +712,7 @@ static int gbcodec_enum_dapm_ctl_get(struct snd_kcontrol *kcontrol,
	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
	struct gbaudio_module_info *module;
	struct gb_audio_ctl_elem_value gbvalue;
	struct device *codec_dev = widget->dapm->dev;
	struct device *codec_dev = snd_soc_dapm_to_dev(widget->dapm);
	struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	struct gb_bundle *bundle;
@@ -759,7 +759,7 @@ static int gbcodec_enum_dapm_ctl_put(struct snd_kcontrol *kcontrol,
	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
	struct gb_audio_ctl_elem_value gbvalue;
	struct gbaudio_module_info *module;
	struct device *codec_dev = widget->dapm->dev;
	struct device *codec_dev = snd_soc_dapm_to_dev(widget->dapm);
	struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
	struct soc_enum *e = (struct soc_enum *)kcontrol->private_value;
	struct gb_bundle *bundle;
@@ -924,7 +924,7 @@ static int gbaudio_widget_event(struct snd_soc_dapm_widget *w,
{
	int wid;
	int ret;
	struct device *codec_dev = w->dapm->dev;
	struct device *codec_dev = snd_soc_dapm_to_dev(w->dapm);
	struct gbaudio_codec_info *gbcodec = dev_get_drvdata(codec_dev);
	struct gbaudio_module_info *module;
	struct gb_bundle *bundle;
Loading