1 .\" $NetBSD: video.9,v 1.4 2008/09/08 22:21:47 ahoka Exp $
3 .\" Copyright (c) 2008 Patrick Mahoney
4 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 .\" POSSIBILITY OF SUCH DAMAGE.
33 .Nd interface between low and high level video drivers
37 .Fn video_attach_mi "const struct video_hw_if *hw_if" "device_t hw_dev"
39 .Fn video_submit_payload "device_t vl_dev" "const struct video_payload *payload"
41 The video device driver is divided into a high level, machine
42 independent layer, and a low level hardware dependent layer.
43 The interface between these is the
45 structure function pointers called by the video layer, and video layer
46 functions called by the hardware driver.
48 The high level video driver attaches to the low level driver
53 struct is as shown below.
55 is the device struct for the hardware device.
56 Return value is the video layer device.
59 int (*open)(void *, int); /* open hardware */
60 void (*close)(void *); /* close hardware */
62 const char * (*get_devname)(void *);
64 int (*enum_format)(void *, uint32_t, struct video_format *);
65 int (*get_format)(void *, struct video_format *);
66 int (*set_format)(void *, struct video_format *);
67 int (*try_format)(void *, struct video_format *);
69 int (*start_transfer)(void *);
70 int (*stop_transfer)(void *);
72 int (*control_iter_init)(void *, struct video_control_iter *);
73 int (*control_iter_next)(void *, struct video_control_iter *);
74 int (*get_control_desc_group)(void *,
75 struct video_control_desc_group *);
76 int (*get_control_group)(void *, struct video_control_group *);
77 int (*set_control_group)(void *, const struct video_control_group *);
81 The upper layer of the video driver allocates buffers for video
83 The hardware driver submits data to the video layer with
84 .Fa video_submit_payload .
86 is the video layer device returned by
89 struct video_payload {
96 .Bl -tag -width indent
98 Pointer to the video data for this payload.
100 portion of the data in one video sample or frame.
102 Size in bytes of the video data in this payload
104 Frame number to which this payload belongs.
105 The hardware driver must toggle the frame number between 0 and 1
106 so the video layer can detect sample or frame boundaries.
108 Optional end of frame marker.
109 If the hardware layer sets this, the
110 video layer can immediately pass the completed sample or frame to
111 userspace rather than waiting for the next payload to toggle
114 .Sh HARDWARE-LAYER FUNCTIONS
117 are described in some more detail below.
118 Some fields are optional and can be set to
121 .Bl -tag -width indent
122 .It Dv int open(void *hdl, int flags)
123 optional, is called when the video device is opened.
124 It should initialize the hardware for I/O.
125 Every successful call to
127 is matched by a call to
129 Return 0 on success, otherwise an error code.
130 .It Dv void close(void *hdl)
131 optional, is called when the audio device is closed.
132 .It Dv const char * get_devname(void *hdl)
133 mandatory, returns a NUL-terminated string naming the device, e.g. a
134 vendor and product model name.
135 .It Dv int enum_format(void *hdl, uint32_t index, struct video_format *format);
136 mandatory, called with an
142 with the format description at that index.
143 Returns 0 on success, otherwise an error code.
144 .It Dv int get_format(void *hdl, struct video_format *format)
147 with the current video format.
148 There should be a default format so
149 this function works before and streaming has begun.
150 Returns 0 on success, otherwise an error code.
151 .It Dv int set_format(void *hdl, struct video_format *format)
152 mandatory, sets the format of the video stream based on
156 with the actual format used which may not be the same as requested.
157 Returns 0 on success, otherwise an error code.
158 .It Dv int try_format(void *hdl, struct video_format *format)
161 but does not actually change the stream format, just checks what is
163 Returns 0 on success, otherwise an error code.
164 .It Dv int start_transfer(void *hdl)
165 mandatory, starts the capture of video frames.
167 must be submitted to the video layer with repeated calls to
168 .Fn video_submit_payload .
169 .It Dv int stop_transfer(void *hdl)
170 .It Dv int control_iter_init(void *hdl, struct video_control_iter *)
171 Does nothing at this time.
172 .It Dv int control_iter_next(void *hdl, struct video_control_iter *)
173 Does nothing at this time.
174 .It Dv int get_control_group(void *hdl, struct video_control_group *)
175 .It Dv int set_control_group(void *hdl, struct video_control_group *)
180 .An Patrick Mahoney Aq pat@polycrystal.org
183 Only supports a single video capture stream.
184 Does not support output streams.
185 Format handling may change in the future.
186 Control handling may change.
187 Current design requires copying all incoming video data.