summaryrefslogtreecommitdiffstats
path: root/src/fw-iso.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Use <stdint.h> types instead of non-standard typesGravatar Thomas Petazzoni 2016-03-201-1/+1
| | | | | | | | | | | | | | | | | | | The __uint32_t type is not a standard type, and not necessarily provided by all C libraries. However, <stdint.h> provides a set of standard types, which are guaranteed to be available with all C libraries. This patch therefore changes __uint32_t to uint32_t, which allows to fix the compilation with the Musl C library. This patch is already used by the Alpine Linux distribution and the Buildroot build system. Original patch from http://git.alpinelinux.org/cgit/aports/plain/main/libraw1394/fix-types.patch. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Prevent requests for previously provided iso tx packetsGravatar Jonathan Woithe 2015-04-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bugfix grew out of an extended investigation into a problem encountered by a small number of people running FFADO. FFADO would report that the tx iso cycle number supplied to the iso tx callback seemingly went backwards - something which should not ordinarily occur. The bug seemed to be sensitive to timing and in some cases would disappear when debug traces were inserted into either FFADO or libraw1394. In essence, libraw1394 was requesting tx data for cycles which had already been requested. Initial discussions can be found in the thread "Problem with RME FF800. Can not start jackd" on the ffado-user mailing list. A followup investigation is tracked in FFADO ticket number 379 (http://subversion.ffado.org/ticket/379) and referenced in the thread "Revisiting backward cycle number sequence (ticket 379)" on ffado-devel. The latter mailing list thread includes a lengthy explanation of what I think is happening. To summarise, the root of the problem seems to be that on certain machines under certain conditions, something causes the kernel to post an iso tx event at a time when fewer than irq_interval packets have been transmitted. Unfortunately it has not been possible to determine the underlying cause of this. Whatever the cause, tests carried out with the reporter of ticket 379 have shown that it is occurring. As a result, the adjustment to libraw1394's packet_count must be done with reference to the number of packets reported as transmitted by the kernel instead of simply assuming that irq_interval packets have been sent. A patch implementing this fix is at the end of this post. This fixes the problem when the newer ABI is in use, which provides tx packet timestamps (and thus an indication of the number of packets actually transmitted) to userspace. It does not address the problem when the older ABI is used, but given the nature of the problem I don't think it's possible to fix it without access to the timestamps (or at least without some way to determine the number of packets really transmitted). Testing by "juanramon" (see ticket 379) has demonstrated that it fixes the "backward cycle number" problem on his machine. Thanks to Andreas Hehn and "juanramon" for their invaluable help in tracking this down. Signed-off-by: Jonathan Woithe <jwoithe@just42.net> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Remove now unused codeGravatar Stefan Richter 2012-06-241-26/+2
| | | | Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Disable power-of-2 alignment of isochronous I/O buffersGravatar Igor Kuzmin 2012-06-241-1/+1
| | | | | | | 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>
* Enable write access to isochronous reception bufferGravatar Igor Kuzmin 2012-06-241-1/+1
| | | | Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Add raw1394_read_cycle_timer_and_clock() APIGravatar Stefan Richter 2012-06-181-2/+17
| | | | | | | | | | | | | | | | | | | 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>
* Remove unused codeGravatar Stefan Richter 2012-05-251-9/+0
| | | | Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Implement raw1394_iso_recv_flush() on JujuGravatar Clemens Ladisch 2012-03-191-1/+6
| | | | | Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* fix start_on_cycle on firewire-coreGravatar Clemens Ladisch 2011-02-251-3/+32
| | | | | | | | | | | | | | | | | | 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>
* do not delay iso packet queueingGravatar Clemens Ladisch 2011-02-251-4/+2
| | | | | | | | | | | | | | 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>
* Rename a few kernel ABI testing helpersGravatar Stefan Richter 2010-09-071-5/+10
| | | | | | Use more uniform names along the lines of abi_has_some_feature(...). Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Always imply iso shutdown in fw_destroy_handleGravatar Stefan Richter 2010-09-071-0/+3
| | | | | | | | | | | | 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>
* Treat the kernel's iso context handle as opaque itemGravatar Stefan Richter 2010-09-071-6/+7
| | | | | | | | 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>
* Fix raw1394_iso_stop on firewire-coreGravatar Stefan Richter 2010-09-071-1/+1
| | | | | | The argument to FW_CDEV_IOC_STOP_ISO was missing. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Add missing malloc failure checksGravatar Stefan Richter 2010-09-071-1/+3
| | | | | | | 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>
* Addendum to 'Calculate iso receive cycles on firewire-core'Gravatar Stefan Richter 2009-11-231-2/+5
| | | | | | | 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>
* Initialize unused fields in ioctl argumentsGravatar Jay Fenlason 2009-11-221-0/+2
| | | | | | | | 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)
* Calculate iso receive cycles on firewire-core at ABI version 1Gravatar Jay Fenlason 2009-11-221-2/+17
| | | | | | | | | More accurately report the cycle on which isochronous packets were received. Only affects libraw1394 when used with kernel 2.6.29 or older. Signed-off-by: Jay Fenlason <fenlason@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (changelog, whitespace)
* Fix reporting of isochronous transmit cycles on firewire-coreGravatar Jay Fenlason 2009-11-221-10/+46
| | | | | | | | | | | | | | | | While firewire-core's iso reception ABI was fixed in its version 2 to report the cycle of each received packet to userspace like rawiso does, this same enhancement was forgotten to add to the iso transmission ABI, causing FFADO to fail to set up and maintain streaming. Since kernel commit 31769cef2e973544164aa7d0db2e2024660d5e21, we also get iso xmit cycles in fw_cdev_event_iso_interrupt.header. Pass these to the iso receive handler. In case of older kernels, calculate cycles based on the cycle of the iso interrupt event. These are inaccurate but better than nothing. Signed-off-by: Jay Fenlason <fenlason@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (changelog, whitespace)
* Fix default isochronous IRQ interval on firewire-coreGravatar Jay Fenlason 2009-11-221-4/+7
| | | | | | | | | libraw1394 takes a negative IRQ interval to mean "every 256 packets" with the juju backend, which doesn't work well if you don't queue that many. Use buf_packets / 4 like the ieee1394 version. Signed-off-by: Jay Fenlason <fenlason@redhat.com> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> (order, comment)
* Iso reception: Use packet timestamps in juju ABI v2Gravatar Stefan Richter 2009-05-301-3/+13
| | | | | | | | | | | | In the firewire-cdev ABI v1, the kernel exported only the timestamp of interrupt packets. libraw1394 estimated the cycle of all packets between interrupt packets by continuously incrementing the cycle. In v2 of the ABI, we can obtain an accurate timestamp of each packet as provided by the OHCI controller. AFAIU, this is also what you got from raw1394/ ohci1394. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
* Change the license of the "juju" fw*.[hc] files to LGPL v2.1 as approvedGravatar Dan Dennedy 2009-02-031-13/+3
| | | | | | | by Kristian Hogsberg in an e-mail to the linux1394-devel mailing list on Feb 3, 2009. Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Work without permission to access local node's /dev/fw*Gravatar Stefan Richter 2009-01-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 10 Jan, David Moore wrote: > On Sat, 2009-01-10 at 19:28 +0100, Stefan Richter wrote: >> @@ -161,14 +160,16 @@ scan_devices(fw_handle_t handle) ... >> + for (j = 0; j < i; j++) >> + if (ports[j].card == get_info.card) >> + continue; >> + > > That continue statement doesn't do what you intended I think. From: Stefan Richter <stefanr@s5r6.in-berlin.de> Subject: [PATCH] Work without permission to access local node's /dev/fw* Fix for juju backend: libraw1394 required write permission to the character device file of the local node(s) in order to enumerate cards and for a number of other operations. This forced users to either run applications like dvgrab and kino with elevated privileges, or to configure write permission for all /dev/fw* or at least for local nodes' /dev/fw*. We now use the first accessible file which was found for each card for as many tasks as possible, instead of the local node's file. This allows distributors or admins to implement stricter access rights (default off, e.g. only on for AV/C and IIDC devices) without sacrificing functionality of said class of applications. Access to the local node is now only required by low-level tools like gscanbus. Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de> Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Fix iso_shutdown with juju firewire stackGravatar Jarod Wilson 2008-12-081-3/+21
| | | | | | | | | | | | | | | | | | Make iso start/stop/start sequences on the same handle, such as those used by apps such as MythTV behave as expected. I can finally watch video off my cable box over FireWire using MythTV w/the juju stack now. :) Initially, seemed a one-liner might be the ticket (setting handle->iso.fd = -1 at the end of fw_iso_shutdown()), but that led to memory corruption and a locked up system. What ultimately worked was essentially mimicking what the old stack did to track iso state, and call fw_iso_stop() from fw_iso_shutdown() as needed. Nb: Only lightly tested with iso receive via MythTV, but its all fairly straight-forward, I think. Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Let fw_read_cycle_timer() use the local fd instead of requiring iso to be ↵Gravatar Dan Dennedy 2008-12-071-1/+1
| | | | | | initialized Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Address some compiler warningsGravatar Stefan Richter 2008-10-281-3/+2
| | | | | | 7x unused variable, 1x assignment used as truth value, 1x pointer signedness Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Makes sure a value is returned by the function.Gravatar Erik Hovland 2008-10-281-0/+1
| | | | | | | A function can compile without returning something always. Signed-off-by: Erik Hovland <erik@hovland.org> Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Make sure that we have the right types.Gravatar Erik Hovland 2008-10-281-3/+4
| | | | | | | | When an unsigned type is assigned a signed value, the negatived value is never seen. Signed-off-by: Erik Hovland <erik@hovland.org> Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Make sure variables are initialized before used.Gravatar Erik Hovland 2008-10-281-1/+2
| | | | | Signed-off-by: Erik Hovland <erik@hovland.org> Signed-off-by: Dan Dennedy <dan@dennedy.org>
* Fix raw1394_read_cycle_timer after juju integrationGravatar Stefan Richter 2008-07-051-0/+19
| | | | | | | | The ieee1394 version of raw1394_read_cycle_timer() fell over the cliff in "First cut at integrating juju". This brings it back and adds a juju version of it. Also correct a typo in the inline documentation: s/get/read/
* Plug dir leak and initialize data structsGravatar Philippe Troin 2008-07-051-0/+2
| | | | | | | | | | | | | | While trying to track down some crashes in kino, I found the following problems with libraw1394: * There is a DIR* leak in raw1394_set_port(). * Lots of data structures are not fully initialized when calling IEEE1394 ioctl()s. These cause valgrind errors (benign, as valgrind does not know how to interpret all ioctls. However these also cause kino to crash in libraw1394. I've added a bunch of memset()s to prevent this problem from happening. Forward-ported to libraw1394 git tree by Jarod Wilson.
* Move the source code files in the juju directory into the src directory andGravatar Dan Dennedy 2008-04-301-0/+529
give them 'fw' names instead of 'juju.'