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 /*****************************************************************************/
30 /*---------------------------------------------------------------------------*/
32 * THE LEAST SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING:
36 * THE MOST SIGNIFICANT BIT OF easycap_standard.mask HAS MEANING:
40 /*---------------------------------------------------------------------------*/
41 const struct easycap_standard easycap_standard
[] = {
43 .mask
= 0x00FF & PAL_BGHIN
,
46 .id
= (V4L2_STD_PAL_B
|
47 V4L2_STD_PAL_G
| V4L2_STD_PAL_H
|
48 V4L2_STD_PAL_I
| V4L2_STD_PAL_N
),
50 .frameperiod
= {1, 25},
52 .reserved
= {0, 0, 0, 0}
55 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
57 .mask
= 0x00FF & NTSC_N_443
,
60 .id
= V4L2_STD_UNKNOWN
,
62 .frameperiod
= {1, 25},
64 .reserved
= {0, 0, 0, 0}
67 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
69 .mask
= 0x00FF & PAL_Nc
,
72 .id
= V4L2_STD_PAL_Nc
,
74 .frameperiod
= {1, 25},
76 .reserved
= {0, 0, 0, 0}
79 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
81 .mask
= 0x00FF & NTSC_N
,
84 .id
= V4L2_STD_UNKNOWN
,
86 .frameperiod
= {1, 25},
88 .reserved
= {0, 0, 0, 0}
91 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
93 .mask
= 0x00FF & SECAM
,
98 .frameperiod
= {1, 25},
100 .reserved
= {0, 0, 0, 0}
103 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
105 .mask
= 0x00FF & NTSC_M
,
108 .id
= V4L2_STD_NTSC_M
,
110 .frameperiod
= {1, 30},
112 .reserved
= {0, 0, 0, 0}
115 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
117 .mask
= 0x00FF & NTSC_M_JP
,
120 .id
= V4L2_STD_NTSC_M_JP
,
122 .frameperiod
= {1, 30},
124 .reserved
= {0, 0, 0, 0}
127 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
129 .mask
= 0x00FF & PAL_60
,
132 .id
= V4L2_STD_PAL_60
,
134 .frameperiod
= {1, 30},
136 .reserved
= {0, 0, 0, 0}
139 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
141 .mask
= 0x00FF & NTSC_443
,
144 .id
= V4L2_STD_NTSC_443
,
146 .frameperiod
= {1, 30},
148 .reserved
= {0, 0, 0, 0}
151 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
153 .mask
= 0x00FF & PAL_M
,
156 .id
= V4L2_STD_PAL_M
,
158 .frameperiod
= {1, 30},
160 .reserved
= {0, 0, 0, 0}
163 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
165 .mask
= 0x8000 | (0x00FF & PAL_BGHIN_SLOW
),
167 .index
= PAL_BGHIN_SLOW
,
168 .id
= (V4L2_STD_PAL_B
| V4L2_STD_PAL_G
|
170 V4L2_STD_PAL_I
| V4L2_STD_PAL_N
|
171 (((v4l2_std_id
)0x01) << 32)),
172 .name
= "PAL_BGHIN_SLOW",
173 .frameperiod
= {1, 5},
175 .reserved
= {0, 0, 0, 0}
178 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
180 .mask
= 0x8000 | (0x00FF & NTSC_N_443_SLOW
),
182 .index
= NTSC_N_443_SLOW
,
183 .id
= (V4L2_STD_UNKNOWN
| (((v4l2_std_id
)0x11) << 32)),
184 .name
= "NTSC_N_443_SLOW",
185 .frameperiod
= {1, 5},
187 .reserved
= {0, 0, 0, 0}
190 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
192 .mask
= 0x8000 | (0x00FF & PAL_Nc_SLOW
),
194 .index
= PAL_Nc_SLOW
,
195 .id
= (V4L2_STD_PAL_Nc
| (((v4l2_std_id
)0x01) << 32)),
196 .name
= "PAL_Nc_SLOW",
197 .frameperiod
= {1, 5},
199 .reserved
= {0, 0, 0, 0}
202 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
204 .mask
= 0x8000 | (0x00FF & NTSC_N_SLOW
),
206 .index
= NTSC_N_SLOW
,
207 .id
= (V4L2_STD_UNKNOWN
| (((v4l2_std_id
)0x21) << 32)),
208 .name
= "NTSC_N_SLOW",
209 .frameperiod
= {1, 5},
211 .reserved
= {0, 0, 0, 0}
214 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
216 .mask
= 0x8000 | (0x00FF & SECAM_SLOW
),
219 .id
= (V4L2_STD_SECAM
| (((v4l2_std_id
)0x01) << 32)),
220 .name
= "SECAM_SLOW",
221 .frameperiod
= {1, 5},
223 .reserved
= {0, 0, 0, 0}
226 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
228 .mask
= 0x8000 | (0x00FF & NTSC_M_SLOW
),
230 .index
= NTSC_M_SLOW
,
231 .id
= (V4L2_STD_NTSC_M
| (((v4l2_std_id
)0x01) << 32)),
232 .name
= "NTSC_M_SLOW",
233 .frameperiod
= {1, 6},
235 .reserved
= {0, 0, 0, 0}
238 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
240 .mask
= 0x8000 | (0x00FF & NTSC_M_JP_SLOW
),
242 .index
= NTSC_M_JP_SLOW
,
243 .id
= (V4L2_STD_NTSC_M_JP
|
244 (((v4l2_std_id
)0x01) << 32)),
245 .name
= "NTSC_M_JP_SLOW",
246 .frameperiod
= {1, 6},
248 .reserved
= {0, 0, 0, 0}
251 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
253 .mask
= 0x8000 | (0x00FF & PAL_60_SLOW
),
255 .index
= PAL_60_SLOW
,
256 .id
= (V4L2_STD_PAL_60
| (((v4l2_std_id
)0x01) << 32)),
257 .name
= "PAL_60_SLOW",
258 .frameperiod
= {1, 6},
260 .reserved
= {0, 0, 0, 0}
263 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
265 .mask
= 0x8000 | (0x00FF & NTSC_443_SLOW
),
267 .index
= NTSC_443_SLOW
,
268 .id
= (V4L2_STD_NTSC_443
| (((v4l2_std_id
)0x01) << 32)),
269 .name
= "NTSC_443_SLOW",
270 .frameperiod
= {1, 6},
272 .reserved
= {0, 0, 0, 0}
275 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
277 .mask
= 0x8000 | (0x00FF & PAL_M_SLOW
),
280 .id
= (V4L2_STD_PAL_M
| (((v4l2_std_id
)0x01) << 32)),
281 .name
= "PAL_M_SLOW",
282 .frameperiod
= {1, 6},
284 .reserved
= {0, 0, 0, 0}
287 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
292 /*---------------------------------------------------------------------------*/
294 * THE 16-BIT easycap_format.mask HAS MEANING:
295 * (least significant) BIT 0: 0 => PAL, 25 FPS; 1 => NTSC, 30 FPS
296 * BITS 2-4: RESERVED FOR DIFFERENTIATING STANDARDS
297 * BITS 5-7: NUMBER OF BYTES PER PIXEL
298 * BIT 8: 0 => NATIVE BYTE ORDER; 1 => SWAPPED
299 * BITS 9-10: RESERVED FOR OTHER BYTE PERMUTATIONS
300 * BIT 11: 0 => UNDECIMATED; 1 => DECIMATED
301 * BIT 12: 0 => OFFER FRAMES; 1 => OFFER FIELDS
302 * BIT 13: 0 => FULL FRAMERATE; 1 => REDUCED
303 * (most significant) BITS 14-15: RESERVED FOR OTHER FIELD/FRAME OPTIONS
305 * bytesperpixel IS ((0x00E0 & easycap_format.mask) >> 5)
306 * byteswaporder IS true IF (0 != (0x0100 & easycap_format.mask))
308 * decimatepixel IS true IF (0 != (0x0800 & easycap_format.mask))
310 * offerfields IS true IF (0 != (0x1000 & easycap_format.mask))
312 /*---------------------------------------------------------------------------*/
314 struct easycap_format easycap_format
[1 + SETTINGS_MANY
];
316 int fillin_formats(void)
318 const char *name1
, *name2
, *name3
, *name4
;
319 struct v4l2_format
*fmt
;
321 u32 width
, height
, pixelformat
, bytesperline
, sizeimage
;
322 u16 mask1
, mask2
, mask3
, mask4
;
323 enum v4l2_field field
;
324 enum v4l2_colorspace colorspace
;
326 for (i
= 0, n
= 0; i
< STANDARD_MANY
; i
++) {
330 mask1
= 0x1F & PAL_BGHIN
;
332 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
336 mask1
= 0x1F & SECAM
;
338 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
342 mask1
= 0x1F & PAL_Nc
;
344 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
348 mask1
= 0x1F & PAL_60
;
350 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
354 mask1
= 0x1F & PAL_M
;
356 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
360 mask1
= 0x1F & NTSC_M
;
362 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
366 mask1
= 0x1F & NTSC_443
;
368 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
372 mask1
= 0x1F & NTSC_M_JP
;
374 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
378 mask1
= 0x1F & NTSC_M
;
380 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
384 mask1
= 0x1F & NTSC_N_443
;
385 name1
= "NTSC_N_443";
386 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
389 case PAL_BGHIN_SLOW
: {
390 mask1
= 0x001F & PAL_BGHIN_SLOW
;
392 name1
= "PAL_BGHIN_SLOW";
393 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
397 mask1
= 0x001F & SECAM_SLOW
;
399 name1
= "SECAM_SLOW";
400 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
404 mask1
= 0x001F & PAL_Nc_SLOW
;
406 name1
= "PAL_Nc_SLOW";
407 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
411 mask1
= 0x001F & PAL_60_SLOW
;
413 name1
= "PAL_60_SLOW";
414 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
418 mask1
= 0x001F & PAL_M_SLOW
;
420 name1
= "PAL_M_SLOW";
421 colorspace
= V4L2_COLORSPACE_470_SYSTEM_BG
;
425 mask1
= 0x001F & NTSC_M_SLOW
;
427 name1
= "NTSC_M_SLOW";
428 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
431 case NTSC_443_SLOW
: {
432 mask1
= 0x001F & NTSC_443_SLOW
;
434 name1
= "NTSC_443_SLOW";
435 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
438 case NTSC_M_JP_SLOW
: {
439 mask1
= 0x001F & NTSC_M_JP_SLOW
;
441 name1
= "NTSC_M_JP_SLOW";
442 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
446 mask1
= 0x001F & NTSC_N_SLOW
;
448 name1
= "NTSC_N_SLOW";
449 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
452 case NTSC_N_443_SLOW
: {
453 mask1
= 0x001F & NTSC_N_443_SLOW
;
455 name1
= "NTSC_N_443_SLOW";
456 colorspace
= V4L2_COLORSPACE_470_SYSTEM_M
;
463 for (j
= 0; j
< RESOLUTION_MANY
; j
++) {
469 name2
= "_AT_720x576";
477 name2
= "_AT_704x576";
483 name2
= "_AT_640x480";
491 name2
= "_AT_720x480";
499 name2
= "_AT_360x288";
506 name2
= "_AT_320x240";
515 name2
= "_AT_360x240";
525 for (k
= 0; k
< PIXELFORMAT_MANY
; k
++) {
529 name3
= __stringify(FMT_UYVY
);
530 pixelformat
= V4L2_PIX_FMT_UYVY
;
531 mask3
|= (0x02 << 5);
535 name3
= __stringify(FMT_YUY2
);
536 pixelformat
= V4L2_PIX_FMT_YUYV
;
537 mask3
|= (0x02 << 5);
542 name3
= __stringify(FMT_RGB24
);
543 pixelformat
= V4L2_PIX_FMT_RGB24
;
544 mask3
|= (0x03 << 5);
548 name3
= __stringify(FMT_RGB32
);
549 pixelformat
= V4L2_PIX_FMT_RGB32
;
550 mask3
|= (0x04 << 5);
554 name3
= __stringify(FMT_BGR24
);
555 pixelformat
= V4L2_PIX_FMT_BGR24
;
556 mask3
|= (0x03 << 5);
561 name3
= __stringify(FMT_BGR32
);
562 pixelformat
= V4L2_PIX_FMT_BGR32
;
563 mask3
|= (0x04 << 5);
570 bytesperline
= width
* ((mask3
& 0x00E0) >> 5);
571 sizeimage
= bytesperline
* height
;
573 for (m
= 0; m
< INTERLACE_MANY
; m
++) {
578 field
= V4L2_FIELD_NONE
;
581 case FIELD_INTERLACED
: {
584 field
= V4L2_FIELD_INTERLACED
;
590 if (SETTINGS_MANY
<= n
)
593 strcpy(easycap_format
[n
].name
, name1
);
594 strcat(easycap_format
[n
].name
, name2
);
595 strcat(easycap_format
[n
].name
, "_");
596 strcat(easycap_format
[n
].name
, name3
);
597 strcat(easycap_format
[n
].name
, name4
);
598 easycap_format
[n
].mask
=
599 mask1
| mask2
| mask3
| mask4
;
600 fmt
= &easycap_format
[n
].v4l2_format
;
602 fmt
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE
;
603 fmt
->fmt
.pix
.width
= width
;
604 fmt
->fmt
.pix
.height
= height
;
605 fmt
->fmt
.pix
.pixelformat
= pixelformat
;
606 fmt
->fmt
.pix
.field
= field
;
607 fmt
->fmt
.pix
.bytesperline
= bytesperline
;
608 fmt
->fmt
.pix
.sizeimage
= sizeimage
;
609 fmt
->fmt
.pix
.colorspace
= colorspace
;
610 fmt
->fmt
.pix
.priv
= 0;
616 if ((1 + SETTINGS_MANY
) <= n
)
618 easycap_format
[n
].mask
= 0xFFFF;
621 /*---------------------------------------------------------------------------*/
622 struct v4l2_queryctrl easycap_control
[] = {
624 .id
= V4L2_CID_BRIGHTNESS
,
625 .type
= V4L2_CTRL_TYPE_INTEGER
,
626 .name
= "Brightness",
630 .default_value
= SAA_0A_DEFAULT
,
634 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
636 .id
= V4L2_CID_CONTRAST
,
637 .type
= V4L2_CTRL_TYPE_INTEGER
,
642 .default_value
= SAA_0B_DEFAULT
+ 128,
646 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
648 .id
= V4L2_CID_SATURATION
,
649 .type
= V4L2_CTRL_TYPE_INTEGER
,
650 .name
= "Saturation",
654 .default_value
= SAA_0C_DEFAULT
+ 128,
658 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
661 .type
= V4L2_CTRL_TYPE_INTEGER
,
666 .default_value
= SAA_0D_DEFAULT
+ 128,
670 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
672 .id
= V4L2_CID_AUDIO_VOLUME
,
673 .type
= V4L2_CTRL_TYPE_INTEGER
,
682 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
684 .id
= V4L2_CID_AUDIO_MUTE
,
685 .type
= V4L2_CTRL_TYPE_BOOLEAN
,
687 .default_value
= true,
691 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
696 /*****************************************************************************/