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

Commit 06a4c648 authored by Sudheer Papothi's avatar Sudheer Papothi
Browse files

ASoC: Add support for event listener from the codec



During low power island mode, register to event listener
to process soundwire inband interrupts from the soundwire
master driver.

Change-Id: Ib15f5ec59ea19010dbb8f9744de76bfc2ca7eebb
Signed-off-by: default avatarSudheer Papothi <spapothi@codeaurora.org>
parent 72ee264c
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -504,6 +504,8 @@ int bolero_register_macro(struct device *dev, u16 macro_id,
	if (macro_id == TX_MACRO) {
		priv->macro_params[macro_id].reg_wake_irq = ops->reg_wake_irq;
		priv->macro_params[macro_id].clk_switch = ops->clk_switch;
		priv->macro_params[macro_id].reg_evt_listener =
							ops->reg_evt_listener;
	}

	priv->num_dais += ops->num_dais;
@@ -567,6 +569,7 @@ void bolero_unregister_macro(struct device *dev, u16 macro_id)
	if (macro_id == TX_MACRO) {
		priv->macro_params[macro_id].reg_wake_irq = NULL;
		priv->macro_params[macro_id].clk_switch = NULL;
		priv->macro_params[macro_id].reg_evt_listener = NULL;
	}

	priv->num_dais -= priv->macro_params[macro_id].num_dais;
@@ -803,6 +806,41 @@ int bolero_tx_clk_switch(struct snd_soc_component *component)
}
EXPORT_SYMBOL(bolero_tx_clk_switch);

/**
 * bolero_register_event_listener - Register/Deregister to event listener
 *
 * @component: pointer to codec component instance.
 * @enable: when set to 1 registers to event listener otherwise, derigisters
 *          from the event listener
 *
 * Returns 0 on success or -EINVAL on error.
 */
int bolero_register_event_listener(struct snd_soc_component *component,
				   bool enable)
{
	struct bolero_priv *priv = NULL;
	int ret = 0;

	if (!component)
		return -EINVAL;

	priv = snd_soc_component_get_drvdata(component);
	if (!priv)
		return -EINVAL;

	if (!bolero_is_valid_codec_dev(priv->dev)) {
		dev_err(component->dev, "%s: invalid codec\n", __func__);
		return -EINVAL;
	}

	if (priv->macro_params[TX_MACRO].reg_evt_listener)
		ret = priv->macro_params[TX_MACRO].reg_evt_listener(component,
								    enable);

	return ret;
}
EXPORT_SYMBOL(bolero_register_event_listener);

static int bolero_soc_codec_probe(struct snd_soc_component *component)
{
	struct bolero_priv *priv = dev_get_drvdata(component->dev);
+10 −0
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ struct macro_ops {
	int (*set_port_map)(struct snd_soc_component *component, u32 uc,
			    u32 size, void *data);
	int (*clk_switch)(struct snd_soc_component *component);
	int (*reg_evt_listener)(struct snd_soc_component *component, bool en);
	char __iomem *io_base;
	u16 clk_id_req;
	u16 default_clk_id;
@@ -80,6 +81,8 @@ int bolero_runtime_resume(struct device *dev);
int bolero_runtime_suspend(struct device *dev);
int bolero_set_port_map(struct snd_soc_component *component, u32 size, void *data);
int bolero_tx_clk_switch(struct snd_soc_component *component);
int bolero_register_event_listener(struct snd_soc_component *component,
				   bool enable);
#else
static inline int bolero_register_res_clk(struct device *dev, rsc_clk_cb_t cb)
{
@@ -144,5 +147,12 @@ static inline int bolero_tx_clk_switch(struct snd_soc_component *component)
	return 0;
}

static inline int bolero_register_event_listener(
					struct snd_soc_component *component,
					bool enable)
{
	return 0;
}

#endif /* CONFIG_SND_SOC_BOLERO */
#endif /* BOLERO_CDC_H */
+37 −0
Original line number Diff line number Diff line
@@ -1582,6 +1582,42 @@ static const struct snd_kcontrol_new tx_macro_snd_controls[] = {
		       tx_macro_get_bcs, tx_macro_set_bcs),
};

static int tx_macro_register_event_listener(struct snd_soc_component *component,
					    bool enable)
{
	struct device *tx_dev = NULL;
	struct tx_macro_priv *tx_priv = NULL;
	int ret = 0;

	if (!component)
		return -EINVAL;

	tx_dev = bolero_get_device_ptr(component->dev, TX_MACRO);
	if (!tx_dev) {
		dev_err(component->dev,
			"%s: null device for macro!\n", __func__);
		return -EINVAL;
	}
	tx_priv = dev_get_drvdata(tx_dev);
	if (!tx_priv) {
		dev_err(component->dev,
			"%s: priv is null for macro!\n", __func__);
		return -EINVAL;
	}
	if (tx_priv->swr_ctrl_data) {
		if (enable)
			ret = swrm_wcd_notify(
				tx_priv->swr_ctrl_data[0].tx_swr_pdev,
				SWR_REGISTER_WAKEUP, NULL);
		else
			ret = swrm_wcd_notify(
				tx_priv->swr_ctrl_data[0].tx_swr_pdev,
				SWR_DEREGISTER_WAKEUP, NULL);
	}

	return ret;
}

static int tx_macro_tx_va_mclk_enable(struct tx_macro_priv *tx_priv,
				      struct regmap *regmap, int clk_type,
				      bool enable)
@@ -2121,6 +2157,7 @@ static void tx_macro_init_ops(struct macro_ops *ops,
	ops->reg_wake_irq = tx_macro_reg_wake_irq;
	ops->set_port_map = tx_macro_set_port_map;
	ops->clk_switch = tx_macro_clk_switch;
	ops->reg_evt_listener = tx_macro_register_event_listener;
}

static int tx_macro_probe(struct platform_device *pdev)
+2 −0
Original line number Diff line number Diff line
@@ -287,8 +287,10 @@ static int va_macro_swr_pwr_event(struct snd_soc_dapm_widget *w,
			if (bolero_tx_clk_switch(component))
				dev_dbg(va_dev, "%s: clock switch failed\n",
					__func__);
		bolero_register_event_listener(component, true);
		break;
	case SND_SOC_DAPM_POST_PMD:
		bolero_register_event_listener(component, false);
		if (bolero_tx_clk_switch(component))
			dev_dbg(va_dev, "%s: clock switch failed\n",__func__);
		if (va_priv->lpass_audio_hw_vote)