aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMengdong Lin <mengdong.lin@linux.intel.com>2016-11-02 13:03:34 -0400
committerMark Brown <broonie@kernel.org>2016-11-03 12:29:02 -0400
commit717a8e7235377fa50f074c407cc5d0486aa15aa2 (patch)
tree763392367212183f2c42fd5f70e34d5a383e133e
parent288b8da7e992f0b86b283f98e92885781ffdcaee (diff)
ASoC: topology: ABI - Add flags and private data to PCM
This is the remaining update to PCM ABI object of version 5. The flags will be applied to FE (Front End) links and can also be used by physical links. The private data is reserved for future extension, so offset update will add the private data size. Now user space is using ABI v4, and the previous patch "ASoC: topology: make PCM backward compatible from ABI v4" can assure the backward compatibility. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--include/uapi/sound/asoc.h8
-rw-r--r--sound/soc/soc-topology.c28
2 files changed, 34 insertions, 2 deletions
diff --git a/include/uapi/sound/asoc.h b/include/uapi/sound/asoc.h
index 69cae7198b18..aeb408241bc3 100644
--- a/include/uapi/sound/asoc.h
+++ b/include/uapi/sound/asoc.h
@@ -146,6 +146,11 @@
146#define SND_SOC_DAI_FORMAT_MSB SND_SOC_DAI_FORMAT_LEFT_J 146#define SND_SOC_DAI_FORMAT_MSB SND_SOC_DAI_FORMAT_LEFT_J
147#define SND_SOC_DAI_FORMAT_LSB SND_SOC_DAI_FORMAT_RIGHT_J 147#define SND_SOC_DAI_FORMAT_LSB SND_SOC_DAI_FORMAT_RIGHT_J
148 148
149/* DAI link flags */
150#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES (1 << 0)
151#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS (1 << 1)
152#define SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS (1 << 2)
153
149/* 154/*
150 * Block Header. 155 * Block Header.
151 * This header precedes all object and object arrays below. 156 * This header precedes all object and object arrays below.
@@ -456,6 +461,9 @@ struct snd_soc_tplg_pcm {
456 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */ 461 struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX]; /* for DAI link */
457 __le32 num_streams; /* number of streams */ 462 __le32 num_streams; /* number of streams */
458 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */ 463 struct snd_soc_tplg_stream_caps caps[2]; /* playback and capture for DAI */
464 __le32 flag_mask; /* bitmask of flags to configure */
465 __le32 flags; /* SND_SOC_TPLG_LNK_FLGBIT_* flag value */
466 struct snd_soc_tplg_private priv;
459} __attribute__((packed)); 467} __attribute__((packed));
460 468
461 469
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 2f9b64ec5904..8baa1761b874 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1676,6 +1676,24 @@ static int soc_tplg_dai_create(struct soc_tplg *tplg,
1676 return snd_soc_register_dai(tplg->comp, dai_drv); 1676 return snd_soc_register_dai(tplg->comp, dai_drv);
1677} 1677}
1678 1678
1679static void set_link_flags(struct snd_soc_dai_link *link,
1680 unsigned int flag_mask, unsigned int flags)
1681{
1682 if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES)
1683 link->symmetric_rates =
1684 flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_RATES ? 1 : 0;
1685
1686 if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS)
1687 link->symmetric_channels =
1688 flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_CHANNELS ?
1689 1 : 0;
1690
1691 if (flag_mask & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS)
1692 link->symmetric_samplebits =
1693 flags & SND_SOC_TPLG_LNK_FLGBIT_SYMMETRIC_SAMPLEBITS ?
1694 1 : 0;
1695}
1696
1679/* create the FE DAI link */ 1697/* create the FE DAI link */
1680static int soc_tplg_link_create(struct soc_tplg *tplg, 1698static int soc_tplg_link_create(struct soc_tplg *tplg,
1681 struct snd_soc_tplg_pcm *pcm) 1699 struct snd_soc_tplg_pcm *pcm)
@@ -1703,6 +1721,8 @@ static int soc_tplg_link_create(struct soc_tplg *tplg,
1703 link->dynamic = 1; 1721 link->dynamic = 1;
1704 link->dpcm_playback = pcm->playback; 1722 link->dpcm_playback = pcm->playback;
1705 link->dpcm_capture = pcm->capture; 1723 link->dpcm_capture = pcm->capture;
1724 if (pcm->flag_mask)
1725 set_link_flags(link, pcm->flag_mask, pcm->flags);
1706 1726
1707 /* pass control to component driver for optional further init */ 1727 /* pass control to component driver for optional further init */
1708 ret = soc_tplg_dai_link_load(tplg, link); 1728 ret = soc_tplg_dai_link_load(tplg, link);
@@ -1848,10 +1868,14 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
1848 /* create the FE DAIs and DAI links */ 1868 /* create the FE DAIs and DAI links */
1849 soc_tplg_pcm_create(tplg, _pcm); 1869 soc_tplg_pcm_create(tplg, _pcm);
1850 1870
1871
1872 /* offset by version-specific struct size and
1873 * real priv data size
1874 */
1875 tplg->pos += pcm->size + _pcm->priv.size;
1876
1851 if (!abi_match) 1877 if (!abi_match)
1852 kfree(_pcm); /* free the duplicated one */ 1878 kfree(_pcm); /* free the duplicated one */
1853
1854 tplg->pos += pcm->size; /* offset by version-specific size */
1855 } 1879 }
1856 1880
1857 dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count); 1881 dev_dbg(tplg->dev, "ASoC: adding %d PCM DAIs\n", count);