hdmi_hal_i2c_dev/lib.rs
1//! Linux userspace [`hdmi-hal`] backend backed by `/dev/i2c-N` via the
2//! [`i2c-dev`] kernel interface.
3//!
4//! This crate is the **development, validation, and diagnostic backend** for
5//! the HDMI stack — not the production path. It lets you run the full FRL link
6//! training stack ([`culvert`], [`plumbob`]) against a real HDMI sink from
7//! userspace, without a kernel module.
8//!
9//! # Quick start
10//!
11//! ```no_run
12//! use hdmi_hal_i2c_dev::{connector_ddc_adapter, I2cDevTransport, StubPhy};
13//!
14//! // Resolve the DDC adapter for a named connector and open the transport.
15//! let path = connector_ddc_adapter("card0-HDMI-A-1")?;
16//! let transport = I2cDevTransport::open(path)?;
17//!
18//! // StubPhy accepts all PHY calls and forwards them to a callback.
19//! // Use `|_| {}` for a no-op, or a closure for logging or test assertions.
20//! let phy = StubPhy::new(|call| eprintln!("{call:?}"));
21//!
22//! // Pass transport and phy to culvert / plumbob as you would any other backend.
23//! # Ok::<(), hdmi_hal_i2c_dev::I2cDevError>(())
24//! ```
25//!
26//! # Privileges
27//!
28//! The calling process needs read/write permission on the `/dev/i2c-N` device
29//! node. On most Linux desktop systems this means membership in the `i2c`
30//! group, or running as root.
31//!
32//! # `amdgpu` limitation
33//!
34//! The `amdgpu` DDC adapter collapses all I²C errors to `EIO`. On that
35//! hardware, [`I2cTransactionError::kind`] is always
36//! [`I2cErrorKind::Unknown`]`{ errno: EIO }` regardless of the actual bus
37//! condition. See `doc/architecture.md` for details.
38//!
39//! [`hdmi-hal`]: https://crates.io/crates/hdmi-hal
40//! [`i2c-dev`]: https://www.kernel.org/doc/Documentation/i2c/dev-interface
41//! [`culvert`]: https://crates.io/crates/culvert
42//! [`plumbob`]: https://crates.io/crates/plumbob
43
44#![forbid(unsafe_code)]
45#![deny(missing_docs)]
46
47pub mod discovery;
48pub mod error;
49pub mod phy;
50pub mod transport;
51
52pub use discovery::connector_ddc_adapter;
53pub use error::{I2cDevError, I2cErrorKind, I2cTransactionError, MessagePhase};
54pub use phy::{PhyCall, StubPhy};
55pub use transport::I2cDevTransport;