This driver makes AD242x nodes available as DAIs in ASoC topologies.
The hardware allows multiple TDM channel modes and bitdepths, but
as these modes have influence in the timing calculations at discovery
time, the mode in that the will be used in needs to be configured
statically in the devicetree.
+ if (ad242x_node_is_master(priv->node) &&
+ ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS)) {
+ dev_err(component->dev, "master node must be clock slave\n");
+ return -EINVAL;
+ }
+
+ if (!ad242x_node_is_master(priv->node) &&
+ ((format & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBM_CFM)) {
+ dev_err(component->dev, "slave node must be clock master\n");
+ return -EINVAL;
+ }
+ switch (params_format(params)) {
+ case SNDRV_PCM_FORMAT_S16_LE:
+ if (priv->node->tdm_slot_size != 16)
+ return -EINVAL;
+ break;
+ case SNDRV_PCM_FORMAT_S32_LE:
+ if (priv->node->tdm_slot_size != 32)
+ return -EINVAL;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (priv->pdm[index]) {
+ if (substream->stream != SNDRV_PCM_STREAM_PLAYBACK)
+ return -EINVAL;
+
+ if (index == 0) {
+ val = AD242X_PDMCTL_PDM0EN;
+ mask = AD242X_PDMCTL_PDM0EN | AD242X_PDMCTL_PDM0SLOTS;
+ } else {
+ val = AD242X_PDMCTL_PDM1EN;
+ mask = AD242X_PDMCTL_PDM1EN | AD242X_PDMCTL_PDM1SLOTS;
+ }
+
+ switch (params_channels(params)) {
+ case 1:
+ break;
+ case 2:
+ val = mask;
+ break;