From: Daniel Baluta <daniel.baluta@oss.nxp.com>
To: pierre-louis.bossart@linux.intel.com, lgirdwood@gmail.com,
broonie@kernel.org
Cc: daniel.baluta@nxp.com, kai.vehmanen@linux.intel.com,
ranjani.sridharan@linux.intel.com,
sound-open-firmware@alsa-project.org,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
cezary.rojewski@intel.com, paul.olaru@nxp.com
Subject: [PATCH v2 2/2] ASoC: SOF: compress: Implement get_caps and get_codec_caps
Date: Tue, 18 Jan 2022 23:27:32 +0200 [thread overview]
Message-ID: <20220118212732.281657-3-daniel.baluta@oss.nxp.com> (raw)
In-Reply-To: <20220118212732.281657-1-daniel.baluta@oss.nxp.com>
From: Paul Olaru <paul.olaru@nxp.com>
These functions are used by the userspace to determine what the firmware
supports and tools like cplay should use in terms of sample rate, bit
rate, buffer size and channel count.
The current implementation uses i.MX8 tested scenarios!
Signed-off-by: Paul Olaru <paul.olaru@nxp.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
---
sound/soc/sof/compress.c | 74 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index 91a9c95929cd..e3f3f309f312 100644
--- a/sound/soc/sof/compress.c
+++ b/sound/soc/sof/compress.c
@@ -308,6 +308,78 @@ static int sof_compr_pointer(struct snd_soc_component *component,
return 0;
}
+static int sof_compr_get_caps(struct snd_soc_component *component,
+ struct snd_compr_stream *cstream,
+ struct snd_compr_caps *caps)
+{
+ caps->num_codecs = 3;
+ caps->min_fragment_size = 3840;
+ caps->max_fragment_size = 3840;
+ caps->min_fragments = 2;
+ caps->max_fragments = 2;
+ caps->codecs[0] = SND_AUDIOCODEC_MP3;
+ caps->codecs[1] = SND_AUDIOCODEC_AAC;
+ caps->codecs[2] = SND_AUDIOCODEC_PCM;
+
+ return 0;
+}
+
+static struct snd_compr_codec_caps caps_pcm = {
+ .num_descriptors = 1,
+ .descriptor[0].max_ch = 2,
+ .descriptor[0].sample_rates[0] = 48000,
+ .descriptor[0].num_sample_rates = 1,
+ .descriptor[0].bit_rate = {1536, 3072},
+ .descriptor[0].num_bitrates = 2,
+ .descriptor[0].profiles = SND_AUDIOPROFILE_PCM,
+ .descriptor[0].modes = 0,
+ .descriptor[0].formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE,
+};
+
+static struct snd_compr_codec_caps caps_mp3 = {
+ .num_descriptors = 1,
+ .descriptor[0].max_ch = 2,
+ .descriptor[0].sample_rates[0] = 48000,
+ .descriptor[0].num_sample_rates = 1,
+ .descriptor[0].bit_rate = {32, 40, 48, 56, 64, 80, 96, 112, 224, 256, 320},
+ .descriptor[0].num_bitrates = 11,
+ .descriptor[0].profiles = 0,
+ .descriptor[0].modes = SND_AUDIOCHANMODE_MP3_STEREO,
+ .descriptor[0].formats = 0,
+};
+
+static struct snd_compr_codec_caps caps_aac = {
+ .num_descriptors = 1,
+ .descriptor[0].max_ch = 2,
+ .descriptor[0].sample_rates[0] = 48000,
+ .descriptor[0].num_sample_rates = 1,
+ .descriptor[0].bit_rate = {128, 192},
+ .descriptor[0].num_bitrates = 2,
+ .descriptor[0].profiles = 0,
+ .descriptor[0].modes = 0,
+ .descriptor[0].formats = SND_AUDIOSTREAMFORMAT_MP4ADTS | SND_AUDIOSTREAMFORMAT_MP2ADTS,
+};
+
+static int sof_compr_get_codec_caps(struct snd_soc_component *component,
+ struct snd_compr_stream *cstream,
+ struct snd_compr_codec_caps *codec)
+{
+ switch (codec->codec) {
+ case SND_AUDIOCODEC_MP3:
+ *codec = caps_mp3;
+ break;
+ case SND_AUDIOCODEC_AAC:
+ *codec = caps_aac;
+ break;
+ case SND_AUDIOCODEC_PCM:
+ *codec = caps_pcm;
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
struct snd_compress_ops sof_compressed_ops = {
.open = sof_compr_open,
.free = sof_compr_free,
@@ -316,5 +388,7 @@ struct snd_compress_ops sof_compressed_ops = {
.trigger = sof_compr_trigger,
.pointer = sof_compr_pointer,
.copy = sof_compr_copy,
+ .get_caps = sof_compr_get_caps,
+ .get_codec_caps = sof_compr_get_codec_caps,
};
EXPORT_SYMBOL(sof_compressed_ops);
--
2.27.0
next prev parent reply other threads:[~2022-01-18 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 21:27 [PATCH v2 0/2] SOF: Add compress support implementation Daniel Baluta
2022-01-18 21:27 ` [PATCH v2 1/2] ASoC: SOF: compr: Add compress ops implementation Daniel Baluta
2022-01-18 21:27 ` Daniel Baluta [this message]
2022-01-19 1:00 ` [PATCH v2 2/2] ASoC: SOF: compress: Implement get_caps and get_codec_caps Pierre-Louis Bossart
2022-01-19 15:43 ` Daniel Baluta
2022-01-19 16:56 ` Pierre-Louis Bossart
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220118212732.281657-3-daniel.baluta@oss.nxp.com \
--to=daniel.baluta@oss.nxp.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=daniel.baluta@nxp.com \
--cc=kai.vehmanen@linux.intel.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.olaru@nxp.com \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=ranjani.sridharan@linux.intel.com \
--cc=sound-open-firmware@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®