public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@maxwell.research.nokia.com>
To: "linux-media@vger.kernel.org" <linux-media@vger.kernel.org>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Hans Verkuil <hverkuil@xs4all.nl>,
	"Ivan T. Ivanov" <iivanov@mm-sol.com>,
	Guru Raj <gururaj.nagendra@intel.com>,
	Cohen David Abraham <david.cohen@nokia.com>
Subject: [PATCH 0/8] V4L2 file handles and event interface
Date: Sat, 06 Feb 2010 20:00:58 +0200	[thread overview]
Message-ID: <4B6DAE5A.5090508@maxwell.research.nokia.com> (raw)

[-- 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;
}

             reply	other threads:[~2010-02-06 18:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-06 18:00 Sakari Ailus [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B6DAE5A.5090508@maxwell.research.nokia.com \
    --to=sakari.ailus@maxwell.research.nokia.com \
    --cc=david.cohen@nokia.com \
    --cc=gururaj.nagendra@intel.com \
    --cc=hverkuil@xs4all.nl \
    --cc=iivanov@mm-sol.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox