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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, FwIsoCtx};
use glib::{prelude::*, translate::*};
glib::wrapper! {
/// An object to receive isochronous packet for single channel.
///
/// [`FwIsoIrSingle`][crate::FwIsoIrSingle] receives isochronous packets for single channel by packet-per-buffer
/// mode of IR context in 1394 OHCI. The content of packet is split to two parts; context header and
/// context payload in a manner of Linux FireWire subsystem.
///
/// ## Signals
///
///
/// #### `interrupted`
/// Emitted when Linux FireWire subsystem generates interrupt event. There are three cases
/// for Linux FireWire subsystem to generate the event:
///
/// - When 1394 OHCI hardware generates hardware interrupt as a result to process the
/// isochronous packet for the buffer chunk marked to generate hardware interrupt.
/// - When the size of accumulated context header for packets since the last event reaches
/// the size of memory page (usually 4,096 bytes).
/// - When application calls [`FwIsoCtxExt::flush_completions()`][crate::prelude::FwIsoCtxExt::flush_completions()] explicitly.
///
/// The handler of signal can retrieve context payload of received packet by call of
/// [`FwIsoIrSingleExtManual::payload()`][crate::prelude::FwIsoIrSingleExtManual::payload()].
///
///
/// <details><summary><h4>FwIsoCtx</h4></summary>
///
///
/// #### `stopped`
/// Emitted when isochronous context is stopped.
///
/// Action
/// </details>
///
/// # Implements
///
/// [`FwIsoIrSingleExt`][trait@crate::prelude::FwIsoIrSingleExt], [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoIrSingleExtManual`][trait@crate::prelude::FwIsoIrSingleExtManual], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual]
#[doc(alias = "HinokoFwIsoIrSingle")]
pub struct FwIsoIrSingle(Object<ffi::HinokoFwIsoIrSingle, ffi::HinokoFwIsoIrSingleClass>) @implements FwIsoCtx;
match fn {
type_ => || ffi::hinoko_fw_iso_ir_single_get_type(),
}
}
impl FwIsoIrSingle {
pub const NONE: Option<&'static FwIsoIrSingle> = None;
/// Instantiate [`FwIsoIrSingle`][crate::FwIsoIrSingle] object and return the instance.
///
/// # Returns
///
/// an instance of [`FwIsoIrSingle`][crate::FwIsoIrSingle].
#[doc(alias = "hinoko_fw_iso_ir_single_new")]
pub fn new() -> FwIsoIrSingle {
unsafe { from_glib_full(ffi::hinoko_fw_iso_ir_single_new()) }
}
}
impl Default for FwIsoIrSingle {
fn default() -> Self {
Self::new()
}
}
/// Trait containing the part of [`struct@FwIsoIrSingle`] methods.
///
/// # Implementors
///
/// [`FwIsoIrSingle`][struct@crate::FwIsoIrSingle]
pub trait FwIsoIrSingleExt: IsA<FwIsoIrSingle> + 'static {
/// Allocate an IR context to 1394 OHCI hardware for packet-per-buffer mode. A local node of the
/// node corresponding to the given path is used as the hardware, thus any path is accepted as
/// long as process has enough permission for the path.
///
/// The header_size parameter has an effect for the content of header parameter in
/// [`interrupted`][struct@crate::FwIsoIrSingle#interrupted]. When it's greater than 8, header includes the series of two
/// quadlets for isochronous packet header and timestamp per isochronous packet. When it's greater
/// than 12, header includes the part of isochronous packet data per packet.
/// ## `path`
/// A path to any Linux FireWire character device.
/// ## `channel`
/// An isochronous channel to listen, up to 63.
/// ## `header_size`
/// The number of bytes for header of IR context, greater than 4 at least to include
/// isochronous packet header in header parameter of [`interrupted`][struct@crate::FwIsoIrSingle#interrupted].
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinoko_fw_iso_ir_single_allocate")]
fn allocate(&self, path: &str, channel: u32, header_size: u32) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinoko_fw_iso_ir_single_allocate(
self.as_ref().to_glib_none().0,
path.to_glib_none().0,
channel,
header_size,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Map intermediate buffer to share payload of IR context with 1394 OHCI hardware.
/// ## `maximum_bytes_per_payload`
/// The maximum number of bytes per payload of IR context.
/// ## `payloads_per_buffer`
/// The number of payload in buffer.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinoko_fw_iso_ir_single_map_buffer")]
fn map_buffer(
&self,
maximum_bytes_per_payload: u32,
payloads_per_buffer: u32,
) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinoko_fw_iso_ir_single_map_buffer(
self.as_ref().to_glib_none().0,
maximum_bytes_per_payload,
payloads_per_buffer,
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
/// Register chunk of buffer to process packet for future isochronous cycle. The caller can schedule
/// hardware interrupt to generate interrupt event. In detail, please refer to documentation about
/// [`interrupted`][struct@crate::FwIsoIrSingle#interrupted] signal.
/// ## `schedule_interrupt`
/// Whether to schedule hardware interrupt at isochronous cycle for the packet.
///
/// # Returns
///
/// TRUE if the overall operation finishes successfully, otherwise FALSE.
#[doc(alias = "hinoko_fw_iso_ir_single_register_packet")]
fn register_packet(&self, schedule_interrupt: bool) -> Result<(), glib::Error> {
unsafe {
let mut error = std::ptr::null_mut();
let is_ok = ffi::hinoko_fw_iso_ir_single_register_packet(
self.as_ref().to_glib_none().0,
schedule_interrupt.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
}
impl<O: IsA<FwIsoIrSingle>> FwIsoIrSingleExt for O {}