Commit Graph

276 Commits

Author SHA1 Message Date
Stefan Richter d0881b4eff Remove now unused code
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-24 00:52:42 +02:00
Igor Kuzmin 662d6534c7 Disable power-of-2 alignment of isochronous I/O buffers
This can save some memory.  (The library user can always round max
packet size himself if it's needed for some reason.)

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-24 00:43:11 +02:00
Igor Kuzmin 82b51be678 Enable write access to isochronous reception buffer
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-24 00:42:16 +02:00
Stefan Richter f880dd00c7 Increase libtool version to 2.1.0
due to the API additions since 2.0.9:
    raw1394_add_config_rom_descriptor()
    raw1394_remove_config_rom_descriptor()
    raw1394_read_cycle_timer_and_clock()

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-18 02:07:31 +02:00
Stefan Richter 5b4cffe9d7 Add raw1394_read_cycle_timer_and_clock() API
This is an extension relative to raw1394_read_cycle_timer().
It lets the client choose a system clock other than CLOCK_REALTIME.

Use case: http://subversion.ffado.org/ticket/242

The underlying ioctl supports reading the system clock with nanoseconds
resolution.  The new libraw1394 call sticks with microseconds resolution
though.  This makes transition from (or parallel use with)
raw1394_read_cycle_timer() easier.  Besides, the call itself takes longer
than a  microsecond, primarily due to a costly MMIO read (on many
controllers even three or more MMIO reads).

Unit tests with CLOCK_MONOTONIC and CLOCK_MONOTONIC_RAW are added to
testlibraw as well.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-18 01:53:32 +02:00
Stefan Richter 56056a9607 Tweak raw1394_add_config_rom_descriptor() API, add documentation and test case
To conform with 'size' arguments of other libraw1394 calls, change the one in
raw1394_add_config_rom_descriptor() from quadlets to bytes.  This breaks runtime
compatibility with potential clients that were written against B.J.'s original
patch, hence reorder arguments just to break compatibility also at compile time.

Change errno to ENOSYS (function not implemented) when called while running on
top of raw1394.

Allow &token to be NULL for convenience of clients which don't require
raw1394_remove_config_rom_descriptor().

Add exhaustive documentation.  Much of it is copied from the documentation of
the underlying ioctl.

Add example code which doubles as unit test in testlibraw.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-18 00:19:23 +02:00
B.J. Buchalter f3c9af36c2 Add raw1394_add_config_rom_descriptor() and raw1394_remove_config_rom_descriptor() API
This adds support of the firewire-core (juju) ABI to add and remove config ROM directories
or descriptors.  The raw1394 ABI supports similar requests, but for now we leave the two
functions unimplemented when running on top of raw1394.

Signed-off-by: Benjamin Buchalter <bj@mhlabs.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (whitespace changes)
2012-06-17 22:00:40 +02:00
Stefan Richter c6753dfcc2 configure.ac, Changelog, NEWS etc.: update to version 2.0.9
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-06-02 16:48:26 +02:00
Stefan Richter b7f4eaeaaf Remove unused code
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-05-25 23:27:45 +02:00
Stefan Richter d2936622ab Include local firewire-*.h instead of system-wide <linux/firewire-*.h>
This guarantees that all features of libraw1394 are actually built in.
Before, some features and fixes would be silently dropped if too old
system headers (typically provided by a package called linux-headers)
were present.

An alternative would be to keep using system headers but add warnings
during the ./configure stage if old headers were encountered.  But this
helps only the person who builds libraw1394 (if there is a person
involved at all), not the users who have no reliable way to determine
how the library binary was built.

Another alternative would be to change the former soft dependency on
certain linux-headers versions into a hard dependency, i.e. fail the
build in absence of too old headers.  This would add an inconvenience
in setting up the build environment though:  The system headers would
have to be updated or a private copy of linux/firewire-*.h be specified
by way of the --with-fw-dir configure switch.

Anyhow.  The libraw1394 sources now already bring a suitable copy of
the two header files.  The --with-fw-dir configure switch is no longer
useful and is removed.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-05-25 22:19:43 +02:00
Stefan Richter b1dd541823 Add firewire-{cdev,constants}.h from Linux v3.4
Add copies of the Linux kernel header files but don't #include them just yet.
These are exact copies of the files from linux-3.4.  In case that we eventually
want updates from later kernels, a diff of the kernel's firewire-c*.h between
v3.4 and then should do the trick.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-05-25 21:27:40 +02:00
Clemens Ladisch d3ba40481f Implement raw1394_iso_recv_flush() on Juju
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-03-19 22:52:41 +01:00
Guus Sliepen 39249705c0 Fix incorrect use of == instead of =.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-19 19:57:42 +01:00
Guus Sliepen e31d8bed56 Remove UTF-8 whitespace.
Found by cppcheck.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-19 19:53:14 +01:00
Stefan Richter a22b06e6c6 configure.ac, Changelog, NEWS etc.: update to version 2.0.8
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-19 14:52:40 +01:00
Stefan Richter d72d1979fb Make a symbol static
This symbol should not be exported.  Fixes commit db5f202d5d.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-05 19:38:32 +01:00
Stefan Richter 2094c86d5c Continue inotify event handling even after failure in one event
If read() on the inotify handle gave us several events at once, and handling
one of them resulted in whatever error, there is little reason not to try
handling the rest of the events.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-05 12:02:37 +01:00
Peter Hurley c6569f39f1 Process multiple inotify events
If multiple inotify events are presented, process *all* of them.
This can happen when several device adds are pushed simultaneously.
handle_inotify() was refactored.

Signed-off-by: Peter Hurley <phurley@charter.net>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-05 11:18:40 +01:00
Peter Hurley ea4acf08bc Reset device fd upon error condition in handle_inotify()
If an error is encountered while adding a new device in inotify
handling, make sure the fd is marked invalid (-1).

Signed-off-by: Peter Hurley <phurley@charter.net>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2012-02-05 10:32:44 +01:00
Stefan Richter 8e433bf584 retry raw1394_read/write/lock/lock64 with delays after ack-busy
Applications or higher-level libraries have retry strategies of their own
in place, but they don't work too well sometimes.  For example, old
Panasonic camcorders require pauses in the order of several milliseconds
between response of a former transaction and request of the next one,
but libavc1394 and libiec61883 retry already after 20 microseconds.

This change cures all FCP transaction failures ("send oops") in kino and
dvgrab that I was getting with Panasonic NV-DX110.  According to reports,
Panasonic AG-EZ30 and Grundig Scenos DLC 2000 were affected too.

The additional latency in raw1394_read/write/lock/lock64 appears to be
the better alternative compared to terminal I/O failures.  Besides, a
caller of this blocking request API should at least in theory be
prepared to cope with transaction durations in the order of a few seconds.
IEEE 1394 specifies split transaction timeouts of up to 8 seconds.  An
application which needs more control should use the non-blocking request
API, i.e. raw1394_start_read/write/lock/lock64.

We specifically only retry after ack-busy, not after any of the other
types of transaction failures that may or may not succeed if retried.

This change is only done in the firewire-core backend (a.k.a. juju).
The same could be added to the raw1394 backend (a.k.a. linux1394) but is
not as important there, perhaps because transaction completion latency
in the ieee1394 core very much increases the success rate of existing
retry code in libavc1394 and friends.

Note, this does not fix every and all FCP transaction problems.  There
are e.g. certain JVC camcorders which do not properly complete FCP
transactions if an application frequently polls for status or requests
status right before a control request, even with an order of magnitude
greater delays than used in this patch.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Reviewed-by: Dan Dennedy <dan@dennedy.org>
2011-10-22 10:58:43 +02:00
Stefan Richter db5f202d5d redirect Config ROM reads into the kernel's ROM cache
The kernel already read each node's Configuration ROM and cached it.
So let all libraw1394 clients read from that cache instead of having
to perform all those transactions all over again.

This reduces bus traffic at application start-up and at each bus reset.
It also makes all Configuration ROM accesses fool-proof and robust.

This together with the kernel patch "firewire: core: handle ack_busy
when fetching the Config ROM" lets me use an old Panasonic camcorder
which requires us to keep pauses between response and request ---
longer than librom1394's retry pause --- with dvgrab (though still
with frequent failures of write requests to FCP_COMMAND, i.e. with lots
of "send oops" noise in the console and occasionally having to repeat
key-presses in interactive mode).

For simplicity of implementation, only the blocking raw1394_read() is
modified, not the nonblocking raw1394_start_read().

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2011-08-21 20:25:50 +02:00
Stefan Richter 52099f7148 configure.ac, Changelog, NEWS: update to version 2.0.7
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2011-03-08 20:13:51 +01:00
Clemens Ladisch 793b7639cf fix start_on_cycle on firewire-core
Libraw1394 uses raw1394's convention of cycle numbers always being less
than one second, i.e., in the range 0..7999.

Firewire-core uses raw cycle numbers as used by the hardware, i.e., with
several additional bits for the seconds.  This was correctly handled
when presenting timestamps returned by the kernel to the application,
but the application's start_on_cycle value was passed directly to the
kernel.

To fix this, do the same calculations that ohci1394 did internally,
i.e., interpret the start_on_cycle value as relative to the current
seconds value of the cycle timer.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2011-02-25 19:45:49 +01:00
Clemens Ladisch 728f538340 do not delay iso packet queueing
Libraw1394's attempt to optimize away the packet queueing ioctl syscall
overhead was a little bit too successful: when used with FFADO's
streaming system, it ended up delaying packets after their intended
transmission time.

For now, to ensure correctness, don't try to optimize anything.

This makes FFADO playback on Juju with my DICE work.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2011-02-25 18:42:55 +01:00
Stefan Richter 9f2e0dac88 configure.ac, Changelog, NEWS etc.: update to version 2.0.6
Also update repo info and maintainer status per Dan's suggestion.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-11-01 23:25:36 +01:00
Stefan Richter 20df6877ae arm on firewire-core: Remove leftover debug printfs
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-10-20 21:08:23 +02:00
Stefan Richter 7416da6112 Be more careful when copying response payloads on firewire-core
When faced with bogus config ROM read responses from an audio device
that did not support block requests as advertized, libffado's csr1212
code was able to recover when running on top of raw1394 but corrupted
its config ROM cache when running on top of firewire-core.
http://subversion.ffado.org/ticket/299

While the actual cause was a combination of firmware bug of the device
and flaw in csr1212.c of libffado, the much less graceful behavior when
running on firewire-core was obviously due to libraw1394's
firewire-core backend.  Hence,
  - do not write into the client's buffer if rcode != RCODE_COMPLETE,
  - do not copy more data than the actual response contained.

The latter safeguard is not overly effective though.  The libraw1394 API
has no means to inform a client about the error case that a responder
node sent less bytes than were requested.  (The case that the responder
sent more bytes than requested is covered up by the kernel already.)
Should we synthesize an I/O failure?  Does not sound ideal either.
However, such a size mismatch should never happen; the important part of
this change is the RCODE_COMPLETE check.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:48:18 +02:00
Stefan Richter 824ababa4d Implement raw1394_(start_)phy_packet_write() on firewire-core
Requires kernel 2.6.36 or newer at runtime and linux-headers 2.6.36 or newer
at build time.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:27:09 +02:00
Stefan Richter 926e9ea3ad Filter incoming requests per card
If multiple cards are installed, firewire-core will emit requests from
nodes on any of the cards to clients.  This is not expected by
libraw1394 clients since a raw1394handle_t is bound to a single card
alias port.

On kernel 2.6.36 and newer we can filter out requests from other cards.
Note that we still need to call the response ioctl in order to release
kernel resources associated with an inbound transaction.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:27:03 +02:00
Stefan Richter d3ace3dfb4 Fix FCP and ARM source node ID on firewire-core
The firewire-core (juju) backend of libraw1394 installs address range
mappings on the default ioctl fd, i.e. a file that represents a random
device on the chosen port.  It receives incoming requests from any
sender node via this address range mapping.  Due to a kernel ABI
limitation, the sender node ID is not known though.  So far libraw1394
simply assumed the node ID of the device that provided the default
ioctl fd.  This only works if there is only one accessible fd on the
entire bus.

This limitation caused for example libffado to fail to work with
another AV/C or IIDC device attached to the bus, because node IDs of
FCP requests and FCP responses did not match since the latter were
wrong.  FCP clients which did not check sender node IDs were seemingly
not affected by this bug.  The bug is fixed by a kernel ABI extension
in Linux 2.6.36.  This libraw1394 change implements libraw1394's
counterpart to this ABI extension.

Hence this libraw1394 fix requires
  - kernel-headers 2.6.36 or later at build time of libraw1394
  - kernel 2.6.36 or later at runtime.
Otherwise, libraw1394 simply degrades to the faulty previous behaviour.

Side note:  The change of IMPLEMENTED_CDEV_ABI_VERSION to 4 requires
that we fill in struct fw_cdev_allocate.region_end which was added in
the ABI v4.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:27:01 +02:00
Stefan Richter 3fc1f00be3 Rename a few kernel ABI testing helpers
Use more uniform names along the lines of abi_has_some_feature(...).

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:26:58 +02:00
Stefan Richter a29d69af5d Do not use a random FW_CDEV_VERSION as our implemented ABI version
Since linux/firewire-cdev.h header file and libraw1394 sources are
distributed separately, it is wrong to fill in a constant from that
header into the FW_CDEV_IOC_GET_INFO ioctl as the ABI version which
libraw1394 supports.  This may not be forward compatible if an old
libraw1394 is compiled with a new kernel header and ran on top of a
kernel that implements new features that require a compatible
userland.

OK, the damage is already done in released versions of libraw1394.
Hence the FW_CDEV_VERSION of the kernel header file is not going to
be updated anymore in future kernel versions.  (Only the version
internally to firewire-core will be incremented further.)

But let's remove the buggy usage of FW_CDEV_VERSION nevertheless.
Developers of other firewire-cdev client programs might look at
libraw1394 sources.  The libraw1394 sources should not teach them
how to do it wrong.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:26:56 +02:00
Stefan Richter 8af54fd97d tools/dumpiso: Add write() return code checks, fix harmless format string bug
Addresses a few compiler warnings about unused results and format string
mismatch.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:26:55 +02:00
Stefan Richter b40bb76891 tools/testlibraw: Fix a harmless format string bug
The compiler warned that size_t and %d don't go well together.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:26:54 +02:00
Stefan Richter 808cc7ee2c Always imply iso shutdown in fw_destroy_handle
because ieee1394_destroy_handle does it too.  Otherwise, clients which
rely on the ieee1394 backend behaviour leak memory when running on the
juju backend.

Also add the ability to call fw_iso_shutdown multiple times or before
a successful context initialization.  Faulty clients might rely on it
based on ieee1394 backend behaviour.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:25:22 +02:00
Stefan Richter c18094afb2 Treat the kernel's iso context handle as opaque item
Libraw1394 must not rely on the kernel always handing out the value 0
as handle of the (first) allocated isochronous I/O context.  For now
this assumption is true but it may not stay that way forever.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:18:10 +02:00
Stefan Richter c321058ae3 Fix raw1394_iso_stop on firewire-core
The argument to FW_CDEV_IOC_STOP_ISO was missing.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:18:08 +02:00
Stefan Richter 9d47becf25 Add missing malloc failure checks
Also add errno = ENOMEM because it is said that that some malloc
implementations might miss to do so.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-09-07 11:18:05 +02:00
Peter Hurley b15039ceb8 Fix for overlooked device HUP with 'firewire' stack
When EPOLLHUP event is received in fw_loop_iterate(), it is or'd
with EPOLLERR. The EPOLLHUP event was then overlooked in
handle_device_event() with unpredictable-but-generally bad results.

This problem has been rediscovered several times.
http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13330
http://thread.gmane.org/gmane.linux.kernel.firewire.devel/13779

Reported-by: B.J. Buchalter <bj@mhlabs.com>
Reported-by: Michael Thireos <mthireos@vanteon.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-04-17 10:36:00 +02:00
Stefan Richter f806f3d0de Fix documentation of return values of raw1394_start_ family of functions
If running on top of the raw1394 kernel driver (any kernel version) or
on top of firewire-core (kernel version <= 2.6.29), raw1394_start_*
functions will return a value > 0 on success, not == 0.  Only with
firewire-core of kernel 2.6.30 or later, == 0 is returned on success.

The exact value depends on which driver is used, on CPU architecture,
and on request payload size in case of some types of requests.  In any
case, only that the value is > or == 0 on success (but == -1 on
failure) is significant to libraw1394 client applications.

This mismatch between documentation and implementation was already
present in older libraw1394 versions, including v1.x.  For the time
being, do not change the implementation, only adjust the documentation.

Reported-by: Dr. David Alan Gilbert
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-02-01 22:10:12 +01:00
Stefan Richter cf7b3e4df0 doc: let "make clean" remove generated HTML files
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-02-01 22:10:12 +01:00
Stefan Richter 30662aab37 Document contact address (linux1394-devel) more clearly
Questions and patches should be posted to the list rather than just sent
as personal mail to Dan.  That way, more people can answer or review it
without Dan having to forward libraw1394 mails to the list all the time.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-02-01 22:10:12 +01:00
Sebastian Schüppel 5941490cd7 update README: replace outdated link to wiki
Signed-off-by: Sebastian <schseb@ubuntu.(none)>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2010-02-01 22:10:12 +01:00
Stefan Richter 6b7b3cbc1e Fix "make doc".
Reported by Guus Sliepen:  "make doc" failed due to missing doctype,
unknown elements, and duplicate element IDs in libraw1394.sgml.

The fix is to declare a recent DTD (matching the one which is used
in current Linux kernel documentation docbooks) and to make the
conflicting element IDs unique.

The latter part of the fix is just temporary.  In order to avoid the
conflict when the documentation is updated the next time, also fix the
kerneldoc comments of the respective API elements:  These are typedefs,
hence kernel-doc needs their comments prepended by "typedef ".

Tested with Gentoo's docbook-xml-dtd 4.5, docbook-xsl-stylesheets
1.75.2, docbook-sgml-utils 0.6.14, and openjade 1.3.2-r1.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2010-01-10 14:47:44 -08:00
Dan Dennedy 844a967b97 Update ChangeLog for release.
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2009-12-26 17:09:52 -08:00
Dan Dennedy ab02c6ae53 Set to version 2.0.5.
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2009-12-26 17:09:07 -08:00
Dan Dennedy 7fd7f4b5a4 Update ChangeLog for release.
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2009-12-26 08:28:31 -08:00
Dan Dennedy 284f2d9e73 Update release notes.
Signed-off-by: Dan Dennedy <dan@dennedy.org>
2009-12-26 08:25:43 -08:00
Stefan Richter 4c4d62f248 Addendum to 'Calculate iso receive cycles on firewire-core'
The number of packets is a 4th of the number of header bytes (in case of
ABI version 1).  Also, wrap after an increment over 8000.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
2009-11-23 21:41:02 +01:00
Jay Fenlason 72e5368aed Initialize unused fields in ioctl arguments
This change is essentially cosmetic:  Set fields of structs passed to
the kernel via ioctl so that valgrind will not complain about them.

Signed-off-by: Jay Fenlason <fenlason@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (changelog, comments)
2009-11-22 23:34:47 +01:00