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> 70cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com> 8a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 9a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton Based on the em2800 driver from Sascha Sommer <saschasommer@freenet.de> 10a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 11a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton This program is free software; you can redistribute it and/or modify 12a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton it under the terms of the GNU General Public License as published by 13a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton the Free Software Foundation; either version 2 of the License, or 14a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton (at your option) any later version. 15a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 16a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton This program is distributed in the hope that it will be useful, 17a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton but WITHOUT ANY WARRANTY; without even the implied warranty of 18a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton GNU General Public License for more details. 20a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 21a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton You should have received a copy of the GNU General Public License 22a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton along with this program; if not, write to the Free Software 23a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 24a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton */ 25a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 263acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#ifndef _EM28XX_H 273acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define _EM28XX_H 28a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 2901c2819330b1e0ec6b53dcfac76ad75ff2c8ba4fMauro Carvalho Chehab#define EM28XX_VERSION "0.2.1" 30d8992b0931c1f9b1254d57b26b2965327337e7c6Mauro Carvalho Chehab#define DRIVER_DESC "Empia em28xx device driver" 31ce67943e2dfd3bc8b7e86b428fc0dfc568730971Mauro Carvalho Chehab 3239a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/workqueue.h> 3339a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/i2c.h> 3439a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab#include <linux/mutex.h> 3547677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehab#include <linux/kref.h> 36cb77d010221e66c63f4a71546fed73be9b12b9a3Mauro Carvalho Chehab#include <linux/videodev2.h> 3739a96b4cf592e79aefd1b4f2b136c20ec7bf10a7Mauro Carvalho Chehab 38d3829fadc4611e96aa360b8ead5adefdf61f45eaDevin Heitmueller#include <media/videobuf2-vmalloc.h> 39f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf#include <media/v4l2-device.h> 40081b945ed74c9bd37da2ee928f9ad281222a6477Hans Verkuil#include <media/v4l2-ctrls.h> 4169a61642ac60e84647394b4cf0f322579701d218Hans Verkuil#include <media/v4l2-fh.h> 42d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab#include <media/ir-kbd-i2c.h> 436bda96447cef24fbf97a798b1ea664224d5fdc25Mauro Carvalho Chehab#include <media/rc-core.h> 443ca9c09379e8f3be0744c47f72769457fa46e9f3Mauro Carvalho Chehab#include "tuner-xc2028.h" 4582e7dbbd4a16274b0a7038978734fc11bbf9f4b6Eddi De Pieri#include "xc5000.h" 462ba890ec0849b222a6dabb5192ccd8fd1696d6d3Mauro Carvalho Chehab#include "em28xx-reg.h" 473aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 483aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* Boards supported by driver */ 49d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_UNKNOWN 0 50d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_UNKNOWN 1 51d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_TERRATEC_CINERGY_250 2 52d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_PINNACLE_USB_2 3 53d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 4 54d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_MSI_VOX_USB_2 5 55d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_TERRATEC_CINERGY_200 6 56d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_LEADTEK_WINFAST_USBII 7 57d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_KWORLD_USB2800 8 58d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_PINNACLE_DVC_90 9 59d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 10 60d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_TERRATEC_HYBRID_XS 11 61d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_KWORLD_PVRTV2800RF 12 62d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_TERRATEC_PRODIGY_XS 13 63d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_PROLINK_PLAYTV_USB2 14 64d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_VGEAR_POCKETTV 15 65d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 16 66d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_PINNACLE_PCTV_HD_PRO 17 67d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 18 68d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2860_BOARD_SAA711X_REFERENCE_DESIGN 19 69d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 20 70d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2800_BOARD_GRABBEEX_USB2800 21 7195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2750_BOARD_UNKNOWN 22 7295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2750_BOARD_DLCW_130 23 7395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_DLINK_USB_TV 24 7495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_GADMEI_UTV310 25 7595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_HERCULES_SMART_TV_USB2 26 7695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_PINNACLE_USB_2_FM1216ME 27 7795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE 28 78443fed9fa42bbeacdb8d336b8a5002a262cac15cDevin Heitmueller#define EM2860_BOARD_TVP5150_REFERENCE_DESIGN 29 7995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2820_BOARD_VIDEOLOGY_20K14XUSB 30 8095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2821_BOARD_USBGEAR_VD204 31 8195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2821_BOARD_SUPERCOMP_USB_2 32 828298f2f810b988dccfa0ab51cd874e107514c036Adrian Taylor#define EM2860_BOARD_ELGATO_VIDEO_CAPTURE 33 8395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_TERRATEC_HYBRID_XS 34 8495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_TYPHOON_DVD_MAKER 35 8595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_NETGMBH_CAM 36 8695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2860_BOARD_GADMEI_UTV330 37 8795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_YAKUMO_MOVIE_MIXER 38 8895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_KWORLD_PVRTV_300U 39 8995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2861_BOARD_PLEXTOR_PX_TV100U 40 9095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_KWORLD_350U 41 9195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_KWORLD_355U 42 9295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_TERRATEC_XS 43 9395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_TERRATEC_XS_MT2060 44 9495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_PINNACLE_PCTV_DVB 45 9595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2870_BOARD_COMPRO_VIDEOMATE 46 9695b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_KWORLD_DVB_305U 47 9795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_KWORLD_DVB_310U 48 9895b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_MSI_DIGIVOX_AD 49 9995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_MSI_DIGIVOX_AD_II 50 10095b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2880_BOARD_TERRATEC_HYBRID_XS_FR 51 10195b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2881_BOARD_DNT_DA2_HYBRID 52 10295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2881_BOARD_PINNACLE_HYBRID_PRO 53 10395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2882_BOARD_KWORLD_VS_DVBT 54 10495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM2882_BOARD_TERRATEC_HYBRID_XS 55 10509bc1942c031686bfcf897746b6baf9d42c92ed5Devin Heitmueller#define EM2882_BOARD_PINNACLE_HYBRID_PRO_330E 56 106d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2883_BOARD_KWORLD_HYBRID_330U 57 107ee281b856d4e4921da24387ab116bb0855c2efaaMauro Carvalho Chehab#define EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU 58 10838b2df95c53be4bd5421d933ca0dabbcb82741d0Devin Heitmueller#define EM2874_BOARD_PCTV_HD_MINI_80E 59 109f89bc32974a4376e8393001484af28d8c3350ab4Douglas Schilling Landgraf#define EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 60 1101e1addd57bdf56c51dbc292d7760ea3d207fe833Douglas Schilling Landgraf#define EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2 61 111f7fe3e6f3c3e9ef6ba5ca187b514d225296d18ddDouglas Schilling Landgraf#define EM2820_BOARD_GADMEI_TVR200 62 112d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2860_BOARD_KAIOMY_TVNPC_U2 63 113d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2860_BOARD_EASYCAP 64 114f74a61e3c6f218053742c2caf3e247fb41bf395eIndika Katugampala#define EM2820_BOARD_IODATA_GVMVP_SZ 65 115e5db5d44432abc82b1250dd05bd0a4b011392d9dDouglas Schilling Landgraf#define EM2880_BOARD_EMPIRE_DUAL_TV 66 1164557af9c5338605c85fe54f5ebba3d4b14a60ab8Mauro Carvalho Chehab#define EM2860_BOARD_TERRATEC_GRABBY 67 117766ed64de554fda08ceb927d36279eabcb08acb3Mauro Carvalho Chehab#define EM2860_BOARD_TERRATEC_AV350 68 118d7de5d8ff74efd01916b01af875a0e87419a3599Franklin Meng#define EM2882_BOARD_KWORLD_ATSC_315U 69 11919859229d7d98bc2d582ff45045dd7f73d649383Devin Heitmueller#define EM2882_BOARD_EVGA_INDTUBE 70 120d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2820_BOARD_SILVERCREST_WEBCAM 71 121d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2861_BOARD_GADMEI_UTV330PLUS 72 122d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2870_BOARD_REDDO_DVB_C_USB_BOX 73 123694a101e6acb865f5405a95c358eea43c813cf24Mauro Carvalho Chehab#define EM2800_BOARD_VC211A 74 1247ca7ef6011e92b52a365ddc78f6668e01793c572Andrea.Amorosi#define EM2882_BOARD_DIKOM_DK300 75 1257e48b30af033076c85ab48a8306b5588faf5fb4bJarod Wilson#define EM2870_BOARD_KWORLD_A340 76 126fec528b77f9be3e7ebb8d7c25888b0cf9fb8e8d6Mauro Carvalho Chehab#define EM2874_BOARD_LEADERSHIP_ISDBT 77 127d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM28174_BOARD_PCTV_290E 78 128fec528b77f9be3e7ebb8d7c25888b0cf9fb8e8d6Mauro Carvalho Chehab#define EM2884_BOARD_TERRATEC_H5 79 129d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM28174_BOARD_PCTV_460E 80 13082e7dbbd4a16274b0a7038978734fc11bbf9f4b6Eddi De Pieri#define EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C 81 131a1ed02e9f1a0fa34e5b5e978209204033bb9cf4fAndreas Oberritter#define EM2884_BOARD_CINERGY_HTC_STICK 82 132d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2860_BOARD_HT_VIDBOX_NW03 83 133d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2874_BOARD_MAXMEDIA_UB425_TC 84 134d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2884_BOARD_PCTV_510E 85 135d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer#define EM2884_BOARD_PCTV_520E 86 136890401364db1c521b0708ffb2468ec75e24de207Martin Blumenstingl#define EM2884_BOARD_TERRATEC_HTC_USB_XS 87 1374159d01bea38ee82f6e49383b7e73e328c118755Mauro Carvalho Chehab#define EM2884_BOARD_C3TECH_DIGITAL_DUO 88 1387c1dfdb059505fee12eaf089070145febd9e5ecfJakob Haufe#define EM2874_BOARD_DELOCK_61959 89 1396dbea9f0978fc47e26aaf1fd4246e63160b778a6Jean-Francois Thibert#define EM2874_BOARD_KWORLD_UB435Q_V2 90 1400c37e736cb869a3a7cc95a2486be73ffc1e1ee7dFrank Schaefer#define EM2765_BOARD_SPEEDLINK_VAD_LAPLACE 91 141ec573362afa202acca640629b321ac09b6911448Antti Palosaari#define EM28178_BOARD_PCTV_461E 92 14202bc1f5574e7324c03c49b3d2892e9e404d777beMauro Carvalho Chehab#define EM2874_BOARD_KWORLD_UB435Q_V3 93 143192292403147877c7d5f737a3cc751ded397aef7Antti Palosaari#define EM28178_BOARD_PCTV_292E 94 1443aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 1453aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* Limits minimum and default number of buffers */ 1463aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_MIN_BUF 4 1473aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_DEF_BUF 8 148a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 149c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab/*Limits the max URB message size */ 150c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab#define URB_MAX_CTRL_SIZE 80 151c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab 15295b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf/* Params for validated field */ 15395b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM28XX_BOARD_NOT_VALIDATED 1 15495b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf#define EM28XX_BOARD_VALIDATED 0 15595b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf 15622cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf/* Params for em28xx_cmd() audio */ 15722cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf#define EM28XX_START_AUDIO 1 15822cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf#define EM28XX_STOP_AUDIO 0 15922cff7b381eca256d2afb460b3b9815f83810011Douglas Schilling Landgraf 160596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab/* maximum number of em28xx boards */ 1613687e1e67e4920a202d53cc24678fb34fcda8fc5Mauro Carvalho Chehab#define EM28XX_MAXBOARDS 4 /*FIXME: should be bigger */ 162596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab 163a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* maximum number of frames that can be queued */ 1643acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_FRAMES 5 165a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* number of frames that get used for v4l2_read() */ 1663acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_READ_FRAMES 2 167a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 168a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* number of buffers for isoc transfers */ 1693acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_NUM_BUFS 5 17086d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari#define EM28XX_DVB_NUM_BUFS 5 171a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 172c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab/* max number of I2C buses on em28xx devices */ 173c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab#define NUM_I2C_BUSES 2 174c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab 175515688a8985c023ba47cc89eb6a22564fab76694Frank Schaefer/* isoc transfers: number of packets for each buffer 17633c02facb5a3123212587295cc1c241ee7e03adbDevin Heitmueller windows requests only 64 packets .. so we better do the same 177d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab this is what I found out for all alternate numbers there! 178d5e5265315770bda46c50ecaa64e2b9790f2064cMauro Carvalho Chehab */ 179515688a8985c023ba47cc89eb6a22564fab76694Frank Schaefer#define EM28XX_NUM_ISOC_PACKETS 64 180515688a8985c023ba47cc89eb6a22564fab76694Frank Schaefer#define EM28XX_DVB_NUM_ISOC_PACKETS 64 181a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 182c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer/* bulk transfers: transfer buffer size = packet size * packet multiplier 183c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer USB 2.0 spec says bulk packet size is always 512 bytes 184c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer */ 185c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer#define EM28XX_BULK_PACKET_MULTIPLIER 384 186c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer#define EM28XX_DVB_BULK_PACKET_MULTIPLIER 384 187c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer 1883acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define EM28XX_INTERLACED_DEFAULT 1 189a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 190d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab/* 191d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * Time in msecs to wait for i2c xfers to finish. 192d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * 35ms is the maximum time a SMBUS device could wait when 193d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * clock stretching is used. As the transfer itself will take 194d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * some time to happen, set it to 35 ms. 195d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * 196d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * Ok, I2C doesn't specify any limit. So, eventually, we may need 197d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * to increase this timeout. 198d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * 199d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * FIXME: this assumes that an I2C message is not longer than 1ms. 200d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * This is actually dependent on the I2C bus speed, although most 201d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * devices use a 100kHz clock. So, this assumtion is true most of 202d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab * the time. 203d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab */ 204d20e4ed6d30c6ecee315eea0efb3449c3591d09eMauro Carvalho Chehab#define EM28XX_I2C_XFER_TIMEOUT 36 205596d92d5128d308b5a79f21c3e72c87f5fc7e58bMauro Carvalho Chehab 2065022a2088687baeda87b03889d0791b1b908266bMauro Carvalho Chehab/* time in msecs to wait for AC97 xfers to finish */ 2075022a2088687baeda87b03889d0791b1b908266bMauro Carvalho Chehab#define EM28XX_AC97_XFER_TIMEOUT 100 2085022a2088687baeda87b03889d0791b1b908266bMauro Carvalho Chehab 209f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer/* max. number of button state polling addresses */ 210f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer#define EM28XX_NUM_BUTTON_ADDRESSES_MAX 5 211f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer 2123aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehabenum em28xx_mode { 2132fe3e2ee72ef17daad1d3769321bb7dd69a003a9Mauro Carvalho Chehab EM28XX_SUSPEND, 2143aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab EM28XX_ANALOG_MODE, 2153aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab EM28XX_DIGITAL_MODE, 2163aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab}; 2173aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 218a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 219579f72e44fb1c991352f44c20b471c3001357f68Aidan Thorntonstruct em28xx; 220579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton 221f0fa9936f577597dabd4a0140095bb3b02988814Frank Schaeferstruct em28xx_usb_bufs { 222ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab /* max packet size of isoc transaction */ 223ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab int max_pkt_size; 224ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 22586d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari /* number of packets in each buffer */ 22686d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari int num_packets; 22786d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari 228ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab /* number of allocated urbs */ 229ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab int num_bufs; 230ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 231f0fa9936f577597dabd4a0140095bb3b02988814Frank Schaefer /* urb for isoc/bulk transfers */ 232ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab struct urb **urb; 233ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 234f0fa9936f577597dabd4a0140095bb3b02988814Frank Schaefer /* transfer buffers for isoc/bulk transfer */ 235ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab char **transfer_buffer; 23686d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari}; 23786d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari 23874209dc06a7c27401de637cc371f54920d628ba8Frank Schaeferstruct em28xx_usb_ctl { 23974209dc06a7c27401de637cc371f54920d628ba8Frank Schaefer /* isoc/bulk transfer buffers for analog mode */ 240f0fa9936f577597dabd4a0140095bb3b02988814Frank Schaefer struct em28xx_usb_bufs analog_bufs; 24186d38d1e0e0f66ec3973b718d35a590e04fb32faGianluca Gennari 24274209dc06a7c27401de637cc371f54920d628ba8Frank Schaefer /* isoc/bulk transfer buffers for digital mode */ 243f0fa9936f577597dabd4a0140095bb3b02988814Frank Schaefer struct em28xx_usb_bufs digital_bufs; 244ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 245ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab /* Stores already requested buffers */ 24628abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller struct em28xx_buffer *vid_buf; 24728abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller struct em28xx_buffer *vbi_buf; 248ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 24974209dc06a7c27401de637cc371f54920d628ba8Frank Schaefer /* copy data from URB */ 25074209dc06a7c27401de637cc371f54920d628ba8Frank Schaefer int (*urb_data_copy) (struct em28xx *dev, struct urb *urb); 251579f72e44fb1c991352f44c20b471c3001357f68Aidan Thornton 252ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab}; 253ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 254bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab/* Struct to enumberate video formats */ 255ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_fmt { 256ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab char *name; 257ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab u32 fourcc; /* v4l2 format id */ 258bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab int depth; 259bddcf63313c6a4a85f94db092f45e31f530da691Mauro Carvalho Chehab int reg; 260ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab}; 261ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 262ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab/* buffer for one video frame */ 263ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_buffer { 264ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab /* common v4l buffer stuff -- must be first */ 265d3829fadc4611e96aa360b8ead5adefdf61f45eaDevin Heitmueller struct vb2_buffer vb; 266d3829fadc4611e96aa360b8ead5adefdf61f45eaDevin Heitmueller struct list_head list; 267ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 268d3829fadc4611e96aa360b8ead5adefdf61f45eaDevin Heitmueller void *mem; 269d3829fadc4611e96aa360b8ead5adefdf61f45eaDevin Heitmueller unsigned int length; 270a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int top_field; 2718732533b3284ca078e3ea4a4721e43627ff7fa8eFrank Schaefer 2728732533b3284ca078e3ea4a4721e43627ff7fa8eFrank Schaefer /* counter to control buffer fill */ 2738732533b3284ca078e3ea4a4721e43627ff7fa8eFrank Schaefer unsigned int pos; 2748732533b3284ca078e3ea4a4721e43627ff7fa8eFrank Schaefer /* NOTE; in interlaced mode, this value is reset to zero at 2758732533b3284ca078e3ea4a4721e43627ff7fa8eFrank Schaefer * the start of each new field (not frame !) */ 2764078d625c9610a362f571f7e5ff2521adadfff2bFrank Schaefer 2774078d625c9610a362f571f7e5ff2521adadfff2bFrank Schaefer /* pointer to vmalloc memory address in vb */ 2784078d625c9610a362f571f7e5ff2521adadfff2bFrank Schaefer char *vb_buf; 279ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab}; 280ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 281ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehabstruct em28xx_dmaqueue { 282ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab struct list_head active; 283ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 284ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab wait_queue_head_t wq; 285a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 286a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 287a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* inputs */ 288a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 2893acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define MAX_EM28XX_INPUT 4 2903acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum enum28xx_itype { 2913acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_COMPOSITE1 = 1, 2923acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_COMPOSITE2, 2933acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_COMPOSITE3, 2943acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_COMPOSITE4, 2953acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_SVIDEO, 2963acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_TELEVISION, 2973acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_CABLE, 2983acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_DVB, 2993acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_VMUX_DEBUG, 3003acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_RADIO, 301a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 302a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 30335643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabenum em28xx_ac97_mode { 30435643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab EM28XX_NO_AC97 = 0, 30535643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab EM28XX_AC97_EM202, 306209acc02249d831e7f2e3d8083b6b562dde5fc6fMauro Carvalho Chehab EM28XX_AC97_SIGMATEL, 30735643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab EM28XX_AC97_OTHER, 30835643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab}; 30935643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab 31035643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabstruct em28xx_audio_mode { 31135643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab enum em28xx_ac97_mode ac97; 312920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaefer}; 31335643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab 314920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaeferenum em28xx_int_audio_type { 315920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaefer EM28XX_INT_AUDIO_NONE = 0, 316920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaefer EM28XX_INT_AUDIO_AC97, 317920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaefer EM28XX_INT_AUDIO_I2S, 3185c2231c84304563fd5d28e8bbb72e09e882a8e32Devin Heitmueller}; 31935643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab 320c5874208ff78a5180ef0456caa117704983f3a45Frank Schaeferenum em28xx_usb_audio_type { 321c5874208ff78a5180ef0456caa117704983f3a45Frank Schaefer EM28XX_USB_AUDIO_NONE = 0, 322c5874208ff78a5180ef0456caa117704983f3a45Frank Schaefer EM28XX_USB_AUDIO_CLASS, 323c5874208ff78a5180ef0456caa117704983f3a45Frank Schaefer EM28XX_USB_AUDIO_VENDOR, 3245c2231c84304563fd5d28e8bbb72e09e882a8e32Devin Heitmueller}; 3255c2231c84304563fd5d28e8bbb72e09e882a8e32Devin Heitmueller 3265faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab/* em28xx has two audio inputs: tuner and line in. 3275faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab However, on most devices, an auxiliary AC97 codec device is used. 3285faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab The AC97 device may have several different inputs and outputs, 3295faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab depending on their model. So, it is possible to use AC97 mixer to 3305faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab address more than two different entries. 3315faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab */ 332539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehabenum em28xx_amux { 3335faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab /* This is the only entry for em28xx tuner input */ 3345faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_VIDEO, /* em28xx tuner, AC97 mixer Video */ 3355faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab 3365faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_LINE_IN, /* AC97 mixer Line In */ 3375faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab 3385faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab /* Some less-common mixer setups */ 3395faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_VIDEO2, /* em28xx Line in, AC97 mixer Video */ 3405faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_PHONE, 3415faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_MIC, 3425faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_CD, 3435faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_AUX, 3445faff78904d9c07f38ac0e227b322e9f58d5447cMauro Carvalho Chehab EM28XX_AMUX_PCM_OUT, 345539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab}; 346539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab 34735ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehabenum em28xx_aout { 3488866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab /* AC97 outputs */ 349e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab EM28XX_AOUT_MASTER = 1 << 0, 350e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab EM28XX_AOUT_LINE = 1 << 1, 351e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab EM28XX_AOUT_MONO = 1 << 2, 352e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab EM28XX_AOUT_LFE = 1 << 3, 353e879b8ebb000298f8124fc8fae570afc9eb37cbbMauro Carvalho Chehab EM28XX_AOUT_SURR = 1 << 4, 3548866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab 3558866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab /* PCM IN Mixer - used by AC97_RECORD_SELECT register */ 3568866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_IN = 1 << 7, 3578866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab 3588866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab /* Bits 10-8 are used to indicate the PCM IN record select */ 3598866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_MIC_PCM = 0 << 8, 3608866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_CD = 1 << 8, 3618866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_VIDEO = 2 << 8, 3628866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_AUX = 3 << 8, 3638866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_LINE = 4 << 8, 3648866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_STEREO = 5 << 8, 3658866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_MONO = 6 << 8, 3668866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab EM28XX_AOUT_PCM_PHONE = 7 << 8, 36735ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab}; 36835ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab 36932929fb4c7c4a693ed723253b21e7bf3c8cb4b1cHans Verkuilstatic inline int ac97_return_record_select(int a_out) 3708866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab{ 3718866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab return (a_out & 0x700) >> 8; 3728866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab} 3738866f9cf8d85f3614855a49b9d9056f265d0cd33Mauro Carvalho Chehab 374122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehabstruct em28xx_reg_seq { 375122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab int reg; 376122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab unsigned char val, mask; 377122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab int sleep; 378122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab}; 379122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab 3803acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_input { 3813acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab enum enum28xx_itype type; 382a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton unsigned int vmux; 383539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab enum em28xx_amux amux; 38435ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab enum em28xx_aout aout; 385122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab struct em28xx_reg_seq *gpio; 386a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 387a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 3883acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define INPUT(nr) (&em28xx_boards[dev->model].input[nr]) 389a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 3903acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabenum em28xx_decoder { 391527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab EM28XX_NODECODER = 0, 3923acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab EM28XX_TVP5150, 393ec5de990d912c0d5cca98e030bf6447c1529f56dMauro Carvalho Chehab EM28XX_SAA711X, 394527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab}; 395527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab 396527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehabenum em28xx_sensor { 397527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab EM28XX_NOSENSOR = 0, 39802e7804b2135ff941b8846f5820cf48fbfdadd54Mauro Carvalho Chehab EM28XX_MT9V011, 399b80fd2d811b48a92051f86d257b00f373e69a6d7Mauro Carvalho Chehab EM28XX_MT9M001, 400f2e26ae7c8c077d001c77b330130f98e42ccad70Mauro Carvalho Chehab EM28XX_MT9M111, 401e4b7131dd51c3efb2656bc5b00aa96bfef17b709Frank Schaefer EM28XX_OV2640, 402a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 403a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 404df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehabenum em28xx_adecoder { 405df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab EM28XX_NOADECODER = 0, 406df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab EM28XX_TVAUDIO, 407df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab}; 408df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab 4096b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaeferenum em28xx_led_role { 4106b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer EM28XX_LED_ANALOG_CAPTURING = 0, 41154e925498cce3795add03ba0f06087fd78c1038dMauro Carvalho Chehab EM28XX_LED_DIGITAL_CAPTURING, 4126063d07785b7059d276cb1a39c76186804f5938eFrank Schaefer EM28XX_LED_ILLUMINATION, 4136b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer EM28XX_NUM_LED_ROLES, /* must be the last */ 4146b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer}; 4156b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer 41607e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaeferstruct em28xx_led { 4176b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer enum em28xx_led_role role; 41807e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer u8 gpio_reg; 41907e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer u8 gpio_mask; 42007e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer bool inverted; 42107e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer}; 42207e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer 423f522260993822d82e2c480aa676aa4ca1230d235Frank Schaeferenum em28xx_button_role { 424f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer EM28XX_BUTTON_SNAPSHOT = 0, 4256063d07785b7059d276cb1a39c76186804f5938eFrank Schaefer EM28XX_BUTTON_ILLUMINATION, 426f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer EM28XX_NUM_BUTTON_ROLES, /* must be the last */ 427f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer}; 428f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer 429f522260993822d82e2c480aa676aa4ca1230d235Frank Schaeferstruct em28xx_button { 430f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer enum em28xx_button_role role; 431f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer u8 reg_r; 432f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer u8 reg_clearing; 433f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer u8 mask; 434f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer bool inverted; 435f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer}; 436f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer 4373acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_board { 438a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton char *name; 439505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab int vchannels; 440a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int tuner_type; 44166767920e3e6532db8afe04f9b2d8e1a9e95cad9Mauro Carvalho Chehab int tuner_addr; 442aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab unsigned def_i2c_bus; /* Default I2C bus */ 443a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 444a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* i2c flags */ 445a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton unsigned int tda9887_conf; 446a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 447017ab4b1e2aa31dc9fe986ab6d1f5ffa2a84395bMauro Carvalho Chehab /* GPIO sequences */ 448122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab struct em28xx_reg_seq *dvb_gpio; 4492fe3e2ee72ef17daad1d3769321bb7dd69a003a9Mauro Carvalho Chehab struct em28xx_reg_seq *suspend_gpio; 450017ab4b1e2aa31dc9fe986ab6d1f5ffa2a84395bMauro Carvalho Chehab struct em28xx_reg_seq *tuner_gpio; 4512bd1d9eb1c27034a77c8e1887156da72d6160ae1Vitaly Wool struct em28xx_reg_seq *mute_gpio; 452122b77e59ed2de0692dfe45c87a93e98156fe03aMauro Carvalho Chehab 45374f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab unsigned int is_em2800:1; 454a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton unsigned int has_msp34xx:1; 4555add9a6f3c90680f89b4694e81025d2aed9559afMauro Carvalho Chehab unsigned int mts_firmware:1; 456c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab unsigned int max_range_640_480:1; 4573aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab unsigned int has_dvb:1; 458c43221df762c33e832e8855cae77989b6bf69fa6Mauro Carvalho Chehab unsigned int is_webcam:1; 45995b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf unsigned int valid:1; 460ac07bb73fe226ae2088f060c63829afddb3f2403Mauro Carvalho Chehab unsigned int has_ir_i2c:1; 4613abee53e4402b6ae39e1e610f9ef94eb74097138Mauro Carvalho Chehab 462a2070c665459ac37a36bebae5e97bb4a2568990eMauro Carvalho Chehab unsigned char xclk, i2c_speed; 463f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf unsigned char radio_addr; 464f2cf250af156bef127433efd255abfae6aab02f6Douglas Schilling Landgraf unsigned short tvaudio_addr; 465a2070c665459ac37a36bebae5e97bb4a2568990eMauro Carvalho Chehab 4663acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab enum em28xx_decoder decoder; 467df7fa09cca9d80f746c29f95b09a7223f6c2f4e7Mauro Carvalho Chehab enum em28xx_adecoder adecoder; 468a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4693acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab struct em28xx_input input[MAX_EM28XX_INPUT]; 4700be4375410f1ecc917f3c0caf8f98908d357c93fMauro Carvalho Chehab struct em28xx_input radio; 47102858eedcb78a664215b918d98cdb753ce432ce6Mauro Carvalho Chehab char *ir_codes; 47207e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer 47307e4de3004ecedd67c72708d6c0fe69c51317f79Frank Schaefer /* LEDs that need to be controlled explicitly */ 4746b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer struct em28xx_led *leds; 475f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer 476f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer /* Buttons */ 477f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer struct em28xx_button *buttons; 478a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 479a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4803acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx_eeprom { 4810c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer u8 id[4]; /* 1a eb 67 95 */ 4820c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer __le16 vendor_ID; 4830c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer __le16 product_ID; 484a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4850c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer __le16 chip_conf; 486a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4870c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer __le16 board_conf; 488a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4890c28dcc054ecbcd16e197bd9bf9b394cc1f691c5Frank Schaefer __le16 string1, string2, string3; 490a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 491a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton u8 string_idx_table; 492a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 493a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 4946d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_CAPTURE_STREAM_EN 1 4953aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 4963aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab/* em28xx extensions */ 4976d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab#define EM28XX_AUDIO 0x10 4983aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab#define EM28XX_DVB 0x20 499f4d4e7656b26a6013bc5072c946920d2e2c44e8eEzequiel García#define EM28XX_RC 0x30 50001c2819330b1e0ec6b53dcfac76ad75ff2c8ba4fMauro Carvalho Chehab#define EM28XX_V4L2 0x40 5016d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab 5028c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller/* em28xx resource types (used for res_get/res_lock etc */ 5038c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller#define EM28XX_RESOURCE_VIDEO 0x01 5048c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller#define EM28XX_RESOURCE_VBI 0x02 5058c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller 50695d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaeferstruct em28xx_v4l2 { 50795d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer struct kref ref; 508abc1308f0bb89d1e59d1eccb71f85161f8e80108Frank Schaefer struct em28xx *dev; 50995d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer 51095d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer struct v4l2_device v4l2_dev; 511abc1308f0bb89d1e59d1eccb71f85161f8e80108Frank Schaefer struct v4l2_ctrl_handler ctrl_handler; 5122c52a2fce0f00479548a076d900d1a2ddd001c27Frank Schaefer struct v4l2_clk *clk; 513ef74a0b9ff56caa0e10be620d3b59f2176984430Frank Schaefer 514ef74a0b9ff56caa0e10be620d3b59f2176984430Frank Schaefer struct video_device *vdev; 515ef74a0b9ff56caa0e10be620d3b59f2176984430Frank Schaefer struct video_device *vbi_dev; 516ef74a0b9ff56caa0e10be620d3b59f2176984430Frank Schaefer struct video_device *radio_dev; 51727a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer 51827a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer /* Videobuf2 */ 51927a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer struct vb2_queue vb_vidq; 52027a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer struct vb2_queue vb_vbiq; 52127a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer struct mutex vb_queue_lock; 52227a36df63b5befa3b142d4aef54f3a240c8bd977Frank Schaefer struct mutex vb_vbi_queue_lock; 523753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer 5249297285e51c0f0305b660d6330a7916da18451c8Frank Schaefer u8 vinmode; 5259297285e51c0f0305b660d6330a7916da18451c8Frank Schaefer u8 vinctl; 5269297285e51c0f0305b660d6330a7916da18451c8Frank Schaefer 527d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer /* Camera specific fields */ 528d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer int sensor_xres; 529d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer int sensor_yres; 530d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer int sensor_xtal; 531d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer 5328e2c8717c1812628b5538c05250057b37c66fdbeFrank Schaefer int users; /* user count for exclusive use */ 5338139a4d583abad45eb987b5a99b3281b6d435b7eFrank Schaefer int streaming_users; /* number of actively streaming users */ 5348139a4d583abad45eb987b5a99b3281b6d435b7eFrank Schaefer 5353854b0d847d558bdc820b93ae8a93c0923d0211dFrank Schaefer u32 frequency; /* selected tuner frequency */ 5363854b0d847d558bdc820b93ae8a93c0923d0211dFrank Schaefer 53706e206721caf42935a458911fa4e5cdb49c22c0cFrank Schaefer struct em28xx_fmt *format; 53852faaf78b5059fcc927f3b821e6aa92cf50d3143Frank Schaefer v4l2_std_id norm; /* selected tv norm */ 53952faaf78b5059fcc927f3b821e6aa92cf50d3143Frank Schaefer 54058159171c7f201e5d6ea2666c7b3857e782a2861Frank Schaefer /* Progressive/interlaced mode */ 54158159171c7f201e5d6ea2666c7b3857e782a2861Frank Schaefer bool progressive; 54258159171c7f201e5d6ea2666c7b3857e782a2861Frank Schaefer int interlaced_fieldmode; /* 1=interlaced fields, 0=just top fields */ 54358159171c7f201e5d6ea2666c7b3857e782a2861Frank Schaefer /* FIXME: everything else than interlaced_fieldmode=1 doesn't work */ 54458159171c7f201e5d6ea2666c7b3857e782a2861Frank Schaefer 545753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer /* Frame properties */ 546753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer int width; /* current frame width */ 547753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer int height; /* current frame height */ 548753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer unsigned hscale; /* horizontal scale factor (see datasheet) */ 549753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer unsigned vscale; /* vertical scale factor (see datasheet) */ 550753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer unsigned int vbi_width; 551753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer unsigned int vbi_height; /* lines per field */ 552f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer 553f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer /* Capture state tracking */ 554f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer int capture_type; 555f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer bool top_field; 556f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer int vbi_read; 557f0e38230b3b1e564841a52e2de17e063f5df19eaFrank Schaefer unsigned int field_count; 55895d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer}; 55995d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer 5606d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabstruct em28xx_audio { 5616d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab char name[50]; 5621b3fd2d342667005855deae74200195695433259Mauro Carvalho Chehab unsigned num_urb; 5631b3fd2d342667005855deae74200195695433259Mauro Carvalho Chehab char **transfer_buffer; 5641b3fd2d342667005855deae74200195695433259Mauro Carvalho Chehab struct urb **urb; 5656d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab struct usb_device *udev; 5666d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab unsigned int capture_transfer_done; 5676d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab struct snd_pcm_substream *capture_pcm_substream; 5686d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab 5696d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab unsigned int hwptr_done_capture; 5706d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab struct snd_card *sndcard; 5716d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab 572a02b9c238b408f69fc78d528b549b85001df98b8Mauro Carvalho Chehab size_t period; 573a02b9c238b408f69fc78d528b549b85001df98b8Mauro Carvalho Chehab 574c744dff260e9efb1080d1e823e588f85176a057bRobert Krakora int users; 5756d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab spinlock_t slock; 576a5c075cfd2386a4f3ab4f8ed2830ebee557d4b3fFrank Schaefer 577a5c075cfd2386a4f3ab4f8ed2830ebee557d4b3fFrank Schaefer /* Controls streaming */ 578a5c075cfd2386a4f3ab4f8ed2830ebee557d4b3fFrank Schaefer struct work_struct wq_trigger; /* trigger to start/stop audio */ 579a5c075cfd2386a4f3ab4f8ed2830ebee557d4b3fFrank Schaefer atomic_t stream_started; /* stream should be running if true */ 5806d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab}; 5816d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab 58252284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehabstruct em28xx; 58352284c3e47bf502aaff72ab2ede509193b628b1bMauro Carvalho Chehab 584a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaeferenum em28xx_i2c_algo_type { 585a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer EM28XX_I2C_ALGO_EM28XX = 0, 586a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer EM28XX_I2C_ALGO_EM2800, 587a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer EM28XX_I2C_ALGO_EM25XX_BUS_B, 588a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer}; 589a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer 590aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehabstruct em28xx_i2c_bus { 591aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab struct em28xx *dev; 592aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab 593aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab unsigned bus; 594a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer enum em28xx_i2c_algo_type algo_type; 595aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab}; 596aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab 597a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* main device struct */ 5983acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabstruct em28xx { 59947677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehab struct kref ref; 60047677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehab 6016743033e58da2888b7f61bf87cad9cd3069a9b17Frank Schaefer /* Sub-module data */ 60295d2608b88a17d0a9326e91608f7b2cf4c1c000dFrank Schaefer struct em28xx_v4l2 *v4l2; 6036743033e58da2888b7f61bf87cad9cd3069a9b17Frank Schaefer struct em28xx_dvb *dvb; 6046743033e58da2888b7f61bf87cad9cd3069a9b17Frank Schaefer struct em28xx_audio adev; 6056743033e58da2888b7f61bf87cad9cd3069a9b17Frank Schaefer struct em28xx_IR *ir; 6066743033e58da2888b7f61bf87cad9cd3069a9b17Frank Schaefer 607a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* generic device properties */ 608a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton char name[30]; /* name (including minor) of the device */ 609a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int model; /* index in the device_data struct */ 610e5589befc472ca50882f37c4fb32333fc93a65b7Mauro Carvalho Chehab int devno; /* marks the number of this device */ 611600bd7f0edee0f9687c3c77e6fe63c74452acbfaDevin Heitmueller enum em28xx_chip_id chip_id; 612505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab 613ce67943e2dfd3bc8b7e86b428fc0dfc568730971Mauro Carvalho Chehab unsigned int is_em25xx:1; /* em25xx/em276x/7x/8x family bridge */ 6142665c2995d6a6026cfc9ec118908dfccb74fb5e0Frank Schaefer unsigned char disconnected:1; /* device has been diconnected */ 61501c2819330b1e0ec6b53dcfac76ad75ff2c8ba4fMauro Carvalho Chehab unsigned int has_video:1; 616ce67943e2dfd3bc8b7e86b428fc0dfc568730971Mauro Carvalho Chehab unsigned int is_audio_only:1; 617920f1e4a528a1db01d6822026f653659ecb4983dFrank Schaefer enum em28xx_int_audio_type int_audio_type; 618c5874208ff78a5180ef0456caa117704983f3a45Frank Schaefer enum em28xx_usb_audio_type usb_audio_type; 6192665c2995d6a6026cfc9ec118908dfccb74fb5e0Frank Schaefer 620505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab struct em28xx_board board; 621505b6d0b774fa4475fedbd3cebf95199c17a0086Mauro Carvalho Chehab 622d7dc18da634dcb5f9023660dca85b6be1e401264Frank Schaefer enum em28xx_sensor em28xx_sensor; /* camera specific */ 623527f09a981e398331c2f8d8f7af83cd46e6a06ccMauro Carvalho Chehab 62489b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab /* Some older em28xx chips needs a waiting time after writing */ 62589b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab unsigned int wait_after_write; 62689b329ef9d7cc16ed46fc991b21b2d45e7bf452cMauro Carvalho Chehab 62774f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab struct list_head devlist; 62874f38a82376fb1b289d0957429ba45349f0cad62Mauro Carvalho Chehab 6299bb13a6dc3a6f68c990264838ff0493d900c48d7Mauro Carvalho Chehab u32 i2s_speed; /* I2S speed for audio digital stream */ 6309bb13a6dc3a6f68c990264838ff0493d900c48d7Mauro Carvalho Chehab 63135643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehab struct em28xx_audio_mode audio_mode; 632a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 633a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int tuner_type; /* type of the tuner */ 634c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab 635a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* i2c i/o */ 636c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab struct i2c_adapter i2c_adap[NUM_I2C_BUSES]; 637c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab struct i2c_client i2c_client[NUM_I2C_BUSES]; 638aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab struct em28xx_i2c_bus i2c_bus[NUM_I2C_BUSES]; 639aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab 64087b52439cff4a8b745f419b9e99fa68a5533c342Frank Schaefer unsigned char eeprom_addrwidth_16bit:1; 641aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab unsigned def_i2c_bus; /* Default I2C bus */ 642aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab unsigned cur_i2c_bus; /* Current I2C bus */ 643aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehab struct rt_mutex i2c_bus_lock; 644c7a45e5b4f8c2f96cd242ae1b1c06e7fb19a08d0Mauro Carvalho Chehab 645a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* video for linux */ 646a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton unsigned int ctl_input; /* selected input */ 64795b86a9a9020da22e7c25abc77aae4dc8f02ab55Douglas Schilling Landgraf unsigned int ctl_ainput;/* selected audio input */ 64835ae6f04ad3e4c3ed8a83382b6511bd9beb5c768Mauro Carvalho Chehab unsigned int ctl_aoutput;/* selected audio output */ 649a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int mute; 650a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int volume; 651753aee7738ed2ee8c810524ee32b556ac7617f2eFrank Schaefer 65203910cc39035d27f4c85c8ad2a236cc5c9456127Mauro Carvalho Chehab unsigned long hash; /* eeprom hash - for boards with generic ID */ 6536ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf unsigned long i2c_hash; /* i2c devicelist hash - 6546ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf for boards with generic ID */ 65503910cc39035d27f4c85c8ad2a236cc5c9456127Mauro Carvalho Chehab 656d7448a8d9d06ca2ca4fd1f17404450ecba8bea3aMauro Carvalho Chehab struct work_struct request_module_wk; 657d7448a8d9d06ca2ca4fd1f17404450ecba8bea3aMauro Carvalho Chehab 658a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* locks */ 6595a80415bcabf2b59e8c34db6e743c54582cfd3c2Sascha Sommer struct mutex lock; 660f2a2e4910502e866833732f31ee697d15b3e56fdMauro Carvalho Chehab struct mutex ctrl_urb_lock; /* protects urb_buf */ 661a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 6628c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller /* resources in use */ 6638c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller unsigned int resources; 6648c873d31af868b4e340defc7053945636c8bd0e1Devin Heitmueller 665510e884c1abb86b060b895ffaf38ee1aac2e7fe4Frank Schaefer /* eeprom content */ 666510e884c1abb86b060b895ffaf38ee1aac2e7fe4Frank Schaefer u8 *eedata; 667510e884c1abb86b060b895ffaf38ee1aac2e7fe4Frank Schaefer u16 eedata_len; 668a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 669ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab /* Isoc control struct */ 670ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab struct em28xx_dmaqueue vidq; 67128abf083d356bc4ec459ded7a95b6a22a20f6c3dDevin Heitmueller struct em28xx_dmaqueue vbiq; 67274209dc06a7c27401de637cc371f54920d628ba8Frank Schaefer struct em28xx_usb_ctl usb_ctl; 673ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab spinlock_t slock; 674ad0ebb96c220c461386e9a765fca3daf5590d01eMauro Carvalho Chehab 675a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* usb transfer */ 676a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton struct usb_device *udev; /* the usb device */ 677961717b41bc1103dcd30d293fd689a614fbfa90cFrank Schaefer u8 ifnum; /* number of the assigned usb interface */ 678c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer u8 analog_ep_isoc; /* address of isoc endpoint for analog */ 679c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer u8 analog_ep_bulk; /* address of bulk endpoint for analog */ 680c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ 681d5b6a7469127147797638b4c2b0c86d3049ad4abFrank Schaefer u8 dvb_ep_bulk; /* address of bulk endpoint for DVB */ 6820cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer int alt; /* alternate setting */ 6830cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer int max_pkt_size; /* max packet size of the selected ep at alt */ 684c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer int packet_multiplier; /* multiplier for wMaxPacketSize, used for 685c647a91a2558c4031eddd013e5860ca5a41363a7Frank Schaefer URB buffer size definition */ 6860cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer int num_alt; /* number of alternative settings */ 6870cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer unsigned int *alt_max_pkt_size_isoc; /* array of isoc wMaxPacketSize */ 6887312f2c9fa22614acc787c064a0865840888d662Frank Schaefer unsigned int analog_xfer_bulk:1; /* use bulk instead of isoc 6897312f2c9fa22614acc787c064a0865840888d662Frank Schaefer transfers for analog */ 6900cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer int dvb_alt_isoc; /* alternate setting for DVB isoc transfers */ 6910cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer unsigned int dvb_max_pkt_size_isoc; /* isoc max packet size of the 6920cf544a6cc66b493852d48517ce4833dfade5809Frank Schaefer selected DVB ep at dvb_alt */ 6937312f2c9fa22614acc787c064a0865840888d662Frank Schaefer unsigned int dvb_xfer_bulk:1; /* use bulk instead of isoc 6947312f2c9fa22614acc787c064a0865840888d662Frank Schaefer transfers for DVB */ 695c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab char urb_buf[URB_MAX_CTRL_SIZE]; /* urb control msg buffer */ 696c4a98793a63c423c9e1af51822325969e23c16d4Mauro Carvalho Chehab 697a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton /* helper funcs that call usb_control_msg */ 6986ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf int (*em28xx_write_regs) (struct em28xx *dev, u16 reg, 699a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton char *buf, int len); 7006ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf int (*em28xx_read_reg) (struct em28xx *dev, u16 reg); 7016ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf int (*em28xx_read_reg_req_len) (struct em28xx *dev, u8 req, u16 reg, 7026ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf char *buf, int len); 7036ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf int (*em28xx_write_regs_req) (struct em28xx *dev, u8 req, u16 reg, 704a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton char *buf, int len); 7056ea54d938b6f81baa0952a8b15d3e67e6c268b8fDouglas Schilling Landgraf int (*em28xx_read_reg_req) (struct em28xx *dev, u8 req, u16 reg); 7063aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 7073aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab enum em28xx_mode mode; 7083aefb79af8d41c85e11da7109d62038849421bb6Mauro Carvalho Chehab 709f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer /* Button state polling */ 710f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer struct delayed_work buttons_query_work; 711f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer u8 button_polling_addresses[EM28XX_NUM_BUTTON_ADDRESSES_MAX]; 7127763481a97488f201e7b6a42ddce1d163cd6297aFrank Schaefer u8 button_polling_last_values[EM28XX_NUM_BUTTON_ADDRESSES_MAX]; 713f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer u8 num_button_polling_addresses; 7140ff950a73dcd25b8d435043440c11901ac91654cFrank Schaefer u16 button_polling_interval; /* [ms] */ 715f522260993822d82e2c480aa676aa4ca1230d235Frank Schaefer /* Snapshot button input device */ 716a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller char snapshot_button_path[30]; /* path of the input dev */ 717a9fc52bcbeb5245b58d23c558f3e3e8f18bebbc3Devin Heitmueller struct input_dev *sbutton_input_dev; 718a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton}; 719a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 72047677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehab#define kref_to_dev(d) container_of(d, struct em28xx, ref) 72147677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehab 7226d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabstruct em28xx_ops { 7236d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab struct list_head next; 7246d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab char *name; 7256d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab int id; 7266d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab int (*init)(struct em28xx *); 7276d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehab int (*fini)(struct em28xx *); 7289c669b731470154a1f7b0ad1c3231cf02114c163Shuah Khan int (*suspend)(struct em28xx *); 7299c669b731470154a1f7b0ad1c3231cf02114c163Shuah Khan int (*resume)(struct em28xx *); 730a3a048cea301baba5d451991074a85dc20a8f228Mauro Carvalho Chehab}; 731a3a048cea301baba5d451991074a85dc20a8f228Mauro Carvalho Chehab 7323acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-i2c.c */ 733aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehabvoid em28xx_do_i2c_scan(struct em28xx *dev, unsigned bus); 734a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaeferint em28xx_i2c_register(struct em28xx *dev, unsigned bus, 735a3ea4bf98bc8499e64b619808fcca09ca3eb4e2fFrank Schaefer enum em28xx_i2c_algo_type algo_type); 736aab3125c43d8fecc7134e5f1e729fabf4dd196daMauro Carvalho Chehabint em28xx_i2c_unregister(struct em28xx *dev, unsigned bus); 737a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 7383acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-core.c */ 7393acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg_req_len(struct em28xx *dev, u8 req, u16 reg, 740a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton char *buf, int len); 7413acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg_req(struct em28xx *dev, u8 req, u16 reg); 7423acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_read_reg(struct em28xx *dev, u16 reg); 7433acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_write_regs_req(struct em28xx *dev, u8 req, u16 reg, char *buf, 744a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton int len); 7453acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_write_regs(struct em28xx *dev, u16 reg, char *buf, int len); 746b69724899440289ab258ff417c2d6aa104c70310Devin Heitmuellerint em28xx_write_reg(struct em28xx *dev, u16 reg, u8 val); 7471bad429e81f9a9ffa01c4158e6d1b1a3e06d9886Mauro Carvalho Chehabint em28xx_write_reg_bits(struct em28xx *dev, u16 reg, u8 val, 7481bad429e81f9a9ffa01c4158e6d1b1a3e06d9886Mauro Carvalho Chehab u8 bitmask); 7496063d07785b7059d276cb1a39c76186804f5938eFrank Schaeferint em28xx_toggle_reg_bits(struct em28xx *dev, u16 reg, u8 bitmask); 750b69724899440289ab258ff417c2d6aa104c70310Devin Heitmueller 751531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehabint em28xx_read_ac97(struct em28xx *dev, u8 reg); 752531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehabint em28xx_write_ac97(struct em28xx *dev, u8 reg, u16 val); 753531c98e71805b32e9ea35a218119100bbd2b7615Mauro Carvalho Chehab 7543acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_audio_analog_set(struct em28xx *dev); 75535643943be58aef82826e340761e86e0d37870ecMauro Carvalho Chehabint em28xx_audio_setup(struct em28xx *dev); 756539c96d0fd86bfdcfac75c88b74aa5798439293dMauro Carvalho Chehab 7576b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaeferconst struct em28xx_led *em28xx_find_led(struct em28xx *dev, 7586b8a3170c9984be58e50e23c78e2eb7833f33c4cFrank Schaefer enum em28xx_led_role role); 7593acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabint em28xx_capture_start(struct em28xx *dev, int start); 7606ddd89d0c90ec384d5a8058cb38679beb03c7eb7Frank Schaeferint em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, 7616ddd89d0c90ec384d5a8058cb38679beb03c7eb7Frank Schaefer int num_bufs, int max_pkt_size, int packet_multiplier); 762057ca0da067c8c0c734088eba229ab06e21bc88cFrank Schaeferint em28xx_init_usb_xfer(struct em28xx *dev, enum em28xx_mode mode, 763057ca0da067c8c0c734088eba229ab06e21bc88cFrank Schaefer int xfer_bulk, 764057ca0da067c8c0c734088eba229ab06e21bc88cFrank Schaefer int num_bufs, int max_pkt_size, int packet_multiplier, 765057ca0da067c8c0c734088eba229ab06e21bc88cFrank Schaefer int (*urb_data_copy) 766057ca0da067c8c0c734088eba229ab06e21bc88cFrank Schaefer (struct em28xx *dev, struct urb *urb)); 767afb177e06563861bfe4d7795a9d4d3b52851813bFrank Schaefervoid em28xx_uninit_usb_xfer(struct em28xx *dev, enum em28xx_mode mode); 7685f5f147f638734c0739b663aa68a3ae03cdc682bGianluca Gennarivoid em28xx_stop_urbs(struct em28xx *dev); 769c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehabint em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); 770c67ec53f8f4e90ebd482789e2f6d121f41a0bd90Mauro Carvalho Chehabint em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio); 7716d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabint em28xx_register_extension(struct em28xx_ops *dev); 7726d79468dd8537530f4150e76ed9b4b63f80571c6Mauro Carvalho Chehabvoid em28xx_unregister_extension(struct em28xx_ops *dev); 7731a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_init_extension(struct em28xx *dev); 7741a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehabvoid em28xx_close_extension(struct em28xx *dev); 7759c669b731470154a1f7b0ad1c3231cf02114c163Shuah Khanint em28xx_suspend_extension(struct em28xx *dev); 7769c669b731470154a1f7b0ad1c3231cf02114c163Shuah Khanint em28xx_resume_extension(struct em28xx *dev); 7771a23f81b7dc3115b29cff0e4f58b5dd04a6242adMauro Carvalho Chehab 7783acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab/* Provided by em28xx-cards.c */ 7793acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern struct em28xx_board em28xx_boards[]; 7803acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehabextern struct usb_device_id em28xx_id_table[]; 781d7cba043d7ec840d67bd5143779d1febe7d83407Michael Krufkyint em28xx_tuner_callback(void *ptr, int component, int command, int arg); 782ee97207c6e7e9a75f49e2abb7ecf944d319ed969Mauro Carvalho Chehabvoid em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl); 78347677e51e2a4040c204d7971a5103592600185b1Mauro Carvalho Chehabvoid em28xx_free_device(struct kref *ref); 784c8793b035df7b18997d1cf34254064dac166f009Mauro Carvalho Chehab 785855ff38e880f57814ea5c0cbea853da11fcdf42fFrank Schaefer/* Provided by em28xx-camera.c */ 786855ff38e880f57814ea5c0cbea853da11fcdf42fFrank Schaeferint em28xx_detect_sensor(struct em28xx *dev); 787855ff38e880f57814ea5c0cbea853da11fcdf42fFrank Schaeferint em28xx_init_camera(struct em28xx *dev); 788855ff38e880f57814ea5c0cbea853da11fcdf42fFrank Schaefer 789a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton/* printk macros */ 790a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 7913acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_err(fmt, arg...) do {\ 792f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare printk(KERN_ERR fmt , ##arg); } while (0) 793a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 7943acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_errdev(fmt, arg...) do {\ 7954ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab printk(KERN_ERR "%s: "fmt,\ 796f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare dev->name , ##arg); } while (0) 797a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 7983acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_info(fmt, arg...) do {\ 7994ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab printk(KERN_INFO "%s: "fmt,\ 800f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare dev->name , ##arg); } while (0) 8013acf28095009509c9ca1e283de821b5be9ddede6Mauro Carvalho Chehab#define em28xx_warn(fmt, arg...) do {\ 8024ac97914c6c35f6bf132071c718e034d0846b9f5Mauro Carvalho Chehab printk(KERN_WARNING "%s: "fmt,\ 803f85c657ff1f712abd5207a95fba8a5fcc282ab04Jean Delvare dev->name , ##arg); } while (0) 804a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton 805a6c2ba283565dbc9f055dcb2ecba1971460bb535Andrew Morton#endif 806