aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>2022-05-08 15:33:32 +0900
committer坂本 貴史 <o-takashi@sakamocchi.jp>2022-05-08 15:36:32 +0900
commit44a5037c9489ce7d146c8dc4cdc03647e84fe3a3 (patch)
treec370c3294e180a3189ec6d44cfa7cd3162a4f101
parent62ed285e4b456b18d347995325f5a2bc7c400408 (diff)
downloadlibhinoko-44a5037c9489ce7d146c8dc4cdc03647e84fe3a3.tar.gz
fw_iso_ctx_private: add inline function to compute timeStamp field in IR/IT descriptors
The layout of timeStamp field in descriptor of IT/IR context is defined in 1394 OHCI specification. This commit adds inline functions to parse it. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx_private.h15
-rw-r--r--src/fw_iso_rx_single.c8
-rw-r--r--src/fw_iso_rx_single.h4
-rw-r--r--src/fw_iso_tx.c8
-rw-r--r--src/fw_iso_tx.h4
5 files changed, 27 insertions, 12 deletions
diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h
index cdbe897..45d3e2c 100644
--- a/src/fw_iso_ctx_private.h
+++ b/src/fw_iso_ctx_private.h
@@ -35,6 +35,21 @@ static inline guint ieee1394_iso_header_to_data_length(guint iso_header)
IEEE1394_ISO_HEADER_DATA_LENGTH_SHIFT;
}
+#define OHCI1394_ISOC_DESC_timeStamp_SEC_MASK 0x0000e000
+#define OHCI1394_ISOC_DESC_timeStamp_SEC_SHIFT 13
+#define OHCI1394_ISOC_DESC_timeStmap_CYCLE_MASK 0x00001fff
+
+static inline guint ohci1394_isoc_desc_tstamp_to_sec(guint32 tstamp)
+{
+ return (tstamp & OHCI1394_ISOC_DESC_timeStamp_SEC_MASK) >>
+ OHCI1394_ISOC_DESC_timeStamp_SEC_SHIFT;
+}
+
+static inline guint ohci1394_isoc_desc_tstamp_to_cycle(guint32 tstamp)
+{
+ return (tstamp & OHCI1394_ISOC_DESC_timeStmap_CYCLE_MASK);
+}
+
struct fw_iso_ctx_state {
int fd;
guint handle;
diff --git a/src/fw_iso_rx_single.c b/src/fw_iso_rx_single.c
index 0efbd4a..3ffb3a2 100644
--- a/src/fw_iso_rx_single.c
+++ b/src/fw_iso_rx_single.c
@@ -59,8 +59,8 @@ static void hinoko_fw_iso_rx_single_class_init(HinokoFwIsoRxSingleClass *klass)
/**
* HinokoFwIsoRxSingle::interrupted:
* @self: A [class@FwIsoRxSingle]
- * @sec: sec part of isochronous cycle when interrupt occurs.
- * @cycle: cycle part of of isochronous cycle when interrupt occurs.
+ * @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: (array length=header_length) (element-type guint8): The headers of IR context
* for handled packets.
* @header_length: the number of bytes for @header.
@@ -183,8 +183,8 @@ gboolean fw_iso_rx_single_handle_event(HinokoFwIsoCtx *inst, const union fw_cdev
priv = hinoko_fw_iso_rx_single_get_instance_private(self);
ev = &event->iso_interrupt;
- sec = (ev->cycle & 0x0000e000) >> 13;
- cycle = ev->cycle & 0x00001fff;
+ sec = ohci1394_isoc_desc_tstamp_to_sec(ev->cycle);
+ cycle = ohci1394_isoc_desc_tstamp_to_cycle(ev->cycle);
count = ev->header_length / priv->header_size;
// TODO; handling error?
diff --git a/src/fw_iso_rx_single.h b/src/fw_iso_rx_single.h
index 87c2b03..a06b510 100644
--- a/src/fw_iso_rx_single.h
+++ b/src/fw_iso_rx_single.h
@@ -17,8 +17,8 @@ struct _HinokoFwIsoRxSingleClass {
/**
* HinokoFwIsoRxSingleClass::interrupted:
* @self: A [class@FwIsoRxSingle].
- * @sec: sec part of isochronous cycle when interrupt occurs.
- * @cycle: cycle part of of isochronous cycle when interrupt occurs.
+ * @sec: The sec part of isochronous cycle when interrupt occurs, up to 7.
+ * @cycle: The cycle part of of isochronous cycle when interrupt occurs, up to 7999.
* @header: (array length=header_length) (element-type guint8): The headers of IR context
* for handled packets.
* @header_length: the number of bytes for header.
diff --git a/src/fw_iso_tx.c b/src/fw_iso_tx.c
index 698a620..aba8b31 100644
--- a/src/fw_iso_tx.c
+++ b/src/fw_iso_tx.c
@@ -53,8 +53,8 @@ static void hinoko_fw_iso_tx_class_init(HinokoFwIsoTxClass *klass)
/**
* HinokoFwIsoTx::interrupted:
* @self: A [class@FwIsoTx].
- * @sec: sec part of isochronous cycle when interrupt occurs.
- * @cycle: cycle part of of isochronous cycle when interrupt occurs.
+ * @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: (array length=tstamp_length) (element-type guint8): A series of timestamps for
* packets already handled.
* @tstamp_length: the number of bytes for @tstamp.
@@ -175,8 +175,8 @@ gboolean fw_iso_tx_handle_event(HinokoFwIsoCtx *inst, const union fw_cdev_event
ev = &event->iso_interrupt;
- sec = (ev->cycle & 0x0000e000) >> 13;
- cycle = ev->cycle & 0x00001fff;
+ sec = ohci1394_isoc_desc_tstamp_to_sec(ev->cycle);
+ cycle = ohci1394_isoc_desc_tstamp_to_cycle(ev->cycle);
pkt_count = ev->header_length / 4;
g_signal_emit(inst, fw_iso_tx_sigs[FW_ISO_TX_SIG_TYPE_IRQ], 0, sec, cycle, ev->header,
diff --git a/src/fw_iso_tx.h b/src/fw_iso_tx.h
index a888bed..ef3ec7f 100644
--- a/src/fw_iso_tx.h
+++ b/src/fw_iso_tx.h
@@ -16,8 +16,8 @@ struct _HinokoFwIsoTxClass {
/**
* HinokoFwIsoTxClass::interrupted:
* @self: A [class@FwIsoTx].
- * @sec: sec part of isochronous cycle when interrupt occurs.
- * @cycle: cycle part of of isochronous cycle when interrupt occurs.
+ * @sec: The sec part of isochronous cycle when interrupt occurs, up to 7.
+ * @cycle: The cycle part of of isochronous cycle when interrupt occurs, up to 7999.
* @tstamp: (array length=tstamp_length) (element-type guint8): A series of timestamps for
* packets already handled.
* @tstamp_length: the number of bytes for @tstamp.