diff --git a/configure.ac b/configure.ac index 0d90d1a..fe23ca8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ # process this file with autoconf to get a configure script -AC_INIT(libraw1394, 1.2.1) +AC_INIT(libraw1394, 1.3.0) AC_CONFIG_SRCDIR(src/raw1394.h) AM_CONFIG_HEADER(config.h) @@ -16,9 +16,9 @@ AC_C_CONST AC_C_BIGENDIAN # set the libtool so version numbers -lt_major=9 -lt_revision=1 -lt_age=1 +lt_major=10 +lt_revision=0 +lt_age=2 AC_SUBST(lt_major) AC_SUBST(lt_revision) diff --git a/src/ieee1394-ioctl.h b/src/ieee1394-ioctl.h index f92b566..46878fe 100644 --- a/src/ieee1394-ioctl.h +++ b/src/ieee1394-ioctl.h @@ -1,5 +1,7 @@ -/* Base file for all ieee1394 ioctl's. Linux-1394 has allocated base '#' - * with a range of 0x00-0x3f. */ +/* + * Base file for all ieee1394 ioctl's. + * Linux-1394 has allocated base '#' with a range of 0x00-0x3f. + */ #ifndef __IEEE1394_IOCTL_H #define __IEEE1394_IOCTL_H @@ -7,14 +9,6 @@ #include #include - -/* AMDTP Gets 6 */ -#define AMDTP_IOC_CHANNEL _IOW('#', 0x00, struct amdtp_ioctl) -#define AMDTP_IOC_PLUG _IOW('#', 0x01, struct amdtp_ioctl) -#define AMDTP_IOC_PING _IOW('#', 0x02, struct amdtp_ioctl) -#define AMDTP_IOC_ZAP _IO ('#', 0x03) - - /* DV1394 Gets 10 */ /* Get the driver ready to transmit video. pass a struct dv1394_init* as @@ -104,8 +98,9 @@ _IOW ('#', 0x27, struct raw1394_iso_packets) #define RAW1394_IOC_ISO_XMIT_SYNC \ _IO ('#', 0x28) -#define RAW1394_IOC_ISO_RECV_FLUSH \ +#define RAW1394_IOC_ISO_RECV_FLUSH \ _IO ('#', 0x29) - +#define RAW1394_IOC_GET_CYCLE_TIMER \ + _IOR ('#', 0x30, struct raw1394_cycle_timer) #endif /* __IEEE1394_IOCTL_H */ diff --git a/src/iso.c b/src/iso.c index 3bea6a4..a16196a 100644 --- a/src/iso.c +++ b/src/iso.c @@ -498,6 +498,20 @@ void raw1394_iso_shutdown(raw1394handle_t handle) handle->iso_mode = ISO_INACTIVE; } +int raw1394_read_cycle_timer(raw1394handle_t handle, + u_int32_t *cycle_timer, u_int64_t *local_time) +{ + int err; + struct raw1394_cycle_timer ctr = { 0 }; + + err = ioctl(handle->fd, RAW1394_IOC_GET_CYCLE_TIMER, &ctr); + if (!err) { + *cycle_timer = ctr.cycle_timer; + *local_time = ctr.local_time; + } + return err; +} + static int _raw1394_iso_recv_packets(raw1394handle_t handle) { struct raw1394_iso_status *stat = &handle->iso_status; diff --git a/src/kernel-raw1394.h b/src/kernel-raw1394.h index cd4fc47..318f612 100644 --- a/src/kernel-raw1394.h +++ b/src/kernel-raw1394.h @@ -177,4 +177,14 @@ struct raw1394_iso_status { __s16 xmit_cycle; }; +/* argument to RAW1394_IOC_GET_CYCLE_TIMER ioctl */ +struct raw1394_cycle_timer { + /* contents of Isochronous Cycle Timer register, + as in OHCI 1.1 clause 5.13 (also with non-OHCI hosts) */ + __u32 cycle_timer; + + /* local time in microseconds since Epoch, + simultaneously read with cycle timer */ + __u64 local_time; +}; #endif /* IEEE1394_RAW1394_H */ diff --git a/src/main.c b/src/main.c index c72bfe1..a6943dd 100644 --- a/src/main.c +++ b/src/main.c @@ -103,7 +103,7 @@ static unsigned int init_rawdevice(struct raw1394_handle *h) } if (req.error) { - errno = 0; + errno = EPROTO; return -1; } memset(h->buffer, 0, HBUF_SIZE); diff --git a/src/raw1394.h b/src/raw1394.h index 4f8fa4b..751c153 100644 --- a/src/raw1394.h +++ b/src/raw1394.h @@ -118,7 +118,6 @@ enum raw1394_modify_mode { RAW1394_MODIFY_FREE }; - #ifdef __cplusplus extern "C" { #endif @@ -328,6 +327,25 @@ void raw1394_iso_stop(raw1394handle_t handle); **/ void raw1394_iso_shutdown(raw1394handle_t handle); +/** + * raw1394_get_cycle_timer - get the current value of the cycle timer + * @handle: libraw1394 handle + * @cycle_timer: buffer for Isochronous Cycle Timer + * @local_time: buffer for local system time in microseconds since Epoch + * + * Simultaneously reads the cycle timer register together with the system clock. + * + * Format of @cycle_timer, from MSB to LSB: 7 bits cycleSeconds (seconds, or + * number of cycleCount rollovers), 13 bits cycleCount (isochronous cycles, or + * cycleOffset rollovers), 12 bits cycleOffset (24.576 MHz clock ticks, not + * provided on some hardware). The union of cycleSeconds and cycleCount is the + * current cycle number. The nominal duration of a cycle is 125 microseconds. + * + * Returns: the error code of the ioctl, or 0 if successful. + **/ +int raw1394_read_cycle_timer(raw1394handle_t handle, + u_int32_t *cycle_timer, u_int64_t *local_time); + typedef int raw1394_errcode_t; #define raw1394_make_errcode(ack, rcode) (((ack) << 16) | rcode) #define raw1394_internal_err(errcode) ((errcode) < 0)