1a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/*
20e7072ef6623c3dc58faf3f7310aba77b0a5845eMichael Krufky   em28xx.h - driver for Empia EM2800/EM2820/2840 USB video capture devices
3a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
4a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   Copyright (C) 2005 Markus Rechberger <mrechberger@gmail.com>
54ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab		      Ludovico Cavedon <cavedon@sssup.it>
62e7c6dc3989136844eb63e05f9e4dc6608a763c6Mauro Carvalho Chehab		      Mauro Carvalho Chehab <mchehab@infradead.org>
7a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
8a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de>
9a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
10a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   This program is free software; you can redistribute it and/or modify
11a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   it under the terms of the GNU General Public License as published by
12a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   the Free Software Foundation; either version 2 of the License, or
13a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   (at your option) any later version.
14a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
15a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   This program is distributed in the hope that it will be useful,
16a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   but WITHOUT ANY WARRANTY; without even the implied warranty of
17a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   GNU General Public License for more details.
19a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
20a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   You should have received a copy of the GNU General Public License
21a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   along with this program; if not, write to the Free Software
22a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton */
24a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
253acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#ifndef _EM28XX_H
263acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define _EM28XX_H
27a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
2839a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/workqueue.h>
2939a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/i2c.h>
3039a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/mutex.h>
31cb77d010221e66c63f4a71546fed73be9b12b9a3Mauro Carvalho Chehab#include <linux/videodev2.h>
3239a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab
33ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab#include <media/videobuf-vmalloc.h>
34f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf#include <media/v4l2-device.h>
35d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab#include <media/ir-kbd-i2c.h>
366bda96447cef24fbf97a798b1ea664224d5fdc25Mauro Carvalho Chehab#include <media/rc-core.h>
373aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#if defined(CONFIG_VIDEO_EM28XX_DVB) || defined(CONFIG_VIDEO_EM28XX_DVB_MODULE)
383aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#include <media/videobuf-dvb.h>
393aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#endif
403ca9c09379e8f3be0744c47f72769457fa46e9f3Mauro Carvalho Chehab#include "tuner-xc2028.h"
4182e7dbbd4a16274b0a7038978734fc11bbf9f4b6Eddi De Pieri#include "xc5000.h"
422ba890ec0849b222a6dabb5192ccd8fd1696d6d3Mauro Carvalho Chehab#include "em28xx-reg.h"
433aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
443aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* Boards supported by driver */
453aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2800_BOARD_UNKNOWN			0
463aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_UNKNOWN			1
473aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_TERRATEC_CINERGY_250	2
483aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_PINNACLE_USB_2		3
493aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2      4
503aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_MSI_VOX_USB_2              5
513aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2800_BOARD_TERRATEC_CINERGY_200       6
523aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2800_BOARD_LEADTEK_WINFAST_USBII      7
533aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2800_BOARD_KWORLD_USB2800             8
543aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_PINNACLE_DVC_90		9
553aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900	10
563aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2880_BOARD_TERRATEC_HYBRID_XS		11
573aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_KWORLD_PVRTV2800RF		12
583aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2880_BOARD_TERRATEC_PRODIGY_XS	13
593aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2820_BOARD_PROLINK_PLAYTV_USB2	14
603aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM2800_BOARD_VGEAR_POCKETTV             15
6110ac6603613d46a43a4544fbbe9581e50879bd45Mauro Carvalho Chehab#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950	16
624fd305b2a2c4d16e8d4ebc95c84f946edd3385c5Devin Heitmueller#define EM2880_BOARD_PINNACLE_PCTV_HD_PRO	17
6317d9d558e818530cc7d210ffea575a36f48eaa1aDevin Heitmueller#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2	18
643ed58baf5db4eab553803916a990a3dbca4dc611Devin Heitmueller#define EM2860_BOARD_SAA711X_REFERENCE_DESIGN	19
65e14b3658a7651ffd9b1f407eaf07f4dde17ef1e7Devin Heitmueller#define EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600   20
6659d07f1b705c466ea4eaca9c43d46be6d6a065a4Aron Szabo#define EM2800_BOARD_GRABBEEX_USB2800           21
6795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2750_BOARD_UNKNOWN			  22
6895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2750_BOARD_DLCW_130			  23
6995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_DLINK_USB_TV		  24
7095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_GADMEI_UTV310		  25
7195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_HERCULES_SMART_TV_USB2	  26
7295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_PINNACLE_USB_2_FM1216ME	  27
7395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28
74443fed9fa42bbeacdb8d336b8a5002a262cac15cDevin Heitmueller#define EM2860_BOARD_TVP5150_REFERENCE_DESIGN	  29
7595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_VIDEOLOGY_20K14XUSB	  30
7695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2821_BOARD_USBGEAR_VD204		  31
7795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2821_BOARD_SUPERCOMP_USB_2		  32
788298f2f810b988dccfa0ab51cd874e107514c036Adrian Taylor#define EM2860_BOARD_ELGATO_VIDEO_CAPTURE	  33
7995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_TERRATEC_HYBRID_XS		  34
8095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_TYPHOON_DVD_MAKER		  35
8195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_NETGMBH_CAM		  36
8295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_GADMEI_UTV330		  37
8395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_YAKUMO_MOVIE_MIXER		  38
8495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_KWORLD_PVRTV_300U		  39
8595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_PLEXTOR_PX_TV100U		  40
8695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_KWORLD_350U		  41
8795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_KWORLD_355U		  42
8895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_TERRATEC_XS		  43
8995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_TERRATEC_XS_MT2060		  44
9095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_PINNACLE_PCTV_DVB		  45
9195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_COMPRO_VIDEOMATE		  46
9295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_KWORLD_DVB_305U		  47
9395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_KWORLD_DVB_310U		  48
9495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_MSI_DIGIVOX_AD		  49
9595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_MSI_DIGIVOX_AD_II		  50
9695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_TERRATEC_HYBRID_XS_FR	  51
9795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2881_BOARD_DNT_DA2_HYBRID		  52
9895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2881_BOARD_PINNACLE_HYBRID_PRO	  53
9995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2882_BOARD_KWORLD_VS_DVBT		  54
10095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2882_BOARD_TERRATEC_HYBRID_XS		  55
10109bc1942c031686bfcf897746b6baf9d42c92ed5Devin Heitmueller#define EM2882_BOARD_PINNACLE_HYBRID_PRO_330E	  56
1026e7b9ea0937eeb75fa166ef7bd22b5f3bb5676d1Robert Krakora#define EM2883_BOARD_KWORLD_HYBRID_330U                  57
103ee281b856d4e4921da24387ab116bb0855c2efaaMauro Carvalho Chehab#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU	  58
104f89bc32974a4376e8393001484af28d8c3350ab4Douglas Schilling Landgraf#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850	  60
1051e1addd57bdf56c51dbc292d7760ea3d207fe833Douglas Schilling Landgraf#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2	  61
106f7fe3e6f3c3e9ef6ba5ca187b514d225296d18ddDouglas Schilling Landgraf#define EM2820_BOARD_GADMEI_TVR200		  62
10756ee38071fe0cf1746d53c5b40a46a835b24fbe4Mauro Carvalho Chehab#define EM2860_BOARD_KAIOMY_TVNPC_U2              63
10856ee38071fe0cf1746d53c5b40a46a835b24fbe4Mauro Carvalho Chehab#define EM2860_BOARD_EASYCAP                      64
109f74a61e3c6f218053742c2caf3e247fb41bf395eIndika Katugampala#define EM2820_BOARD_IODATA_GVMVP_SZ		  65
110e5db5d44432abc82b1250dd05bd0a4b011392d9dDouglas Schilling Landgraf#define EM2880_BOARD_EMPIRE_DUAL_TV		  66
1114557af9c5338605c85fe54f5ebba3d4b14a60ab8Mauro Carvalho Chehab#define EM2860_BOARD_TERRATEC_GRABBY		  67
112766ed64de554fda08ceb927d36279eabcb08acb3Mauro Carvalho Chehab#define EM2860_BOARD_TERRATEC_AV350		  68
113d7de5d8ff74efd01916b01af875a0e87419a3599Franklin Meng#define EM2882_BOARD_KWORLD_ATSC_315U		  69
11419859229d7d98bc2d582ff45045dd7f73d649383Devin Heitmueller#define EM2882_BOARD_EVGA_INDTUBE		  70
11502e7804b2135ff941b8846f5820cf48fbfdadd54Mauro Carvalho Chehab#define EM2820_BOARD_SILVERCREST_WEBCAM           71
1166d888a66be1c50c2f5193c53d6ea556e01dd60e3Mauro Carvalho Chehab#define EM2861_BOARD_GADMEI_UTV330PLUS           72
117285eb1a40242adb3feaf9c73d352cbfeee1bea1cAntti Palosaari#define EM2870_BOARD_REDDO_DVB_C_USB_BOX          73
118694a101e6acb865f5405a95c358eea43c813cf24Mauro Carvalho Chehab#define EM2800_BOARD_VC211A			  74
1197ca7ef6011e92b52a365ddc78f6668e01793c572Andrea.Amorosi#define EM2882_BOARD_DIKOM_DK300		  75
1207e48b30af033076c85ab48a8306b5588faf5fb4bJarod Wilson#define EM2870_BOARD_KWORLD_A340		  76
121fec528b77f9be3e7ebb8d7c25888b0cf9fb8e8d6Mauro Carvalho Chehab#define EM2874_BOARD_LEADERSHIP_ISDBT		  77
122d6a5f921fb8cbd418b298e5bbe83e5c8c8e1da16Antti Palosaari#define EM28174_BOARD_PCTV_290E                   78
123fec528b77f9be3e7ebb8d7c25888b0cf9fb8e8d6Mauro Carvalho Chehab#define EM2884_BOARD_TERRATEC_H5		  79
12436588715fc0ed3ff0ffb025dc841652cb3b2b667Antti Palosaari#define EM28174_BOARD_PCTV_460E                   80
12582e7dbbd4a16274b0a7038978734fc11bbf9f4b6Eddi De Pieri#define EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C	  81
126a1ed02e9f1a0fa34e5b5e978209204033bb9cf4fAndreas Oberritter#define EM2884_BOARD_CINERGY_HTC_STICK		  82
1274d28d3d9978b84326a4608c25bda484973bba0a6Gareth Williams#define EM2860_BOARD_HT_VIDBOX_NW03 		  83
1283aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
1293aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* Limits minimum and default number of buffers */
1303aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_MIN_BUF 4
1313aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_DEF_BUF 8
132a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
133c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab/*Limits the max URB message size */
134c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab#define URB_MAX_CTRL_SIZE 80
135c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab
13695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf/* Params for validated field */
13795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM28XX_BOARD_NOT_VALIDATED 1
13895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM28XX_BOARD_VALIDATED	   0
13995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf
14022cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf/* Params for em28xx_cmd() audio */
14122cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf#define EM28XX_START_AUDIO      1
14222cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf#define EM28XX_STOP_AUDIO       0
14322cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf
144596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab/* maximum number of em28xx boards */
1453687e1e67e4920a202d53cc24678fb34fcda8fc5Mauro Carvalho Chehab#define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */
146596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab
147a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* maximum number of frames that can be queued */
1483acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_FRAMES 5
149a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* number of frames that get used for v4l2_read() */
1503acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_READ_FRAMES 2
151a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
152a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* number of buffers for isoc transfers */
1533acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_BUFS 5
154a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
155d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab/* number of packets for each buffer
15633c02facb5a3123212587295cc1c241ee7e03adbDevin Heitmueller   windows requests only 64 packets .. so we better do the same
157d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab   this is what I found out for all alternate numbers there!
158d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab */
15933c02facb5a3123212587295cc1c241ee7e03adbDevin Heitmueller#define EM28XX_NUM_PACKETS 64
160a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
1613acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_INTERLACED_DEFAULT 1
162a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
163a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/*
164a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#define (use usbview if you want to get the other alternate number infos)
165a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#define
166a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#define alternate number 2
167a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#define 			Endpoint Address: 82
168a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Direction: in
169a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Attribute: 1
170a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Type: Isoc
171a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Max Packet Size: 1448
172a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Interval: 125us
173a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
174a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton  alternate number 7
175a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
176a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Endpoint Address: 82
177a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Direction: in
178a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Attribute: 1
179a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Type: Isoc
180a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Max Packet Size: 3072
181a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			Interval: 125us
182a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton*/
183a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
184a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* time to wait when stopping the isoc transfer */
185a1a6ee74f2c68918f2e145dccba3637eea91a52aNicola Soranzo#define EM28XX_URB_TIMEOUT \
186a1a6ee74f2c68918f2e145dccba3637eea91a52aNicola Soranzo			msecs_to_jiffies(EM28XX_NUM_BUFS * EM28XX_NUM_PACKETS)
187a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
188596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab/* time in msecs to wait for i2c writes to finish */
189596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab#define EM2800_I2C_WRITE_TIMEOUT 20
190596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab
1913aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehabenum em28xx_mode {
1922fe3e2ee72ef17daad1d3769321bb7dd69a003a9Mauro Carvalho Chehab	EM28XX_SUSPEND,
1933aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab	EM28XX_ANALOG_MODE,
1943aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab	EM28XX_DIGITAL_MODE,
1953aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab};
1963aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
197a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
198579f72e44fb1c991352f44c20b471c3001357f68Aidan Thorntonstruct em28xx;
199579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton
200ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_usb_isoc_ctl {
201ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* max packet size of isoc transaction */
202ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				max_pkt_size;
203ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
204ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* number of allocated urbs */
205ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				num_bufs;
206ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
207ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* urb for isoc transfers */
208ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct urb			**urb;
209ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
210ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* transfer buffers for isoc transfer */
211ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	char				**transfer_buffer;
212ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
213ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* Last buffer command and region */
214ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	u8				cmd;
215ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				pos, size, pktsize;
216ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
217ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* Last field: ODD or EVEN? */
218ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				field;
219ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
220ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* Stores incomplete commands */
221ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	u32				tmp_buf;
222ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				tmp_buf_len;
223ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
224ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* Stores already requested buffers */
22528abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller	struct em28xx_buffer    	*vid_buf;
22628abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller	struct em28xx_buffer    	*vbi_buf;
227ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
228ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab		/* Stores the number of received fields */
229ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int				nfields;
230579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton
231579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton		/* isoc urb callback */
232579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton	int (*isoc_copy) (struct em28xx *dev, struct urb *urb);
233579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton
234ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab};
235ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
236bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab/* Struct to enumberate video formats */
237ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_fmt {
238ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	char  *name;
239ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	u32   fourcc;          /* v4l2 format id */
240bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab	int   depth;
241bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab	int   reg;
242ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab};
243ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
244ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab/* buffer for one video frame */
245ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_buffer {
246ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	/* common v4l buffer stuff -- must be first */
247ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct videobuf_buffer vb;
248ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
249a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct list_head frame;
250a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int top_field;
251ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int receiving;
252ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab};
253ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
254ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_dmaqueue {
255ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct list_head       active;
256ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct list_head       queued;
257ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
258ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	wait_queue_head_t          wq;
259ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
260ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	/* Counters to control buffer fill */
261ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	int                        pos;
262a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
263a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
264a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* io methods */
2653acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum em28xx_io_method {
266a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	IO_NONE,
267a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	IO_READ,
268a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	IO_MMAP,
269a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
270a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
271a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* inputs */
272a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
2733acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define MAX_EM28XX_INPUT 4
2743acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum enum28xx_itype {
2753acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_COMPOSITE1 = 1,
2763acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_COMPOSITE2,
2773acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_COMPOSITE3,
2783acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_COMPOSITE4,
2793acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_SVIDEO,
2803acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_TELEVISION,
2813acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_CABLE,
2823acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_DVB,
2833acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_VMUX_DEBUG,
2843acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_RADIO,
285a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
286a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
28735643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabenum em28xx_ac97_mode {
28835643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	EM28XX_NO_AC97 = 0,
28935643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	EM28XX_AC97_EM202,
290209acc02249d831e7f2e3d8083b6b562dde5fc6fMauro Carvalho Chehab	EM28XX_AC97_SIGMATEL,
29135643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	EM28XX_AC97_OTHER,
29235643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab};
29335643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab
29435643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabstruct em28xx_audio_mode {
29535643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	enum em28xx_ac97_mode ac97;
29635643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab
29735643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	u16 ac97_feat;
29816c7bcadff2222b297d13951dc30e133f56d0154Mauro Carvalho Chehab	u32 ac97_vendor_id;
29935643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab
30035643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	unsigned int has_audio:1;
30135643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab
30235643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	unsigned int i2s_3rates:1;
30335643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	unsigned int i2s_5rates:1;
3045c2231c84304563fd5d28e8bbb72e09e882a8e32Devin Heitmueller};
3055c2231c84304563fd5d28e8bbb72e09e882a8e32Devin Heitmueller
3065faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab/* em28xx has two audio inputs: tuner and line in.
3075faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab   However, on most devices, an auxiliary AC97 codec device is used.
3085faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab   The AC97 device may have several different inputs and outputs,
3095faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab   depending on their model. So, it is possible to use AC97 mixer to
3105faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab   address more than two different entries.
3115faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab */
312539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehabenum em28xx_amux {
3135faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	/* This is the only entry for em28xx tuner input */
3145faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_VIDEO,	/* em28xx tuner, AC97 mixer Video */
3155faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab
3165faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_LINE_IN,	/* AC97 mixer Line In */
3175faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab
3185faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	/* Some less-common mixer setups */
3195faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_VIDEO2,	/* em28xx Line in, AC97 mixer Video */
3205faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_PHONE,
3215faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_MIC,
3225faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_CD,
3235faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_AUX,
3245faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab	EM28XX_AMUX_PCM_OUT,
325539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab};
326539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab
32735ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehabenum em28xx_aout {
3288866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	/* AC97 outputs */
329e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab	EM28XX_AOUT_MASTER = 1 << 0,
330e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab	EM28XX_AOUT_LINE   = 1 << 1,
331e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab	EM28XX_AOUT_MONO   = 1 << 2,
332e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab	EM28XX_AOUT_LFE    = 1 << 3,
333e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab	EM28XX_AOUT_SURR   = 1 << 4,
3348866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab
3358866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	/* PCM IN Mixer - used by AC97_RECORD_SELECT register */
3368866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_IN = 1 << 7,
3378866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab
3388866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	/* Bits 10-8 are used to indicate the PCM IN record select */
3398866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_MIC_PCM = 0 << 8,
3408866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_CD	= 1 << 8,
3418866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_VIDEO	= 2 << 8,
3428866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_AUX	= 3 << 8,
3438866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_LINE	= 4 << 8,
3448866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_STEREO	= 5 << 8,
3458866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_MONO	= 6 << 8,
3468866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	EM28XX_AOUT_PCM_PHONE	= 7 << 8,
34735ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab};
34835ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab
34932929fb4c7c4a693ed723253b21e7bf3c8cb4b1cHans Verkuilstatic inline int ac97_return_record_select(int a_out)
3508866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab{
3518866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab	return (a_out & 0x700) >> 8;
3528866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab}
3538866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab
354122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehabstruct em28xx_reg_seq {
355122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab	int reg;
356122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab	unsigned char val, mask;
357122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab	int sleep;
358122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab};
359122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab
3603acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_input {
3613acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	enum enum28xx_itype type;
362a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	unsigned int vmux;
363539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab	enum em28xx_amux amux;
36435ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab	enum em28xx_aout aout;
365122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab	struct em28xx_reg_seq *gpio;
366a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
367a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
3683acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define INPUT(nr) (&em28xx_boards[dev->model].input[nr])
369a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
3703acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum em28xx_decoder {
371527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab	EM28XX_NODECODER = 0,
3723acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	EM28XX_TVP5150,
373ec5de990d912c0d5cca98e030bf6447c1529f56dMauro Carvalho Chehab	EM28XX_SAA711X,
374527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab};
375527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab
376527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehabenum em28xx_sensor {
377527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab	EM28XX_NOSENSOR = 0,
37802e7804b2135ff941b8846f5820cf48fbfdadd54Mauro Carvalho Chehab	EM28XX_MT9V011,
379b80fd2d811b48a92051f86d257b00f373e69a6d7Mauro Carvalho Chehab	EM28XX_MT9M001,
380f2e26ae7c8c077d001c77b330130f98e42ccad70Mauro Carvalho Chehab	EM28XX_MT9M111,
381a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
382a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
383df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehabenum em28xx_adecoder {
384df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab	EM28XX_NOADECODER = 0,
385df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab	EM28XX_TVAUDIO,
386df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab};
387df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab
3883acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_board {
389a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	char *name;
390505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab	int vchannels;
391a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int tuner_type;
39266767920e3e6532db8afe04f9b2d8e1a9e95cad9Mauro Carvalho Chehab	int tuner_addr;
393a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
394a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* i2c flags */
395a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	unsigned int tda9887_conf;
396a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
397017ab4b1e2aa31dc9fe986ab6d1f5ffa2a84395bMauro Carvalho Chehab	/* GPIO sequences */
398122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab	struct em28xx_reg_seq *dvb_gpio;
3992fe3e2ee72ef17daad1d3769321bb7dd69a003a9Mauro Carvalho Chehab	struct em28xx_reg_seq *suspend_gpio;
400017ab4b1e2aa31dc9fe986ab6d1f5ffa2a84395bMauro Carvalho Chehab	struct em28xx_reg_seq *tuner_gpio;
4012bd1d9eb1c27034a77c8e1887156da72d6160ae1Vitaly Wool	struct em28xx_reg_seq *mute_gpio;
402122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab
40374f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab	unsigned int is_em2800:1;
404a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	unsigned int has_msp34xx:1;
4055add9a6f3c90680f89b4694e81025d2aed9559afMauro Carvalho Chehab	unsigned int mts_firmware:1;
406c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab	unsigned int max_range_640_480:1;
4073aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab	unsigned int has_dvb:1;
408a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller	unsigned int has_snapshot_button:1;
409c43221df762c33e832e8855cae77989b6bf69fa6Mauro Carvalho Chehab	unsigned int is_webcam:1;
41095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf	unsigned int valid:1;
411ac07bb73fe226ae2088f060c63829afddb3f2403Mauro Carvalho Chehab	unsigned int has_ir_i2c:1;
4123abee53e4402b6ae39e1e610f9ef94eb74097138Mauro Carvalho Chehab
413a2070c665459ac37a36bebae5e97bb4a2568990eMauro Carvalho Chehab	unsigned char xclk, i2c_speed;
414f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf	unsigned char radio_addr;
415f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf	unsigned short tvaudio_addr;
416a2070c665459ac37a36bebae5e97bb4a2568990eMauro Carvalho Chehab
4173acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	enum em28xx_decoder decoder;
418df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab	enum em28xx_adecoder adecoder;
419a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
4203acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	struct em28xx_input       input[MAX_EM28XX_INPUT];
4210be4375410f1ecc917f3c0caf8f98908d357c93fMauro Carvalho Chehab	struct em28xx_input	  radio;
42202858eedcb78a664215b918d98cdb753ce432ce6Mauro Carvalho Chehab	char			  *ir_codes;
423a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
424a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
4253acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_eeprom {
426a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u32 id;			/* 0x9567eb1a */
427a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u16 vendor_ID;
428a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u16 product_ID;
429a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
430a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u16 chip_conf;
431a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
432a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u16 board_conf;
433a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
434a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u16 string1, string2, string3;
435a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
436a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 string_idx_table;
437a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
438a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
439a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* device states */
4403acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum em28xx_dev_state {
441a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	DEV_INITIALIZED = 0x01,
442a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	DEV_DISCONNECTED = 0x02,
443a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	DEV_MISCONFIGURED = 0x04,
444a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
445a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
4466d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_AUDIO_BUFS 5
4476d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_NUM_AUDIO_PACKETS 64
4486d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_AUDIO_MAX_PACKET_SIZE 196 /* static value */
4496d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_CAPTURE_STREAM_EN 1
4503aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
4513aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* em28xx extensions */
4526d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_AUDIO   0x10
4533aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_DVB     0x20
4546d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
4558c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller/* em28xx resource types (used for res_get/res_lock etc */
4568c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller#define EM28XX_RESOURCE_VIDEO 0x01
4578c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller#define EM28XX_RESOURCE_VBI   0x02
4588c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller
4596d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabstruct em28xx_audio {
4606d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	char name[50];
4616d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	char *transfer_buffer[EM28XX_AUDIO_BUFS];
4626d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	struct urb *urb[EM28XX_AUDIO_BUFS];
4636d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	struct usb_device *udev;
4646d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	unsigned int capture_transfer_done;
4656d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	struct snd_pcm_substream   *capture_pcm_substream;
4666d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
4676d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	unsigned int hwptr_done_capture;
4686d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	struct snd_card            *sndcard;
4696d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
470c744dff260e9efb1080d1e823e588f85176a057bRobert Krakora	int users;
4716d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	spinlock_t slock;
4726d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab};
4736d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
47452284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehabstruct em28xx;
47552284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab
47652284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehabstruct em28xx_fh {
47752284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab	struct em28xx *dev;
47852284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab	int           radio;
4798c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller	unsigned int  resources;
48052284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab
48152284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab	struct videobuf_queue        vb_vidq;
48228abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller	struct videobuf_queue        vb_vbiq;
48352284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab
48452284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab	enum v4l2_buf_type           type;
48552284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab};
48652284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab
487a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* main device struct */
4883acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx {
489a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* generic device properties */
490a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	char name[30];		/* name (including minor) of the device */
491a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int model;		/* index in the device_data struct */
492e5589befc472ca50882f37c4fb32333fc93a65b7Mauro Carvalho Chehab	int devno;		/* marks the number of this device */
493600bd7f0edee0f9687c3c77e6fe63c74452acbfaDevin Heitmueller	enum em28xx_chip_id chip_id;
494505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab
4954f83e7b3ef938eb9a01eadf81a0f3b2c67d3afb6Mauro Carvalho Chehab	int audio_ifnum;
4964f83e7b3ef938eb9a01eadf81a0f3b2c67d3afb6Mauro Carvalho Chehab
497f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf	struct v4l2_device v4l2_dev;
498505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab	struct em28xx_board board;
499505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab
500d36bb4e77257ed0df86deca3f69794f037f68c7dMauro Carvalho Chehab	/* Webcam specific fields */
501527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab	enum em28xx_sensor em28xx_sensor;
5025569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab	int sensor_xres, sensor_yres;
503d36bb4e77257ed0df86deca3f69794f037f68c7dMauro Carvalho Chehab	int sensor_xtal;
504527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab
505c2a6b54a9cf08d4ffeb75d70603c4a5d03ac97adMauro Carvalho Chehab	/* Allows progressive (e. g. non-interlaced) mode */
506c2a6b54a9cf08d4ffeb75d70603c4a5d03ac97adMauro Carvalho Chehab	int progressive;
507c2a6b54a9cf08d4ffeb75d70603c4a5d03ac97adMauro Carvalho Chehab
508579d315218e8a3f696e375c5f6917da6488bec8aMauro Carvalho Chehab	/* Vinmode/Vinctl used at the driver */
509579d315218e8a3f696e375c5f6917da6488bec8aMauro Carvalho Chehab	int vinmode, vinctl;
510579d315218e8a3f696e375c5f6917da6488bec8aMauro Carvalho Chehab
511d7448a8d9d06ca2ca4fd1f17404450ecba8bea3aMauro Carvalho Chehab	unsigned int has_audio_class:1;
51224a613e4b08c4077b4c809bebab1d4a36d541fccDevin Heitmueller	unsigned int has_alsa_audio:1;
5134f83e7b3ef938eb9a01eadf81a0f3b2c67d3afb6Mauro Carvalho Chehab	unsigned int is_audio_only:1;
514a2070c665459ac37a36bebae5e97bb4a2568990eMauro Carvalho Chehab
51539a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab	/* Controls audio streaming */
51639a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab	struct work_struct wq_trigger;              /* Trigger to start/stop audio for alsa module */
51739a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab	 atomic_t       stream_started;      /* stream should be running if true */
51839a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab
519bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab	struct em28xx_fmt *format;
520bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab
521a924a499adb89f52046936deac87264774652a81Mauro Carvalho Chehab	struct em28xx_IR *ir;
522a924a499adb89f52046936deac87264774652a81Mauro Carvalho Chehab
52389b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab	/* Some older em28xx chips needs a waiting time after writing */
52489b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab	unsigned int wait_after_write;
52589b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab
52674f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab	struct list_head	devlist;
52774f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab
5289bb13a6dc3a6f68c990264838ff0493d900c48d7Mauro Carvalho Chehab	u32 i2s_speed;		/* I2S speed for audio digital stream */
5299bb13a6dc3a6f68c990264838ff0493d900c48d7Mauro Carvalho Chehab
53035643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab	struct em28xx_audio_mode audio_mode;
531a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
532a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int tuner_type;		/* type of the tuner */
533a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int tuner_addr;		/* tuner address */
534a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int tda9887_conf;
535a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* i2c i/o */
536a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct i2c_adapter i2c_adap;
537a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct i2c_client i2c_client;
538a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* video for linux */
539a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int users;		/* user count for exclusive use */
540a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct video_device *vdev;	/* video for linux device struct */
5417d497f8afa80128bb99a425a6d7a766a863128a5Mauro Carvalho Chehab	v4l2_std_id norm;	/* selected tv norm */
542a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int ctl_freq;		/* selected frequency */
543a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	unsigned int ctl_input;	/* selected input */
54495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf	unsigned int ctl_ainput;/* selected audio input */
54535ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab	unsigned int ctl_aoutput;/* selected audio output */
546a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int mute;
547a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int volume;
548a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* frame properties */
549a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int width;		/* current frame width */
550a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int height;		/* current frame height */
551d45b9b8ab43c8973a9630ac54f4ede6c3e009f9eHans Verkuil	unsigned hscale;	/* horizontal scale factor (see datasheet) */
552d45b9b8ab43c8973a9630ac54f4ede6c3e009f9eHans Verkuil	unsigned vscale;	/* vertical scale factor (see datasheet) */
553a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int interlaced;		/* 1=interlace fileds, 0=just top fileds */
5549e31ced888d1ca49ec5be51ef295e3ce994366c4Mauro Carvalho Chehab	unsigned int video_bytesread;	/* Number of bytes read */
555a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
55603910cc39035d27f4c85c8ad2a236cc5c9456127Mauro Carvalho Chehab	unsigned long hash;	/* eeprom hash - for boards with generic ID */
5576ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	unsigned long i2c_hash;	/* i2c devicelist hash -
5586ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf				   for boards with generic ID */
55903910cc39035d27f4c85c8ad2a236cc5c9456127Mauro Carvalho Chehab
5609baed99ee7a834b1f2599e13f219087f01c63f38Mauro Carvalho Chehab	struct em28xx_audio adev;
5616d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
562a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* states */
5633acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	enum em28xx_dev_state state;
5643acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	enum em28xx_io_method io;
5659e31ced888d1ca49ec5be51ef295e3ce994366c4Mauro Carvalho Chehab
566da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmueller	/* vbi related state tracking */
567da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmueller	int capture_type;
568da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmueller	int vbi_read;
569da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmueller	unsigned char cur_field;
57066d9cbad5330d6df30c82f10ee18b62b096b84efDevin Heitmueller	unsigned int vbi_width;
57166d9cbad5330d6df30c82f10ee18b62b096b84efDevin Heitmueller	unsigned int vbi_height; /* lines per field */
572da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmueller
573d7448a8d9d06ca2ca4fd1f17404450ecba8bea3aMauro Carvalho Chehab	struct work_struct         request_module_wk;
574d7448a8d9d06ca2ca4fd1f17404450ecba8bea3aMauro Carvalho Chehab
575a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* locks */
5765a80415bcabf2b59e8c34db6e743c54582cfd3c2Sascha Sommer	struct mutex lock;
577f2a2e4910502e866833732f31ee697d15b3e56fdMauro Carvalho Chehab	struct mutex ctrl_urb_lock;	/* protects urb_buf */
578d7aa80207babe694b316a48200b096cf0336ecb3Aidan Thornton	/* spinlock_t queue_lock; */
579a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct list_head inqueue, outqueue;
580a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	wait_queue_head_t open, wait_frame, wait_stream;
581a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct video_device *vbi_dev;
5820be4375410f1ecc917f3c0caf8f98908d357c93fMauro Carvalho Chehab	struct video_device *radio_dev;
583a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
5848c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller	/* resources in use */
5858c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller	unsigned int resources;
5868c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller
587a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	unsigned char eedata[256];
588a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
589ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	/* Isoc control struct */
590ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct em28xx_dmaqueue vidq;
59128abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller	struct em28xx_dmaqueue vbiq;
592ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	struct em28xx_usb_isoc_ctl isoc_ctl;
593ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab	spinlock_t slock;
594ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab
595a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* usb transfer */
596a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	struct usb_device *udev;	/* the usb device */
597a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int alt;		/* alternate */
598a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	int max_pkt_size;	/* max packet size of isoc transaction */
5999d4d9c05c807ab8a49ac0024987b223bb32c022dMauro Carvalho Chehab	int num_alt;		/* Number of alternative settings */
6009d4d9c05c807ab8a49ac0024987b223bb32c022dMauro Carvalho Chehab	unsigned int *alt_max_pkt_size;	/* array of wMaxPacketSize */
6018ab3362665a699bd54fc489ff7fb6372678b94c1Holger Nelson	int dvb_alt;				/* alternate for DVB */
6028ab3362665a699bd54fc489ff7fb6372678b94c1Holger Nelson	unsigned int dvb_max_pkt_size;		/* wMaxPacketSize for DVB */
6033acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab	struct urb *urb[EM28XX_NUM_BUFS];	/* urb for isoc transfers */
604a1a6ee74f2c68918f2e145dccba3637eea91a52aNicola Soranzo	char *transfer_buffer[EM28XX_NUM_BUFS];	/* transfer buffers for isoc
605a1a6ee74f2c68918f2e145dccba3637eea91a52aNicola Soranzo						   transfer */
606c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab	char urb_buf[URB_MAX_CTRL_SIZE];	/* urb control msg buffer */
607c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab
608a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* helper funcs that call usb_control_msg */
6096ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	int (*em28xx_write_regs) (struct em28xx *dev, u16 reg,
610a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton					char *buf, int len);
6116ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	int (*em28xx_read_reg) (struct em28xx *dev, u16 reg);
6126ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg,
6136ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf					char *buf, int len);
6146ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg,
615a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton				      char *buf, int len);
6166ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf	int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg);
6173aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
6183aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab	enum em28xx_mode mode;
6193aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab
6206a1acc3bc5144e004996029b20e46e6020d128a7Devin Heitmueller	/* register numbers for GPO/GPIO registers */
6216a1acc3bc5144e004996029b20e46e6020d128a7Devin Heitmueller	u16 reg_gpo_num, reg_gpio_num;
6226a1acc3bc5144e004996029b20e46e6020d128a7Devin Heitmueller
623c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehab	/* Caches GPO and GPIO registers */
624c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehab	unsigned char	reg_gpo, reg_gpio;
625c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehab
626a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller	/* Snapshot button */
627a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller	char snapshot_button_path[30];	/* path of the input dev */
628a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller	struct input_dev *sbutton_input_dev;
629a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller	struct delayed_work sbutton_query_work;
630a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller
6313421b7787a2cf41ac5edce9b5766bddd1e1d9986Aidan Thornton	struct em28xx_dvb *dvb;
632d2ebd0f806fdb6104903365e355675934eec22b2Mauro Carvalho Chehab
633d2ebd0f806fdb6104903365e355675934eec22b2Mauro Carvalho Chehab	/* I2C keyboard data */
634d2ebd0f806fdb6104903365e355675934eec22b2Mauro Carvalho Chehab	struct IR_i2c_init_data init_data;
635a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton};
636a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
6376d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabstruct em28xx_ops {
6386d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	struct list_head next;
6396d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	char *name;
6406d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	int id;
6416d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	int (*init)(struct em28xx *);
6426d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab	int (*fini)(struct em28xx *);
643a3a048cea301baba5d451991074a85dc20a8f228Mauro Carvalho Chehab};
644a3a048cea301baba5d451991074a85dc20a8f228Mauro Carvalho Chehab
6453acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-i2c.c */
646fad7b958e753e18ff443786360f7846da50a3085Sascha Sommervoid em28xx_do_i2c_scan(struct em28xx *dev);
647f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgrafint  em28xx_i2c_register(struct em28xx *dev);
648f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgrafint  em28xx_i2c_unregister(struct em28xx *dev);
649a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
6503acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-core.c */
651a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
6523acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabu32 em28xx_request_buffers(struct em28xx *dev, u32 count);
6533acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabvoid em28xx_queue_unusedframes(struct em28xx *dev);
6543acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabvoid em28xx_release_buffers(struct em28xx *dev);
655a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
6563acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg,
657a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			    char *buf, int len);
6583acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg);
6593acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg(struct em28xx *dev, u16 reg);
6603acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf,
661a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton			  int len);
6623acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len);
663b69724899440289ab258ff417c2d6aa104c70310Devin Heitmuellerint em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val);
6641bad429e81f9a9ffa01c4158e6d1b1a3e06d9886Mauro Carvalho Chehabint em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val,
6651bad429e81f9a9ffa01c4158e6d1b1a3e06d9886Mauro Carvalho Chehab				 u8 bitmask);
666b69724899440289ab258ff417c2d6aa104c70310Devin Heitmueller
667531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehabint em28xx_read_ac97(struct em28xx *dev, u8 reg);
668531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehabint em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val);
669531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehab
6703acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_audio_analog_set(struct em28xx *dev);
67135643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabint em28xx_audio_setup(struct em28xx *dev);
672539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab
6733acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_colorlevels_set_default(struct em28xx *dev);
6743acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_capture_start(struct em28xx *dev, int start);
675da52a55cff643b8e0b346b9894adf5b93946040dDevin Heitmuellerint em28xx_vbi_supported(struct em28xx *dev);
676bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehabint em28xx_set_outfmt(struct em28xx *dev);
6773acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_resolution_set(struct em28xx *dev);
6783acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_set_alternate(struct em28xx *dev);
679579f72e44fb1c991352f44c20b471c3001357f68Aidan Thorntonint em28xx_init_isoc(struct em28xx *dev, int max_packets,
680579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton		     int num_bufs, int max_pkt_size,
681c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehab		     int (*isoc_copy) (struct em28xx *dev, struct urb *urb));
682579f72e44fb1c991352f44c20b471c3001357f68Aidan Thorntonvoid em28xx_uninit_isoc(struct em28xx *dev);
683d18e2fda7133287bf8a81809816e646cf17c332eDevin Heitmuellerint em28xx_isoc_dvb_max_packetsize(struct em28xx *dev);
684c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehabint em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode);
685c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehabint em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);
6861a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_wake_i2c(struct em28xx *dev);
6876d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabint em28xx_register_extension(struct em28xx_ops *dev);
6886d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabvoid em28xx_unregister_extension(struct em28xx_ops *dev);
6891a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_init_extension(struct em28xx *dev);
6901a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_close_extension(struct em28xx *dev);
6911a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehab
6921a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehab/* Provided by em28xx-video.c */
6931a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabint em28xx_register_analog_devices(struct em28xx *dev);
6941a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_release_analog_resources(struct em28xx *dev);
6956d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab
6963acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-cards.c */
6976ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafextern int em2800_variant_detect(struct usb_device *udev, int model);
698a94e95b443811c127734ef10f3b7d2220532c1d2Markus Rechbergerextern void em28xx_pre_card_setup(struct em28xx *dev);
6993acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern void em28xx_card_setup(struct em28xx *dev);
7003acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern struct em28xx_board em28xx_boards[];
7013acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern struct usb_device_id em28xx_id_table[];
7023acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern const unsigned int em28xx_bcount;
703c668f32dca105d876e51862a003a302fa61e4ae4Jean Delvarevoid em28xx_register_i2c_ir(struct em28xx *dev);
704d7cba043d7ec840d67bd5143779d1febe7d83407Michael Krufkyint em28xx_tuner_callback(void *ptr, int component, int command, int arg);
7051a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_release_resources(struct em28xx *dev);
706c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab
707c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab/* Provided by em28xx-input.c */
7085b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
7095b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#ifdef CONFIG_VIDEO_EM28XX_RC
7105b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
711c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehabint em28xx_get_key_terratec(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
712c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehabint em28xx_get_key_em_haup(struct IR_i2c *ir, u32 *ir_key, u32 *ir_raw);
713c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehabint em28xx_get_key_pinnacle_usb_grey(struct IR_i2c *ir, u32 *ir_key,
714c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab				     u32 *ir_raw);
715ca39d84d438b609af127f2eb161cd9029afbc9a7Magnus Almint em28xx_get_key_winfast_usbii_deluxe(struct IR_i2c *ir, u32 *ir_key,
716ca39d84d438b609af127f2eb161cd9029afbc9a7Magnus Alm				     u32 *ir_raw);
717a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmuellervoid em28xx_register_snapshot_button(struct em28xx *dev);
718a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmuellervoid em28xx_deregister_snapshot_button(struct em28xx *dev);
719a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
720a924a499adb89f52046936deac87264774652a81Mauro Carvalho Chehabint em28xx_ir_init(struct em28xx *dev);
721a924a499adb89f52046936deac87264774652a81Mauro Carvalho Chehabint em28xx_ir_fini(struct em28xx *dev);
722a924a499adb89f52046936deac87264774652a81Mauro Carvalho Chehab
7235b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#else
7245b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
7255b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#define em28xx_get_key_terratec			NULL
7265b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#define em28xx_get_key_em_haup			NULL
7275b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#define em28xx_get_key_pinnacle_usb_grey	NULL
7285b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#define em28xx_get_key_winfast_usbii_deluxe	NULL
7295b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
7305b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehabstatic inline void em28xx_register_snapshot_button(struct em28xx *dev) {}
7315b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehabstatic inline void em28xx_deregister_snapshot_button(struct em28xx *dev) {}
7325b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehabstatic inline int em28xx_ir_init(struct em28xx *dev) { return 0; }
7335b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehabstatic inline int em28xx_ir_fini(struct em28xx *dev) { return 0; }
7345b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
7355b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab#endif
7365b89ecf98998911f397fa913b06ee2304a373e54Mauro Carvalho Chehab
73728abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller/* Provided by em28xx-vbi.c */
73828abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmuellerextern struct videobuf_queue_ops em28xx_vbi_qops;
73928abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller
740a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* printk macros */
741a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7423acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_err(fmt, arg...) do {\
743f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare	printk(KERN_ERR fmt , ##arg); } while (0)
744a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7453acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_errdev(fmt, arg...) do {\
7464ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	printk(KERN_ERR "%s: "fmt,\
747f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare			dev->name , ##arg); } while (0)
748a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7493acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_info(fmt, arg...) do {\
7504ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	printk(KERN_INFO "%s: "fmt,\
751f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare			dev->name , ##arg); } while (0)
7523acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_warn(fmt, arg...) do {\
7534ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab	printk(KERN_WARNING "%s: "fmt,\
754f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare			dev->name , ##arg); } while (0)
755a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7566ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_compression_disable(struct em28xx *dev)
757a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
758a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	/* side effect of disabling scaler and mixer */
7592a29a0d770ef6f24a8fd7806655c826d45888cbaMauro Carvalho Chehab	return em28xx_write_reg(dev, EM28XX_R26_COMPR, 0x00);
760a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
761a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7626ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_contrast_get(struct em28xx *dev)
763a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
76441facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R20_YGAIN) & 0x1f;
765a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
766a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7676ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_brightness_get(struct em28xx *dev)
768a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
76941facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R21_YOFFSET);
770a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
771a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7726ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_saturation_get(struct em28xx *dev)
773a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
77441facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R22_UVGAIN) & 0x1f;
775a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
776a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7776ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_u_balance_get(struct em28xx *dev)
778a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
77941facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R23_UOFFSET);
780a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
781a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7826ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_v_balance_get(struct em28xx *dev)
783a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
78441facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R24_VOFFSET);
785a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
786a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7876ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_gamma_get(struct em28xx *dev)
788a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
78941facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_read_reg(dev, EM28XX_R14_GAMMA) & 0x3f;
790a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
791a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7926ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_contrast_set(struct em28xx *dev, s32 val)
793a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
794a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
79541facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R20_YGAIN, &tmp, 1);
796a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
797a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
7986ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_brightness_set(struct em28xx *dev, s32 val)
799a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
800a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
80141facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R21_YOFFSET, &tmp, 1);
802a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
803a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
8046ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_saturation_set(struct em28xx *dev, s32 val)
805a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
806a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
80741facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R22_UVGAIN, &tmp, 1);
808a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
809a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
8106ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_u_balance_set(struct em28xx *dev, s32 val)
811a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
812a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
81341facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R23_UOFFSET, &tmp, 1);
814a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
815a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
8166ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_v_balance_set(struct em28xx *dev, s32 val)
817a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
818a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
81941facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R24_VOFFSET, &tmp, 1);
820a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
821a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
8226ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline int em28xx_gamma_set(struct em28xx *dev, s32 val)
823a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
824a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton	u8 tmp = (u8) val;
82541facaa4b63cc1a0ff5a900149a29942d47e1491Mauro Carvalho Chehab	return em28xx_write_regs(dev, EM28XX_R14_GAMMA, &tmp, 1);
826a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
827a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton
828a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/*FIXME: maxw should be dependent of alt mode */
8296ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline unsigned int norm_maxw(struct em28xx *dev)
83030556b23f31973ca311341277c4e4b128c0528bbMarkus Rechberger{
8315569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab	if (dev->board.is_webcam)
8325569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab		return dev->sensor_xres;
8335569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab
8341020d13d50d0a5bfcfc8a0a6826ed221cdf8a775Sascha Sommer	if (dev->board.max_range_640_480)
8357d497f8afa80128bb99a425a6d7a766a863128a5Mauro Carvalho Chehab		return 640;
8365569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab
8375569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab	return 720;
83830556b23f31973ca311341277c4e4b128c0528bbMarkus Rechberger}
83930556b23f31973ca311341277c4e4b128c0528bbMarkus Rechberger
8406ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgrafstatic inline unsigned int norm_maxh(struct em28xx *dev)
841a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton{
8425569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab	if (dev->board.is_webcam)
8435569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab		return dev->sensor_yres;
8445569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab
845505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab	if (dev->board.max_range_640_480)
8467d497f8afa80128bb99a425a6d7a766a863128a5Mauro Carvalho Chehab		return 480;
8475569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab
8485569996421fa1cfc1fc0d9e683ac1def46ea985dMauro Carvalho Chehab	return (dev->norm & V4L2_STD_625_50) ? 576 : 480;
849a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}
850a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#endif
851