Rev 1676 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1676 | tullio | 1 | %---------------------------------------------------------------------------- |
2 | \chapter{The Frame Grabber Library} |
||
3 | %---------------------------------------------------------------------------- |
||
4 | |||
5 | The library is divided in 2 layers: the low level and the high level. The first |
||
6 | one is in charge of the acquisition board hardware control and supplies a |
||
7 | generic interface for the higher level. The second layer supplies some API |
||
8 | function for a comunication between the application and a generir video device |
||
9 | (framegrammer, webcam, etc.). |
||
10 | |||
11 | %---------------------------------------------------------------------------- |
||
12 | \section{BTTV low lever driver} |
||
13 | %---------------------------------------------------------------------------- |
||
14 | |||
15 | At the actual stage of developement is the only low lever driver ported from |
||
16 | Linux to S.Ha.R.K. Support acquisition boards based on BookTree BT8x8 chips. |
||
17 | Presents only 2 functions for opening and closing cards. |
||
18 | |||
19 | \vspace{7mm} |
||
20 | |||
21 | \begin{intest} |
||
22 | BTTV26\_INIT\index{BTTV26\_init()} |
||
23 | \end{intest} |
||
24 | |||
25 | \begin{description} |
||
26 | \item [\textbf{int BTTV26\_init(void);}] |
||
27 | \item [\textbf{Description:}] It initializes the acquisition board interface and the |
||
28 | library's internal data |
||
29 | structures. |
||
30 | \end{description} |
||
31 | |||
32 | \begin{intest} |
||
33 | BTTV26\_CLOSE\index{BTTV26\_close()} |
||
34 | \end{intest} |
||
35 | |||
36 | \begin{description} |
||
37 | \item [\textbf{int BTTV26\_close(void);}] |
||
38 | \item [\textbf{Description:}] It close the acquisition board interface. |
||
39 | \end{description} |
||
40 | |||
41 | %---------------------------------------------------------------------------- |
||
42 | \section{VideoDevice high lever interface} |
||
43 | %---------------------------------------------------------------------------- |
||
44 | |||
45 | This library supplies an abstract layer created to obtain a common interface |
||
46 | between different low level driver. The interaction with an application is quite |
||
47 | simple and implies only 2 functions: the first one open the comunication between |
||
48 | the application and the hardware through the low level driver, the second one |
||
49 | send commands to the device. |
||
50 | |||
51 | \vspace{7mm} |
||
52 | |||
53 | \begin{intest} |
||
54 | VIDEODEV26\_OPEN\index{VIDEODEV26\_open()} |
||
55 | \end{intest} |
||
56 | |||
57 | \begin{description} |
||
58 | \item [\textbf{int VIDEODEV26\_open(int num);}] |
||
59 | \item [\textbf{Description:}] It initializes the acquisition board interface and the |
||
60 | library's internal data structures. The parametetr \texttt{num} define the |
||
61 | device that must be opened. \item [Return]value: 0 if the module is installed; 1 |
||
62 | otherwise. |
||
63 | \end{description} |
||
64 | |||
65 | \begin{intest} |
||
66 | VIDEODEV26\_IOCTL\index{VIDEODEV26\_ioctl()} |
||
67 | \end{intest} |
||
68 | |||
69 | \begin{description} |
||
70 | \item [\textbf{int VIDEODEV26\_ioctl(int num, unsigned int cmd, |
||
71 | unsigned long arg);}] |
||
72 | \item [\textbf{Description:}] It send the command \texttt{cmd}, with argument |
||
73 | \texttt{arg}, to the device number \texttt{num}. \item [Return]value: It depends |
||
74 | from the command executed. |
||
75 | \end{description} |
||
76 | |||
77 | %---------------------------------------------------------------------------- |
||
78 | \subsection{Video Devices Commands} |
||
79 | %---------------------------------------------------------------------------- |
||
80 | |||
81 | This is a list of most commond videodev commands. Most of them are supported by |
||
82 | the BTTV low lever driver. There is only a major change implemented during the |
||
83 | porting phase: the VIDIOCSYNC function requires an aperiodic task PID as input. |
||
84 | When the new frame is ready, the task is activated. |
||
85 | |||
86 | \vspace{7mm} |
||
87 | |||
88 | \begin{description} |
||
89 | \item [The]full command list is: |
||
90 | \end{description} |
||
91 | |||
92 | VIDIOCSYNC - Synchronize with memory mapped capture. |
||
93 | |||
94 | VIDIOCGCAP - Get video/radio device capabilities. |
||
95 | |||
96 | VIDIOCGCHAN - Get source properties. |
||
97 | |||
98 | VIDIOCSCHAN - Select source and set properties. |
||
99 | |||
100 | VIDIOCGTUNER - Get tuner properties. |
||
101 | |||
102 | VIDIOCSTUNER - Select tuner and set properties. |
||
103 | |||
104 | VIDIOCGPICT - Get video image (picture) properties. |
||
105 | |||
106 | VIDIOCSPICT - Set video image (picture) properties. |
||
107 | |||
108 | VIDIOCCAPTURE - Enable or disable video capturing. |
||
109 | |||
110 | VIDIOCGWIN - Get video output window properties. |
||
111 | |||
112 | VIDIOCSWIN - Set video output properties. |
||
113 | |||
114 | VIDIOCGFBUF - Get direct video output frame buffer properties. |
||
115 | |||
116 | VIDIOCSFBUF - Set direct video output frame buffer properties. |
||
117 | |||
118 | VIDIOCGFREQ - Get tuner frequency property. |
||
119 | |||
120 | VIDIOCSFREQ - Set tuner frequency property (i.e., tune to new frequency). |
||
121 | |||
122 | VIDIOCGAUDIO - Get audio properties. |
||
123 | |||
124 | VIDIOCSAUDIO - Set audio properties. |
||
125 | |||
126 | VIDIOCMCAPTURE - Initiate memory mapped capture. |
||
127 | |||
128 | VIDIOCGMBUF - Get memory mapped buffer properties. |
||
129 | |||
130 | \begin{description} |
||
131 | \item [Example:] |
||
132 | \end{description} |
||
133 | |||
134 | \begin{tt} |
||
135 | \begin{verbatim} |
||
136 | /* Init videodev driver */ |
||
137 | |||
138 | VIDEODEV26_open(FRAME_GRABBER_NUMBER); |
||
139 | |||
140 | /* Select the input channel */ |
||
141 | |||
142 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGCHAN,(unsigned long)&chan); |
||
143 | |||
144 | chan.channel = channel; |
||
145 | chan.type = VIDEO_VC_TUNER; |
||
146 | chan.norm = VIDEO_TYPE_CAMERA; |
||
147 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSCHAN,(unsigned long)&chan); |
||
148 | |||
149 | /* Enable the tuner */ |
||
150 | |||
151 | tuner.tuner = 0; |
||
152 | tuner.mode = VIDEO_MODE_PAL; |
||
153 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSTUNER,(unsigned long)&tuner); |
||
154 | |||
155 | /* Select palette and depth */ |
||
156 | |||
157 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGPICT,(unsigned long)&vpic); |
||
158 | |||
159 | #ifdef COLOR |
||
160 | vpic.palette = VIDEO_PALETTE_RGB24; |
||
161 | vpic.depth = 24; |
||
162 | #else |
||
163 | vpic.palette = VIDEO_PALETTE_GREY; |
||
164 | vpic.depth = 8; |
||
165 | #endif |
||
166 | |||
167 | vpic.brightness = 35000; |
||
168 | vpic.hue = 32000; |
||
169 | vpic.contrast = 32000; |
||
170 | vpic.colour = 32000; |
||
171 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSPICT,(unsigned long)&vpic); |
||
172 | |||
173 | /* Set window dimensions */ |
||
174 | |||
175 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCGWIN,(unsigned long)&win); |
||
176 | |||
177 | win.x = 0; |
||
178 | win.y = 0; |
||
179 | win.width = FG_W; |
||
180 | win.height = FG_H; |
||
181 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSWIN,(unsigned long)&win); |
||
182 | |||
183 | /* Set the buffer */ |
||
184 | |||
185 | res = VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSFBUF,(unsigned long)(fbuf)); |
||
186 | |||
187 | /* IMPORTANT: Set the aperiodic elaboration task */ |
||
188 | |||
189 | /* When the new frame is ready, the task elaborate_PID (aperiodic), is activated.*/ |
||
190 | |||
191 | VIDEODEV26_ioctl(FRAME_GRABBER_NUMBER,VIDIOCSYNC,(unsigned long)(elaborate_PID)); |
||
192 | \end{verbatim} |
||
193 | \end{tt} |