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

Commit 67276156 authored by Joonwoo Park's avatar Joonwoo Park Committed by Stephen Boyd
Browse files

ASoC: wcd9xxx: Update sound card's online/offline state



Update sound card's state when it went to online/offline so application
can monitor and wait for card's online prior to issue command.

Change-Id: I7cfb120e56e97cf743782a8b4b2fcbad242b227b
Signed-off-by: default avatarJoonwoo Park <joonwoop@codeaurora.org>
parent d811feab
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
@@ -1567,6 +1567,7 @@ static int wcd9xxx_device_up(struct wcd9xxx *wcd9xxx)
		pr_err("%s: Resetting Codec failed\n", __func__);

	wcd9xxx_bring_up(wcd9xxx);
	if (wcd9xxx->post_reset)
		wcd9xxx->post_reset(wcd9xxx);
	return ret;
}
@@ -1574,9 +1575,20 @@ static int wcd9xxx_device_up(struct wcd9xxx *wcd9xxx)
static int wcd9xxx_slim_device_up(struct slim_device *sldev)
{
	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
	dev_dbg(wcd9xxx->dev, "%s: device up\n", __func__);
	return wcd9xxx_device_up(wcd9xxx);
}

static int wcd9xxx_slim_device_down(struct slim_device *sldev)
{
	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);

	if (wcd9xxx->dev_down)
		wcd9xxx->dev_down(wcd9xxx);
	dev_dbg(wcd9xxx->dev, "%s: device down\n", __func__);
	return 0;
}

static int wcd9xxx_slim_resume(struct slim_device *sldev)
{
	struct wcd9xxx *wcd9xxx = slim_get_devicedata(sldev);
@@ -1733,6 +1745,7 @@ static struct slim_driver taiko_slim_driver = {
	.resume = wcd9xxx_slim_resume,
	.suspend = wcd9xxx_slim_suspend,
	.device_up = wcd9xxx_slim_device_up,
	.device_down = wcd9xxx_slim_device_down,
};

static const struct slim_device_id tapan_slimtest_id[] = {
@@ -1751,6 +1764,7 @@ static struct slim_driver tapan_slim_driver = {
	.resume = wcd9xxx_slim_resume,
	.suspend = wcd9xxx_slim_suspend,
	.device_up = wcd9xxx_slim_device_up,
	.device_down = wcd9xxx_slim_device_down,
};

static struct i2c_device_id wcd9xxx_id_table[] = {
+3 −0
Original line number Diff line number Diff line
@@ -188,10 +188,13 @@ struct wcd9xxx {
			int bytes, void *dest, bool interface_reg);
	int (*write_dev)(struct wcd9xxx *wcd9xxx, unsigned short reg,
			int bytes, void *src, bool interface_reg);
	int (*dev_down)(struct wcd9xxx *wcd9xxx);
	int (*post_reset)(struct wcd9xxx *wcd9xxx);

	void *ssr_priv;
	bool slim_device_bootup;
	/* device down flag by device_down notification */
	bool device_down;

	u32 num_of_supplies;
	struct regulator_bulk_data *supplies;
+20 −4
Original line number Diff line number Diff line
@@ -4727,6 +4727,16 @@ int tapan_hs_detect(struct snd_soc_codec *codec,
}
EXPORT_SYMBOL_GPL(tapan_hs_detect);

static int tapan_device_down(struct wcd9xxx *wcd9xxx)
{
	struct snd_soc_codec *codec;

	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
	snd_soc_card_change_online_state(codec->card, 0);

	return 0;
}

static int tapan_post_reset_cb(struct wcd9xxx *wcd9xxx)
{
	int ret = 0;
@@ -4736,8 +4746,10 @@ static int tapan_post_reset_cb(struct wcd9xxx *wcd9xxx)

	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
	tapan = snd_soc_codec_get_drvdata(codec);
	mutex_lock(&codec->mutex);

	snd_soc_card_change_online_state(codec->card, 1);

	mutex_lock(&codec->mutex);
	if (codec->reg_def_copy) {
		pr_debug("%s: Update ASOC cache", __func__);
		kfree(codec->reg_cache);
@@ -4785,9 +4797,12 @@ static struct wcd9xxx_reg_address tapan_reg_address = {
};

static int wcd9xxx_ssr_register(struct wcd9xxx *control,
		int (*post_reset_cb)(struct wcd9xxx *wcd9xxx), void *priv)
				int (*device_down_cb)(struct wcd9xxx *wcd9xxx),
				int (*device_up_cb)(struct wcd9xxx *wcd9xxx),
				void *priv)
{
	control->post_reset = post_reset_cb;
	control->dev_down = device_down_cb;
	control->post_reset = device_up_cb;
	control->ssr_priv = priv;
	return 0;
}
@@ -4821,7 +4836,8 @@ static int tapan_codec_probe(struct snd_soc_codec *codec)
	codec->control_data = dev_get_drvdata(codec->dev->parent);
	control = codec->control_data;

	wcd9xxx_ssr_register(control, tapan_post_reset_cb, (void *)codec);
	wcd9xxx_ssr_register(control, tapan_device_down,
			     tapan_post_reset_cb, (void *)codec);

	dev_info(codec->dev, "%s()\n", __func__);

+20 −4
Original line number Diff line number Diff line
@@ -6213,6 +6213,16 @@ static void taiko_init_slim_slave_cfg(struct snd_soc_codec *codec)
	pr_debug("%s: slimbus logical address 0x%llx\n", __func__, eaddr);
}

static int taiko_device_down(struct wcd9xxx *wcd9xxx)
{
	struct snd_soc_codec *codec;

	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
	snd_soc_card_change_online_state(codec->card, 0);

	return 0;
}

static int taiko_post_reset_cb(struct wcd9xxx *wcd9xxx)
{
	int ret = 0;
@@ -6222,8 +6232,10 @@ static int taiko_post_reset_cb(struct wcd9xxx *wcd9xxx)

	codec = (struct snd_soc_codec *)(wcd9xxx->ssr_priv);
	taiko = snd_soc_codec_get_drvdata(codec);
	mutex_lock(&codec->mutex);

	snd_soc_card_change_online_state(codec->card, 1);

	mutex_lock(&codec->mutex);
	if (codec->reg_def_copy) {
		pr_debug("%s: Update ASOC cache", __func__);
		kfree(codec->reg_cache);
@@ -6310,9 +6322,12 @@ static struct wcd9xxx_reg_address taiko_reg_address = {
};

static int wcd9xxx_ssr_register(struct wcd9xxx *control,
		int (*post_reset_cb)(struct wcd9xxx *wcd9xxx), void *priv)
				int (*device_down_cb)(struct wcd9xxx *wcd9xxx),
				int (*device_up_cb)(struct wcd9xxx *wcd9xxx),
				void *priv)
{
	control->post_reset = post_reset_cb;
	control->dev_down = device_down_cb;
	control->post_reset = device_up_cb;
	control->ssr_priv = priv;
	return 0;
}
@@ -6397,7 +6412,8 @@ static int taiko_codec_probe(struct snd_soc_codec *codec)
	codec->control_data = dev_get_drvdata(codec->dev->parent);
	control = codec->control_data;

	wcd9xxx_ssr_register(control, taiko_post_reset_cb, (void *)codec);
	wcd9xxx_ssr_register(control, taiko_device_down,
			     taiko_post_reset_cb, (void *)codec);

	dev_info(codec->dev, "%s()\n", __func__);