]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/staging/easycap/easycap.h
47467d5fdd2c017da545ce214320812a156a7b46
[mirror_ubuntu-artful-kernel.git] / drivers / staging / easycap / easycap.h
1 /*****************************************************************************
2 * *
3 * easycap.h *
4 * *
5 *****************************************************************************/
6 /*
7 *
8 * Copyright (C) 2010 R.M. Thomas <rmthomas@sciolus.org>
9 *
10 *
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.
15 *
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.
20 *
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
24 *
25 */
26 /*****************************************************************************/
27 /*---------------------------------------------------------------------------*/
28 /*
29 * THE FOLLOWING PARAMETERS ARE UNDEFINED:
30 *
31 * EASYCAP_DEBUG
32 * EASYCAP_IS_VIDEODEV_CLIENT
33 * EASYCAP_NEEDS_USBVIDEO_H
34 * EASYCAP_NEEDS_V4L2_DEVICE_H
35 * EASYCAP_NEEDS_V4L2_FOPS
36 * EASYCAP_SILENT
37 *
38 * IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER
39 * OPTIONS.
40 */
41 /*---------------------------------------------------------------------------*/
42
43 #ifndef __EASYCAP_H__
44 #define __EASYCAP_H__
45
46 /*---------------------------------------------------------------------------*/
47 /*
48 * THESE ARE NORMALLY DEFINED
49 */
50 /*---------------------------------------------------------------------------*/
51 #define PATIENCE 500
52 #undef PREFER_NTSC
53 #define PERSEVERE
54 /*---------------------------------------------------------------------------*/
55 /*
56 * THESE ARE FOR MAINTENANCE ONLY - NORMALLY UNDEFINED:
57 */
58 /*---------------------------------------------------------------------------*/
59 #undef EASYCAP_TESTCARD
60 #ifdef CONFIG_EASYCAP_OSS
61 #undef EASYCAP_TESTTONE
62 #endif /* CONFIG_EASYCAP_OSS */
63 /*---------------------------------------------------------------------------*/
64 #include <linux/kernel.h>
65 #include <linux/errno.h>
66 #include <linux/init.h>
67 #include <linux/slab.h>
68 #include <linux/module.h>
69 #include <linux/kref.h>
70 #include <linux/usb.h>
71 #include <linux/uaccess.h>
72
73 #include <linux/i2c.h>
74 #include <linux/version.h>
75 #include <linux/workqueue.h>
76 #include <linux/poll.h>
77 #include <linux/mm.h>
78 #include <linux/fs.h>
79 #include <linux/delay.h>
80 #include <linux/types.h>
81
82 #ifndef CONFIG_EASYCAP_OSS
83 #include <linux/vmalloc.h>
84 #include <linux/sound.h>
85 #include <sound/core.h>
86 #include <sound/pcm.h>
87 #include <sound/pcm_params.h>
88 #include <sound/info.h>
89 #include <sound/initval.h>
90 #include <sound/control.h>
91 #endif /* !CONFIG_EASYCAP_OSS */
92 /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
93 #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
94 #include <media/v4l2-dev.h>
95 #if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
96 #include <media/v4l2-device.h>
97 #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
98 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
99 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
100 #include <linux/videodev2.h>
101 #include <linux/soundcard.h>
102 #if defined(EASYCAP_NEEDS_USBVIDEO_H)
103 #include <config/video/usbvideo.h>
104 #endif /*EASYCAP_NEEDS_USBVIDEO_H*/
105
106 #if (!defined(PAGE_SIZE))
107 #error "PAGE_SIZE not defined"
108 #endif
109
110 /*---------------------------------------------------------------------------*/
111 /* VENDOR, PRODUCT: Syntek Semiconductor Co., Ltd
112 *
113 * EITHER EasyCAP USB 2.0 Video Adapter with Audio, Model No. DC60
114 * with input cabling: AUDIO(L), AUDIO(R), CVBS, S-VIDEO.
115 *
116 * OR EasyCAP 4CHANNEL USB 2.0 DVR, Model No. EasyCAP002
117 * with input cabling: MICROPHONE, CVBS1, CVBS2, CVBS3, CVBS4.
118 */
119 /*---------------------------------------------------------------------------*/
120 #define USB_EASYCAP_VENDOR_ID 0x05e1
121 #define USB_EASYCAP_PRODUCT_ID 0x0408
122
123 #define EASYCAP_DRIVER_VERSION "0.9.01"
124 #define EASYCAP_DRIVER_DESCRIPTION "easycapdc60"
125
126 #define USB_SKEL_MINOR_BASE 192
127 #define DONGLE_MANY 8
128 #define INPUT_MANY 6
129 /*---------------------------------------------------------------------------*/
130 /*
131 * DEFAULT LUMINANCE, CONTRAST, SATURATION AND HUE
132 */
133 /*---------------------------------------------------------------------------*/
134 #define SAA_0A_DEFAULT 0x7F
135 #define SAA_0B_DEFAULT 0x3F
136 #define SAA_0C_DEFAULT 0x2F
137 #define SAA_0D_DEFAULT 0x00
138 /*---------------------------------------------------------------------------*/
139 /*
140 * VIDEO STREAMING PARAMETERS:
141 * USB 2.0 PROVIDES FOR HIGH-BANDWIDTH ENDPOINTS WITH AN UPPER LIMIT
142 * OF 3072 BYTES PER MICROFRAME for wMaxPacketSize.
143 */
144 /*---------------------------------------------------------------------------*/
145 #define VIDEO_ISOC_BUFFER_MANY 16
146 #define VIDEO_ISOC_ORDER 3
147 #define VIDEO_ISOC_FRAMESPERDESC ((unsigned int) 1 << VIDEO_ISOC_ORDER)
148 #define USB_2_0_MAXPACKETSIZE 3072
149 #if (USB_2_0_MAXPACKETSIZE > PAGE_SIZE)
150 #error video_isoc_buffer[.] will not be big enough
151 #endif
152 #define VIDEO_JUNK_TOLERATE VIDEO_ISOC_BUFFER_MANY
153 #define VIDEO_LOST_TOLERATE 50
154 /*---------------------------------------------------------------------------*/
155 /*
156 * VIDEO BUFFERS
157 */
158 /*---------------------------------------------------------------------------*/
159 #define FIELD_BUFFER_SIZE (203 * PAGE_SIZE)
160 #define FRAME_BUFFER_SIZE (405 * PAGE_SIZE)
161 #define FIELD_BUFFER_MANY 4
162 #define FRAME_BUFFER_MANY 6
163 /*---------------------------------------------------------------------------*/
164 /*
165 * AUDIO STREAMING PARAMETERS
166 */
167 /*---------------------------------------------------------------------------*/
168 #define AUDIO_ISOC_BUFFER_MANY 16
169 #define AUDIO_ISOC_ORDER 1
170 #define AUDIO_ISOC_FRAMESPERDESC 32
171 #define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER)
172 /*---------------------------------------------------------------------------*/
173 /*
174 * AUDIO BUFFERS
175 */
176 /*---------------------------------------------------------------------------*/
177 #define AUDIO_FRAGMENT_MANY 32
178 #define PAGES_PER_AUDIO_FRAGMENT 4
179 /*---------------------------------------------------------------------------*/
180 /*
181 * IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND,
182 * ODD-NUMBERED STANDARDS ARE 30 FRAMES PER SECOND.
183 * THE NUMBERING OF STANDARDS MUST NOT BE CHANGED WITHOUT DUE CARE. NOT
184 * ONLY MUST THE PARAMETER
185 * STANDARD_MANY
186 * BE CHANGED TO CORRESPOND TO THE NEW NUMBER OF STANDARDS, BUT ALSO THE
187 * NUMBERING MUST REMAIN AN UNBROKEN ASCENDING SEQUENCE: DUMMY STANDARDS
188 * MAY NEED TO BE ADDED. APPROPRIATE CHANGES WILL ALWAYS BE REQUIRED IN
189 * ROUTINE fillin_formats() AND POSSIBLY ELSEWHERE. BEWARE.
190 */
191 /*---------------------------------------------------------------------------*/
192 #define PAL_BGHIN 0
193 #define PAL_Nc 2
194 #define SECAM 4
195 #define NTSC_N 6
196 #define NTSC_N_443 8
197 #define NTSC_M 1
198 #define NTSC_443 3
199 #define NTSC_M_JP 5
200 #define PAL_60 7
201 #define PAL_M 9
202 #define PAL_BGHIN_SLOW 10
203 #define PAL_Nc_SLOW 12
204 #define SECAM_SLOW 14
205 #define NTSC_N_SLOW 16
206 #define NTSC_N_443_SLOW 18
207 #define NTSC_M_SLOW 11
208 #define NTSC_443_SLOW 13
209 #define NTSC_M_JP_SLOW 15
210 #define PAL_60_SLOW 17
211 #define PAL_M_SLOW 19
212 #define STANDARD_MANY 20
213 /*---------------------------------------------------------------------------*/
214 /*
215 * ENUMS
216 */
217 /*---------------------------------------------------------------------------*/
218 enum {
219 AT_720x576,
220 AT_704x576,
221 AT_640x480,
222 AT_720x480,
223 AT_360x288,
224 AT_320x240,
225 AT_360x240,
226 RESOLUTION_MANY
227 };
228 enum {
229 FMT_UYVY,
230 FMT_YUY2,
231 FMT_RGB24,
232 FMT_RGB32,
233 FMT_BGR24,
234 FMT_BGR32,
235 PIXELFORMAT_MANY
236 };
237 enum {
238 FIELD_NONE,
239 FIELD_INTERLACED,
240 INTERLACE_MANY
241 };
242 #define SETTINGS_MANY (STANDARD_MANY * \
243 RESOLUTION_MANY * \
244 2 * \
245 PIXELFORMAT_MANY * \
246 INTERLACE_MANY)
247 /*---------------------------------------------------------------------------*/
248 /*
249 * STRUCTURE DEFINITIONS
250 */
251 /*---------------------------------------------------------------------------*/
252 struct easycap_dongle {
253 struct easycap *peasycap;
254 struct mutex mutex_video;
255 struct mutex mutex_audio;
256 };
257 /*---------------------------------------------------------------------------*/
258 struct data_buffer {
259 struct list_head list_head;
260 void *pgo;
261 void *pto;
262 __u16 kount;
263 __u16 input;
264 };
265 /*---------------------------------------------------------------------------*/
266 struct data_urb {
267 struct list_head list_head;
268 struct urb *purb;
269 int isbuf;
270 int length;
271 };
272 /*---------------------------------------------------------------------------*/
273 struct easycap_standard {
274 __u16 mask;
275 struct v4l2_standard v4l2_standard;
276 };
277 struct easycap_format {
278 __u16 mask;
279 char name[128];
280 struct v4l2_format v4l2_format;
281 };
282 struct inputset {
283 int input;
284 int input_ok;
285 int standard_offset;
286 int standard_offset_ok;
287 int format_offset;
288 int format_offset_ok;
289 int brightness;
290 int brightness_ok;
291 int contrast;
292 int contrast_ok;
293 int saturation;
294 int saturation_ok;
295 int hue;
296 int hue_ok;
297 };
298 /*---------------------------------------------------------------------------*/
299 /*
300 * easycap.ilk == 0 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=256
301 * easycap.ilk == 2 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=9
302 * easycap.ilk == 3 => FOUR-CVBS HARDWARE, AUDIO wMaxPacketSize=9
303 */
304 /*---------------------------------------------------------------------------*/
305 struct easycap {
306 #define TELLTALE "expectedstring"
307 char telltale[16];
308 int isdongle;
309 int minor;
310
311 /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
312 #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
313 struct video_device video_device;
314 #if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
315 struct v4l2_device v4l2_device;
316 #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
317 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
318 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
319 int status;
320 unsigned int audio_pages_per_fragment;
321 unsigned int audio_bytes_per_fragment;
322 unsigned int audio_buffer_page_many;
323
324 #define UPSAMPLE
325 #if defined(UPSAMPLE)
326 __s16 oldaudio;
327 #endif /*UPSAMPLE*/
328
329 int ilk;
330 bool microphone;
331
332 struct usb_device *pusb_device;
333 struct usb_interface *pusb_interface;
334
335 struct kref kref;
336
337 int queued[FRAME_BUFFER_MANY];
338 int done[FRAME_BUFFER_MANY];
339
340 wait_queue_head_t wq_video;
341 wait_queue_head_t wq_audio;
342 wait_queue_head_t wq_trigger;
343
344 int input;
345 int polled;
346 int standard_offset;
347 int format_offset;
348 struct inputset inputset[INPUT_MANY];
349
350 bool ntsc;
351 int fps;
352 int usec;
353 int tolerate;
354 int skip;
355 int skipped;
356 int lost[INPUT_MANY];
357 int merit[180];
358
359 struct timeval timeval0;
360 struct timeval timeval1;
361 struct timeval timeval2;
362 struct timeval timeval3;
363 struct timeval timeval6;
364 struct timeval timeval7;
365 struct timeval timeval8;
366 long long int dnbydt;
367
368 int video_interface;
369 int video_altsetting_on;
370 int video_altsetting_off;
371 int video_endpointnumber;
372 int video_isoc_maxframesize;
373 int video_isoc_buffer_size;
374 int video_isoc_framesperdesc;
375
376 int video_isoc_streaming;
377 int video_isoc_sequence;
378 int video_idle;
379 int video_eof;
380 int video_junk;
381
382 struct data_buffer video_isoc_buffer[VIDEO_ISOC_BUFFER_MANY];
383 struct data_buffer field_buffer[FIELD_BUFFER_MANY]
384 [(FIELD_BUFFER_SIZE/PAGE_SIZE)];
385 struct data_buffer frame_buffer[FRAME_BUFFER_MANY]
386 [(FRAME_BUFFER_SIZE/PAGE_SIZE)];
387
388 struct list_head urb_video_head;
389 struct list_head *purb_video_head;
390
391 __u8 cache[8];
392 __u8 *pcache;
393 int video_mt;
394 int audio_mt;
395 long long audio_bytes;
396 __u32 isequence;
397
398 int vma_many;
399 /*---------------------------------------------------------------------------*/
400 /*
401 * BUFFER INDICATORS
402 */
403 /*---------------------------------------------------------------------------*/
404 int field_fill; /* Field buffer being filled by easycap_complete(). */
405 /* Bumped only by easycap_complete(). */
406 int field_page; /* Page of field buffer page being filled by */
407 /* easycap_complete(). */
408 int field_read; /* Field buffer to be read by field2frame(). */
409 /* Bumped only by easycap_complete(). */
410 int frame_fill; /* Frame buffer being filled by field2frame(). */
411 /* Bumped only by easycap_dqbuf() when */
412 /* field2frame() has created a complete frame. */
413 int frame_read; /* Frame buffer offered to user by DQBUF. */
414 /* Set only by easycap_dqbuf() to trail frame_fill.*/
415 int frame_lock; /* Flag set to 1 by DQBUF and cleared by QBUF */
416 /*---------------------------------------------------------------------------*/
417 /*
418 * IMAGE PROPERTIES
419 */
420 /*---------------------------------------------------------------------------*/
421 __u32 pixelformat;
422 int width;
423 int height;
424 int bytesperpixel;
425 bool byteswaporder;
426 bool decimatepixel;
427 bool offerfields;
428 int frame_buffer_used;
429 int frame_buffer_many;
430 int videofieldamount;
431
432 int brightness;
433 int contrast;
434 int saturation;
435 int hue;
436
437 int allocation_video_urb;
438 int allocation_video_page;
439 int allocation_video_struct;
440 int registered_video;
441 /*---------------------------------------------------------------------------*/
442 /*
443 * ALSA
444 */
445 /*---------------------------------------------------------------------------*/
446 #ifndef CONFIG_EASYCAP_OSS
447 struct snd_pcm_hardware alsa_hardware;
448 struct snd_card *psnd_card;
449 struct snd_pcm *psnd_pcm;
450 struct snd_pcm_substream *psubstream;
451 int dma_fill;
452 int dma_next;
453 int dma_read;
454 #endif /* !CONFIG_EASYCAP_OSS */
455 /*---------------------------------------------------------------------------*/
456 /*
457 * SOUND PROPERTIES
458 */
459 /*---------------------------------------------------------------------------*/
460 int audio_interface;
461 int audio_altsetting_on;
462 int audio_altsetting_off;
463 int audio_endpointnumber;
464 int audio_isoc_maxframesize;
465 int audio_isoc_buffer_size;
466 int audio_isoc_framesperdesc;
467
468 int audio_isoc_streaming;
469 int audio_idle;
470 int audio_eof;
471 int volume;
472 int mute;
473 s8 gain;
474
475 struct data_buffer audio_isoc_buffer[AUDIO_ISOC_BUFFER_MANY];
476
477 struct list_head urb_audio_head;
478 struct list_head *purb_audio_head;
479 /*---------------------------------------------------------------------------*/
480 /*
481 * BUFFER INDICATORS
482 */
483 /*---------------------------------------------------------------------------*/
484 int audio_fill; /* Audio buffer being filled by easycap_complete(). */
485 /* Bumped only by easycap_complete(). */
486 int audio_read; /* Audio buffer page being read by easycap_read(). */
487 /* Set by easycap_read() to trail audio_fill by */
488 /* one fragment. */
489 /*---------------------------------------------------------------------------*/
490 /*
491 * SOUND PROPERTIES
492 */
493 /*---------------------------------------------------------------------------*/
494
495 int audio_buffer_many;
496
497 int allocation_audio_urb;
498 int allocation_audio_page;
499 int allocation_audio_struct;
500 int registered_audio;
501
502 long long int audio_sample;
503 long long int audio_niveau;
504 long long int audio_square;
505
506 struct data_buffer audio_buffer[];
507 };
508 /*---------------------------------------------------------------------------*/
509 /*
510 * VIDEO FUNCTION PROTOTYPES
511 */
512 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
513 long easycap_unlocked_ioctl(struct file *, unsigned int, unsigned long);
514 int easycap_dqbuf(struct easycap *, int);
515 int submit_video_urbs(struct easycap *);
516 int kill_video_urbs(struct easycap *);
517 int field2frame(struct easycap *);
518 int redaub(struct easycap *, void *, void *,
519 int, int, __u8, __u8, bool);
520 void easycap_testcard(struct easycap *, int);
521 int fillin_formats(void);
522 int newinput(struct easycap *, int);
523 int adjust_standard(struct easycap *, v4l2_std_id);
524 int adjust_format(struct easycap *, __u32, __u32, __u32,
525 int, bool);
526 int adjust_brightness(struct easycap *, int);
527 int adjust_contrast(struct easycap *, int);
528 int adjust_saturation(struct easycap *, int);
529 int adjust_hue(struct easycap *, int);
530 int adjust_volume(struct easycap *, int);
531 /*---------------------------------------------------------------------------*/
532 /*
533 * AUDIO FUNCTION PROTOTYPES
534 */
535 /*---------------------------------------------------------------------------*/
536 #ifndef CONFIG_EASYCAP_OSS
537 int easycap_alsa_probe(struct easycap *);
538 void easycap_alsa_complete(struct urb *);
539 #else /* CONFIG_EASYCAP_OSS */
540 void easyoss_complete(struct urb *);
541 #endif /* !CONFIG_EASYCAP_OSS */
542
543 int easycap_sound_setup(struct easycap *);
544 int submit_audio_urbs(struct easycap *);
545 int kill_audio_urbs(struct easycap *);
546 void easyoss_testtone(struct easycap *, int);
547 int audio_setup(struct easycap *);
548 /*---------------------------------------------------------------------------*/
549 /*
550 * LOW-LEVEL FUNCTION PROTOTYPES
551 */
552 /*---------------------------------------------------------------------------*/
553 int audio_gainget(struct usb_device *);
554 int audio_gainset(struct usb_device *, __s8);
555
556 int set_interface(struct usb_device *, __u16);
557 int wakeup_device(struct usb_device *);
558 int confirm_resolution(struct usb_device *);
559 int confirm_stream(struct usb_device *);
560
561 int setup_stk(struct usb_device *, bool);
562 int setup_saa(struct usb_device *, bool);
563 int setup_vt(struct usb_device *);
564 int check_stk(struct usb_device *, bool);
565 int check_saa(struct usb_device *, bool);
566 int ready_saa(struct usb_device *);
567 int merit_saa(struct usb_device *);
568 int check_vt(struct usb_device *);
569 int select_input(struct usb_device *, int, int);
570 int set_resolution(struct usb_device *,
571 __u16, __u16, __u16, __u16);
572
573 int read_saa(struct usb_device *, __u16);
574 int read_stk(struct usb_device *, __u32);
575 int write_saa(struct usb_device *, __u16, __u16);
576 int wait_i2c(struct usb_device *);
577 int write_000(struct usb_device *, __u16, __u16);
578 int start_100(struct usb_device *);
579 int stop_100(struct usb_device *);
580 int write_300(struct usb_device *);
581 int read_vt(struct usb_device *, __u16);
582 int write_vt(struct usb_device *, __u16, __u16);
583 int regset(struct usb_device *, __u16, __u16);
584 int regget(struct usb_device *, __u16, void *);
585 int isdongle(struct easycap *);
586 /*---------------------------------------------------------------------------*/
587 struct signed_div_result {
588 long long int quotient;
589 unsigned long long int remainder;
590 } signed_div(long long int, long long int);
591
592
593 /*---------------------------------------------------------------------------*/
594 /*
595 * MACROS
596 */
597 /*---------------------------------------------------------------------------*/
598 #define GET(X, Y, Z) do { \
599 int rc; \
600 *(Z) = (__u16)0; \
601 rc = regget(X, Y, Z); \
602 if (0 > rc) { \
603 JOT(8, ":-(%i\n", __LINE__); return(rc); \
604 } \
605 } while (0)
606
607 #define SET(X, Y, Z) do { \
608 int rc; \
609 rc = regset(X, Y, Z); \
610 if (0 > rc) { \
611 JOT(8, ":-(%i\n", __LINE__); return(rc); \
612 } \
613 } while (0)
614 /*---------------------------------------------------------------------------*/
615 /*
616 * MACROS SAM(...) AND JOM(...) ALLOW DIAGNOSTIC OUTPUT TO BE TAGGED WITH
617 * THE IDENTITY OF THE DONGLE TO WHICH IT APPLIES, BUT IF INVOKED WHEN THE
618 * POINTER peasycap IS INVALID AN Oops IS LIKELY, AND ITS CAUSE MAY NOT BE
619 * IMMEDIATELY OBVIOUS FROM A CASUAL READING OF THE SOURCE CODE. BEWARE.
620 */
621 /*---------------------------------------------------------------------------*/
622 const char *strerror(int err);
623
624 #define SAY(format, args...) do { \
625 printk(KERN_DEBUG "easycap:: %s: " \
626 format, __func__, ##args); \
627 } while (0)
628 #define SAM(format, args...) do { \
629 printk(KERN_DEBUG "easycap::%i%s: " \
630 format, peasycap->isdongle, __func__, ##args);\
631 } while (0)
632
633 #ifdef CONFIG_EASYCAP_DEBUG
634 extern int easycap_debug;
635 #define JOT(n, format, args...) do { \
636 if (n <= easycap_debug) { \
637 printk(KERN_DEBUG "easycap:: %s: " \
638 format, __func__, ##args);\
639 } \
640 } while (0)
641 #define JOM(n, format, args...) do { \
642 if (n <= easycap_debug) { \
643 printk(KERN_DEBUG "easycap::%i%s: " \
644 format, peasycap->isdongle, __func__, ##args);\
645 } \
646 } while (0)
647
648 #else
649 #define JOT(n, format, args...) do {} while (0)
650 #define JOM(n, format, args...) do {} while (0)
651 #endif /* CONFIG_EASYCAP_DEBUG */
652
653 #define MICROSECONDS(X, Y) \
654 ((1000000*((long long int)(X.tv_sec - Y.tv_sec))) + \
655 (long long int)(X.tv_usec - Y.tv_usec))
656
657 /*---------------------------------------------------------------------------*/
658 /*
659 * (unsigned char *)P pointer to next byte pair
660 * (long int *)X pointer to accumulating count
661 * (long int *)Y pointer to accumulating sum
662 * (long long int *)Z pointer to accumulating sum of squares
663 */
664 /*---------------------------------------------------------------------------*/
665 #define SUMMER(P, X, Y, Z) do { \
666 unsigned char *p; \
667 unsigned int u0, u1, u2; \
668 long int s; \
669 p = (unsigned char *)(P); \
670 u0 = (unsigned int) (*p); \
671 u1 = (unsigned int) (*(p + 1)); \
672 u2 = (unsigned int) ((u1 << 8) | u0); \
673 if (0x8000 & u2) \
674 s = -(long int)(0x7FFF & (~u2)); \
675 else \
676 s = (long int)(0x7FFF & u2); \
677 *((X)) += (long int) 1; \
678 *((Y)) += (long int) s; \
679 *((Z)) += ((long long int)(s) * (long long int)(s)); \
680 } while (0)
681 /*---------------------------------------------------------------------------*/
682
683 /*---------------------------------------------------------------------------*/
684 /* globals
685 */
686 /*---------------------------------------------------------------------------*/
687
688 extern const struct easycap_standard easycap_standard[];
689 extern struct easycap_format easycap_format[];
690 extern struct v4l2_queryctrl easycap_control[];
691 extern struct usb_driver easycap_usb_driver;
692 extern struct easycap_dongle easycapdc60_dongle[];
693 #ifndef CONFIG_EASYCAP_OSS
694 extern struct snd_pcm_ops easycap_alsa_ops;
695 extern struct snd_pcm_hardware easycap_pcm_hardware;
696 extern struct snd_card *psnd_card;
697 #else /* CONFIG_EASYCAP_OSS */
698 extern struct usb_class_driver easyoss_class;
699 extern const struct file_operations easyoss_fops;
700 #endif /* !CONFIG_EASYCAP_OSS */
701
702 #endif /* !__EASYCAP_H__ */