PageRenderTime 38ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/staging/easycap/easycap.h

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