forked from AmmarkoV/VideoInput
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintV4L2.c
254 lines (231 loc) · 8.95 KB
/
PrintV4L2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include "PrintV4L2.h"
/*
THIS FILE WILL BE DELETED
void print(struct v4l2_capability cap)
{
fprintf(stderr,"driver: %s\n",cap.driver);
fprintf(stderr,"card: %s\n",cap.card);
fprintf(stderr,"bus_info: %s\n",cap.bus_info);
fprintf(stderr,"version: %u.%u.%u\n",
(cap.version >> 16) & 0xFF,
(cap.version >> 8) & 0xFF,
cap.version & 0xFF);
fprintf(stderr,"capabilities:\n");
fprintf(stderr," V4L2_CAP_VIDEO_CAPTURE %d\n",(cap.capabilities & 0x00000001) !=0);
fprintf(stderr," V4L2_CAP_VIDEO_OUTPUT %d\n",(cap.capabilities & 0x00000002) !=0);
fprintf(stderr," V4L2_CAP_VIDEO_OVERLAY %d\n",(cap.capabilities & 0x00000004) !=0);
fprintf(stderr," V4L2_CAP_VBI_CAPTURE %d\n",(cap.capabilities & 0x00000010) !=0);
fprintf(stderr," V4L2_CAP_VBI_OUTPUT %d\n",(cap.capabilities & 0x00000020) !=0);
fprintf(stderr," V4L2_CAP_SLICED_VBI_CAPTURE %d\n",(cap.capabilities & 0x00000040) !=0);
fprintf(stderr," V4L2_CAP_SLICED_VBI_OUTPUT %d\n",(cap.capabilities & 0x00000080) !=0);
fprintf(stderr," V4L2_CAP_RDS_CAPTURE %d\n",(cap.capabilities & 0x00000100) !=0);
fprintf(stderr," V4L2_CAP_TUNER %d\n",(cap.capabilities & 0x00010000) !=0);
fprintf(stderr," V4L2_CAP_AUDIO %d\n",(cap.capabilities & 0x00020000) !=0);
fprintf(stderr," V4L2_CAP_RADIO %d\n",(cap.capabilities & 0x00040000) !=0);
fprintf(stderr," V4L2_CAP_READWRITE %d\n",(cap.capabilities & 0x01000000) !=0);
fprintf(stderr," V4L2_CAP_ASYNCIO %d\n",(cap.capabilities & 0x02000000) !=0);
fprintf(stderr," V4L2_CAP_STREAMING %d\n",(cap.capabilities & 0x04000000) !=0);
}
void print(struct v4l2_format fmt)
{
print(fmt.type);
print(fmt.fmt.pix);
print(fmt.fmt.win);
print(fmt.fmt.vbi);
//print(fmt.fmt.sliced);
}
void print(struct v4l2_pix_format pix)
{
fprintf(stderr,"width: %d\n",pix.width);
fprintf(stderr,"height: %d\n",pix.height);
printPixelFormat(pix.pixelformat);
print(pix.field);
fprintf(stderr,"bytesperline: %d\n",pix.bytesperline);
fprintf(stderr,"sizeimage: %d\n",pix.sizeimage);
print(pix.colorspace);
fprintf(stderr,"priv: %d\n",pix.priv);
}
void print(struct v4l2_window window)
{
print(window.w);
print(window.field);
fprintf(stderr,"chromakey: %d\n",window.chromakey);
fprintf(stderr,"clipcount: %d\n",window.clipcount);
print(window.clips);
}
void print(struct v4l2_vbi_format vbi)
{
fprintf(stderr,"sampling_rate: %d\n",vbi.sampling_rate);
fprintf(stderr,"offset: %d\n",vbi.offset);
fprintf(stderr,"samples_per_line: %d\n",vbi.samples_per_line);
fprintf(stderr,"sample_format: %d\n",vbi.sample_format);
fprintf(stderr,"start[0]: %d\n",vbi.start[0]);
fprintf(stderr,"start[1]: %d\n",vbi.start[1]);
fprintf(stderr,"count[0]: %d\n",vbi.count[0]);
fprintf(stderr,"count[1]: %d\n",vbi.count[1]);
fprintf(stderr,"flags: %d\n",vbi.flags);
}
void print(struct v4l2_queryctrl ctrl)
{
fprintf(stderr,"name: %s\n",ctrl.name);
fprintf(stderr,"id: %d\n",ctrl.id);
fprintf(stderr,"type: %d\n",ctrl.type);
fprintf(stderr,"minimum: %d\n",ctrl.minimum);
fprintf(stderr,"maximum: %d\n",ctrl.maximum);
fprintf(stderr,"step: %d\n",ctrl.step);
fprintf(stderr,"default_value: %d\n",ctrl.default_value);
fprintf(stderr,"flags: %d\n",ctrl.flags);
}
void print(struct v4l2_control control)
{
fprintf(stderr,"id: %d\n",control.id);
fprintf(stderr,"value: %d\n",control.value);
}
//void print(struct v4l2_sliced_vbi_format sliced)
//{
//}
void print(struct v4l2_clip *clip)
{
if (clip!=NULL)
{
fprintf(stderr,"clip:\n");
print(clip->c);
print(clip->next);
}
}
void print(struct v4l2_rect rect)
{
fprintf(stderr,"left: %d\n",rect.left);
fprintf(stderr,"top: %d\n",rect.top);
fprintf(stderr,"width: %d\n",rect.width);
fprintf(stderr,"height: %d\n",rect.height);
}
void print(v4l2_buf_type type)
{
fprintf(stderr,"type: ");
if (type==V4L2_BUF_TYPE_VIDEO_CAPTURE)
fprintf(stderr,"V4L2_BUF_TYPE_VIDEO_CAPTURE\n");
else if (type==V4L2_BUF_TYPE_VIDEO_OUTPUT)
fprintf(stderr,"V4L2_BUF_TYPE_VIDEO_OUTPUT\n");
else if (type==V4L2_BUF_TYPE_VIDEO_OVERLAY)
fprintf(stderr,"V4L2_BUF_TYPE_VIDEO_OVERLAY\n");
else if (type==V4L2_BUF_TYPE_VBI_CAPTURE)
fprintf(stderr,"V4L2_BUF_TYPE_VBI_CAPTURE\n");
else if (type==V4L2_BUF_TYPE_VBI_OUTPUT)
fprintf(stderr,"V4L2_BUF_TYPE_VBI_OUTPUT\n");
//else if (type==V4L2_BUF_TYPE_SLICED_VBI_CAPTURE)
// fprintf(stderr,"V4L2_BUF_TYPE_SLICED_VBI_CAPTURE\n");
//else if (type==V4L2_BUF_TYPE_SLICED_VBI_OUTPUT)
// fprintf(stderr,"V4L2_BUF_TYPE_SLICED_VBI_OUTPUT\n");
else if (type==V4L2_BUF_TYPE_PRIVATE)
fprintf(stderr,"V4L2_BUF_TYPE_PRIVATE\n");
else fprintf(stderr,"UNKNOWN\n");
}
void print(v4l2_field field)
{
fprintf(stderr,"field: ");
if (field==V4L2_FIELD_ANY)
fprintf(stderr,"V4L2_FIELD_ANY\n");
else if (field==V4L2_FIELD_NONE)
fprintf(stderr,"V4L2_FIELD_NONE\n");
else if (field==V4L2_FIELD_TOP)
fprintf(stderr,"V4L2_FIELD_TOP\n");
else if (field==V4L2_FIELD_BOTTOM)
fprintf(stderr,"V4L2_FIELD_BOTTOM\n");
else if (field==V4L2_FIELD_INTERLACED)
fprintf(stderr,"V4L2_FIELD_INTERLACED\n");
else if (field==V4L2_FIELD_SEQ_TB)
fprintf(stderr,"V4L2_FIELD_SEQ_TB\n");
else if (field==V4L2_FIELD_SEQ_BT)
fprintf(stderr,"V4L2_FIELD_SEQ_BT\n");
else if (field==V4L2_FIELD_ALTERNATE)
fprintf(stderr,"V4L2_FIELD_ALTERNATE\n");
else fprintf(stderr,"UNKNOWN\n");
}
void print(v4l2_colorspace colorspace)
{
fprintf(stderr,"colorspace: ");
if (colorspace==V4L2_COLORSPACE_SMPTE170M)
fprintf(stderr,"V4L2_COLORSPACE_SMPTE170M\n");
else if (colorspace==V4L2_COLORSPACE_SMPTE240M)
fprintf(stderr,"V4L2_COLORSPACE_SMPTE240M\n");
else if (colorspace==V4L2_COLORSPACE_REC709)
fprintf(stderr,"V4L2_COLORSPACE_REC709\n");
else if (colorspace==V4L2_COLORSPACE_BT878)
fprintf(stderr,"V4L2_COLORSPACE_BT878\n");
else if (colorspace==V4L2_COLORSPACE_470_SYSTEM_M)
fprintf(stderr,"V4L2_COLORSPACE_470_SYSTEM_M\n");
else if (colorspace==V4L2_COLORSPACE_470_SYSTEM_BG)
fprintf(stderr,"V4L2_COLORSPACE_470_SYSTEM_BG\n");
else if (colorspace==V4L2_COLORSPACE_JPEG)
fprintf(stderr,"V4L2_COLORSPACE_JPEG\n");
else if (colorspace==V4L2_COLORSPACE_SRGB)
fprintf(stderr,"V4L2_COLORSPACE_SRGB\n");
else fprintf(stderr,"UNKNOWN\n");
}
void printPixelFormat(__u32 pixelformat)
{
fprintf(stderr,"pixelformat: ");
if (pixelformat==V4L2_PIX_FMT_RGB332)
fprintf(stderr,"V4L2_COLORSPACE_470_SYSTEM_BG\n");
else if (pixelformat==V4L2_PIX_FMT_RGB555)
fprintf(stderr,"V4L2_PIX_FMT_RGB555\n");
else if (pixelformat==V4L2_PIX_FMT_RGB565)
fprintf(stderr,"V4L2_PIX_FMT_RGB565\n");
else if (pixelformat==V4L2_PIX_FMT_RGB555X)
fprintf(stderr,"V4L2_PIX_FMT_RGB555X\n");
else if (pixelformat==V4L2_PIX_FMT_RGB565X)
fprintf(stderr,"V4L2_PIX_FMT_RGB565X\n");
else if (pixelformat==V4L2_PIX_FMT_BGR24)
fprintf(stderr,"V4L2_PIX_FMT_BGR24\n");
else if (pixelformat==V4L2_PIX_FMT_RGB24)
fprintf(stderr,"V4L2_PIX_FMT_RGB24\n");
else if (pixelformat==V4L2_PIX_FMT_BGR32)
fprintf(stderr,"V4L2_PIX_FMT_BGR32\n");
else if (pixelformat==V4L2_PIX_FMT_RGB32)
fprintf(stderr,"V4L2_PIX_FMT_RGB32\n");
else if (pixelformat==V4L2_PIX_FMT_GREY)
fprintf(stderr,"V4L2_PIX_FMT_GREY\n");
else if (pixelformat==V4L2_PIX_FMT_YVU410)
fprintf(stderr,"V4L2_PIX_FMT_YVU410\n");
else if (pixelformat==V4L2_PIX_FMT_YVU420)
fprintf(stderr,"V4L2_PIX_FMT_YVU420\n");
else if (pixelformat==V4L2_PIX_FMT_YUYV)
fprintf(stderr,"V4L2_PIX_FMT_YUYV\n");
else if (pixelformat==V4L2_PIX_FMT_UYVY)
fprintf(stderr,"V4L2_PIX_FMT_UYVY\n");
else if (pixelformat==V4L2_PIX_FMT_YUV422P)
fprintf(stderr,"V4L2_PIX_FMT_YUV422P\n");
else if (pixelformat==V4L2_PIX_FMT_YUV411P)
fprintf(stderr,"V4L2_PIX_FMT_YUV411P\n");
else if (pixelformat==V4L2_PIX_FMT_Y41P)
fprintf(stderr,"V4L2_PIX_FMT_Y41P\n");
else if (pixelformat==V4L2_PIX_FMT_NV12)
fprintf(stderr,"V4L2_PIX_FMT_NV12\n");
else if (pixelformat==V4L2_PIX_FMT_NV21)
fprintf(stderr,"V4L2_PIX_FMT_NV21\n");
else if (pixelformat==V4L2_PIX_FMT_YUV410)
fprintf(stderr,"V4L2_PIX_FMT_YUV410\n");
else if (pixelformat==V4L2_PIX_FMT_YUV420)
fprintf(stderr,"V4L2_PIX_FMT_YUV420\n");
else if (pixelformat==V4L2_PIX_FMT_YYUV)
fprintf(stderr,"V4L2_PIX_FMT_YYUV\n");
else if (pixelformat==V4L2_PIX_FMT_HI240)
fprintf(stderr,"V4L2_PIX_FMT_HI240\n");
else if (pixelformat==V4L2_PIX_FMT_SBGGR8)
fprintf(stderr,"V4L2_PIX_FMT_SBGGR8\n");
else if (pixelformat==V4L2_PIX_FMT_MJPEG)
fprintf(stderr,"V4L2_PIX_FMT_MJPEG\n");
else if (pixelformat==V4L2_PIX_FMT_JPEG)
fprintf(stderr,"V4L2_PIX_FMT_JPEG\n");
else if (pixelformat==V4L2_PIX_FMT_DV)
fprintf(stderr,"V4L2_PIX_FMT_DV\n");
else if (pixelformat==V4L2_PIX_FMT_MPEG)
fprintf(stderr,"V4L2_PIX_FMT_MPEG\n");
else if (pixelformat==V4L2_PIX_FMT_WNVA)
fprintf(stderr,"V4L2_PIX_FMT_WNVA\n");
else if (pixelformat==V4L2_PIX_FMT_SN9C10X)
fprintf(stderr,"V4L2_PIX_FMT_SN9C10X\n");
else fprintf(stderr,"UNKNOWN\n");
}
*/