From da4bee6cc695384c4426efcb9716c88b9b3733ce Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 31 May 2017 11:21:51 -0700 Subject: [PATCH] Audio: Introduce Codec abstraction. Now that we have two hardware variants with different audio codecs. --- firmware/application/audio.hpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/firmware/application/audio.hpp b/firmware/application/audio.hpp index e3d7544f..8ed545e4 100644 --- a/firmware/application/audio.hpp +++ b/firmware/application/audio.hpp @@ -25,9 +25,34 @@ #include "volume.hpp" #include +#include + +#include namespace audio { +class Codec { +public: + virtual ~Codec() { } + + virtual std::string name() const = 0; + + virtual bool reset() = 0; + virtual void init() = 0; + + virtual void headphone_enable() = 0; + virtual void headphone_disable() = 0; + virtual volume_range_t headphone_gain_range() const = 0; + virtual void set_headphone_volume(const volume_t volume) = 0; + + virtual void microphone_enable() = 0; + virtual void microphone_disable() = 0; + + virtual size_t reg_count() const = 0; + virtual size_t reg_bits() const = 0; + virtual uint32_t reg_read(const size_t register_number) = 0; +}; + namespace output { void start();