diff options
-rw-r--r-- | Documentation/video4linux/v4l2-framework.txt | 51 |
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 | |||
897 | The V4L2 events provide a generic way to pass events to user space. | 897 | The V4L2 events provide a generic way to pass events to user space. |
898 | The driver must use v4l2_fh to be able to support V4L2 events. | 898 | The driver must use v4l2_fh to be able to support V4L2 events. |
899 | 899 | ||
900 | Useful functions: | 900 | Events are defined by a type and an optional ID. The ID may refer to a V4L2 |
901 | object such as a control ID. If unused, then the ID is 0. | ||
902 | |||
903 | When the user subscribes to an event the driver will allocate a number of | ||
904 | kevent structs for that event. So every (type, ID) event tuple will have | ||
905 | its own set of kevent structs. This guarantees that if a driver is generating | ||
906 | lots of events of one type in a short time, then that will not overwrite | ||
907 | events of another type. | ||
908 | |||
909 | But if you get more events of one type than the number of kevents that were | ||
910 | reserved, then the oldest event will be dropped and the new one added. | ||
911 | |||
912 | Furthermore, the internal struct v4l2_subscribed_event has merge() and | ||
913 | replace() callbacks which drivers can set. These callbacks are called when | ||
914 | a new event is raised and there is no more room. The replace() callback | ||
915 | allows you to replace the payload of the old event with that of the new event, | ||
916 | merging any relevant data from the old payload into the new payload that | ||
917 | replaces it. It is called when this event type has only one kevent struct | ||
918 | allocated. The merge() callback allows you to merge the oldest event payload | ||
919 | into that of the second-oldest event payload. It is called when there are two | ||
920 | or more kevent structs allocated. | ||
901 | 921 | ||
902 | - v4l2_event_alloc() | 922 | This way no status information is lost, just the intermediate steps leading |
923 | up to that state. | ||
903 | 924 | ||
904 | To use events, the driver must allocate events for the file handle. By | 925 | A 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 | 926 | ctrls_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. | 928 | Note: these callbacks can be called from interrupt context, so they must be |
929 | fast. | ||
930 | |||
931 | Useful 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 | ||
934 | Drivers do not initialise events directly. The events are initialised | ||
935 | through v4l2_fh_init() if video_device->ioctl_ops->vidioc_subscribe_event is | ||
936 | non-NULL. This *MUST* be performed in the driver's | ||
937 | v4l2_file_operations->open() handler. | ||
938 | |||
939 | Events are delivered to user space through the poll system call. The driver | 960 | Events are delivered to user space through the poll system call. The driver |
940 | can use v4l2_fh->events->wait wait_queue_head_t as the argument for | 961 | can use v4l2_fh->wait (a wait_queue_head_t) as the argument for poll_wait(). |
941 | poll_wait(). | ||
942 | 962 | ||
943 | There are standard and private events. New standard events must use the | 963 | There are standard and private events. New standard events must use the |
944 | smallest available event type. The drivers must allocate their events from | 964 | smallest 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 | |||
948 | available event type is 'class base + 1'. | 968 | available event type is 'class base + 1'. |
949 | 969 | ||
950 | An example on how the V4L2 events may be used can be found in the OMAP | 970 | An example on how the V4L2 events may be used can be found in the OMAP |
951 | 3 ISP driver available at <URL:http://gitorious.org/omap3camera> as of | 971 | 3 ISP driver (drivers/media/video/omap3isp). |
952 | writing this. | ||