use core::time::Duration;
use hdmi_hal::HdmiForumFrl;
use hdmi_hal::ddc::{DdcCapabilities, EddcTarget};
use hdmi_hal::phy::{EqParams, FrlOutput, LanePatterns, TmdsPhyCapabilities, TmdsPhyConfig};
use hdmi_hal_async::ddc::{SendDdcBus, SendDdcHandle};
use hdmi_hal_async::phy::{SendFrlPhy, SendPhyPower, SendTmdsPhy};
use hdmi_hal_async::time::SendDelay;
use crate::bench::Time;
use crate::clock::SimClock;
use crate::ddc::{BusError, Ddc};
use crate::phy::{Phy, PhyError};
impl hdmi_hal_async::ddc::DdcHandle for Ddc<'_> {
type Bus = Self;
fn bus(&self) -> &Self {
self
}
}
impl SendDdcHandle for Ddc<'_> {
type Bus = Self;
fn bus(&self) -> &Self {
self
}
}
impl SendDdcBus for Ddc<'_> {
type Error = BusError;
fn capabilities(&self) -> DdcCapabilities {
hdmi_hal::ddc::DdcBus::capabilities(self)
}
async fn write(&self, addr: u8, bytes: &[u8]) -> Result<(), BusError> {
hdmi_hal::ddc::DdcBus::write(self, addr, bytes)
}
async fn write_read(&self, addr: u8, bytes: &[u8], buf: &mut [u8]) -> Result<(), BusError> {
hdmi_hal::ddc::DdcBus::write_read(self, addr, bytes, buf)
}
async fn read(&self, addr: u8, buf: &mut [u8]) -> Result<(), BusError> {
hdmi_hal::ddc::DdcBus::read(self, addr, buf)
}
async fn read_segmented(
&self,
target: EddcTarget,
segment: u8,
offset: u8,
buf: &mut [u8],
) -> Result<(), BusError> {
hdmi_hal::ddc::DdcBus::read_segmented(self, target, segment, offset, buf)
}
}
impl SendDelay for Time<'_> {
async fn delay(&mut self, duration: Duration) {
hdmi_hal::time::Delay::delay(self, duration)
}
}
impl SendDelay for SimClock {
async fn delay(&mut self, duration: Duration) {
hdmi_hal::time::Delay::delay(self, duration)
}
}
impl SendDelay for &SimClock {
async fn delay(&mut self, duration: Duration) {
hdmi_hal::time::Delay::delay(self, duration)
}
}
impl SendTmdsPhy for Phy<'_> {
type Error = PhyError;
fn capabilities(&self) -> TmdsPhyCapabilities {
hdmi_hal::phy::TmdsPhy::capabilities(self)
}
async fn configure(&mut self, config: TmdsPhyConfig) -> Result<(), PhyError> {
hdmi_hal::phy::TmdsPhy::configure(self, config)
}
async fn set_scrambling(&mut self, enabled: bool) -> Result<(), PhyError> {
hdmi_hal::phy::TmdsPhy::set_scrambling(self, enabled)
}
async fn start_output(&mut self) -> Result<(), PhyError> {
hdmi_hal::phy::TmdsPhy::start_output(self)
}
async fn stop_output(&mut self) -> Result<(), PhyError> {
hdmi_hal::phy::TmdsPhy::stop_output(self)
}
}
impl SendPhyPower for Phy<'_> {
type Error = PhyError;
async fn power_on(&mut self) -> Result<(), PhyError> {
hdmi_hal::phy::PhyPower::power_on(self)
}
async fn power_off(&mut self) -> Result<(), PhyError> {
hdmi_hal::phy::PhyPower::power_off(self)
}
}
impl SendFrlPhy for Phy<'_> {
type Error = PhyError;
async fn set_frl_rate(&mut self, rate: HdmiForumFrl) -> Result<(), PhyError> {
hdmi_hal::phy::FrlPhy::set_frl_rate(self, rate)
}
async fn send_ltp(&mut self, patterns: LanePatterns) -> Result<(), PhyError> {
hdmi_hal::phy::FrlPhy::send_ltp(self, patterns)
}
async fn set_frl_output(&mut self, output: FrlOutput) -> Result<(), PhyError> {
hdmi_hal::phy::FrlPhy::set_frl_output(self, output)
}
async fn adjust_equalization(&mut self, params: EqParams) -> Result<(), PhyError> {
hdmi_hal::phy::FrlPhy::adjust_equalization(self, params)
}
}