fbdev: Modify vsync timing calculation in wm8505fb
[deliverable/linux.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 *
37 * IF REQUIRED THEY MUST BE EXTERNALLY DEFINED, FOR EXAMPLE AS COMPILER
38 * OPTIONS.
39 */
40 /*---------------------------------------------------------------------------*/
41
42 #if (!defined(EASYCAP_H))
43 #define EASYCAP_H
44
45 #if defined(EASYCAP_DEBUG)
46 #if (9 < EASYCAP_DEBUG)
47 #error Debug levels 0 to 9 are okay.\
48 To achieve higher levels, remove this trap manually from easycap.h
49 #endif
50 #endif /*EASYCAP_DEBUG*/
51 /*---------------------------------------------------------------------------*/
52 /*
53 * THESE ARE FOR MAINTENANCE ONLY - NORMALLY UNDEFINED:
54 */
55 /*---------------------------------------------------------------------------*/
56 #undef PREFER_NTSC
57 #undef EASYCAP_TESTCARD
58 #undef EASYCAP_TESTTONE
59 #undef LOCKFRAME
60 #undef NOREADBACK
61 #undef AUDIOTIME
62 /*---------------------------------------------------------------------------*/
63 /*
64 *
65 * DEFINE BRIDGER TO ACTIVATE THE ROUTINE FOR BRIDGING VIDEOTAPE DROPOUTS.
66 *
67 * *** UNDER DEVELOPMENT/TESTING - NOT READY YET!***
68 *
69 */
70 /*---------------------------------------------------------------------------*/
71 #undef BRIDGER
72 /*---------------------------------------------------------------------------*/
73
74 #include <linux/kernel.h>
75 #include <linux/errno.h>
76 #include <linux/init.h>
77 #include <linux/slab.h>
78 #include <linux/module.h>
79 #include <linux/kref.h>
80 #include <linux/usb.h>
81 #include <linux/uaccess.h>
82
83 #include <linux/i2c.h>
84 #include <linux/version.h>
85 #include <linux/workqueue.h>
86 #include <linux/poll.h>
87 #include <linux/mm.h>
88 #include <linux/fs.h>
89 #include <linux/delay.h>
90 #include <linux/types.h>
91
92 /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
93 #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
94 #if (!defined(__OLD_VIDIOC_))
95 #define __OLD_VIDIOC_
96 #endif /* !defined(__OLD_VIDIOC_) */
97
98 #include <media/v4l2-dev.h>
99
100 #if defined(EASYCAP_NEEDS_V4L2_DEVICE_H)
101 #include <media/v4l2-device.h>
102 #endif /*EASYCAP_NEEDS_V4L2_DEVICE_H*/
103 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
104 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
105
106 #if (!defined(__OLD_VIDIOC_))
107 #define __OLD_VIDIOC_
108 #endif /* !defined(__OLD_VIDIOC_) */
109 #include <linux/videodev2.h>
110
111 #include <linux/soundcard.h>
112
113 #if defined(EASYCAP_NEEDS_USBVIDEO_H)
114 #include <config/video/usbvideo.h>
115 #endif /*EASYCAP_NEEDS_USBVIDEO_H*/
116
117 #if (!defined(PAGE_SIZE))
118 #error "PAGE_SIZE not defined"
119 #endif
120
121 #define STRINGIZE_AGAIN(x) #x
122 #define STRINGIZE(x) STRINGIZE_AGAIN(x)
123
124 /*---------------------------------------------------------------------------*/
125 /* VENDOR, PRODUCT: Syntek Semiconductor Co., Ltd
126 *
127 * EITHER EasyCAP USB 2.0 Video Adapter with Audio, Model No. DC60
128 * with input cabling: AUDIO(L), AUDIO(R), CVBS, S-VIDEO.
129 *
130 * OR EasyCAP 4CHANNEL USB 2.0 DVR, Model No. EasyCAP002
131 * with input cabling: MICROPHONE, CVBS1, CVBS2, CVBS3, CVBS4.
132 */
133 /*---------------------------------------------------------------------------*/
134 #define USB_EASYCAP_VENDOR_ID 0x05e1
135 #define USB_EASYCAP_PRODUCT_ID 0x0408
136
137 #define EASYCAP_DRIVER_VERSION "0.8.21"
138 #define EASYCAP_DRIVER_DESCRIPTION "easycapdc60"
139
140 #define USB_SKEL_MINOR_BASE 192
141 #define VIDEO_DEVICE_MANY 8
142
143 /*---------------------------------------------------------------------------*/
144 /*
145 * DEFAULT LUMINANCE, CONTRAST, SATURATION AND HUE
146 */
147 /*---------------------------------------------------------------------------*/
148 #define SAA_0A_DEFAULT 0x7F
149 #define SAA_0B_DEFAULT 0x3F
150 #define SAA_0C_DEFAULT 0x2F
151 #define SAA_0D_DEFAULT 0x00
152 /*---------------------------------------------------------------------------*/
153 /*
154 * VIDEO STREAMING PARAMETERS:
155 * USB 2.0 PROVIDES FOR HIGH-BANDWIDTH ENDPOINTS WITH AN UPPER LIMIT
156 * OF 3072 BYTES PER MICROFRAME for wMaxPacketSize.
157 */
158 /*---------------------------------------------------------------------------*/
159 #define VIDEO_ISOC_BUFFER_MANY 16
160 #define VIDEO_ISOC_ORDER 3
161 #define VIDEO_ISOC_FRAMESPERDESC ((unsigned int) 1 << VIDEO_ISOC_ORDER)
162 #define USB_2_0_MAXPACKETSIZE 3072
163 #if (USB_2_0_MAXPACKETSIZE > PAGE_SIZE)
164 #error video_isoc_buffer[.] will not be big enough
165 #endif
166 /*---------------------------------------------------------------------------*/
167 /*
168 * VIDEO BUFFERS
169 */
170 /*---------------------------------------------------------------------------*/
171 #define FIELD_BUFFER_SIZE (203 * PAGE_SIZE)
172 #define FRAME_BUFFER_SIZE (405 * PAGE_SIZE)
173 #define FIELD_BUFFER_MANY 4
174 #define FRAME_BUFFER_MANY 6
175 /*---------------------------------------------------------------------------*/
176 /*
177 * AUDIO STREAMING PARAMETERS
178 */
179 /*---------------------------------------------------------------------------*/
180 #define AUDIO_ISOC_BUFFER_MANY 16
181 #define AUDIO_ISOC_ORDER 3
182 #define AUDIO_ISOC_BUFFER_SIZE (PAGE_SIZE << AUDIO_ISOC_ORDER)
183 /*---------------------------------------------------------------------------*/
184 /*
185 * AUDIO BUFFERS
186 */
187 /*---------------------------------------------------------------------------*/
188 #define AUDIO_FRAGMENT_MANY 32
189 /*---------------------------------------------------------------------------*/
190 /*
191 * IT IS ESSENTIAL THAT EVEN-NUMBERED STANDARDS ARE 25 FRAMES PER SECOND,
192 * ODD-NUMBERED STANDARDS ARE 30 FRAMES PER SECOND.
193 * THE NUMBERING OF STANDARDS MUST NOT BE CHANGED WITHOUT DUE CARE. NOT
194 * ONLY MUST THE PARAMETER
195 * STANDARD_MANY
196 * BE CHANGED TO CORRESPOND TO THE NEW NUMBER OF STANDARDS, BUT ALSO THE
197 * NUMBERING MUST REMAIN AN UNBROKEN ASCENDING SEQUENCE: DUMMY STANDARDS
198 * MAY NEED TO BE ADDED. APPROPRIATE CHANGES WILL ALWAYS BE REQUIRED IN
199 * ROUTINE fillin_formats() AND POSSIBLY ELSEWHERE. BEWARE.
200 */
201 /*---------------------------------------------------------------------------*/
202 #define PAL_BGHIN 0
203 #define PAL_Nc 2
204 #define SECAM 4
205 #define NTSC_N 6
206 #define NTSC_N_443 8
207 #define NTSC_M 1
208 #define NTSC_443 3
209 #define NTSC_M_JP 5
210 #define PAL_60 7
211 #define PAL_M 9
212 #define STANDARD_MANY 10
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 FIELD_ALTERNATE,
241 INTERLACE_MANY
242 };
243 #define SETTINGS_MANY (STANDARD_MANY * \
244 RESOLUTION_MANY * \
245 2 * \
246 PIXELFORMAT_MANY * \
247 INTERLACE_MANY)
248 /*---------------------------------------------------------------------------*/
249 /*
250 * STRUCTURE DEFINITIONS
251 */
252 /*---------------------------------------------------------------------------*/
253 struct data_buffer {
254 struct list_head list_head;
255 void *pgo;
256 void *pto;
257 __u16 kount;
258 };
259 /*---------------------------------------------------------------------------*/
260 struct data_urb {
261 struct list_head list_head;
262 struct urb *purb;
263 int isbuf;
264 int length;
265 };
266 /*---------------------------------------------------------------------------*/
267 struct easycap_standard {
268 __u16 mask;
269 struct v4l2_standard v4l2_standard;
270 };
271 struct easycap_format {
272 __u16 mask;
273 char name[128];
274 struct v4l2_format v4l2_format;
275 };
276 /*---------------------------------------------------------------------------*/
277 /*
278 * easycap.ilk == 0 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=256
279 * easycap.ilk == 2 => CVBS+S-VIDEO HARDWARE, AUDIO wMaxPacketSize=9
280 * easycap.ilk == 3 => FOUR-CVBS HARDWARE, AUDIO wMaxPacketSize=9
281 */
282 /*---------------------------------------------------------------------------*/
283 struct easycap {
284 unsigned int audio_pages_per_fragment;
285 unsigned int audio_bytes_per_fragment;
286 unsigned int audio_buffer_page_many;
287
288 #define UPSAMPLE
289 #if defined(UPSAMPLE)
290 __s16 oldaudio;
291 #endif /*UPSAMPLE*/
292
293 struct easycap_format easycap_format[1 + SETTINGS_MANY];
294
295 int ilk;
296 bool microphone;
297
298 /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
299 #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
300 struct video_device *pvideo_device;
301 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
302 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
303
304 struct usb_device *pusb_device;
305 struct usb_interface *pusb_interface;
306
307 struct kref kref;
308
309 struct mutex mutex_mmap_video[FRAME_BUFFER_MANY];
310 struct mutex mutex_timeval0;
311 struct mutex mutex_timeval1;
312
313 int queued[FRAME_BUFFER_MANY];
314 int done[FRAME_BUFFER_MANY];
315
316 wait_queue_head_t wq_video;
317 wait_queue_head_t wq_audio;
318
319 int input;
320 int polled;
321 int standard_offset;
322 int format_offset;
323
324 int fps;
325 int usec;
326 int tolerate;
327 int merit[180];
328
329 struct timeval timeval0;
330 struct timeval timeval1;
331 struct timeval timeval2;
332 struct timeval timeval7;
333 long long int dnbydt;
334
335 int video_interface;
336 int video_altsetting_on;
337 int video_altsetting_off;
338 int video_endpointnumber;
339 int video_isoc_maxframesize;
340 int video_isoc_buffer_size;
341 int video_isoc_framesperdesc;
342
343 int video_isoc_streaming;
344 int video_isoc_sequence;
345 int video_idle;
346 int video_eof;
347 int video_junk;
348
349 int fudge;
350
351 struct data_buffer video_isoc_buffer[VIDEO_ISOC_BUFFER_MANY];
352 struct data_buffer \
353 field_buffer[FIELD_BUFFER_MANY][(FIELD_BUFFER_SIZE/PAGE_SIZE)];
354 struct data_buffer \
355 frame_buffer[FRAME_BUFFER_MANY][(FRAME_BUFFER_SIZE/PAGE_SIZE)];
356
357 struct list_head urb_video_head;
358 struct list_head *purb_video_head;
359
360 int vma_many;
361
362 /*---------------------------------------------------------------------------*/
363 /*
364 * BUFFER INDICATORS
365 */
366 /*---------------------------------------------------------------------------*/
367 int field_fill; /* Field buffer being filled by easycap_complete(). */
368 /* Bumped only by easycap_complete(). */
369 int field_page; /* Page of field buffer page being filled by */
370 /* easycap_complete(). */
371 int field_read; /* Field buffer to be read by field2frame(). */
372 /* Bumped only by easycap_complete(). */
373 int frame_fill; /* Frame buffer being filled by field2frame(). */
374 /* Bumped only by easycap_dqbuf() when */
375 /* field2frame() has created a complete frame. */
376 int frame_read; /* Frame buffer offered to user by DQBUF. */
377 /* Set only by easycap_dqbuf() to trail frame_fill.*/
378 int frame_lock; /* Flag set to 1 by DQBUF and cleared by QBUF */
379 /*---------------------------------------------------------------------------*/
380 /*
381 * IMAGE PROPERTIES
382 */
383 /*---------------------------------------------------------------------------*/
384 __u32 pixelformat;
385 __u32 field;
386 int width;
387 int height;
388 int bytesperpixel;
389 bool byteswaporder;
390 bool decimatepixel;
391 bool offerfields;
392 int frame_buffer_used;
393 int frame_buffer_many;
394 int videofieldamount;
395
396 int brightness;
397 int contrast;
398 int saturation;
399 int hue;
400
401 int allocation_video_urb;
402 int allocation_video_page;
403 int allocation_video_struct;
404 int registered_video;
405 /*---------------------------------------------------------------------------*/
406 /*
407 * SOUND PROPERTIES
408 */
409 /*---------------------------------------------------------------------------*/
410 int audio_interface;
411 int audio_altsetting_on;
412 int audio_altsetting_off;
413 int audio_endpointnumber;
414 int audio_isoc_maxframesize;
415 int audio_isoc_buffer_size;
416 int audio_isoc_framesperdesc;
417
418 int audio_isoc_streaming;
419 int audio_idle;
420 int audio_eof;
421 int volume;
422 int mute;
423
424 struct data_buffer audio_isoc_buffer[AUDIO_ISOC_BUFFER_MANY];
425
426 struct list_head urb_audio_head;
427 struct list_head *purb_audio_head;
428 /*---------------------------------------------------------------------------*/
429 /*
430 * BUFFER INDICATORS
431 */
432 /*---------------------------------------------------------------------------*/
433 int audio_fill; /* Audio buffer being filled by easysnd_complete(). */
434 /* Bumped only by easysnd_complete(). */
435 int audio_read; /* Audio buffer page being read by easysnd_read(). */
436 /* Set by easysnd_read() to trail audio_fill by */
437 /* one fragment. */
438 /*---------------------------------------------------------------------------*/
439 /*
440 * SOUND PROPERTIES
441 */
442 /*---------------------------------------------------------------------------*/
443
444 int audio_buffer_many;
445
446 int allocation_audio_urb;
447 int allocation_audio_page;
448 int allocation_audio_struct;
449 int registered_audio;
450
451 long long int audio_sample;
452 long long int audio_niveau;
453 long long int audio_square;
454
455 struct data_buffer audio_buffer[];
456 };
457 /*---------------------------------------------------------------------------*/
458 /*
459 * VIDEO FUNCTION PROTOTYPES
460 */
461 /*---------------------------------------------------------------------------*/
462 void easycap_complete(struct urb *);
463 int easycap_open(struct inode *, struct file *);
464 int easycap_release(struct inode *, struct file *);
465 long easycap_ioctl(struct file *, unsigned int, unsigned long);
466
467 /*vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv*/
468 #if defined(EASYCAP_IS_VIDEODEV_CLIENT)
469 int easycap_open_noinode(struct file *);
470 int easycap_release_noinode(struct file *);
471 int videodev_release(struct video_device *);
472 #endif /*EASYCAP_IS_VIDEODEV_CLIENT*/
473 /*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*/
474
475 unsigned int easycap_poll(struct file *, poll_table *);
476 int easycap_mmap(struct file *, struct vm_area_struct *);
477 int easycap_usb_probe(struct usb_interface *, \
478 const struct usb_device_id *);
479 void easycap_usb_disconnect(struct usb_interface *);
480 void easycap_delete(struct kref *);
481
482 void easycap_vma_open(struct vm_area_struct *);
483 void easycap_vma_close(struct vm_area_struct *);
484 int easycap_vma_fault(struct vm_area_struct *, struct vm_fault *);
485 int easycap_dqbuf(struct easycap *, int);
486 int submit_video_urbs(struct easycap *);
487 int kill_video_urbs(struct easycap *);
488 int field2frame(struct easycap *);
489 int redaub(struct easycap *, void *, void *, \
490 int, int, __u8, __u8, bool);
491 void debrief(struct easycap *);
492 void sayreadonly(struct easycap *);
493 void easycap_testcard(struct easycap *, int);
494 int explain_ioctl(__u32);
495 int explain_cid(__u32);
496 int fillin_formats(void);
497 int adjust_standard(struct easycap *, v4l2_std_id);
498 int adjust_format(struct easycap *, __u32, __u32, __u32, \
499 int, bool);
500 int adjust_brightness(struct easycap *, int);
501 int adjust_contrast(struct easycap *, int);
502 int adjust_saturation(struct easycap *, int);
503 int adjust_hue(struct easycap *, int);
504 int adjust_volume(struct easycap *, int);
505 /*---------------------------------------------------------------------------*/
506 /*
507 * AUDIO FUNCTION PROTOTYPES
508 */
509 /*---------------------------------------------------------------------------*/
510 void easysnd_complete(struct urb *);
511 ssize_t easysnd_read(struct file *, char __user *, size_t, loff_t *);
512 int easysnd_open(struct inode *, struct file *);
513 int easysnd_release(struct inode *, struct file *);
514 long easysnd_ioctl(struct file *, unsigned int, unsigned long);
515 unsigned int easysnd_poll(struct file *, poll_table *);
516 void easysnd_delete(struct kref *);
517 int submit_audio_urbs(struct easycap *);
518 int kill_audio_urbs(struct easycap *);
519 void easysnd_testtone(struct easycap *, int);
520 int audio_setup(struct easycap *);
521 /*---------------------------------------------------------------------------*/
522 /*
523 * LOW-LEVEL FUNCTION PROTOTYPES
524 */
525 /*---------------------------------------------------------------------------*/
526 int audio_gainget(struct usb_device *);
527 int audio_gainset(struct usb_device *, __s8);
528
529 int set_interface(struct usb_device *, __u16);
530 int wakeup_device(struct usb_device *);
531 int confirm_resolution(struct usb_device *);
532 int confirm_stream(struct usb_device *);
533
534 int setup_stk(struct usb_device *);
535 int setup_saa(struct usb_device *);
536 int setup_vt(struct usb_device *);
537 int check_stk(struct usb_device *);
538 int check_saa(struct usb_device *);
539 int ready_saa(struct usb_device *);
540 int merit_saa(struct usb_device *);
541 int check_vt(struct usb_device *);
542 int select_input(struct usb_device *, int, int);
543 int set_resolution(struct usb_device *, \
544 __u16, __u16, __u16, __u16);
545
546 int read_saa(struct usb_device *, __u16);
547 int read_stk(struct usb_device *, __u32);
548 int write_saa(struct usb_device *, __u16, __u16);
549 int wait_i2c(struct usb_device *);
550 int write_000(struct usb_device *, __u16, __u16);
551 int start_100(struct usb_device *);
552 int stop_100(struct usb_device *);
553 int write_300(struct usb_device *);
554 int read_vt(struct usb_device *, __u16);
555 int write_vt(struct usb_device *, __u16, __u16);
556
557 int set2to78(struct usb_device *);
558 int set2to93(struct usb_device *);
559
560 int regset(struct usb_device *, __u16, __u16);
561 int regget(struct usb_device *, __u16, void *);
562 /*---------------------------------------------------------------------------*/
563 struct signed_div_result {
564 long long int quotient;
565 unsigned long long int remainder;
566 } signed_div(long long int, long long int);
567 /*---------------------------------------------------------------------------*/
568 /*
569 * MACROS
570 */
571 /*---------------------------------------------------------------------------*/
572 #define GET(X, Y, Z) do { \
573 int rc; \
574 *(Z) = (__u16)0; \
575 rc = regget(X, Y, Z); \
576 if (0 > rc) { \
577 JOT(8, ":-(%i\n", __LINE__); return(rc); \
578 } \
579 } while (0)
580
581 #define SET(X, Y, Z) do { \
582 int rc; \
583 rc = regset(X, Y, Z); \
584 if (0 > rc) { \
585 JOT(8, ":-(%i\n", __LINE__); return(rc); \
586 } \
587 } while (0)
588 /*---------------------------------------------------------------------------*/
589
590 #define SAY(format, args...) do { \
591 printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \
592 } while (0)
593
594
595 #if defined(EASYCAP_DEBUG)
596 #define JOT(n, format, args...) do { \
597 if (n <= easycap_debug) { \
598 printk(KERN_DEBUG "easycap: %s: " format, __func__, ##args); \
599 } \
600 } while (0)
601 #else
602 #define JOT(n, format, args...) do {} while (0)
603 #endif /*EASYCAP_DEBUG*/
604
605 #define POUT JOT(8, ":-(in file %s line %4i\n", __FILE__, __LINE__)
606
607 #define MICROSECONDS(X, Y) \
608 ((1000000*((long long int)(X.tv_sec - Y.tv_sec))) + \
609 (long long int)(X.tv_usec - Y.tv_usec))
610
611 /*---------------------------------------------------------------------------*/
612 /*
613 * (unsigned char *)P pointer to next byte pair
614 * (long int *)X pointer to accumulating count
615 * (long int *)Y pointer to accumulating sum
616 * (long long int *)Z pointer to accumulating sum of squares
617 */
618 /*---------------------------------------------------------------------------*/
619 #define SUMMER(P, X, Y, Z) do { \
620 unsigned char *p; \
621 unsigned int u0, u1, u2; \
622 long int s; \
623 p = (unsigned char *)(P); \
624 u0 = (unsigned int) (*p); \
625 u1 = (unsigned int) (*(p + 1)); \
626 u2 = (unsigned int) ((u1 << 8) | u0); \
627 if (0x8000 & u2) \
628 s = -(long int)(0x7FFF & (~u2)); \
629 else \
630 s = (long int)(0x7FFF & u2); \
631 *((X)) += (long int) 1; \
632 *((Y)) += (long int) s; \
633 *((Z)) += ((long long int)(s) * (long long int)(s)); \
634 } while (0)
635 /*---------------------------------------------------------------------------*/
636
637 #endif /*EASYCAP_H*/
This page took 0.04675 seconds and 5 git commands to generate.