staticint tas2780_mute(struct snd_soc_dai *dai, int mute, int direction)
{ struct snd_soc_component *component = dai->component; struct tas2780_priv *tas2780 =
snd_soc_component_get_drvdata(component); int ret = 0;
ret = snd_soc_component_update_bits(component, TAS2780_PWR_CTRL,
TAS2780_PWR_CTRL_MASK,
mute ? TAS2780_PWR_CTRL_MUTE : 0); if (ret < 0) {
dev_err(tas2780->dev, "%s: Failed to set powercontrol\n",
__func__); goto err;
}
ret = 0;
err: return ret;
}
staticint tas2780_set_bitwidth(struct tas2780_priv *tas2780, int bitwidth)
{ struct snd_soc_component *component = tas2780->component; int sense_en; int val; int ret; int slot_size;
switch (bitwidth) { case SNDRV_PCM_FORMAT_S16_LE:
ret = snd_soc_component_update_bits(component,
TAS2780_TDM_CFG2,
TAS2780_TDM_CFG2_RXW_MASK,
TAS2780_TDM_CFG2_RXW_16BITS);
slot_size = TAS2780_TDM_CFG2_RXS_16BITS; break; case SNDRV_PCM_FORMAT_S24_LE:
ret = snd_soc_component_update_bits(component,
TAS2780_TDM_CFG2,
TAS2780_TDM_CFG2_RXW_MASK,
TAS2780_TDM_CFG2_RXW_24BITS);
slot_size = TAS2780_TDM_CFG2_RXS_24BITS; break; case SNDRV_PCM_FORMAT_S32_LE:
ret = snd_soc_component_update_bits(component,
TAS2780_TDM_CFG2,
TAS2780_TDM_CFG2_RXW_MASK,
TAS2780_TDM_CFG2_RXW_32BITS);
slot_size = TAS2780_TDM_CFG2_RXS_32BITS; break;
default:
ret = -EINVAL;
}
if (ret < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x set bitwidth error\n",
__func__, ret); goto err;
}
ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2,
TAS2780_TDM_CFG2_RXS_MASK, slot_size); if (ret < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x set RX slot size error\n",
__func__, ret); goto err;
}
val = snd_soc_component_read(tas2780->component, TAS2780_PWR_CTRL); if (val < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x read PWR_CTRL error\n",
__func__, val);
ret = val; goto err;
}
staticint tas2780_set_fmt(struct snd_soc_dai *dai, unsignedint fmt)
{ struct snd_soc_component *component = dai->component; struct tas2780_priv *tas2780 =
snd_soc_component_get_drvdata(component);
u8 tdm_rx_start_slot = 0, asi_cfg_1 = 0; int iface; int ret = 0;
switch (fmt & SND_SOC_DAIFMT_INV_MASK) { case SND_SOC_DAIFMT_NB_NF:
asi_cfg_1 = TAS2780_TDM_CFG1_RX_RISING; break; case SND_SOC_DAIFMT_IB_NF:
asi_cfg_1 = TAS2780_TDM_CFG1_RX_FALLING; break; default:
dev_err(tas2780->dev, "ASI format Inverse is not found\n"); return -EINVAL;
}
ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG1,
TAS2780_TDM_CFG1_RX_MASK, asi_cfg_1); if (ret < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x Failed to set asi_cfg_1\n",
__func__, ret); goto err;
}
if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S)
|| ((fmt & SND_SOC_DAIFMT_FORMAT_MASK)
== SND_SOC_DAIFMT_DSP_A)){
iface = TAS2780_TDM_CFG2_SCFG_I2S;
tdm_rx_start_slot = 1;
} else { if (((fmt & SND_SOC_DAIFMT_FORMAT_MASK)
== SND_SOC_DAIFMT_DSP_B)
|| ((fmt & SND_SOC_DAIFMT_FORMAT_MASK)
== SND_SOC_DAIFMT_LEFT_J)) {
iface = TAS2780_TDM_CFG2_SCFG_LEFT_J;
tdm_rx_start_slot = 0;
} else {
dev_err(tas2780->dev, "%s:DAI Format is not found, fmt=0x%x\n",
__func__, fmt);
ret = -EINVAL; goto err;
}
}
ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG1,
TAS2780_TDM_CFG1_MASK,
(tdm_rx_start_slot << TAS2780_TDM_CFG1_51_SHIFT)); if (ret < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x Failed to set tdm_rx_start_slot\n",
__func__, ret); goto err;
}
ret = snd_soc_component_update_bits(component, TAS2780_TDM_CFG2,
TAS2780_TDM_CFG2_SCFG_MASK, iface); if (ret < 0) {
dev_err(tas2780->dev, "%s:errCode:0x%x Failed to set iface\n",
__func__, ret); goto err;
}
ret = 0;
err: return ret;
}
staticint tas2780_set_dai_tdm_slot(struct snd_soc_dai *dai, unsignedint tx_mask, unsignedint rx_mask, int slots, int slot_width)
{ struct snd_soc_component *component = dai->component; struct tas2780_priv *tas2780 =
snd_soc_component_get_drvdata(component); int left_slot, right_slot; int slots_cfg; int slot_size; int ret = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.