Skip to main content

spiritlevel_async/
lib.rs

1//! Async TMDS link bring-up for HDMI sources.
2//!
3//! `spiritlevel-async` is the async companion to `spiritlevel`. It has no procedures of its
4//! own: [`TmdsLink`] runs spiritlevel's — bring-up, tear-down, the reconnect check and the
5//! quick restore — over an async [`TmdsScdc`], hdmi-hal-async's [`TmdsPhy`] and [`Delay`],
6//! a [`Clock`] and an optional [`Cancel`] flag, `.await`ing each operation. Sync and async
7//! bring-up are one procedure, so they take the same steps and record the same
8//! [`TmdsEvent`]s given the same I/O.
9//!
10//! The settings, outcomes and events are spiritlevel's, re-exported here with the
11//! hdmi-hal-async types the API uses, so a caller or an implementation has one import
12//! path.
13//!
14//! # Stopping a procedure
15//!
16//! A running procedure is stopped through its cancel flag ([`TmdsLink::with_cancel`]),
17//! never by dropping its future: a dropped future stops at whichever `.await` it was
18//! suspended on and cannot run its tear-down. Each procedure's documentation says what to
19//! do after one.
20//!
21//! # `Send` futures
22//!
23//! The plain traits promise nothing about their futures. Each has a `Send` twin —
24//! [`SendTmdsScdc`], [`SendTmdsPhy`], [`SendDelay`] — and in code bounded by the twins
25//! alone, with a clock and a flag that are `Send` (and, for the `_with_events` forms, a
26//! `Send` callback), every procedure's future is `Send`, so it
27//! can be spawned on a multi-threaded executor.
28//!
29//! # Features
30//!
31//! - **`display-types`** (default) — spiritlevel's `From` conversions from display-types'
32//!   `HdmiForumSinkCap` into the sink facts.
33//! - **`culvert-async`** — [`TmdsScdc`] for culvert-async's client `Scdc<T>` and a borrow
34//!   of it, with errors in spiritlevel's `CulvertError`.
35
36#![no_std]
37#![cfg_attr(docsrs, feature(doc_cfg))]
38#![forbid(unsafe_code)]
39#![deny(missing_docs)]
40
41// Compiles and runs the README's examples as doctests.
42#[cfg(doctest)]
43#[doc = include_str!("../README.md")]
44struct ReadmeDoctests;
45
46#[cfg(feature = "culvert-async")]
47mod culvert;
48mod link;
49mod scdc;
50
51pub use link::TmdsLink;
52pub use scdc::{SendTmdsScdc, TmdsScdc};
53
54// spiritlevel's link parameters, SCDC values, settings, outcomes, errors and events,
55// re-exported so that callers name the same versions this crate's procedures use. The
56// sync `TmdsScdc` and `TmdsLink` are not re-exported: this crate's own carry those names.
57
58// The link parameters.
59pub use spiritlevel::{
60    ClockRatio, ParamsError, ScramblingDecision, ScramblingOff, ScramblingThreshold, SinkTmdsFacts,
61    SourceTmdsFacts, TmdsConfigGate, TmdsLinkParams, TmdsPolicy,
62};
63// The SCDC values.
64pub use spiritlevel::{ScramblingStatus, SinkTmdsConfig, TmdsConfigReading, UpdateError};
65// The settings.
66pub use spiritlevel::{
67    BringUpConfig, ClearFrl, ConfigError, OnTmdsConfigFailure, OutputDuringSinkWrite, ScramblerOff,
68    SinkClearTiming, SinkPresence, SourceVersionWrite, TearDownConfig, TmdsConfigWrite,
69};
70// The outcomes and errors.
71pub use spiritlevel::{
72    BringUpError, BringUpOutcome, BringUpWarning, CheckResult, Cleanup, FailedRead, LinkUp,
73    OutputState, ReconnectCheck, RestoreError, Restored, ScramblingCheck, SinkClear, TearDownError,
74    TornDown, Warnings,
75};
76// The events.
77pub use spiritlevel::{
78    CancelPoint, FrlClearSkip, MAX_BRING_UP_EVENTS, MAX_QUICK_RESTORE_EVENTS,
79    MAX_RECONNECT_CHECK_EVENTS, MAX_TEAR_DOWN_EVENTS, SinkClearSkip, SourceVersionSkip,
80    TmdsConfigSkip, TmdsEvent, TmdsEventKind, TmdsStep,
81};
82
83// The sink capabilities the sink facts convert from, re-exported from display-types
84// through spiritlevel.
85#[cfg(feature = "display-types")]
86pub use spiritlevel::HdmiForumSinkCap;
87
88// The hdmi-hal-async traits and types the driver's signatures use, re-exported so that
89// callers and implementations name the same versions this crate does: the cancel flag,
90// the SCDC error classification, the PHY and its `Send` twin, the clock, the delay and its
91// `Send` twin, and the colour depth and format a `TmdsVideo` carries.
92pub use hdmi_hal_async::cancel::{Cancel, NoCancel};
93pub use hdmi_hal_async::ddc::{DdcError, DdcErrorKind, NoAcknowledgeSource};
94pub use hdmi_hal_async::phy::{
95    SendTmdsPhy, TmdsPhy, TmdsPhyCapabilities, TmdsPhyConfig, TmdsVideo,
96};
97pub use hdmi_hal_async::time::{Clock, Delay, SendDelay, Timestamp};
98pub use hdmi_hal_async::{ColorBitDepth, ColorFormat};
99
100// culvert-async's client, its errors and the transports it runs over, re-exported for the
101// adapter's users.
102#[cfg(feature = "culvert-async")]
103pub use culvert_async::{ProtocolError, Scdc, ScdcError, ScdcTransport, SendScdcTransport};
104// The error of culvert's client as the SCDC trait reports it, re-exported from spiritlevel
105// so that the sync and async adapters return the same type.
106#[cfg(feature = "culvert-async")]
107pub use spiritlevel::CulvertError;