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