pulseaudio: add alsa and pulseaudio support for the CCMP15
Signed-off-by: Mike Engel <Mike.Engel@digi.com>
This commit is contained in:
parent
548b8729aa
commit
ea0d8d7b8b
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2013-2020 Digi International.
|
# Copyright (C) 2013-2022 Digi International.
|
||||||
|
|
||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,9 @@
|
||||||
pcm.!playback_codec {
|
pcm.stm32max98088 {
|
||||||
type hw
|
type hw
|
||||||
card CCMP15DVK
|
card 0
|
||||||
device 0
|
|
||||||
}
|
}
|
||||||
|
ctl.stm32max98088 {
|
||||||
pcm.!record_codec {
|
|
||||||
type hw
|
type hw
|
||||||
card CCMP15DVK
|
card 0
|
||||||
device 1
|
|
||||||
}
|
}
|
||||||
|
ctl.!default stm32max98088
|
||||||
pcm.!playback_hdmi {
|
|
||||||
type hw
|
|
||||||
card CCMP15DVK
|
|
||||||
device 2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,221 @@
|
||||||
|
From cc06048dcd722049f92ab17958760bd798fb4781 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shengjiu Wang <b02247@freescale.com>
|
||||||
|
Date: Thu, 5 Jun 2014 17:37:47 +0800
|
||||||
|
Subject: [PATCH] add conf for multichannel support in imx
|
||||||
|
|
||||||
|
Upstream Status: Inappropriate [platform specific]
|
||||||
|
|
||||||
|
Signed-off-by: Shengjiu Wang <b02247@freescale.com>
|
||||||
|
---
|
||||||
|
src/conf/cards/CS42888.conf | 94 ++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
src/conf/cards/IMX-HDMI.conf | 67 +++++++++++++++++++++++++++++++
|
||||||
|
src/conf/cards/Makefile.am | 4 +-
|
||||||
|
src/conf/cards/aliases.conf | 2 +
|
||||||
|
4 files changed, 166 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 src/conf/cards/CS42888.conf
|
||||||
|
create mode 100644 src/conf/cards/IMX-HDMI.conf
|
||||||
|
|
||||||
|
diff --git a/src/conf/cards/CS42888.conf b/src/conf/cards/CS42888.conf
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..671a284
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/conf/cards/CS42888.conf
|
||||||
|
@@ -0,0 +1,94 @@
|
||||||
|
+#
|
||||||
|
+# Configuration for the CS42888 chip
|
||||||
|
+#
|
||||||
|
+
|
||||||
|
+# default with dmix & dsnoop
|
||||||
|
+CS42888.pcm.default {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type asym
|
||||||
|
+ playback.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dmix:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ capture.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dsnoop:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround40.conf>
|
||||||
|
+
|
||||||
|
+CS42888.pcm.surround40.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 4
|
||||||
|
+ ttable.0.0 1
|
||||||
|
+ ttable.1.2 1
|
||||||
|
+ ttable.2.1 1
|
||||||
|
+ ttable.3.3 1
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround41.conf>
|
||||||
|
+<confdir:pcm/surround50.conf>
|
||||||
|
+<confdir:pcm/surround51.conf>
|
||||||
|
+
|
||||||
|
+CS42888.pcm.surround51.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 6
|
||||||
|
+ ttable.0.0 1
|
||||||
|
+ ttable.1.3 1
|
||||||
|
+ ttable.2.1 1
|
||||||
|
+ ttable.3.4 1
|
||||||
|
+ ttable.4.2 1
|
||||||
|
+ ttable.5.5 1
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround71.conf>
|
||||||
|
+
|
||||||
|
+CS42888.pcm.surround71.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 8
|
||||||
|
+ ttable.0.0 1
|
||||||
|
+ ttable.1.4 1
|
||||||
|
+ ttable.2.1 1
|
||||||
|
+ ttable.3.5 1
|
||||||
|
+ ttable.4.2 1
|
||||||
|
+ ttable.5.6 1
|
||||||
|
+ ttable.6.3 1
|
||||||
|
+ ttable.7.7 1
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+# vim: ft=alsaconf
|
||||||
|
diff --git a/src/conf/cards/IMX-HDMI.conf b/src/conf/cards/IMX-HDMI.conf
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..a51509e
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/conf/cards/IMX-HDMI.conf
|
||||||
|
@@ -0,0 +1,67 @@
|
||||||
|
+#
|
||||||
|
+# Configuration for the CS42888 chip
|
||||||
|
+#
|
||||||
|
+
|
||||||
|
+# default with dmix & dsnoop
|
||||||
|
+IMX-HDMI.pcm.default {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type asym
|
||||||
|
+ playback.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dmix:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ capture.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dsnoop:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround40.conf>
|
||||||
|
+
|
||||||
|
+IMX-HDMI.pcm.surround40.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ channels 4
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround41.conf>
|
||||||
|
+<confdir:pcm/surround50.conf>
|
||||||
|
+<confdir:pcm/surround51.conf>
|
||||||
|
+
|
||||||
|
+IMX-HDMI.pcm.surround51.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ channels 6
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround71.conf>
|
||||||
|
+
|
||||||
|
+IMX-HDMI.pcm.surround71.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ channels 8
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+# vim: ft=alsaconf
|
||||||
|
diff --git a/src/conf/cards/Makefile.am b/src/conf/cards/Makefile.am
|
||||||
|
index 00999f0..fbf0697 100644
|
||||||
|
--- a/src/conf/cards/Makefile.am
|
||||||
|
+++ b/src/conf/cards/Makefile.am
|
||||||
|
@@ -58,7 +58,9 @@ cfg_files = aliases.conf \
|
||||||
|
VIA8237.conf \
|
||||||
|
VX222.conf \
|
||||||
|
VXPocket.conf \
|
||||||
|
- VXPocket440.conf
|
||||||
|
+ VXPocket440.conf \
|
||||||
|
+ CS42888.conf \
|
||||||
|
+ IMX-HDMI.conf
|
||||||
|
|
||||||
|
if BUILD_ALISP
|
||||||
|
cfg_files += aliases.alisp
|
||||||
|
diff --git a/src/conf/cards/aliases.conf b/src/conf/cards/aliases.conf
|
||||||
|
index 18a920f..2c422ee 100644
|
||||||
|
--- a/src/conf/cards/aliases.conf
|
||||||
|
+++ b/src/conf/cards/aliases.conf
|
||||||
|
@@ -57,6 +57,8 @@ CMI8786 cards.CMI8788
|
||||||
|
CMI8787 cards.CMI8788
|
||||||
|
pistachio cards.pistachio-card
|
||||||
|
VC4-HDMI cards.vc4-hdmi
|
||||||
|
+imx-cs42888 cards.CS42888
|
||||||
|
+imx-hdmi-soc cards.IMX-HDMI
|
||||||
|
|
||||||
|
<confdir:pcm/default.conf>
|
||||||
|
<confdir:pcm/dmix.conf>
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
From 67be50a9d95c8659d4821d0cd8c228e4f57b2c32 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jaroslav Kysela <perex@perex.cz>
|
||||||
|
Date: Wed, 30 Dec 2020 09:31:10 +0100
|
||||||
|
Subject: [PATCH 1/2] pcm: plugin status - fix the return value (regression)
|
||||||
|
|
||||||
|
The snd_pcm_plugin_avail_update() error code in snd_pcm_plugin_status()
|
||||||
|
should not be reported to the caller. The state errors can be determined
|
||||||
|
using the state member in the status structure.
|
||||||
|
|
||||||
|
Fixes: 4f90392f07e ("pcm: fix the snd_pcm_plugin_status() avail and delay fields")
|
||||||
|
BugLink: https://github.com/alsa-project/alsa-lib/issues/107
|
||||||
|
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||||
|
---
|
||||||
|
src/pcm/pcm_plugin.c | 8 +++-----
|
||||||
|
1 file changed, 3 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
|
||||||
|
index 5739cfc2eb07..76a524fa801d 100644
|
||||||
|
--- a/src/pcm/pcm_plugin.c
|
||||||
|
+++ b/src/pcm/pcm_plugin.c
|
||||||
|
@@ -541,19 +541,17 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
|
||||||
|
static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
||||||
|
{
|
||||||
|
snd_pcm_plugin_t *plugin = pcm->private_data;
|
||||||
|
- snd_pcm_sframes_t err, avail;
|
||||||
|
+ snd_pcm_sframes_t err;
|
||||||
|
|
||||||
|
/* sync with the latest hw and appl ptrs */
|
||||||
|
- avail = snd_pcm_plugin_avail_update(pcm);
|
||||||
|
- if (avail < 0)
|
||||||
|
- return avail;
|
||||||
|
+ snd_pcm_plugin_avail_update(pcm);
|
||||||
|
|
||||||
|
err = snd_pcm_status(plugin->gen.slave, status);
|
||||||
|
if (err < 0)
|
||||||
|
return err;
|
||||||
|
status->appl_ptr = *pcm->appl.ptr;
|
||||||
|
status->hw_ptr = *pcm->hw.ptr;
|
||||||
|
- status->avail = avail;
|
||||||
|
+ status->avail = snd_pcm_mmap_avail(pcm);
|
||||||
|
status->delay = snd_pcm_mmap_delay(pcm);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
@ -0,0 +1,34 @@
|
||||||
|
From eeea1c8c352e54908f464e8dfd7a06b0f7ce0e6e Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jaroslav Kysela <perex@perex.cz>
|
||||||
|
Date: Sun, 3 Jan 2021 16:16:10 +0100
|
||||||
|
Subject: [PATCH 2/2] pcm: plugin status - revert the recent changes
|
||||||
|
|
||||||
|
It's no reason to sync the avail/delay fields using the mirrored
|
||||||
|
buffer pointers. The slave information must be valid.
|
||||||
|
|
||||||
|
The original report probably tries to fix something for
|
||||||
|
the specific plugin. Revert all changes.
|
||||||
|
|
||||||
|
Fixes: afe6ff3b33e ("pcm: plugin status - fix the return value (regression)")
|
||||||
|
Fixes: 4f90392f07e ("pcm: fix the snd_pcm_plugin_status() avail and delay fields")
|
||||||
|
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
|
||||||
|
---
|
||||||
|
src/pcm/pcm_plugin.c | 2 --
|
||||||
|
1 file changed, 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/pcm/pcm_plugin.c b/src/pcm/pcm_plugin.c
|
||||||
|
index 76a524fa801d..ea60eb98986e 100644
|
||||||
|
--- a/src/pcm/pcm_plugin.c
|
||||||
|
+++ b/src/pcm/pcm_plugin.c
|
||||||
|
@@ -551,8 +551,6 @@ static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
|
||||||
|
return err;
|
||||||
|
status->appl_ptr = *pcm->appl.ptr;
|
||||||
|
status->hw_ptr = *pcm->hw.ptr;
|
||||||
|
- status->avail = snd_pcm_mmap_avail(pcm);
|
||||||
|
- status->delay = snd_pcm_mmap_delay(pcm);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
@ -0,0 +1,123 @@
|
||||||
|
From 1641ce8c724018365d7fa598f9a70c6492e7c271 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shengjiu Wang <shengjiu.wang@nxp.com>
|
||||||
|
Date: Wed, 31 Jan 2018 15:06:53 +0800
|
||||||
|
Subject: [PATCH] add ak4458 conf for multichannel support
|
||||||
|
|
||||||
|
one limitation is that ALSA and pulseaudio only support
|
||||||
|
maximum 8 channels, but ak4458 may support 16 channels
|
||||||
|
|
||||||
|
Upstream-Status: Inappropriate [i.MX specific]
|
||||||
|
|
||||||
|
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
|
||||||
|
---
|
||||||
|
src/conf/cards/AK4458.conf | 74 +++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
src/conf/cards/Makefile.am | 3 +-
|
||||||
|
src/conf/cards/aliases.conf | 1 +
|
||||||
|
3 files changed, 77 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100644 src/conf/cards/AK4458.conf
|
||||||
|
|
||||||
|
Index: alsa-lib-1.1.6/src/conf/cards/AK4458.conf
|
||||||
|
===================================================================
|
||||||
|
--- /dev/null
|
||||||
|
+++ alsa-lib-1.1.6/src/conf/cards/AK4458.conf
|
||||||
|
@@ -0,0 +1,74 @@
|
||||||
|
+#
|
||||||
|
+# Configuration for the AK4458 chip
|
||||||
|
+#
|
||||||
|
+
|
||||||
|
+# default with dmix & dsnoop
|
||||||
|
+AK4458.pcm.default {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type asym
|
||||||
|
+ playback.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dmix:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ capture.pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "dsnoop:" $CARD ",FORMAT=S32_LE" ]
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround40.conf>
|
||||||
|
+
|
||||||
|
+AK4458.pcm.surround40.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 4
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround41.conf>
|
||||||
|
+<confdir:pcm/surround50.conf>
|
||||||
|
+<confdir:pcm/surround51.conf>
|
||||||
|
+
|
||||||
|
+AK4458.pcm.surround51.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 6
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/surround71.conf>
|
||||||
|
+
|
||||||
|
+AK4458.pcm.surround71.0 {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD {
|
||||||
|
+ type string
|
||||||
|
+ }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ slave.channels 8
|
||||||
|
+}
|
||||||
|
Index: alsa-lib-1.1.6/src/conf/cards/Makefile.am
|
||||||
|
===================================================================
|
||||||
|
--- alsa-lib-1.1.6.orig/src/conf/cards/Makefile.am
|
||||||
|
+++ alsa-lib-1.1.6/src/conf/cards/Makefile.am
|
||||||
|
@@ -60,7 +60,8 @@ cfg_files = aliases.conf \
|
||||||
|
VXPocket.conf \
|
||||||
|
VXPocket440.conf \
|
||||||
|
CS42888.conf \
|
||||||
|
- IMX-HDMI.conf
|
||||||
|
+ IMX-HDMI.conf \
|
||||||
|
+ AK4458.conf
|
||||||
|
|
||||||
|
if BUILD_ALISP
|
||||||
|
cfg_files += aliases.alisp
|
||||||
|
Index: alsa-lib-1.1.6/src/conf/cards/aliases.conf
|
||||||
|
===================================================================
|
||||||
|
--- alsa-lib-1.1.6.orig/src/conf/cards/aliases.conf
|
||||||
|
+++ alsa-lib-1.1.6/src/conf/cards/aliases.conf
|
||||||
|
@@ -59,6 +59,7 @@ pistachio cards.pistachio-card
|
||||||
|
VC4-HDMI cards.vc4-hdmi
|
||||||
|
imx-cs42888 cards.CS42888
|
||||||
|
imx-hdmi-soc cards.IMX-HDMI
|
||||||
|
+ak4458-audio cards.AK4458
|
||||||
|
|
||||||
|
<confdir:pcm/default.conf>
|
||||||
|
<confdir:pcm/dmix.conf>
|
||||||
|
|
@ -0,0 +1,89 @@
|
||||||
|
From d2be0f650f9fec265f0f0b4ba646a157f2a4cb7c Mon Sep 17 00:00:00 2001
|
||||||
|
From: Viorel Suman <viorel.suman@nxp.com>
|
||||||
|
Date: Mon, 9 Mar 2020 14:25:46 +0200
|
||||||
|
Subject: [PATCH] add conf for iMX XCVR sound card
|
||||||
|
|
||||||
|
Upstream Status: Pending
|
||||||
|
|
||||||
|
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
|
||||||
|
---
|
||||||
|
src/conf/cards/IMX-XCVR.conf | 39 +++++++++++++++++++++++++++++++++++++++
|
||||||
|
src/conf/cards/Makefile.am | 3 ++-
|
||||||
|
src/conf/cards/aliases.conf | 1 +
|
||||||
|
3 files changed, 42 insertions(+), 1 deletion(-)
|
||||||
|
create mode 100755 src/conf/cards/IMX-XCVR.conf
|
||||||
|
|
||||||
|
diff --git a/src/conf/cards/IMX-XCVR.conf b/src/conf/cards/IMX-XCVR.conf
|
||||||
|
new file mode 100755
|
||||||
|
index 0000000..009000c
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/conf/cards/IMX-XCVR.conf
|
||||||
|
@@ -0,0 +1,39 @@
|
||||||
|
+#
|
||||||
|
+# Configuration for the IMX-XCVR sound card using software IEC958
|
||||||
|
+# subframe conversion
|
||||||
|
+#
|
||||||
|
+IMX-XCVR.pcm.default {
|
||||||
|
+ @args [ CARD ]
|
||||||
|
+ @args.CARD { type string }
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ @func concat
|
||||||
|
+ strings [ "iec958:" $CARD ]
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+<confdir:pcm/iec958.conf>
|
||||||
|
+
|
||||||
|
+IMX-XCVR.pcm.iec958.0 {
|
||||||
|
+ @args [ CARD AES0 AES1 AES2 AES3 ]
|
||||||
|
+ @args.CARD { type string }
|
||||||
|
+ @args.AES0 { type integer }
|
||||||
|
+ @args.AES1 { type integer }
|
||||||
|
+ @args.AES2 { type integer }
|
||||||
|
+ @args.AES3 { type integer }
|
||||||
|
+ type iec958
|
||||||
|
+ slave {
|
||||||
|
+ format IEC958_SUBFRAME_LE
|
||||||
|
+ pcm {
|
||||||
|
+ type plug
|
||||||
|
+ slave.pcm {
|
||||||
|
+ type hw
|
||||||
|
+ card $CARD
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ status [ $AES0 $AES1 $AES2 $AES3 ]
|
||||||
|
+ preamble.z 0x0
|
||||||
|
+ preamble.x 0x1
|
||||||
|
+ preamble.y 0x3
|
||||||
|
+}
|
||||||
|
diff --git a/src/conf/cards/Makefile.am b/src/conf/cards/Makefile.am
|
||||||
|
index 34fa5a3..70b9bab 100644
|
||||||
|
--- a/src/conf/cards/Makefile.am
|
||||||
|
+++ b/src/conf/cards/Makefile.am
|
||||||
|
@@ -61,7 +61,8 @@ cfg_files = aliases.conf \
|
||||||
|
VXPocket440.conf \
|
||||||
|
CS42888.conf \
|
||||||
|
IMX-HDMI.conf \
|
||||||
|
- AK4458.conf
|
||||||
|
+ AK4458.conf \
|
||||||
|
+ IMX-XCVR.conf
|
||||||
|
|
||||||
|
if BUILD_ALISP
|
||||||
|
cfg_files += aliases.alisp
|
||||||
|
diff --git a/src/conf/cards/aliases.conf b/src/conf/cards/aliases.conf
|
||||||
|
index 5d92ac7..c195848 100644
|
||||||
|
--- a/src/conf/cards/aliases.conf
|
||||||
|
+++ b/src/conf/cards/aliases.conf
|
||||||
|
@@ -60,6 +60,7 @@ VC4-HDMI cards.vc4-hdmi
|
||||||
|
imx-cs42888 cards.CS42888
|
||||||
|
imx-hdmi-soc cards.IMX-HDMI
|
||||||
|
ak4458-audio cards.AK4458
|
||||||
|
+imx-audio-xcvr cards.IMX-XCVR
|
||||||
|
|
||||||
|
<confdir:pcm/default.conf>
|
||||||
|
<confdir:pcm/dmix.conf>
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
|
||||||
|
|
||||||
|
IMX_PATCH += " \
|
||||||
|
file://0001-pcm-plugin-status-fix-the-return-value-regression.patch \
|
||||||
|
file://0002-pcm-plugin-status-revert-the-recent-changes.patch \
|
||||||
|
"
|
||||||
|
|
||||||
|
PACKAGE_ARCH_imx = "${TUNE_PKGARCH}"
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
# Copyright (C) 2017 Digi International.
|
||||||
|
|
||||||
|
SUMMARY = "DEY sound card detection app"
|
||||||
|
SECTION = "multimedia"
|
||||||
|
LICENSE = "MPL-2.0"
|
||||||
|
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MPL-2.0;md5=815ca599c9df247a0c7f619bab123dad"
|
||||||
|
|
||||||
|
DEPENDS = "alsa-lib"
|
||||||
|
|
||||||
|
SRC_URI = "file://card-detect.c"
|
||||||
|
|
||||||
|
S = "${WORKDIR}"
|
||||||
|
|
||||||
|
inherit pkgconfig
|
||||||
|
|
||||||
|
export CFLAGS += "`pkg-config --cflags alsa`"
|
||||||
|
export LDLIBS += "`pkg-config --libs alsa`"
|
||||||
|
|
||||||
|
do_configure[noexec] = "1"
|
||||||
|
|
||||||
|
do_compile() {
|
||||||
|
oe_runmake card-detect
|
||||||
|
}
|
||||||
|
|
||||||
|
do_install() {
|
||||||
|
install -d ${D}${bindir}
|
||||||
|
install -m 0755 card-detect ${D}${bindir}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2017 Digi International Inc.
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
|
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||||
|
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||||
|
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||||
|
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||||
|
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int len, ret = EXIT_SUCCESS;
|
||||||
|
snd_pcm_t *handle;
|
||||||
|
char *device;
|
||||||
|
|
||||||
|
if (argc < 2) {
|
||||||
|
printf("Usage: %s [CARD NUMBER]\n", argv[0]);
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen("hw:") + strlen(argv[1]) + 1;
|
||||||
|
device = calloc(1, len);
|
||||||
|
snprintf(device, len, "hw:%s", argv[1]);
|
||||||
|
|
||||||
|
/* Open the PCM-device in playback mode */
|
||||||
|
if (snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, 0) < 0) {
|
||||||
|
printf("Could't open PCM '%s'\n", device);
|
||||||
|
ret = EXIT_FAILURE;
|
||||||
|
} else {
|
||||||
|
printf("Device %s opened successfully\n", device);
|
||||||
|
snd_pcm_close(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(device);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Copyright (C) 2019 Digi International
|
# Copyright (C) 2019-2022 Digi International
|
||||||
|
|
||||||
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
FILESEXTRAPATHS_prepend := "${THISDIR}/${BPN}:"
|
||||||
|
|
||||||
|
|
@ -40,6 +40,10 @@ SRC_URI_append_ccimx6ulsbc = " \
|
||||||
file://0001-pulseaudio-keep-headphones-volume-in-platforms-witho.patch \
|
file://0001-pulseaudio-keep-headphones-volume-in-platforms-witho.patch \
|
||||||
"
|
"
|
||||||
|
|
||||||
|
SRC_URI_append_ccmp15 = " \
|
||||||
|
file://0001-pulseaudio-keep-headphones-volume-in-platforms-witho.patch \
|
||||||
|
"
|
||||||
|
|
||||||
# This default setting should be added on all i.MX SoC,
|
# This default setting should be added on all i.MX SoC,
|
||||||
# For now, the setting for mx6(including mx6ul & mx6sll)/mx7 has been upstreamed
|
# For now, the setting for mx6(including mx6ul & mx6sll)/mx7 has been upstreamed
|
||||||
SRC_URI_append_mx8 = " \
|
SRC_URI_append_mx8 = " \
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,221 @@
|
||||||
|
From 4d4bc0a958fe254531920095fbabc241aad88113 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Shengjiu Wang <shengjiu.wang@nxp.com>
|
||||||
|
Date: Tue, 28 Jul 2020 13:00:36 +0800
|
||||||
|
Subject: [PATCH] cplay: Support wave file
|
||||||
|
|
||||||
|
The supported format is mono/stereo, S16_LE/S32_LE, 8kHz-192kHz.
|
||||||
|
Command is:
|
||||||
|
cplay -c x -I PCM test.wav
|
||||||
|
|
||||||
|
Upstream-Status: Inappropriate [i.MX specific]
|
||||||
|
Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
|
||||||
|
---
|
||||||
|
include/tinycompress/wave_formats.h | 51 +++++++++++++
|
||||||
|
src/utils/cplay.c | 107 ++++++++++++++++++++++++++++
|
||||||
|
2 files changed, 158 insertions(+)
|
||||||
|
create mode 100644 include/tinycompress/wave_formats.h
|
||||||
|
|
||||||
|
diff --git a/include/tinycompress/wave_formats.h b/include/tinycompress/wave_formats.h
|
||||||
|
new file mode 100644
|
||||||
|
index 000000000000..4e2e009206cf
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/include/tinycompress/wave_formats.h
|
||||||
|
@@ -0,0 +1,51 @@
|
||||||
|
+#ifndef WAVE_FORMATS_H
|
||||||
|
+#define WAVE_FORMATS_H 1
|
||||||
|
+
|
||||||
|
+#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
|
||||||
|
+
|
||||||
|
+#define WAV_RIFF COMPOSE_ID('R','I','F','F')
|
||||||
|
+#define WAV_RIFX COMPOSE_ID('R','I','F','X')
|
||||||
|
+#define WAV_WAVE COMPOSE_ID('W','A','V','E')
|
||||||
|
+#define WAV_FMT COMPOSE_ID('f','m','t',' ')
|
||||||
|
+#define WAV_DATA COMPOSE_ID('d','a','t','a')
|
||||||
|
+
|
||||||
|
+/* WAVE fmt block constants from Microsoft mmreg.h header */
|
||||||
|
+#define WAV_FMT_PCM 0x0001
|
||||||
|
+#define WAV_FMT_IEEE_FLOAT 0x0003
|
||||||
|
+#define WAV_FMT_DOLBY_AC3_SPDIF 0x0092
|
||||||
|
+#define WAV_FMT_EXTENSIBLE 0xfffe
|
||||||
|
+
|
||||||
|
+/* Used with WAV_FMT_EXTENSIBLE format */
|
||||||
|
+#define WAV_GUID_TAG "\x00\x00\x00\x00\x10\x00\x80\x00\x00\xAA\x00\x38\x9B\x71"
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ u_int magic; /* 'RIFF' */
|
||||||
|
+ u_int length; /* filelen */
|
||||||
|
+ u_int type; /* 'WAVE' */
|
||||||
|
+} WaveHeader;
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ u_short format; /* see WAV_FMT_* */
|
||||||
|
+ u_short channels;
|
||||||
|
+ u_int sample_fq; /* frequence of sample */
|
||||||
|
+ u_int byte_p_sec;
|
||||||
|
+ u_short byte_p_spl; /* samplesize; 1 or 2 bytes */
|
||||||
|
+ u_short bit_p_spl; /* 8, 12 or 16 bit */
|
||||||
|
+} WaveFmtBody;
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ WaveFmtBody format;
|
||||||
|
+ u_short ext_size;
|
||||||
|
+ u_short bit_p_spl;
|
||||||
|
+ u_int channel_mask;
|
||||||
|
+ u_short guid_format; /* WAV_FMT_* */
|
||||||
|
+ u_char guid_tag[14]; /* WAV_GUID_TAG */
|
||||||
|
+} WaveFmtExtensibleBody;
|
||||||
|
+
|
||||||
|
+typedef struct {
|
||||||
|
+ u_int type; /* 'data' */
|
||||||
|
+ u_int length; /* samplecount */
|
||||||
|
+} WaveChunkHeader;
|
||||||
|
+
|
||||||
|
+
|
||||||
|
+#endif /* FORMATS */
|
||||||
|
diff --git a/src/utils/cplay.c b/src/utils/cplay.c
|
||||||
|
index 5b749419e731..8882f4d9746d 100644
|
||||||
|
--- a/src/utils/cplay.c
|
||||||
|
+++ b/src/utils/cplay.c
|
||||||
|
@@ -1,4 +1,6 @@
|
||||||
|
/*
|
||||||
|
+ * Copyright 2020 NXP
|
||||||
|
+ *
|
||||||
|
* This file is provided under a dual BSD/LGPLv2.1 license. When using or
|
||||||
|
* redistributing this file, you may do so under either license.
|
||||||
|
*
|
||||||
|
@@ -73,6 +75,8 @@
|
||||||
|
#include "tinycompress/tinycompress.h"
|
||||||
|
#include "tinycompress/tinymp3.h"
|
||||||
|
#include "tinycompress/id3_tag_decode.h"
|
||||||
|
+#include "tinycompress/wave_formats.h"
|
||||||
|
+#include <alsa/asoundlib.h>
|
||||||
|
|
||||||
|
static int verbose;
|
||||||
|
static const unsigned int DEFAULT_CODEC_ID = SND_AUDIOCODEC_PCM;
|
||||||
|
@@ -166,6 +170,77 @@ static int parse_mp3_header(struct mp3_header *header, unsigned int *num_channel
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static int parse_wav_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate,
|
||||||
|
+ unsigned int *format) {
|
||||||
|
+ WaveHeader wave_header;
|
||||||
|
+ WaveChunkHeader chunk_header;
|
||||||
|
+ WaveFmtBody fmt_body;
|
||||||
|
+ int more_chunks = 1;
|
||||||
|
+
|
||||||
|
+ fread(&wave_header, sizeof(WaveHeader), 1, file);
|
||||||
|
+ if ((wave_header.magic != WAV_RIFF) ||
|
||||||
|
+ (wave_header.type != WAV_WAVE)) {
|
||||||
|
+ fprintf(stderr, "Error: it is not a riff/wave file\n");
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ do {
|
||||||
|
+ fread(&chunk_header, sizeof(WaveChunkHeader), 1, file);
|
||||||
|
+ switch (chunk_header.type) {
|
||||||
|
+ case WAV_FMT:
|
||||||
|
+ fread(&fmt_body, sizeof(WaveFmtBody), 1, file);
|
||||||
|
+ /* If the format header is larger, skip the rest */
|
||||||
|
+ if (chunk_header.length > sizeof(WaveFmtBody))
|
||||||
|
+ fseek(file, chunk_header.length - sizeof(WaveFmtBody), SEEK_CUR);
|
||||||
|
+
|
||||||
|
+ *num_channels = fmt_body.channels;
|
||||||
|
+ *sample_rate = fmt_body.sample_fq;
|
||||||
|
+
|
||||||
|
+ switch (fmt_body.bit_p_spl) {
|
||||||
|
+ case 8:
|
||||||
|
+ *format = SND_PCM_FORMAT_U8;
|
||||||
|
+ break;
|
||||||
|
+ case 16:
|
||||||
|
+ *format = SND_PCM_FORMAT_S16_LE;
|
||||||
|
+ break;
|
||||||
|
+ case 24:
|
||||||
|
+ switch (fmt_body.byte_p_spl / fmt_body.channels) {
|
||||||
|
+ case 3:
|
||||||
|
+ *format = SND_PCM_FORMAT_S24_3LE;
|
||||||
|
+ break;
|
||||||
|
+ case 4:
|
||||||
|
+ *format = SND_PCM_FORMAT_S24_LE;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ fprintf(stderr, "format error\n");
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case 32:
|
||||||
|
+ if (fmt_body.format == WAV_FMT_PCM) {
|
||||||
|
+ *format = SND_PCM_FORMAT_S32_LE;
|
||||||
|
+ } else if (fmt_body.format == WAV_FMT_IEEE_FLOAT) {
|
||||||
|
+ *format = SND_PCM_FORMAT_FLOAT_LE;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ fprintf(stderr, "format error\n");
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case WAV_DATA:
|
||||||
|
+ /* Stop looking for chunks */
|
||||||
|
+ more_chunks = 0;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ /* Unknown chunk, skip bytes */
|
||||||
|
+ fseek(file, chunk_header.length, SEEK_CUR);
|
||||||
|
+ }
|
||||||
|
+ } while (more_chunks);
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int print_time(struct compress *compress)
|
||||||
|
{
|
||||||
|
unsigned int avail;
|
||||||
|
@@ -385,6 +460,35 @@ void get_codec_iec(FILE *file, struct compr_config *config,
|
||||||
|
codec->format = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void get_codec_pcm(FILE *file, struct compr_config *config,
|
||||||
|
+ struct snd_codec *codec)
|
||||||
|
+{
|
||||||
|
+ unsigned int channels, rate, format;
|
||||||
|
+
|
||||||
|
+ if (parse_wav_header(file, &channels, &rate, &format) == -1) {
|
||||||
|
+ fclose(file);
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (channels > 2 || (format != SND_PCM_FORMAT_S16_LE && format != SND_PCM_FORMAT_S32_LE) ||
|
||||||
|
+ rate > 192000) {
|
||||||
|
+ fprintf(stderr, "unsupported wave file\n");
|
||||||
|
+ fclose(file);
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ codec->id = SND_AUDIOCODEC_PCM;
|
||||||
|
+ codec->ch_in = channels;
|
||||||
|
+ codec->ch_out = channels;
|
||||||
|
+ codec->sample_rate = rate;
|
||||||
|
+ codec->bit_rate = 0;
|
||||||
|
+ codec->rate_control = 0;
|
||||||
|
+ codec->profile = SND_AUDIOPROFILE_PCM;
|
||||||
|
+ codec->level = 0;
|
||||||
|
+ codec->ch_mode = 0;
|
||||||
|
+ codec->format = format;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
unsigned long buffer_size, unsigned int frag,
|
||||||
|
unsigned long codec_id)
|
||||||
|
@@ -411,6 +515,9 @@ void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
case SND_AUDIOCODEC_IEC61937:
|
||||||
|
get_codec_iec(file, &config, &codec);
|
||||||
|
break;
|
||||||
|
+ case SND_AUDIOCODEC_PCM:
|
||||||
|
+ get_codec_pcm(file, &config, &codec);
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "codec ID %ld is not supported\n", codec_id);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
--
|
||||||
|
2.27.0
|
||||||
|
|
||||||
|
|
@ -0,0 +1,147 @@
|
||||||
|
From 6f778c21ee357a662cdd758cff578a3e4b85eedf Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhang Peng <peng.zhang_8@nxp.com>
|
||||||
|
Date: Tue, 4 Aug 2020 15:29:29 +0800
|
||||||
|
Subject: [PATCH] cplay: Add pause feature
|
||||||
|
|
||||||
|
Add option: -p pause
|
||||||
|
|
||||||
|
Upstream-Status: Inappropriate [i.MX specific]
|
||||||
|
|
||||||
|
Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
|
||||||
|
---
|
||||||
|
src/utils/cplay.c | 56 +++++++++++++++++++++++++++++++++++++++++++----
|
||||||
|
1 file changed, 52 insertions(+), 4 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/utils/cplay.c b/src/utils/cplay.c
|
||||||
|
index 8882f4d..8e3dcbb 100644
|
||||||
|
--- a/src/utils/cplay.c
|
||||||
|
+++ b/src/utils/cplay.c
|
||||||
|
@@ -117,6 +117,9 @@ static void usage(void)
|
||||||
|
"-f\tfragments\n\n"
|
||||||
|
"-v\tverbose mode\n"
|
||||||
|
"-h\tPrints this help list\n\n"
|
||||||
|
+ "-p\tpause\n"
|
||||||
|
+ "-m\tpause blocks\n"
|
||||||
|
+ "-n\tpause time duration\n"
|
||||||
|
"Example:\n"
|
||||||
|
"\tcplay -c 1 -d 2 test.mp3\n"
|
||||||
|
"\tcplay -f 5 test.mp3\n\n"
|
||||||
|
@@ -133,7 +136,8 @@ static void usage(void)
|
||||||
|
|
||||||
|
void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
unsigned long buffer_size, unsigned int frag,
|
||||||
|
- unsigned long codec_id);
|
||||||
|
+ unsigned long codec_id, int pause_count, int pause_block,
|
||||||
|
+ int pause_duration);
|
||||||
|
|
||||||
|
struct mp3_header {
|
||||||
|
uint16_t sync;
|
||||||
|
@@ -262,12 +266,15 @@ int main(int argc, char **argv)
|
||||||
|
int c, i;
|
||||||
|
unsigned int card = 0, device = 0, frag = 0;
|
||||||
|
unsigned int codec_id = SND_AUDIOCODEC_MP3;
|
||||||
|
+ int pause_count = 0;
|
||||||
|
+ int pause_block = 6;
|
||||||
|
+ int pause_duration = 10;
|
||||||
|
|
||||||
|
if (argc < 2)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
verbose = 0;
|
||||||
|
- while ((c = getopt(argc, argv, "hvb:f:c:d:I:")) != -1) {
|
||||||
|
+ while ((c = getopt(argc, argv, "hvb:f:c:d:I:p:m:n:")) != -1) {
|
||||||
|
switch (c) {
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
@@ -306,6 +313,23 @@ int main(int argc, char **argv)
|
||||||
|
case 'v':
|
||||||
|
verbose = 1;
|
||||||
|
break;
|
||||||
|
+ case 'p':
|
||||||
|
+ pause_count = strtol(optarg, NULL, 10);
|
||||||
|
+ break;
|
||||||
|
+ case 'm':
|
||||||
|
+ pause_block = strtol(optarg, NULL, 10);
|
||||||
|
+ if (pause_duration < 0) {
|
||||||
|
+ printf("Set wrong paramter! Set duration default 6.\n");
|
||||||
|
+ pause_duration = 6;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
+ case 'n':
|
||||||
|
+ pause_duration = strtol(optarg, NULL, 10);
|
||||||
|
+ if (pause_duration < 0) {
|
||||||
|
+ printf("Set wrong paramter! Set duration default 10.\n");
|
||||||
|
+ pause_duration = 10;
|
||||||
|
+ }
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
@@ -315,7 +339,7 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
|
file = argv[optind];
|
||||||
|
|
||||||
|
- play_samples(file, card, device, buffer_size, frag, codec_id);
|
||||||
|
+ play_samples(file, card, device, buffer_size, frag, codec_id, pause_count, pause_block, pause_duration);
|
||||||
|
|
||||||
|
fprintf(stderr, "Finish Playing.... Close Normally\n");
|
||||||
|
exit(EXIT_SUCCESS);
|
||||||
|
@@ -491,7 +515,8 @@ void get_codec_pcm(FILE *file, struct compr_config *config,
|
||||||
|
|
||||||
|
void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
unsigned long buffer_size, unsigned int frag,
|
||||||
|
- unsigned long codec_id)
|
||||||
|
+ unsigned long codec_id, int pause_count, int pause_block,
|
||||||
|
+ int pause_duration)
|
||||||
|
{
|
||||||
|
struct compr_config config;
|
||||||
|
struct snd_codec codec;
|
||||||
|
@@ -499,6 +524,7 @@ void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
FILE *file;
|
||||||
|
char *buffer;
|
||||||
|
int size, num_read, wrote;
|
||||||
|
+ int write_count = 0;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: entry\n", __func__);
|
||||||
|
@@ -574,6 +600,13 @@ void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: You should hear audio NOW!!!\n", __func__);
|
||||||
|
|
||||||
|
+ if (pause_count > 0) {
|
||||||
|
+ printf("sleep...\n");
|
||||||
|
+ compress_pause(compress);
|
||||||
|
+ sleep(pause_duration);
|
||||||
|
+ compress_resume(compress);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
do {
|
||||||
|
num_read = fread(buffer, 1, size, file);
|
||||||
|
if (num_read > 0) {
|
||||||
|
@@ -592,8 +625,23 @@ void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
printf("%s: wrote %d\n", __func__, wrote);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
+ write_count++;
|
||||||
|
+ if ((pause_count > 0) && (write_count % pause_block == 0)) {
|
||||||
|
+ printf("pause...\n");
|
||||||
|
+ compress_pause(compress);
|
||||||
|
+ sleep(pause_duration);
|
||||||
|
+ printf("pause release...\n");
|
||||||
|
+ compress_resume(compress);
|
||||||
|
+ pause_count--;
|
||||||
|
+ }
|
||||||
|
} while (num_read > 0);
|
||||||
|
|
||||||
|
+ if (pause_count > 0) {
|
||||||
|
+ compress_pause(compress);
|
||||||
|
+ sleep(5);
|
||||||
|
+ compress_resume(compress);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (verbose)
|
||||||
|
printf("%s: exit success\n", __func__);
|
||||||
|
/* issue drain if it supports */
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
From a2892bf5db7520689fa9cb1d1589fa804bd9dc1a Mon Sep 17 00:00:00 2001
|
||||||
|
From: Bing Song <bing.song@nxp.com>
|
||||||
|
Date: Tue, 18 Aug 2020 15:26:51 +0800
|
||||||
|
Subject: [PATCH] tinycompress: pass NULL buffer with 0 size to driver.
|
||||||
|
|
||||||
|
The NULL buffer with 0 size to indecate driver drain input data with
|
||||||
|
non-block mode. The defaul drain is block mode.
|
||||||
|
|
||||||
|
upstream status: imx specific
|
||||||
|
|
||||||
|
Signed-off-by: Bing Song <bing.song@nxp.com>
|
||||||
|
---
|
||||||
|
src/lib/compress.c | 5 +++--
|
||||||
|
1 file changed, 3 insertions(+), 2 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/lib/compress.c b/src/lib/compress.c
|
||||||
|
index bba4fcf..d66df0b 100644
|
||||||
|
--- a/src/lib/compress.c
|
||||||
|
+++ b/src/lib/compress.c
|
||||||
|
@@ -315,7 +315,8 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
|
||||||
|
fds.events = POLLOUT;
|
||||||
|
|
||||||
|
/*TODO: treat auto start here first */
|
||||||
|
- while (size) {
|
||||||
|
+ /* NULL buffer with 0 size for non-block drain */
|
||||||
|
+ do {
|
||||||
|
if (ioctl(compress->fd, SNDRV_COMPRESS_AVAIL, &avail))
|
||||||
|
return oops(compress, errno, "cannot get avail");
|
||||||
|
|
||||||
|
@@ -357,7 +358,7 @@ int compress_write(struct compress *compress, const void *buf, unsigned int size
|
||||||
|
size -= written;
|
||||||
|
cbuf += written;
|
||||||
|
total += written;
|
||||||
|
- }
|
||||||
|
+ } while (size);
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
||||||
|
|
@ -0,0 +1,252 @@
|
||||||
|
From 2912f8573cea25fbd38ac7a8b68af2ea6a05e599 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Zhang Peng <peng.zhang_8@nxp.com>
|
||||||
|
Date: Wed, 28 Oct 2020 19:08:53 +0800
|
||||||
|
Subject: [PATCH] cplay: Support aac streams
|
||||||
|
|
||||||
|
Support run aac format streams for cplay.
|
||||||
|
|
||||||
|
upstream status: imx specific
|
||||||
|
|
||||||
|
Signed-off-by: Zhang Peng <peng.zhang_8@nxp.com>
|
||||||
|
---
|
||||||
|
src/utils/cplay.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++
|
||||||
|
1 file changed, 210 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/utils/cplay.c b/src/utils/cplay.c
|
||||||
|
index 8e3dcbb..2a1464a 100644
|
||||||
|
--- a/src/utils/cplay.c
|
||||||
|
+++ b/src/utils/cplay.c
|
||||||
|
@@ -245,6 +245,190 @@ static int parse_wav_header(FILE *file, unsigned int *num_channels, unsigned int
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+int find_adts_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+ unsigned char buf[5];
|
||||||
|
+
|
||||||
|
+ ret = fread(buf, sizeof(buf), 1, file);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ fprintf(stderr, "open file error: %d\n", ret);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ fseek(file, 0, SEEK_SET);
|
||||||
|
+
|
||||||
|
+ if ((buf[0] != 0xff) || (buf[1] & 0xf0 != 0xf0))
|
||||||
|
+ return 0;
|
||||||
|
+ /* mpeg id */
|
||||||
|
+ switch (buf[1]>>3 & 0x1) {
|
||||||
|
+ case 0x0:
|
||||||
|
+ *format = SND_AUDIOSTREAMFORMAT_MP4ADTS;
|
||||||
|
+ break;
|
||||||
|
+ case 0x1:
|
||||||
|
+ *format = SND_AUDIOSTREAMFORMAT_MP2ADTS;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ fprintf(stderr, "can't find stream format\n");
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ /* sample_rate */
|
||||||
|
+ switch (buf[2]>>2 & 0xf) {
|
||||||
|
+ case 0x0:
|
||||||
|
+ *sample_rate = 96000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x1:
|
||||||
|
+ *sample_rate = 88200;
|
||||||
|
+ break;
|
||||||
|
+ case 0x2:
|
||||||
|
+ *sample_rate = 64000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x3:
|
||||||
|
+ *sample_rate = 48000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x4:
|
||||||
|
+ *sample_rate = 44100;
|
||||||
|
+ break;
|
||||||
|
+ case 0x5:
|
||||||
|
+ *sample_rate = 32000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x6:
|
||||||
|
+ *sample_rate = 24000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x7:
|
||||||
|
+ *sample_rate = 22050;
|
||||||
|
+ break;
|
||||||
|
+ case 0x8:
|
||||||
|
+ *sample_rate = 16000;
|
||||||
|
+ break;
|
||||||
|
+ case 0x9:
|
||||||
|
+ *sample_rate = 12000;
|
||||||
|
+ break;
|
||||||
|
+ case 0xa:
|
||||||
|
+ *sample_rate = 11025;
|
||||||
|
+ break;
|
||||||
|
+ case 0xb:
|
||||||
|
+ *sample_rate = 8000;
|
||||||
|
+ break;
|
||||||
|
+ case 0xc:
|
||||||
|
+ *sample_rate = 7350;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ /* channel */
|
||||||
|
+ switch (((buf[2]&0x1) << 2) | (buf[3]>>6)) {
|
||||||
|
+ case 1:
|
||||||
|
+ *num_channels = 1;
|
||||||
|
+ break;
|
||||||
|
+ case 2:
|
||||||
|
+ *num_channels = 2;
|
||||||
|
+ break;
|
||||||
|
+ case 3:
|
||||||
|
+ *num_channels = 3;
|
||||||
|
+ break;
|
||||||
|
+ case 4:
|
||||||
|
+ *num_channels = 4;
|
||||||
|
+ break;
|
||||||
|
+ case 5:
|
||||||
|
+ *num_channels = 5;
|
||||||
|
+ break;
|
||||||
|
+ case 6:
|
||||||
|
+ *num_channels = 6;
|
||||||
|
+ break;
|
||||||
|
+ case 7:
|
||||||
|
+ *num_channels = 7;
|
||||||
|
+ break;
|
||||||
|
+ default:
|
||||||
|
+ break;
|
||||||
|
+ }
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static const int aac_sample_rates[] = { 96000, 88200, 64000, 48000, 44100,
|
||||||
|
+ 32000, 24000, 22050, 16000, 12000, 11025, 8000, 7350
|
||||||
|
+};
|
||||||
|
+
|
||||||
|
+#define MAX_SR_NUM sizeof(aac_sample_rates)/sizeof(aac_sample_rates[0])
|
||||||
|
+
|
||||||
|
+static int get_sample_rate_from_index(int sr_index)
|
||||||
|
+{
|
||||||
|
+ if (sr_index >= 0 && sr_index < MAX_SR_NUM)
|
||||||
|
+ return aac_sample_rates[sr_index];
|
||||||
|
+
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+int find_adif_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
|
||||||
|
+{
|
||||||
|
+ int ret;
|
||||||
|
+ unsigned char adif_id[4];
|
||||||
|
+ unsigned char adif_header[20];
|
||||||
|
+ int bitstream_type;
|
||||||
|
+ int bitrate;
|
||||||
|
+ int object_type;
|
||||||
|
+ int sr_index;
|
||||||
|
+ int skip_size = 0;
|
||||||
|
+
|
||||||
|
+ ret = fread(adif_id, sizeof(unsigned char), 4, file);
|
||||||
|
+ if (ret < 0) {
|
||||||
|
+ fprintf(stderr, "read data from file err: %d\n", ret);
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+ /* adif id */
|
||||||
|
+ if ((adif_id[0] != 0x41) || (adif_id[1] != 0x44) ||
|
||||||
|
+ (adif_id[2] != 0x49) || (adif_id[3] != 0x46))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ fread(adif_header, sizeof(unsigned char), 20, file);
|
||||||
|
+
|
||||||
|
+ /* copyright string */
|
||||||
|
+ if (adif_header[0] & 0x80)
|
||||||
|
+ skip_size = 9;
|
||||||
|
+
|
||||||
|
+ bitstream_type = adif_header[0 + skip_size] & 0x10;
|
||||||
|
+ bitrate =
|
||||||
|
+ ((unsigned int) (adif_header[0 + skip_size] & 0x0f) << 19) |
|
||||||
|
+ ((unsigned int) adif_header[1 + skip_size] << 11) |
|
||||||
|
+ ((unsigned int) adif_header[2 + skip_size] << 3) |
|
||||||
|
+ ((unsigned int) adif_header[3 + skip_size] & 0xe0);
|
||||||
|
+
|
||||||
|
+ if (bitstream_type == 0) {
|
||||||
|
+ object_type = ((adif_header[6 + skip_size] & 0x01) << 1) |
|
||||||
|
+ ((adif_header[7 + skip_size] & 0x80) >> 7);
|
||||||
|
+ sr_index = (adif_header[7 + skip_size] & 0x78) >> 3;
|
||||||
|
+ }
|
||||||
|
+ /* VBR */
|
||||||
|
+ else {
|
||||||
|
+ object_type = (adif_header[4 + skip_size] & 0x18) >> 3;
|
||||||
|
+ sr_index = ((adif_header[4 + skip_size] & 0x07) << 1) |
|
||||||
|
+ ((adif_header[5 + skip_size] & 0x80) >> 7);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* sample rate */
|
||||||
|
+ *sample_rate = get_sample_rate_from_index(sr_index);
|
||||||
|
+
|
||||||
|
+ /* FIXME: assume channels is 2 */
|
||||||
|
+ *num_channels = 2;
|
||||||
|
+
|
||||||
|
+ *format = SND_AUDIOSTREAMFORMAT_ADIF;
|
||||||
|
+ fseek(file, 0, SEEK_SET);
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static int parse_aac_header(FILE *file, unsigned int *num_channels, unsigned int *sample_rate, unsigned int *format)
|
||||||
|
+{
|
||||||
|
+ if (find_adts_header(file, num_channels, sample_rate, format))
|
||||||
|
+ return 1;
|
||||||
|
+ else if (find_adif_header(file, num_channels, sample_rate, format))
|
||||||
|
+ return 1;
|
||||||
|
+ else {
|
||||||
|
+ fprintf(stderr, "can't find streams format\n");
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return 1;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
static int print_time(struct compress *compress)
|
||||||
|
{
|
||||||
|
unsigned int avail;
|
||||||
|
@@ -513,6 +697,29 @@ void get_codec_pcm(FILE *file, struct compr_config *config,
|
||||||
|
codec->format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
+void get_codec_aac(FILE *file, struct compr_config *config,
|
||||||
|
+ struct snd_codec *codec)
|
||||||
|
+{
|
||||||
|
+ unsigned int channels, rate, format;
|
||||||
|
+
|
||||||
|
+ if (parse_aac_header(file, &channels, &rate, &format) == 0) {
|
||||||
|
+ fclose(file);
|
||||||
|
+ exit(EXIT_FAILURE);
|
||||||
|
+ };
|
||||||
|
+ fseek(file, 0, SEEK_SET);
|
||||||
|
+
|
||||||
|
+ codec->id = SND_AUDIOCODEC_AAC;
|
||||||
|
+ codec->ch_in = channels;
|
||||||
|
+ codec->ch_out = channels;
|
||||||
|
+ codec->sample_rate = rate;
|
||||||
|
+ codec->bit_rate = 0;
|
||||||
|
+ codec->rate_control = 0;
|
||||||
|
+ codec->profile = SND_AUDIOPROFILE_AAC;
|
||||||
|
+ codec->level = 0;
|
||||||
|
+ codec->ch_mode = 0;
|
||||||
|
+ codec->format = format;
|
||||||
|
+
|
||||||
|
+}
|
||||||
|
void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
unsigned long buffer_size, unsigned int frag,
|
||||||
|
unsigned long codec_id, int pause_count, int pause_block,
|
||||||
|
@@ -544,6 +751,9 @@ void play_samples(char *name, unsigned int card, unsigned int device,
|
||||||
|
case SND_AUDIOCODEC_PCM:
|
||||||
|
get_codec_pcm(file, &config, &codec);
|
||||||
|
break;
|
||||||
|
+ case SND_AUDIOCODEC_AAC:
|
||||||
|
+ get_codec_aac(file, &config, &codec);
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
fprintf(stderr, "codec ID %ld is not supported\n", codec_id);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
--
|
||||||
|
2.17.1
|
||||||
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
SUMMARY = "tinycompress library for compress audio offload in alsa"
|
||||||
|
DESCRIPTION = "A library to handle compressed formats like MP3 etc"
|
||||||
|
LICENSE = "BSD-3-Clause"
|
||||||
|
|
||||||
|
inherit autotools pkgconfig
|
||||||
|
LIC_FILES_CHKSUM = "file://COPYING;md5=cf9105c1a2d4405cbe04bbe3367373a0"
|
||||||
|
|
||||||
|
DEPENDS_append = " alsa-lib"
|
||||||
|
|
||||||
|
SRC_URI = "git://git.alsa-project.org/tinycompress.git;protocol=git;branch=master \
|
||||||
|
file://0001-tinycompress-Add-id3-decoding.patch \
|
||||||
|
file://0002-cplay-Support-wave-file.patch \
|
||||||
|
file://0003-cplay-Add-pause-feature.patch \
|
||||||
|
file://0004-tinycompress-pass-NULL-buffer-with-0-size-to-driver.patch \
|
||||||
|
file://0005-cplay-Support-aac-streams.patch \
|
||||||
|
"
|
||||||
|
SRCREV = "995f2ed91045dad8c20485ab1a64727d22cd92e5"
|
||||||
|
|
||||||
|
S = "${WORKDIR}/git"
|
||||||
Loading…
Reference in New Issue