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
commit3850166fe0931f3063a0667f69ad10e5682730e0 (patch)
tree1888b671a2c2fe9ca62b597c46e77f68fb6ea959
parente747b5324707ec1eeb3af5793be3aff69ca8d5fd (diff)
downloadlibhinoko-3850166fe0931f3063a0667f69ad10e5682730e0.tar.gz
fw_iso_ctx_private: add helper function to compute data length from isoc packet header
The layout of isochronous packet header is defined in IEEE 1394 specification. This commit adds helper function for constant values. Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
-rw-r--r--src/fw_iso_ctx_private.h8
-rw-r--r--src/fw_iso_rx_multiple.c2
-rw-r--r--src/fw_iso_rx_single.c2
3 files changed, 10 insertions, 2 deletions
diff --git a/src/fw_iso_ctx_private.h b/src/fw_iso_ctx_private.h
index c0688d7..cdbe897 100644
--- a/src/fw_iso_ctx_private.h
+++ b/src/fw_iso_ctx_private.h
@@ -26,6 +26,14 @@ extern const char *const fw_iso_ctx_err_msgs[7];
#define IEEE1394_MAX_CHANNEL 63
#define IEEE1394_MAX_SYNC_CODE 15
+#define IEEE1394_ISO_HEADER_DATA_LENGTH_MASK 0xffff0000
+#define IEEE1394_ISO_HEADER_DATA_LENGTH_SHIFT 16
+
+static inline guint ieee1394_iso_header_to_data_length(guint iso_header)
+{
+ return (iso_header & IEEE1394_ISO_HEADER_DATA_LENGTH_MASK) >>
+ IEEE1394_ISO_HEADER_DATA_LENGTH_SHIFT;
+}
struct fw_iso_ctx_state {
int fd;
diff --git a/src/fw_iso_rx_multiple.c b/src/fw_iso_rx_multiple.c
index 047ba18..8763533 100644
--- a/src/fw_iso_rx_multiple.c
+++ b/src/fw_iso_rx_multiple.c
@@ -261,7 +261,7 @@ gboolean fw_iso_rx_multiple_handle_event(HinokoFwIsoCtx *inst, const union fw_cd
buf = (const guint32 *)frames;
iso_header = GUINT32_FROM_LE(buf[0]);
- length = (iso_header & 0xffff0000) >> 16;
+ length = ieee1394_iso_header_to_data_length(iso_header);
// In buffer-fill mode, payload is sandwitched by heading
// isochronous header and trailing timestamp.
diff --git a/src/fw_iso_rx_single.c b/src/fw_iso_rx_single.c
index 34ecb12..0efbd4a 100644
--- a/src/fw_iso_rx_single.c
+++ b/src/fw_iso_rx_single.c
@@ -394,7 +394,7 @@ void hinoko_fw_iso_rx_single_get_payload(HinokoFwIsoRxSingle *self, guint index,
pos = index * priv->header_size / 4;
iso_header = GUINT32_FROM_BE(priv->ev->header[pos]);
- *length = (iso_header & 0xffff0000) >> 16;
+ *length = ieee1394_iso_header_to_data_length(iso_header);
if (*length > bytes_per_chunk)
*length = bytes_per_chunk;