1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
//! The [`Scdc`] client.
use ScdcTransport;
/// Async typed client for the HDMI 2.1 SCDC (Status and Control Data Channel) register map.
///
/// `Scdc<T>` wraps an async [`ScdcTransport`] and exposes one typed `async fn` per register
/// group. It holds no protocol state; all sequencing logic belongs in the caller.
///
/// # Cancellation
///
/// To stop early, check a deadline or cancel signal before each call and stop there,
/// rather than dropping a future mid-flight: no transaction is then cut short, whatever
/// the transport does. If a future is dropped, `Scdc<T>` itself stays usable (it keeps no
/// state between calls); the transport's documentation says what a cancelled transfer
/// leaves behind (see `ScdcTransport`'s "Cancellation"). What a dropped call has done is
/// then unknown, method by method:
///
/// - **Writes that set a whole register** — `write_source_version`, `write_tmds_config`,
/// `write_config_0`, `write_frl_config` — may or may not have reached the sink.
/// Repeating one writes the same register contents again. What the write sets off on
/// the sink is another matter: a `Config_1` write ([`write_frl_config`]) is what starts
/// link training there, so repeating it mid-training may restart the sink's training.
/// To abandon a training attempt, return the link to TMDS (plumbob-async's
/// `exit_to_tmds`) rather than repeating the write.
/// - **`clear_update_flags`** writes 1 to clear, so repeating it can clear a flag the sink
/// set again in the meantime. For `CED_Update` and `RSED_Update` that loses at most a
/// hint: any counts stay in the counters, which are read regularly anyway. For a flag
/// you act on, such as `FLT_Update` or `FRL_Start`, read `Update_0` again
/// ([`read_update_flags`]) and clear only what is set, rather than repeating the clear.
/// - **Reads** change nothing on the sink and are read again — except the error counters
/// ([`read_ced`], [`read_rs_correction`]), which a sink may clear when they are read:
/// a dropped read of them can lose counts.
///
/// [`read_update_flags`]: Self::read_update_flags
/// [`write_frl_config`]: Self::write_frl_config
/// [`read_ced`]: Self::read_ced
/// [`read_rs_correction`]: Self::read_rs_correction
///
/// # Example
///
/// ```rust
/// use culvert_async::Scdc;
/// use hdmi_hal_async::scdc::{ScdcTransport, read_block_bytewise};
///
/// struct StubTransport;
/// impl ScdcTransport for StubTransport {
/// type Error = core::convert::Infallible;
/// async fn read(&self, _reg: u8) -> Result<u8, Self::Error> { Ok(0) }
/// async fn write(&mut self, _reg: u8, _value: u8) -> Result<(), Self::Error> { Ok(()) }
/// async fn read_block(&self, reg: u8, buf: &mut [u8]) -> Result<(), Self::Error> {
/// read_block_bytewise(self, reg, buf).await
/// }
/// }
///
/// # pollster::block_on(async {
/// let mut scdc = Scdc::new(StubTransport);
/// let sink_version = scdc.read_sink_version().await.unwrap();
/// scdc.write_source_version(1).await.unwrap();
/// # });
/// ```