aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/video4linux/v4l2-framework.txt51
1 files changed, 35 insertions, 16 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt
index 312a0e2f9d66..f8dcabf7852c 100644
--- a/Documentation/video4linux/v4l2-framework.txt
+++ b/Documentation/video4linux/v4l2-framework.txt
@@ -897,14 +897,38 @@ V4L2 events
897The V4L2 events provide a generic way to pass events to user space. 897The V4L2 events provide a generic way to pass events to user space.
898The driver must use v4l2_fh to be able to support V4L2 events. 898The driver must use v4l2_fh to be able to support V4L2 events.
899 899
900Useful functions: 900Events are defined by a type and an optional ID. The ID may refer to a V4L2
901object such as a control ID. If unused, then the ID is 0.
902
903When the user subscribes to an event the driver will allocate a number of
904kevent structs for that event. So every (type, ID) event tuple will have
905its own set of kevent structs. This guarantees that if a driver is generating
906lots of events of one type in a short time, then that will not overwrite
907events of another type.
908
909But if you get more events of one type than the number of kevents that were
910reserved, then the oldest event will be dropped and the new one added.
911
912Furthermore, the internal struct v4l2_subscribed_event has merge() and
913replace() callbacks which drivers can set. These callbacks are called when
914a new event is raised and there is no more room. The replace() callback
915allows you to replace the payload of the old event with that of the new event,
916merging any relevant data from the old payload into the new payload that
917replaces it. It is called when this event type has only one kevent struct
918allocated. The merge() callback allows you to merge the oldest event payload
919into that of the second-oldest event payload. It is called when there are two
920or more kevent structs allocated.
901 921
902- v4l2_event_alloc() 922This way no status information is lost, just the intermediate steps leading
923up to that state.
903 924
904 To use events, the driver must allocate events for the file handle. By 925A good example of these replace/merge callbacks is in v4l2-event.c:
905 calling the function more than once, the driver may assure that at least n 926ctrls_replace() and ctrls_merge() callbacks for the control event.
906 events in total have been allocated. The function may not be called in 927
907 atomic context. 928Note: these callbacks can be called from interrupt context, so they must be
929fast.
930
931Useful functions:
908 932
909- v4l2_event_queue() 933- v4l2_event_queue()
910 934
@@ -916,7 +940,9 @@ Useful functions:
916 940
917 The video_device->ioctl_ops->vidioc_subscribe_event must check the driver 941 The video_device->ioctl_ops->vidioc_subscribe_event must check the driver
918 is able to produce events with specified event id. Then it calls 942 is able to produce events with specified event id. Then it calls
919 v4l2_event_subscribe() to subscribe the event. 943 v4l2_event_subscribe() to subscribe the event. The last argument is the
944 size of the event queue for this event. If it is 0, then the framework
945 will fill in a default value (this depends on the event type).
920 946
921- v4l2_event_unsubscribe() 947- v4l2_event_unsubscribe()
922 948
@@ -931,14 +957,8 @@ Useful functions:
931 957
932 Returns the number of pending events. Useful when implementing poll. 958 Returns the number of pending events. Useful when implementing poll.
933 959
934Drivers do not initialise events directly. The events are initialised
935through v4l2_fh_init() if video_device->ioctl_ops->vidioc_subscribe_event is
936non-NULL. This *MUST* be performed in the driver's
937v4l2_file_operations->open() handler.
938
939Events are delivered to user space through the poll system call. The driver 960Events are delivered to user space through the poll system call. The driver
940can use v4l2_fh->events->wait wait_queue_head_t as the argument for 961can use v4l2_fh->wait (a wait_queue_head_t) as the argument for poll_wait().
941poll_wait().
942 962
943There are standard and private events. New standard events must use the 963There are standard and private events. New standard events must use the
944smallest available event type. The drivers must allocate their events from 964smallest available event type. The drivers must allocate their events from
@@ -948,5 +968,4 @@ The first event type in the class is reserved for future use, so the first
948available event type is 'class base + 1'. 968available event type is 'class base + 1'.
949 969
950An example on how the V4L2 events may be used can be found in the OMAP 970An example on how the V4L2 events may be used can be found in the OMAP
9513 ISP driver available at <URL:http://gitorious.org/omap3camera> as of 9713 ISP driver (drivers/media/video/omap3isp).
952writing this.