public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] V4L2 file handles and event interface
@ 2010-02-06 18:00 Sakari Ailus
  2010-02-06 18:02 ` [PATCH 1/8] V4L: File handles Sakari Ailus
                   ` (7 more replies)
  0 siblings, 8 replies; 14+ messages in thread
From: Sakari Ailus @ 2010-02-06 18:00 UTC (permalink / raw)
  To: linux-media@vger.kernel.org
  Cc: Laurent Pinchart, Hans Verkuil, Ivan T. Ivanov, Guru Raj,
	Cohen David Abraham

[-- Attachment #1: Type: text/plain, Size: 1568 bytes --]

Hi,

Here's the third version of the V4L2 file handle and event interface
patchset. I've marked this as PATCH instead of RFC for the first time.

The first patch adds the V4L2 file handle support and the rest are for
V4L2 events.

The second patch adds reference count for the v4l2_fh structures. This
is useful later when queueing events to file handles.

The next six patches are for the event interface.

The patchset has been tested with the OMAP 3 ISP driver. A simple test
program can be found as the attachment. Patches for OMAP 3 ISP are not
part of this patchset but are available in Gitorious (branch is called
event):

	git://gitorious.org/omap3camera/mainline.git event

The major change since the last RFC set is changing the kmem_cache
allocation to static per file handle allocation. The number of
allocatable events that way is likely small and can now be set by the
driver. Adding further events to free queue is also possible runtime.
Also, if a driver does not use events, the event system overhead for the
driver is limited to one pointer in v4l2_fh structure.

Locking has been also improved. The v4l2_fh structures have reference
count which makes it possible to free the list lock when working on
individual file handles. The spinlocks have been moved from events to
the file handles themselves.

To unsubscribe V4L2_EVENT_ALL, VIDIOC_UNSUBSCRIBE_EVENT has to be issued
for that event ID.

Comments would be welcome indeed. Especially on the new locking and
refcounting scheme.

Cheers,

-- 
Sakari Ailus
sakari.ailus@maxwell.research.nokia.com

[-- Attachment #2: polltest2.c --]
[-- Type: text/x-csrc, Size: 1071 bytes --]

#include <stdio.h>

#include <sys/select.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <linux/videodev2.h>
#include <mach/isp_user.h>

int main(int argc, char *argv) {
	struct v4l2_event_subscription sub;
	struct v4l2_event ev;
	int fd;
	fd_set exfds;
	int ret;

	fd = open("/dev/video0", O_RDONLY);
	if (fd < 0) {
		perror("select()");
		return 1;
	}

	printf("fd %d\n", fd);

	sub.type = V4L2_EVENT_ALL;

	ret = ioctl(fd, VIDIOC_SUBSCRIBE_EVENT, &sub);
	if (ret < 0) {
		perror("subscribe()");
	} else
		printf("okay...\n");

	FD_ZERO(&exfds);
	FD_SET(fd, &exfds);

	while (1) {
		ret = pselect(fd + 1, NULL, NULL, &exfds, NULL, NULL);
		printf("pselect %d\n", ret);
		if (ret < 0)
			break;
	
		ret = ioctl(fd, VIDIOC_DQEVENT, &ev);
		if (ret < 0) {
			perror("dequeue");
			return 1;
		} else
			printf("okay...\n");
	
		printf("type         %x\n",ev.type);
		printf("sequence     %d\n",ev.sequence);
		printf("count        %d\n",ev.count);
		printf("timestamp    %u.%9.9u\n",ev.timestamp.tv_sec,ev.timestamp.tv_nsec);
	}

	return 0;
}

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-02-07 18:29 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-06 18:00 [PATCH 0/8] V4L2 file handles and event interface Sakari Ailus
2010-02-06 18:02 ` [PATCH 1/8] V4L: File handles Sakari Ailus
2010-02-06 18:02 ` [PATCH 2/8] V4L: File handles: Add refcount to v4l2_fh Sakari Ailus
2010-02-06 18:02 ` [PATCH 3/8] V4L: Events: Add new ioctls for events Sakari Ailus
2010-02-06 18:02 ` [PATCH 4/8] V4L: Events: Support event handling in do_ioctl Sakari Ailus
2010-02-07 12:15   ` Sakari Ailus
2010-02-07 12:22     ` Hans Verkuil
2010-02-07 18:30       ` Sakari Ailus
2010-02-06 18:02 ` [PATCH 5/8] V4L: Events: Add backend Sakari Ailus
2010-02-07 12:45   ` Hans Verkuil
2010-02-07 18:29     ` Sakari Ailus
2010-02-06 18:02 ` [PATCH 6/8] V4L: Events: Count event queue length Sakari Ailus
2010-02-06 18:02 ` [PATCH 7/8] V4L: Events: Sequence numbers Sakari Ailus
2010-02-06 18:02 ` [PATCH 8/8] V4L: Events: Support all events Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox