linux/drivers/media/usb/em28xx/em28xx-cards.c
<<
>>
Prefs
   1/*
   2   em28xx-cards.c - driver for Empia EM2800/EM2820/2840 USB
   3                    video capture devices
   4
   5   Copyright (C) 2005 Ludovico Cavedon <cavedon@sssup.it>
   6                      Markus Rechberger <mrechberger@gmail.com>
   7                      Mauro Carvalho Chehab <mchehab@infradead.org>
   8                      Sascha Sommer <saschasommer@freenet.de>
   9   Copyright (C) 2012 Frank Schäfer <fschaefer.oss@googlemail.com>
  10
  11   This program is free software; you can redistribute it and/or modify
  12   it under the terms of the GNU General Public License as published by
  13   the Free Software Foundation; either version 2 of the License, or
  14   (at your option) any later version.
  15
  16   This program is distributed in the hope that it will be useful,
  17   but WITHOUT ANY WARRANTY; without even the implied warranty of
  18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19   GNU General Public License for more details.
  20
  21   You should have received a copy of the GNU General Public License
  22   along with this program; if not, write to the Free Software
  23   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24 */
  25
  26#include "em28xx.h"
  27
  28#include <linux/init.h>
  29#include <linux/module.h>
  30#include <linux/slab.h>
  31#include <linux/delay.h>
  32#include <linux/i2c.h>
  33#include <linux/usb.h>
  34#include <media/tuner.h>
  35#include <media/drv-intf/msp3400.h>
  36#include <media/i2c/saa7115.h>
  37#include <dt-bindings/media/tvp5150.h>
  38#include <media/i2c/tvaudio.h>
  39#include <media/i2c-addr.h>
  40#include <media/tveeprom.h>
  41#include <media/v4l2-common.h>
  42#include <sound/ac97_codec.h>
  43
  44
  45#define DRIVER_NAME         "em28xx"
  46
  47static int tuner = -1;
  48module_param(tuner, int, 0444);
  49MODULE_PARM_DESC(tuner, "tuner type");
  50
  51static unsigned int disable_ir;
  52module_param(disable_ir, int, 0444);
  53MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
  54
  55static unsigned int disable_usb_speed_check;
  56module_param(disable_usb_speed_check, int, 0444);
  57MODULE_PARM_DESC(disable_usb_speed_check,
  58                 "override min bandwidth requirement of 480M bps");
  59
  60static unsigned int card[]     = {[0 ... (EM28XX_MAXBOARDS - 1)] = -1U };
  61module_param_array(card,  int, NULL, 0444);
  62MODULE_PARM_DESC(card,     "card type");
  63
  64static int usb_xfer_mode = -1;
  65module_param(usb_xfer_mode, int, 0444);
  66MODULE_PARM_DESC(usb_xfer_mode,
  67                 "USB transfer mode for frame data (-1 = auto, 0 = prefer isoc, 1 = prefer bulk)");
  68
  69/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS - 1 */
  70static DECLARE_BITMAP(em28xx_devused, EM28XX_MAXBOARDS);
  71
  72struct em28xx_hash_table {
  73        unsigned long hash;
  74        unsigned int  model;
  75        unsigned int  tuner;
  76};
  77
  78static void em28xx_pre_card_setup(struct em28xx *dev);
  79
  80/*
  81 *  Reset sequences for analog/digital modes
  82 */
  83
  84/* Reset for the most [analog] boards */
  85static struct em28xx_reg_seq default_analog[] = {
  86        {EM2820_R08_GPIO_CTRL,  0x6d,   ~EM_GPIO_4,     10},
  87        {       -1,             -1,     -1,             -1},
  88};
  89
  90/* Reset for the most [digital] boards */
  91static struct em28xx_reg_seq default_digital[] = {
  92        {EM2820_R08_GPIO_CTRL,  0x6e,   ~EM_GPIO_4,     10},
  93        {       -1,             -1,     -1,             -1},
  94};
  95
  96/* Board Hauppauge WinTV HVR 900 analog */
  97static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
  98        {EM2820_R08_GPIO_CTRL,  0x2d,   ~EM_GPIO_4,     10},
  99        {       0x05,           0xff,   0x10,           10},
 100        {       -1,             -1,     -1,             -1},
 101};
 102
 103/* Board Hauppauge WinTV HVR 900 digital */
 104static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
 105        {EM2820_R08_GPIO_CTRL,  0x2e,   ~EM_GPIO_4,     10},
 106        {EM2880_R04_GPO,        0x04,   0x0f,           10},
 107        {EM2880_R04_GPO,        0x0c,   0x0f,           10},
 108        {       -1,             -1,     -1,             -1},
 109};
 110
 111/* Board Hauppauge WinTV HVR 900 (R2) digital */
 112static struct em28xx_reg_seq hauppauge_wintv_hvr_900R2_digital[] = {
 113        {EM2820_R08_GPIO_CTRL,  0x2e,   ~EM_GPIO_4,     10},
 114        {EM2880_R04_GPO,        0x0c,   0x0f,           10},
 115        {       -1,             -1,     -1,             -1},
 116};
 117
 118/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
 119static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
 120        {EM2820_R08_GPIO_CTRL,  0x69,   ~EM_GPIO_4,     10},
 121        {       -1,             -1,     -1,             -1},
 122};
 123
 124/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
 125
 126/* Board  - EM2870 Kworld 355u
 127   Analog - No input analog */
 128
 129/* Board - EM2882 Kworld 315U digital */
 130static struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
 131        {EM2820_R08_GPIO_CTRL,  0xff,   0xff,           10},
 132        {EM2820_R08_GPIO_CTRL,  0xfe,   0xff,           10},
 133        {EM2880_R04_GPO,        0x04,   0xff,           10},
 134        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 135        {EM2820_R08_GPIO_CTRL,  0x7e,   0xff,           10},
 136        {       -1,             -1,     -1,             -1},
 137};
 138
 139static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
 140        {EM2880_R04_GPO,        0x08,   0xff,           10},
 141        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 142        {EM2880_R04_GPO,        0x08,   0xff,           10},
 143        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 144        {       -1,             -1,     -1,             -1},
 145};
 146
 147static struct em28xx_reg_seq kworld_330u_analog[] = {
 148        {EM2820_R08_GPIO_CTRL,  0x6d,   ~EM_GPIO_4,     10},
 149        {EM2880_R04_GPO,        0x00,   0xff,           10},
 150        {       -1,             -1,     -1,             -1},
 151};
 152
 153static struct em28xx_reg_seq kworld_330u_digital[] = {
 154        {EM2820_R08_GPIO_CTRL,  0x6e,   ~EM_GPIO_4,     10},
 155        {EM2880_R04_GPO,        0x08,   0xff,           10},
 156        {       -1,             -1,     -1,             -1},
 157};
 158
 159/* Evga inDtube
 160   GPIO0 - Enable digital power (s5h1409) - low to enable
 161   GPIO1 - Enable analog power (tvp5150/emp202) - low to enable
 162   GPIO4 - xc3028 reset
 163   GOP3  - s5h1409 reset
 164 */
 165static struct em28xx_reg_seq evga_indtube_analog[] = {
 166        {EM2820_R08_GPIO_CTRL,  0x79,   0xff,           60},
 167        {       -1,             -1,     -1,             -1},
 168};
 169
 170static struct em28xx_reg_seq evga_indtube_digital[] = {
 171        {EM2820_R08_GPIO_CTRL,  0x7a,   0xff,            1},
 172        {EM2880_R04_GPO,        0x04,   0xff,           10},
 173        {EM2880_R04_GPO,        0x0c,   0xff,            1},
 174        {       -1,             -1,     -1,             -1},
 175};
 176
 177/*
 178 * KWorld PlusTV 340U, UB435-Q and UB435-Q V2 (ATSC) GPIOs map:
 179 * EM_GPIO_0 - currently unknown
 180 * EM_GPIO_1 - LED disable/enable (1 = off, 0 = on)
 181 * EM_GPIO_2 - currently unknown
 182 * EM_GPIO_3 - currently unknown
 183 * EM_GPIO_4 - TDA18271HD/C1 tuner (1 = active, 0 = in reset)
 184 * EM_GPIO_5 - LGDT3304 ATSC/QAM demod (1 = active, 0 = in reset)
 185 * EM_GPIO_6 - currently unknown
 186 * EM_GPIO_7 - currently unknown
 187 */
 188static struct em28xx_reg_seq kworld_a340_digital[] = {
 189        {EM2820_R08_GPIO_CTRL,  0x6d,   ~EM_GPIO_4,     10},
 190        {       -1,             -1,     -1,             -1},
 191};
 192
 193static struct em28xx_reg_seq kworld_ub435q_v3_digital[] = {
 194        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xff,   100},
 195        {EM2874_R80_GPIO_P0_CTRL,       0xfe,   0xff,   100},
 196        {EM2874_R80_GPIO_P0_CTRL,       0xbe,   0xff,   100},
 197        {EM2874_R80_GPIO_P0_CTRL,       0xfe,   0xff,   100},
 198        {       -1,                     -1,     -1,     -1},
 199};
 200
 201/* Pinnacle Hybrid Pro eb1a:2881 */
 202static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
 203        {EM2820_R08_GPIO_CTRL,  0xfd,   ~EM_GPIO_4,     10},
 204        {       -1,             -1,     -1,             -1},
 205};
 206
 207static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
 208        {EM2820_R08_GPIO_CTRL,  0x6e,   ~EM_GPIO_4,     10},
 209        {EM2880_R04_GPO,        0x04,   0xff,          100},/* zl10353 reset */
 210        {EM2880_R04_GPO,        0x0c,   0xff,            1},
 211        {       -1,             -1,     -1,             -1},
 212};
 213
 214static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_analog[] = {
 215        {EM2820_R08_GPIO_CTRL,  0x6d,   ~EM_GPIO_4,     10},
 216        {EM2880_R04_GPO,        0x00,   0xff,           10},
 217        {       -1,             -1,     -1,             -1},
 218};
 219
 220static struct em28xx_reg_seq terratec_cinergy_USB_XS_FR_digital[] = {
 221        {EM2820_R08_GPIO_CTRL,  0x6e,   ~EM_GPIO_4,     10},
 222        {EM2880_R04_GPO,        0x08,   0xff,           10},
 223        {       -1,             -1,     -1,             -1},
 224};
 225
 226/* PCTV HD Mini (80e) GPIOs
 227   0-5: not used
 228   6:   demod reset, active low
 229   7:   LED on, active high */
 230static struct em28xx_reg_seq em2874_pctv_80e_digital[] = {
 231        {EM28XX_R06_I2C_CLK,    0x45,   0xff,             10}, /*400 KHz*/
 232        {EM2874_R80_GPIO_P0_CTRL, 0x00,   0xff,           100},/*Demod reset*/
 233        {EM2874_R80_GPIO_P0_CTRL, 0x40,   0xff,           10},
 234        {  -1,                  -1,     -1,               -1},
 235};
 236
 237/* eb1a:2868 Reddo DVB-C USB TV Box
 238   GPIO4 - CU1216L NIM
 239   Other GPIOs seems to be don't care. */
 240static struct em28xx_reg_seq reddo_dvb_c_usb_box[] = {
 241        {EM2820_R08_GPIO_CTRL,  0xfe,   0xff,           10},
 242        {EM2820_R08_GPIO_CTRL,  0xde,   0xff,           10},
 243        {EM2820_R08_GPIO_CTRL,  0xfe,   0xff,           10},
 244        {EM2820_R08_GPIO_CTRL,  0xff,   0xff,           10},
 245        {EM2820_R08_GPIO_CTRL,  0x7f,   0xff,           10},
 246        {EM2820_R08_GPIO_CTRL,  0x6f,   0xff,           10},
 247        {EM2820_R08_GPIO_CTRL,  0xff,   0xff,           10},
 248        {       -1,             -1,     -1,             -1},
 249};
 250
 251/* Callback for the most boards */
 252static struct em28xx_reg_seq default_tuner_gpio[] = {
 253        {EM2820_R08_GPIO_CTRL,  EM_GPIO_4,      EM_GPIO_4,      10},
 254        {EM2820_R08_GPIO_CTRL,  0,              EM_GPIO_4,      10},
 255        {EM2820_R08_GPIO_CTRL,  EM_GPIO_4,      EM_GPIO_4,      10},
 256        {       -1,             -1,             -1,             -1},
 257};
 258
 259/* Mute/unmute */
 260static struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
 261        {EM2820_R08_GPIO_CTRL,  5,      7,      10},
 262        {       -1,             -1,     -1,     -1},
 263};
 264
 265static struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
 266        {EM2820_R08_GPIO_CTRL,  4,      7,      10},
 267        {       -1,             -1,     -1,     -1},
 268};
 269
 270static struct em28xx_reg_seq compro_mute_gpio[] = {
 271        {EM2820_R08_GPIO_CTRL,  6,      7,      10},
 272        {       -1,             -1,     -1,     -1},
 273};
 274
 275/* Terratec AV350 */
 276static struct em28xx_reg_seq terratec_av350_mute_gpio[] = {
 277        {EM2820_R08_GPIO_CTRL,  0xff,   0x7f,           10},
 278        {       -1,             -1,     -1,             -1},
 279};
 280
 281static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
 282        {EM2820_R08_GPIO_CTRL,  0xff,   0xff,           10},
 283        {       -1,             -1,     -1,             -1},
 284};
 285
 286static struct em28xx_reg_seq silvercrest_reg_seq[] = {
 287        {EM2820_R08_GPIO_CTRL,  0xff,   0xff,           10},
 288        {EM2820_R08_GPIO_CTRL,  0x01,   0xf7,           10},
 289        {       -1,             -1,     -1,             -1},
 290};
 291
 292static struct em28xx_reg_seq vc211a_enable[] = {
 293        {EM2820_R08_GPIO_CTRL,  0xff,   0x07,           10},
 294        {EM2820_R08_GPIO_CTRL,  0xff,   0x0f,           10},
 295        {EM2820_R08_GPIO_CTRL,  0xff,   0x0b,           10},
 296        {       -1,             -1,     -1,             -1},
 297};
 298
 299static struct em28xx_reg_seq dikom_dk300_digital[] = {
 300        {EM2820_R08_GPIO_CTRL,  0x6e,   ~EM_GPIO_4,     10},
 301        {EM2880_R04_GPO,        0x08,   0xff,           10},
 302        {       -1,             -1,     -1,             -1},
 303};
 304
 305/* Reset for the most [digital] boards */
 306static struct em28xx_reg_seq leadership_digital[] = {
 307        {EM2874_R80_GPIO_P0_CTRL,       0x70,   0xff,   10},
 308        {       -1,                     -1,     -1,     -1},
 309};
 310
 311static struct em28xx_reg_seq leadership_reset[] = {
 312        {EM2874_R80_GPIO_P0_CTRL,       0xf0,   0xff,   10},
 313        {EM2874_R80_GPIO_P0_CTRL,       0xb0,   0xff,   10},
 314        {EM2874_R80_GPIO_P0_CTRL,       0xf0,   0xff,   10},
 315        {       -1,                     -1,     -1,     -1},
 316};
 317
 318/* 2013:024f PCTV nanoStick T2 290e
 319 * GPIO_6 - demod reset
 320 * GPIO_7 - LED
 321 */
 322static struct em28xx_reg_seq pctv_290e[] = {
 323        {EM2874_R80_GPIO_P0_CTRL,       0x00,   0xff,   80},
 324        {EM2874_R80_GPIO_P0_CTRL,       0x40,   0xff,   80}, /* GPIO_6 = 1 */
 325        {EM2874_R80_GPIO_P0_CTRL,       0xc0,   0xff,   80}, /* GPIO_7 = 1 */
 326        {       -1,                     -1,     -1,     -1},
 327};
 328
 329#if 0
 330static struct em28xx_reg_seq terratec_h5_gpio[] = {
 331        {EM2820_R08_GPIO_CTRL,          0xff,   0xff,   10},
 332        {EM2874_R80_GPIO_P0_CTRL,       0xf6,   0xff,   100},
 333        {EM2874_R80_GPIO_P0_CTRL,       0xf2,   0xff,   50},
 334        {EM2874_R80_GPIO_P0_CTRL,       0xf6,   0xff,   50},
 335        {       -1,                     -1,     -1,     -1},
 336};
 337
 338static struct em28xx_reg_seq terratec_h5_digital[] = {
 339        {EM2874_R80_GPIO_P0_CTRL,       0xf6,   0xff,   10},
 340        {EM2874_R80_GPIO_P0_CTRL,       0xe6,   0xff,   100},
 341        {EM2874_R80_GPIO_P0_CTRL,       0xa6,   0xff,   10},
 342        {       -1,                     -1,     -1,     -1},
 343};
 344#endif
 345
 346/* 2013:024f PCTV DVB-S2 Stick 460e
 347 * GPIO_0 - POWER_ON
 348 * GPIO_1 - BOOST
 349 * GPIO_2 - VUV_LNB (red LED)
 350 * GPIO_3 - EXT_12V
 351 * GPIO_4 - INT_DEM (DEMOD GPIO_0)
 352 * GPIO_5 - INT_LNB
 353 * GPIO_6 - RESET_DEM
 354 * GPIO_7 - LED (green LED)
 355 */
 356static struct em28xx_reg_seq pctv_460e[] = {
 357        {EM2874_R80_GPIO_P0_CTRL,       0x01,   0xff,   50},
 358        {       0x0d,                   0xff,   0xff,   50},
 359        {EM2874_R80_GPIO_P0_CTRL,       0x41,   0xff,   50}, /* GPIO_6=1 */
 360        {       0x0d,                   0x42,   0xff,   50},
 361        {EM2874_R80_GPIO_P0_CTRL,       0x61,   0xff,   50}, /* GPIO_5=1 */
 362        {       -1,                     -1,     -1,     -1},
 363};
 364
 365static struct em28xx_reg_seq c3tech_digital_duo_digital[] = {
 366        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xff,   10},
 367        {EM2874_R80_GPIO_P0_CTRL,       0xfd,   0xff,   10}, /* xc5000 reset */
 368        {EM2874_R80_GPIO_P0_CTRL,       0xf9,   0xff,   35},
 369        {EM2874_R80_GPIO_P0_CTRL,       0xfd,   0xff,   10},
 370        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xff,   10},
 371        {EM2874_R80_GPIO_P0_CTRL,       0xfe,   0xff,   10},
 372        {EM2874_R80_GPIO_P0_CTRL,       0xbe,   0xff,   10},
 373        {EM2874_R80_GPIO_P0_CTRL,       0xfe,   0xff,   20},
 374        {       -1,                     -1,     -1,     -1},
 375};
 376
 377/*
 378 * 2013:0258 PCTV DVB-S2 Stick (461e)
 379 * GPIO 0 = POWER_ON
 380 * GPIO 1 = BOOST
 381 * GPIO 2 = VUV_LNB (red LED)
 382 * GPIO 3 = #EXT_12V
 383 * GPIO 4 = INT_DEM
 384 * GPIO 5 = INT_LNB
 385 * GPIO 6 = #RESET_DEM
 386 * GPIO 7 = P07_LED (green LED)
 387 */
 388static struct em28xx_reg_seq pctv_461e[] = {
 389        {EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,    0},
 390        {0x0d,                 0xff, 0xff,    0},
 391        {EM2874_R80_GPIO_P0_CTRL,      0x3f, 0xff,  100}, /* reset demod */
 392        {EM2874_R80_GPIO_P0_CTRL,      0x7f, 0xff,  200}, /* reset demod */
 393        {0x0d,                 0x42, 0xff,    0},
 394        {EM2874_R80_GPIO_P0_CTRL,      0xeb, 0xff,    0},
 395        {EM2874_R5F_TS_ENABLE, 0x84, 0x84,    0}, /* parallel? | null discard */
 396        {                  -1,   -1,   -1,   -1},
 397};
 398
 399#if 0
 400static struct em28xx_reg_seq hauppauge_930c_gpio[] = {
 401        {EM2874_R80_GPIO_P0_CTRL,       0x6f,   0xff,   10},
 402        {EM2874_R80_GPIO_P0_CTRL,       0x4f,   0xff,   10}, /* xc5000 reset */
 403        {EM2874_R80_GPIO_P0_CTRL,       0x6f,   0xff,   10},
 404        {EM2874_R80_GPIO_P0_CTRL,       0x4f,   0xff,   10},
 405        {       -1,                     -1,     -1,     -1},
 406};
 407
 408static struct em28xx_reg_seq hauppauge_930c_digital[] = {
 409        {EM2874_R80_GPIO_P0_CTRL,       0xf6,   0xff,   10},
 410        {EM2874_R80_GPIO_P0_CTRL,       0xe6,   0xff,   100},
 411        {EM2874_R80_GPIO_P0_CTRL,       0xa6,   0xff,   10},
 412        {       -1,                     -1,     -1,     -1},
 413};
 414#endif
 415
 416/* 1b80:e425 MaxMedia UB425-TC
 417 * 1b80:e1cc Delock 61959
 418 * GPIO_6 - demod reset, 0=active
 419 * GPIO_7 - LED, 0=active
 420 */
 421static struct em28xx_reg_seq maxmedia_ub425_tc[] = {
 422        {EM2874_R80_GPIO_P0_CTRL,       0x83,   0xff,   100},
 423        {EM2874_R80_GPIO_P0_CTRL,       0xc3,   0xff,   100}, /* GPIO_6 = 1 */
 424        {EM2874_R80_GPIO_P0_CTRL,       0x43,   0xff,   000}, /* GPIO_7 = 0 */
 425        {       -1,                     -1,     -1,     -1},
 426};
 427
 428/* 2304:0242 PCTV QuatroStick (510e)
 429 * GPIO_2: decoder reset, 0=active
 430 * GPIO_4: decoder suspend, 0=active
 431 * GPIO_6: demod reset, 0=active
 432 * GPIO_7: LED, 1=active
 433 */
 434static struct em28xx_reg_seq pctv_510e[] = {
 435        {EM2874_R80_GPIO_P0_CTRL,       0x10,   0xff,   100},
 436        {EM2874_R80_GPIO_P0_CTRL,       0x14,   0xff,   100}, /* GPIO_2 = 1 */
 437        {EM2874_R80_GPIO_P0_CTRL,       0x54,   0xff,   050}, /* GPIO_6 = 1 */
 438        {       -1,                     -1,     -1,     -1},
 439};
 440
 441/* 2013:0251 PCTV QuatroStick nano (520e)
 442 * GPIO_2: decoder reset, 0=active
 443 * GPIO_4: decoder suspend, 0=active
 444 * GPIO_6: demod reset, 0=active
 445 * GPIO_7: LED, 1=active
 446 */
 447static struct em28xx_reg_seq pctv_520e[] = {
 448        {EM2874_R80_GPIO_P0_CTRL,       0x10,   0xff,   100},
 449        {EM2874_R80_GPIO_P0_CTRL,       0x14,   0xff,   100}, /* GPIO_2 = 1 */
 450        {EM2874_R80_GPIO_P0_CTRL,       0x54,   0xff,   050}, /* GPIO_6 = 1 */
 451        {EM2874_R80_GPIO_P0_CTRL,       0xd4,   0xff,   000}, /* GPIO_7 = 1 */
 452        {       -1,                     -1,     -1,     -1},
 453};
 454
 455/* 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
 456 * reg 0x80/0x84:
 457 * GPIO_0: capturing LED, 0=on, 1=off
 458 * GPIO_2: AV mute button, 0=pressed, 1=unpressed
 459 * GPIO 3: illumination button, 0=pressed, 1=unpressed
 460 * GPIO_6: illumination/flash LED, 0=on, 1=off
 461 * reg 0x81/0x85:
 462 * GPIO_7: snapshot button, 0=pressed, 1=unpressed
 463 */
 464static struct em28xx_reg_seq speedlink_vad_laplace_reg_seq[] = {
 465        {EM2820_R08_GPIO_CTRL,          0xf7,   0xff,   10},
 466        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xb2,   10},
 467        {       -1,                     -1,     -1,     -1},
 468};
 469
 470static struct em28xx_reg_seq pctv_292e[] = {
 471        {EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
 472        {0x0d,                         0xff, 0xff,    950},
 473        {EM2874_R80_GPIO_P0_CTRL,      0xbd, 0xff,    100},
 474        {EM2874_R80_GPIO_P0_CTRL,      0xfd, 0xff,    410},
 475        {EM2874_R80_GPIO_P0_CTRL,      0x7d, 0xff,    300},
 476        {EM2874_R80_GPIO_P0_CTRL,      0x7c, 0xff,     60},
 477        {0x0d,                         0x42, 0xff,     50},
 478        {EM2874_R5F_TS_ENABLE,         0x85, 0xff,      0},
 479        {-1,                             -1,   -1,     -1},
 480};
 481
 482static struct em28xx_reg_seq terratec_t2_stick_hd[] = {
 483        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xff,   0},
 484        {0x0d,                          0xff,   0xff,   600},
 485        {EM2874_R80_GPIO_P0_CTRL,       0xfc,   0xff,   10},
 486        {EM2874_R80_GPIO_P0_CTRL,       0xbc,   0xff,   100},
 487        {EM2874_R80_GPIO_P0_CTRL,       0xfc,   0xff,   100},
 488        {EM2874_R80_GPIO_P0_CTRL,       0x00,   0xff,   300},
 489        {EM2874_R80_GPIO_P0_CTRL,       0xf8,   0xff,   100},
 490        {EM2874_R80_GPIO_P0_CTRL,       0xfc,   0xff,   300},
 491        {0x0d,                          0x42,   0xff,   1000},
 492        {EM2874_R5F_TS_ENABLE,          0x85,   0xff,   0},
 493        {-1,                             -1,   -1,     -1},
 494};
 495
 496static struct em28xx_reg_seq plex_px_bcud[] = {
 497        {EM2874_R80_GPIO_P0_CTRL,       0xff,   0xff,   0},
 498        {0x0d,                          0xff,   0xff,   0},
 499        {EM2874_R50_IR_CONFIG,          0x01,   0xff,   0},
 500        {EM28XX_R06_I2C_CLK,            0x40,   0xff,   0},
 501        {EM2874_R80_GPIO_P0_CTRL,       0xfd,   0xff,   100},
 502        {EM28XX_R12_VINENABLE,          0x20,   0x20,   0},
 503        {0x0d,                          0x42,   0xff,   1000},
 504        {EM2874_R80_GPIO_P0_CTRL,       0xfc,   0xff,   10},
 505        {EM2874_R80_GPIO_P0_CTRL,       0xfd,   0xff,   10},
 506        {0x73,                          0xfd,   0xff,   100},
 507        {-1,                            -1,     -1,     -1},
 508};
 509
 510/*
 511 * 2040:0265 Hauppauge WinTV-dualHD DVB
 512 * 2040:026d Hauppauge WinTV-dualHD ATSC/QAM
 513 * reg 0x80/0x84:
 514 * GPIO_0: Yellow LED tuner 1, 0=on, 1=off
 515 * GPIO_1: Green LED tuner 1, 0=on, 1=off
 516 * GPIO_2: Yellow LED tuner 2, 0=on, 1=off
 517 * GPIO_3: Green LED tuner 2, 0=on, 1=off
 518 * GPIO_5: Reset #2, 0=active
 519 * GPIO_6: Reset #1, 0=active
 520 */
 521static struct em28xx_reg_seq hauppauge_dualhd_dvb[] = {
 522        {EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,      0},
 523        {0x0d,                         0xff, 0xff,    200},
 524        {0x50,                         0x04, 0xff,    300},
 525        {EM2874_R80_GPIO_P0_CTRL,      0xbf, 0xff,    100}, /* demod 1 reset */
 526        {EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
 527        {EM2874_R80_GPIO_P0_CTRL,      0xdf, 0xff,    100}, /* demod 2 reset */
 528        {EM2874_R80_GPIO_P0_CTRL,      0xff, 0xff,    100},
 529        {EM2874_R5F_TS_ENABLE,         0x44, 0xff,     50},
 530        {EM2874_R5D_TS1_PKT_SIZE,      0x05, 0xff,     50},
 531        {EM2874_R5E_TS2_PKT_SIZE,      0x05, 0xff,     50},
 532        {-1,                             -1,   -1,     -1},
 533};
 534
 535/*
 536 *  Button definitions
 537 */
 538static struct em28xx_button std_snapshot_button[] = {
 539        {
 540                .role         = EM28XX_BUTTON_SNAPSHOT,
 541                .reg_r        = EM28XX_R0C_USBSUSP,
 542                .reg_clearing = EM28XX_R0C_USBSUSP,
 543                .mask         = EM28XX_R0C_USBSUSP_SNAPSHOT,
 544                .inverted     = 0,
 545        },
 546        {-1, 0, 0, 0, 0},
 547};
 548
 549static struct em28xx_button speedlink_vad_laplace_buttons[] = {
 550        {
 551                .role     = EM28XX_BUTTON_SNAPSHOT,
 552                .reg_r    = EM2874_R85_GPIO_P1_STATE,
 553                .mask     = 0x80,
 554                .inverted = 1,
 555        },
 556        {
 557                .role     = EM28XX_BUTTON_ILLUMINATION,
 558                .reg_r    = EM2874_R84_GPIO_P0_STATE,
 559                .mask     = 0x08,
 560                .inverted = 1,
 561        },
 562        {-1, 0, 0, 0, 0},
 563};
 564
 565/*
 566 *  LED definitions
 567 */
 568static struct em28xx_led speedlink_vad_laplace_leds[] = {
 569        {
 570                .role      = EM28XX_LED_ANALOG_CAPTURING,
 571                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 572                .gpio_mask = 0x01,
 573                .inverted  = 1,
 574        },
 575        {
 576                .role      = EM28XX_LED_ILLUMINATION,
 577                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 578                .gpio_mask = 0x40,
 579                .inverted  = 1,
 580        },
 581        {-1, 0, 0, 0},
 582};
 583
 584static struct em28xx_led kworld_ub435q_v3_leds[] = {
 585        {
 586                .role      = EM28XX_LED_DIGITAL_CAPTURING,
 587                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 588                .gpio_mask = 0x80,
 589                .inverted  = 1,
 590        },
 591        {-1, 0, 0, 0},
 592};
 593
 594static struct em28xx_led pctv_80e_leds[] = {
 595        {
 596                .role      = EM28XX_LED_DIGITAL_CAPTURING,
 597                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 598                .gpio_mask = 0x80,
 599                .inverted  = 0,
 600        },
 601        {-1, 0, 0, 0},
 602};
 603
 604static struct em28xx_led terratec_grabby_leds[] = {
 605        {
 606                .role      = EM28XX_LED_ANALOG_CAPTURING,
 607                .gpio_reg  = EM2820_R08_GPIO_CTRL,
 608                .gpio_mask = EM_GPIO_3,
 609                .inverted  = 1,
 610        },
 611        {-1, 0, 0, 0},
 612};
 613
 614static struct em28xx_led hauppauge_dualhd_leds[] = {
 615        {
 616                .role      = EM28XX_LED_DIGITAL_CAPTURING,
 617                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 618                .gpio_mask = EM_GPIO_1,
 619                .inverted  = 1,
 620        },
 621        {
 622                .role      = EM28XX_LED_DIGITAL_CAPTURING_TS2,
 623                .gpio_reg  = EM2874_R80_GPIO_P0_CTRL,
 624                .gpio_mask = EM_GPIO_3,
 625                .inverted  = 1,
 626        },
 627        {-1, 0, 0, 0},
 628};
 629
 630/*
 631 *  Board definitions
 632 */
 633struct em28xx_board em28xx_boards[] = {
 634        [EM2750_BOARD_UNKNOWN] = {
 635                .name          = "EM2710/EM2750/EM2751 webcam grabber",
 636                .xclk          = EM28XX_XCLK_FREQUENCY_20MHZ,
 637                .tuner_type    = TUNER_ABSENT,
 638                .is_webcam     = 1,
 639                .input         = { {
 640                        .type     = EM28XX_VMUX_COMPOSITE,
 641                        .vmux     = 0,
 642                        .amux     = EM28XX_AMUX_VIDEO,
 643                        .gpio     = silvercrest_reg_seq,
 644                } },
 645        },
 646        [EM2800_BOARD_UNKNOWN] = {
 647                .name         = "Unknown EM2800 video grabber",
 648                .is_em2800    = 1,
 649                .tda9887_conf = TDA9887_PRESENT,
 650                .decoder      = EM28XX_SAA711X,
 651                .tuner_type   = TUNER_ABSENT,
 652                .input        = { {
 653                        .type     = EM28XX_VMUX_COMPOSITE,
 654                        .vmux     = SAA7115_COMPOSITE0,
 655                        .amux     = EM28XX_AMUX_LINE_IN,
 656                }, {
 657                        .type     = EM28XX_VMUX_SVIDEO,
 658                        .vmux     = SAA7115_SVIDEO3,
 659                        .amux     = EM28XX_AMUX_LINE_IN,
 660                } },
 661        },
 662        [EM2820_BOARD_UNKNOWN] = {
 663                .name          = "Unknown EM2750/28xx video grabber",
 664                .tuner_type    = TUNER_ABSENT,
 665                .is_webcam     = 1,     /* To enable sensor probe */
 666        },
 667        [EM2750_BOARD_DLCW_130] = {
 668                /* Beijing Huaqi Information Digital Technology Co., Ltd */
 669                .name          = "Huaqi DLCW-130",
 670                .valid         = EM28XX_BOARD_NOT_VALIDATED,
 671                .xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
 672                .tuner_type    = TUNER_ABSENT,
 673                .is_webcam     = 1,
 674                .input         = { {
 675                        .type     = EM28XX_VMUX_COMPOSITE,
 676                        .vmux     = 0,
 677                        .amux     = EM28XX_AMUX_VIDEO,
 678                } },
 679        },
 680        [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
 681                .name         = "Kworld PVR TV 2800 RF",
 682                .tuner_type   = TUNER_TEMIC_PAL,
 683                .tda9887_conf = TDA9887_PRESENT,
 684                .decoder      = EM28XX_SAA711X,
 685                .input        = { {
 686                        .type     = EM28XX_VMUX_COMPOSITE,
 687                        .vmux     = SAA7115_COMPOSITE0,
 688                        .amux     = EM28XX_AMUX_LINE_IN,
 689                }, {
 690                        .type     = EM28XX_VMUX_SVIDEO,
 691                        .vmux     = SAA7115_SVIDEO3,
 692                        .amux     = EM28XX_AMUX_LINE_IN,
 693                } },
 694        },
 695        [EM2820_BOARD_GADMEI_TVR200] = {
 696                .name         = "Gadmei TVR200",
 697                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 698                .tda9887_conf = TDA9887_PRESENT,
 699                .decoder      = EM28XX_SAA711X,
 700                .input        = { {
 701                        .type     = EM28XX_VMUX_TELEVISION,
 702                        .vmux     = SAA7115_COMPOSITE2,
 703                        .amux     = EM28XX_AMUX_LINE_IN,
 704                }, {
 705                        .type     = EM28XX_VMUX_COMPOSITE,
 706                        .vmux     = SAA7115_COMPOSITE0,
 707                        .amux     = EM28XX_AMUX_LINE_IN,
 708                }, {
 709                        .type     = EM28XX_VMUX_SVIDEO,
 710                        .vmux     = SAA7115_SVIDEO3,
 711                        .amux     = EM28XX_AMUX_LINE_IN,
 712                } },
 713        },
 714        [EM2820_BOARD_TERRATEC_CINERGY_250] = {
 715                .name         = "Terratec Cinergy 250 USB",
 716                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 717                .has_ir_i2c   = 1,
 718                .tda9887_conf = TDA9887_PRESENT,
 719                .decoder      = EM28XX_SAA711X,
 720                .input        = { {
 721                        .type     = EM28XX_VMUX_TELEVISION,
 722                        .vmux     = SAA7115_COMPOSITE2,
 723                        .amux     = EM28XX_AMUX_VIDEO,
 724                }, {
 725                        .type     = EM28XX_VMUX_COMPOSITE,
 726                        .vmux     = SAA7115_COMPOSITE0,
 727                        .amux     = EM28XX_AMUX_LINE_IN,
 728                }, {
 729                        .type     = EM28XX_VMUX_SVIDEO,
 730                        .vmux     = SAA7115_SVIDEO3,
 731                        .amux     = EM28XX_AMUX_LINE_IN,
 732                } },
 733        },
 734        [EM2820_BOARD_PINNACLE_USB_2] = {
 735                .name         = "Pinnacle PCTV USB 2",
 736                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 737                .has_ir_i2c   = 1,
 738                .tda9887_conf = TDA9887_PRESENT,
 739                .decoder      = EM28XX_SAA711X,
 740                .input        = { {
 741                        .type     = EM28XX_VMUX_TELEVISION,
 742                        .vmux     = SAA7115_COMPOSITE2,
 743                        .amux     = EM28XX_AMUX_VIDEO,
 744                }, {
 745                        .type     = EM28XX_VMUX_COMPOSITE,
 746                        .vmux     = SAA7115_COMPOSITE0,
 747                        .amux     = EM28XX_AMUX_LINE_IN,
 748                }, {
 749                        .type     = EM28XX_VMUX_SVIDEO,
 750                        .vmux     = SAA7115_SVIDEO3,
 751                        .amux     = EM28XX_AMUX_LINE_IN,
 752                } },
 753        },
 754        [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
 755                .name         = "Hauppauge WinTV USB 2",
 756                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
 757                .tda9887_conf = TDA9887_PRESENT |
 758                                TDA9887_PORT1_ACTIVE |
 759                                TDA9887_PORT2_ACTIVE,
 760                .decoder      = EM28XX_TVP5150,
 761                .has_msp34xx  = 1,
 762                .has_ir_i2c   = 1,
 763                .input        = { {
 764                        .type     = EM28XX_VMUX_TELEVISION,
 765                        .vmux     = TVP5150_COMPOSITE0,
 766                        .amux     = MSP_INPUT_DEFAULT,
 767                }, {
 768                        .type     = EM28XX_VMUX_SVIDEO,
 769                        .vmux     = TVP5150_SVIDEO,
 770                        .amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
 771                                        MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
 772                } },
 773        },
 774        [EM2820_BOARD_DLINK_USB_TV] = {
 775                .name         = "D-Link DUB-T210 TV Tuner",
 776                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 777                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 778                .tda9887_conf = TDA9887_PRESENT,
 779                .decoder      = EM28XX_SAA711X,
 780                .input        = { {
 781                        .type     = EM28XX_VMUX_TELEVISION,
 782                        .vmux     = SAA7115_COMPOSITE2,
 783                        .amux     = EM28XX_AMUX_LINE_IN,
 784                }, {
 785                        .type     = EM28XX_VMUX_COMPOSITE,
 786                        .vmux     = SAA7115_COMPOSITE0,
 787                        .amux     = EM28XX_AMUX_LINE_IN,
 788                }, {
 789                        .type     = EM28XX_VMUX_SVIDEO,
 790                        .vmux     = SAA7115_SVIDEO3,
 791                        .amux     = EM28XX_AMUX_LINE_IN,
 792                } },
 793        },
 794        [EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
 795                .name         = "Hercules Smart TV USB 2.0",
 796                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 797                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 798                .tda9887_conf = TDA9887_PRESENT,
 799                .decoder      = EM28XX_SAA711X,
 800                .input        = { {
 801                        .type     = EM28XX_VMUX_TELEVISION,
 802                        .vmux     = SAA7115_COMPOSITE2,
 803                        .amux     = EM28XX_AMUX_LINE_IN,
 804                }, {
 805                        .type     = EM28XX_VMUX_COMPOSITE,
 806                        .vmux     = SAA7115_COMPOSITE0,
 807                        .amux     = EM28XX_AMUX_LINE_IN,
 808                }, {
 809                        .type     = EM28XX_VMUX_SVIDEO,
 810                        .vmux     = SAA7115_SVIDEO3,
 811                        .amux     = EM28XX_AMUX_LINE_IN,
 812                } },
 813        },
 814        [EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
 815                .name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
 816                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 817                .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
 818                .tda9887_conf = TDA9887_PRESENT,
 819                .decoder      = EM28XX_SAA711X,
 820                .input        = { {
 821                        .type     = EM28XX_VMUX_TELEVISION,
 822                        .vmux     = SAA7115_COMPOSITE2,
 823                        .amux     = EM28XX_AMUX_VIDEO,
 824                }, {
 825                        .type     = EM28XX_VMUX_COMPOSITE,
 826                        .vmux     = SAA7115_COMPOSITE0,
 827                        .amux     = EM28XX_AMUX_LINE_IN,
 828                }, {
 829                        .type     = EM28XX_VMUX_SVIDEO,
 830                        .vmux     = SAA7115_SVIDEO3,
 831                        .amux     = EM28XX_AMUX_LINE_IN,
 832                } },
 833        },
 834        [EM2820_BOARD_GADMEI_UTV310] = {
 835                .name         = "Gadmei UTV310",
 836                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 837                .tuner_type   = TUNER_TNF_5335MF,
 838                .tda9887_conf = TDA9887_PRESENT,
 839                .decoder      = EM28XX_SAA711X,
 840                .input        = { {
 841                        .type     = EM28XX_VMUX_TELEVISION,
 842                        .vmux     = SAA7115_COMPOSITE1,
 843                        .amux     = EM28XX_AMUX_LINE_IN,
 844                }, {
 845                        .type     = EM28XX_VMUX_COMPOSITE,
 846                        .vmux     = SAA7115_COMPOSITE0,
 847                        .amux     = EM28XX_AMUX_LINE_IN,
 848                }, {
 849                        .type     = EM28XX_VMUX_SVIDEO,
 850                        .vmux     = SAA7115_SVIDEO3,
 851                        .amux     = EM28XX_AMUX_LINE_IN,
 852                } },
 853        },
 854        [EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
 855                .name         = "Leadtek Winfast USB II Deluxe",
 856                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 857                .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
 858                .has_ir_i2c   = 1,
 859                .tvaudio_addr = 0x58,
 860                .tda9887_conf = TDA9887_PRESENT |
 861                                TDA9887_PORT2_ACTIVE |
 862                                TDA9887_QSS,
 863                .decoder      = EM28XX_SAA711X,
 864                .adecoder     = EM28XX_TVAUDIO,
 865                .input        = { {
 866                        .type     = EM28XX_VMUX_TELEVISION,
 867                        .vmux     = SAA7115_COMPOSITE4,
 868                        .amux     = EM28XX_AMUX_AUX,
 869                }, {
 870                        .type     = EM28XX_VMUX_COMPOSITE,
 871                        .vmux     = SAA7115_COMPOSITE5,
 872                        .amux     = EM28XX_AMUX_LINE_IN,
 873                }, {
 874                        .type     = EM28XX_VMUX_SVIDEO,
 875                        .vmux     = SAA7115_SVIDEO3,
 876                        .amux     = EM28XX_AMUX_LINE_IN,
 877                } },
 878                        .radio    = {
 879                        .type     = EM28XX_RADIO,
 880                        .amux     = EM28XX_AMUX_AUX,
 881                        }
 882        },
 883        [EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
 884                .name         = "Videology 20K14XUSB USB2.0",
 885                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 886                .tuner_type   = TUNER_ABSENT,
 887                .is_webcam    = 1,
 888                .input        = { {
 889                        .type     = EM28XX_VMUX_COMPOSITE,
 890                        .vmux     = 0,
 891                        .amux     = EM28XX_AMUX_VIDEO,
 892                } },
 893        },
 894        [EM2820_BOARD_SILVERCREST_WEBCAM] = {
 895                .name         = "Silvercrest Webcam 1.3mpix",
 896                .tuner_type   = TUNER_ABSENT,
 897                .is_webcam    = 1,
 898                .input        = { {
 899                        .type     = EM28XX_VMUX_COMPOSITE,
 900                        .vmux     = 0,
 901                        .amux     = EM28XX_AMUX_VIDEO,
 902                        .gpio     = silvercrest_reg_seq,
 903                } },
 904        },
 905        [EM2821_BOARD_SUPERCOMP_USB_2] = {
 906                .name         = "Supercomp USB 2.0 TV",
 907                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 908                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
 909                .tda9887_conf = TDA9887_PRESENT |
 910                                TDA9887_PORT1_ACTIVE |
 911                                TDA9887_PORT2_ACTIVE,
 912                .decoder      = EM28XX_SAA711X,
 913                .input        = { {
 914                        .type     = EM28XX_VMUX_TELEVISION,
 915                        .vmux     = SAA7115_COMPOSITE2,
 916                        .amux     = EM28XX_AMUX_LINE_IN,
 917                }, {
 918                        .type     = EM28XX_VMUX_COMPOSITE,
 919                        .vmux     = SAA7115_COMPOSITE0,
 920                        .amux     = EM28XX_AMUX_VIDEO,
 921                }, {
 922                        .type     = EM28XX_VMUX_SVIDEO,
 923                        .vmux     = SAA7115_SVIDEO3,
 924                        .amux     = EM28XX_AMUX_LINE_IN,
 925                } },
 926        },
 927        [EM2821_BOARD_USBGEAR_VD204] = {
 928                .name         = "Usbgear VD204v9",
 929                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 930                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
 931                .decoder      = EM28XX_SAA711X,
 932                .input        = { {
 933                        .type  = EM28XX_VMUX_COMPOSITE,
 934                        .vmux  = SAA7115_COMPOSITE0,
 935                        .amux  = EM28XX_AMUX_LINE_IN,
 936                }, {
 937                        .type  = EM28XX_VMUX_SVIDEO,
 938                        .vmux  = SAA7115_SVIDEO3,
 939                        .amux  = EM28XX_AMUX_LINE_IN,
 940                } },
 941        },
 942        [EM2860_BOARD_NETGMBH_CAM] = {
 943                /* Beijing Huaqi Information Digital Technology Co., Ltd */
 944                .name         = "NetGMBH Cam",
 945                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 946                .tuner_type   = TUNER_ABSENT,
 947                .is_webcam    = 1,
 948                .input        = { {
 949                        .type     = EM28XX_VMUX_COMPOSITE,
 950                        .vmux     = 0,
 951                        .amux     = EM28XX_AMUX_VIDEO,
 952                } },
 953        },
 954        [EM2860_BOARD_TYPHOON_DVD_MAKER] = {
 955                .name         = "Typhoon DVD Maker",
 956                .decoder      = EM28XX_SAA711X,
 957                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
 958                .input        = { {
 959                        .type  = EM28XX_VMUX_COMPOSITE,
 960                        .vmux  = SAA7115_COMPOSITE0,
 961                        .amux  = EM28XX_AMUX_LINE_IN,
 962                }, {
 963                        .type  = EM28XX_VMUX_SVIDEO,
 964                        .vmux  = SAA7115_SVIDEO3,
 965                        .amux  = EM28XX_AMUX_LINE_IN,
 966                } },
 967        },
 968        [EM2860_BOARD_GADMEI_UTV330] = {
 969                .name         = "Gadmei UTV330",
 970                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 971                .tuner_type   = TUNER_TNF_5335MF,
 972                .tda9887_conf = TDA9887_PRESENT,
 973                .decoder      = EM28XX_SAA711X,
 974                .input        = { {
 975                        .type     = EM28XX_VMUX_TELEVISION,
 976                        .vmux     = SAA7115_COMPOSITE2,
 977                        .amux     = EM28XX_AMUX_VIDEO,
 978                }, {
 979                        .type     = EM28XX_VMUX_COMPOSITE,
 980                        .vmux     = SAA7115_COMPOSITE0,
 981                        .amux     = EM28XX_AMUX_LINE_IN,
 982                }, {
 983                        .type     = EM28XX_VMUX_SVIDEO,
 984                        .vmux     = SAA7115_SVIDEO3,
 985                        .amux     = EM28XX_AMUX_LINE_IN,
 986                } },
 987        },
 988        [EM2861_BOARD_GADMEI_UTV330PLUS] = {
 989                .name         = "Gadmei UTV330+",
 990                .tuner_type   = TUNER_TNF_5335MF,
 991                .tda9887_conf = TDA9887_PRESENT,
 992                .ir_codes     = RC_MAP_GADMEI_RM008Z,
 993                .decoder      = EM28XX_SAA711X,
 994                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
 995                .input        = { {
 996                        .type     = EM28XX_VMUX_TELEVISION,
 997                        .vmux     = SAA7115_COMPOSITE2,
 998                        .amux     = EM28XX_AMUX_VIDEO,
 999                }, {
1000                        .type     = EM28XX_VMUX_COMPOSITE,
1001                        .vmux     = SAA7115_COMPOSITE0,
1002                        .amux     = EM28XX_AMUX_LINE_IN,
1003                }, {
1004                        .type     = EM28XX_VMUX_SVIDEO,
1005                        .vmux     = SAA7115_SVIDEO3,
1006                        .amux     = EM28XX_AMUX_LINE_IN,
1007                } },
1008        },
1009        [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
1010                .name         = "Terratec Cinergy A Hybrid XS",
1011                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1012                .tuner_type   = TUNER_XC2028,
1013                .tuner_gpio   = default_tuner_gpio,
1014                .decoder      = EM28XX_TVP5150,
1015
1016                .input        = { {
1017                        .type     = EM28XX_VMUX_TELEVISION,
1018                        .vmux     = TVP5150_COMPOSITE0,
1019                        .amux     = EM28XX_AMUX_VIDEO,
1020                        .gpio     = hauppauge_wintv_hvr_900_analog,
1021                }, {
1022                        .type     = EM28XX_VMUX_COMPOSITE,
1023                        .vmux     = TVP5150_COMPOSITE1,
1024                        .amux     = EM28XX_AMUX_LINE_IN,
1025                        .gpio     = hauppauge_wintv_hvr_900_analog,
1026                }, {
1027                        .type     = EM28XX_VMUX_SVIDEO,
1028                        .vmux     = TVP5150_SVIDEO,
1029                        .amux     = EM28XX_AMUX_LINE_IN,
1030                        .gpio     = hauppauge_wintv_hvr_900_analog,
1031                } },
1032        },
1033        [EM2861_BOARD_KWORLD_PVRTV_300U] = {
1034                .name         = "KWorld PVRTV 300U",
1035                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1036                .tuner_type   = TUNER_XC2028,
1037                .tuner_gpio   = default_tuner_gpio,
1038                .decoder      = EM28XX_TVP5150,
1039                .input        = { {
1040                        .type     = EM28XX_VMUX_TELEVISION,
1041                        .vmux     = TVP5150_COMPOSITE0,
1042                        .amux     = EM28XX_AMUX_VIDEO,
1043                }, {
1044                        .type     = EM28XX_VMUX_COMPOSITE,
1045                        .vmux     = TVP5150_COMPOSITE1,
1046                        .amux     = EM28XX_AMUX_LINE_IN,
1047                }, {
1048                        .type     = EM28XX_VMUX_SVIDEO,
1049                        .vmux     = TVP5150_SVIDEO,
1050                        .amux     = EM28XX_AMUX_LINE_IN,
1051                } },
1052        },
1053        [EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
1054                .name          = "Yakumo MovieMixer",
1055                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
1056                .decoder       = EM28XX_TVP5150,
1057                .input         = { {
1058                        .type     = EM28XX_VMUX_TELEVISION,
1059                        .vmux     = TVP5150_COMPOSITE0,
1060                        .amux     = EM28XX_AMUX_VIDEO,
1061                }, {
1062                        .type     = EM28XX_VMUX_COMPOSITE,
1063                        .vmux     = TVP5150_COMPOSITE1,
1064                        .amux     = EM28XX_AMUX_LINE_IN,
1065                }, {
1066                        .type     = EM28XX_VMUX_SVIDEO,
1067                        .vmux     = TVP5150_SVIDEO,
1068                        .amux     = EM28XX_AMUX_LINE_IN,
1069                } },
1070        },
1071        [EM2860_BOARD_TVP5150_REFERENCE_DESIGN] = {
1072                .name          = "EM2860/TVP5150 Reference Design",
1073                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
1074                .decoder       = EM28XX_TVP5150,
1075                .input         = { {
1076                        .type     = EM28XX_VMUX_COMPOSITE,
1077                        .vmux     = TVP5150_COMPOSITE1,
1078                        .amux     = EM28XX_AMUX_LINE_IN,
1079                }, {
1080                        .type     = EM28XX_VMUX_SVIDEO,
1081                        .vmux     = TVP5150_SVIDEO,
1082                        .amux     = EM28XX_AMUX_LINE_IN,
1083                } },
1084        },
1085        [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
1086                .name         = "Plextor ConvertX PX-TV100U",
1087                .tuner_type   = TUNER_TNF_5335MF,
1088                .xclk         = EM28XX_XCLK_I2S_MSB_TIMING |
1089                                EM28XX_XCLK_FREQUENCY_12MHZ,
1090                .tda9887_conf = TDA9887_PRESENT,
1091                .decoder      = EM28XX_TVP5150,
1092                .has_msp34xx  = 1,
1093                .input        = { {
1094                        .type     = EM28XX_VMUX_TELEVISION,
1095                        .vmux     = TVP5150_COMPOSITE0,
1096                        .amux     = EM28XX_AMUX_LINE_IN,
1097                        .gpio     = pinnacle_hybrid_pro_analog,
1098                }, {
1099                        .type     = EM28XX_VMUX_COMPOSITE,
1100                        .vmux     = TVP5150_COMPOSITE1,
1101                        .amux     = EM28XX_AMUX_LINE_IN,
1102                        .gpio     = pinnacle_hybrid_pro_analog,
1103                }, {
1104                        .type     = EM28XX_VMUX_SVIDEO,
1105                        .vmux     = TVP5150_SVIDEO,
1106                        .amux     = EM28XX_AMUX_LINE_IN,
1107                        .gpio     = pinnacle_hybrid_pro_analog,
1108                } },
1109        },
1110
1111        /* Those boards with em2870 are DVB Only*/
1112
1113        [EM2870_BOARD_TERRATEC_XS] = {
1114                .name         = "Terratec Cinergy T XS",
1115                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1116                .tuner_type   = TUNER_XC2028,
1117                .tuner_gpio   = default_tuner_gpio,
1118        },
1119        [EM2870_BOARD_TERRATEC_XS_MT2060] = {
1120                .name         = "Terratec Cinergy T XS (MT2060)",
1121                .xclk         = EM28XX_XCLK_IR_RC5_MODE |
1122                                EM28XX_XCLK_FREQUENCY_12MHZ,
1123                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1124                .tuner_type   = TUNER_ABSENT, /* MT2060 */
1125                .has_dvb      = 1,
1126                .tuner_gpio   = default_tuner_gpio,
1127        },
1128        [EM2870_BOARD_KWORLD_350U] = {
1129                .name         = "Kworld 350 U DVB-T",
1130                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1131                .tuner_type   = TUNER_XC2028,
1132                .tuner_gpio   = default_tuner_gpio,
1133        },
1134        [EM2870_BOARD_KWORLD_355U] = {
1135                .name         = "Kworld 355 U DVB-T",
1136                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1137                .tuner_type   = TUNER_ABSENT,
1138                .tuner_gpio   = default_tuner_gpio,
1139                .has_dvb      = 1,
1140                .dvb_gpio     = default_digital,
1141        },
1142        [EM2870_BOARD_PINNACLE_PCTV_DVB] = {
1143                .name         = "Pinnacle PCTV DVB-T",
1144                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1145                .tuner_type   = TUNER_ABSENT, /* MT2060 */
1146                /* djh - I have serious doubts this is right... */
1147                .xclk         = EM28XX_XCLK_IR_RC5_MODE |
1148                                EM28XX_XCLK_FREQUENCY_10MHZ,
1149        },
1150        [EM2870_BOARD_COMPRO_VIDEOMATE] = {
1151                .name         = "Compro, VideoMate U3",
1152                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1153                .tuner_type   = TUNER_ABSENT, /* MT2060 */
1154        },
1155
1156        [EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
1157                .name         = "Terratec Hybrid XS Secam",
1158                .has_msp34xx  = 1,
1159                .tuner_type   = TUNER_XC2028,
1160                .tuner_gpio   = default_tuner_gpio,
1161                .decoder      = EM28XX_TVP5150,
1162                .has_dvb      = 1,
1163                .dvb_gpio     = terratec_cinergy_USB_XS_FR_digital,
1164                .input        = { {
1165                        .type     = EM28XX_VMUX_TELEVISION,
1166                        .vmux     = TVP5150_COMPOSITE0,
1167                        .amux     = EM28XX_AMUX_VIDEO,
1168                        .gpio     = terratec_cinergy_USB_XS_FR_analog,
1169                }, {
1170                        .type     = EM28XX_VMUX_COMPOSITE,
1171                        .vmux     = TVP5150_COMPOSITE1,
1172                        .amux     = EM28XX_AMUX_LINE_IN,
1173                        .gpio     = terratec_cinergy_USB_XS_FR_analog,
1174                }, {
1175                        .type     = EM28XX_VMUX_SVIDEO,
1176                        .vmux     = TVP5150_SVIDEO,
1177                        .amux     = EM28XX_AMUX_LINE_IN,
1178                        .gpio     = terratec_cinergy_USB_XS_FR_analog,
1179                } },
1180        },
1181        [EM2884_BOARD_TERRATEC_H5] = {
1182                .name         = "Terratec Cinergy H5",
1183                .has_dvb      = 1,
1184#if 0
1185                .tuner_type   = TUNER_PHILIPS_TDA8290,
1186                .tuner_addr   = 0x41,
1187                .dvb_gpio     = terratec_h5_digital, /* FIXME: probably wrong */
1188                .tuner_gpio   = terratec_h5_gpio,
1189#else
1190                .tuner_type   = TUNER_ABSENT,
1191#endif
1192                .def_i2c_bus  = 1,
1193                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1194                                EM28XX_I2C_FREQ_400_KHZ,
1195        },
1196        [EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C] = {
1197                .name         = "Hauppauge WinTV HVR 930C",
1198                .has_dvb      = 1,
1199#if 0 /* FIXME: Add analog support */
1200                .tuner_type   = TUNER_XC5000,
1201                .tuner_addr   = 0x41,
1202                .dvb_gpio     = hauppauge_930c_digital,
1203                .tuner_gpio   = hauppauge_930c_gpio,
1204#else
1205                .tuner_type   = TUNER_ABSENT,
1206#endif
1207                .ir_codes     = RC_MAP_HAUPPAUGE,
1208                .def_i2c_bus  = 1,
1209                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1210                                EM28XX_I2C_FREQ_400_KHZ,
1211        },
1212        [EM2884_BOARD_C3TECH_DIGITAL_DUO] = {
1213                .name         = "C3 Tech Digital Duo HDTV/SDTV USB",
1214                .has_dvb      = 1,
1215                /* FIXME: Add analog support - need a saa7136 driver */
1216                .tuner_type = TUNER_ABSENT,     /* Digital-only TDA18271HD */
1217                .ir_codes     = RC_MAP_EMPTY,
1218                .def_i2c_bus  = 1,
1219                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE,
1220                .dvb_gpio     = c3tech_digital_duo_digital,
1221        },
1222        [EM2884_BOARD_CINERGY_HTC_STICK] = {
1223                .name         = "Terratec Cinergy HTC Stick",
1224                .has_dvb      = 1,
1225                .ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1226                .tuner_type   = TUNER_ABSENT,
1227                .def_i2c_bus  = 1,
1228                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1229                                EM28XX_I2C_FREQ_400_KHZ,
1230        },
1231        [EM2884_BOARD_ELGATO_EYETV_HYBRID_2008] = {
1232                .name         = "Elgato EyeTV Hybrid 2008 INT",
1233                .has_dvb      = 1,
1234                .ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
1235                .tuner_type   = TUNER_ABSENT,
1236                .def_i2c_bus  = 1,
1237                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
1238                                EM28XX_I2C_FREQ_400_KHZ,
1239        },
1240        [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
1241                .name         = "Hauppauge WinTV HVR 900",
1242                .tda9887_conf = TDA9887_PRESENT,
1243                .tuner_type   = TUNER_XC2028,
1244                .tuner_gpio   = default_tuner_gpio,
1245                .mts_firmware = 1,
1246                .has_dvb      = 1,
1247                .dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1248                .ir_codes     = RC_MAP_HAUPPAUGE,
1249                .decoder      = EM28XX_TVP5150,
1250                .input        = { {
1251                        .type     = EM28XX_VMUX_TELEVISION,
1252                        .vmux     = TVP5150_COMPOSITE0,
1253                        .amux     = EM28XX_AMUX_VIDEO,
1254                        .gpio     = hauppauge_wintv_hvr_900_analog,
1255                }, {
1256                        .type     = EM28XX_VMUX_COMPOSITE,
1257                        .vmux     = TVP5150_COMPOSITE1,
1258                        .amux     = EM28XX_AMUX_LINE_IN,
1259                        .gpio     = hauppauge_wintv_hvr_900_analog,
1260                }, {
1261                        .type     = EM28XX_VMUX_SVIDEO,
1262                        .vmux     = TVP5150_SVIDEO,
1263                        .amux     = EM28XX_AMUX_LINE_IN,
1264                        .gpio     = hauppauge_wintv_hvr_900_analog,
1265                } },
1266        },
1267        [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
1268                .name         = "Hauppauge WinTV HVR 900 (R2)",
1269                .tda9887_conf = TDA9887_PRESENT,
1270                .tuner_type   = TUNER_XC2028,
1271                .tuner_gpio   = default_tuner_gpio,
1272                .mts_firmware = 1,
1273                .has_dvb      = 1,
1274                .dvb_gpio     = hauppauge_wintv_hvr_900R2_digital,
1275                .ir_codes     = RC_MAP_HAUPPAUGE,
1276                .decoder      = EM28XX_TVP5150,
1277                .input        = { {
1278                        .type     = EM28XX_VMUX_TELEVISION,
1279                        .vmux     = TVP5150_COMPOSITE0,
1280                        .amux     = EM28XX_AMUX_VIDEO,
1281                        .gpio     = hauppauge_wintv_hvr_900_analog,
1282                }, {
1283                        .type     = EM28XX_VMUX_COMPOSITE,
1284                        .vmux     = TVP5150_COMPOSITE1,
1285                        .amux     = EM28XX_AMUX_LINE_IN,
1286                        .gpio     = hauppauge_wintv_hvr_900_analog,
1287                }, {
1288                        .type     = EM28XX_VMUX_SVIDEO,
1289                        .vmux     = TVP5150_SVIDEO,
1290                        .amux     = EM28XX_AMUX_LINE_IN,
1291                        .gpio     = hauppauge_wintv_hvr_900_analog,
1292                } },
1293        },
1294        [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
1295                .name           = "Hauppauge WinTV HVR 850",
1296                .tuner_type     = TUNER_XC2028,
1297                .tuner_gpio     = default_tuner_gpio,
1298                .mts_firmware   = 1,
1299                .has_dvb        = 1,
1300                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1301                .ir_codes       = RC_MAP_HAUPPAUGE,
1302                .decoder        = EM28XX_TVP5150,
1303                .input          = { {
1304                        .type     = EM28XX_VMUX_TELEVISION,
1305                        .vmux     = TVP5150_COMPOSITE0,
1306                        .amux     = EM28XX_AMUX_VIDEO,
1307                        .gpio     = hauppauge_wintv_hvr_900_analog,
1308                }, {
1309                        .type     = EM28XX_VMUX_COMPOSITE,
1310                        .vmux     = TVP5150_COMPOSITE1,
1311                        .amux     = EM28XX_AMUX_LINE_IN,
1312                        .gpio     = hauppauge_wintv_hvr_900_analog,
1313                }, {
1314                        .type     = EM28XX_VMUX_SVIDEO,
1315                        .vmux     = TVP5150_SVIDEO,
1316                        .amux     = EM28XX_AMUX_LINE_IN,
1317                        .gpio     = hauppauge_wintv_hvr_900_analog,
1318                } },
1319        },
1320        [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
1321                .name           = "Hauppauge WinTV HVR 950",
1322                .tuner_type     = TUNER_XC2028,
1323                .tuner_gpio     = default_tuner_gpio,
1324                .mts_firmware   = 1,
1325                .has_dvb        = 1,
1326                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1327                .ir_codes       = RC_MAP_HAUPPAUGE,
1328                .decoder        = EM28XX_TVP5150,
1329                .input          = { {
1330                        .type     = EM28XX_VMUX_TELEVISION,
1331                        .vmux     = TVP5150_COMPOSITE0,
1332                        .amux     = EM28XX_AMUX_VIDEO,
1333                        .gpio     = hauppauge_wintv_hvr_900_analog,
1334                }, {
1335                        .type     = EM28XX_VMUX_COMPOSITE,
1336                        .vmux     = TVP5150_COMPOSITE1,
1337                        .amux     = EM28XX_AMUX_LINE_IN,
1338                        .gpio     = hauppauge_wintv_hvr_900_analog,
1339                }, {
1340                        .type     = EM28XX_VMUX_SVIDEO,
1341                        .vmux     = TVP5150_SVIDEO,
1342                        .amux     = EM28XX_AMUX_LINE_IN,
1343                        .gpio     = hauppauge_wintv_hvr_900_analog,
1344                } },
1345        },
1346        [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
1347                .name           = "Pinnacle PCTV HD Pro Stick",
1348                .tuner_type     = TUNER_XC2028,
1349                .tuner_gpio   = default_tuner_gpio,
1350                .mts_firmware   = 1,
1351                .has_dvb        = 1,
1352                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1353                .ir_codes       = RC_MAP_PINNACLE_PCTV_HD,
1354                .decoder        = EM28XX_TVP5150,
1355                .input          = { {
1356                        .type     = EM28XX_VMUX_TELEVISION,
1357                        .vmux     = TVP5150_COMPOSITE0,
1358                        .amux     = EM28XX_AMUX_VIDEO,
1359                        .gpio     = hauppauge_wintv_hvr_900_analog,
1360                }, {
1361                        .type     = EM28XX_VMUX_COMPOSITE,
1362                        .vmux     = TVP5150_COMPOSITE1,
1363                        .amux     = EM28XX_AMUX_LINE_IN,
1364                        .gpio     = hauppauge_wintv_hvr_900_analog,
1365                }, {
1366                        .type     = EM28XX_VMUX_SVIDEO,
1367                        .vmux     = TVP5150_SVIDEO,
1368                        .amux     = EM28XX_AMUX_LINE_IN,
1369                        .gpio     = hauppauge_wintv_hvr_900_analog,
1370                } },
1371        },
1372        [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
1373                .name           = "AMD ATI TV Wonder HD 600",
1374                .tuner_type     = TUNER_XC2028,
1375                .tuner_gpio     = default_tuner_gpio,
1376                .mts_firmware   = 1,
1377                .has_dvb        = 1,
1378                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
1379                .ir_codes       = RC_MAP_ATI_TV_WONDER_HD_600,
1380                .decoder        = EM28XX_TVP5150,
1381                .input          = { {
1382                        .type     = EM28XX_VMUX_TELEVISION,
1383                        .vmux     = TVP5150_COMPOSITE0,
1384                        .amux     = EM28XX_AMUX_VIDEO,
1385                        .gpio     = hauppauge_wintv_hvr_900_analog,
1386                }, {
1387                        .type     = EM28XX_VMUX_COMPOSITE,
1388                        .vmux     = TVP5150_COMPOSITE1,
1389                        .amux     = EM28XX_AMUX_LINE_IN,
1390                        .gpio     = hauppauge_wintv_hvr_900_analog,
1391                }, {
1392                        .type     = EM28XX_VMUX_SVIDEO,
1393                        .vmux     = TVP5150_SVIDEO,
1394                        .amux     = EM28XX_AMUX_LINE_IN,
1395                        .gpio     = hauppauge_wintv_hvr_900_analog,
1396                } },
1397        },
1398        [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
1399                .name           = "Terratec Hybrid XS",
1400                .tuner_type     = TUNER_XC2028,
1401                .tuner_gpio     = default_tuner_gpio,
1402                .decoder        = EM28XX_TVP5150,
1403                .has_dvb        = 1,
1404                .dvb_gpio       = default_digital,
1405                .ir_codes       = RC_MAP_TERRATEC_CINERGY_XS,
1406                .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1407                .input          = { {
1408                        .type     = EM28XX_VMUX_TELEVISION,
1409                        .vmux     = TVP5150_COMPOSITE0,
1410                        .amux     = EM28XX_AMUX_VIDEO,
1411                        .gpio     = default_analog,
1412                }, {
1413                        .type     = EM28XX_VMUX_COMPOSITE,
1414                        .vmux     = TVP5150_COMPOSITE1,
1415                        .amux     = EM28XX_AMUX_LINE_IN,
1416                        .gpio     = default_analog,
1417                }, {
1418                        .type     = EM28XX_VMUX_SVIDEO,
1419                        .vmux     = TVP5150_SVIDEO,
1420                        .amux     = EM28XX_AMUX_LINE_IN,
1421                        .gpio     = default_analog,
1422                } },
1423        },
1424        /* maybe there's a reason behind it why Terratec sells the Hybrid XS
1425           as Prodigy XS with a different PID, let's keep it separated for now
1426           maybe we'll need it lateron */
1427        [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
1428                .name         = "Terratec Prodigy XS",
1429                .tuner_type   = TUNER_XC2028,
1430                .tuner_gpio   = default_tuner_gpio,
1431                .decoder      = EM28XX_TVP5150,
1432                .input        = { {
1433                        .type     = EM28XX_VMUX_TELEVISION,
1434                        .vmux     = TVP5150_COMPOSITE0,
1435                        .amux     = EM28XX_AMUX_VIDEO,
1436                        .gpio     = hauppauge_wintv_hvr_900_analog,
1437                }, {
1438                        .type     = EM28XX_VMUX_COMPOSITE,
1439                        .vmux     = TVP5150_COMPOSITE1,
1440                        .amux     = EM28XX_AMUX_LINE_IN,
1441                        .gpio     = hauppauge_wintv_hvr_900_analog,
1442                }, {
1443                        .type     = EM28XX_VMUX_SVIDEO,
1444                        .vmux     = TVP5150_SVIDEO,
1445                        .amux     = EM28XX_AMUX_LINE_IN,
1446                        .gpio     = hauppauge_wintv_hvr_900_analog,
1447                } },
1448        },
1449        [EM2820_BOARD_MSI_VOX_USB_2] = {
1450                .name              = "MSI VOX USB 2.0",
1451                .tuner_type        = TUNER_LG_PAL_NEW_TAPC,
1452                .tda9887_conf      = TDA9887_PRESENT      |
1453                                     TDA9887_PORT1_ACTIVE |
1454                                     TDA9887_PORT2_ACTIVE,
1455                .max_range_640_480 = 1,
1456                .decoder           = EM28XX_SAA711X,
1457                .input             = { {
1458                        .type      = EM28XX_VMUX_TELEVISION,
1459                        .vmux      = SAA7115_COMPOSITE4,
1460                        .amux      = EM28XX_AMUX_VIDEO,
1461                }, {
1462                        .type      = EM28XX_VMUX_COMPOSITE,
1463                        .vmux      = SAA7115_COMPOSITE0,
1464                        .amux      = EM28XX_AMUX_LINE_IN,
1465                }, {
1466                        .type      = EM28XX_VMUX_SVIDEO,
1467                        .vmux      = SAA7115_SVIDEO3,
1468                        .amux      = EM28XX_AMUX_LINE_IN,
1469                } },
1470        },
1471        [EM2800_BOARD_TERRATEC_CINERGY_200] = {
1472                .name         = "Terratec Cinergy 200 USB",
1473                .is_em2800    = 1,
1474                .has_ir_i2c   = 1,
1475                .tuner_type   = TUNER_LG_TALN,
1476                .tda9887_conf = TDA9887_PRESENT,
1477                .decoder      = EM28XX_SAA711X,
1478                .input        = { {
1479                        .type     = EM28XX_VMUX_TELEVISION,
1480                        .vmux     = SAA7115_COMPOSITE2,
1481                        .amux     = EM28XX_AMUX_VIDEO,
1482                }, {
1483                        .type     = EM28XX_VMUX_COMPOSITE,
1484                        .vmux     = SAA7115_COMPOSITE0,
1485                        .amux     = EM28XX_AMUX_LINE_IN,
1486                }, {
1487                        .type     = EM28XX_VMUX_SVIDEO,
1488                        .vmux     = SAA7115_SVIDEO3,
1489                        .amux     = EM28XX_AMUX_LINE_IN,
1490                } },
1491        },
1492        [EM2800_BOARD_GRABBEEX_USB2800] = {
1493                .name       = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
1494                .is_em2800  = 1,
1495                .decoder    = EM28XX_SAA711X,
1496                .tuner_type = TUNER_ABSENT, /* capture only board */
1497                .input      = { {
1498                        .type     = EM28XX_VMUX_COMPOSITE,
1499                        .vmux     = SAA7115_COMPOSITE0,
1500                        .amux     = EM28XX_AMUX_LINE_IN,
1501                }, {
1502                        .type     = EM28XX_VMUX_SVIDEO,
1503                        .vmux     = SAA7115_SVIDEO3,
1504                        .amux     = EM28XX_AMUX_LINE_IN,
1505                } },
1506        },
1507        [EM2800_BOARD_VC211A] = {
1508                .name         = "Actionmaster/LinXcel/Digitus VC211A",
1509                .is_em2800    = 1,
1510                .tuner_type   = TUNER_ABSENT,   /* Capture-only board */
1511                .decoder      = EM28XX_SAA711X,
1512                .input        = { {
1513                        .type     = EM28XX_VMUX_COMPOSITE,
1514                        .vmux     = SAA7115_COMPOSITE0,
1515                        .amux     = EM28XX_AMUX_LINE_IN,
1516                        .gpio     = vc211a_enable,
1517                }, {
1518                        .type     = EM28XX_VMUX_SVIDEO,
1519                        .vmux     = SAA7115_SVIDEO3,
1520                        .amux     = EM28XX_AMUX_LINE_IN,
1521                        .gpio     = vc211a_enable,
1522                } },
1523        },
1524        [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
1525                .name         = "Leadtek Winfast USB II",
1526                .is_em2800    = 1,
1527                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1528                .tda9887_conf = TDA9887_PRESENT,
1529                .decoder      = EM28XX_SAA711X,
1530                .input        = { {
1531                        .type     = EM28XX_VMUX_TELEVISION,
1532                        .vmux     = SAA7115_COMPOSITE2,
1533                        .amux     = EM28XX_AMUX_VIDEO,
1534                }, {
1535                        .type     = EM28XX_VMUX_COMPOSITE,
1536                        .vmux     = SAA7115_COMPOSITE0,
1537                        .amux     = EM28XX_AMUX_LINE_IN,
1538                }, {
1539                        .type     = EM28XX_VMUX_SVIDEO,
1540                        .vmux     = SAA7115_SVIDEO3,
1541                        .amux     = EM28XX_AMUX_LINE_IN,
1542                } },
1543        },
1544        [EM2800_BOARD_KWORLD_USB2800] = {
1545                .name         = "Kworld USB2800",
1546                .is_em2800    = 1,
1547                .tuner_type   = TUNER_PHILIPS_FCV1236D,
1548                .tda9887_conf = TDA9887_PRESENT,
1549                .decoder      = EM28XX_SAA711X,
1550                .input        = { {
1551                        .type     = EM28XX_VMUX_TELEVISION,
1552                        .vmux     = SAA7115_COMPOSITE2,
1553                        .amux     = EM28XX_AMUX_VIDEO,
1554                }, {
1555                        .type     = EM28XX_VMUX_COMPOSITE,
1556                        .vmux     = SAA7115_COMPOSITE0,
1557                        .amux     = EM28XX_AMUX_LINE_IN,
1558                }, {
1559                        .type     = EM28XX_VMUX_SVIDEO,
1560                        .vmux     = SAA7115_SVIDEO3,
1561                        .amux     = EM28XX_AMUX_LINE_IN,
1562                } },
1563        },
1564        [EM2820_BOARD_PINNACLE_DVC_90] = {
1565                .name         = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker / Kworld DVD Maker 2 / Plextor ConvertX PX-AV100U",
1566                .tuner_type   = TUNER_ABSENT, /* capture only board */
1567                .decoder      = EM28XX_SAA711X,
1568                .input        = { {
1569                        .type     = EM28XX_VMUX_COMPOSITE,
1570                        .vmux     = SAA7115_COMPOSITE0,
1571                        .amux     = EM28XX_AMUX_LINE_IN,
1572                }, {
1573                        .type     = EM28XX_VMUX_SVIDEO,
1574                        .vmux     = SAA7115_SVIDEO3,
1575                        .amux     = EM28XX_AMUX_LINE_IN,
1576                } },
1577        },
1578        [EM2800_BOARD_VGEAR_POCKETTV] = {
1579                .name         = "V-Gear PocketTV",
1580                .is_em2800    = 1,
1581                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1582                .tda9887_conf = TDA9887_PRESENT,
1583                .decoder      = EM28XX_SAA711X,
1584                .input        = { {
1585                        .type     = EM28XX_VMUX_TELEVISION,
1586                        .vmux     = SAA7115_COMPOSITE2,
1587                        .amux     = EM28XX_AMUX_VIDEO,
1588                }, {
1589                        .type     = EM28XX_VMUX_COMPOSITE,
1590                        .vmux     = SAA7115_COMPOSITE0,
1591                        .amux     = EM28XX_AMUX_LINE_IN,
1592                }, {
1593                        .type     = EM28XX_VMUX_SVIDEO,
1594                        .vmux     = SAA7115_SVIDEO3,
1595                        .amux     = EM28XX_AMUX_LINE_IN,
1596                } },
1597        },
1598        [EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2] = {
1599                .name         = "Pixelview PlayTV Box 4 USB 2.0",
1600                .tda9887_conf = TDA9887_PRESENT,
1601                .tuner_type   = TUNER_YMEC_TVF_5533MF,
1602                .decoder      = EM28XX_SAA711X,
1603                .input        = { {
1604                        .type     = EM28XX_VMUX_TELEVISION,
1605                        .vmux     = SAA7115_COMPOSITE2,
1606                        .amux     = EM28XX_AMUX_VIDEO,
1607                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
1608                                    EM28XX_AOUT_MASTER, /* Line out pin */
1609                }, {
1610                        .type     = EM28XX_VMUX_COMPOSITE,
1611                        .vmux     = SAA7115_COMPOSITE0,
1612                        .amux     = EM28XX_AMUX_LINE_IN,
1613                }, {
1614                        .type     = EM28XX_VMUX_SVIDEO,
1615                        .vmux     = SAA7115_SVIDEO3,
1616                        .amux     = EM28XX_AMUX_LINE_IN,
1617                } },
1618        },
1619        [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
1620                .name         = "SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0",
1621                .buttons = std_snapshot_button,
1622                .tda9887_conf = TDA9887_PRESENT,
1623                .tuner_type   = TUNER_YMEC_TVF_5533MF,
1624                .tuner_addr   = 0x60,
1625                .decoder      = EM28XX_SAA711X,
1626                .input        = { {
1627                        .type     = EM28XX_VMUX_TELEVISION,
1628                        .vmux     = SAA7115_COMPOSITE2,
1629                        .amux     = EM28XX_AMUX_VIDEO,
1630                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
1631                                    EM28XX_AOUT_MASTER, /* Line out pin */
1632                }, {
1633                        .type     = EM28XX_VMUX_COMPOSITE,
1634                        .vmux     = SAA7115_COMPOSITE0,
1635                        .amux     = EM28XX_AMUX_LINE_IN,
1636                }, {
1637                        .type     = EM28XX_VMUX_SVIDEO,
1638                        .vmux     = SAA7115_SVIDEO3,
1639                        .amux     = EM28XX_AMUX_LINE_IN,
1640                } },
1641        },
1642        [EM2860_BOARD_SAA711X_REFERENCE_DESIGN] = {
1643                .name                = "EM2860/SAA711X Reference Design",
1644                .buttons = std_snapshot_button,
1645                .tuner_type          = TUNER_ABSENT,
1646                .decoder             = EM28XX_SAA711X,
1647                .input               = { {
1648                        .type     = EM28XX_VMUX_SVIDEO,
1649                        .vmux     = SAA7115_SVIDEO3,
1650                }, {
1651                        .type     = EM28XX_VMUX_COMPOSITE,
1652                        .vmux     = SAA7115_COMPOSITE0,
1653                } },
1654        },
1655
1656        [EM2874_BOARD_LEADERSHIP_ISDBT] = {
1657                .def_i2c_bus    = 1,
1658                .i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE |
1659                                  EM28XX_I2C_FREQ_100_KHZ,
1660                .xclk           = EM28XX_XCLK_FREQUENCY_10MHZ,
1661                .name           = "EM2874 Leadership ISDBT",
1662                .tuner_type     = TUNER_ABSENT,
1663                .tuner_gpio     = leadership_reset,
1664                .dvb_gpio       = leadership_digital,
1665                .has_dvb        = 1,
1666        },
1667
1668        [EM2880_BOARD_MSI_DIGIVOX_AD] = {
1669                .name         = "MSI DigiVox A/D",
1670                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1671                .tuner_type   = TUNER_XC2028,
1672                .tuner_gpio   = default_tuner_gpio,
1673                .decoder      = EM28XX_TVP5150,
1674                .input        = { {
1675                        .type     = EM28XX_VMUX_TELEVISION,
1676                        .vmux     = TVP5150_COMPOSITE0,
1677                        .amux     = EM28XX_AMUX_VIDEO,
1678                        .gpio     = em2880_msi_digivox_ad_analog,
1679                }, {
1680                        .type     = EM28XX_VMUX_COMPOSITE,
1681                        .vmux     = TVP5150_COMPOSITE1,
1682                        .amux     = EM28XX_AMUX_LINE_IN,
1683                        .gpio     = em2880_msi_digivox_ad_analog,
1684                }, {
1685                        .type     = EM28XX_VMUX_SVIDEO,
1686                        .vmux     = TVP5150_SVIDEO,
1687                        .amux     = EM28XX_AMUX_LINE_IN,
1688                        .gpio     = em2880_msi_digivox_ad_analog,
1689                } },
1690        },
1691        [EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
1692                .name         = "MSI DigiVox A/D II",
1693                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1694                .tuner_type   = TUNER_XC2028,
1695                .tuner_gpio   = default_tuner_gpio,
1696                .decoder      = EM28XX_TVP5150,
1697                .input        = { {
1698                        .type     = EM28XX_VMUX_TELEVISION,
1699                        .vmux     = TVP5150_COMPOSITE0,
1700                        .amux     = EM28XX_AMUX_VIDEO,
1701                        .gpio     = em2880_msi_digivox_ad_analog,
1702                }, {
1703                        .type     = EM28XX_VMUX_COMPOSITE,
1704                        .vmux     = TVP5150_COMPOSITE1,
1705                        .amux     = EM28XX_AMUX_LINE_IN,
1706                        .gpio     = em2880_msi_digivox_ad_analog,
1707                }, {
1708                        .type     = EM28XX_VMUX_SVIDEO,
1709                        .vmux     = TVP5150_SVIDEO,
1710                        .amux     = EM28XX_AMUX_LINE_IN,
1711                        .gpio     = em2880_msi_digivox_ad_analog,
1712                } },
1713        },
1714        [EM2880_BOARD_KWORLD_DVB_305U] = {
1715                .name         = "KWorld DVB-T 305U",
1716                .tuner_type   = TUNER_XC2028,
1717                .tuner_gpio   = default_tuner_gpio,
1718                .decoder      = EM28XX_TVP5150,
1719                .input        = { {
1720                        .type     = EM28XX_VMUX_TELEVISION,
1721                        .vmux     = TVP5150_COMPOSITE0,
1722                        .amux     = EM28XX_AMUX_VIDEO,
1723                }, {
1724                        .type     = EM28XX_VMUX_COMPOSITE,
1725                        .vmux     = TVP5150_COMPOSITE1,
1726                        .amux     = EM28XX_AMUX_LINE_IN,
1727                }, {
1728                        .type     = EM28XX_VMUX_SVIDEO,
1729                        .vmux     = TVP5150_SVIDEO,
1730                        .amux     = EM28XX_AMUX_LINE_IN,
1731                } },
1732        },
1733        [EM2880_BOARD_KWORLD_DVB_310U] = {
1734                .name         = "KWorld DVB-T 310U",
1735                .tuner_type   = TUNER_XC2028,
1736                .tuner_gpio   = default_tuner_gpio,
1737                .has_dvb      = 1,
1738                .dvb_gpio     = default_digital,
1739                .mts_firmware = 1,
1740                .decoder      = EM28XX_TVP5150,
1741                .input        = { {
1742                        .type     = EM28XX_VMUX_TELEVISION,
1743                        .vmux     = TVP5150_COMPOSITE0,
1744                        .amux     = EM28XX_AMUX_VIDEO,
1745                        .gpio     = default_analog,
1746                }, {
1747                        .type     = EM28XX_VMUX_COMPOSITE,
1748                        .vmux     = TVP5150_COMPOSITE1,
1749                        .amux     = EM28XX_AMUX_LINE_IN,
1750                        .gpio     = default_analog,
1751                }, {    /* S-video has not been tested yet */
1752                        .type     = EM28XX_VMUX_SVIDEO,
1753                        .vmux     = TVP5150_SVIDEO,
1754                        .amux     = EM28XX_AMUX_LINE_IN,
1755                        .gpio     = default_analog,
1756                } },
1757        },
1758        [EM2882_BOARD_KWORLD_ATSC_315U] = {
1759                .name           = "KWorld ATSC 315U HDTV TV Box",
1760                .valid          = EM28XX_BOARD_NOT_VALIDATED,
1761                .tuner_type     = TUNER_THOMSON_DTT761X,
1762                .tuner_gpio     = em2882_kworld_315u_tuner_gpio,
1763                .tda9887_conf   = TDA9887_PRESENT,
1764                .decoder        = EM28XX_SAA711X,
1765                .has_dvb        = 1,
1766                .dvb_gpio       = em2882_kworld_315u_digital,
1767                .ir_codes       = RC_MAP_KWORLD_315U,
1768                .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ,
1769                .i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE,
1770                /* Analog mode - still not ready */
1771                /*.input        = { {
1772                        .type = EM28XX_VMUX_TELEVISION,
1773                        .vmux = SAA7115_COMPOSITE2,
1774                        .amux = EM28XX_AMUX_VIDEO,
1775                        .gpio = em2882_kworld_315u_analog,
1776                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1777                }, {
1778                        .type = EM28XX_VMUX_COMPOSITE,
1779                        .vmux = SAA7115_COMPOSITE0,
1780                        .amux = EM28XX_AMUX_LINE_IN,
1781                        .gpio = em2882_kworld_315u_analog1,
1782                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1783                }, {
1784                        .type = EM28XX_VMUX_SVIDEO,
1785                        .vmux = SAA7115_SVIDEO3,
1786                        .amux = EM28XX_AMUX_LINE_IN,
1787                        .gpio = em2882_kworld_315u_analog1,
1788                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1789                } }, */
1790        },
1791        [EM2880_BOARD_EMPIRE_DUAL_TV] = {
1792                .name = "Empire dual TV",
1793                .tuner_type = TUNER_XC2028,
1794                .tuner_gpio = default_tuner_gpio,
1795                .has_dvb = 1,
1796                .dvb_gpio = default_digital,
1797                .mts_firmware = 1,
1798                .decoder = EM28XX_TVP5150,
1799                .input = { {
1800                        .type = EM28XX_VMUX_TELEVISION,
1801                        .vmux = TVP5150_COMPOSITE0,
1802                        .amux = EM28XX_AMUX_VIDEO,
1803                        .gpio = default_analog,
1804                }, {
1805                        .type = EM28XX_VMUX_COMPOSITE,
1806                        .vmux = TVP5150_COMPOSITE1,
1807                        .amux = EM28XX_AMUX_LINE_IN,
1808                        .gpio = default_analog,
1809                }, {
1810                        .type = EM28XX_VMUX_SVIDEO,
1811                        .vmux = TVP5150_SVIDEO,
1812                        .amux = EM28XX_AMUX_LINE_IN,
1813                        .gpio = default_analog,
1814                } },
1815        },
1816        [EM2881_BOARD_DNT_DA2_HYBRID] = {
1817                .name         = "DNT DA2 Hybrid",
1818                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1819                .tuner_type   = TUNER_XC2028,
1820                .tuner_gpio   = default_tuner_gpio,
1821                .decoder      = EM28XX_TVP5150,
1822                .input        = { {
1823                        .type     = EM28XX_VMUX_TELEVISION,
1824                        .vmux     = TVP5150_COMPOSITE0,
1825                        .amux     = EM28XX_AMUX_VIDEO,
1826                        .gpio     = default_analog,
1827                }, {
1828                        .type     = EM28XX_VMUX_COMPOSITE,
1829                        .vmux     = TVP5150_COMPOSITE1,
1830                        .amux     = EM28XX_AMUX_LINE_IN,
1831                        .gpio     = default_analog,
1832                }, {
1833                        .type     = EM28XX_VMUX_SVIDEO,
1834                        .vmux     = TVP5150_SVIDEO,
1835                        .amux     = EM28XX_AMUX_LINE_IN,
1836                        .gpio     = default_analog,
1837                } },
1838        },
1839        [EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
1840                .name         = "Pinnacle Hybrid Pro",
1841                .tuner_type   = TUNER_XC2028,
1842                .tuner_gpio   = default_tuner_gpio,
1843                .decoder      = EM28XX_TVP5150,
1844                .has_dvb      = 1,
1845                .dvb_gpio     = pinnacle_hybrid_pro_digital,
1846                .input        = { {
1847                        .type     = EM28XX_VMUX_TELEVISION,
1848                        .vmux     = TVP5150_COMPOSITE0,
1849                        .amux     = EM28XX_AMUX_VIDEO,
1850                        .gpio     = pinnacle_hybrid_pro_analog,
1851                }, {
1852                        .type     = EM28XX_VMUX_COMPOSITE,
1853                        .vmux     = TVP5150_COMPOSITE1,
1854                        .amux     = EM28XX_AMUX_LINE_IN,
1855                        .gpio     = pinnacle_hybrid_pro_analog,
1856                }, {
1857                        .type     = EM28XX_VMUX_SVIDEO,
1858                        .vmux     = TVP5150_SVIDEO,
1859                        .amux     = EM28XX_AMUX_LINE_IN,
1860                        .gpio     = pinnacle_hybrid_pro_analog,
1861                } },
1862        },
1863        [EM2882_BOARD_PINNACLE_HYBRID_PRO_330E] = {
1864                .name         = "Pinnacle Hybrid Pro (330e)",
1865                .tuner_type   = TUNER_XC2028,
1866                .tuner_gpio   = default_tuner_gpio,
1867                .mts_firmware = 1,
1868                .has_dvb      = 1,
1869                .dvb_gpio     = hauppauge_wintv_hvr_900R2_digital,
1870                .ir_codes     = RC_MAP_PINNACLE_PCTV_HD,
1871                .decoder      = EM28XX_TVP5150,
1872                .input        = { {
1873                        .type     = EM28XX_VMUX_TELEVISION,
1874                        .vmux     = TVP5150_COMPOSITE0,
1875                        .amux     = EM28XX_AMUX_VIDEO,
1876                        .gpio     = hauppauge_wintv_hvr_900_analog,
1877                }, {
1878                        .type     = EM28XX_VMUX_COMPOSITE,
1879                        .vmux     = TVP5150_COMPOSITE1,
1880                        .amux     = EM28XX_AMUX_LINE_IN,
1881                        .gpio     = hauppauge_wintv_hvr_900_analog,
1882                }, {
1883                        .type     = EM28XX_VMUX_SVIDEO,
1884                        .vmux     = TVP5150_SVIDEO,
1885                        .amux     = EM28XX_AMUX_LINE_IN,
1886                        .gpio     = hauppauge_wintv_hvr_900_analog,
1887                } },
1888        },
1889        [EM2882_BOARD_KWORLD_VS_DVBT] = {
1890                .name         = "Kworld VS-DVB-T 323UR",
1891                .tuner_type   = TUNER_XC2028,
1892                .tuner_gpio   = default_tuner_gpio,
1893                .decoder      = EM28XX_TVP5150,
1894                .mts_firmware = 1,
1895                .has_dvb      = 1,
1896                .dvb_gpio     = kworld_330u_digital,
1897                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1898                .ir_codes     = RC_MAP_KWORLD_315U,
1899                .input        = { {
1900                        .type     = EM28XX_VMUX_TELEVISION,
1901                        .vmux     = TVP5150_COMPOSITE0,
1902                        .amux     = EM28XX_AMUX_VIDEO,
1903                }, {
1904                        .type     = EM28XX_VMUX_COMPOSITE,
1905                        .vmux     = TVP5150_COMPOSITE1,
1906                        .amux     = EM28XX_AMUX_LINE_IN,
1907                }, {
1908                        .type     = EM28XX_VMUX_SVIDEO,
1909                        .vmux     = TVP5150_SVIDEO,
1910                        .amux     = EM28XX_AMUX_LINE_IN,
1911                } },
1912        },
1913        [EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1914                .name         = "Terratec Cinnergy Hybrid T USB XS (em2882)",
1915                .tuner_type   = TUNER_XC2028,
1916                .tuner_gpio   = default_tuner_gpio,
1917                .mts_firmware = 1,
1918                .decoder      = EM28XX_TVP5150,
1919                .has_dvb      = 1,
1920                .dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1921                .ir_codes     = RC_MAP_TERRATEC_CINERGY_XS,
1922                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
1923                .input        = { {
1924                        .type     = EM28XX_VMUX_TELEVISION,
1925                        .vmux     = TVP5150_COMPOSITE0,
1926                        .amux     = EM28XX_AMUX_VIDEO,
1927                        .gpio     = hauppauge_wintv_hvr_900_analog,
1928                }, {
1929                        .type     = EM28XX_VMUX_COMPOSITE,
1930                        .vmux     = TVP5150_COMPOSITE1,
1931                        .amux     = EM28XX_AMUX_LINE_IN,
1932                        .gpio     = hauppauge_wintv_hvr_900_analog,
1933                }, {
1934                        .type     = EM28XX_VMUX_SVIDEO,
1935                        .vmux     = TVP5150_SVIDEO,
1936                        .amux     = EM28XX_AMUX_LINE_IN,
1937                        .gpio     = hauppauge_wintv_hvr_900_analog,
1938                } },
1939        },
1940        [EM2882_BOARD_DIKOM_DK300] = {
1941                .name         = "Dikom DK300",
1942                .tuner_type   = TUNER_XC2028,
1943                .tuner_gpio   = default_tuner_gpio,
1944                .decoder      = EM28XX_TVP5150,
1945                .mts_firmware = 1,
1946                .has_dvb      = 1,
1947                .dvb_gpio     = dikom_dk300_digital,
1948                .input        = { {
1949                        .type     = EM28XX_VMUX_TELEVISION,
1950                        .vmux     = TVP5150_COMPOSITE0,
1951                        .amux     = EM28XX_AMUX_VIDEO,
1952                        .gpio     = default_analog,
1953                } },
1954        },
1955        [EM2883_BOARD_KWORLD_HYBRID_330U] = {
1956                .name         = "Kworld PlusTV HD Hybrid 330",
1957                .tuner_type   = TUNER_XC2028,
1958                .tuner_gpio   = default_tuner_gpio,
1959                .decoder      = EM28XX_TVP5150,
1960                .mts_firmware = 1,
1961                .has_dvb      = 1,
1962                .dvb_gpio     = kworld_330u_digital,
1963                .xclk             = EM28XX_XCLK_FREQUENCY_12MHZ,
1964                .i2c_speed        = EM28XX_I2C_CLK_WAIT_ENABLE |
1965                                    EM28XX_I2C_EEPROM_ON_BOARD |
1966                                    EM28XX_I2C_EEPROM_KEY_VALID,
1967                .input        = { {
1968                        .type     = EM28XX_VMUX_TELEVISION,
1969                        .vmux     = TVP5150_COMPOSITE0,
1970                        .amux     = EM28XX_AMUX_VIDEO,
1971                        .gpio     = kworld_330u_analog,
1972                        .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1973                }, {
1974                        .type     = EM28XX_VMUX_COMPOSITE,
1975                        .vmux     = TVP5150_COMPOSITE1,
1976                        .amux     = EM28XX_AMUX_LINE_IN,
1977                        .gpio     = kworld_330u_analog,
1978                        .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1979                }, {
1980                        .type     = EM28XX_VMUX_SVIDEO,
1981                        .vmux     = TVP5150_SVIDEO,
1982                        .amux     = EM28XX_AMUX_LINE_IN,
1983                        .gpio     = kworld_330u_analog,
1984                } },
1985        },
1986        [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1987                .name         = "Compro VideoMate ForYou/Stereo",
1988                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1989                .tvaudio_addr = 0xb0,
1990                .tda9887_conf = TDA9887_PRESENT,
1991                .decoder      = EM28XX_TVP5150,
1992                .adecoder     = EM28XX_TVAUDIO,
1993                .mute_gpio    = compro_mute_gpio,
1994                .input        = { {
1995                        .type     = EM28XX_VMUX_TELEVISION,
1996                        .vmux     = TVP5150_COMPOSITE0,
1997                        .amux     = EM28XX_AMUX_VIDEO,
1998                        .gpio     = compro_unmute_tv_gpio,
1999                }, {
2000                        .type     = EM28XX_VMUX_SVIDEO,
2001                        .vmux     = TVP5150_SVIDEO,
2002                        .amux     = EM28XX_AMUX_LINE_IN,
2003                        .gpio     = compro_unmute_svid_gpio,
2004                } },
2005        },
2006        [EM2860_BOARD_KAIOMY_TVNPC_U2] = {
2007                .name         = "Kaiomy TVnPC U2",
2008                .vchannels    = 3,
2009                .tuner_type   = TUNER_XC2028,
2010                .tuner_addr   = 0x61,
2011                .mts_firmware = 1,
2012                .decoder      = EM28XX_TVP5150,
2013                .tuner_gpio   = default_tuner_gpio,
2014                .ir_codes     = RC_MAP_KAIOMY,
2015                .input          = { {
2016                        .type     = EM28XX_VMUX_TELEVISION,
2017                        .vmux     = TVP5150_COMPOSITE0,
2018                        .amux     = EM28XX_AMUX_VIDEO,
2019
2020                }, {
2021                        .type     = EM28XX_VMUX_COMPOSITE,
2022                        .vmux     = TVP5150_COMPOSITE1,
2023                        .amux     = EM28XX_AMUX_LINE_IN,
2024                }, {
2025                        .type     = EM28XX_VMUX_SVIDEO,
2026                        .vmux     = TVP5150_SVIDEO,
2027                        .amux     = EM28XX_AMUX_LINE_IN,
2028                } },
2029                .radio          = {
2030                        .type     = EM28XX_RADIO,
2031                        .amux     = EM28XX_AMUX_LINE_IN,
2032                }
2033        },
2034        [EM2860_BOARD_EASYCAP] = {
2035                .name         = "Easy Cap Capture DC-60",
2036                .vchannels    = 2,
2037                .tuner_type   = TUNER_ABSENT,
2038                .decoder      = EM28XX_SAA711X,
2039                .input           = { {
2040                        .type     = EM28XX_VMUX_COMPOSITE,
2041                        .vmux     = SAA7115_COMPOSITE0,
2042                        .amux     = EM28XX_AMUX_LINE_IN,
2043                }, {
2044                        .type     = EM28XX_VMUX_SVIDEO,
2045                        .vmux     = SAA7115_SVIDEO3,
2046                        .amux     = EM28XX_AMUX_LINE_IN,
2047                } },
2048        },
2049        [EM2820_BOARD_IODATA_GVMVP_SZ] = {
2050                .name       = "IO-DATA GV-MVP/SZ",
2051                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
2052                .tuner_gpio   = default_tuner_gpio,
2053                .tda9887_conf = TDA9887_PRESENT,
2054                .decoder      = EM28XX_TVP5150,
2055                .input        = { {
2056                        .type     = EM28XX_VMUX_TELEVISION,
2057                        .vmux     = TVP5150_COMPOSITE0,
2058                        .amux     = EM28XX_AMUX_VIDEO,
2059                }, { /* Composite has not been tested yet */
2060                        .type     = EM28XX_VMUX_COMPOSITE,
2061                        .vmux     = TVP5150_COMPOSITE1,
2062                        .amux     = EM28XX_AMUX_VIDEO,
2063                }, { /* S-video has not been tested yet */
2064                        .type     = EM28XX_VMUX_SVIDEO,
2065                        .vmux     = TVP5150_SVIDEO,
2066                        .amux     = EM28XX_AMUX_VIDEO,
2067                } },
2068        },
2069        [EM2860_BOARD_TERRATEC_GRABBY] = {
2070                .name            = "Terratec Grabby",
2071                .vchannels       = 2,
2072                .tuner_type      = TUNER_ABSENT,
2073                .decoder         = EM28XX_SAA711X,
2074                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
2075                .input           = { {
2076                        .type     = EM28XX_VMUX_COMPOSITE,
2077                        .vmux     = SAA7115_COMPOSITE0,
2078                        .amux     = EM28XX_AMUX_LINE_IN,
2079                }, {
2080                        .type     = EM28XX_VMUX_SVIDEO,
2081                        .vmux     = SAA7115_SVIDEO3,
2082                        .amux     = EM28XX_AMUX_LINE_IN,
2083                } },
2084                .buttons         = std_snapshot_button,
2085                .leds            = terratec_grabby_leds,
2086        },
2087        [EM2860_BOARD_TERRATEC_AV350] = {
2088                .name            = "Terratec AV350",
2089                .vchannels       = 2,
2090                .tuner_type      = TUNER_ABSENT,
2091                .decoder         = EM28XX_TVP5150,
2092                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
2093                .mute_gpio       = terratec_av350_mute_gpio,
2094                .input           = { {
2095                        .type     = EM28XX_VMUX_COMPOSITE,
2096                        .vmux     = TVP5150_COMPOSITE1,
2097                        .amux     = EM28XX_AUDIO_SRC_LINE,
2098                        .gpio     = terratec_av350_unmute_gpio,
2099
2100                }, {
2101                        .type     = EM28XX_VMUX_SVIDEO,
2102                        .vmux     = TVP5150_SVIDEO,
2103                        .amux     = EM28XX_AUDIO_SRC_LINE,
2104                        .gpio     = terratec_av350_unmute_gpio,
2105                } },
2106        },
2107
2108        [EM2860_BOARD_ELGATO_VIDEO_CAPTURE] = {
2109                .name         = "Elgato Video Capture",
2110                .decoder      = EM28XX_SAA711X,
2111                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
2112                .input        = { {
2113                        .type  = EM28XX_VMUX_COMPOSITE,
2114                        .vmux  = SAA7115_COMPOSITE0,
2115                        .amux  = EM28XX_AMUX_LINE_IN,
2116                }, {
2117                        .type  = EM28XX_VMUX_SVIDEO,
2118                        .vmux  = SAA7115_SVIDEO3,
2119                        .amux  = EM28XX_AMUX_LINE_IN,
2120                } },
2121        },
2122
2123        [EM2882_BOARD_EVGA_INDTUBE] = {
2124                .name         = "Evga inDtube",
2125                .tuner_type   = TUNER_XC2028,
2126                .tuner_gpio   = default_tuner_gpio,
2127                .decoder      = EM28XX_TVP5150,
2128                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
2129                .mts_firmware = 1,
2130                .has_dvb      = 1,
2131                .dvb_gpio     = evga_indtube_digital,
2132                .ir_codes     = RC_MAP_EVGA_INDTUBE,
2133                .input        = { {
2134                        .type     = EM28XX_VMUX_TELEVISION,
2135                        .vmux     = TVP5150_COMPOSITE0,
2136                        .amux     = EM28XX_AMUX_VIDEO,
2137                        .gpio     = evga_indtube_analog,
2138                }, {
2139                        .type     = EM28XX_VMUX_COMPOSITE,
2140                        .vmux     = TVP5150_COMPOSITE1,
2141                        .amux     = EM28XX_AMUX_LINE_IN,
2142                        .gpio     = evga_indtube_analog,
2143                }, {
2144                        .type     = EM28XX_VMUX_SVIDEO,
2145                        .vmux     = TVP5150_SVIDEO,
2146                        .amux     = EM28XX_AMUX_LINE_IN,
2147                        .gpio     = evga_indtube_analog,
2148                } },
2149        },
2150        /* eb1a:2868 Empia EM2870 + Philips CU1216L NIM (Philips TDA10023 +
2151           Infineon TUA6034) */
2152        [EM2870_BOARD_REDDO_DVB_C_USB_BOX] = {
2153                .name          = "Reddo DVB-C USB TV Box",
2154                .tuner_type    = TUNER_ABSENT,
2155                .tuner_gpio    = reddo_dvb_c_usb_box,
2156                .has_dvb       = 1,
2157        },
2158        /* 1b80:a340 - Empia EM2870, NXP TDA18271HD and LG DT3304, sold
2159         * initially as the KWorld PlusTV 340U, then as the UB435-Q.
2160         * Early variants have a TDA18271HD/C1, later ones a TDA18271HD/C2 */
2161        [EM2870_BOARD_KWORLD_A340] = {
2162                .name       = "KWorld PlusTV 340U or UB435-Q (ATSC)",
2163                .tuner_type = TUNER_ABSENT,     /* Digital-only TDA18271HD */
2164                .has_dvb    = 1,
2165                .dvb_gpio   = kworld_a340_digital,
2166                .tuner_gpio = default_tuner_gpio,
2167        },
2168        /* 2013:024f PCTV nanoStick T2 290e.
2169         * Empia EM28174, Sony CXD2820R and NXP TDA18271HD/C2 */
2170        [EM28174_BOARD_PCTV_290E] = {
2171                .name          = "PCTV nanoStick T2 290e",
2172                .def_i2c_bus   = 1,
2173                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_100_KHZ,
2174                .tuner_type    = TUNER_ABSENT,
2175                .tuner_gpio    = pctv_290e,
2176                .has_dvb       = 1,
2177                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2178        },
2179        /* 2013:024f PCTV DVB-S2 Stick 460e
2180         * Empia EM28174, NXP TDA10071, Conexant CX24118A and Allegro A8293 */
2181        [EM28174_BOARD_PCTV_460E] = {
2182                .def_i2c_bus   = 1,
2183                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ,
2184                .name          = "PCTV DVB-S2 Stick (460e)",
2185                .tuner_type    = TUNER_ABSENT,
2186                .tuner_gpio    = pctv_460e,
2187                .has_dvb       = 1,
2188                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2189        },
2190        /* eb1a:5006 Honestech VIDBOX NW03
2191         * Empia EM2860, Philips SAA7113, Empia EMP202, No Tuner */
2192        [EM2860_BOARD_HT_VIDBOX_NW03] = {
2193                .name                = "Honestech Vidbox NW03",
2194                .tuner_type          = TUNER_ABSENT,
2195                .decoder             = EM28XX_SAA711X,
2196                .input               = { {
2197                        .type     = EM28XX_VMUX_COMPOSITE,
2198                        .vmux     = SAA7115_COMPOSITE0,
2199                        .amux     = EM28XX_AMUX_LINE_IN,
2200                }, {
2201                        .type     = EM28XX_VMUX_SVIDEO,
2202                        .vmux     = SAA7115_SVIDEO3,  /* S-VIDEO needs confirming */
2203                        .amux     = EM28XX_AMUX_LINE_IN,
2204                } },
2205        },
2206        /* 1b80:e425 MaxMedia UB425-TC
2207         * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2 */
2208        [EM2874_BOARD_MAXMEDIA_UB425_TC] = {
2209                .name          = "MaxMedia UB425-TC",
2210                .tuner_type    = TUNER_ABSENT,
2211                .tuner_gpio    = maxmedia_ub425_tc,
2212                .has_dvb       = 1,
2213                .ir_codes      = RC_MAP_REDDO,
2214                .def_i2c_bus   = 1,
2215                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2216                                EM28XX_I2C_FREQ_400_KHZ,
2217        },
2218        /* 2304:0242 PCTV QuatroStick (510e)
2219         * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
2220        [EM2884_BOARD_PCTV_510E] = {
2221                .name          = "PCTV QuatroStick (510e)",
2222                .tuner_type    = TUNER_ABSENT,
2223                .tuner_gpio    = pctv_510e,
2224                .has_dvb       = 1,
2225                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2226                .def_i2c_bus   = 1,
2227                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2228                                EM28XX_I2C_FREQ_400_KHZ,
2229        },
2230        /* 2013:0251 PCTV QuatroStick nano (520e)
2231         * Empia EM2884 + Micronas DRX 3926K + NXP TDA18271HDC2 */
2232        [EM2884_BOARD_PCTV_520E] = {
2233                .name          = "PCTV QuatroStick nano (520e)",
2234                .tuner_type    = TUNER_ABSENT,
2235                .tuner_gpio    = pctv_520e,
2236                .has_dvb       = 1,
2237                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2238                .def_i2c_bus   = 1,
2239                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2240                                EM28XX_I2C_FREQ_400_KHZ,
2241        },
2242        [EM2884_BOARD_TERRATEC_HTC_USB_XS] = {
2243                .name         = "Terratec Cinergy HTC USB XS",
2244                .has_dvb      = 1,
2245                .ir_codes     = RC_MAP_NEC_TERRATEC_CINERGY_XS,
2246                .tuner_type   = TUNER_ABSENT,
2247                .def_i2c_bus  = 1,
2248                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
2249                                EM28XX_I2C_FREQ_400_KHZ,
2250        },
2251        /* 1b80:e1cc Delock 61959
2252         * Empia EM2874B + Micronas DRX 3913KA2 + NXP TDA18271HDC2
2253         * mostly the same as MaxMedia UB-425-TC but different remote */
2254        [EM2874_BOARD_DELOCK_61959] = {
2255                .name          = "Delock 61959",
2256                .tuner_type    = TUNER_ABSENT,
2257                .tuner_gpio    = maxmedia_ub425_tc,
2258                .has_dvb       = 1,
2259                .ir_codes      = RC_MAP_DELOCK_61959,
2260                .def_i2c_bus   = 1,
2261                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2262                                EM28XX_I2C_FREQ_400_KHZ,
2263        },
2264        /*
2265         * 1b80:e346 KWorld USB ATSC TV Stick UB435-Q V2
2266         * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2267         */
2268        [EM2874_BOARD_KWORLD_UB435Q_V2] = {
2269                .name           = "KWorld USB ATSC TV Stick UB435-Q V2",
2270                .tuner_type     = TUNER_ABSENT,
2271                .has_dvb        = 1,
2272                .dvb_gpio       = kworld_a340_digital,
2273                .tuner_gpio     = default_tuner_gpio,
2274                .def_i2c_bus    = 1,
2275        },
2276        /*
2277         * 1b80:e34c KWorld USB ATSC TV Stick UB435-Q V3
2278         * Empia EM2874B + LG DT3305 + NXP TDA18271HDC2
2279         */
2280        [EM2874_BOARD_KWORLD_UB435Q_V3] = {
2281                .name           = "KWorld USB ATSC TV Stick UB435-Q V3",
2282                .tuner_type     = TUNER_ABSENT,
2283                .has_dvb        = 1,
2284                .tuner_gpio     = kworld_ub435q_v3_digital,
2285                .def_i2c_bus    = 1,
2286                .i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE |
2287                                  EM28XX_I2C_FREQ_100_KHZ,
2288                .leds = kworld_ub435q_v3_leds,
2289        },
2290        [EM2874_BOARD_PCTV_HD_MINI_80E] = {
2291                .name         = "Pinnacle PCTV HD Mini",
2292                .tuner_type   = TUNER_ABSENT,
2293                .has_dvb      = 1,
2294                .dvb_gpio     = em2874_pctv_80e_digital,
2295                .decoder      = EM28XX_NODECODER,
2296                .ir_codes     = RC_MAP_PINNACLE_PCTV_HD,
2297                .leds         = pctv_80e_leds,
2298        },
2299        /* 1ae7:9003/9004 SpeedLink Vicious And Devine Laplace webcam
2300         * Empia EM2765 + OmniVision OV2640 */
2301        [EM2765_BOARD_SPEEDLINK_VAD_LAPLACE] = {
2302                .name         = "SpeedLink Vicious And Devine Laplace webcam",
2303                .xclk         = EM28XX_XCLK_FREQUENCY_24MHZ,
2304                .i2c_speed    = EM28XX_I2C_CLK_WAIT_ENABLE |
2305                                EM28XX_I2C_FREQ_100_KHZ,
2306                .def_i2c_bus  = 1,
2307                .tuner_type   = TUNER_ABSENT,
2308                .is_webcam    = 1,
2309                .input        = { {
2310                        .type     = EM28XX_VMUX_COMPOSITE,
2311                        .amux     = EM28XX_AMUX_VIDEO,
2312                        .gpio     = speedlink_vad_laplace_reg_seq,
2313                } },
2314                .buttons = speedlink_vad_laplace_buttons,
2315                .leds = speedlink_vad_laplace_leds,
2316        },
2317        /* 2013:0258 PCTV DVB-S2 Stick (461e)
2318         * Empia EM28178, Montage M88DS3103, Montage M88TS2022, Allegro A8293 */
2319        [EM28178_BOARD_PCTV_461E] = {
2320                .def_i2c_bus   = 1,
2321                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ,
2322                .name          = "PCTV DVB-S2 Stick (461e)",
2323                .tuner_type    = TUNER_ABSENT,
2324                .tuner_gpio    = pctv_461e,
2325                .has_dvb       = 1,
2326                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2327        },
2328        /* 2013:025f PCTV tripleStick (292e).
2329         * Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2157 */
2330        [EM28178_BOARD_PCTV_292E] = {
2331                .name          = "PCTV tripleStick (292e)",
2332                .def_i2c_bus   = 1,
2333                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ,
2334                .tuner_type    = TUNER_ABSENT,
2335                .tuner_gpio    = pctv_292e,
2336                .has_dvb       = 1,
2337                .ir_codes      = RC_MAP_PINNACLE_PCTV_HD,
2338        },
2339        [EM2861_BOARD_LEADTEK_VC100] = {
2340                .name          = "Leadtek VC100",
2341                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
2342                .decoder       = EM28XX_TVP5150,
2343                .input         = { {
2344                        .type     = EM28XX_VMUX_COMPOSITE,
2345                        .vmux     = TVP5150_COMPOSITE1,
2346                        .amux     = EM28XX_AMUX_LINE_IN,
2347                }, {
2348                        .type     = EM28XX_VMUX_SVIDEO,
2349                        .vmux     = TVP5150_SVIDEO,
2350                        .amux     = EM28XX_AMUX_LINE_IN,
2351                } },
2352        },
2353        /* eb1a:8179 Terratec Cinergy T2 Stick HD.
2354         * Empia EM28178, Silicon Labs Si2168, Silicon Labs Si2146 */
2355        [EM28178_BOARD_TERRATEC_T2_STICK_HD] = {
2356                .name          = "Terratec Cinergy T2 Stick HD",
2357                .def_i2c_bus   = 1,
2358                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE | EM28XX_I2C_FREQ_400_KHZ,
2359                .tuner_type    = TUNER_ABSENT,
2360                .tuner_gpio    = terratec_t2_stick_hd,
2361                .has_dvb       = 1,
2362                .ir_codes      = RC_MAP_TERRATEC_SLIM_2,
2363        },
2364
2365        /*
2366         * 3275:0085 PLEX PX-BCUD.
2367         * Empia EM28178, TOSHIBA TC90532XBG, Sharp QM1D1C0042
2368         */
2369        [EM28178_BOARD_PLEX_PX_BCUD] = {
2370                .name          = "PLEX PX-BCUD",
2371                .xclk          = EM28XX_XCLK_FREQUENCY_4_3MHZ,
2372                .def_i2c_bus   = 1,
2373                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE,
2374                .tuner_type    = TUNER_ABSENT,
2375                .tuner_gpio    = plex_px_bcud,
2376                .has_dvb       = 1,
2377        },
2378        /*
2379         * 2040:0265 Hauppauge WinTV-dualHD (DVB version).
2380         * Empia EM28274, 2x Silicon Labs Si2168, 2x Silicon Labs Si2157
2381         */
2382        [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB] = {
2383                .name          = "Hauppauge WinTV-dualHD DVB",
2384                .def_i2c_bus   = 1,
2385                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2386                                 EM28XX_I2C_FREQ_400_KHZ,
2387                .tuner_type    = TUNER_ABSENT,
2388                .tuner_gpio    = hauppauge_dualhd_dvb,
2389                .has_dvb       = 1,
2390                .ir_codes      = RC_MAP_HAUPPAUGE,
2391                .leds          = hauppauge_dualhd_leds,
2392        },
2393        /*
2394         * 2040:026d Hauppauge WinTV-dualHD (model 01595 - ATSC/QAM).
2395         * Empia EM28274, 2x LG LGDT3306A, 2x Silicon Labs Si2157
2396         */
2397        [EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595] = {
2398                .name          = "Hauppauge WinTV-dualHD 01595 ATSC/QAM",
2399                .def_i2c_bus   = 1,
2400                .i2c_speed     = EM28XX_I2C_CLK_WAIT_ENABLE |
2401                                 EM28XX_I2C_FREQ_400_KHZ,
2402                .tuner_type    = TUNER_ABSENT,
2403                .tuner_gpio    = hauppauge_dualhd_dvb,
2404                .has_dvb       = 1,
2405                .ir_codes      = RC_MAP_HAUPPAUGE,
2406                .leds          = hauppauge_dualhd_leds,
2407        },
2408};
2409EXPORT_SYMBOL_GPL(em28xx_boards);
2410
2411static const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
2412
2413/* table of devices that work with this driver */
2414struct usb_device_id em28xx_id_table[] = {
2415        { USB_DEVICE(0xeb1a, 0x2750),
2416                        .driver_info = EM2750_BOARD_UNKNOWN },
2417        { USB_DEVICE(0xeb1a, 0x2751),
2418                        .driver_info = EM2750_BOARD_UNKNOWN },
2419        { USB_DEVICE(0xeb1a, 0x2800),
2420                        .driver_info = EM2800_BOARD_UNKNOWN },
2421        { USB_DEVICE(0xeb1a, 0x2710),
2422                        .driver_info = EM2820_BOARD_UNKNOWN },
2423        { USB_DEVICE(0xeb1a, 0x2820),
2424                        .driver_info = EM2820_BOARD_UNKNOWN },
2425        { USB_DEVICE(0xeb1a, 0x2821),
2426                        .driver_info = EM2820_BOARD_UNKNOWN },
2427        { USB_DEVICE(0xeb1a, 0x2860),
2428                        .driver_info = EM2820_BOARD_UNKNOWN },
2429        { USB_DEVICE(0xeb1a, 0x2861),
2430                        .driver_info = EM2820_BOARD_UNKNOWN },
2431        { USB_DEVICE(0xeb1a, 0x2862),
2432                        .driver_info = EM2820_BOARD_UNKNOWN },
2433        { USB_DEVICE(0xeb1a, 0x2863),
2434                        .driver_info = EM2820_BOARD_UNKNOWN },
2435        { USB_DEVICE(0xeb1a, 0x2870),
2436                        .driver_info = EM2820_BOARD_UNKNOWN },
2437        { USB_DEVICE(0xeb1a, 0x2881),
2438                        .driver_info = EM2820_BOARD_UNKNOWN },
2439        { USB_DEVICE(0xeb1a, 0x2883),
2440                        .driver_info = EM2820_BOARD_UNKNOWN },
2441        { USB_DEVICE(0xeb1a, 0x2868),
2442                        .driver_info = EM2820_BOARD_UNKNOWN },
2443        { USB_DEVICE(0xeb1a, 0x2875),
2444                        .driver_info = EM2820_BOARD_UNKNOWN },
2445        { USB_DEVICE(0xeb1a, 0x2885), /* MSI Digivox Trio */
2446                        .driver_info = EM2884_BOARD_TERRATEC_H5 },
2447        { USB_DEVICE(0xeb1a, 0xe300),
2448                        .driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
2449        { USB_DEVICE(0xeb1a, 0xe303),
2450                        .driver_info = EM2860_BOARD_KAIOMY_TVNPC_U2 },
2451        { USB_DEVICE(0xeb1a, 0xe305),
2452                        .driver_info = EM2880_BOARD_KWORLD_DVB_305U },
2453        { USB_DEVICE(0xeb1a, 0xe310),
2454                        .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
2455        { USB_DEVICE(0xeb1a, 0xa313),
2456                .driver_info = EM2882_BOARD_KWORLD_ATSC_315U },
2457        { USB_DEVICE(0xeb1a, 0xa316),
2458                        .driver_info = EM2883_BOARD_KWORLD_HYBRID_330U },
2459        { USB_DEVICE(0xeb1a, 0xe320),
2460                        .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
2461        { USB_DEVICE(0xeb1a, 0xe323),
2462                        .driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
2463        { USB_DEVICE(0xeb1a, 0xe350),
2464                        .driver_info = EM2870_BOARD_KWORLD_350U },
2465        { USB_DEVICE(0xeb1a, 0xe355),
2466                        .driver_info = EM2870_BOARD_KWORLD_355U },
2467        { USB_DEVICE(0xeb1a, 0x2801),
2468                        .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
2469        { USB_DEVICE(0xeb1a, 0xe357),
2470                        .driver_info = EM2870_BOARD_KWORLD_355U },
2471        { USB_DEVICE(0xeb1a, 0xe359),
2472                        .driver_info = EM2870_BOARD_KWORLD_355U },
2473        { USB_DEVICE(0x1b80, 0xe302),
2474                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kaiser Baas Video to DVD maker */
2475        { USB_DEVICE(0x1b80, 0xe304),
2476                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kworld DVD Maker 2 */
2477        { USB_DEVICE(0x0ccd, 0x0036),
2478                        .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
2479        { USB_DEVICE(0x0ccd, 0x004c),
2480                        .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
2481        { USB_DEVICE(0x0ccd, 0x004f),
2482                        .driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
2483        { USB_DEVICE(0x0ccd, 0x005e),
2484                        .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
2485        { USB_DEVICE(0x0ccd, 0x0042),
2486                        .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
2487        { USB_DEVICE(0x0ccd, 0x0043),
2488                        .driver_info = EM2870_BOARD_TERRATEC_XS_MT2060 },
2489        { USB_DEVICE(0x0ccd, 0x008e),   /* Cinergy HTC USB XS Rev. 1 */
2490                        .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2491        { USB_DEVICE(0x0ccd, 0x00ac),   /* Cinergy HTC USB XS Rev. 2 */
2492                        .driver_info = EM2884_BOARD_TERRATEC_HTC_USB_XS },
2493        { USB_DEVICE(0x0ccd, 0x10a2),   /* H5 Rev. 1 */
2494                        .driver_info = EM2884_BOARD_TERRATEC_H5 },
2495        { USB_DEVICE(0x0ccd, 0x10ad),   /* H5 Rev. 2 */
2496                        .driver_info = EM2884_BOARD_TERRATEC_H5 },
2497        { USB_DEVICE(0x0ccd, 0x10b6),   /* H5 Rev. 3 */
2498                        .driver_info = EM2884_BOARD_TERRATEC_H5 },
2499        { USB_DEVICE(0x0ccd, 0x0084),
2500                        .driver_info = EM2860_BOARD_TERRATEC_AV350 },
2501        { USB_DEVICE(0x0ccd, 0x0096),
2502                        .driver_info = EM2860_BOARD_TERRATEC_GRABBY },
2503        { USB_DEVICE(0x0ccd, 0x10AF),
2504                        .driver_info = EM2860_BOARD_TERRATEC_GRABBY },
2505        { USB_DEVICE(0x0ccd, 0x00b2),
2506                        .driver_info = EM2884_BOARD_CINERGY_HTC_STICK },
2507        { USB_DEVICE(0x0fd9, 0x0018),
2508                        .driver_info = EM2884_BOARD_ELGATO_EYETV_HYBRID_2008 },
2509        { USB_DEVICE(0x0fd9, 0x0033),
2510                        .driver_info = EM2860_BOARD_ELGATO_VIDEO_CAPTURE },
2511        { USB_DEVICE(0x185b, 0x2870),
2512                        .driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
2513        { USB_DEVICE(0x185b, 0x2041),
2514                        .driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
2515        { USB_DEVICE(0x2040, 0x4200),
2516                        .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
2517        { USB_DEVICE(0x2040, 0x4201),
2518                        .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
2519        { USB_DEVICE(0x2040, 0x6500),
2520                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
2521        { USB_DEVICE(0x2040, 0x6502),
2522                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
2523        { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
2524                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2525        { USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
2526                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2527        { USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
2528                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
2529        { USB_DEVICE(0x2040, 0x651f),
2530                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
2531        { USB_DEVICE(0x2040, 0x0265),
2532                        .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB },
2533        { USB_DEVICE(0x2040, 0x026d),
2534                        .driver_info = EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595 },
2535        { USB_DEVICE(0x0438, 0xb002),
2536                        .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
2537        { USB_DEVICE(0x2001, 0xf112),
2538                        .driver_info = EM2820_BOARD_DLINK_USB_TV },
2539        { USB_DEVICE(0x2304, 0x0207),
2540                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2541        { USB_DEVICE(0x2304, 0x0208),
2542                        .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
2543        { USB_DEVICE(0x2304, 0x021a),
2544                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2545        { USB_DEVICE(0x2304, 0x0226),
2546                        .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO_330E },
2547        { USB_DEVICE(0x2304, 0x0227),
2548                        .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
2549        { USB_DEVICE(0x2304, 0x023f),
2550                        .driver_info = EM2874_BOARD_PCTV_HD_MINI_80E },
2551        { USB_DEVICE(0x0413, 0x6023),
2552                        .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
2553        { USB_DEVICE(0x093b, 0xa003),
2554                       .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
2555        { USB_DEVICE(0x093b, 0xa005),
2556                        .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
2557        { USB_DEVICE(0x04bb, 0x0515),
2558                        .driver_info = EM2820_BOARD_IODATA_GVMVP_SZ },
2559        { USB_DEVICE(0xeb1a, 0x50a6),
2560                        .driver_info = EM2860_BOARD_GADMEI_UTV330 },
2561        { USB_DEVICE(0x1b80, 0xa340),
2562                        .driver_info = EM2870_BOARD_KWORLD_A340 },
2563        { USB_DEVICE(0x1b80, 0xe346),
2564                        .driver_info = EM2874_BOARD_KWORLD_UB435Q_V2 },
2565        { USB_DEVICE(0x1b80, 0xe34c),
2566                        .driver_info = EM2874_BOARD_KWORLD_UB435Q_V3 },
2567        { USB_DEVICE(0x2013, 0x024f),
2568                        .driver_info = EM28174_BOARD_PCTV_290E },
2569        { USB_DEVICE(0x2013, 0x024c),
2570                        .driver_info = EM28174_BOARD_PCTV_460E },
2571        { USB_DEVICE(0x2040, 0x1605),
2572                        .driver_info = EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C },
2573        { USB_DEVICE(0x1b80, 0xe755),
2574                        .driver_info = EM2884_BOARD_C3TECH_DIGITAL_DUO },
2575        { USB_DEVICE(0xeb1a, 0x5006),
2576                        .driver_info = EM2860_BOARD_HT_VIDBOX_NW03 },
2577        { USB_DEVICE(0x1b80, 0xe309), /* Sveon STV40 */
2578                        .driver_info = EM2860_BOARD_EASYCAP },
2579        { USB_DEVICE(0x1b80, 0xe425),
2580                        .driver_info = EM2874_BOARD_MAXMEDIA_UB425_TC },
2581        { USB_DEVICE(0x2304, 0x0242),
2582                        .driver_info = EM2884_BOARD_PCTV_510E },
2583        { USB_DEVICE(0x2013, 0x0251),
2584                        .driver_info = EM2884_BOARD_PCTV_520E },
2585        { USB_DEVICE(0x1b80, 0xe1cc),
2586                        .driver_info = EM2874_BOARD_DELOCK_61959 },
2587        { USB_DEVICE(0x1ae7, 0x9003),
2588                        .driver_info = EM2765_BOARD_SPEEDLINK_VAD_LAPLACE },
2589        { USB_DEVICE(0x1ae7, 0x9004),
2590                        .driver_info = EM2765_BOARD_SPEEDLINK_VAD_LAPLACE },
2591        { USB_DEVICE(0x2013, 0x0258),
2592                        .driver_info = EM28178_BOARD_PCTV_461E },
2593        { USB_DEVICE(0x2013, 0x025f),
2594                        .driver_info = EM28178_BOARD_PCTV_292E },
2595        { USB_DEVICE(0x2040, 0x0264), /* Hauppauge WinTV-soloHD */
2596                        .driver_info = EM28178_BOARD_PCTV_292E },
2597        { USB_DEVICE(0x0413, 0x6f07),
2598                        .driver_info = EM2861_BOARD_LEADTEK_VC100 },
2599        { USB_DEVICE(0xeb1a, 0x8179),
2600                        .driver_info = EM28178_BOARD_TERRATEC_T2_STICK_HD },
2601        { USB_DEVICE(0x3275, 0x0085),
2602                        .driver_info = EM28178_BOARD_PLEX_PX_BCUD },
2603        { USB_DEVICE(0xeb1a, 0x5051), /* Ion Video 2 PC MKII / Startech svid2usb23 / Raygo R12-41373 */
2604                        .driver_info = EM2860_BOARD_TVP5150_REFERENCE_DESIGN },
2605        { },
2606};
2607MODULE_DEVICE_TABLE(usb, em28xx_id_table);
2608
2609/*
2610 * EEPROM hash table for devices with generic USB IDs
2611 */
2612static struct em28xx_hash_table em28xx_eeprom_hash[] = {
2613        /* P/N: SA 60002070465 Tuner: TVF7533-MF */
2614        {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
2615        {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
2616        {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
2617        {0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
2618        {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
2619        {0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
2620        {0x63f653bd, EM2870_BOARD_REDDO_DVB_C_USB_BOX, TUNER_ABSENT},
2621        {0x4e913442, EM2882_BOARD_DIKOM_DK300, TUNER_XC2028},
2622};
2623
2624/* I2C devicelist hash table for devices with generic USB IDs */
2625static struct em28xx_hash_table em28xx_i2c_hash[] = {
2626        {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
2627        {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
2628        {0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
2629        {0x77800080, EM2860_BOARD_TVP5150_REFERENCE_DESIGN, TUNER_ABSENT},
2630        {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
2631        {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
2632        {0x6b800080, EM2874_BOARD_LEADERSHIP_ISDBT, TUNER_ABSENT},
2633};
2634
2635/* NOTE: introduce a separate hash table for devices with 16 bit eeproms */
2636
2637int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
2638{
2639        struct em28xx_i2c_bus *i2c_bus = ptr;
2640        struct em28xx *dev = i2c_bus->dev;
2641        int rc = 0;
2642
2643        if (dev->tuner_type != TUNER_XC2028 && dev->tuner_type != TUNER_XC5000)
2644                return 0;
2645
2646        if (command != XC2028_TUNER_RESET && command != XC5000_TUNER_RESET)
2647                return 0;
2648
2649        rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
2650
2651        return rc;
2652}
2653EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
2654
2655static inline void em28xx_set_model(struct em28xx *dev)
2656{
2657        dev->board = em28xx_boards[dev->model];
2658
2659        /* Those are the default values for the majority of boards
2660           Use those values if not specified otherwise at boards entry
2661         */
2662        if (!dev->board.xclk)
2663                dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
2664                                  EM28XX_XCLK_FREQUENCY_12MHZ;
2665
2666        if (!dev->board.i2c_speed)
2667                dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
2668                                       EM28XX_I2C_FREQ_100_KHZ;
2669
2670        /* Should be initialized early, for I2C to work */
2671        dev->def_i2c_bus = dev->board.def_i2c_bus;
2672}
2673
2674/* Wait until AC97_RESET reports the expected value reliably before proceeding.
2675 * We also check that two unrelated registers accesses don't return the same
2676 * value to avoid premature return.
2677 * This procedure helps ensuring AC97 register accesses are reliable.
2678 */
2679static int em28xx_wait_until_ac97_features_equals(struct em28xx *dev,
2680                                                  int expected_feat)
2681{
2682        unsigned long timeout = jiffies + msecs_to_jiffies(2000);
2683        int feat, powerdown;
2684
2685        while (time_is_after_jiffies(timeout)) {
2686                feat = em28xx_read_ac97(dev, AC97_RESET);
2687                if (feat < 0)
2688                        return feat;
2689
2690                powerdown = em28xx_read_ac97(dev, AC97_POWERDOWN);
2691                if (powerdown < 0)
2692                        return powerdown;
2693
2694                if (feat == expected_feat && feat != powerdown)
2695                        return 0;
2696
2697                msleep(50);
2698        }
2699
2700        dev_warn(&dev->intf->dev, "AC97 registers access is not reliable !\n");
2701        return -ETIMEDOUT;
2702}
2703
2704/* Since em28xx_pre_card_setup() requires a proper dev->model,
2705 * this won't work for boards with generic PCI IDs
2706 */
2707static void em28xx_pre_card_setup(struct em28xx *dev)
2708{
2709        /* Set the initial XCLK and I2C clock values based on the board
2710           definition */
2711        em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
2712        if (!dev->board.is_em2800)
2713                em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
2714        msleep(50);
2715
2716        /* request some modules */
2717        switch (dev->model) {
2718        case EM2861_BOARD_PLEXTOR_PX_TV100U:
2719                /* Sets the msp34xx I2S speed */
2720                dev->i2s_speed = 2048000;
2721                break;
2722        case EM2861_BOARD_KWORLD_PVRTV_300U:
2723        case EM2880_BOARD_KWORLD_DVB_305U:
2724                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x6d);
2725                msleep(10);
2726                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0x7d);
2727                msleep(10);
2728                break;
2729        case EM2870_BOARD_COMPRO_VIDEOMATE:
2730                /* TODO: someone can do some cleanup here...
2731                         not everything's needed */
2732                em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2733                msleep(10);
2734                em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
2735                msleep(10);
2736                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2737                mdelay(70);
2738                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2739                mdelay(70);
2740                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xdc);
2741                mdelay(70);
2742                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfc);
2743                mdelay(70);
2744                break;
2745        case EM2870_BOARD_TERRATEC_XS_MT2060:
2746                /* this device needs some gpio writes to get the DVB-T
2747                   demod work */
2748                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2749                mdelay(70);
2750                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2751                mdelay(70);
2752                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2753                mdelay(70);
2754                break;
2755        case EM2870_BOARD_PINNACLE_PCTV_DVB:
2756                /* this device needs some gpio writes to get the
2757                   DVB-T demod work */
2758                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2759                mdelay(70);
2760                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xde);
2761                mdelay(70);
2762                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2763                mdelay(70);
2764                break;
2765        case EM2820_BOARD_GADMEI_UTV310:
2766        case EM2820_BOARD_MSI_VOX_USB_2:
2767                /* enables audio for that devices */
2768                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2769                break;
2770
2771        case EM2882_BOARD_KWORLD_ATSC_315U:
2772                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
2773                msleep(10);
2774                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2775                msleep(10);
2776                em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2777                msleep(10);
2778                em28xx_write_reg(dev, EM2880_R04_GPO, 0x08);
2779                msleep(10);
2780                break;
2781
2782        case EM2860_BOARD_KAIOMY_TVNPC_U2:
2783                em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
2784                em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
2785                em28xx_write_regs(dev, 0x0d, "\x42", 1);
2786                em28xx_write_regs(dev, 0x08, "\xfd", 1);
2787                msleep(10);
2788                em28xx_write_regs(dev, 0x08, "\xff", 1);
2789                msleep(10);
2790                em28xx_write_regs(dev, 0x08, "\x7f", 1);
2791                msleep(10);
2792                em28xx_write_regs(dev, 0x08, "\x6b", 1);
2793
2794                break;
2795        case EM2860_BOARD_EASYCAP:
2796                em28xx_write_regs(dev, 0x08, "\xf8", 1);
2797                break;
2798
2799        case EM2820_BOARD_IODATA_GVMVP_SZ:
2800                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xff);
2801                msleep(70);
2802                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf7);
2803                msleep(10);
2804                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfe);
2805                msleep(70);
2806                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2807                msleep(70);
2808                break;
2809
2810        case EM2860_BOARD_TERRATEC_GRABBY:
2811                /* HACK?: Ensure AC97 register reading is reliable before
2812                 * proceeding. In practice, this will wait about 1.6 seconds.
2813                 */
2814                em28xx_wait_until_ac97_features_equals(dev, 0x6a90);
2815                break;
2816        }
2817
2818        em28xx_gpio_set(dev, dev->board.tuner_gpio);
2819        em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2820
2821        /* Unlock device */
2822        em28xx_set_mode(dev, EM28XX_SUSPEND);
2823}
2824
2825static int em28xx_hint_board(struct em28xx *dev)
2826{
2827        int i;
2828
2829        if (dev->board.is_webcam) {
2830                if (dev->em28xx_sensor == EM28XX_MT9V011) {
2831                        dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
2832                } else if (dev->em28xx_sensor == EM28XX_MT9M001 ||
2833                           dev->em28xx_sensor == EM28XX_MT9M111) {
2834                        dev->model = EM2750_BOARD_UNKNOWN;
2835                }
2836                /* FIXME: IMPROVE ! */
2837
2838                return 0;
2839        }
2840
2841        /* HINT method: EEPROM
2842         *
2843         * This method works only for boards with eeprom.
2844         * Uses a hash of all eeprom bytes. The hash should be
2845         * unique for a vendor/tuner pair.
2846         * There are a high chance that tuners for different
2847         * video standards produce different hashes.
2848         */
2849        for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
2850                if (dev->hash == em28xx_eeprom_hash[i].hash) {
2851                        dev->model = em28xx_eeprom_hash[i].model;
2852                        dev->tuner_type = em28xx_eeprom_hash[i].tuner;
2853
2854                        dev_err(&dev->intf->dev,
2855                                "Your board has no unique USB ID.\n"
2856                                "A hint were successfully done, based on eeprom hash.\n"
2857                                "This method is not 100%% failproof.\n"
2858                                "If the board were missdetected, please email this log to:\n"
2859                                "\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2860                                "Board detected as %s\n",
2861                               em28xx_boards[dev->model].name);
2862
2863                        return 0;
2864                }
2865        }
2866
2867        /* HINT method: I2C attached devices
2868         *
2869         * This method works for all boards.
2870         * Uses a hash of i2c scanned devices.
2871         * Devices with the same i2c attached chips will
2872         * be considered equal.
2873         * This method is less precise than the eeprom one.
2874         */
2875
2876        /* user did not request i2c scanning => do it now */
2877        if (!dev->i2c_hash)
2878                em28xx_do_i2c_scan(dev, dev->def_i2c_bus);
2879
2880        for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
2881                if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2882                        dev->model = em28xx_i2c_hash[i].model;
2883                        dev->tuner_type = em28xx_i2c_hash[i].tuner;
2884                        dev_err(&dev->intf->dev,
2885                                "Your board has no unique USB ID.\n"
2886                                "A hint were successfully done, based on i2c devicelist hash.\n"
2887                                "This method is not 100%% failproof.\n"
2888                                "If the board were missdetected, please email this log to:\n"
2889                                "\tV4L Mailing List  <linux-media@vger.kernel.org>\n"
2890                                "Board detected as %s\n",
2891                                em28xx_boards[dev->model].name);
2892
2893                        return 0;
2894                }
2895        }
2896
2897        dev_err(&dev->intf->dev,
2898                "Your board has no unique USB ID and thus need a hint to be detected.\n"
2899                "You may try to use card=<n> insmod option to workaround that.\n"
2900                "Please send an email with this log to:\n"
2901                "\tV4L Mailing List <linux-media@vger.kernel.org>\n"
2902                "Board eeprom hash is 0x%08lx\n"
2903                "Board i2c devicelist hash is 0x%08lx\n",
2904                dev->hash, dev->i2c_hash);
2905
2906        dev_err(&dev->intf->dev,
2907                "Here is a list of valid choices for the card=<n> insmod option:\n");
2908        for (i = 0; i < em28xx_bcount; i++) {
2909                dev_err(&dev->intf->dev,
2910                        "    card=%d -> %s\n", i, em28xx_boards[i].name);
2911        }
2912        return -1;
2913}
2914
2915static void em28xx_card_setup(struct em28xx *dev)
2916{
2917        /*
2918         * If the device can be a webcam, seek for a sensor.
2919         * If sensor is not found, then it isn't a webcam.
2920         */
2921        if (dev->board.is_webcam) {
2922                em28xx_detect_sensor(dev);
2923                if (dev->em28xx_sensor == EM28XX_NOSENSOR)
2924                        /* NOTE: error/unknown sensor/no sensor */
2925                        dev->board.is_webcam = 0;
2926        }
2927
2928        switch (dev->model) {
2929        case EM2750_BOARD_UNKNOWN:
2930        case EM2820_BOARD_UNKNOWN:
2931        case EM2800_BOARD_UNKNOWN:
2932                /*
2933                 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
2934                 *
2935                 * This occurs because they share identical USB vendor and
2936                 * product IDs.
2937                 *
2938                 * What we do here is look up the EEPROM hash of the K-WORLD
2939                 * and if it is found then we decide that we do not have
2940                 * a DIGIVOX and reset the device to the K-WORLD instead.
2941                 *
2942                 * This solution is only valid if they do not share eeprom
2943                 * hash identities which has not been determined as yet.
2944                 */
2945                if (em28xx_hint_board(dev) < 0)
2946                        dev_err(&dev->intf->dev, "Board not discovered\n");
2947                else {
2948                        em28xx_set_model(dev);
2949                        em28xx_pre_card_setup(dev);
2950                }
2951                break;
2952        default:
2953                em28xx_set_model(dev);
2954        }
2955
2956        dev_info(&dev->intf->dev, "Identified as %s (card=%d)\n",
2957                dev->board.name, dev->model);
2958
2959        dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2960
2961        /* request some modules */
2962        switch (dev->model) {
2963        case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2964        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2965        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2966        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2967        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2968        case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
2969        case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_DVB:
2970        case EM28174_BOARD_HAUPPAUGE_WINTV_DUALHD_01595:
2971        {
2972                struct tveeprom tv;
2973
2974                if (dev->eedata == NULL)
2975                        break;
2976#if defined(CONFIG_MODULES) && defined(MODULE)
2977                request_module("tveeprom");
2978#endif
2979                /* Call first TVeeprom */
2980
2981                tveeprom_hauppauge_analog(&tv, dev->eedata);
2982
2983                dev->tuner_type = tv.tuner_type;
2984
2985                if (tv.audio_processor == TVEEPROM_AUDPROC_MSP) {
2986                        dev->i2s_speed = 2048000;
2987                        dev->board.has_msp34xx = 1;
2988                }
2989                break;
2990        }
2991        case EM2882_BOARD_KWORLD_ATSC_315U:
2992                em28xx_write_reg(dev, 0x0d, 0x42);
2993                msleep(10);
2994                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xfd);
2995                msleep(10);
2996                break;
2997        case EM2820_BOARD_KWORLD_PVRTV2800RF:
2998                /* GPIO enables sound on KWORLD PVR TV 2800RF */
2999                em28xx_write_reg(dev, EM2820_R08_GPIO_CTRL, 0xf9);
3000                break;
3001        case EM2820_BOARD_UNKNOWN:
3002        case EM2800_BOARD_UNKNOWN:
3003                /*
3004                 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
3005                 *
3006                 * This occurs because they share identical USB vendor and
3007                 * product IDs.
3008                 *
3009                 * What we do here is look up the EEPROM hash of the K-WORLD
3010                 * and if it is found then we decide that we do not have
3011                 * a DIGIVOX and reset the device to the K-WORLD instead.
3012                 *
3013                 * This solution is only valid if they do not share eeprom
3014                 * hash identities which has not been determined as yet.
3015                 */
3016        case EM2880_BOARD_MSI_DIGIVOX_AD:
3017                if (!em28xx_hint_board(dev))
3018                        em28xx_set_model(dev);
3019
3020                /* In cases where we had to use a board hint, the call to
3021                   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3022                   so make the call now so the analog GPIOs are set properly
3023                   before probing the i2c bus. */
3024                em28xx_gpio_set(dev, dev->board.tuner_gpio);
3025                em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3026                break;
3027
3028                /*
3029                 * The Dikom DK300 is detected as an Kworld VS-DVB-T 323UR.
3030                 *
3031                 * This occurs because they share identical USB vendor and
3032                 * product IDs.
3033                 *
3034                 * What we do here is look up the EEPROM hash of the Dikom
3035                 * and if it is found then we decide that we do not have
3036                 * a Kworld and reset the device to the Dikom instead.
3037                 *
3038                 * This solution is only valid if they do not share eeprom
3039                 * hash identities which has not been determined as yet.
3040                 */
3041        case EM2882_BOARD_KWORLD_VS_DVBT:
3042                if (!em28xx_hint_board(dev))
3043                        em28xx_set_model(dev);
3044
3045                /* In cases where we had to use a board hint, the call to
3046                   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
3047                   so make the call now so the analog GPIOs are set properly
3048                   before probing the i2c bus. */
3049                em28xx_gpio_set(dev, dev->board.tuner_gpio);
3050                em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
3051                break;
3052        }
3053
3054        if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
3055                dev_err(&dev->intf->dev,
3056                        "\n\n"
3057                        "The support for this board weren't valid yet.\n"
3058                        "Please send a report of having this working\n"
3059                        "not to V4L mailing list (and/or to other addresses)\n\n");
3060        }
3061
3062        /* Free eeprom data memory */
3063        kfree(dev->eedata);
3064        dev->eedata = NULL;
3065
3066        /* Allow override tuner type by a module parameter */
3067        if (tuner >= 0)
3068                dev->tuner_type = tuner;
3069}
3070
3071void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
3072{
3073        memset(ctl, 0, sizeof(*ctl));
3074
3075        ctl->fname   = XC2028_DEFAULT_FIRMWARE;
3076        ctl->max_len = 64;
3077        ctl->mts = em28xx_boards[dev->model].mts_firmware;
3078
3079        switch (dev->model) {
3080        case EM2880_BOARD_EMPIRE_DUAL_TV:
3081        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
3082        case EM2882_BOARD_TERRATEC_HYBRID_XS:
3083                ctl->demod = XC3028_FE_ZARLINK456;
3084                break;
3085        case EM2880_BOARD_TERRATEC_HYBRID_XS:
3086        case EM2880_BOARD_TERRATEC_HYBRID_XS_FR:
3087        case EM2881_BOARD_PINNACLE_HYBRID_PRO:
3088                ctl->demod = XC3028_FE_ZARLINK456;
3089                break;
3090        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
3091        case EM2882_BOARD_PINNACLE_HYBRID_PRO_330E:
3092                ctl->demod = XC3028_FE_DEFAULT;
3093                break;
3094        case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
3095                ctl->demod = XC3028_FE_DEFAULT;
3096                ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3097                break;
3098        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
3099        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
3100        case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
3101                /* FIXME: Better to specify the needed IF */
3102                ctl->demod = XC3028_FE_DEFAULT;
3103                break;
3104        case EM2883_BOARD_KWORLD_HYBRID_330U:
3105        case EM2882_BOARD_DIKOM_DK300:
3106        case EM2882_BOARD_KWORLD_VS_DVBT:
3107                ctl->demod = XC3028_FE_CHINA;
3108                ctl->fname = XC2028_DEFAULT_FIRMWARE;
3109                break;
3110        case EM2882_BOARD_EVGA_INDTUBE:
3111                ctl->demod = XC3028_FE_CHINA;
3112                ctl->fname = XC3028L_DEFAULT_FIRMWARE;
3113                break;
3114        default:
3115                ctl->demod = XC3028_FE_OREN538;
3116        }
3117}
3118EXPORT_SYMBOL_GPL(em28xx_setup_xc3028);
3119
3120static void request_module_async(struct work_struct *work)
3121{
3122        struct em28xx *dev = container_of(work,
3123                             struct em28xx, request_module_wk);
3124
3125        /*
3126         * The em28xx extensions can be modules or builtin. If the
3127         * modules are already loaded or are built in, those extensions
3128         * can be initialised right now. Otherwise, the module init
3129         * code will do it.
3130         */
3131
3132        /*
3133         * Devicdes with an audio-only interface also have a V4L/DVB/RC
3134         * interface. Don't register extensions twice on those devices.
3135         */
3136        if (dev->is_audio_only) {
3137#if defined(CONFIG_MODULES) && defined(MODULE)
3138                request_module("em28xx-alsa");
3139#endif
3140                return;
3141        }
3142
3143        em28xx_init_extension(dev);
3144
3145#if defined(CONFIG_MODULES) && defined(MODULE)
3146        if (dev->has_video)
3147                request_module("em28xx-v4l");
3148        if (dev->usb_audio_type == EM28XX_USB_AUDIO_CLASS)
3149                request_module("snd-usb-audio");
3150        else if (dev->usb_audio_type == EM28XX_USB_AUDIO_VENDOR)
3151                request_module("em28xx-alsa");
3152        if (dev->board.has_dvb)
3153                request_module("em28xx-dvb");
3154        if (dev->board.buttons ||
3155            ((dev->board.ir_codes || dev->board.has_ir_i2c) && !disable_ir))
3156                request_module("em28xx-rc");
3157#endif /* CONFIG_MODULES */
3158}
3159
3160static void request_modules(struct em28xx *dev)
3161{
3162        INIT_WORK(&dev->request_module_wk, request_module_async);
3163        schedule_work(&dev->request_module_wk);
3164}
3165
3166static void flush_request_modules(struct em28xx *dev)
3167{
3168        flush_work(&dev->request_module_wk);
3169}
3170
3171static int em28xx_media_device_init(struct em28xx *dev,
3172                                    struct usb_device *udev)
3173{
3174#ifdef CONFIG_MEDIA_CONTROLLER
3175        struct media_device *mdev;
3176
3177        mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
3178        if (!mdev)
3179                return -ENOMEM;
3180
3181        if (udev->product)
3182                media_device_usb_init(mdev, udev, udev->product);
3183        else if (udev->manufacturer)
3184                media_device_usb_init(mdev, udev, udev->manufacturer);
3185        else
3186                media_device_usb_init(mdev, udev, dev_name(&dev->intf->dev));
3187
3188        dev->media_dev = mdev;
3189#endif
3190        return 0;
3191}
3192
3193static void em28xx_unregister_media_device(struct em28xx *dev)
3194{
3195
3196#ifdef CONFIG_MEDIA_CONTROLLER
3197        if (dev->media_dev) {
3198                media_device_unregister(dev->media_dev);
3199                media_device_cleanup(dev->media_dev);
3200                kfree(dev->media_dev);
3201                dev->media_dev = NULL;
3202        }
3203#endif
3204}
3205
3206/*
3207 * em28xx_release_resources()
3208 * unregisters the v4l2,i2c and usb devices
3209 * called when the device gets disconnected or at module unload
3210*/
3211static void em28xx_release_resources(struct em28xx *dev)
3212{
3213        struct usb_device *udev = interface_to_usbdev(dev->intf);
3214
3215        /*FIXME: I2C IR should be disconnected */
3216
3217        mutex_lock(&dev->lock);
3218
3219        em28xx_unregister_media_device(dev);
3220
3221        if (dev->def_i2c_bus)
3222                em28xx_i2c_unregister(dev, 1);
3223        em28xx_i2c_unregister(dev, 0);
3224
3225        usb_put_dev(udev);
3226
3227        /* Mark device as unused */
3228        clear_bit(dev->devno, em28xx_devused);
3229
3230        mutex_unlock(&dev->lock);
3231};
3232
3233/**
3234 * em28xx_free_device() - Free em28xx device
3235 *
3236 * @ref: struct kref for em28xx device
3237 *
3238 * This is called when all extensions and em28xx core unregisters a device
3239 */
3240void em28xx_free_device(struct kref *ref)
3241{
3242        struct em28xx *dev = kref_to_dev(ref);
3243
3244        dev_info(&dev->intf->dev, "Freeing device\n");
3245
3246        if (!dev->disconnected)
3247                em28xx_release_resources(dev);
3248
3249        kfree(dev->alt_max_pkt_size_isoc);
3250        kfree(dev);
3251}
3252EXPORT_SYMBOL_GPL(em28xx_free_device);
3253
3254/*
3255 * em28xx_init_dev()
3256 * allocates and inits the device structs, registers i2c bus and v4l device
3257 */
3258static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
3259                           struct usb_interface *interface,
3260                           int minor)
3261{
3262        int retval;
3263        const char *chip_name = NULL;
3264
3265        dev->intf = interface;
3266        mutex_init(&dev->ctrl_urb_lock);
3267        spin_lock_init(&dev->slock);
3268
3269        dev->em28xx_write_regs = em28xx_write_regs;
3270        dev->em28xx_read_reg = em28xx_read_reg;
3271        dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
3272        dev->em28xx_write_regs_req = em28xx_write_regs_req;
3273        dev->em28xx_read_reg_req = em28xx_read_reg_req;
3274        dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
3275
3276        em28xx_set_model(dev);
3277
3278        dev->wait_after_write = 5;
3279
3280        /* Based on the Chip ID, set the device configuration */
3281        retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
3282        if (retval > 0) {
3283                dev->chip_id = retval;
3284
3285                switch (dev->chip_id) {
3286                case CHIP_ID_EM2800:
3287                        chip_name = "em2800";
3288                        break;
3289                case CHIP_ID_EM2710:
3290                        chip_name = "em2710";
3291                        break;
3292                case CHIP_ID_EM2750:
3293                        chip_name = "em2750";
3294                        break;
3295                case CHIP_ID_EM2765:
3296                        chip_name = "em2765";
3297                        dev->wait_after_write = 0;
3298                        dev->is_em25xx = 1;
3299                        dev->eeprom_addrwidth_16bit = 1;
3300                        break;
3301                case CHIP_ID_EM2820:
3302                        chip_name = "em2710/2820";
3303                        if (le16_to_cpu(udev->descriptor.idVendor) == 0xeb1a) {
3304                                __le16 idProd = udev->descriptor.idProduct;
3305
3306                                if (le16_to_cpu(idProd) == 0x2710)
3307                                        chip_name = "em2710";
3308                                else if (le16_to_cpu(idProd) == 0x2820)
3309                                        chip_name = "em2820";
3310                        }
3311                        /* NOTE: the em2820 is used in webcams, too ! */
3312                        break;
3313                case CHIP_ID_EM2840:
3314                        chip_name = "em2840";
3315                        break;
3316                case CHIP_ID_EM2860:
3317                        chip_name = "em2860";
3318                        break;
3319                case CHIP_ID_EM2870:
3320                        chip_name = "em2870";
3321                        dev->wait_after_write = 0;
3322                        break;
3323                case CHIP_ID_EM2874:
3324                        chip_name = "em2874";
3325                        dev->wait_after_write = 0;
3326                        dev->eeprom_addrwidth_16bit = 1;
3327                        break;
3328                case CHIP_ID_EM28174:
3329                        chip_name = "em28174";
3330                        dev->wait_after_write = 0;
3331                        dev->eeprom_addrwidth_16bit = 1;
3332                        break;
3333                case CHIP_ID_EM28178:
3334                        chip_name = "em28178";
3335                        dev->wait_after_write = 0;
3336                        dev->eeprom_addrwidth_16bit = 1;
3337                        break;
3338                case CHIP_ID_EM2883:
3339                        chip_name = "em2882/3";
3340                        dev->wait_after_write = 0;
3341                        break;
3342                case CHIP_ID_EM2884:
3343                        chip_name = "em2884";
3344                        dev->wait_after_write = 0;
3345                        dev->eeprom_addrwidth_16bit = 1;
3346                        break;
3347                }
3348        }
3349        if (!chip_name)
3350                dev_info(&dev->intf->dev,
3351                         "unknown em28xx chip ID (%d)\n", dev->chip_id);
3352        else
3353                dev_info(&dev->intf->dev, "chip ID is %s\n", chip_name);
3354
3355        em28xx_media_device_init(dev, udev);
3356
3357        if (dev->is_audio_only) {
3358                retval = em28xx_audio_setup(dev);
3359                if (retval)
3360                        return -ENODEV;
3361                em28xx_init_extension(dev);
3362
3363                return 0;
3364        }
3365
3366        em28xx_pre_card_setup(dev);
3367
3368        if (!dev->board.is_em2800) {
3369                /* Resets I2C speed */
3370                retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
3371                if (retval < 0) {
3372                        dev_err(&dev->intf->dev,
3373                               "%s: em28xx_write_reg failed! retval [%d]\n",
3374                               __func__, retval);
3375                        return retval;
3376                }
3377        }
3378
3379        rt_mutex_init(&dev->i2c_bus_lock);
3380
3381        /* register i2c bus 0 */
3382        if (dev->board.is_em2800)
3383                retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM2800);
3384        else
3385                retval = em28xx_i2c_register(dev, 0, EM28XX_I2C_ALGO_EM28XX);
3386        if (retval < 0) {
3387                dev_err(&dev->intf->dev,
3388                        "%s: em28xx_i2c_register bus 0 - error [%d]!\n",
3389                       __func__, retval);
3390                return retval;
3391        }
3392
3393        /* register i2c bus 1 */
3394        if (dev->def_i2c_bus) {
3395                if (dev->is_em25xx)
3396                        retval = em28xx_i2c_register(dev, 1,
3397                                                     EM28XX_I2C_ALGO_EM25XX_BUS_B);
3398                else
3399                        retval = em28xx_i2c_register(dev, 1,
3400                                                     EM28XX_I2C_ALGO_EM28XX);
3401                if (retval < 0) {
3402                        dev_err(&dev->intf->dev,
3403                               "%s: em28xx_i2c_register bus 1 - error [%d]!\n",
3404                               __func__, retval);
3405
3406                        em28xx_i2c_unregister(dev, 0);
3407
3408                        return retval;
3409                }
3410        }
3411
3412        /* Do board specific init and eeprom reading */
3413        em28xx_card_setup(dev);
3414
3415        return 0;
3416}
3417
3418/* high bandwidth multiplier, as encoded in highspeed endpoint descriptors */
3419#define hb_mult(wMaxPacketSize) (1 + (((wMaxPacketSize) >> 11) & 0x03))
3420
3421/*
3422 * em28xx_usb_probe()
3423 * checks for supported devices
3424 */
3425static int em28xx_usb_probe(struct usb_interface *interface,
3426                            const struct usb_device_id *id)
3427{
3428        struct usb_device *udev;
3429        struct em28xx *dev = NULL;
3430        int retval;
3431        bool has_vendor_audio = false, has_video = false, has_dvb = false;
3432        int i, nr, try_bulk;
3433        const int ifnum = interface->altsetting[0].desc.bInterfaceNumber;
3434        char *speed;
3435
3436        udev = usb_get_dev(interface_to_usbdev(interface));
3437
3438        /* Check to see next free device and mark as used */
3439        do {
3440                nr = find_first_zero_bit(em28xx_devused, EM28XX_MAXBOARDS);
3441                if (nr >= EM28XX_MAXBOARDS) {
3442                        /* No free device slots */
3443                        dev_err(&interface->dev,
3444                                "Driver supports up to %i em28xx boards.\n",
3445                               EM28XX_MAXBOARDS);
3446                        retval = -ENOMEM;
3447                        goto err_no_slot;
3448                }
3449        } while (test_and_set_bit(nr, em28xx_devused));
3450
3451        /* Don't register audio interfaces */
3452        if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3453                dev_err(&interface->dev,
3454                        "audio device (%04x:%04x): interface %i, class %i\n",
3455                        le16_to_cpu(udev->descriptor.idVendor),
3456                        le16_to_cpu(udev->descriptor.idProduct),
3457                        ifnum,
3458                        interface->altsetting[0].desc.bInterfaceClass);
3459
3460                retval = -ENODEV;
3461                goto err;
3462        }
3463
3464        /* allocate memory for our device state and initialize it */
3465        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
3466        if (dev == NULL) {
3467                retval = -ENOMEM;
3468                goto err;
3469        }
3470
3471        /* compute alternate max packet sizes */
3472        dev->alt_max_pkt_size_isoc =
3473                                kmalloc(sizeof(dev->alt_max_pkt_size_isoc[0]) *
3474                                        interface->num_altsetting, GFP_KERNEL);
3475        if (dev->alt_max_pkt_size_isoc == NULL) {
3476                kfree(dev);
3477                retval = -ENOMEM;
3478                goto err;
3479        }
3480
3481        /* Get endpoints */
3482        for (i = 0; i < interface->num_altsetting; i++) {
3483                int ep;
3484
3485                for (ep = 0; ep < interface->altsetting[i].desc.bNumEndpoints; ep++) {
3486                        const struct usb_endpoint_descriptor *e;
3487                        int sizedescr, size;
3488
3489                        e = &interface->altsetting[i].endpoint[ep].desc;
3490
3491                        sizedescr = le16_to_cpu(e->wMaxPacketSize);
3492                        size = sizedescr & 0x7ff;
3493
3494                        if (udev->speed == USB_SPEED_HIGH)
3495                                size = size * hb_mult(sizedescr);
3496
3497                        if (usb_endpoint_dir_in(e)) {
3498                                switch (e->bEndpointAddress) {
3499                                case 0x82:
3500                                        has_video = true;
3501                                        if (usb_endpoint_xfer_isoc(e)) {
3502                                                dev->analog_ep_isoc =
3503                                                            e->bEndpointAddress;
3504                                                dev->alt_max_pkt_size_isoc[i] = size;
3505                                        } else if (usb_endpoint_xfer_bulk(e)) {
3506                                                dev->analog_ep_bulk =
3507                                                            e->bEndpointAddress;
3508                                        }
3509                                        break;
3510                                case 0x83:
3511                                        if (usb_endpoint_xfer_isoc(e)) {
3512                                                has_vendor_audio = true;
3513                                        } else {
3514                                                dev_err(&interface->dev,
3515                                                        "error: skipping audio endpoint 0x83, because it uses bulk transfers !\n");
3516                                        }
3517                                        break;
3518                                case 0x84:
3519                                        if (has_video &&
3520                                            (usb_endpoint_xfer_bulk(e))) {
3521                                                dev->analog_ep_bulk =
3522                                                            e->bEndpointAddress;
3523                                        } else {
3524                                                if (usb_endpoint_xfer_isoc(e)) {
3525                                                        if (size > dev->dvb_max_pkt_size_isoc) {
3526                                                                has_dvb = true; /* see NOTE (~) */
3527                                                                dev->dvb_ep_isoc = e->bEndpointAddress;
3528                                                                dev->dvb_max_pkt_size_isoc = size;
3529                                                                dev->dvb_alt_isoc = i;
3530                                                        }
3531                                                } else {
3532                                                        has_dvb = true;
3533                                                        dev->dvb_ep_bulk = e->bEndpointAddress;
3534                                                }
3535                                        }
3536                                        break;
3537                                }
3538                        }
3539                        /* NOTE:
3540                         * Old logic with support for isoc transfers only was:
3541                         *  0x82        isoc            => analog
3542                         *  0x83        isoc            => audio
3543                         *  0x84        isoc            => digital
3544                         *
3545                         * New logic with support for bulk transfers
3546                         *  0x82        isoc            => analog
3547                         *  0x82        bulk            => analog
3548                         *  0x83        isoc*           => audio
3549                         *  0x84        isoc            => digital
3550                         *  0x84        bulk            => analog or digital**
3551                         * (*: audio should always be isoc)
3552                         * (**: analog, if ep 0x82 is isoc, otherwise digital)
3553                         *
3554                         * The new logic preserves backwards compatibility and
3555                         * reflects the endpoint configurations we have seen
3556                         * so far. But there might be devices for which this
3557                         * logic is not sufficient...
3558                         */
3559                        /*
3560                         * NOTE (~): some manufacturers (e.g. Terratec) disable
3561                         * endpoints by setting wMaxPacketSize to 0 bytes for
3562                         * all alt settings. So far, we've seen this for
3563                         * DVB isoc endpoints only.
3564                         */
3565                }
3566        }
3567
3568        if (!(has_vendor_audio || has_video || has_dvb)) {
3569                retval = -ENODEV;
3570                goto err_free;
3571        }
3572
3573        switch (udev->speed) {
3574        case USB_SPEED_LOW:
3575                speed = "1.5";
3576                break;
3577        case USB_SPEED_UNKNOWN:
3578        case USB_SPEED_FULL:
3579                speed = "12";
3580                break;
3581        case USB_SPEED_HIGH:
3582                speed = "480";
3583                break;
3584        default:
3585                speed = "unknown";
3586        }
3587
3588        dev_err(&interface->dev,
3589                "New device %s %s @ %s Mbps (%04x:%04x, interface %d, class %d)\n",
3590                udev->manufacturer ? udev->manufacturer : "",
3591                udev->product ? udev->product : "",
3592                speed,
3593                le16_to_cpu(udev->descriptor.idVendor),
3594                le16_to_cpu(udev->descriptor.idProduct),
3595                ifnum,
3596                interface->altsetting->desc.bInterfaceNumber);
3597
3598        /*
3599         * Make sure we have 480 Mbps of bandwidth, otherwise things like
3600         * video stream wouldn't likely work, since 12 Mbps is generally
3601         * not enough even for most Digital TV streams.
3602         */
3603        if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
3604                dev_err(&interface->dev, "Device initialization failed.\n");
3605                dev_err(&interface->dev,
3606                        "Device must be connected to a high-speed USB 2.0 port.\n");
3607                retval = -ENODEV;
3608                goto err_free;
3609        }
3610
3611        dev->devno = nr;
3612        dev->model = id->driver_info;
3613        dev->alt   = -1;
3614        dev->is_audio_only = has_vendor_audio && !(has_video || has_dvb);
3615        dev->has_video = has_video;
3616        dev->ifnum = ifnum;
3617
3618        if (has_vendor_audio) {
3619                dev_err(&interface->dev,
3620                        "Audio interface %i found (Vendor Class)\n", ifnum);
3621                dev->usb_audio_type = EM28XX_USB_AUDIO_VENDOR;
3622        }
3623        /* Checks if audio is provided by a USB Audio Class interface */
3624        for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
3625                struct usb_interface *uif = udev->config->interface[i];
3626
3627                if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
3628                        if (has_vendor_audio)
3629                                dev_err(&interface->dev,
3630                                        "em28xx: device seems to have vendor AND usb audio class interfaces !\n"
3631                                       "\t\tThe vendor interface will be ignored. Please contact the developers <linux-media@vger.kernel.org>\n");
3632                        dev->usb_audio_type = EM28XX_USB_AUDIO_CLASS;
3633                        break;
3634                }
3635        }
3636
3637        if (has_video)
3638                dev_err(&interface->dev, "Video interface %i found:%s%s\n",
3639                        ifnum,
3640                        dev->analog_ep_bulk ? " bulk" : "",
3641                        dev->analog_ep_isoc ? " isoc" : "");
3642        if (has_dvb)
3643                dev_err(&interface->dev, "DVB interface %i found:%s%s\n",
3644                        ifnum,
3645                        dev->dvb_ep_bulk ? " bulk" : "",
3646                        dev->dvb_ep_isoc ? " isoc" : "");
3647
3648        dev->num_alt = interface->num_altsetting;
3649
3650        if ((unsigned)card[nr] < em28xx_bcount)
3651                dev->model = card[nr];
3652
3653        /* save our data pointer in this interface device */
3654        usb_set_intfdata(interface, dev);
3655
3656        /* allocate device struct and check if the device is a webcam */
3657        mutex_init(&dev->lock);
3658        retval = em28xx_init_dev(dev, udev, interface, nr);
3659        if (retval) {
3660                goto err_free;
3661        }
3662
3663        if (usb_xfer_mode < 0) {
3664                if (dev->board.is_webcam)
3665                        try_bulk = 1;
3666                else
3667                        try_bulk = 0;
3668        } else {
3669                try_bulk = usb_xfer_mode > 0;
3670        }
3671
3672        /* Disable V4L2 if the device doesn't have a decoder or image sensor */
3673        if (has_video &&
3674            dev->board.decoder == EM28XX_NODECODER &&
3675            dev->em28xx_sensor == EM28XX_NOSENSOR) {
3676
3677                dev_err(&interface->dev,
3678                        "Currently, V4L2 is not supported on this model\n");
3679                has_video = false;
3680                dev->has_video = false;
3681        }
3682
3683        /* Select USB transfer types to use */
3684        if (has_video) {
3685                if (!dev->analog_ep_isoc || (try_bulk && dev->analog_ep_bulk))
3686                        dev->analog_xfer_bulk = 1;
3687                dev_err(&interface->dev, "analog set to %s mode.\n",
3688                        dev->analog_xfer_bulk ? "bulk" : "isoc");
3689        }
3690        if (has_dvb) {
3691                if (!dev->dvb_ep_isoc || (try_bulk && dev->dvb_ep_bulk))
3692                        dev->dvb_xfer_bulk = 1;
3693                dev_err(&interface->dev, "dvb set to %s mode.\n",
3694                        dev->dvb_xfer_bulk ? "bulk" : "isoc");
3695        }
3696
3697        kref_init(&dev->ref);
3698
3699        request_modules(dev);
3700
3701        /*
3702         * Do it at the end, to reduce dynamic configuration changes during
3703         * the device init. Yet, as request_modules() can be async, the
3704         * topology will likely change after the load of the em28xx subdrivers.
3705         */
3706#ifdef CONFIG_MEDIA_CONTROLLER
3707        retval = media_device_register(dev->media_dev);
3708#endif
3709
3710        return 0;
3711
3712err_free:
3713        kfree(dev->alt_max_pkt_size_isoc);
3714        kfree(dev);
3715
3716err:
3717        clear_bit(nr, em28xx_devused);
3718
3719err_no_slot:
3720        usb_put_dev(udev);
3721        return retval;
3722}
3723
3724/*
3725 * em28xx_usb_disconnect()
3726 * called when the device gets disconnected
3727 * video device will be unregistered on v4l2_close in case it is still open
3728 */
3729static void em28xx_usb_disconnect(struct usb_interface *interface)
3730{
3731        struct em28xx *dev;
3732
3733        dev = usb_get_intfdata(interface);
3734        usb_set_intfdata(interface, NULL);
3735
3736        if (!dev)
3737                return;
3738
3739        dev->disconnected = 1;
3740
3741        dev_err(&dev->intf->dev, "Disconnecting\n");
3742
3743        flush_request_modules(dev);
3744
3745        em28xx_close_extension(dev);
3746
3747        em28xx_release_resources(dev);
3748        kref_put(&dev->ref, em28xx_free_device);
3749}
3750
3751static int em28xx_usb_suspend(struct usb_interface *interface,
3752                              pm_message_t message)
3753{
3754        struct em28xx *dev;
3755
3756        dev = usb_get_intfdata(interface);
3757        if (!dev)
3758                return 0;
3759        em28xx_suspend_extension(dev);
3760        return 0;
3761}
3762
3763static int em28xx_usb_resume(struct usb_interface *interface)
3764{
3765        struct em28xx *dev;
3766
3767        dev = usb_get_intfdata(interface);
3768        if (!dev)
3769                return 0;
3770        em28xx_resume_extension(dev);
3771        return 0;
3772}
3773
3774static struct usb_driver em28xx_usb_driver = {
3775        .name = "em28xx",
3776        .probe = em28xx_usb_probe,
3777        .disconnect = em28xx_usb_disconnect,
3778        .suspend = em28xx_usb_suspend,
3779        .resume = em28xx_usb_resume,
3780        .reset_resume = em28xx_usb_resume,
3781        .id_table = em28xx_id_table,
3782};
3783
3784module_usb_driver(em28xx_usb_driver);
3785