1 /******************************************************************************
5 ******************************************************************************/
8 * Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
11 * This is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * The software is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this software; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 /*****************************************************************************/
29 #include "easycap_debug.h"
31 /*---------------------------------------------------------------------------*/
33 * THE LEAST SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING:
37 /*---------------------------------------------------------------------------*/
38 const struct easycap_standard easycap_standard[] = {
40 .mask = 0x000F & PAL_BGHIN ,
43 .id = (V4L2_STD_PAL_B | V4L2_STD_PAL_G | V4L2_STD_PAL_H | \
44 V4L2_STD_PAL_I | V4L2_STD_PAL_N),
46 .frameperiod = {1, 25},
48 .reserved = {0, 0, 0, 0}
51 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
53 .mask = 0x000F & NTSC_N_443 ,
56 .id = V4L2_STD_UNKNOWN,
58 .frameperiod = {1, 25},
60 .reserved = {0, 0, 0, 0}
63 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
65 .mask = 0x000F & PAL_Nc ,
68 .id = V4L2_STD_PAL_Nc,
70 .frameperiod = {1, 25},
72 .reserved = {0, 0, 0, 0}
75 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
77 .mask = 0x000F & NTSC_N ,
80 .id = V4L2_STD_UNKNOWN,
82 .frameperiod = {1, 25},
84 .reserved = {0, 0, 0, 0}
87 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
89 .mask = 0x000F & SECAM ,
94 .frameperiod = {1, 25},
96 .reserved = {0, 0, 0, 0}
99 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
101 .mask = 0x000F & NTSC_M ,
104 .id = V4L2_STD_NTSC_M,
106 .frameperiod = {1, 30},
108 .reserved = {0, 0, 0, 0}
111 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
113 .mask = 0x000F & NTSC_M_JP ,
116 .id = V4L2_STD_NTSC_M_JP,
118 .frameperiod = {1, 30},
120 .reserved = {0, 0, 0, 0}
123 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
125 .mask = 0x000F & PAL_60 ,
128 .id = V4L2_STD_PAL_60,
130 .frameperiod = {1, 30},
132 .reserved = {0, 0, 0, 0}
135 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
137 .mask = 0x000F & NTSC_443 ,
140 .id = V4L2_STD_NTSC_443,
142 .frameperiod = {1, 30},
144 .reserved = {0, 0, 0, 0}
147 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
149 .mask = 0x000F & PAL_M ,
152 .id = V4L2_STD_PAL_M,
154 .frameperiod = {1, 30},
156 .reserved = {0, 0, 0, 0}
159 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
164 /*---------------------------------------------------------------------------*/
166 * THE 16-BIT easycap_format.mask HAS MEANING:
167 * (least significant) BIT 0: 0 => PAL, 25 FPS; 1 => NTSC, 30 FPS
168 * BITS 1-3: RESERVED FOR DIFFERENTIATING STANDARDS
169 * BITS 4-7: NUMBER OF BYTES PER PIXEL
170 * BIT 8: 0 => NATIVE BYTE ORDER; 1 => SWAPPED
171 * BITS 9-10: RESERVED FOR OTHER BYTE PERMUTATIONS
172 * BIT 11: 0 => UNDECIMATED; 1 => DECIMATED
173 * BIT 12: 0 => OFFER FRAMES; 1 => OFFER FIELDS
174 * (most significant) BITS 13-15: RESERVED FOR OTHER FIELD ORDER OPTIONS
176 * bytesperpixel IS ((0x00F0 & easycap_format.mask) >> 4)
177 * byteswaporder IS true IF (0 != (0x0100 & easycap_format.mask))
179 * decimatepixel IS true IF (0 != (0x0800 & easycap_format.mask))
181 * offerfields IS true IF (0 != (0x1000 & easycap_format.mask))
183 /*---------------------------------------------------------------------------*/
185 struct easycap_format easycap_format[1 + SETTINGS_MANY];
191 __u32 width, height, pixelformat, bytesperline, sizeimage;
192 __u32 field, colorspace;
193 __u16 mask1, mask2, mask3, mask4;
194 char name1[32], name2[32], name3[32], name4[32];
196 for (i = 0, n = 0; i < STANDARD_MANY; i++) {
201 strcpy(&name1[0], "PAL_BGHIN");
202 colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
207 strcpy(&name1[0], "SECAM");
208 colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
213 strcpy(&name1[0], "PAL_Nc");
214 colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
219 strcpy(&name1[0], "PAL_60");
220 colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
225 strcpy(&name1[0], "PAL_M");
226 colorspace = V4L2_COLORSPACE_470_SYSTEM_BG;
231 strcpy(&name1[0], "NTSC_M");
232 colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
237 strcpy(&name1[0], "NTSC_443");
238 colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
243 strcpy(&name1[0], "NTSC_M_JP");
244 colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
249 strcpy(&name1[0], "NTSC_N");
250 colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
255 strcpy(&name1[0], "NTSC_N_443");
256 colorspace = V4L2_COLORSPACE_470_SYSTEM_M;
263 for (j = 0; j < RESOLUTION_MANY; j++) {
269 strcpy(&name2[0], "_AT_720x576");
270 width = 720; height = 576; break;
275 strcpy(&name2[0], "_AT_704x576");
276 width = 704; height = 576; break;
279 strcpy(&name2[0], "_AT_640x480");
280 width = 640; height = 480; break;
285 strcpy(&name2[0], "_AT_720x480");
286 width = 720; height = 480; break;
291 strcpy(&name2[0], "_AT_360x288");
292 width = 360; height = 288; mask2 = 0x0800; break;
295 strcpy(&name2[0], "_AT_320x240");
296 width = 320; height = 240; mask2 = 0x0800; break;
301 strcpy(&name2[0], "_AT_360x240");
302 width = 360; height = 240; mask2 = 0x0800; break;
308 for (k = 0; k < PIXELFORMAT_MANY; k++) {
312 strcpy(&name3[0], "_" STRINGIZE(FMT_UYVY));
313 pixelformat = V4L2_PIX_FMT_UYVY;
314 mask3 |= (0x02 << 4);
318 strcpy(&name3[0], "_" STRINGIZE(FMT_YUY2));
319 pixelformat = V4L2_PIX_FMT_YUYV;
320 mask3 |= (0x02 << 4);
325 strcpy(&name3[0], "_" STRINGIZE(FMT_RGB24));
326 pixelformat = V4L2_PIX_FMT_RGB24;
327 mask3 |= (0x03 << 4);
331 strcpy(&name3[0], "_" STRINGIZE(FMT_RGB32));
332 pixelformat = V4L2_PIX_FMT_RGB32;
333 mask3 |= (0x04 << 4);
337 strcpy(&name3[0], "_" STRINGIZE(FMT_BGR24));
338 pixelformat = V4L2_PIX_FMT_BGR24;
339 mask3 |= (0x03 << 4);
344 strcpy(&name3[0], "_" STRINGIZE(FMT_BGR32));
345 pixelformat = V4L2_PIX_FMT_BGR32;
346 mask3 |= (0x04 << 4);
353 bytesperline = width * ((mask3 & 0x00F0) >> 4);
354 sizeimage = bytesperline * height;
356 for (m = 0; m < INTERLACE_MANY; m++) {
360 strcpy(&name4[0], "-n");
361 field = V4L2_FIELD_NONE;
364 case FIELD_INTERLACED: {
365 strcpy(&name4[0], "-i");
366 field = V4L2_FIELD_INTERLACED;
369 case FIELD_ALTERNATE: {
370 strcpy(&name4[0], "-a");
372 field = V4L2_FIELD_ALTERNATE;
378 if (SETTINGS_MANY <= n)
380 strcpy(&easycap_format[n].name[0], &name1[0]);
381 strcat(&easycap_format[n].name[0], &name2[0]);
382 strcat(&easycap_format[n].name[0], &name3[0]);
383 strcat(&easycap_format[n].name[0], &name4[0]);
384 easycap_format[n].mask = \
385 mask1 | mask2 | mask3 | mask4;
386 easycap_format[n].v4l2_format\
387 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
388 easycap_format[n].v4l2_format\
389 .fmt.pix.width = width;
390 easycap_format[n].v4l2_format\
391 .fmt.pix.height = height;
392 easycap_format[n].v4l2_format\
393 .fmt.pix.pixelformat = pixelformat;
394 easycap_format[n].v4l2_format\
395 .fmt.pix.field = field;
396 easycap_format[n].v4l2_format\
397 .fmt.pix.bytesperline = bytesperline;
398 easycap_format[n].v4l2_format\
399 .fmt.pix.sizeimage = sizeimage;
400 easycap_format[n].v4l2_format\
401 .fmt.pix.colorspace = colorspace;
402 easycap_format[n].v4l2_format\
409 if ((1 + SETTINGS_MANY) <= n)
411 easycap_format[n].mask = 0xFFFF;
414 /*---------------------------------------------------------------------------*/
415 struct v4l2_queryctrl easycap_control[] = \
417 .id = V4L2_CID_BRIGHTNESS,
418 .type = V4L2_CTRL_TYPE_INTEGER,
419 .name = "Brightness",
423 .default_value = SAA_0A_DEFAULT,
427 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
429 .id = V4L2_CID_CONTRAST,
430 .type = V4L2_CTRL_TYPE_INTEGER,
435 .default_value = SAA_0B_DEFAULT + 128,
439 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
441 .id = V4L2_CID_SATURATION,
442 .type = V4L2_CTRL_TYPE_INTEGER,
443 .name = "Saturation",
447 .default_value = SAA_0C_DEFAULT + 128,
451 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
454 .type = V4L2_CTRL_TYPE_INTEGER,
459 .default_value = SAA_0D_DEFAULT + 128,
463 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
465 .id = V4L2_CID_AUDIO_VOLUME,
466 .type = V4L2_CTRL_TYPE_INTEGER,
475 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
477 .id = V4L2_CID_AUDIO_MUTE,
478 .type = V4L2_CTRL_TYPE_BOOLEAN,
480 .default_value = true,
484 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
489 /*****************************************************************************/