Loading asoc/codecs/bolero/bolero-cdc.c +78 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #include <linux/printk.h> #include <linux/delay.h> #include <linux/kernel.h> #include <soc/snd_event.h> #include "bolero-cdc.h" #include "internal.h" Loading Loading @@ -62,6 +62,11 @@ static int __bolero_reg_read(struct bolero_priv *priv, u16 current_mclk_mux_macro; mutex_lock(&priv->clk_lock); if (!priv->dev_up) { dev_dbg_ratelimited(priv->dev, "%s: SSR in progress, exit\n", __func__); goto err; } current_mclk_mux_macro = priv->current_mclk_mux_macro[macro_id]; if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) { Loading Loading @@ -94,6 +99,11 @@ static int __bolero_reg_write(struct bolero_priv *priv, u16 current_mclk_mux_macro; mutex_lock(&priv->clk_lock); if (!priv->dev_up) { dev_dbg_ratelimited(priv->dev, "%s: SSR in progress, exit\n", __func__); goto err; } current_mclk_mux_macro = priv->current_mclk_mux_macro[macro_id]; if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) { Loading Loading @@ -529,10 +539,64 @@ static ssize_t bolero_version_read(struct snd_info_entry *entry, return simple_read_from_buffer(buf, count, &pos, buffer, len); } static int bolero_ssr_enable(struct device *dev, void *data) { struct bolero_priv *priv = data; int macro_idx; if (priv->initial_boot) { priv->initial_boot = false; return 0; } if (priv->macro_params[VA_MACRO].event_handler) priv->macro_params[VA_MACRO].event_handler(priv->codec, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0); regcache_cache_only(priv->regmap, false); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_SSR_UP, 0x0); } mutex_lock(&priv->clk_lock); priv->dev_up = true; mutex_unlock(&priv->clk_lock); bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_UP); return 0; } static void bolero_ssr_disable(struct device *dev, void *data) { struct bolero_priv *priv = data; int macro_idx; regcache_cache_only(priv->regmap, true); mutex_lock(&priv->clk_lock); priv->dev_up = false; mutex_unlock(&priv->clk_lock); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_SSR_DOWN, 0x0); } bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_DOWN); } static struct snd_info_entry_ops bolero_info_ops = { .read = bolero_version_read, }; static const struct snd_event_ops bolero_ssr_ops = { .enable = bolero_ssr_enable, .disable = bolero_ssr_disable, }; /* * bolero_info_create_codec_entry - creates bolero module * @codec_root: The parent directory Loading Loading @@ -623,6 +687,16 @@ static int bolero_soc_codec_probe(struct snd_soc_codec *codec) else if (priv->num_macros_registered > 2) priv->version = BOLERO_VERSION_1_2; ret = snd_event_client_register(priv->dev, &bolero_ssr_ops, priv); if (!ret) { snd_event_notify(priv->dev, SND_EVENT_UP); } else { dev_err(codec->dev, "%s: Registration with SND event FWK failed ret = %d\n", __func__, ret); goto err; } dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__); err: return ret; Loading @@ -633,6 +707,7 @@ static int bolero_soc_codec_remove(struct snd_soc_codec *codec) struct bolero_priv *priv = dev_get_drvdata(codec->dev); int macro_idx; snd_event_client_deregister(priv->dev); /* call exit for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) if (priv->macro_params[macro_idx].exit) Loading Loading @@ -756,6 +831,8 @@ static int bolero_probe(struct platform_device *pdev) bolero_reg_access[VA_MACRO] = bolero_va_top_reg_access; priv->dev = &pdev->dev; priv->dev_up = true; priv->initial_boot = true; priv->regmap = bolero_regmap_init(priv->dev, &bolero_regmap_config); if (IS_ERR_OR_NULL((void *)(priv->regmap))) { Loading asoc/codecs/bolero/bolero-cdc.h +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ enum { BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */ BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */ BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */ BOLERO_MACRO_EVT_SSR_DOWN, BOLERO_MACRO_EVT_SSR_UP, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET }; struct macro_ops { Loading asoc/codecs/bolero/internal.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ /* from bolero to WCD events */ enum { BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1, BOLERO_WCD_EVT_SSR_DOWN, BOLERO_WCD_EVT_SSR_UP, }; enum { Loading Loading @@ -52,6 +54,8 @@ struct bolero_priv { struct mutex clk_lock; bool va_without_decimation; bool macros_supported[MAX_MACRO]; bool dev_up; bool initial_boot; struct macro_ops macro_params[MAX_MACRO]; struct snd_soc_dai_driver *bolero_dais; u16 num_dais; Loading asoc/codecs/bolero/rx-macro.c +13 −0 Original line number Diff line number Diff line Loading @@ -1130,6 +1130,19 @@ static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, case BOLERO_MACRO_EVT_IMPED_FALSE: rx_macro_wcd_clsh_imped_config(codec, data, false); break; case BOLERO_MACRO_EVT_SSR_DOWN: swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_DOWN, NULL); swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_DOWN, NULL); break; case BOLERO_MACRO_EVT_SSR_UP: swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; } return 0; } Loading asoc/codecs/bolero/tx-macro.c +29 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <soc/swr-wcd.h> #include "bolero-cdc.h" #include "bolero-cdc-registers.h" #include "../msm-cdc-pinctrl.h" Loading Loading @@ -303,6 +304,33 @@ static int tx_macro_mclk_ctrl(struct device *dev, bool enable) return ret; } static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, u32 data) { struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) return -EINVAL; switch (event) { case BOLERO_MACRO_EVT_SSR_DOWN: swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_DOWN, NULL); swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_DOWN, NULL); break; case BOLERO_MACRO_EVT_SSR_UP: swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; } return 0; } static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) { struct delayed_work *hpf_delayed_work = NULL; Loading Loading @@ -1640,6 +1668,7 @@ static void tx_macro_init_ops(struct macro_ops *ops, ops->dai_ptr = tx_macro_dai; ops->num_dais = ARRAY_SIZE(tx_macro_dai); ops->mclk_fn = tx_macro_mclk_ctrl; ops->event_handler = tx_macro_event_handler; } static int tx_macro_probe(struct platform_device *pdev) Loading Loading
asoc/codecs/bolero/bolero-cdc.c +78 −1 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ #include <linux/printk.h> #include <linux/delay.h> #include <linux/kernel.h> #include <soc/snd_event.h> #include "bolero-cdc.h" #include "internal.h" Loading Loading @@ -62,6 +62,11 @@ static int __bolero_reg_read(struct bolero_priv *priv, u16 current_mclk_mux_macro; mutex_lock(&priv->clk_lock); if (!priv->dev_up) { dev_dbg_ratelimited(priv->dev, "%s: SSR in progress, exit\n", __func__); goto err; } current_mclk_mux_macro = priv->current_mclk_mux_macro[macro_id]; if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) { Loading Loading @@ -94,6 +99,11 @@ static int __bolero_reg_write(struct bolero_priv *priv, u16 current_mclk_mux_macro; mutex_lock(&priv->clk_lock); if (!priv->dev_up) { dev_dbg_ratelimited(priv->dev, "%s: SSR in progress, exit\n", __func__); goto err; } current_mclk_mux_macro = priv->current_mclk_mux_macro[macro_id]; if (!priv->macro_params[current_mclk_mux_macro].mclk_fn) { Loading Loading @@ -529,10 +539,64 @@ static ssize_t bolero_version_read(struct snd_info_entry *entry, return simple_read_from_buffer(buf, count, &pos, buffer, len); } static int bolero_ssr_enable(struct device *dev, void *data) { struct bolero_priv *priv = data; int macro_idx; if (priv->initial_boot) { priv->initial_boot = false; return 0; } if (priv->macro_params[VA_MACRO].event_handler) priv->macro_params[VA_MACRO].event_handler(priv->codec, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET, 0x0); regcache_cache_only(priv->regmap, false); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_SSR_UP, 0x0); } mutex_lock(&priv->clk_lock); priv->dev_up = true; mutex_unlock(&priv->clk_lock); bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_UP); return 0; } static void bolero_ssr_disable(struct device *dev, void *data) { struct bolero_priv *priv = data; int macro_idx; regcache_cache_only(priv->regmap, true); mutex_lock(&priv->clk_lock); priv->dev_up = false; mutex_unlock(&priv->clk_lock); /* call ssr event for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) { if (!priv->macro_params[macro_idx].event_handler) continue; priv->macro_params[macro_idx].event_handler(priv->codec, BOLERO_MACRO_EVT_SSR_DOWN, 0x0); } bolero_cdc_notifier_call(priv, BOLERO_WCD_EVT_SSR_DOWN); } static struct snd_info_entry_ops bolero_info_ops = { .read = bolero_version_read, }; static const struct snd_event_ops bolero_ssr_ops = { .enable = bolero_ssr_enable, .disable = bolero_ssr_disable, }; /* * bolero_info_create_codec_entry - creates bolero module * @codec_root: The parent directory Loading Loading @@ -623,6 +687,16 @@ static int bolero_soc_codec_probe(struct snd_soc_codec *codec) else if (priv->num_macros_registered > 2) priv->version = BOLERO_VERSION_1_2; ret = snd_event_client_register(priv->dev, &bolero_ssr_ops, priv); if (!ret) { snd_event_notify(priv->dev, SND_EVENT_UP); } else { dev_err(codec->dev, "%s: Registration with SND event FWK failed ret = %d\n", __func__, ret); goto err; } dev_dbg(codec->dev, "%s: bolero soc codec probe success\n", __func__); err: return ret; Loading @@ -633,6 +707,7 @@ static int bolero_soc_codec_remove(struct snd_soc_codec *codec) struct bolero_priv *priv = dev_get_drvdata(codec->dev); int macro_idx; snd_event_client_deregister(priv->dev); /* call exit for supported macros */ for (macro_idx = START_MACRO; macro_idx < MAX_MACRO; macro_idx++) if (priv->macro_params[macro_idx].exit) Loading Loading @@ -756,6 +831,8 @@ static int bolero_probe(struct platform_device *pdev) bolero_reg_access[VA_MACRO] = bolero_va_top_reg_access; priv->dev = &pdev->dev; priv->dev_up = true; priv->initial_boot = true; priv->regmap = bolero_regmap_init(priv->dev, &bolero_regmap_config); if (IS_ERR_OR_NULL((void *)(priv->regmap))) { Loading
asoc/codecs/bolero/bolero-cdc.h +3 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,9 @@ enum { BOLERO_MACRO_EVT_RX_MUTE = 1, /* for RX mute/unmute */ BOLERO_MACRO_EVT_IMPED_TRUE, /* for imped true */ BOLERO_MACRO_EVT_IMPED_FALSE, /* for imped false */ BOLERO_MACRO_EVT_SSR_DOWN, BOLERO_MACRO_EVT_SSR_UP, BOLERO_MACRO_EVT_WAIT_VA_CLK_RESET }; struct macro_ops { Loading
asoc/codecs/bolero/internal.h +4 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ /* from bolero to WCD events */ enum { BOLERO_WCD_EVT_TX_CH_HOLD_CLEAR = 1, BOLERO_WCD_EVT_SSR_DOWN, BOLERO_WCD_EVT_SSR_UP, }; enum { Loading Loading @@ -52,6 +54,8 @@ struct bolero_priv { struct mutex clk_lock; bool va_without_decimation; bool macros_supported[MAX_MACRO]; bool dev_up; bool initial_boot; struct macro_ops macro_params[MAX_MACRO]; struct snd_soc_dai_driver *bolero_dais; u16 num_dais; Loading
asoc/codecs/bolero/rx-macro.c +13 −0 Original line number Diff line number Diff line Loading @@ -1130,6 +1130,19 @@ static int rx_macro_event_handler(struct snd_soc_codec *codec, u16 event, case BOLERO_MACRO_EVT_IMPED_FALSE: rx_macro_wcd_clsh_imped_config(codec, data, false); break; case BOLERO_MACRO_EVT_SSR_DOWN: swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_DOWN, NULL); swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_DOWN, NULL); break; case BOLERO_MACRO_EVT_SSR_UP: swrm_wcd_notify( rx_priv->swr_ctrl_data[0].rx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; } return 0; } Loading
asoc/codecs/bolero/tx-macro.c +29 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ #include <sound/soc.h> #include <sound/soc-dapm.h> #include <sound/tlv.h> #include <soc/swr-wcd.h> #include "bolero-cdc.h" #include "bolero-cdc-registers.h" #include "../msm-cdc-pinctrl.h" Loading Loading @@ -303,6 +304,33 @@ static int tx_macro_mclk_ctrl(struct device *dev, bool enable) return ret; } static int tx_macro_event_handler(struct snd_soc_codec *codec, u16 event, u32 data) { struct device *tx_dev = NULL; struct tx_macro_priv *tx_priv = NULL; if (!tx_macro_get_data(codec, &tx_dev, &tx_priv, __func__)) return -EINVAL; switch (event) { case BOLERO_MACRO_EVT_SSR_DOWN: swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_DOWN, NULL); swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_DOWN, NULL); break; case BOLERO_MACRO_EVT_SSR_UP: swrm_wcd_notify( tx_priv->swr_ctrl_data[0].tx_swr_pdev, SWR_DEVICE_SSR_UP, NULL); break; } return 0; } static void tx_macro_tx_hpf_corner_freq_callback(struct work_struct *work) { struct delayed_work *hpf_delayed_work = NULL; Loading Loading @@ -1640,6 +1668,7 @@ static void tx_macro_init_ops(struct macro_ops *ops, ops->dai_ptr = tx_macro_dai; ops->num_dais = ARRAY_SIZE(tx_macro_dai); ops->mclk_fn = tx_macro_mclk_ctrl; ops->event_handler = tx_macro_event_handler; } static int tx_macro_probe(struct platform_device *pdev) Loading