added raw1394_read_cycle_timer, contributed by Pieter Palmers

git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@169 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
ddennedy 2007-02-14 05:29:18 +00:00
parent 3a35307a85
commit fa981a8b96
6 changed files with 55 additions and 18 deletions

View File

@ -1,6 +1,6 @@
# process this file with autoconf to get a configure script # 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) AC_CONFIG_SRCDIR(src/raw1394.h)
AM_CONFIG_HEADER(config.h) AM_CONFIG_HEADER(config.h)
@ -16,9 +16,9 @@ AC_C_CONST
AC_C_BIGENDIAN AC_C_BIGENDIAN
# set the libtool so version numbers # set the libtool so version numbers
lt_major=9 lt_major=10
lt_revision=1 lt_revision=0
lt_age=1 lt_age=2
AC_SUBST(lt_major) AC_SUBST(lt_major)
AC_SUBST(lt_revision) AC_SUBST(lt_revision)

View File

@ -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 #ifndef __IEEE1394_IOCTL_H
#define __IEEE1394_IOCTL_H #define __IEEE1394_IOCTL_H
@ -7,14 +9,6 @@
#include <linux/ioctl.h> #include <linux/ioctl.h>
#include <linux/types.h> #include <linux/types.h>
/* 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 */ /* DV1394 Gets 10 */
/* Get the driver ready to transmit video. pass a struct dv1394_init* as /* Get the driver ready to transmit video. pass a struct dv1394_init* as
@ -104,8 +98,9 @@
_IOW ('#', 0x27, struct raw1394_iso_packets) _IOW ('#', 0x27, struct raw1394_iso_packets)
#define RAW1394_IOC_ISO_XMIT_SYNC \ #define RAW1394_IOC_ISO_XMIT_SYNC \
_IO ('#', 0x28) _IO ('#', 0x28)
#define RAW1394_IOC_ISO_RECV_FLUSH \ #define RAW1394_IOC_ISO_RECV_FLUSH \
_IO ('#', 0x29) _IO ('#', 0x29)
#define RAW1394_IOC_GET_CYCLE_TIMER \
_IOR ('#', 0x30, struct raw1394_cycle_timer)
#endif /* __IEEE1394_IOCTL_H */ #endif /* __IEEE1394_IOCTL_H */

View File

@ -498,6 +498,20 @@ void raw1394_iso_shutdown(raw1394handle_t handle)
handle->iso_mode = ISO_INACTIVE; 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) static int _raw1394_iso_recv_packets(raw1394handle_t handle)
{ {
struct raw1394_iso_status *stat = &handle->iso_status; struct raw1394_iso_status *stat = &handle->iso_status;

View File

@ -177,4 +177,14 @@ struct raw1394_iso_status {
__s16 xmit_cycle; __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 */ #endif /* IEEE1394_RAW1394_H */

View File

@ -103,7 +103,7 @@ static unsigned int init_rawdevice(struct raw1394_handle *h)
} }
if (req.error) { if (req.error) {
errno = 0; errno = EPROTO;
return -1; return -1;
} }
memset(h->buffer, 0, HBUF_SIZE); memset(h->buffer, 0, HBUF_SIZE);

View File

@ -118,7 +118,6 @@ enum raw1394_modify_mode {
RAW1394_MODIFY_FREE RAW1394_MODIFY_FREE
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -328,6 +327,25 @@ void raw1394_iso_stop(raw1394handle_t handle);
**/ **/
void raw1394_iso_shutdown(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; typedef int raw1394_errcode_t;
#define raw1394_make_errcode(ack, rcode) (((ack) << 16) | rcode) #define raw1394_make_errcode(ack, rcode) (((ack) << 16) | rcode)
#define raw1394_internal_err(errcode) ((errcode) < 0) #define raw1394_internal_err(errcode) ((errcode) < 0)