From adbedb7ab7df4daf92922cf419eba3a4d79b2185 Mon Sep 17 00:00:00 2001 From: Takashi Sakamoto Date: Sun, 25 Jun 2023 22:04:35 +0900 Subject: fw_node: add a new method to read CYCLE_TIMER register in 1394 OHCI controller This commit adds a new method to read data for CYCLE_TIMER register in 1394 OHCI controller. Signed-off-by: Takashi Sakamoto --- src/fw_node.c | 29 +++++++++++++++++++++++++++++ src/fw_node.h | 3 +++ src/hinawa.map | 2 ++ tests/fw-node | 1 + 4 files changed, 35 insertions(+) diff --git a/src/fw_node.c b/src/fw_node.c index 65854a3..f576485 100644 --- a/src/fw_node.c +++ b/src/fw_node.c @@ -417,6 +417,35 @@ void hinawa_fw_node_get_config_rom(HinawaFwNode *self, const guint8 **image, g_mutex_unlock(&priv->mutex); } +/** + * hinawa_fw_node_read_cycle_time: + * @self: A [class@FwNode] + * @clock_id: The numeric 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. + * @cycle_time: (inout): A [struct@CycleTime]. + * @error: A [struct@GLib.Error]. + * + * Read current value of CYCLE_TIME register in 1394 OHCI controller. + * + * Returns: TRUE if the overall operation finishes successfully, otherwise FALSE. + * + * Since: 2.6. + */ +gboolean hinawa_fw_node_read_cycle_time(HinawaFwNode *self, gint clock_id, + HinawaCycleTime *const *cycle_time, GError **error) +{ + int err; + + g_return_val_if_fail(cycle_time != NULL, FALSE); + + (*cycle_time)->clk_id = clock_id; + err = hinawa_fw_node_ioctl(self, FW_CDEV_IOC_GET_CYCLE_TIMER2, *cycle_time, error); + if (err < 0 && *error == NULL) + generate_syscall_error(error, errno, "ioctl(%s)", "FW_CDEV_IOC_GET_CYCLE_TIMER2"); + + return err == 0; +} + static void handle_update(HinawaFwNode *self) { HinawaFwNodePrivate *priv; diff --git a/src/fw_node.h b/src/fw_node.h index 1125d84..e46bd82 100644 --- a/src/fw_node.h +++ b/src/fw_node.h @@ -47,6 +47,9 @@ void hinawa_fw_node_open(HinawaFwNode *self, const gchar *path, void hinawa_fw_node_get_config_rom(HinawaFwNode *self, const guint8 **image, gsize *length, GError **error); +gboolean hinawa_fw_node_read_cycle_time(HinawaFwNode *self, gint clock_id, + HinawaCycleTime *const *cycle_time, GError **error); + void hinawa_fw_node_create_source(HinawaFwNode *self, GSource **gsrc, GError **error); diff --git a/src/hinawa.map b/src/hinawa.map index be6ddcd..1f44be1 100644 --- a/src/hinawa.map +++ b/src/hinawa.map @@ -167,4 +167,6 @@ HINAWA_2_6_0 { "hinawa_cycle_time_get_clock_id"; "hinawa_cycle_time_get_fields"; "hinawa_cycle_time_get_raw"; + + "hinawa_fw_node_read_cycle_time"; } HINAWA_2_5_0; diff --git a/tests/fw-node b/tests/fw-node index 8221141..4e39bd2 100644 --- a/tests/fw-node +++ b/tests/fw-node @@ -22,6 +22,7 @@ methods = ( 'new', 'open', 'get_config_rom', + 'read_cycle_time', 'create_source', ) vmethods = ( -- cgit 1.2.3-korg