mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
re-org the codec crate so that it can accommodate gnarly backends
This is in anticipation of: 1) supply chain issues causing CODEC chips to change out 2) host integration being a PITA
This commit is contained in:
parent
f558f75116
commit
50174f99e5
4 changed files with 67 additions and 72 deletions
13
services/codec/src/backend/hostaudio.rs
Normal file
13
services/codec/src/backend/hostaudio.rs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
pub struct Codec {
|
||||
}
|
||||
|
||||
impl Codec {
|
||||
pub fn new() -> Codec {
|
||||
Codec {
|
||||
}
|
||||
}
|
||||
pub fn suspend(&self) {
|
||||
}
|
||||
pub fn resume(&self) {
|
||||
}
|
||||
}
|
||||
9
services/codec/src/backend/mod.rs
Normal file
9
services/codec/src/backend/mod.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#[cfg(not(target_os = "none"))]
|
||||
mod hostaudio;
|
||||
#[cfg(not(target_os = "none"))]
|
||||
pub use crate::backend::hostaudio::*;
|
||||
|
||||
#[cfg(target_os = "none")]
|
||||
mod tlv320aic3100;
|
||||
#[cfg(target_os = "none")]
|
||||
pub use crate::backend::tlv320aic3100::*;
|
||||
43
services/codec/src/backend/tlv320aic3100.rs
Normal file
43
services/codec/src/backend/tlv320aic3100.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use utralib::generated::*;
|
||||
use xous::MemoryRange;
|
||||
use susres::{RegManager, RegOrField, SuspendResume, ManagedMem};
|
||||
|
||||
pub struct Codec {
|
||||
csr: utralib::CSR<u32>,
|
||||
fifo: MemoryRange,
|
||||
susres_manager: RegManager::<{utra::audio::AUDIO_NUMREGS}>,
|
||||
}
|
||||
|
||||
impl Codec {
|
||||
pub fn new() -> Codec {
|
||||
let csr = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::audio::HW_AUDIO_BASE),
|
||||
None,
|
||||
4096,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map Audio CSR range");
|
||||
let fifo = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utralib::HW_AUDIO_MEM),
|
||||
None,
|
||||
utralib::HW_AUDIO_MEM_LEN,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map Audio CSR range");
|
||||
|
||||
let mut codec = Codec {
|
||||
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
||||
susres_manager: RegManager::new(csr.as_mut_ptr() as *mut u32),
|
||||
fifo,
|
||||
};
|
||||
|
||||
codec
|
||||
}
|
||||
|
||||
pub fn suspend(&mut self) {
|
||||
self.susres_manager.suspend();
|
||||
}
|
||||
pub fn resume(&mut self) {
|
||||
self.susres_manager.resume();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,85 +2,15 @@
|
|||
#![cfg_attr(target_os = "none", no_main)]
|
||||
|
||||
mod api;
|
||||
mod backend;
|
||||
use backend::Codec;
|
||||
|
||||
use num_traits::FromPrimitive;
|
||||
|
||||
use log::info;
|
||||
|
||||
|
||||
#[cfg(target_os = "none")]
|
||||
mod implementation {
|
||||
use utralib::generated::*;
|
||||
// use crate::api::*;
|
||||
use log::info;
|
||||
use susres::{RegManager, RegOrField, SuspendResume};
|
||||
|
||||
pub struct Codec {
|
||||
csr: utralib::CSR<u32>,
|
||||
fifo: xous::MemoryRange,
|
||||
susres_manager: RegManager::<{utra::audio::AUDIO_NUMREGS}>,
|
||||
}
|
||||
|
||||
impl Codec {
|
||||
pub fn new() -> Codec {
|
||||
let csr = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::audio::HW_AUDIO_BASE),
|
||||
None,
|
||||
4096,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map Audio CSR range");
|
||||
let fifo = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utralib::HW_AUDIO_MEM),
|
||||
None,
|
||||
utralib::HW_AUDIO_MEM_LEN,
|
||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map Audio CSR range");
|
||||
|
||||
let mut codec = Codec {
|
||||
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
||||
susres_manager: RegManager::new(csr.as_mut_ptr() as *mut u32),
|
||||
fifo,
|
||||
};
|
||||
|
||||
codec
|
||||
}
|
||||
|
||||
pub fn suspend(&mut self) {
|
||||
self.susres_manager.suspend();
|
||||
}
|
||||
pub fn resume(&mut self) {
|
||||
self.susres_manager.resume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// a stub to try to avoid breaking hosted mode for as long as possible.
|
||||
#[cfg(not(target_os = "none"))]
|
||||
mod implementation {
|
||||
use log::info;
|
||||
|
||||
pub struct Codec {
|
||||
}
|
||||
|
||||
impl Codec {
|
||||
pub fn new() -> Codec {
|
||||
Codec {
|
||||
}
|
||||
}
|
||||
pub fn suspend(&self) {
|
||||
}
|
||||
pub fn resume(&self) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[xous::xous_main]
|
||||
fn xmain() -> ! {
|
||||
use crate::implementation::Codec;
|
||||
|
||||
log_server::init_wait().unwrap();
|
||||
log::set_max_level(log::LevelFilter::Info);
|
||||
info!("my PID is {}", xous::process::id());
|
||||
|
|
|
|||
Loading…
Reference in a new issue