diff options
author | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-07-07 23:20:46 +0900 |
---|---|---|
committer | Takashi Sakamoto <o-takashi@sakamocchi.jp> | 2022-07-07 23:20:46 +0900 |
commit | 56d90e913253921df3cead31a45ab29f7e9a6bf5 (patch) | |
tree | b998cac1f08cc4d97069f2b5f675211792dddb5b | |
parent | 626b882e1779bb0f8cbf1ff64ce7b65803bc46fc (diff) | |
download | hinoko-rs-56d90e913253921df3cead31a45ab29f7e9a6bf5.tar.gz |
hinoko: fulfill documentation
The gir tool can fulfill documentation from gir file. The documentation
comes from function comment in C library, thus it is necessarily suitable
to rust crate, however it is convenient.
This commit fulfills documentation for the file.
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r-- | hinoko/src/auto/cycle_timer.rs | 29 | ||||
-rw-r--r-- | hinoko/src/auto/enums.rs | 29 | ||||
-rw-r--r-- | hinoko/src/auto/flags.rs | 5 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_ctx.rs | 37 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_resource.rs | 84 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_resource_auto.rs | 36 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_resource_once.rs | 45 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_rx_multiple.rs | 44 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_rx_single.rs | 48 | ||||
-rw-r--r-- | hinoko/src/auto/fw_iso_tx.rs | 43 | ||||
-rw-r--r-- | hinoko/src/cycle_timer.rs | 10 | ||||
-rw-r--r-- | hinoko/src/fw_iso_ctx.rs | 16 | ||||
-rw-r--r-- | hinoko/src/fw_iso_rx_multiple.rs | 31 | ||||
-rw-r--r-- | hinoko/src/fw_iso_rx_single.rs | 51 | ||||
-rw-r--r-- | hinoko/src/fw_iso_tx.rs | 53 | ||||
-rw-r--r-- | hinoko/src/lib.rs | 36 | ||||
-rw-r--r-- | hinoko/src/subclass.rs | 9 | ||||
-rw-r--r-- | hinoko/src/subclass/fw_iso_ctx.rs | 3 | ||||
-rw-r--r-- | hinoko/src/subclass/fw_iso_resource.rs | 3 | ||||
-rw-r--r-- | hinoko/src/subclass/fw_iso_rx_multiple.rs | 3 | ||||
-rw-r--r-- | hinoko/src/subclass/fw_iso_rx_single.rs | 3 | ||||
-rw-r--r-- | hinoko/src/subclass/fw_iso_tx.rs | 2 |
22 files changed, 620 insertions, 0 deletions
diff --git a/hinoko/src/auto/cycle_timer.rs b/hinoko/src/auto/cycle_timer.rs index 5cd7d80..1cd51f0 100644 --- a/hinoko/src/auto/cycle_timer.rs +++ b/hinoko/src/auto/cycle_timer.rs @@ -7,6 +7,10 @@ use glib::translate::*; use std::mem; glib::wrapper! { + /// A boxed object to represent data for cycle timer. + /// + /// A [`CycleTimer`][crate::CycleTimer] is an boxed object to represent the value of cycle timer and timestamp + /// referring to clock_id. #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct CycleTimer(Boxed<ffi::HinokoCycleTimer>); @@ -18,11 +22,25 @@ glib::wrapper! { } impl CycleTimer { + /// Allocate and return an instance of [`CycleTimer`][crate::CycleTimer]. + /// + /// # Returns + /// + /// An instance of [`CycleTimer`][crate::CycleTimer]. #[doc(alias = "hinoko_cycle_timer_new")] pub fn new() -> CycleTimer { unsafe { from_glib_none(ffi::hinoko_cycle_timer_new()) } } + /// Get the ID of clock for timestamp. + /// + /// # Returns + /// + /// + /// ## `clock_id` + /// The numerical ID of clock source for the reference timestamp. One of + /// CLOCK_REALTIME(0), CLOCK_MONOTONIC(1), and CLOCK_MONOTONIC_RAW(4) is available in + /// UAPI of Linux kernel. #[doc(alias = "hinoko_cycle_timer_get_clock_id")] #[doc(alias = "get_clock_id")] pub fn clock_id(&mut self) -> i32 { @@ -34,6 +52,17 @@ impl CycleTimer { } } + /// Get timestamp with enough sizee of strorage. The timestamp refers to clock_id available by + /// [`clock_id()`][Self::clock_id()]. + /// + /// # Returns + /// + /// + /// ## `tv_sec` + /// The second part of timestamp. + /// + /// ## `tv_nsec` + /// The nanosecond part of timestamp. #[doc(alias = "hinoko_cycle_timer_get_timestamp")] #[doc(alias = "get_timestamp")] pub fn timestamp(&mut self) -> (i64, i32) { diff --git a/hinoko/src/auto/enums.rs b/hinoko/src/auto/enums.rs index 25cfa33..f0ecb86 100644 --- a/hinoko/src/auto/enums.rs +++ b/hinoko/src/auto/enums.rs @@ -12,22 +12,30 @@ use glib::StaticType; use glib::Type; use std::fmt; +/// A set of error code for [`FwIsoCtx`][crate::FwIsoCtx]. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinokoFwIsoCtxError")] pub enum FwIsoCtxError { + /// The system call fails. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_FAILED")] Failed, + /// The instance is already associated to any firewire character device. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_ALLOCATED")] Allocated, + /// The instance is not associated to any firewire character device. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_NOT_ALLOCATED")] NotAllocated, + /// The intermediate buffer is already mapped to the process. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_MAPPED")] Mapped, + /// The intermediate buffer is not mapped to the process. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_NOT_MAPPED")] NotMapped, + /// No chunk registered before starting. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_CHUNK_UNREGISTERED")] ChunkUnregistered, + /// No isochronous channel is available. #[doc(alias = "HINOKO_FW_ISO_CTX_ERROR_NO_ISOC_CHANNEL")] NoIsocChannel, #[doc(hidden)] @@ -142,14 +150,18 @@ impl ToValue for FwIsoCtxError { } } +/// A set of mode for isochronous context of Linux FireWire subsystem. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinokoFwIsoCtxMode")] pub enum FwIsoCtxMode { + // The mode of IT context of 1394 OHCI. #[doc(alias = "HINOKO_FW_ISO_CTX_MODE_TX")] Tx, + /// The mode of IR context of 1394 OHCI with packer-per-buffer protocol #[doc(alias = "HINOKO_FW_ISO_CTX_MODE_RX_SINGLE")] RxSingle, + /// The mode of IR context of 1394 OHCI with buffer-fill protocol. #[doc(alias = "HINOKO_FW_ISO_CTX_MODE_RX_MULTIPLE")] RxMultiple, #[doc(hidden)] @@ -229,14 +241,18 @@ impl ToValue for FwIsoCtxMode { } } +/// A set of error code for [`FwIsoResourceAuto`][crate::FwIsoResourceAuto]. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinokoFwIsoResourceAutoError")] pub enum FwIsoResourceAutoError { + /// The system call fails. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_FAILED")] Failed, + /// The instance is already associated to allocated isochronous resources. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_ALLOCATED")] Allocated, + /// The instance is not associated to allocated isochronous resources. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_AUTO_ERROR_NOT_ALLOCATED")] NotAllocated, #[doc(hidden)] @@ -335,18 +351,24 @@ impl ToValue for FwIsoResourceAutoError { } } +/// A set of error code for [`FwIsoResource`][crate::FwIsoResource]. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinokoFwIsoResourceError")] pub enum FwIsoResourceError { + /// The system call fails. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_ERROR_FAILED")] Failed, + /// The instance is already associated to any firewire character device. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_ERROR_OPENED")] Opened, + /// The instance is not associated to any firewire character device. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_ERROR_NOT_OPENED")] NotOpened, + /// No event to the request arrives within timeout. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_ERROR_TIMEOUT")] Timeout, + /// Event for the request arrives but includes error code. #[doc(alias = "HINOKO_FW_ISO_RESOURCE_ERROR_EVENT")] Event, #[doc(hidden)] @@ -453,20 +475,27 @@ impl ToValue for FwIsoResourceError { } } +/// A set of speed for isochronous context on IEEE 1394 bus. #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "HinokoFwScode")] pub enum FwScode { + /// 100 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S100")] S100, + /// 200 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S200")] S200, + /// 400 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S400")] S400, + /// 800 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S800")] S800, + /// 1600 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S1600")] S1600, + /// 3200 Mbps. #[doc(alias = "HINOKO_FW_SCODE_S3200")] S3200, #[doc(hidden)] diff --git a/hinoko/src/auto/flags.rs b/hinoko/src/auto/flags.rs index 1e40a80..cd8e14d 100644 --- a/hinoko/src/auto/flags.rs +++ b/hinoko/src/auto/flags.rs @@ -12,14 +12,19 @@ use glib::Type; use std::fmt; bitflags! { + /// A set of tag field of isochronous packet on IEEE 1394 bus. #[doc(alias = "HinokoFwIsoCtxMatchFlag")] pub struct FwIsoCtxMatchFlag: u32 { + /// The value of tag0 in 1394 OHCI. #[doc(alias = "HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG0")] const TAG0 = ffi::HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG0 as u32; + /// The value of tag1 in 1394 OHCI. #[doc(alias = "HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG1")] const TAG1 = ffi::HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG1 as u32; + /// The value of tag2 in 1394 OHCI. #[doc(alias = "HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG2")] const TAG2 = ffi::HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG2 as u32; + /// The value of tag3 in 1394 OHCI. #[doc(alias = "HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG3")] const TAG3 = ffi::HINOKO_FW_ISO_CTX_MATCH_FLAG_TAG3 as u32; } diff --git a/hinoko/src/auto/fw_iso_ctx.rs b/hinoko/src/auto/fw_iso_ctx.rs index 2df856f..ca4acae 100644 --- a/hinoko/src/auto/fw_iso_ctx.rs +++ b/hinoko/src/auto/fw_iso_ctx.rs @@ -15,6 +15,14 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// An basic interface to operate isochronous context on 1394 OHCI controller. + /// + /// A [`FwIsoCtx`][crate::FwIsoCtx] is an basic interface to use UAPI of Linux FireWire subsystem to operate + /// 1394 OHCI controller. + /// + /// # Implements + /// + /// [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual] #[doc(alias = "HinokoFwIsoCtx")] pub struct FwIsoCtx(Interface<ffi::HinokoFwIsoCtx, ffi::HinokoFwIsoCtxInterface>); @@ -27,28 +35,57 @@ impl FwIsoCtx { pub const NONE: Option<&'static FwIsoCtx> = None; } +/// Trait containing the part of[`struct@FwIsoCtx`] methods. +/// +/// # Implementors +/// +/// [`FwIsoCtx`][struct@crate::FwIsoCtx], [`FwIsoRxMultiple`][struct@crate::FwIsoRxMultiple], [`FwIsoRxSingle`][struct@crate::FwIsoRxSingle], [`FwIsoTx`][struct@crate::FwIsoTx] pub trait FwIsoCtxExt: 'static { + /// Create [`glib::Source`][crate::glib::Source] for `GLib::MainContext` to dispatch events for isochronous + /// context. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. + /// + /// ## `source` + /// A [`glib::Source`][crate::glib::Source]. #[doc(alias = "hinoko_fw_iso_ctx_create_source")] fn create_source(&self) -> Result<glib::Source, glib::Error>; + /// Flush isochronous context until recent isochronous cycle. The call of function forces the + /// context to queue any type of interrupt event for the recent isochronous cycle. Application can + /// process the content of isochronous packet without waiting for actual hardware interrupt. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_ctx_flush_completions")] fn flush_completions(&self) -> Result<(), glib::Error>; + /// Release the contest from 1394 OHCI controller. #[doc(alias = "hinoko_fw_iso_ctx_release")] fn release(&self); + /// Stop isochronous context. #[doc(alias = "hinoko_fw_iso_ctx_stop")] fn stop(&self); + /// Unmap intermediate buffer shared with 1394 OHCI controller for the context. #[doc(alias = "hinoko_fw_iso_ctx_unmap_buffer")] fn unmap_buffer(&self); + /// The number of bytes per chunk in buffer. #[doc(alias = "bytes-per-chunk")] fn bytes_per_chunk(&self) -> u32; + /// The number of chunks per buffer. #[doc(alias = "chunks-per-buffer")] fn chunks_per_buffer(&self) -> u32; + /// Emitted when isochronous context is stopped. + /// ## `error` + /// A [`glib::Error`][crate::glib::Error]. #[doc(alias = "stopped")] fn connect_stopped<F: Fn(&Self, Option<&glib::Error>) + 'static>( &self, diff --git a/hinoko/src/auto/fw_iso_resource.rs b/hinoko/src/auto/fw_iso_resource.rs index f634dc7..e140a4b 100644 --- a/hinoko/src/auto/fw_iso_resource.rs +++ b/hinoko/src/auto/fw_iso_resource.rs @@ -16,6 +16,14 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// An interface object to listen events of isochronous resource allocation and deallocation. + /// + /// The [`FwIsoResource`][crate::FwIsoResource] should be implemented in GObject-derived object to listen events of + /// isochronous resource allocation and deallocation. + /// + /// # Implements + /// + /// [`FwIsoResourceExt`][trait@crate::prelude::FwIsoResourceExt] #[doc(alias = "HinokoFwIsoResource")] pub struct FwIsoResource(Interface<ffi::HinokoFwIsoResource, ffi::HinokoFwIsoResourceInterface>); @@ -27,6 +35,16 @@ glib::wrapper! { impl FwIsoResource { pub const NONE: Option<&'static FwIsoResource> = None; + /// Calculate the amount of bandwidth expected to be consumed in allocation unit + /// by given parameters. + /// ## `bytes_per_payload` + /// The number of bytes in payload of isochronous packet. + /// ## `scode` + /// The speed of transmission. + /// + /// # Returns + /// + /// The amount of bandwidth expected to be consumed. #[doc(alias = "hinoko_fw_iso_resource_calculate_bandwidth")] pub fn calculate_bandwidth(bytes_per_payload: u32, scode: FwScode) -> u32 { unsafe { @@ -35,10 +53,40 @@ impl FwIsoResource { } } +/// Trait containing all [`struct@FwIsoResource`] methods. +/// +/// # Implementors +/// +/// [`FwIsoResourceAuto`][struct@crate::FwIsoResourceAuto], [`FwIsoResourceOnce`][struct@crate::FwIsoResourceOnce], [`FwIsoResource`][struct@crate::FwIsoResource] pub trait FwIsoResourceExt: 'static { + /// Initiate allocation of isochronous resource without any wait. One of the candidates is actually + /// allocated for channel. When the allocation finishes, `signal::FwIsoResource::allocated` signal is + /// emitted to notify the result, channel, and bandwidth. + /// ## `channel_candidates` + /// The array with elements for + /// numeric number of isochronous channel to be allocated. + /// ## `bandwidth` + /// The amount of bandwidth to be allocated. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_allocate_async")] fn allocate_async(&self, channel_candidates: &[u8], bandwidth: u32) -> Result<(), glib::Error>; + /// Initiate allocation of isochronous resource and wait for `signal::FwIsoResource::allocated` + /// signal. One of the candidates is actually allocated for channel. + /// ## `channel_candidates` + /// The array with elements for + /// numeric number for isochronous channel to be allocated. + /// ## `bandwidth` + /// The amount of bandwidth to be allocated. + /// ## `timeout_ms` + /// The timeout to wait for allocated event. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_allocate_sync")] fn allocate_sync( &self, @@ -47,14 +95,42 @@ pub trait FwIsoResourceExt: 'static { timeout_ms: u32, ) -> Result<(), glib::Error>; + /// Create [`glib::Source`][crate::glib::Source] for `GLib::MainContext` to dispatch events for isochronous + /// resource. + /// + /// # Returns + /// + /// TRUE if the overall operation finished successfully, otherwise FALSE. + /// + /// ## `source` + /// A [`glib::Source`][crate::glib::Source] #[doc(alias = "hinoko_fw_iso_resource_create_source")] fn create_source(&self) -> Result<glib::Source, glib::Error>; + /// Open Linux FireWire character device to delegate any request for isochronous + /// resource management to Linux FireWire subsystem. + /// ## `path` + /// A path of any Linux FireWire character device. + /// ## `open_flag` + /// The flag of open(2) system call. O_RDONLY is forced to fulfil + /// internally. + /// + /// # Returns + /// + /// TRUE if the overall operation finished successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_open")] fn open(&self, path: &str, open_flag: i32) -> Result<(), glib::Error>; fn generation(&self) -> u32; + /// Emitted when allocation of isochronous resource finishes. + /// ## `channel` + /// The deallocated channel number. + /// ## `bandwidth` + /// The deallocated amount of bandwidth. + /// ## `error` + /// A [`glib::Error`][crate::glib::Error]. Error can be generated + /// with domain of Hinoko.FwIsoResourceError and its EVENT code. #[doc(alias = "allocated")] fn connect_allocated<F: Fn(&Self, u32, u32, Option<&glib::Error>) + 'static>( &self, @@ -63,6 +139,14 @@ pub trait FwIsoResourceExt: 'static { fn emit_allocated(&self, channel: u32, bandwidth: u32, error: Option<&glib::Error>); + /// Emitted when deallocation of isochronous resource finishes. + /// ## `channel` + /// The deallocated channel number. + /// ## `bandwidth` + /// The deallocated amount of bandwidth. + /// ## `error` + /// A [`glib::Error`][crate::glib::Error]. Error can be generated + /// with domain of Hinoko.FwIsoResourceError and its EVENT code. #[doc(alias = "deallocated")] fn connect_deallocated<F: Fn(&Self, u32, u32, Option<&glib::Error>) + 'static>( &self, diff --git a/hinoko/src/auto/fw_iso_resource_auto.rs b/hinoko/src/auto/fw_iso_resource_auto.rs index 4420c3a..9d5ba29 100644 --- a/hinoko/src/auto/fw_iso_resource_auto.rs +++ b/hinoko/src/auto/fw_iso_resource_auto.rs @@ -15,6 +15,15 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// An object to maintain allocated isochronous resource. + /// + /// A [`FwIsoResourceAuto`][crate::FwIsoResourceAuto]is an object to maintain isochronous resource during the lifetime of + /// the object. The allocated isochronous resource is kept even if the generation of the bus + /// updates. The maintenance of allocated isochronous resource is done by Linux FireWire subsystem. + /// + /// # Implements + /// + /// [`FwIsoResourceAutoExt`][trait@crate::prelude::FwIsoResourceAutoExt], [`FwIsoResourceExt`][trait@crate::prelude::FwIsoResourceExt] #[doc(alias = "HinokoFwIsoResourceAuto")] pub struct FwIsoResourceAuto(Object<ffi::HinokoFwIsoResourceAuto, ffi::HinokoFwIsoResourceAutoClass>) @implements FwIsoResource; @@ -26,6 +35,11 @@ glib::wrapper! { impl FwIsoResourceAuto { pub const NONE: Option<&'static FwIsoResourceAuto> = None; + /// Allocate and return an instance of [`FwIsoResourceAuto`][crate::FwIsoResourceAuto]object. + /// + /// # Returns + /// + /// A [`FwIsoResourceAuto`][crate::FwIsoResourceAuto] #[doc(alias = "hinoko_fw_iso_resource_auto_new")] pub fn new() -> FwIsoResourceAuto { unsafe { from_glib_full(ffi::hinoko_fw_iso_resource_auto_new()) } @@ -38,17 +52,39 @@ impl Default for FwIsoResourceAuto { } } +/// Trait containing all [`struct@FwIsoResourceAuto`] methods. +/// +/// # Implementors +/// +/// [`FwIsoResourceAuto`][struct@crate::FwIsoResourceAuto] pub trait FwIsoResourceAutoExt: 'static { + /// Initiate deallocation of isochronous resource. When the deallocation is done, + /// `signal::FwIsoResource::deallocated` signal is emit to notify the result, channel, and bandwidth. + /// + /// # Returns + /// + /// TRUE if the overall operation finished successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_auto_deallocate_async")] fn deallocate_async(&self) -> Result<(), glib::Error>; + /// Initiate deallocation of isochronous resource. When the deallocation is done, + /// `signal::FwIsoResource::deallocated` signal is emit to notify the result, channel, and bandwidth. + /// ## `timeout_ms` + /// The timeout to wait for allocated event by milli second unit. + /// + /// # Returns + /// + /// TRUE if the overall operation finished successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_auto_deallocate_sync")] fn deallocate_sync(&self, timeout_ms: u32) -> Result<(), glib::Error>; + /// The allocated amount of bandwidth. fn bandwidth(&self) -> u32; + /// The allocated channel number. fn channel(&self) -> u32; + /// Whether to be allocate isochronous resource or not. #[doc(alias = "is-allocated")] fn is_allocated(&self) -> bool; diff --git a/hinoko/src/auto/fw_iso_resource_once.rs b/hinoko/src/auto/fw_iso_resource_once.rs index 87d82c3..bce1388 100644 --- a/hinoko/src/auto/fw_iso_resource_once.rs +++ b/hinoko/src/auto/fw_iso_resource_once.rs @@ -10,6 +10,16 @@ use std::fmt; use std::ptr; glib::wrapper! { + /// An object to initiate requests and listen events of isochronous resource allocation/deallocation + /// by one shot. + /// + /// The [`FwIsoResourceOnce`][crate::FwIsoResourceOnce] is an object to initiate requests and listen events of isochronous + /// resource allocation/deallocation by file descriptor owned internally. The allocated resource + /// is left even if this object is destroyed, thus application is responsible for deallocation. + /// + /// # Implements + /// + /// [`FwIsoResourceOnceExt`][trait@crate::prelude::FwIsoResourceOnceExt], [`FwIsoResourceExt`][trait@crate::prelude::FwIsoResourceExt] #[doc(alias = "HinokoFwIsoResourceOnce")] pub struct FwIsoResourceOnce(Object<ffi::HinokoFwIsoResourceOnce, ffi::HinokoFwIsoResourceOnceClass>) @implements FwIsoResource; @@ -21,6 +31,13 @@ glib::wrapper! { impl FwIsoResourceOnce { pub const NONE: Option<&'static FwIsoResourceOnce> = None; + /// Allocate and return an instance of [`FwIsoResourceOnce`][crate::FwIsoResourceOnce]. + /// + /// # Returns + /// + /// A [`FwIsoResourceOnce`][crate::FwIsoResourceOnce]. + /// + /// Sine: 0.7. #[doc(alias = "hinoko_fw_iso_resource_once_new")] pub fn new() -> FwIsoResourceOnce { unsafe { from_glib_full(ffi::hinoko_fw_iso_resource_once_new()) } @@ -33,10 +50,38 @@ impl Default for FwIsoResourceOnce { } } +/// Trait containing all [`struct@FwIsoResourceOnce`] methods. +/// +/// # Implementors +/// +/// [`FwIsoResourceOnce`][struct@crate::FwIsoResourceOnce] pub trait FwIsoResourceOnceExt: 'static { + /// Initiate deallocation of isochronous resource without any wait. When the + /// deallocation finishes, `signal::FwIsoResource::deallocated` signal is emit to notify the result, + /// channel, and bandwidth. + /// ## `channel` + /// The channel number to be deallocated. + /// ## `bandwidth` + /// The amount of bandwidth to be deallocated. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_once_deallocate_async")] fn deallocate_async(&self, channel: u32, bandwidth: u32) -> Result<(), glib::Error>; + /// Initiate deallocation of isochronous resource and wait for `signal::FwIsoResource::deallocated` + /// signal. + /// ## `channel` + /// The channel number to be deallocated. + /// ## `bandwidth` + /// The amount of bandwidth to be deallocated. + /// ## `timeout_ms` + /// The timeout to wait for deallocated event. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_resource_once_deallocate_sync")] fn deallocate_sync( &self, diff --git a/hinoko/src/auto/fw_iso_rx_multiple.rs b/hinoko/src/auto/fw_iso_rx_multiple.rs index 7d70c73..c9f83dc 100644 --- a/hinoko/src/auto/fw_iso_rx_multiple.rs +++ b/hinoko/src/auto/fw_iso_rx_multiple.rs @@ -15,6 +15,14 @@ use std::mem::transmute; use std::ptr; glib::wrapper! { + /// An object to receive isochronous packet for several channels. + /// + /// A [`FwIsoRxMultiple`][crate::FwIsoRxMultiple] receives isochronous packets for several channels by IR context for + /// buffer-fill mode in 1394 OHCI. + /// + /// # Implements + /// + /// [`FwIsoRxMultipleExt`][trait@crate::prelude::FwIsoRxMultipleExt], [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoRxMultipleExtManual`][trait@crate::prelude::FwIsoRxMultipleExtManual], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual] #[doc(alias = "HinokoFwIsoRxMultiple")] pub struct FwIsoRxMultiple(Object<ffi::HinokoFwIsoRxMultiple, ffi::HinokoFwIsoRxMultipleClass>) @implements FwIsoCtx; @@ -26,6 +34,11 @@ glib::wrapper! { impl FwIsoRxMultiple { pub const NONE: Option<&'static FwIsoRxMultiple> = None; + /// Instantiate [`FwIsoRxMultiple`][crate::FwIsoRxMultiple] object and return the instance. + /// + /// # Returns + /// + /// an instance of [`FwIsoRxMultiple`][crate::FwIsoRxMultiple]. #[doc(alias = "hinoko_fw_iso_rx_multiple_new")] pub fn new() -> FwIsoRxMultiple { unsafe { from_glib_full(ffi::hinoko_fw_iso_rx_multiple_new()) } @@ -38,13 +51,44 @@ impl Default for FwIsoRxMultiple { } } +/// Trait containing the part of[`struct@FwIsoRxMultiple`] methods. +/// +/// # Implementors +/// +/// [`FwIsoRxMultiple`][struct@crate::FwIsoRxMultiple] pub trait FwIsoRxMultipleExt: 'static { + /// Allocate an IR context to 1394 OHCI controller for buffer-fill mode. A local node of the node + /// corresponding to the given path is used as the controller, thus any path is accepted as long as + /// process has enough permission for the path. + /// ## `path` + /// A path to any Linux FireWire character device. + /// ## `channels` + /// an array for channels to listen + /// to. The value of each element should be up to 63. #[doc(alias = "hinoko_fw_iso_rx_multiple_allocate")] fn allocate(&self, path: &str, channels: &[u8]) -> Result<(), glib::Error>; + /// Map an intermediate buffer to share payload of IR context with 1394 OHCI + /// controller. + /// ## `bytes_per_chunk` + /// The maximum number of bytes for payload of isochronous packet (not payload for + /// isochronous context). + /// ## `chunks_per_buffer` + /// The number of chunks in buffer. #[doc(alias = "hinoko_fw_iso_rx_multiple_map_buffer")] fn map_buffer(&self, bytes_per_chunk: u32, chunks_per_buffer: u32) -> Result<(), glib::Error>; + /// Emitted when Linux FireWire subsystem generates interrupt event. There are two cases + /// for Linux FireWire subsystem to generate the event: + /// + /// - When OHCI 1394 controller generates hardware interrupt as a result to process the + /// isochronous packet for the buffer chunk marked to generate hardware interrupt. + /// - When application calls [`FwIsoCtxExt::flush_completions()`][crate::prelude::FwIsoCtxExt::flush_completions()] explicitly. + /// + /// The handler of signal can retrieve the content of packet by call of + /// [`FwIsoRxMultipleExtManual::payload()`][crate::prelude::FwIsoRxMultipleExtManual::payload()]. + /// ## `count` + /// The number of packets available in this interrupt. #[doc(alias = "interrupted")] fn connect_interrupted<F: Fn(&Self, u32) + 'static>(&self, f: F) -> SignalHandlerId; } diff --git a/hinoko/src/auto/fw_iso_rx_single.rs b/hinoko/src/auto/fw_iso_rx_single.rs index 92a51c4..c3c3949 100644 --- a/hinoko/src/auto/fw_iso_rx_single.rs +++ b/hinoko/src/auto/fw_iso_rx_single.rs @@ -10,6 +10,16 @@ use std::fmt; use std::ptr; glib::wrapper! { + /// An object to receive isochronous packet for single channel. + /// + /// A [`FwIsoRxSingle`][crate::FwIsoRxSingle] receives isochronous packets for single channel by IR + /// context for packet-per-buffer mode in 1394 OHCI. The content of packet is + /// split to two parts; context header and context payload in a manner of Linux + /// FireWire subsystem. + /// + /// # Implements + /// + /// [`FwIsoRxSingleExt`][trait@crate::prelude::FwIsoRxSingleExt], [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoRxSingleExtManual`][trait@crate::prelude::FwIsoRxSingleExtManual], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual] #[doc(alias = "HinokoFwIsoRxSingle")] pub struct FwIsoRxSingle(Object<ffi::HinokoFwIsoRxSingle, ffi::HinokoFwIsoRxSingleClass>) @implements FwIsoCtx; @@ -21,6 +31,11 @@ glib::wrapper! { impl FwIsoRxSingle { pub const NONE: Option<&'static FwIsoRxSingle> = None; + /// Instantiate [`FwIsoRxSingle`][crate::FwIsoRxSingle] object and return the instance. + /// + /// # Returns + /// + /// an instance of [`FwIsoRxSingle`][crate::FwIsoRxSingle]. #[doc(alias = "hinoko_fw_iso_rx_single_new")] pub fn new() -> FwIsoRxSingle { unsafe { from_glib_full(ffi::hinoko_fw_iso_rx_single_new()) } @@ -33,7 +48,31 @@ impl Default for FwIsoRxSingle { } } +/// Trait containing the part of[`struct@FwIsoRxSingle`] methods. +/// +/// # Implementors +/// +/// [`FwIsoRxSingle`][struct@crate::FwIsoRxSingle] pub trait FwIsoRxSingleExt: 'static { + /// Allocate an IR context to 1394 OHCI controller for packet-per-buffer mode. A local node of the + /// node corresponding to the given path is used as the controller, 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 + /// `signal::FwIsoRxSingle::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 `signal::FwIsoRxSingle::interrupted`. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_rx_single_allocate")] fn allocate(&self, path: &str, channel: u32, header_size: u32) -> Result<(), glib::Error>; @@ -44,6 +83,15 @@ pub trait FwIsoRxSingleExt: 'static { payloads_per_buffer: u32, ) -> Result<(), glib::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 + /// `signal::FwIsoRxSingle::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_rx_single_register_packet")] fn register_packet(&self, schedule_interrupt: bool) -> Result<(), glib::Error>; } diff --git a/hinoko/src/auto/fw_iso_tx.rs b/hinoko/src/auto/fw_iso_tx.rs index 6cbec4c..efcced8 100644 --- a/hinoko/src/auto/fw_iso_tx.rs +++ b/hinoko/src/auto/fw_iso_tx.rs @@ -11,6 +11,15 @@ use std::fmt; use std::ptr; glib::wrapper! { + /// An object to transmit isochronous packet for single channel. + /// + /// A [`FwIsoTx`][crate::FwIsoTx] transmits isochronous packets for single channel by IT 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. + /// + /// # Implements + /// + /// [`FwIsoTxExt`][trait@crate::prelude::FwIsoTxExt], [`FwIsoCtxExt`][trait@crate::prelude::FwIsoCtxExt], [`FwIsoTxExtManual`][trait@crate::prelude::FwIsoTxExtManual], [`FwIsoCtxExtManual`][trait@crate::prelude::FwIsoCtxExtManual] #[doc(alias = "HinokoFwIsoTx")] pub struct FwIsoTx(Object<ffi::HinokoFwIsoTx, ffi::HinokoFwIsoTxClass>) @implements FwIsoCtx; @@ -22,6 +31,11 @@ glib::wrapper! { impl FwIsoTx { pub const NONE: Option<&'static FwIsoTx> = None; + /// Instantiate [`FwIsoTx`][crate::FwIsoTx] object and return the instance. + /// + /// # Returns + /// + /// an instance of [`FwIsoTx`][crate::FwIsoTx]. #[doc(alias = "hinoko_fw_iso_tx_new")] pub fn new() -> FwIsoTx { unsafe { from_glib_full(ffi::hinoko_fw_iso_tx_new()) } @@ -34,7 +48,27 @@ impl Default for FwIsoTx { } } +/// Trait containing the part of[`struct@FwIsoTx`] methods. +/// +/// # Implementors +/// +/// [`FwIsoTx`][struct@crate::FwIsoTx] pub trait FwIsoTxExt: 'static { + /// Allocate an IT context to 1394 OHCI controller. A local node of the node corresponding to the + /// given path is used as the controller, thus any path is accepted as long as process has enough + /// permission for the path. + /// ## `path` + /// A path to any Linux FireWire character device. + /// ## `scode` + /// A [`FwScode`][crate::FwScode] to indicate speed of isochronous communication. + /// ## `channel` + /// An isochronous channel to transfer, up to 63. + /// ## `header_size` + /// The number of bytes for header of IT context. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successful, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_tx_allocate")] fn allocate( &self, @@ -44,6 +78,15 @@ pub trait FwIsoTxExt: 'static { header_size: u32, ) -> Result<(), glib::Error>; + /// Map intermediate buffer to share payload of IT context with 1394 OHCI controller. + /// ## `maximum_bytes_per_payload` + /// The number of bytes for payload of IT context. + /// ## `payloads_per_buffer` + /// The number of payloads of IT context in buffer. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successful, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_tx_map_buffer")] fn map_buffer( &self, diff --git a/hinoko/src/cycle_timer.rs b/hinoko/src/cycle_timer.rs index b7cfe7c..0b7120e 100644 --- a/hinoko/src/cycle_timer.rs +++ b/hinoko/src/cycle_timer.rs @@ -2,6 +2,16 @@ use crate::*; impl CycleTimer { + /// Get the value of cycle timer in 1394 OHCI controller. The first element of array expresses the + /// value of sec field, up to 127. The second element of array expresses the value of cycle field, + /// up to 7999. The third element of array expresses the value of offset field, up to 3071. + /// + /// # Returns + /// + /// + /// ## `cycle_timer` + /// The value of cycle timer register of 1394 OHCI, including three elements; second, cycle, and + /// offset. #[doc(alias = "hinoko_cycle_timer_get_cycle_timer")] #[doc(alias = "get_cycle_timer")] pub fn cycle_timer(&mut self) -> [u16; 3] { diff --git a/hinoko/src/fw_iso_ctx.rs b/hinoko/src/fw_iso_ctx.rs index 491107a..16f9f0e 100644 --- a/hinoko/src/fw_iso_ctx.rs +++ b/hinoko/src/fw_iso_ctx.rs @@ -1,7 +1,23 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of [`struct@FwIsoCtx`] methods. +/// +/// # Implementors +/// +/// [`FwIsoCtx`][struct@crate::FwIsoCtx], [`FwIsoRxMultiple`][struct@crate::FwIsoRxMultiple], [`FwIsoRxSingle`][struct@crate::FwIsoRxSingle], [`FwIsoTx`][struct@crate::FwIsoTx] pub trait FwIsoCtxExtManual { + /// Retrieve the value of cycle timer register. This method call is available + /// once any isochronous context is created. + /// ## `clock_id` + /// The numeric ID of clock source for the reference timestamp. One CLOCK_REALTIME(0), + /// CLOCK_MONOTONIC(1), and CLOCK_MONOTONIC_RAW(2) is available in UAPI of Linux kernel. + /// ## `cycle_timer` + /// A [`CycleTimer`][crate::CycleTimer] to store data of cycle timer. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_ctx_get_cycle_timer")] fn get_cycle_timer(&self, clock_id: i32, cycle_timer: &mut CycleTimer) -> Result<(), Error>; } diff --git a/hinoko/src/fw_iso_rx_multiple.rs b/hinoko/src/fw_iso_rx_multiple.rs index 59fe61d..0a2f881 100644 --- a/hinoko/src/fw_iso_rx_multiple.rs +++ b/hinoko/src/fw_iso_rx_multiple.rs @@ -1,13 +1,33 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of[`struct@FwIsoRxMultiple`] methods. +/// +/// # Implementors +/// +/// [`FwIsoRxMultiple`][struct@crate::FwIsoRxMultiple] pub trait FwIsoRxMultipleExtManual { + /// The array with elements to express isochronous channels to be listened to. fn channels(&self) -> Option<Vec<u8>>; #[doc(alias = "channels")] fn connect_channels_notify<F>(&self, f: F) -> SignalHandlerId where F: Fn(&Self) + 'static; + /// Start IR context. + /// ## `cycle_match` + /// The isochronous cycle + /// to start packet processing. The first element should be the second part of + /// isochronous cycle, up to 3. The second element should be the cycle part of + /// isochronous cycle, up to 7999. + /// ## `sync_code` + /// The value of sy field in isochronous packet header for packet processing, up to 15. + /// ## `tags` + /// The value of tag field in isochronous header for packet processing. + /// ## `chunks_per_irq` + /// The number of chunks per interval of interrupt. When 0 is given, application + /// should call [`FwIsoCtxExt::flush_completions()`][crate::prelude::FwIsoCtxExt::flush_completions()] voluntarily to generate + /// `signal::FwIsoRxMultiple::interrupted` event. #[doc(alias = "hinoko_fw_iso_rx_multiple_start")] fn start( &self, @@ -17,6 +37,17 @@ pub trait FwIsoRxMultipleExtManual { chunks_per_irq: u32, ) -> Result<(), Error>; + /// Retrieve data for packet indicated by the index parameter. The data has isochronous packet header + /// in its first quadlet, timestamp in its last quadlet. The rest is data of isochronous packet. + /// ## `index` + /// the index of packet available in this interrupt. + /// + /// # Returns + /// + /// + /// ## `payload` + /// The array with data frame for payload of + /// IR context. #[doc(alias = "hinoko_fw_iso_rx_multiple_get_payload")] #[doc(alias = "get_payload")] fn payload(&self, index: u32) -> &[u8]; diff --git a/hinoko/src/fw_iso_rx_single.rs b/hinoko/src/fw_iso_rx_single.rs index 9283f9e..a743d4e 100644 --- a/hinoko/src/fw_iso_rx_single.rs +++ b/hinoko/src/fw_iso_rx_single.rs @@ -1,7 +1,26 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of [`struct@FwIsoRxSingle`] methods. +/// +/// # Implementors +/// +/// [`FwIsoRxSingle`][struct@crate::FwIsoRxSingle] pub trait FwIsoRxSingleExtManual { + /// Start IR context. + /// ## `cycle_match` + /// The isochronous cycle + /// to start packet processing. The first element should be the second part of + /// isochronous cycle, up to 3. The second element should be the cycle part of + /// isochronous cycle, up to 7999. + /// ## `sync_code` + /// The value of sy field in isochronous packet header for packet processing, up to 15. + /// ## `tags` + /// The value of tag field in isochronous header for packet processing. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successfully, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_rx_single_start")] fn start( &self, @@ -10,10 +29,42 @@ pub trait FwIsoRxSingleExtManual { tags: FwIsoCtxMatchFlag, ) -> Result<(), Error>; + /// Retrieve payload of IR context for a handled packet corresponding to index at the event of + /// interrupt. + /// ## `index` + /// the index inner available packets at the event of interrupt. + /// + /// # Returns + /// + /// + /// ## `payload` + /// The array with data + /// frame for payload of IR context. #[doc(alias = "hinoko_fw_iso_rx_single_get_payload")] #[doc(alias = "get_payload")] fn payload(&self, index: u32) -> &[u8]; + /// Emitted when Linux FireWire subsystem generates interrupt event. There are three cases + /// for Linux FireWire subsystem to generate the event: + /// + /// - When OHCI 1394 controller 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 + /// [`FwIsoRxSingleExtManual::payload()`][crate::prelude::FwIsoRxSingleExtManual::payload()]. + /// ## `sec` + /// sec part of isochronous cycle when interrupt occurs, up to 7. + /// ## `cycle` + /// cycle part of of isochronous cycle when interrupt occurs, up to 7999. + /// ## `header` + /// The headers of IR context + /// for packets handled in the event of interrupt. The content is different + /// depending on header_size parameter of [`FwIsoRxSingleExt::allocate()`][crate::prelude::FwIsoRxSingleExt::allocate()]. + /// ## `count` + /// the number of packets to handle. #[doc(alias = "interrupted")] fn connect_interrupted<F: Fn(&Self, u32, u32, &[u8], u32) + 'static>( &self, diff --git a/hinoko/src/fw_iso_tx.rs b/hinoko/src/fw_iso_tx.rs index b7d0b49..1ae9b1f 100644 --- a/hinoko/src/fw_iso_tx.rs +++ b/hinoko/src/fw_iso_tx.rs @@ -1,7 +1,33 @@ // SPDX-License-Identifier: MIT use crate::*; +/// Trait containing the rest of[`struct@FwIsoTx`] methods. +/// +/// # Implementors +/// +/// [`FwIsoTx`][struct@crate::FwIsoTx] pub trait FwIsoTxExtManual { + /// Register packet data with header and payload for IT context. The content of given header and + /// payload is appended into data field of isochronous packet to be sent. The caller can schedule + /// hardware interrupt to generate interrupt event. In detail, please refer to documentation about + /// `signal::FwIsoTx::interrupted`. + /// ## `tags` + /// The value of tag field for isochronous packet to register. + /// ## `sync_code` + /// The value of sync field in isochronous packet header for packet processing, up to 15. + /// ## `header` + /// The header of IT context for isochronous + /// packet. The length of header should be the same as the size of header indicated in + /// allocation if it's not null. + /// ## `payload` + /// The payload of IT context for isochronous + /// packet. + /// ## `schedule_interrupt` + /// Whether to schedule hardware interrupt at isochronous cycle for the packet. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successful, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_tx_register_packet")] fn register_packet( &self, @@ -12,9 +38,36 @@ pub trait FwIsoTxExtManual { schedule_interrupt: bool, ) -> Result<(), Error>; + /// Start IT context. + /// ## `cycle_match` + /// The isochronous cycle + /// to start packet processing. The first element should be the second part of + /// isochronous cycle, up to 3. The second element should be the cycle part of + /// isochronous cycle, up to 7999. + /// + /// # Returns + /// + /// TRUE if the overall operation finishes successful, otherwise FALSE. #[doc(alias = "hinoko_fw_iso_tx_start")] fn start(&self, cycle_match: Option<&[u16; 2]>) -> Result<(), Error>; + /// Emitted when Linux FireWire subsystem generates interrupt event. There are three cases + /// for Linux FireWire subsystem to generate the event: + /// + /// - When OHCI 1394 controller generates hardware interrupt as a result of processing the + /// isochronous packet for the buffer chunk marked to generate hardware interrupt. + /// - When the number of isochronous packets sent since the last interrupt event reaches + /// one quarter of memory page size (usually 4,096 / 4 = 1,024 packets). + /// - When application calls [`FwIsoCtxExt::flush_completions()`][crate::prelude::FwIsoCtxExt::flush_completions()] explicitly. + /// ## `sec` + /// sec part of isochronous cycle when interrupt occurs, up to 7. + /// ## `cycle` + /// cycle part of of isochronous cycle when interrupt occurs, up to 7999. + /// ## `tstamp` + /// A series of timestamps for + /// packets already handled. + /// ## `count` + /// the number of handled packets. #[doc(alias = "interrupted")] fn connect_interrupted<F>(&self, f: F) -> SignalHandlerId where diff --git a/hinoko/src/lib.rs b/hinoko/src/lib.rs index f613564..14f4754 100644 --- a/hinoko/src/lib.rs +++ b/hinoko/src/lib.rs @@ -1,4 +1,36 @@ // SPDX-License-Identifier: MIT + +//! Rust libhinoko bindings +//! +//! Rust bindings and wrappers for [hinoko library](https://github.com/takaswie/libhinoko) to +//! operate Linux FireWire character device for isochronous packets and resources in IEEE 1394 +//! bus. +//! +//! The hinoko library v0.7.1 is the minimum supported version for underlying library. +//! +//! The crate depends on [glib crate v0.15](https://crates.io/crates/glib) provided by +//! [gtk-rs project](https://gtk-rs.org/) for type/object system, event loop, and dispacher. +//! +//! # License +//! +//! Released under MIT license. +//! +//! # Sample programs +//! +//! Some programs are available under `examples` directory. +//! +//! `fw-iso-resource` +//! : demonstration to allocate and deallocate isochronous resources +//! +//! `fw-iso-rx-single` +//! : demonstration to receive isochronous packets at single channel +//! +//! `fw-iso-rx-multiple` +//! : demonstration to receive isochronous packets at multiple channels +//! +//! `fw-iso-tx` +//! : demonstration to transmit isochronous packets at single channel + mod auto; mod cycle_timer; mod fw_iso_ctx; @@ -19,8 +51,12 @@ pub mod prelude { /// For subclass implementations derived from provided class. pub mod subclass; +// To access to hinoko-sys crate for FFI. pub use ffi; +// For links in documentation. +use glib; + use glib::{signal::*, translate::*, Cast, Error, IsA, SignalHandlerId, StaticType, Value}; use libc::c_uint; diff --git a/hinoko/src/subclass.rs b/hinoko/src/subclass.rs index c8b4b7f..ffe1630 100644 --- a/hinoko/src/subclass.rs +++ b/hinoko/src/subclass.rs @@ -1,9 +1,18 @@ // SPDX-License-Identifier: MIT +// For subclass of [`FwIsoCtx`][crate::FwIsoCtx] . mod fw_iso_ctx; + +// For subclass of [`FwIsoResource`][crate::FwIsoResource] . mod fw_iso_resource; + +// For subclass of [`FwIsoRxMultiple`][crate::FwIsoRxMultiple] . mod fw_iso_rx_multiple; + +// For subclass of [`FwIsoRxSingle`][crate::FwIsoRxSingle] . mod fw_iso_rx_single; + +// For subclass of [`FwIsoTx`][crate::FwIsoTx] . mod fw_iso_tx; /// For convenience to provide traits and their blanket implementations to write subclass. diff --git a/hinoko/src/subclass/fw_iso_ctx.rs b/hinoko/src/subclass/fw_iso_ctx.rs index 1acfbd5..1ce104c 100644 --- a/hinoko/src/subclass/fw_iso_ctx.rs +++ b/hinoko/src/subclass/fw_iso_ctx.rs @@ -2,6 +2,7 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwIsoCtx`][crate::FwIsoCtx]. pub trait FwIsoCtxImpl: ObjectImpl { fn create_source(&self, ctx: &Self::Type) -> Result<Source, Error>; fn flush_completions(&self, ctx: &Self::Type) -> Result<(), Error>; @@ -17,6 +18,8 @@ pub trait FwIsoCtxImpl: ObjectImpl { fn stopped(&self, ctx: &Self::Type, error: Option<&Error>); } +/// Trait which is automatically implemented to implementator of +/// [`FwIsoCtxImpl`][self::FwIsoCtxImpl]. pub trait FwIsoCtxImplExt: ObjectSubclass { fn parent_create_source(&self, ctx: &Self::Type) -> Result<Source, Error>; fn parent_flush_completions(&self, ctx: &Self::Type) -> Result<(), Error>; diff --git a/hinoko/src/subclass/fw_iso_resource.rs b/hinoko/src/subclass/fw_iso_resource.rs index d8723a6..df6949a 100644 --- a/hinoko/src/subclass/fw_iso_resource.rs +++ b/hinoko/src/subclass/fw_iso_resource.rs @@ -2,6 +2,7 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwIsoResource`][crate::FwIsoResource]. pub trait FwIsoResourceImpl: ObjectImpl { fn open(&self, resource: &Self::Type, path: &str, open_flag: i32) -> Result<(), Error>; fn create_source(&self, resource: &Self::Type) -> Result<Source, Error>; @@ -21,6 +22,8 @@ pub trait FwIsoResourceImpl: ObjectImpl { ); } +/// Trait which is automatically implemented to implementator of +/// [`FwIsoResourceImpl`][self::FwIsoResourceImpl]. pub trait FwIsoResourceImplExt: ObjectSubclass { fn parent_open(&self, resource: &Self::Type, path: &str, open_flag: i32) -> Result<(), Error>; fn parent_create_source(&self, resource: &Self::Type) -> Result<Source, Error>; diff --git a/hinoko/src/subclass/fw_iso_rx_multiple.rs b/hinoko/src/subclass/fw_iso_rx_multiple.rs index e3bd7db..0f45037 100644 --- a/hinoko/src/subclass/fw_iso_rx_multiple.rs +++ b/hinoko/src/subclass/fw_iso_rx_multiple.rs @@ -2,12 +2,15 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwIsoRxMultiple`][crate::FwIsoRxMultiple]. pub trait FwIsoRxMultipleImpl: FwIsoCtxImpl { fn interrupted(&self, ctx: &Self::Type, count: u32) { self.parent_interrupted(ctx, count) } } +/// Trait which is automatically implemented to implementator of +/// [`FwIsoRxMultipleImpl`][self::FwIsoRxMultipleImpl]. pub trait FwIsoRxMultipleImplExt: ObjectSubclass { fn parent_interrupted(&self, ctx: &Self::Type, count: u32); } diff --git a/hinoko/src/subclass/fw_iso_rx_single.rs b/hinoko/src/subclass/fw_iso_rx_single.rs index a6c40b8..52d8399 100644 --- a/hinoko/src/subclass/fw_iso_rx_single.rs +++ b/hinoko/src/subclass/fw_iso_rx_single.rs @@ -2,12 +2,15 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwIsoRxSingle`][crate::FwIsoRxSingle]. pub trait FwIsoRxSingleImpl: FwIsoCtxImpl { fn interrupted(&self, ctx: &Self::Type, sec: u32, cycle: u32, header: &[u8], count: u32) { self.parent_interrupted(ctx, sec, cycle, header, count) } } +/// Trait which is automatically implemented to implementator of +/// [`FwIsoRxSingleImpl`][self::FwIsoRxSingleImpl]. pub trait FwIsoRxSingleImplExt: ObjectSubclass { fn parent_interrupted(&self, ctx: &Self::Type, sec: u32, cycle: u32, header: &[u8], count: u32); } diff --git a/hinoko/src/subclass/fw_iso_tx.rs b/hinoko/src/subclass/fw_iso_tx.rs index c48ad00..4fbe3b9 100644 --- a/hinoko/src/subclass/fw_iso_tx.rs +++ b/hinoko/src/subclass/fw_iso_tx.rs @@ -2,12 +2,14 @@ use super::*; +/// Trait which should be implemented by subclass of [`FwIsoTx`][crate::FwIsoTx]. pub trait FwIsoTxImpl: FwIsoCtxImpl { fn interrupted(&self, ctx: &Self::Type, sec: u32, cycle: u32, header: &[u8], count: u32) { self.parent_interrupted(ctx, sec, cycle, header, count) } } +/// Trait which is automatically implemented to implementator of [`FwIsoTxImpl`][self::FwIsoTxImpl]. pub trait FwIsoTxImplExt: ObjectSubclass { fn parent_interrupted(&self, ctx: &Self::Type, sec: u32, cycle: u32, header: &[u8], count: u32); } |