summaryrefslogtreecommitdiffstats
path: root/audio/audio_hw.c
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-11-28 00:56:52 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2020-11-28 03:33:22 +0100
commit10f8d01eedc6d66440a81c80f64c0520bafe0ded (patch)
treebd8c9a3fbf230c1ed339d3b3ee338bfd41d3c055 /audio/audio_hw.c
parent0304cc83a0b1d067951209db7f941dcddf6a4d2a (diff)
downloaddevice_samsung_midas-common-10f8d01eedc6d66440a81c80f64c0520bafe0ded.tar.gz
device_samsung_midas-common-10f8d01eedc6d66440a81c80f64c0520bafe0ded.tar.bz2
device_samsung_midas-common-10f8d01eedc6d66440a81c80f64c0520bafe0ded.zip
audio: add extremely basic routing
The configuration is derived from the default and speaker on configurations from the configs/tiny_hw.xml file in the replicant-6.0 branch of the device_samsung_i9300[1]. This should be sufficient for testing the audio as it routes it to the speaker and never changes route. This will be improved in subsequent commits as only having the ability to use the speaker and leaving them on all the time doesn't really make the device usable. The audio_hw.c part was inspired from the audio_hw.c and audio_hw.h files in the device_amlogic_yukawa repository[2] at the following commit: 7252a5cd25ced5badee99e7377fb678394c943a8 7252a5c Snap for 6453963 from b70ebf49d8bc1f162601b8cb627edfc7a689b67a to rvc-release References: ----------- [1]https://git.replicant.us/replicant/device_samsung_i9300.git [2]https://android.googlesource.com/device/amlogic/yukawa Thanks to Joonas Kylmälä who found that some boards were using a mixer_paths.xml configuration file. With that information I was able to find the libaudioroute library and an example xml file. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Diffstat (limited to 'audio/audio_hw.c')
-rw-r--r--audio/audio_hw.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/audio/audio_hw.c b/audio/audio_hw.c
index d601ea8..7be7178 100644
--- a/audio/audio_hw.c
+++ b/audio/audio_hw.c
@@ -14,6 +14,8 @@
* limitations under the License.
*/
+#define MIXER_XML_PATH "/vendor/etc/mixer_paths.xml"
+
#define LOG_TAG "audio_hw_dragonboard"
//#define LOG_NDEBUG 0
@@ -33,6 +35,7 @@
#include <system/audio.h>
#include <hardware/audio.h>
+#include <audio_route/audio_route.h>
#include <sound/asound.h>
#include <tinyalsa/asoundlib.h>
#include <audio_utils/resampler.h>
@@ -69,6 +72,8 @@ struct alsa_audio_device {
int devices;
struct alsa_stream_in *active_input;
struct alsa_stream_out *active_output;
+ struct audio_route *audio_route;
+ struct mixer *mixer;
bool mic_mute;
};
@@ -671,6 +676,35 @@ static int adev_open(const hw_module_t* module, const char* name,
*device = &adev->hw_device.common;
+ /* TODO: Ideally we should use Alsa UCM instead of libaudioroute
+ * because with Alsa UCM:
+ * - We can share the work with GNU/Linux. For instance we
+ * might have automatic support for the PinePhone and our
+ * work would benefit GNU/Linux distributions as well.
+ * - It opens the door to generic images: With Alsa UCM, we
+ * don't need build time configuration anymore: we could
+ * ship a single audio library and Alsa UCM would take care
+ * of the routing and abstract away the device specific part
+ * for us. If we code that ourselves, it will probably not
+ * be as fine grained nor as good as Alsa UCM.
+ * - It can be experimented with without even recompiling, this
+ * could make porting Replicant to new devices much less time
+ * consuming and way easier.
+ */
+ adev->mixer = mixer_open(CARD_OUT);
+
+ if (!adev->mixer) {
+ ALOGE("Unable to open the mixer, aborting.");
+ return -EINVAL;
+ }
+
+ /* Set default audio route */
+ adev->audio_route = audio_route_init(CARD_OUT, MIXER_XML_PATH);
+ if (!adev->audio_route) {
+ ALOGE("%s: Failed to init audio route controls, aborting.", __func__);
+ return -EINVAL;
+ }
+
return 0;
}