mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-14 08:36:12 -04:00
ASoC: bolero: Add support to retrieve soundwire port configuration
Add support to get the platform specific soundwire port configuration for soundwire master ports. Change-Id: Ie1d32a77d534f6c3f397936b85c025b14d01f321 Signed-off-by: Sudheer Papothi <spapothi@codeaurora.org>
This commit is contained in:
parent
3d1596e2c6
commit
a3e969d6f0
5 changed files with 126 additions and 0 deletions
|
|
@ -13,6 +13,7 @@
|
|||
#include <linux/clk.h>
|
||||
#include <soc/snd_event.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <soc/swr-common.h>
|
||||
#include "bolero-cdc.h"
|
||||
#include "internal.h"
|
||||
|
||||
|
|
@ -37,6 +38,41 @@ static u16 bolero_mclk_mux_tbl[MAX_MACRO][MCLK_MUX_MAX] = {
|
|||
{TX_MACRO, VA_MACRO},
|
||||
};
|
||||
|
||||
static bool bolero_is_valid_codec_dev(struct device *dev);
|
||||
|
||||
int bolero_set_port_map(struct snd_soc_component *component,
|
||||
u32 size, void *data)
|
||||
{
|
||||
struct bolero_priv *priv = NULL;
|
||||
struct swr_mstr_port_map *map = NULL;
|
||||
u16 idx;
|
||||
|
||||
if (!component || (size == 0) || !data)
|
||||
return -EINVAL;
|
||||
|
||||
priv = snd_soc_component_get_drvdata(component);
|
||||
if (!priv)
|
||||
return -EINVAL;
|
||||
|
||||
if (!bolero_is_valid_codec_dev(priv->dev)) {
|
||||
dev_err(priv->dev, "%s: invalid codec\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
map = (struct swr_mstr_port_map *)data;
|
||||
|
||||
for (idx = 0; idx < size; idx++) {
|
||||
if (priv->macro_params[map->id].set_port_map)
|
||||
priv->macro_params[map->id].set_port_map(component,
|
||||
map->uc,
|
||||
SWR_MSTR_PORT_LEN,
|
||||
map->swr_port_params);
|
||||
map += 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(bolero_set_port_map);
|
||||
|
||||
static void bolero_ahb_write_device(char __iomem *io_base,
|
||||
u16 reg, u8 value)
|
||||
{
|
||||
|
|
@ -350,6 +386,7 @@ int bolero_register_macro(struct device *dev, u16 macro_id,
|
|||
priv->macro_params[macro_id].dai_ptr = ops->dai_ptr;
|
||||
priv->macro_params[macro_id].mclk_fn = ops->mclk_fn;
|
||||
priv->macro_params[macro_id].event_handler = ops->event_handler;
|
||||
priv->macro_params[macro_id].set_port_map = ops->set_port_map;
|
||||
priv->macro_params[macro_id].dev = dev;
|
||||
priv->current_mclk_mux_macro[macro_id] =
|
||||
bolero_mclk_mux_tbl[macro_id][MCLK_MUX0];
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ struct macro_ops {
|
|||
int (*event_handler)(struct snd_soc_component *component, u16 event,
|
||||
u32 data);
|
||||
int (*reg_wake_irq)(struct snd_soc_component *component, u32 data);
|
||||
int (*set_port_map)(struct snd_soc_component *component, u32 uc,
|
||||
u32 size, void *data);
|
||||
char __iomem *io_base;
|
||||
};
|
||||
|
||||
|
|
@ -69,6 +71,7 @@ int bolero_register_wake_irq(struct snd_soc_component *component, u32 data);
|
|||
void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n);
|
||||
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);
|
||||
#else
|
||||
static inline int bolero_register_macro(struct device *dev,
|
||||
u16 macro_id,
|
||||
|
|
@ -107,13 +110,24 @@ static inline void bolero_clear_amic_tx_hold(struct device *dev, u16 adc_n)
|
|||
|
||||
static inline int bolero_register_wake_irq(struct snd_soc_component *component,
|
||||
u32 data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bolero_runtime_resume(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bolero_runtime_suspend(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int bolero_set_port_map(struct snd_soc_component *component,
|
||||
u32 size, void *data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_SND_SOC_BOLERO */
|
||||
#endif /* BOLERO_CDC_H */
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
#include <sound/pcm_params.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <soc/swr-common.h>
|
||||
#include <soc/swr-wcd.h>
|
||||
|
||||
#include "bolero-cdc.h"
|
||||
|
|
@ -701,6 +702,29 @@ static bool rx_macro_get_data(struct snd_soc_component *component,
|
|||
return true;
|
||||
}
|
||||
|
||||
static int rx_macro_set_port_map(struct snd_soc_component *component,
|
||||
u32 usecase, u32 size, void *data)
|
||||
{
|
||||
struct device *rx_dev = NULL;
|
||||
struct rx_macro_priv *rx_priv = NULL;
|
||||
struct swrm_port_config port_cfg;
|
||||
int ret = 0;
|
||||
|
||||
if (!rx_macro_get_data(component, &rx_dev, &rx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
memset(&port_cfg, 0, sizeof(port_cfg));
|
||||
port_cfg.uc = usecase;
|
||||
port_cfg.size = size;
|
||||
port_cfg.params = data;
|
||||
|
||||
ret = swrm_wcd_notify(
|
||||
rx_priv->swr_ctrl_data[0].rx_swr_pdev,
|
||||
SWR_SET_PORT_MAP, &port_cfg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int rx_macro_int_dem_inp_mux_put(struct snd_kcontrol *kcontrol,
|
||||
struct snd_ctl_elem_value *ucontrol)
|
||||
{
|
||||
|
|
@ -3366,6 +3390,7 @@ static void rx_macro_init_ops(struct macro_ops *ops, char __iomem *rx_io_base)
|
|||
ops->num_dais = ARRAY_SIZE(rx_macro_dai);
|
||||
ops->mclk_fn = rx_macro_mclk_ctrl;
|
||||
ops->event_handler = rx_macro_event_handler;
|
||||
ops->set_port_map = rx_macro_set_port_map;
|
||||
}
|
||||
|
||||
static int rx_macro_probe(struct platform_device *pdev)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <soc/swr-common.h>
|
||||
#include <soc/swr-wcd.h>
|
||||
#include "bolero-cdc.h"
|
||||
#include "bolero-cdc-registers.h"
|
||||
|
|
@ -1709,6 +1710,29 @@ err:
|
|||
return;
|
||||
}
|
||||
|
||||
static int tx_macro_set_port_map(struct snd_soc_component *component,
|
||||
u32 usecase, u32 size, void *data)
|
||||
{
|
||||
struct device *tx_dev = NULL;
|
||||
struct tx_macro_priv *tx_priv = NULL;
|
||||
struct swrm_port_config port_cfg;
|
||||
int ret = 0;
|
||||
|
||||
if (!tx_macro_get_data(component, &tx_dev, &tx_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
memset(&port_cfg, 0, sizeof(port_cfg));
|
||||
port_cfg.uc = usecase;
|
||||
port_cfg.size = size;
|
||||
port_cfg.params = data;
|
||||
|
||||
ret = swrm_wcd_notify(
|
||||
tx_priv->swr_ctrl_data[0].tx_swr_pdev,
|
||||
SWR_SET_PORT_MAP, &port_cfg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void tx_macro_init_ops(struct macro_ops *ops,
|
||||
char __iomem *tx_io_base)
|
||||
{
|
||||
|
|
@ -1721,6 +1745,7 @@ static void tx_macro_init_ops(struct macro_ops *ops,
|
|||
ops->mclk_fn = tx_macro_mclk_ctrl;
|
||||
ops->event_handler = tx_macro_event_handler;
|
||||
ops->reg_wake_irq = tx_macro_reg_wake_irq;
|
||||
ops->set_port_map = tx_macro_set_port_map;
|
||||
}
|
||||
|
||||
static int tx_macro_probe(struct platform_device *pdev)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <sound/soc.h>
|
||||
#include <sound/soc-dapm.h>
|
||||
#include <sound/tlv.h>
|
||||
#include <soc/swr-common.h>
|
||||
#include <soc/swr-wcd.h>
|
||||
|
||||
#include "bolero-cdc.h"
|
||||
|
|
@ -452,6 +453,29 @@ static bool wsa_macro_get_data(struct snd_soc_component *component,
|
|||
return true;
|
||||
}
|
||||
|
||||
static int wsa_macro_set_port_map(struct snd_soc_component *component,
|
||||
u32 usecase, u32 size, void *data)
|
||||
{
|
||||
struct device *wsa_dev = NULL;
|
||||
struct wsa_macro_priv *wsa_priv = NULL;
|
||||
struct swrm_port_config port_cfg;
|
||||
int ret = 0;
|
||||
|
||||
if (!wsa_macro_get_data(component, &wsa_dev, &wsa_priv, __func__))
|
||||
return -EINVAL;
|
||||
|
||||
memset(&port_cfg, 0, sizeof(port_cfg));
|
||||
port_cfg.uc = usecase;
|
||||
port_cfg.size = size;
|
||||
port_cfg.params = data;
|
||||
|
||||
ret = swrm_wcd_notify(
|
||||
wsa_priv->swr_ctrl_data[0].wsa_swr_pdev,
|
||||
SWR_SET_PORT_MAP, &port_cfg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* wsa_macro_set_spkr_gain_offset - offset the speaker path
|
||||
* gain with the given offset value.
|
||||
|
|
@ -2770,6 +2794,7 @@ static void wsa_macro_init_ops(struct macro_ops *ops,
|
|||
ops->num_dais = ARRAY_SIZE(wsa_macro_dai);
|
||||
ops->mclk_fn = wsa_macro_mclk_ctrl;
|
||||
ops->event_handler = wsa_macro_event_handler;
|
||||
ops->set_port_map = wsa_macro_set_port_map;
|
||||
}
|
||||
|
||||
static int wsa_macro_probe(struct platform_device *pdev)
|
||||
|
|
|
|||
Loading…
Reference in a new issue