linux/drivers/media/video/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
  10   This program is free software; you can redistribute it and/or modify
  11   it under the terms of the GNU General Public License as published by
  12   the Free Software Foundation; either version 2 of the License, or
  13   (at your option) any later version.
  14
  15   This program is distributed in the hope that it will be useful,
  16   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18   GNU General Public License for more details.
  19
  20   You should have received a copy of the GNU General Public License
  21   along with this program; if not, write to the Free Software
  22   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23 */
  24
  25#include <linux/init.h>
  26#include <linux/module.h>
  27#include <linux/slab.h>
  28#include <linux/delay.h>
  29#include <linux/i2c.h>
  30#include <linux/usb.h>
  31#include <media/tuner.h>
  32#include <media/msp3400.h>
  33#include <media/saa7115.h>
  34#include <media/tvp5150.h>
  35#include <media/tvaudio.h>
  36#include <media/i2c-addr.h>
  37#include <media/tveeprom.h>
  38#include <media/v4l2-common.h>
  39#include <media/v4l2-chip-ident.h>
  40
  41#include "em28xx.h"
  42
  43#define DRIVER_NAME         "em28xx"
  44
  45static int tuner = -1;
  46module_param(tuner, int, 0444);
  47MODULE_PARM_DESC(tuner, "tuner type");
  48
  49static unsigned int disable_ir;
  50module_param(disable_ir, int, 0444);
  51MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
  52
  53static unsigned int disable_usb_speed_check;
  54module_param(disable_usb_speed_check, int, 0444);
  55MODULE_PARM_DESC(disable_usb_speed_check,
  56                 "override min bandwidth requirement of 480M bps");
  57
  58static unsigned int card[]     = {[0 ... (EM28XX_MAXBOARDS - 1)] = UNSET };
  59module_param_array(card,  int, NULL, 0444);
  60MODULE_PARM_DESC(card,     "card type");
  61
  62/* Bitmask marking allocated devices from 0 to EM28XX_MAXBOARDS */
  63static unsigned long em28xx_devused;
  64
  65struct em28xx_hash_table {
  66        unsigned long hash;
  67        unsigned int  model;
  68        unsigned int  tuner;
  69};
  70
  71/*
  72 *  Reset sequences for analog/digital modes
  73 */
  74
  75/* Reset for the most [analog] boards */
  76static struct em28xx_reg_seq default_analog[] = {
  77        {EM28XX_R08_GPIO,       0x6d,   ~EM_GPIO_4,     10},
  78        {       -1,             -1,     -1,             -1},
  79};
  80
  81/* Reset for the most [digital] boards */
  82static struct em28xx_reg_seq default_digital[] = {
  83        {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
  84        {       -1,             -1,     -1,             -1},
  85};
  86
  87/* Board Hauppauge WinTV HVR 900 analog */
  88static struct em28xx_reg_seq hauppauge_wintv_hvr_900_analog[] = {
  89        {EM28XX_R08_GPIO,       0x2d,   ~EM_GPIO_4,     10},
  90        {0x05,                  0xff,   0x10,           10},
  91        {  -1,                  -1,     -1,             -1},
  92};
  93
  94/* Board Hauppauge WinTV HVR 900 digital */
  95static struct em28xx_reg_seq hauppauge_wintv_hvr_900_digital[] = {
  96        {EM28XX_R08_GPIO,       0x2e,   ~EM_GPIO_4,     10},
  97        {EM2880_R04_GPO,        0x04,   0x0f,           10},
  98        {EM2880_R04_GPO,        0x0c,   0x0f,           10},
  99        { -1,                   -1,     -1,             -1},
 100};
 101
 102/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
 103static struct em28xx_reg_seq em2880_msi_digivox_ad_analog[] = {
 104        {EM28XX_R08_GPIO,       0x69,   ~EM_GPIO_4,      10},
 105        {       -1,             -1,     -1,              -1},
 106};
 107
 108/* Boards - EM2880 MSI DIGIVOX AD and EM2880_BOARD_MSI_DIGIVOX_AD_II */
 109
 110/* Board  - EM2870 Kworld 355u
 111   Analog - No input analog */
 112
 113/* Board - EM2882 Kworld 315U digital */
 114static struct em28xx_reg_seq em2882_kworld_315u_digital[] = {
 115        {EM28XX_R08_GPIO,       0xff,   0xff,           10},
 116        {EM28XX_R08_GPIO,       0xfe,   0xff,           10},
 117        {EM2880_R04_GPO,        0x04,   0xff,           10},
 118        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 119        {EM28XX_R08_GPIO,       0x7e,   0xff,           10},
 120        {  -1,                  -1,     -1,             -1},
 121};
 122
 123static struct em28xx_reg_seq em2882_kworld_315u_tuner_gpio[] = {
 124        {EM2880_R04_GPO,        0x08,   0xff,           10},
 125        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 126        {EM2880_R04_GPO,        0x08,   0xff,           10},
 127        {EM2880_R04_GPO,        0x0c,   0xff,           10},
 128        {  -1,                  -1,     -1,             -1},
 129};
 130
 131static struct em28xx_reg_seq kworld_330u_analog[] = {
 132        {EM28XX_R08_GPIO,       0x6d,   ~EM_GPIO_4,     10},
 133        {EM2880_R04_GPO,        0x00,   0xff,           10},
 134        { -1,                   -1,     -1,             -1},
 135};
 136
 137static struct em28xx_reg_seq kworld_330u_digital[] = {
 138        {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
 139        {EM2880_R04_GPO,        0x08,   0xff,           10},
 140        { -1,                   -1,     -1,             -1},
 141};
 142
 143/* Evga inDtube
 144   GPIO0 - Enable digital power (s5h1409) - low to enable
 145   GPIO1 - Enable analog power (tvp5150/emp202) - low to enable
 146   GPIO4 - xc3028 reset
 147   GOP3  - s5h1409 reset
 148 */
 149static struct em28xx_reg_seq evga_indtube_analog[] = {
 150        {EM28XX_R08_GPIO,       0x79,   0xff,           60},
 151        {       -1,             -1,     -1,             -1},
 152};
 153
 154static struct em28xx_reg_seq evga_indtube_digital[] = {
 155        {EM28XX_R08_GPIO,       0x7a,   0xff,            1},
 156        {EM2880_R04_GPO,        0x04,   0xff,           10},
 157        {EM2880_R04_GPO,        0x0c,   0xff,            1},
 158        { -1,                   -1,     -1,             -1},
 159};
 160
 161/* Pinnacle Hybrid Pro eb1a:2881 */
 162static struct em28xx_reg_seq pinnacle_hybrid_pro_analog[] = {
 163        {EM28XX_R08_GPIO,       0xfd,   ~EM_GPIO_4,     10},
 164        {       -1,             -1,     -1,             -1},
 165};
 166
 167static struct em28xx_reg_seq pinnacle_hybrid_pro_digital[] = {
 168        {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
 169        {EM2880_R04_GPO,        0x04,   0xff,          100},/* zl10353 reset */
 170        {EM2880_R04_GPO,        0x0c,   0xff,            1},
 171        {       -1,             -1,     -1,             -1},
 172};
 173
 174/* eb1a:2868 Reddo DVB-C USB TV Box
 175   GPIO4 - CU1216L NIM
 176   Other GPIOs seems to be don't care. */
 177static struct em28xx_reg_seq reddo_dvb_c_usb_box[] = {
 178        {EM28XX_R08_GPIO,       0xfe,   0xff,           10},
 179        {EM28XX_R08_GPIO,       0xde,   0xff,           10},
 180        {EM28XX_R08_GPIO,       0xfe,   0xff,           10},
 181        {EM28XX_R08_GPIO,       0xff,   0xff,           10},
 182        {EM28XX_R08_GPIO,       0x7f,   0xff,           10},
 183        {EM28XX_R08_GPIO,       0x6f,   0xff,           10},
 184        {EM28XX_R08_GPIO,       0xff,   0xff,           10},
 185        {-1,                    -1,     -1,             -1},
 186};
 187
 188/* Callback for the most boards */
 189static struct em28xx_reg_seq default_tuner_gpio[] = {
 190        {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
 191        {EM28XX_R08_GPIO,       0,              EM_GPIO_4,      10},
 192        {EM28XX_R08_GPIO,       EM_GPIO_4,      EM_GPIO_4,      10},
 193        {  -1,                  -1,             -1,             -1},
 194};
 195
 196/* Mute/unmute */
 197static struct em28xx_reg_seq compro_unmute_tv_gpio[] = {
 198        {EM28XX_R08_GPIO,       5,              7,              10},
 199        {  -1,                  -1,             -1,             -1},
 200};
 201
 202static struct em28xx_reg_seq compro_unmute_svid_gpio[] = {
 203        {EM28XX_R08_GPIO,       4,              7,              10},
 204        {  -1,                  -1,             -1,             -1},
 205};
 206
 207static struct em28xx_reg_seq compro_mute_gpio[] = {
 208        {EM28XX_R08_GPIO,       6,              7,              10},
 209        {  -1,                  -1,             -1,             -1},
 210};
 211
 212/* Terratec AV350 */
 213static struct em28xx_reg_seq terratec_av350_mute_gpio[] = {
 214        {EM28XX_R08_GPIO,       0xff,   0x7f,           10},
 215        {       -1,             -1,     -1,             -1},
 216};
 217
 218static struct em28xx_reg_seq terratec_av350_unmute_gpio[] = {
 219        {EM28XX_R08_GPIO,       0xff,   0xff,           10},
 220        {       -1,             -1,     -1,             -1},
 221};
 222
 223static struct em28xx_reg_seq silvercrest_reg_seq[] = {
 224        {EM28XX_R08_GPIO,       0xff,   0xff,           10},
 225        {EM28XX_R08_GPIO,       0x01,   0xf7,           10},
 226        {       -1,             -1,     -1,             -1},
 227};
 228
 229static struct em28xx_reg_seq vc211a_enable[] = {
 230        {EM28XX_R08_GPIO,       0xff,   0x07,           10},
 231        {EM28XX_R08_GPIO,       0xff,   0x0f,           10},
 232        {EM28XX_R08_GPIO,       0xff,   0x0b,           10},
 233        {       -1,             -1,     -1,             -1},
 234};
 235
 236static struct em28xx_reg_seq dikom_dk300_digital[] = {
 237        {EM28XX_R08_GPIO,       0x6e,   ~EM_GPIO_4,     10},
 238        {EM2880_R04_GPO,        0x08,   0xff,           10},
 239        { -1,                   -1,     -1,             -1},
 240};
 241
 242
 243/*
 244 *  Board definitions
 245 */
 246struct em28xx_board em28xx_boards[] = {
 247        [EM2750_BOARD_UNKNOWN] = {
 248                .name          = "EM2710/EM2750/EM2751 webcam grabber",
 249                .xclk          = EM28XX_XCLK_FREQUENCY_20MHZ,
 250                .tuner_type    = TUNER_ABSENT,
 251                .is_webcam     = 1,
 252                .input         = { {
 253                        .type     = EM28XX_VMUX_COMPOSITE1,
 254                        .vmux     = 0,
 255                        .amux     = EM28XX_AMUX_VIDEO,
 256                        .gpio     = silvercrest_reg_seq,
 257                } },
 258        },
 259        [EM2800_BOARD_UNKNOWN] = {
 260                .name         = "Unknown EM2800 video grabber",
 261                .is_em2800    = 1,
 262                .tda9887_conf = TDA9887_PRESENT,
 263                .decoder      = EM28XX_SAA711X,
 264                .tuner_type   = TUNER_ABSENT,
 265                .input        = { {
 266                        .type     = EM28XX_VMUX_COMPOSITE1,
 267                        .vmux     = SAA7115_COMPOSITE0,
 268                        .amux     = EM28XX_AMUX_LINE_IN,
 269                }, {
 270                        .type     = EM28XX_VMUX_SVIDEO,
 271                        .vmux     = SAA7115_SVIDEO3,
 272                        .amux     = EM28XX_AMUX_LINE_IN,
 273                } },
 274        },
 275        [EM2820_BOARD_UNKNOWN] = {
 276                .name          = "Unknown EM2750/28xx video grabber",
 277                .tuner_type    = TUNER_ABSENT,
 278                .is_webcam     = 1,     /* To enable sensor probe */
 279        },
 280        [EM2750_BOARD_DLCW_130] = {
 281                /* Beijing Huaqi Information Digital Technology Co., Ltd */
 282                .name          = "Huaqi DLCW-130",
 283                .valid         = EM28XX_BOARD_NOT_VALIDATED,
 284                .xclk          = EM28XX_XCLK_FREQUENCY_48MHZ,
 285                .tuner_type    = TUNER_ABSENT,
 286                .is_webcam     = 1,
 287                .input         = { {
 288                        .type     = EM28XX_VMUX_COMPOSITE1,
 289                        .vmux     = 0,
 290                        .amux     = EM28XX_AMUX_VIDEO,
 291                } },
 292        },
 293        [EM2820_BOARD_KWORLD_PVRTV2800RF] = {
 294                .name         = "Kworld PVR TV 2800 RF",
 295                .tuner_type   = TUNER_TEMIC_PAL,
 296                .tda9887_conf = TDA9887_PRESENT,
 297                .decoder      = EM28XX_SAA711X,
 298                .input        = { {
 299                        .type     = EM28XX_VMUX_COMPOSITE1,
 300                        .vmux     = SAA7115_COMPOSITE0,
 301                        .amux     = EM28XX_AMUX_LINE_IN,
 302                }, {
 303                        .type     = EM28XX_VMUX_SVIDEO,
 304                        .vmux     = SAA7115_SVIDEO3,
 305                        .amux     = EM28XX_AMUX_LINE_IN,
 306                } },
 307        },
 308        [EM2820_BOARD_GADMEI_TVR200] = {
 309                .name         = "Gadmei TVR200",
 310                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 311                .tda9887_conf = TDA9887_PRESENT,
 312                .decoder      = EM28XX_SAA711X,
 313                .input        = { {
 314                        .type     = EM28XX_VMUX_TELEVISION,
 315                        .vmux     = SAA7115_COMPOSITE2,
 316                        .amux     = EM28XX_AMUX_LINE_IN,
 317                }, {
 318                        .type     = EM28XX_VMUX_COMPOSITE1,
 319                        .vmux     = SAA7115_COMPOSITE0,
 320                        .amux     = EM28XX_AMUX_LINE_IN,
 321                }, {
 322                        .type     = EM28XX_VMUX_SVIDEO,
 323                        .vmux     = SAA7115_SVIDEO3,
 324                        .amux     = EM28XX_AMUX_LINE_IN,
 325                } },
 326        },
 327        [EM2820_BOARD_TERRATEC_CINERGY_250] = {
 328                .name         = "Terratec Cinergy 250 USB",
 329                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 330                .has_ir_i2c   = 1,
 331                .tda9887_conf = TDA9887_PRESENT,
 332                .decoder      = EM28XX_SAA711X,
 333                .input        = { {
 334                        .type     = EM28XX_VMUX_TELEVISION,
 335                        .vmux     = SAA7115_COMPOSITE2,
 336                        .amux     = EM28XX_AMUX_LINE_IN,
 337                }, {
 338                        .type     = EM28XX_VMUX_COMPOSITE1,
 339                        .vmux     = SAA7115_COMPOSITE0,
 340                        .amux     = EM28XX_AMUX_LINE_IN,
 341                }, {
 342                        .type     = EM28XX_VMUX_SVIDEO,
 343                        .vmux     = SAA7115_SVIDEO3,
 344                        .amux     = EM28XX_AMUX_LINE_IN,
 345                } },
 346        },
 347        [EM2820_BOARD_PINNACLE_USB_2] = {
 348                .name         = "Pinnacle PCTV USB 2",
 349                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 350                .has_ir_i2c   = 1,
 351                .tda9887_conf = TDA9887_PRESENT,
 352                .decoder      = EM28XX_SAA711X,
 353                .input        = { {
 354                        .type     = EM28XX_VMUX_TELEVISION,
 355                        .vmux     = SAA7115_COMPOSITE2,
 356                        .amux     = EM28XX_AMUX_VIDEO,
 357                }, {
 358                        .type     = EM28XX_VMUX_COMPOSITE1,
 359                        .vmux     = SAA7115_COMPOSITE0,
 360                        .amux     = EM28XX_AMUX_LINE_IN,
 361                }, {
 362                        .type     = EM28XX_VMUX_SVIDEO,
 363                        .vmux     = SAA7115_SVIDEO3,
 364                        .amux     = EM28XX_AMUX_LINE_IN,
 365                } },
 366        },
 367        [EM2820_BOARD_HAUPPAUGE_WINTV_USB_2] = {
 368                .name         = "Hauppauge WinTV USB 2",
 369                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
 370                .tda9887_conf = TDA9887_PRESENT |
 371                                TDA9887_PORT1_ACTIVE |
 372                                TDA9887_PORT2_ACTIVE,
 373                .decoder      = EM28XX_TVP5150,
 374                .has_msp34xx  = 1,
 375                .has_ir_i2c   = 1,
 376                .input        = { {
 377                        .type     = EM28XX_VMUX_TELEVISION,
 378                        .vmux     = TVP5150_COMPOSITE0,
 379                        .amux     = MSP_INPUT_DEFAULT,
 380                }, {
 381                        .type     = EM28XX_VMUX_SVIDEO,
 382                        .vmux     = TVP5150_SVIDEO,
 383                        .amux     = MSP_INPUT(MSP_IN_SCART1, MSP_IN_TUNER1,
 384                                        MSP_DSP_IN_SCART, MSP_DSP_IN_SCART),
 385                } },
 386        },
 387        [EM2820_BOARD_DLINK_USB_TV] = {
 388                .name         = "D-Link DUB-T210 TV Tuner",
 389                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 390                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 391                .tda9887_conf = TDA9887_PRESENT,
 392                .decoder      = EM28XX_SAA711X,
 393                .input        = { {
 394                        .type     = EM28XX_VMUX_TELEVISION,
 395                        .vmux     = SAA7115_COMPOSITE2,
 396                        .amux     = EM28XX_AMUX_LINE_IN,
 397                }, {
 398                        .type     = EM28XX_VMUX_COMPOSITE1,
 399                        .vmux     = SAA7115_COMPOSITE0,
 400                        .amux     = EM28XX_AMUX_LINE_IN,
 401                }, {
 402                        .type     = EM28XX_VMUX_SVIDEO,
 403                        .vmux     = SAA7115_SVIDEO3,
 404                        .amux     = EM28XX_AMUX_LINE_IN,
 405                } },
 406        },
 407        [EM2820_BOARD_HERCULES_SMART_TV_USB2] = {
 408                .name         = "Hercules Smart TV USB 2.0",
 409                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 410                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
 411                .tda9887_conf = TDA9887_PRESENT,
 412                .decoder      = EM28XX_SAA711X,
 413                .input        = { {
 414                        .type     = EM28XX_VMUX_TELEVISION,
 415                        .vmux     = SAA7115_COMPOSITE2,
 416                        .amux     = EM28XX_AMUX_LINE_IN,
 417                }, {
 418                        .type     = EM28XX_VMUX_COMPOSITE1,
 419                        .vmux     = SAA7115_COMPOSITE0,
 420                        .amux     = EM28XX_AMUX_LINE_IN,
 421                }, {
 422                        .type     = EM28XX_VMUX_SVIDEO,
 423                        .vmux     = SAA7115_SVIDEO3,
 424                        .amux     = EM28XX_AMUX_LINE_IN,
 425                } },
 426        },
 427        [EM2820_BOARD_PINNACLE_USB_2_FM1216ME] = {
 428                .name         = "Pinnacle PCTV USB 2 (Philips FM1216ME)",
 429                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 430                .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
 431                .tda9887_conf = TDA9887_PRESENT,
 432                .decoder      = EM28XX_SAA711X,
 433                .input        = { {
 434                        .type     = EM28XX_VMUX_TELEVISION,
 435                        .vmux     = SAA7115_COMPOSITE2,
 436                        .amux     = EM28XX_AMUX_VIDEO,
 437                }, {
 438                        .type     = EM28XX_VMUX_COMPOSITE1,
 439                        .vmux     = SAA7115_COMPOSITE0,
 440                        .amux     = EM28XX_AMUX_LINE_IN,
 441                }, {
 442                        .type     = EM28XX_VMUX_SVIDEO,
 443                        .vmux     = SAA7115_SVIDEO3,
 444                        .amux     = EM28XX_AMUX_LINE_IN,
 445                } },
 446        },
 447        [EM2820_BOARD_GADMEI_UTV310] = {
 448                .name         = "Gadmei UTV310",
 449                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 450                .tuner_type   = TUNER_TNF_5335MF,
 451                .tda9887_conf = TDA9887_PRESENT,
 452                .decoder      = EM28XX_SAA711X,
 453                .input        = { {
 454                        .type     = EM28XX_VMUX_TELEVISION,
 455                        .vmux     = SAA7115_COMPOSITE1,
 456                        .amux     = EM28XX_AMUX_LINE_IN,
 457                }, {
 458                        .type     = EM28XX_VMUX_COMPOSITE1,
 459                        .vmux     = SAA7115_COMPOSITE0,
 460                        .amux     = EM28XX_AMUX_LINE_IN,
 461                }, {
 462                        .type     = EM28XX_VMUX_SVIDEO,
 463                        .vmux     = SAA7115_SVIDEO3,
 464                        .amux     = EM28XX_AMUX_LINE_IN,
 465                } },
 466        },
 467        [EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE] = {
 468                .name         = "Leadtek Winfast USB II Deluxe",
 469                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 470                .tuner_type   = TUNER_PHILIPS_FM1216ME_MK3,
 471                .has_ir_i2c   = 1,
 472                .tvaudio_addr = 0x58,
 473                .tda9887_conf = TDA9887_PRESENT |
 474                                TDA9887_PORT2_ACTIVE |
 475                                TDA9887_QSS,
 476                .decoder      = EM28XX_SAA711X,
 477                .adecoder     = EM28XX_TVAUDIO,
 478                .input        = { {
 479                        .type     = EM28XX_VMUX_TELEVISION,
 480                        .vmux     = SAA7115_COMPOSITE4,
 481                        .amux     = EM28XX_AMUX_AUX,
 482                }, {
 483                        .type     = EM28XX_VMUX_COMPOSITE1,
 484                        .vmux     = SAA7115_COMPOSITE5,
 485                        .amux     = EM28XX_AMUX_LINE_IN,
 486                }, {
 487                        .type     = EM28XX_VMUX_SVIDEO,
 488                        .vmux     = SAA7115_SVIDEO3,
 489                        .amux     = EM28XX_AMUX_LINE_IN,
 490                } },
 491                        .radio    = {
 492                        .type     = EM28XX_RADIO,
 493                        .amux     = EM28XX_AMUX_AUX,
 494                        }
 495        },
 496        [EM2820_BOARD_VIDEOLOGY_20K14XUSB] = {
 497                .name         = "Videology 20K14XUSB USB2.0",
 498                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 499                .tuner_type   = TUNER_ABSENT,
 500                .is_webcam    = 1,
 501                .input        = { {
 502                        .type     = EM28XX_VMUX_COMPOSITE1,
 503                        .vmux     = 0,
 504                        .amux     = EM28XX_AMUX_VIDEO,
 505                } },
 506        },
 507        [EM2820_BOARD_SILVERCREST_WEBCAM] = {
 508                .name         = "Silvercrest Webcam 1.3mpix",
 509                .tuner_type   = TUNER_ABSENT,
 510                .is_webcam    = 1,
 511                .input        = { {
 512                        .type     = EM28XX_VMUX_COMPOSITE1,
 513                        .vmux     = 0,
 514                        .amux     = EM28XX_AMUX_VIDEO,
 515                        .gpio     = silvercrest_reg_seq,
 516                } },
 517        },
 518        [EM2821_BOARD_SUPERCOMP_USB_2] = {
 519                .name         = "Supercomp USB 2.0 TV",
 520                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 521                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
 522                .tda9887_conf = TDA9887_PRESENT |
 523                                TDA9887_PORT1_ACTIVE |
 524                                TDA9887_PORT2_ACTIVE,
 525                .decoder      = EM28XX_SAA711X,
 526                .input        = { {
 527                        .type     = EM28XX_VMUX_TELEVISION,
 528                        .vmux     = SAA7115_COMPOSITE2,
 529                        .amux     = EM28XX_AMUX_LINE_IN,
 530                }, {
 531                        .type     = EM28XX_VMUX_COMPOSITE1,
 532                        .vmux     = SAA7115_COMPOSITE0,
 533                        .amux     = EM28XX_AMUX_VIDEO,
 534                }, {
 535                        .type     = EM28XX_VMUX_SVIDEO,
 536                        .vmux     = SAA7115_SVIDEO3,
 537                        .amux     = EM28XX_AMUX_LINE_IN,
 538                } },
 539        },
 540        [EM2821_BOARD_USBGEAR_VD204] = {
 541                .name         = "Usbgear VD204v9",
 542                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 543                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
 544                .decoder      = EM28XX_SAA711X,
 545                .input        = { {
 546                        .type  = EM28XX_VMUX_COMPOSITE1,
 547                        .vmux  = SAA7115_COMPOSITE0,
 548                        .amux  = EM28XX_AMUX_LINE_IN,
 549                }, {
 550                        .type  = EM28XX_VMUX_SVIDEO,
 551                        .vmux  = SAA7115_SVIDEO3,
 552                        .amux  = EM28XX_AMUX_LINE_IN,
 553                } },
 554        },
 555        [EM2860_BOARD_NETGMBH_CAM] = {
 556                /* Beijing Huaqi Information Digital Technology Co., Ltd */
 557                .name         = "NetGMBH Cam",
 558                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 559                .tuner_type   = TUNER_ABSENT,
 560                .is_webcam    = 1,
 561                .input        = { {
 562                        .type     = EM28XX_VMUX_COMPOSITE1,
 563                        .vmux     = 0,
 564                        .amux     = EM28XX_AMUX_VIDEO,
 565                } },
 566        },
 567        [EM2860_BOARD_TYPHOON_DVD_MAKER] = {
 568                .name         = "Typhoon DVD Maker",
 569                .decoder      = EM28XX_SAA711X,
 570                .tuner_type   = TUNER_ABSENT,   /* Capture only device */
 571                .input        = { {
 572                        .type  = EM28XX_VMUX_COMPOSITE1,
 573                        .vmux  = SAA7115_COMPOSITE0,
 574                        .amux  = EM28XX_AMUX_LINE_IN,
 575                }, {
 576                        .type  = EM28XX_VMUX_SVIDEO,
 577                        .vmux  = SAA7115_SVIDEO3,
 578                        .amux  = EM28XX_AMUX_LINE_IN,
 579                } },
 580        },
 581        [EM2860_BOARD_GADMEI_UTV330] = {
 582                .name         = "Gadmei UTV330",
 583                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 584                .tuner_type   = TUNER_TNF_5335MF,
 585                .tda9887_conf = TDA9887_PRESENT,
 586                .decoder      = EM28XX_SAA711X,
 587                .input        = { {
 588                        .type     = EM28XX_VMUX_TELEVISION,
 589                        .vmux     = SAA7115_COMPOSITE2,
 590                        .amux     = EM28XX_AMUX_VIDEO,
 591                }, {
 592                        .type     = EM28XX_VMUX_COMPOSITE1,
 593                        .vmux     = SAA7115_COMPOSITE0,
 594                        .amux     = EM28XX_AMUX_LINE_IN,
 595                }, {
 596                        .type     = EM28XX_VMUX_SVIDEO,
 597                        .vmux     = SAA7115_SVIDEO3,
 598                        .amux     = EM28XX_AMUX_LINE_IN,
 599                } },
 600        },
 601        [EM2861_BOARD_GADMEI_UTV330PLUS] = {
 602                .name         = "Gadmei UTV330+",
 603                .tuner_type   = TUNER_TNF_5335MF,
 604                .tda9887_conf = TDA9887_PRESENT,
 605                .ir_codes     = RC_MAP_GADMEI_RM008Z,
 606                .decoder      = EM28XX_SAA711X,
 607                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
 608                .input        = { {
 609                        .type     = EM28XX_VMUX_TELEVISION,
 610                        .vmux     = SAA7115_COMPOSITE2,
 611                        .amux     = EM28XX_AMUX_VIDEO,
 612                }, {
 613                        .type     = EM28XX_VMUX_COMPOSITE1,
 614                        .vmux     = SAA7115_COMPOSITE0,
 615                        .amux     = EM28XX_AMUX_LINE_IN,
 616                }, {
 617                        .type     = EM28XX_VMUX_SVIDEO,
 618                        .vmux     = SAA7115_SVIDEO3,
 619                        .amux     = EM28XX_AMUX_LINE_IN,
 620                } },
 621        },
 622        [EM2860_BOARD_TERRATEC_HYBRID_XS] = {
 623                .name         = "Terratec Cinergy A Hybrid XS",
 624                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 625                .tuner_type   = TUNER_XC2028,
 626                .tuner_gpio   = default_tuner_gpio,
 627                .decoder      = EM28XX_TVP5150,
 628
 629                .input        = { {
 630                        .type     = EM28XX_VMUX_TELEVISION,
 631                        .vmux     = TVP5150_COMPOSITE0,
 632                        .amux     = EM28XX_AMUX_VIDEO,
 633                        .gpio     = hauppauge_wintv_hvr_900_analog,
 634                }, {
 635                        .type     = EM28XX_VMUX_COMPOSITE1,
 636                        .vmux     = TVP5150_COMPOSITE1,
 637                        .amux     = EM28XX_AMUX_LINE_IN,
 638                        .gpio     = hauppauge_wintv_hvr_900_analog,
 639                }, {
 640                        .type     = EM28XX_VMUX_SVIDEO,
 641                        .vmux     = TVP5150_SVIDEO,
 642                        .amux     = EM28XX_AMUX_LINE_IN,
 643                        .gpio     = hauppauge_wintv_hvr_900_analog,
 644                } },
 645        },
 646        [EM2861_BOARD_KWORLD_PVRTV_300U] = {
 647                .name         = "KWorld PVRTV 300U",
 648                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 649                .tuner_type   = TUNER_XC2028,
 650                .tuner_gpio   = default_tuner_gpio,
 651                .decoder      = EM28XX_TVP5150,
 652                .input        = { {
 653                        .type     = EM28XX_VMUX_TELEVISION,
 654                        .vmux     = TVP5150_COMPOSITE0,
 655                        .amux     = EM28XX_AMUX_VIDEO,
 656                }, {
 657                        .type     = EM28XX_VMUX_COMPOSITE1,
 658                        .vmux     = TVP5150_COMPOSITE1,
 659                        .amux     = EM28XX_AMUX_LINE_IN,
 660                }, {
 661                        .type     = EM28XX_VMUX_SVIDEO,
 662                        .vmux     = TVP5150_SVIDEO,
 663                        .amux     = EM28XX_AMUX_LINE_IN,
 664                } },
 665        },
 666        [EM2861_BOARD_YAKUMO_MOVIE_MIXER] = {
 667                .name          = "Yakumo MovieMixer",
 668                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
 669                .decoder       = EM28XX_TVP5150,
 670                .input         = { {
 671                        .type     = EM28XX_VMUX_TELEVISION,
 672                        .vmux     = TVP5150_COMPOSITE0,
 673                        .amux     = EM28XX_AMUX_VIDEO,
 674                }, {
 675                        .type     = EM28XX_VMUX_COMPOSITE1,
 676                        .vmux     = TVP5150_COMPOSITE1,
 677                        .amux     = EM28XX_AMUX_LINE_IN,
 678                }, {
 679                        .type     = EM28XX_VMUX_SVIDEO,
 680                        .vmux     = TVP5150_SVIDEO,
 681                        .amux     = EM28XX_AMUX_LINE_IN,
 682                } },
 683        },
 684        [EM2860_BOARD_TVP5150_REFERENCE_DESIGN] = {
 685                .name          = "EM2860/TVP5150 Reference Design",
 686                .tuner_type    = TUNER_ABSENT,  /* Capture only device */
 687                .decoder       = EM28XX_TVP5150,
 688                .input         = { {
 689                        .type     = EM28XX_VMUX_COMPOSITE1,
 690                        .vmux     = TVP5150_COMPOSITE1,
 691                        .amux     = EM28XX_AMUX_LINE_IN,
 692                }, {
 693                        .type     = EM28XX_VMUX_SVIDEO,
 694                        .vmux     = TVP5150_SVIDEO,
 695                        .amux     = EM28XX_AMUX_LINE_IN,
 696                } },
 697        },
 698        [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
 699                .name         = "Plextor ConvertX PX-TV100U",
 700                .tuner_type   = TUNER_TNF_5335MF,
 701                .xclk         = EM28XX_XCLK_I2S_MSB_TIMING |
 702                                EM28XX_XCLK_FREQUENCY_12MHZ,
 703                .tda9887_conf = TDA9887_PRESENT,
 704                .decoder      = EM28XX_TVP5150,
 705                .has_msp34xx  = 1,
 706                .input        = { {
 707                        .type     = EM28XX_VMUX_TELEVISION,
 708                        .vmux     = TVP5150_COMPOSITE0,
 709                        .amux     = EM28XX_AMUX_LINE_IN,
 710                        .gpio     = pinnacle_hybrid_pro_analog,
 711                }, {
 712                        .type     = EM28XX_VMUX_COMPOSITE1,
 713                        .vmux     = TVP5150_COMPOSITE1,
 714                        .amux     = EM28XX_AMUX_LINE_IN,
 715                        .gpio     = pinnacle_hybrid_pro_analog,
 716                }, {
 717                        .type     = EM28XX_VMUX_SVIDEO,
 718                        .vmux     = TVP5150_SVIDEO,
 719                        .amux     = EM28XX_AMUX_LINE_IN,
 720                        .gpio     = pinnacle_hybrid_pro_analog,
 721                } },
 722        },
 723
 724        /* Those boards with em2870 are DVB Only*/
 725
 726        [EM2870_BOARD_TERRATEC_XS] = {
 727                .name         = "Terratec Cinergy T XS",
 728                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 729                .tuner_type   = TUNER_XC2028,
 730                .tuner_gpio   = default_tuner_gpio,
 731        },
 732        [EM2870_BOARD_TERRATEC_XS_MT2060] = {
 733                .name         = "Terratec Cinergy T XS (MT2060)",
 734                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 735                .tuner_type   = TUNER_ABSENT, /* MT2060 */
 736        },
 737        [EM2870_BOARD_KWORLD_350U] = {
 738                .name         = "Kworld 350 U DVB-T",
 739                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 740                .tuner_type   = TUNER_XC2028,
 741                .tuner_gpio   = default_tuner_gpio,
 742        },
 743        [EM2870_BOARD_KWORLD_355U] = {
 744                .name         = "Kworld 355 U DVB-T",
 745                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 746        },
 747        [EM2870_BOARD_PINNACLE_PCTV_DVB] = {
 748                .name         = "Pinnacle PCTV DVB-T",
 749                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 750                .tuner_type   = TUNER_ABSENT, /* MT2060 */
 751                /* djh - I have serious doubts this is right... */
 752                .xclk         = EM28XX_XCLK_IR_RC5_MODE |
 753                                EM28XX_XCLK_FREQUENCY_10MHZ,
 754        },
 755        [EM2870_BOARD_COMPRO_VIDEOMATE] = {
 756                .name         = "Compro, VideoMate U3",
 757                .valid        = EM28XX_BOARD_NOT_VALIDATED,
 758                .tuner_type   = TUNER_ABSENT, /* MT2060 */
 759        },
 760
 761        [EM2880_BOARD_TERRATEC_HYBRID_XS_FR] = {
 762                .name         = "Terratec Hybrid XS Secam",
 763                .has_msp34xx  = 1,
 764                .tuner_type   = TUNER_XC2028,
 765                .tuner_gpio   = default_tuner_gpio,
 766                .decoder      = EM28XX_TVP5150,
 767                .has_dvb      = 1,
 768                .dvb_gpio     = default_digital,
 769                .input        = { {
 770                        .type     = EM28XX_VMUX_TELEVISION,
 771                        .vmux     = TVP5150_COMPOSITE0,
 772                        .amux     = EM28XX_AMUX_VIDEO,
 773                        .gpio     = default_analog,
 774                }, {
 775                        .type     = EM28XX_VMUX_COMPOSITE1,
 776                        .vmux     = TVP5150_COMPOSITE1,
 777                        .amux     = EM28XX_AMUX_LINE_IN,
 778                        .gpio     = default_analog,
 779                }, {
 780                        .type     = EM28XX_VMUX_SVIDEO,
 781                        .vmux     = TVP5150_SVIDEO,
 782                        .amux     = EM28XX_AMUX_LINE_IN,
 783                        .gpio     = default_analog,
 784                } },
 785        },
 786        [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900] = {
 787                .name         = "Hauppauge WinTV HVR 900",
 788                .tda9887_conf = TDA9887_PRESENT,
 789                .tuner_type   = TUNER_XC2028,
 790                .tuner_gpio   = default_tuner_gpio,
 791                .mts_firmware = 1,
 792                .has_dvb      = 1,
 793                .dvb_gpio     = hauppauge_wintv_hvr_900_digital,
 794                .ir_codes     = RC_MAP_HAUPPAUGE_NEW,
 795                .decoder      = EM28XX_TVP5150,
 796                .input        = { {
 797                        .type     = EM28XX_VMUX_TELEVISION,
 798                        .vmux     = TVP5150_COMPOSITE0,
 799                        .amux     = EM28XX_AMUX_VIDEO,
 800                        .gpio     = hauppauge_wintv_hvr_900_analog,
 801                }, {
 802                        .type     = EM28XX_VMUX_COMPOSITE1,
 803                        .vmux     = TVP5150_COMPOSITE1,
 804                        .amux     = EM28XX_AMUX_LINE_IN,
 805                        .gpio     = hauppauge_wintv_hvr_900_analog,
 806                }, {
 807                        .type     = EM28XX_VMUX_SVIDEO,
 808                        .vmux     = TVP5150_SVIDEO,
 809                        .amux     = EM28XX_AMUX_LINE_IN,
 810                        .gpio     = hauppauge_wintv_hvr_900_analog,
 811                } },
 812        },
 813        [EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2] = {
 814                .name         = "Hauppauge WinTV HVR 900 (R2)",
 815                .tda9887_conf = TDA9887_PRESENT,
 816                .tuner_type   = TUNER_XC2028,
 817                .tuner_gpio   = default_tuner_gpio,
 818                .mts_firmware = 1,
 819                .ir_codes     = RC_MAP_HAUPPAUGE_NEW,
 820                .decoder      = EM28XX_TVP5150,
 821                .input        = { {
 822                        .type     = EM28XX_VMUX_TELEVISION,
 823                        .vmux     = TVP5150_COMPOSITE0,
 824                        .amux     = EM28XX_AMUX_VIDEO,
 825                        .gpio     = hauppauge_wintv_hvr_900_analog,
 826                }, {
 827                        .type     = EM28XX_VMUX_COMPOSITE1,
 828                        .vmux     = TVP5150_COMPOSITE1,
 829                        .amux     = EM28XX_AMUX_LINE_IN,
 830                        .gpio     = hauppauge_wintv_hvr_900_analog,
 831                }, {
 832                        .type     = EM28XX_VMUX_SVIDEO,
 833                        .vmux     = TVP5150_SVIDEO,
 834                        .amux     = EM28XX_AMUX_LINE_IN,
 835                        .gpio     = hauppauge_wintv_hvr_900_analog,
 836                } },
 837        },
 838        [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850] = {
 839                .name           = "Hauppauge WinTV HVR 850",
 840                .tuner_type     = TUNER_XC2028,
 841                .tuner_gpio     = default_tuner_gpio,
 842                .mts_firmware   = 1,
 843                .has_dvb        = 1,
 844                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
 845                .ir_codes       = RC_MAP_HAUPPAUGE_NEW,
 846                .decoder        = EM28XX_TVP5150,
 847                .input          = { {
 848                        .type     = EM28XX_VMUX_TELEVISION,
 849                        .vmux     = TVP5150_COMPOSITE0,
 850                        .amux     = EM28XX_AMUX_VIDEO,
 851                        .gpio     = hauppauge_wintv_hvr_900_analog,
 852                }, {
 853                        .type     = EM28XX_VMUX_COMPOSITE1,
 854                        .vmux     = TVP5150_COMPOSITE1,
 855                        .amux     = EM28XX_AMUX_LINE_IN,
 856                        .gpio     = hauppauge_wintv_hvr_900_analog,
 857                }, {
 858                        .type     = EM28XX_VMUX_SVIDEO,
 859                        .vmux     = TVP5150_SVIDEO,
 860                        .amux     = EM28XX_AMUX_LINE_IN,
 861                        .gpio     = hauppauge_wintv_hvr_900_analog,
 862                } },
 863        },
 864        [EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950] = {
 865                .name           = "Hauppauge WinTV HVR 950",
 866                .tuner_type     = TUNER_XC2028,
 867                .tuner_gpio     = default_tuner_gpio,
 868                .mts_firmware   = 1,
 869                .has_dvb        = 1,
 870                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
 871                .ir_codes       = RC_MAP_RC5_HAUPPAUGE_NEW,
 872                .decoder        = EM28XX_TVP5150,
 873                .input          = { {
 874                        .type     = EM28XX_VMUX_TELEVISION,
 875                        .vmux     = TVP5150_COMPOSITE0,
 876                        .amux     = EM28XX_AMUX_VIDEO,
 877                        .gpio     = hauppauge_wintv_hvr_900_analog,
 878                }, {
 879                        .type     = EM28XX_VMUX_COMPOSITE1,
 880                        .vmux     = TVP5150_COMPOSITE1,
 881                        .amux     = EM28XX_AMUX_LINE_IN,
 882                        .gpio     = hauppauge_wintv_hvr_900_analog,
 883                }, {
 884                        .type     = EM28XX_VMUX_SVIDEO,
 885                        .vmux     = TVP5150_SVIDEO,
 886                        .amux     = EM28XX_AMUX_LINE_IN,
 887                        .gpio     = hauppauge_wintv_hvr_900_analog,
 888                } },
 889        },
 890        [EM2880_BOARD_PINNACLE_PCTV_HD_PRO] = {
 891                .name           = "Pinnacle PCTV HD Pro Stick",
 892                .tuner_type     = TUNER_XC2028,
 893                .tuner_gpio   = default_tuner_gpio,
 894                .mts_firmware   = 1,
 895                .has_dvb        = 1,
 896                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
 897                .ir_codes       = RC_MAP_PINNACLE_PCTV_HD,
 898                .decoder        = EM28XX_TVP5150,
 899                .input          = { {
 900                        .type     = EM28XX_VMUX_TELEVISION,
 901                        .vmux     = TVP5150_COMPOSITE0,
 902                        .amux     = EM28XX_AMUX_VIDEO,
 903                        .gpio     = hauppauge_wintv_hvr_900_analog,
 904                }, {
 905                        .type     = EM28XX_VMUX_COMPOSITE1,
 906                        .vmux     = TVP5150_COMPOSITE1,
 907                        .amux     = EM28XX_AMUX_LINE_IN,
 908                        .gpio     = hauppauge_wintv_hvr_900_analog,
 909                }, {
 910                        .type     = EM28XX_VMUX_SVIDEO,
 911                        .vmux     = TVP5150_SVIDEO,
 912                        .amux     = EM28XX_AMUX_LINE_IN,
 913                        .gpio     = hauppauge_wintv_hvr_900_analog,
 914                } },
 915        },
 916        [EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600] = {
 917                .name           = "AMD ATI TV Wonder HD 600",
 918                .tuner_type     = TUNER_XC2028,
 919                .tuner_gpio     = default_tuner_gpio,
 920                .mts_firmware   = 1,
 921                .has_dvb        = 1,
 922                .dvb_gpio       = hauppauge_wintv_hvr_900_digital,
 923                .ir_codes       = RC_MAP_ATI_TV_WONDER_HD_600,
 924                .decoder        = EM28XX_TVP5150,
 925                .input          = { {
 926                        .type     = EM28XX_VMUX_TELEVISION,
 927                        .vmux     = TVP5150_COMPOSITE0,
 928                        .amux     = EM28XX_AMUX_VIDEO,
 929                        .gpio     = hauppauge_wintv_hvr_900_analog,
 930                }, {
 931                        .type     = EM28XX_VMUX_COMPOSITE1,
 932                        .vmux     = TVP5150_COMPOSITE1,
 933                        .amux     = EM28XX_AMUX_LINE_IN,
 934                        .gpio     = hauppauge_wintv_hvr_900_analog,
 935                }, {
 936                        .type     = EM28XX_VMUX_SVIDEO,
 937                        .vmux     = TVP5150_SVIDEO,
 938                        .amux     = EM28XX_AMUX_LINE_IN,
 939                        .gpio     = hauppauge_wintv_hvr_900_analog,
 940                } },
 941        },
 942        [EM2880_BOARD_TERRATEC_HYBRID_XS] = {
 943                .name           = "Terratec Hybrid XS",
 944                .tuner_type     = TUNER_XC2028,
 945                .tuner_gpio     = default_tuner_gpio,
 946                .decoder        = EM28XX_TVP5150,
 947                .has_dvb        = 1,
 948                .dvb_gpio       = default_digital,
 949                .ir_codes       = RC_MAP_TERRATEC_CINERGY_XS,
 950                .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
 951                .input          = { {
 952                        .type     = EM28XX_VMUX_TELEVISION,
 953                        .vmux     = TVP5150_COMPOSITE0,
 954                        .amux     = EM28XX_AMUX_VIDEO,
 955                        .gpio     = default_analog,
 956                }, {
 957                        .type     = EM28XX_VMUX_COMPOSITE1,
 958                        .vmux     = TVP5150_COMPOSITE1,
 959                        .amux     = EM28XX_AMUX_LINE_IN,
 960                        .gpio     = default_analog,
 961                }, {
 962                        .type     = EM28XX_VMUX_SVIDEO,
 963                        .vmux     = TVP5150_SVIDEO,
 964                        .amux     = EM28XX_AMUX_LINE_IN,
 965                        .gpio     = default_analog,
 966                } },
 967        },
 968        /* maybe there's a reason behind it why Terratec sells the Hybrid XS
 969           as Prodigy XS with a different PID, let's keep it separated for now
 970           maybe we'll need it lateron */
 971        [EM2880_BOARD_TERRATEC_PRODIGY_XS] = {
 972                .name         = "Terratec Prodigy XS",
 973                .tuner_type   = TUNER_XC2028,
 974                .tuner_gpio   = default_tuner_gpio,
 975                .decoder      = EM28XX_TVP5150,
 976                .input        = { {
 977                        .type     = EM28XX_VMUX_TELEVISION,
 978                        .vmux     = TVP5150_COMPOSITE0,
 979                        .amux     = EM28XX_AMUX_VIDEO,
 980                        .gpio     = hauppauge_wintv_hvr_900_analog,
 981                }, {
 982                        .type     = EM28XX_VMUX_COMPOSITE1,
 983                        .vmux     = TVP5150_COMPOSITE1,
 984                        .amux     = EM28XX_AMUX_LINE_IN,
 985                        .gpio     = hauppauge_wintv_hvr_900_analog,
 986                }, {
 987                        .type     = EM28XX_VMUX_SVIDEO,
 988                        .vmux     = TVP5150_SVIDEO,
 989                        .amux     = EM28XX_AMUX_LINE_IN,
 990                        .gpio     = hauppauge_wintv_hvr_900_analog,
 991                } },
 992        },
 993        [EM2820_BOARD_MSI_VOX_USB_2] = {
 994                .name              = "MSI VOX USB 2.0",
 995                .tuner_type        = TUNER_LG_PAL_NEW_TAPC,
 996                .tda9887_conf      = TDA9887_PRESENT      |
 997                                     TDA9887_PORT1_ACTIVE |
 998                                     TDA9887_PORT2_ACTIVE,
 999                .max_range_640_480 = 1,
1000                .decoder           = EM28XX_SAA711X,
1001                .input             = { {
1002                        .type      = EM28XX_VMUX_TELEVISION,
1003                        .vmux      = SAA7115_COMPOSITE4,
1004                        .amux      = EM28XX_AMUX_VIDEO,
1005                }, {
1006                        .type      = EM28XX_VMUX_COMPOSITE1,
1007                        .vmux      = SAA7115_COMPOSITE0,
1008                        .amux      = EM28XX_AMUX_LINE_IN,
1009                }, {
1010                        .type      = EM28XX_VMUX_SVIDEO,
1011                        .vmux      = SAA7115_SVIDEO3,
1012                        .amux      = EM28XX_AMUX_LINE_IN,
1013                } },
1014        },
1015        [EM2800_BOARD_TERRATEC_CINERGY_200] = {
1016                .name         = "Terratec Cinergy 200 USB",
1017                .is_em2800    = 1,
1018                .has_ir_i2c   = 1,
1019                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1020                .tda9887_conf = TDA9887_PRESENT,
1021                .decoder      = EM28XX_SAA711X,
1022                .input        = { {
1023                        .type     = EM28XX_VMUX_TELEVISION,
1024                        .vmux     = SAA7115_COMPOSITE2,
1025                        .amux     = EM28XX_AMUX_VIDEO,
1026                }, {
1027                        .type     = EM28XX_VMUX_COMPOSITE1,
1028                        .vmux     = SAA7115_COMPOSITE0,
1029                        .amux     = EM28XX_AMUX_LINE_IN,
1030                }, {
1031                        .type     = EM28XX_VMUX_SVIDEO,
1032                        .vmux     = SAA7115_SVIDEO3,
1033                        .amux     = EM28XX_AMUX_LINE_IN,
1034                } },
1035        },
1036        [EM2800_BOARD_GRABBEEX_USB2800] = {
1037                .name       = "eMPIA Technology, Inc. GrabBeeX+ Video Encoder",
1038                .is_em2800  = 1,
1039                .decoder    = EM28XX_SAA711X,
1040                .tuner_type = TUNER_ABSENT, /* capture only board */
1041                .input      = { {
1042                        .type     = EM28XX_VMUX_COMPOSITE1,
1043                        .vmux     = SAA7115_COMPOSITE0,
1044                        .amux     = EM28XX_AMUX_LINE_IN,
1045                }, {
1046                        .type     = EM28XX_VMUX_SVIDEO,
1047                        .vmux     = SAA7115_SVIDEO3,
1048                        .amux     = EM28XX_AMUX_LINE_IN,
1049                } },
1050        },
1051        [EM2800_BOARD_VC211A] = {
1052                .name         = "Actionmaster/LinXcel/Digitus VC211A",
1053                .is_em2800    = 1,
1054                .tuner_type   = TUNER_ABSENT,   /* Capture-only board */
1055                .decoder      = EM28XX_SAA711X,
1056                .input        = { {
1057                        .type     = EM28XX_VMUX_COMPOSITE1,
1058                        .vmux     = SAA7115_COMPOSITE0,
1059                        .amux     = EM28XX_AMUX_LINE_IN,
1060                        .gpio     = vc211a_enable,
1061                }, {
1062                        .type     = EM28XX_VMUX_SVIDEO,
1063                        .vmux     = SAA7115_SVIDEO3,
1064                        .amux     = EM28XX_AMUX_LINE_IN,
1065                        .gpio     = vc211a_enable,
1066                } },
1067        },
1068        [EM2800_BOARD_LEADTEK_WINFAST_USBII] = {
1069                .name         = "Leadtek Winfast USB II",
1070                .is_em2800    = 1,
1071                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1072                .tda9887_conf = TDA9887_PRESENT,
1073                .decoder      = EM28XX_SAA711X,
1074                .input        = { {
1075                        .type     = EM28XX_VMUX_TELEVISION,
1076                        .vmux     = SAA7115_COMPOSITE2,
1077                        .amux     = EM28XX_AMUX_VIDEO,
1078                }, {
1079                        .type     = EM28XX_VMUX_COMPOSITE1,
1080                        .vmux     = SAA7115_COMPOSITE0,
1081                        .amux     = EM28XX_AMUX_LINE_IN,
1082                }, {
1083                        .type     = EM28XX_VMUX_SVIDEO,
1084                        .vmux     = SAA7115_SVIDEO3,
1085                        .amux     = EM28XX_AMUX_LINE_IN,
1086                } },
1087        },
1088        [EM2800_BOARD_KWORLD_USB2800] = {
1089                .name         = "Kworld USB2800",
1090                .is_em2800    = 1,
1091                .tuner_type   = TUNER_PHILIPS_FCV1236D,
1092                .tda9887_conf = TDA9887_PRESENT,
1093                .decoder      = EM28XX_SAA711X,
1094                .input        = { {
1095                        .type     = EM28XX_VMUX_TELEVISION,
1096                        .vmux     = SAA7115_COMPOSITE2,
1097                        .amux     = EM28XX_AMUX_VIDEO,
1098                }, {
1099                        .type     = EM28XX_VMUX_COMPOSITE1,
1100                        .vmux     = SAA7115_COMPOSITE0,
1101                        .amux     = EM28XX_AMUX_LINE_IN,
1102                }, {
1103                        .type     = EM28XX_VMUX_SVIDEO,
1104                        .vmux     = SAA7115_SVIDEO3,
1105                        .amux     = EM28XX_AMUX_LINE_IN,
1106                } },
1107        },
1108        [EM2820_BOARD_PINNACLE_DVC_90] = {
1109                .name         = "Pinnacle Dazzle DVC 90/100/101/107 / Kaiser Baas Video to DVD maker "
1110                                "/ Kworld DVD Maker 2",
1111                .tuner_type   = TUNER_ABSENT, /* capture only board */
1112                .decoder      = EM28XX_SAA711X,
1113                .input        = { {
1114                        .type     = EM28XX_VMUX_COMPOSITE1,
1115                        .vmux     = SAA7115_COMPOSITE0,
1116                        .amux     = EM28XX_AMUX_LINE_IN,
1117                }, {
1118                        .type     = EM28XX_VMUX_SVIDEO,
1119                        .vmux     = SAA7115_SVIDEO3,
1120                        .amux     = EM28XX_AMUX_LINE_IN,
1121                } },
1122        },
1123        [EM2800_BOARD_VGEAR_POCKETTV] = {
1124                .name         = "V-Gear PocketTV",
1125                .is_em2800    = 1,
1126                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1127                .tda9887_conf = TDA9887_PRESENT,
1128                .decoder      = EM28XX_SAA711X,
1129                .input        = { {
1130                        .type     = EM28XX_VMUX_TELEVISION,
1131                        .vmux     = SAA7115_COMPOSITE2,
1132                        .amux     = EM28XX_AMUX_VIDEO,
1133                }, {
1134                        .type     = EM28XX_VMUX_COMPOSITE1,
1135                        .vmux     = SAA7115_COMPOSITE0,
1136                        .amux     = EM28XX_AMUX_LINE_IN,
1137                }, {
1138                        .type     = EM28XX_VMUX_SVIDEO,
1139                        .vmux     = SAA7115_SVIDEO3,
1140                        .amux     = EM28XX_AMUX_LINE_IN,
1141                } },
1142        },
1143        [EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2] = {
1144                .name         = "Pixelview PlayTV Box 4 USB 2.0",
1145                .tda9887_conf = TDA9887_PRESENT,
1146                .tuner_type   = TUNER_YMEC_TVF_5533MF,
1147                .decoder      = EM28XX_SAA711X,
1148                .input        = { {
1149                        .type     = EM28XX_VMUX_TELEVISION,
1150                        .vmux     = SAA7115_COMPOSITE2,
1151                        .amux     = EM28XX_AMUX_VIDEO,
1152                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
1153                                    EM28XX_AOUT_MASTER, /* Line out pin */
1154                }, {
1155                        .type     = EM28XX_VMUX_COMPOSITE1,
1156                        .vmux     = SAA7115_COMPOSITE0,
1157                        .amux     = EM28XX_AMUX_LINE_IN,
1158                }, {
1159                        .type     = EM28XX_VMUX_SVIDEO,
1160                        .vmux     = SAA7115_SVIDEO3,
1161                        .amux     = EM28XX_AMUX_LINE_IN,
1162                } },
1163        },
1164        [EM2820_BOARD_PROLINK_PLAYTV_USB2] = {
1165                .name         = "SIIG AVTuner-PVR / Pixelview Prolink PlayTV USB 2.0",
1166                .has_snapshot_button = 1,
1167                .tda9887_conf = TDA9887_PRESENT,
1168                .tuner_type   = TUNER_YMEC_TVF_5533MF,
1169                .decoder      = EM28XX_SAA711X,
1170                .input        = { {
1171                        .type     = EM28XX_VMUX_TELEVISION,
1172                        .vmux     = SAA7115_COMPOSITE2,
1173                        .amux     = EM28XX_AMUX_VIDEO,
1174                        .aout     = EM28XX_AOUT_MONO |  /* I2S */
1175                                    EM28XX_AOUT_MASTER, /* Line out pin */
1176                }, {
1177                        .type     = EM28XX_VMUX_COMPOSITE1,
1178                        .vmux     = SAA7115_COMPOSITE0,
1179                        .amux     = EM28XX_AMUX_LINE_IN,
1180                }, {
1181                        .type     = EM28XX_VMUX_SVIDEO,
1182                        .vmux     = SAA7115_SVIDEO3,
1183                        .amux     = EM28XX_AMUX_LINE_IN,
1184                } },
1185        },
1186        [EM2860_BOARD_SAA711X_REFERENCE_DESIGN] = {
1187                .name                = "EM2860/SAA711X Reference Design",
1188                .has_snapshot_button = 1,
1189                .tuner_type          = TUNER_ABSENT,
1190                .decoder             = EM28XX_SAA711X,
1191                .input               = { {
1192                        .type     = EM28XX_VMUX_SVIDEO,
1193                        .vmux     = SAA7115_SVIDEO3,
1194                }, {
1195                        .type     = EM28XX_VMUX_COMPOSITE1,
1196                        .vmux     = SAA7115_COMPOSITE0,
1197                } },
1198        },
1199        [EM2880_BOARD_MSI_DIGIVOX_AD] = {
1200                .name         = "MSI DigiVox A/D",
1201                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1202                .tuner_type   = TUNER_XC2028,
1203                .tuner_gpio   = default_tuner_gpio,
1204                .decoder      = EM28XX_TVP5150,
1205                .input        = { {
1206                        .type     = EM28XX_VMUX_TELEVISION,
1207                        .vmux     = TVP5150_COMPOSITE0,
1208                        .amux     = EM28XX_AMUX_VIDEO,
1209                        .gpio     = em2880_msi_digivox_ad_analog,
1210                }, {
1211                        .type     = EM28XX_VMUX_COMPOSITE1,
1212                        .vmux     = TVP5150_COMPOSITE1,
1213                        .amux     = EM28XX_AMUX_LINE_IN,
1214                        .gpio     = em2880_msi_digivox_ad_analog,
1215                }, {
1216                        .type     = EM28XX_VMUX_SVIDEO,
1217                        .vmux     = TVP5150_SVIDEO,
1218                        .amux     = EM28XX_AMUX_LINE_IN,
1219                        .gpio     = em2880_msi_digivox_ad_analog,
1220                } },
1221        },
1222        [EM2880_BOARD_MSI_DIGIVOX_AD_II] = {
1223                .name         = "MSI DigiVox A/D II",
1224                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1225                .tuner_type   = TUNER_XC2028,
1226                .tuner_gpio   = default_tuner_gpio,
1227                .decoder      = EM28XX_TVP5150,
1228                .input        = { {
1229                        .type     = EM28XX_VMUX_TELEVISION,
1230                        .vmux     = TVP5150_COMPOSITE0,
1231                        .amux     = EM28XX_AMUX_VIDEO,
1232                        .gpio     = em2880_msi_digivox_ad_analog,
1233                }, {
1234                        .type     = EM28XX_VMUX_COMPOSITE1,
1235                        .vmux     = TVP5150_COMPOSITE1,
1236                        .amux     = EM28XX_AMUX_LINE_IN,
1237                        .gpio     = em2880_msi_digivox_ad_analog,
1238                }, {
1239                        .type     = EM28XX_VMUX_SVIDEO,
1240                        .vmux     = TVP5150_SVIDEO,
1241                        .amux     = EM28XX_AMUX_LINE_IN,
1242                        .gpio     = em2880_msi_digivox_ad_analog,
1243                } },
1244        },
1245        [EM2880_BOARD_KWORLD_DVB_305U] = {
1246                .name         = "KWorld DVB-T 305U",
1247                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1248                .tuner_type   = TUNER_XC2028,
1249                .tuner_gpio   = default_tuner_gpio,
1250                .decoder      = EM28XX_TVP5150,
1251                .input        = { {
1252                        .type     = EM28XX_VMUX_TELEVISION,
1253                        .vmux     = TVP5150_COMPOSITE0,
1254                        .amux     = EM28XX_AMUX_VIDEO,
1255                }, {
1256                        .type     = EM28XX_VMUX_COMPOSITE1,
1257                        .vmux     = TVP5150_COMPOSITE1,
1258                        .amux     = EM28XX_AMUX_LINE_IN,
1259                }, {
1260                        .type     = EM28XX_VMUX_SVIDEO,
1261                        .vmux     = TVP5150_SVIDEO,
1262                        .amux     = EM28XX_AMUX_LINE_IN,
1263                } },
1264        },
1265        [EM2880_BOARD_KWORLD_DVB_310U] = {
1266                .name         = "KWorld DVB-T 310U",
1267                .tuner_type   = TUNER_XC2028,
1268                .tuner_gpio   = default_tuner_gpio,
1269                .has_dvb      = 1,
1270                .dvb_gpio     = default_digital,
1271                .mts_firmware = 1,
1272                .decoder      = EM28XX_TVP5150,
1273                .input        = { {
1274                        .type     = EM28XX_VMUX_TELEVISION,
1275                        .vmux     = TVP5150_COMPOSITE0,
1276                        .amux     = EM28XX_AMUX_VIDEO,
1277                        .gpio     = default_analog,
1278                }, {
1279                        .type     = EM28XX_VMUX_COMPOSITE1,
1280                        .vmux     = TVP5150_COMPOSITE1,
1281                        .amux     = EM28XX_AMUX_LINE_IN,
1282                        .gpio     = default_analog,
1283                }, {    /* S-video has not been tested yet */
1284                        .type     = EM28XX_VMUX_SVIDEO,
1285                        .vmux     = TVP5150_SVIDEO,
1286                        .amux     = EM28XX_AMUX_LINE_IN,
1287                        .gpio     = default_analog,
1288                } },
1289        },
1290        [EM2882_BOARD_KWORLD_ATSC_315U] = {
1291                .name           = "KWorld ATSC 315U HDTV TV Box",
1292                .valid          = EM28XX_BOARD_NOT_VALIDATED,
1293                .tuner_type     = TUNER_THOMSON_DTT761X,
1294                .tuner_gpio     = em2882_kworld_315u_tuner_gpio,
1295                .tda9887_conf   = TDA9887_PRESENT,
1296                .decoder        = EM28XX_SAA711X,
1297                .has_dvb        = 1,
1298                .dvb_gpio       = em2882_kworld_315u_digital,
1299                .ir_codes       = RC_MAP_KWORLD_315U,
1300                .xclk           = EM28XX_XCLK_FREQUENCY_12MHZ,
1301                .i2c_speed      = EM28XX_I2C_CLK_WAIT_ENABLE,
1302                /* Analog mode - still not ready */
1303                /*.input        = { {
1304                        .type = EM28XX_VMUX_TELEVISION,
1305                        .vmux = SAA7115_COMPOSITE2,
1306                        .amux = EM28XX_AMUX_VIDEO,
1307                        .gpio = em2882_kworld_315u_analog,
1308                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1309                }, {
1310                        .type = EM28XX_VMUX_COMPOSITE1,
1311                        .vmux = SAA7115_COMPOSITE0,
1312                        .amux = EM28XX_AMUX_LINE_IN,
1313                        .gpio = em2882_kworld_315u_analog1,
1314                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1315                }, {
1316                        .type = EM28XX_VMUX_SVIDEO,
1317                        .vmux = SAA7115_SVIDEO3,
1318                        .amux = EM28XX_AMUX_LINE_IN,
1319                        .gpio = em2882_kworld_315u_analog1,
1320                        .aout = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1321                } }, */
1322        },
1323        [EM2880_BOARD_EMPIRE_DUAL_TV] = {
1324                .name = "Empire dual TV",
1325                .tuner_type = TUNER_XC2028,
1326                .tuner_gpio = default_tuner_gpio,
1327                .has_dvb = 1,
1328                .dvb_gpio = default_digital,
1329                .mts_firmware = 1,
1330                .decoder = EM28XX_TVP5150,
1331                .input = { {
1332                        .type = EM28XX_VMUX_TELEVISION,
1333                        .vmux = TVP5150_COMPOSITE0,
1334                        .amux = EM28XX_AMUX_VIDEO,
1335                        .gpio = default_analog,
1336                }, {
1337                        .type = EM28XX_VMUX_COMPOSITE1,
1338                        .vmux = TVP5150_COMPOSITE1,
1339                        .amux = EM28XX_AMUX_LINE_IN,
1340                        .gpio = default_analog,
1341                }, {
1342                        .type = EM28XX_VMUX_SVIDEO,
1343                        .vmux = TVP5150_SVIDEO,
1344                        .amux = EM28XX_AMUX_LINE_IN,
1345                        .gpio = default_analog,
1346                } },
1347        },
1348        [EM2881_BOARD_DNT_DA2_HYBRID] = {
1349                .name         = "DNT DA2 Hybrid",
1350                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1351                .tuner_type   = TUNER_XC2028,
1352                .tuner_gpio   = default_tuner_gpio,
1353                .decoder      = EM28XX_TVP5150,
1354                .input        = { {
1355                        .type     = EM28XX_VMUX_TELEVISION,
1356                        .vmux     = TVP5150_COMPOSITE0,
1357                        .amux     = EM28XX_AMUX_VIDEO,
1358                        .gpio     = default_analog,
1359                }, {
1360                        .type     = EM28XX_VMUX_COMPOSITE1,
1361                        .vmux     = TVP5150_COMPOSITE1,
1362                        .amux     = EM28XX_AMUX_LINE_IN,
1363                        .gpio     = default_analog,
1364                }, {
1365                        .type     = EM28XX_VMUX_SVIDEO,
1366                        .vmux     = TVP5150_SVIDEO,
1367                        .amux     = EM28XX_AMUX_LINE_IN,
1368                        .gpio     = default_analog,
1369                } },
1370        },
1371        [EM2881_BOARD_PINNACLE_HYBRID_PRO] = {
1372                .name         = "Pinnacle Hybrid Pro",
1373                .tuner_type   = TUNER_XC2028,
1374                .tuner_gpio   = default_tuner_gpio,
1375                .decoder      = EM28XX_TVP5150,
1376                .has_dvb      = 1,
1377                .dvb_gpio     = pinnacle_hybrid_pro_digital,
1378                .input        = { {
1379                        .type     = EM28XX_VMUX_TELEVISION,
1380                        .vmux     = TVP5150_COMPOSITE0,
1381                        .amux     = EM28XX_AMUX_VIDEO,
1382                        .gpio     = pinnacle_hybrid_pro_analog,
1383                }, {
1384                        .type     = EM28XX_VMUX_COMPOSITE1,
1385                        .vmux     = TVP5150_COMPOSITE1,
1386                        .amux     = EM28XX_AMUX_LINE_IN,
1387                        .gpio     = pinnacle_hybrid_pro_analog,
1388                }, {
1389                        .type     = EM28XX_VMUX_SVIDEO,
1390                        .vmux     = TVP5150_SVIDEO,
1391                        .amux     = EM28XX_AMUX_LINE_IN,
1392                        .gpio     = pinnacle_hybrid_pro_analog,
1393                } },
1394        },
1395        [EM2882_BOARD_PINNACLE_HYBRID_PRO] = {
1396                .name         = "Pinnacle Hybrid Pro (2)",
1397                .valid        = EM28XX_BOARD_NOT_VALIDATED,
1398                .tuner_type   = TUNER_XC2028,
1399                .tuner_gpio   = default_tuner_gpio,
1400                .mts_firmware = 1,
1401                .decoder      = EM28XX_TVP5150,
1402                .input        = { {
1403                        .type     = EM28XX_VMUX_TELEVISION,
1404                        .vmux     = TVP5150_COMPOSITE0,
1405                        .amux     = EM28XX_AMUX_VIDEO,
1406                        .gpio     = hauppauge_wintv_hvr_900_analog,
1407                }, {
1408                        .type     = EM28XX_VMUX_COMPOSITE1,
1409                        .vmux     = TVP5150_COMPOSITE1,
1410                        .amux     = EM28XX_AMUX_LINE_IN,
1411                        .gpio     = hauppauge_wintv_hvr_900_analog,
1412                }, {
1413                        .type     = EM28XX_VMUX_SVIDEO,
1414                        .vmux     = TVP5150_SVIDEO,
1415                        .amux     = EM28XX_AMUX_LINE_IN,
1416                        .gpio     = hauppauge_wintv_hvr_900_analog,
1417                } },
1418        },
1419        [EM2882_BOARD_KWORLD_VS_DVBT] = {
1420                .name         = "Kworld VS-DVB-T 323UR",
1421                .tuner_type   = TUNER_XC2028,
1422                .tuner_gpio   = default_tuner_gpio,
1423                .decoder      = EM28XX_TVP5150,
1424                .mts_firmware = 1,
1425                .has_dvb      = 1,
1426                .dvb_gpio     = kworld_330u_digital,
1427                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1428                .ir_codes     = RC_MAP_KWORLD_315U,
1429                .input        = { {
1430                        .type     = EM28XX_VMUX_TELEVISION,
1431                        .vmux     = TVP5150_COMPOSITE0,
1432                        .amux     = EM28XX_AMUX_VIDEO,
1433                }, {
1434                        .type     = EM28XX_VMUX_COMPOSITE1,
1435                        .vmux     = TVP5150_COMPOSITE1,
1436                        .amux     = EM28XX_AMUX_LINE_IN,
1437                }, {
1438                        .type     = EM28XX_VMUX_SVIDEO,
1439                        .vmux     = TVP5150_SVIDEO,
1440                        .amux     = EM28XX_AMUX_LINE_IN,
1441                } },
1442        },
1443        [EM2882_BOARD_TERRATEC_HYBRID_XS] = {
1444                .name         = "Terratec Hybrid XS (em2882)",
1445                .tuner_type   = TUNER_XC2028,
1446                .tuner_gpio   = default_tuner_gpio,
1447                .mts_firmware = 1,
1448                .decoder      = EM28XX_TVP5150,
1449                .has_dvb      = 1,
1450                .dvb_gpio     = hauppauge_wintv_hvr_900_digital,
1451                .ir_codes     = RC_MAP_TERRATEC_CINERGY_XS,
1452                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ,
1453                .input        = { {
1454                        .type     = EM28XX_VMUX_TELEVISION,
1455                        .vmux     = TVP5150_COMPOSITE0,
1456                        .amux     = EM28XX_AMUX_VIDEO,
1457                        .gpio     = hauppauge_wintv_hvr_900_analog,
1458                }, {
1459                        .type     = EM28XX_VMUX_COMPOSITE1,
1460                        .vmux     = TVP5150_COMPOSITE1,
1461                        .amux     = EM28XX_AMUX_LINE_IN,
1462                        .gpio     = hauppauge_wintv_hvr_900_analog,
1463                }, {
1464                        .type     = EM28XX_VMUX_SVIDEO,
1465                        .vmux     = TVP5150_SVIDEO,
1466                        .amux     = EM28XX_AMUX_LINE_IN,
1467                        .gpio     = hauppauge_wintv_hvr_900_analog,
1468                } },
1469        },
1470        [EM2882_BOARD_DIKOM_DK300] = {
1471                .name         = "Dikom DK300",
1472                .tuner_type   = TUNER_XC2028,
1473                .tuner_gpio   = default_tuner_gpio,
1474                .decoder      = EM28XX_TVP5150,
1475                .mts_firmware = 1,
1476                .has_dvb      = 1,
1477                .dvb_gpio     = dikom_dk300_digital,
1478                .input        = { {
1479                        .type     = EM28XX_VMUX_TELEVISION,
1480                        .vmux     = TVP5150_COMPOSITE0,
1481                        .amux     = EM28XX_AMUX_VIDEO,
1482                        .gpio     = default_analog,
1483                } },
1484        },
1485        [EM2883_BOARD_KWORLD_HYBRID_330U] = {
1486                .name         = "Kworld PlusTV HD Hybrid 330",
1487                .tuner_type   = TUNER_XC2028,
1488                .tuner_gpio   = default_tuner_gpio,
1489                .decoder      = EM28XX_TVP5150,
1490                .mts_firmware = 1,
1491                .has_dvb      = 1,
1492                .dvb_gpio     = kworld_330u_digital,
1493                .xclk             = EM28XX_XCLK_FREQUENCY_12MHZ,
1494                .i2c_speed        = EM28XX_I2C_CLK_WAIT_ENABLE |
1495                                    EM28XX_I2C_EEPROM_ON_BOARD |
1496                                    EM28XX_I2C_EEPROM_KEY_VALID,
1497                .input        = { {
1498                        .type     = EM28XX_VMUX_TELEVISION,
1499                        .vmux     = TVP5150_COMPOSITE0,
1500                        .amux     = EM28XX_AMUX_VIDEO,
1501                        .gpio     = kworld_330u_analog,
1502                        .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1503                }, {
1504                        .type     = EM28XX_VMUX_COMPOSITE1,
1505                        .vmux     = TVP5150_COMPOSITE1,
1506                        .amux     = EM28XX_AMUX_LINE_IN,
1507                        .gpio     = kworld_330u_analog,
1508                        .aout     = EM28XX_AOUT_PCM_IN | EM28XX_AOUT_PCM_STEREO,
1509                }, {
1510                        .type     = EM28XX_VMUX_SVIDEO,
1511                        .vmux     = TVP5150_SVIDEO,
1512                        .amux     = EM28XX_AMUX_LINE_IN,
1513                        .gpio     = kworld_330u_analog,
1514                } },
1515        },
1516        [EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU] = {
1517                .name         = "Compro VideoMate ForYou/Stereo",
1518                .tuner_type   = TUNER_LG_PAL_NEW_TAPC,
1519                .tvaudio_addr = 0xb0,
1520                .tda9887_conf = TDA9887_PRESENT,
1521                .decoder      = EM28XX_TVP5150,
1522                .adecoder     = EM28XX_TVAUDIO,
1523                .mute_gpio    = compro_mute_gpio,
1524                .input        = { {
1525                        .type     = EM28XX_VMUX_TELEVISION,
1526                        .vmux     = TVP5150_COMPOSITE0,
1527                        .amux     = EM28XX_AMUX_VIDEO,
1528                        .gpio     = compro_unmute_tv_gpio,
1529                }, {
1530                        .type     = EM28XX_VMUX_SVIDEO,
1531                        .vmux     = TVP5150_SVIDEO,
1532                        .amux     = EM28XX_AMUX_LINE_IN,
1533                        .gpio     = compro_unmute_svid_gpio,
1534                } },
1535        },
1536        [EM2860_BOARD_KAIOMY_TVNPC_U2] = {
1537                .name         = "Kaiomy TVnPC U2",
1538                .vchannels    = 3,
1539                .tuner_type   = TUNER_XC2028,
1540                .tuner_addr   = 0x61,
1541                .mts_firmware = 1,
1542                .decoder      = EM28XX_TVP5150,
1543                .tuner_gpio   = default_tuner_gpio,
1544                .ir_codes     = RC_MAP_KAIOMY,
1545                .input          = { {
1546                        .type     = EM28XX_VMUX_TELEVISION,
1547                        .vmux     = TVP5150_COMPOSITE0,
1548                        .amux     = EM28XX_AMUX_VIDEO,
1549
1550                }, {
1551                        .type     = EM28XX_VMUX_COMPOSITE1,
1552                        .vmux     = TVP5150_COMPOSITE1,
1553                        .amux     = EM28XX_AMUX_LINE_IN,
1554                }, {
1555                        .type     = EM28XX_VMUX_SVIDEO,
1556                        .vmux     = TVP5150_SVIDEO,
1557                        .amux     = EM28XX_AMUX_LINE_IN,
1558                } },
1559                .radio          = {
1560                        .type     = EM28XX_RADIO,
1561                        .amux     = EM28XX_AMUX_LINE_IN,
1562                }
1563        },
1564        [EM2860_BOARD_EASYCAP] = {
1565                .name         = "Easy Cap Capture DC-60",
1566                .vchannels    = 2,
1567                .tuner_type   = TUNER_ABSENT,
1568                .decoder      = EM28XX_SAA711X,
1569                .input           = { {
1570                        .type     = EM28XX_VMUX_COMPOSITE1,
1571                        .vmux     = SAA7115_COMPOSITE0,
1572                        .amux     = EM28XX_AMUX_LINE_IN,
1573                }, {
1574                        .type     = EM28XX_VMUX_SVIDEO,
1575                        .vmux     = SAA7115_SVIDEO3,
1576                        .amux     = EM28XX_AMUX_LINE_IN,
1577                } },
1578        },
1579        [EM2820_BOARD_IODATA_GVMVP_SZ] = {
1580                .name       = "IO-DATA GV-MVP/SZ",
1581                .tuner_type   = TUNER_PHILIPS_FM1236_MK3,
1582                .tuner_gpio   = default_tuner_gpio,
1583                .tda9887_conf = TDA9887_PRESENT,
1584                .decoder      = EM28XX_TVP5150,
1585                .input        = { {
1586                        .type     = EM28XX_VMUX_TELEVISION,
1587                        .vmux     = TVP5150_COMPOSITE0,
1588                        .amux     = EM28XX_AMUX_VIDEO,
1589                }, { /* Composite has not been tested yet */
1590                        .type     = EM28XX_VMUX_COMPOSITE1,
1591                        .vmux     = TVP5150_COMPOSITE1,
1592                        .amux     = EM28XX_AMUX_VIDEO,
1593                }, { /* S-video has not been tested yet */
1594                        .type     = EM28XX_VMUX_SVIDEO,
1595                        .vmux     = TVP5150_SVIDEO,
1596                        .amux     = EM28XX_AMUX_VIDEO,
1597                } },
1598        },
1599        [EM2860_BOARD_TERRATEC_GRABBY] = {
1600                .name            = "Terratec Grabby",
1601                .vchannels       = 2,
1602                .tuner_type      = TUNER_ABSENT,
1603                .decoder         = EM28XX_SAA711X,
1604                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
1605                .input           = { {
1606                        .type     = EM28XX_VMUX_COMPOSITE1,
1607                        .vmux     = SAA7115_COMPOSITE0,
1608                        .amux     = EM28XX_AMUX_VIDEO2,
1609                }, {
1610                        .type     = EM28XX_VMUX_SVIDEO,
1611                        .vmux     = SAA7115_SVIDEO3,
1612                        .amux     = EM28XX_AMUX_VIDEO2,
1613                } },
1614        },
1615        [EM2860_BOARD_TERRATEC_AV350] = {
1616                .name            = "Terratec AV350",
1617                .vchannels       = 2,
1618                .tuner_type      = TUNER_ABSENT,
1619                .decoder         = EM28XX_TVP5150,
1620                .xclk            = EM28XX_XCLK_FREQUENCY_12MHZ,
1621                .mute_gpio       = terratec_av350_mute_gpio,
1622                .input           = { {
1623                        .type     = EM28XX_VMUX_COMPOSITE1,
1624                        .vmux     = TVP5150_COMPOSITE1,
1625                        .amux     = EM28XX_AUDIO_SRC_LINE,
1626                        .gpio     = terratec_av350_unmute_gpio,
1627
1628                }, {
1629                        .type     = EM28XX_VMUX_SVIDEO,
1630                        .vmux     = TVP5150_SVIDEO,
1631                        .amux     = EM28XX_AUDIO_SRC_LINE,
1632                        .gpio     = terratec_av350_unmute_gpio,
1633                } },
1634        },
1635        [EM2882_BOARD_EVGA_INDTUBE] = {
1636                .name         = "Evga inDtube",
1637                .tuner_type   = TUNER_XC2028,
1638                .tuner_gpio   = default_tuner_gpio,
1639                .decoder      = EM28XX_TVP5150,
1640                .xclk         = EM28XX_XCLK_FREQUENCY_12MHZ, /* NEC IR */
1641                .mts_firmware = 1,
1642                .has_dvb      = 1,
1643                .dvb_gpio     = evga_indtube_digital,
1644                .ir_codes     = RC_MAP_EVGA_INDTUBE,
1645                .input        = { {
1646                        .type     = EM28XX_VMUX_TELEVISION,
1647                        .vmux     = TVP5150_COMPOSITE0,
1648                        .amux     = EM28XX_AMUX_VIDEO,
1649                        .gpio     = evga_indtube_analog,
1650                }, {
1651                        .type     = EM28XX_VMUX_COMPOSITE1,
1652                        .vmux     = TVP5150_COMPOSITE1,
1653                        .amux     = EM28XX_AMUX_LINE_IN,
1654                        .gpio     = evga_indtube_analog,
1655                }, {
1656                        .type     = EM28XX_VMUX_SVIDEO,
1657                        .vmux     = TVP5150_SVIDEO,
1658                        .amux     = EM28XX_AMUX_LINE_IN,
1659                        .gpio     = evga_indtube_analog,
1660                } },
1661        },
1662        /* eb1a:2868 Empia EM2870 + Philips CU1216L NIM (Philips TDA10023 +
1663           Infineon TUA6034) */
1664        [EM2870_BOARD_REDDO_DVB_C_USB_BOX] = {
1665                .name          = "Reddo DVB-C USB TV Box",
1666                .tuner_type    = TUNER_ABSENT,
1667                .tuner_gpio    = reddo_dvb_c_usb_box,
1668                .has_dvb       = 1,
1669        },
1670};
1671const unsigned int em28xx_bcount = ARRAY_SIZE(em28xx_boards);
1672
1673/* table of devices that work with this driver */
1674struct usb_device_id em28xx_id_table[] = {
1675        { USB_DEVICE(0xeb1a, 0x2750),
1676                        .driver_info = EM2750_BOARD_UNKNOWN },
1677        { USB_DEVICE(0xeb1a, 0x2751),
1678                        .driver_info = EM2750_BOARD_UNKNOWN },
1679        { USB_DEVICE(0xeb1a, 0x2800),
1680                        .driver_info = EM2800_BOARD_UNKNOWN },
1681        { USB_DEVICE(0xeb1a, 0x2710),
1682                        .driver_info = EM2820_BOARD_UNKNOWN },
1683        { USB_DEVICE(0xeb1a, 0x2820),
1684                        .driver_info = EM2820_BOARD_UNKNOWN },
1685        { USB_DEVICE(0xeb1a, 0x2821),
1686                        .driver_info = EM2820_BOARD_UNKNOWN },
1687        { USB_DEVICE(0xeb1a, 0x2860),
1688                        .driver_info = EM2820_BOARD_UNKNOWN },
1689        { USB_DEVICE(0xeb1a, 0x2861),
1690                        .driver_info = EM2820_BOARD_UNKNOWN },
1691        { USB_DEVICE(0xeb1a, 0x2862),
1692                        .driver_info = EM2820_BOARD_UNKNOWN },
1693        { USB_DEVICE(0xeb1a, 0x2863),
1694                        .driver_info = EM2820_BOARD_UNKNOWN },
1695        { USB_DEVICE(0xeb1a, 0x2870),
1696                        .driver_info = EM2820_BOARD_UNKNOWN },
1697        { USB_DEVICE(0xeb1a, 0x2881),
1698                        .driver_info = EM2820_BOARD_UNKNOWN },
1699        { USB_DEVICE(0xeb1a, 0x2883),
1700                        .driver_info = EM2820_BOARD_UNKNOWN },
1701        { USB_DEVICE(0xeb1a, 0x2868),
1702                        .driver_info = EM2820_BOARD_UNKNOWN },
1703        { USB_DEVICE(0xeb1a, 0xe300),
1704                        .driver_info = EM2861_BOARD_KWORLD_PVRTV_300U },
1705        { USB_DEVICE(0xeb1a, 0xe303),
1706                        .driver_info = EM2860_BOARD_KAIOMY_TVNPC_U2 },
1707        { USB_DEVICE(0xeb1a, 0xe305),
1708                        .driver_info = EM2880_BOARD_KWORLD_DVB_305U },
1709        { USB_DEVICE(0xeb1a, 0xe310),
1710                        .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD },
1711        { USB_DEVICE(0xeb1a, 0xa313),
1712                .driver_info = EM2882_BOARD_KWORLD_ATSC_315U },
1713        { USB_DEVICE(0xeb1a, 0xa316),
1714                        .driver_info = EM2883_BOARD_KWORLD_HYBRID_330U },
1715        { USB_DEVICE(0xeb1a, 0xe320),
1716                        .driver_info = EM2880_BOARD_MSI_DIGIVOX_AD_II },
1717        { USB_DEVICE(0xeb1a, 0xe323),
1718                        .driver_info = EM2882_BOARD_KWORLD_VS_DVBT },
1719        { USB_DEVICE(0xeb1a, 0xe350),
1720                        .driver_info = EM2870_BOARD_KWORLD_350U },
1721        { USB_DEVICE(0xeb1a, 0xe355),
1722                        .driver_info = EM2870_BOARD_KWORLD_355U },
1723        { USB_DEVICE(0xeb1a, 0x2801),
1724                        .driver_info = EM2800_BOARD_GRABBEEX_USB2800 },
1725        { USB_DEVICE(0xeb1a, 0xe357),
1726                        .driver_info = EM2870_BOARD_KWORLD_355U },
1727        { USB_DEVICE(0x1b80, 0xe302),
1728                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kaiser Baas Video to DVD maker */
1729        { USB_DEVICE(0x1b80, 0xe304),
1730                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 }, /* Kworld DVD Maker 2 */
1731        { USB_DEVICE(0x0ccd, 0x0036),
1732                        .driver_info = EM2820_BOARD_TERRATEC_CINERGY_250 },
1733        { USB_DEVICE(0x0ccd, 0x004c),
1734                        .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS_FR },
1735        { USB_DEVICE(0x0ccd, 0x004f),
1736                        .driver_info = EM2860_BOARD_TERRATEC_HYBRID_XS },
1737        { USB_DEVICE(0x0ccd, 0x005e),
1738                        .driver_info = EM2882_BOARD_TERRATEC_HYBRID_XS },
1739        { USB_DEVICE(0x0ccd, 0x0042),
1740                        .driver_info = EM2880_BOARD_TERRATEC_HYBRID_XS },
1741        { USB_DEVICE(0x0ccd, 0x0043),
1742                        .driver_info = EM2870_BOARD_TERRATEC_XS },
1743        { USB_DEVICE(0x0ccd, 0x0047),
1744                        .driver_info = EM2880_BOARD_TERRATEC_PRODIGY_XS },
1745        { USB_DEVICE(0x0ccd, 0x0084),
1746                        .driver_info = EM2860_BOARD_TERRATEC_AV350 },
1747        { USB_DEVICE(0x0ccd, 0x0096),
1748                        .driver_info = EM2860_BOARD_TERRATEC_GRABBY },
1749        { USB_DEVICE(0x185b, 0x2870),
1750                        .driver_info = EM2870_BOARD_COMPRO_VIDEOMATE },
1751        { USB_DEVICE(0x185b, 0x2041),
1752                        .driver_info = EM2820_BOARD_COMPRO_VIDEOMATE_FORYOU },
1753        { USB_DEVICE(0x2040, 0x4200),
1754                        .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1755        { USB_DEVICE(0x2040, 0x4201),
1756                        .driver_info = EM2820_BOARD_HAUPPAUGE_WINTV_USB_2 },
1757        { USB_DEVICE(0x2040, 0x6500),
1758                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900 },
1759        { USB_DEVICE(0x2040, 0x6502),
1760                        .driver_info = EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2 },
1761        { USB_DEVICE(0x2040, 0x6513), /* HCW HVR-980 */
1762                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1763        { USB_DEVICE(0x2040, 0x6517), /* HP  HVR-950 */
1764                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1765        { USB_DEVICE(0x2040, 0x651b), /* RP  HVR-950 */
1766                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950 },
1767        { USB_DEVICE(0x2040, 0x651f),
1768                        .driver_info = EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850 },
1769        { USB_DEVICE(0x0438, 0xb002),
1770                        .driver_info = EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600 },
1771        { USB_DEVICE(0x2001, 0xf112),
1772                        .driver_info = EM2820_BOARD_DLINK_USB_TV },
1773        { USB_DEVICE(0x2304, 0x0207),
1774                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1775        { USB_DEVICE(0x2304, 0x0208),
1776                        .driver_info = EM2820_BOARD_PINNACLE_USB_2 },
1777        { USB_DEVICE(0x2304, 0x021a),
1778                        .driver_info = EM2820_BOARD_PINNACLE_DVC_90 },
1779        { USB_DEVICE(0x2304, 0x0226),
1780                        .driver_info = EM2882_BOARD_PINNACLE_HYBRID_PRO },
1781        { USB_DEVICE(0x2304, 0x0227),
1782                        .driver_info = EM2880_BOARD_PINNACLE_PCTV_HD_PRO },
1783        { USB_DEVICE(0x0413, 0x6023),
1784                        .driver_info = EM2800_BOARD_LEADTEK_WINFAST_USBII },
1785        { USB_DEVICE(0x093b, 0xa005),
1786                        .driver_info = EM2861_BOARD_PLEXTOR_PX_TV100U },
1787        { USB_DEVICE(0x04bb, 0x0515),
1788                        .driver_info = EM2820_BOARD_IODATA_GVMVP_SZ },
1789        { USB_DEVICE(0xeb1a, 0x50a6),
1790                        .driver_info = EM2860_BOARD_GADMEI_UTV330 },
1791        { },
1792};
1793MODULE_DEVICE_TABLE(usb, em28xx_id_table);
1794
1795/*
1796 * EEPROM hash table for devices with generic USB IDs
1797 */
1798static struct em28xx_hash_table em28xx_eeprom_hash[] = {
1799        /* P/N: SA 60002070465 Tuner: TVF7533-MF */
1800        {0x6ce05a8f, EM2820_BOARD_PROLINK_PLAYTV_USB2, TUNER_YMEC_TVF_5533MF},
1801        {0x72cc5a8b, EM2820_BOARD_PROLINK_PLAYTV_BOX4_USB2, TUNER_YMEC_TVF_5533MF},
1802        {0x966a0441, EM2880_BOARD_KWORLD_DVB_310U, TUNER_XC2028},
1803        {0x166a0441, EM2880_BOARD_EMPIRE_DUAL_TV, TUNER_XC2028},
1804        {0xcee44a99, EM2882_BOARD_EVGA_INDTUBE, TUNER_XC2028},
1805        {0xb8846b20, EM2881_BOARD_PINNACLE_HYBRID_PRO, TUNER_XC2028},
1806        {0x63f653bd, EM2870_BOARD_REDDO_DVB_C_USB_BOX, TUNER_ABSENT},
1807        {0x4e913442, EM2882_BOARD_DIKOM_DK300, TUNER_XC2028},
1808};
1809
1810/* I2C devicelist hash table for devices with generic USB IDs */
1811static struct em28xx_hash_table em28xx_i2c_hash[] = {
1812        {0xb06a32c3, EM2800_BOARD_TERRATEC_CINERGY_200, TUNER_LG_PAL_NEW_TAPC},
1813        {0xf51200e3, EM2800_BOARD_VGEAR_POCKETTV, TUNER_LG_PAL_NEW_TAPC},
1814        {0x1ba50080, EM2860_BOARD_SAA711X_REFERENCE_DESIGN, TUNER_ABSENT},
1815        {0x77800080, EM2860_BOARD_TVP5150_REFERENCE_DESIGN, TUNER_ABSENT},
1816        {0xc51200e3, EM2820_BOARD_GADMEI_TVR200, TUNER_LG_PAL_NEW_TAPC},
1817        {0x4ba50080, EM2861_BOARD_GADMEI_UTV330PLUS, TUNER_TNF_5335MF},
1818};
1819
1820/* I2C possible address to saa7115, tvp5150, msp3400, tvaudio */
1821static unsigned short saa711x_addrs[] = {
1822        0x4a >> 1, 0x48 >> 1,   /* SAA7111, SAA7111A and SAA7113 */
1823        0x42 >> 1, 0x40 >> 1,   /* SAA7114, SAA7115 and SAA7118 */
1824        I2C_CLIENT_END };
1825
1826static unsigned short tvp5150_addrs[] = {
1827        0xb8 >> 1,
1828        0xba >> 1,
1829        I2C_CLIENT_END
1830};
1831
1832static unsigned short mt9v011_addrs[] = {
1833        0xba >> 1,
1834        I2C_CLIENT_END
1835};
1836
1837static unsigned short msp3400_addrs[] = {
1838        0x80 >> 1,
1839        0x88 >> 1,
1840        I2C_CLIENT_END
1841};
1842
1843int em28xx_tuner_callback(void *ptr, int component, int command, int arg)
1844{
1845        int rc = 0;
1846        struct em28xx *dev = ptr;
1847
1848        if (dev->tuner_type != TUNER_XC2028)
1849                return 0;
1850
1851        if (command != XC2028_TUNER_RESET)
1852                return 0;
1853
1854        rc = em28xx_gpio_set(dev, dev->board.tuner_gpio);
1855
1856        return rc;
1857}
1858EXPORT_SYMBOL_GPL(em28xx_tuner_callback);
1859
1860static inline void em28xx_set_model(struct em28xx *dev)
1861{
1862        memcpy(&dev->board, &em28xx_boards[dev->model], sizeof(dev->board));
1863
1864        /* Those are the default values for the majority of boards
1865           Use those values if not specified otherwise at boards entry
1866         */
1867        if (!dev->board.xclk)
1868                dev->board.xclk = EM28XX_XCLK_IR_RC5_MODE |
1869                                  EM28XX_XCLK_FREQUENCY_12MHZ;
1870
1871        if (!dev->board.i2c_speed)
1872                dev->board.i2c_speed = EM28XX_I2C_CLK_WAIT_ENABLE |
1873                                       EM28XX_I2C_FREQ_100_KHZ;
1874}
1875
1876
1877/* FIXME: Should be replaced by a proper mt9m111 driver */
1878static int em28xx_initialize_mt9m111(struct em28xx *dev)
1879{
1880        int i;
1881        unsigned char regs[][3] = {
1882                { 0x0d, 0x00, 0x01, },  /* reset and use defaults */
1883                { 0x0d, 0x00, 0x00, },
1884                { 0x0a, 0x00, 0x21, },
1885                { 0x21, 0x04, 0x00, },  /* full readout speed, no row/col skipping */
1886        };
1887
1888        for (i = 0; i < ARRAY_SIZE(regs); i++)
1889                i2c_master_send(&dev->i2c_client, &regs[i][0], 3);
1890
1891        return 0;
1892}
1893
1894
1895/* FIXME: Should be replaced by a proper mt9m001 driver */
1896static int em28xx_initialize_mt9m001(struct em28xx *dev)
1897{
1898        int i;
1899        unsigned char regs[][3] = {
1900                { 0x0d, 0x00, 0x01, },
1901                { 0x0d, 0x00, 0x00, },
1902                { 0x04, 0x05, 0x00, },  /* hres = 1280 */
1903                { 0x03, 0x04, 0x00, },  /* vres = 1024 */
1904                { 0x20, 0x11, 0x00, },
1905                { 0x06, 0x00, 0x10, },
1906                { 0x2b, 0x00, 0x24, },
1907                { 0x2e, 0x00, 0x24, },
1908                { 0x35, 0x00, 0x24, },
1909                { 0x2d, 0x00, 0x20, },
1910                { 0x2c, 0x00, 0x20, },
1911                { 0x09, 0x0a, 0xd4, },
1912                { 0x35, 0x00, 0x57, },
1913        };
1914
1915        for (i = 0; i < ARRAY_SIZE(regs); i++)
1916                i2c_master_send(&dev->i2c_client, &regs[i][0], 3);
1917
1918        return 0;
1919}
1920
1921/* HINT method: webcam I2C chips
1922 *
1923 * This method works for webcams with Micron sensors
1924 */
1925static int em28xx_hint_sensor(struct em28xx *dev)
1926{
1927        int rc;
1928        char *sensor_name;
1929        unsigned char cmd;
1930        __be16 version_be;
1931        u16 version;
1932
1933        /* Micron sensor detection */
1934        dev->i2c_client.addr = 0xba >> 1;
1935        cmd = 0;
1936        i2c_master_send(&dev->i2c_client, &cmd, 1);
1937        rc = i2c_master_recv(&dev->i2c_client, (char *)&version_be, 2);
1938        if (rc != 2)
1939                return -EINVAL;
1940
1941        version = be16_to_cpu(version_be);
1942        switch (version) {
1943        case 0x8232:            /* mt9v011 640x480 1.3 Mpix sensor */
1944        case 0x8243:            /* mt9v011 rev B 640x480 1.3 Mpix sensor */
1945                dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
1946                em28xx_set_model(dev);
1947
1948                sensor_name = "mt9v011";
1949                dev->em28xx_sensor = EM28XX_MT9V011;
1950                dev->sensor_xres = 640;
1951                dev->sensor_yres = 480;
1952                /*
1953                 * FIXME: mt9v011 uses I2S speed as xtal clk - at least with
1954                 * the Silvercrest cam I have here for testing - for higher
1955                 * resolutions, a high clock cause horizontal artifacts, so we
1956                 * need to use a lower xclk frequency.
1957                 * Yet, it would be possible to adjust xclk depending on the
1958                 * desired resolution, since this affects directly the
1959                 * frame rate.
1960                 */
1961                dev->board.xclk = EM28XX_XCLK_FREQUENCY_4_3MHZ;
1962                dev->sensor_xtal = 4300000;
1963
1964                /* probably means GRGB 16 bit bayer */
1965                dev->vinmode = 0x0d;
1966                dev->vinctl = 0x00;
1967
1968                break;
1969
1970        case 0x143a:    /* MT9M111 as found in the ECS G200 */
1971                dev->model = EM2750_BOARD_UNKNOWN;
1972                em28xx_set_model(dev);
1973
1974                sensor_name = "mt9m111";
1975                dev->board.xclk = EM28XX_XCLK_FREQUENCY_48MHZ;
1976                dev->em28xx_sensor = EM28XX_MT9M111;
1977                em28xx_initialize_mt9m111(dev);
1978                dev->sensor_xres = 640;
1979                dev->sensor_yres = 512;
1980
1981                dev->vinmode = 0x0a;
1982                dev->vinctl = 0x00;
1983
1984                break;
1985
1986        case 0x8431:
1987                dev->model = EM2750_BOARD_UNKNOWN;
1988                em28xx_set_model(dev);
1989
1990                sensor_name = "mt9m001";
1991                dev->em28xx_sensor = EM28XX_MT9M001;
1992                em28xx_initialize_mt9m001(dev);
1993                dev->sensor_xres = 1280;
1994                dev->sensor_yres = 1024;
1995
1996                /* probably means BGGR 16 bit bayer */
1997                dev->vinmode = 0x0c;
1998                dev->vinctl = 0x00;
1999
2000                break;
2001        default:
2002                printk("Unknown Micron Sensor 0x%04x\n", version);
2003                return -EINVAL;
2004        }
2005
2006        /* Setup webcam defaults */
2007        em28xx_pre_card_setup(dev);
2008
2009        em28xx_errdev("Sensor is %s, using model %s entry.\n",
2010                      sensor_name, em28xx_boards[dev->model].name);
2011
2012        return 0;
2013}
2014
2015/* Since em28xx_pre_card_setup() requires a proper dev->model,
2016 * this won't work for boards with generic PCI IDs
2017 */
2018void em28xx_pre_card_setup(struct em28xx *dev)
2019{
2020        /* Set the initial XCLK and I2C clock values based on the board
2021           definition */
2022        em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
2023        em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, dev->board.i2c_speed);
2024        msleep(50);
2025
2026        /* request some modules */
2027        switch (dev->model) {
2028        case EM2861_BOARD_PLEXTOR_PX_TV100U:
2029                /* Sets the msp34xx I2S speed */
2030                dev->i2s_speed = 2048000;
2031                break;
2032        case EM2861_BOARD_KWORLD_PVRTV_300U:
2033        case EM2880_BOARD_KWORLD_DVB_305U:
2034                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x6d);
2035                msleep(10);
2036                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0x7d);
2037                msleep(10);
2038                break;
2039        case EM2870_BOARD_COMPRO_VIDEOMATE:
2040                /* TODO: someone can do some cleanup here...
2041                         not everything's needed */
2042                em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2043                msleep(10);
2044                em28xx_write_reg(dev, EM2880_R04_GPO, 0x01);
2045                msleep(10);
2046                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2047                mdelay(70);
2048                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
2049                mdelay(70);
2050                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xdc);
2051                mdelay(70);
2052                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfc);
2053                mdelay(70);
2054                break;
2055        case EM2870_BOARD_TERRATEC_XS_MT2060:
2056                /* this device needs some gpio writes to get the DVB-T
2057                   demod work */
2058                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2059                mdelay(70);
2060                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
2061                mdelay(70);
2062                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2063                mdelay(70);
2064                break;
2065        case EM2870_BOARD_PINNACLE_PCTV_DVB:
2066                /* this device needs some gpio writes to get the
2067                   DVB-T demod work */
2068                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2069                mdelay(70);
2070                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xde);
2071                mdelay(70);
2072                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2073                mdelay(70);
2074                break;
2075        case EM2820_BOARD_GADMEI_UTV310:
2076        case EM2820_BOARD_MSI_VOX_USB_2:
2077                /* enables audio for that devices */
2078                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2079                break;
2080
2081        case EM2882_BOARD_KWORLD_ATSC_315U:
2082                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
2083                msleep(10);
2084                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2085                msleep(10);
2086                em28xx_write_reg(dev, EM2880_R04_GPO, 0x00);
2087                msleep(10);
2088                em28xx_write_reg(dev, EM2880_R04_GPO, 0x08);
2089                msleep(10);
2090                break;
2091
2092        case EM2860_BOARD_KAIOMY_TVNPC_U2:
2093                em28xx_write_regs(dev, EM28XX_R0F_XCLK, "\x07", 1);
2094                em28xx_write_regs(dev, EM28XX_R06_I2C_CLK, "\x40", 1);
2095                em28xx_write_regs(dev, 0x0d, "\x42", 1);
2096                em28xx_write_regs(dev, 0x08, "\xfd", 1);
2097                msleep(10);
2098                em28xx_write_regs(dev, 0x08, "\xff", 1);
2099                msleep(10);
2100                em28xx_write_regs(dev, 0x08, "\x7f", 1);
2101                msleep(10);
2102                em28xx_write_regs(dev, 0x08, "\x6b", 1);
2103
2104                break;
2105        case EM2860_BOARD_EASYCAP:
2106                em28xx_write_regs(dev, 0x08, "\xf8", 1);
2107                break;
2108
2109        case EM2820_BOARD_IODATA_GVMVP_SZ:
2110                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
2111                msleep(70);
2112                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
2113                msleep(10);
2114                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfe);
2115                msleep(70);
2116                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2117                msleep(70);
2118                break;
2119        }
2120
2121        em28xx_gpio_set(dev, dev->board.tuner_gpio);
2122        em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2123
2124        /* Unlock device */
2125        em28xx_set_mode(dev, EM28XX_SUSPEND);
2126}
2127
2128static void em28xx_setup_xc3028(struct em28xx *dev, struct xc2028_ctrl *ctl)
2129{
2130        memset(ctl, 0, sizeof(*ctl));
2131
2132        ctl->fname   = XC2028_DEFAULT_FIRMWARE;
2133        ctl->max_len = 64;
2134        ctl->mts = em28xx_boards[dev->model].mts_firmware;
2135
2136        switch (dev->model) {
2137        case EM2880_BOARD_EMPIRE_DUAL_TV:
2138        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2139        case EM2882_BOARD_TERRATEC_HYBRID_XS:
2140                ctl->demod = XC3028_FE_ZARLINK456;
2141                break;
2142        case EM2880_BOARD_TERRATEC_HYBRID_XS:
2143        case EM2881_BOARD_PINNACLE_HYBRID_PRO:
2144                ctl->demod = XC3028_FE_ZARLINK456;
2145                break;
2146        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2147                /* djh - Not sure which demod we need here */
2148                ctl->demod = XC3028_FE_DEFAULT;
2149                break;
2150        case EM2880_BOARD_AMD_ATI_TV_WONDER_HD_600:
2151                ctl->demod = XC3028_FE_DEFAULT;
2152                ctl->fname = XC3028L_DEFAULT_FIRMWARE;
2153                break;
2154        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2155        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2156        case EM2880_BOARD_PINNACLE_PCTV_HD_PRO:
2157                /* FIXME: Better to specify the needed IF */
2158                ctl->demod = XC3028_FE_DEFAULT;
2159                break;
2160        case EM2883_BOARD_KWORLD_HYBRID_330U:
2161        case EM2882_BOARD_DIKOM_DK300:
2162        case EM2882_BOARD_KWORLD_VS_DVBT:
2163                ctl->demod = XC3028_FE_CHINA;
2164                ctl->fname = XC2028_DEFAULT_FIRMWARE;
2165                break;
2166        case EM2882_BOARD_EVGA_INDTUBE:
2167                ctl->demod = XC3028_FE_CHINA;
2168                ctl->fname = XC3028L_DEFAULT_FIRMWARE;
2169                break;
2170        default:
2171                ctl->demod = XC3028_FE_OREN538;
2172        }
2173}
2174
2175static void em28xx_tuner_setup(struct em28xx *dev)
2176{
2177        struct tuner_setup           tun_setup;
2178        struct v4l2_frequency        f;
2179
2180        if (dev->tuner_type == TUNER_ABSENT)
2181                return;
2182
2183        memset(&tun_setup, 0, sizeof(tun_setup));
2184
2185        tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
2186        tun_setup.tuner_callback = em28xx_tuner_callback;
2187
2188        if (dev->board.radio.type) {
2189                tun_setup.type = dev->board.radio.type;
2190                tun_setup.addr = dev->board.radio_addr;
2191
2192                v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
2193        }
2194
2195        if ((dev->tuner_type != TUNER_ABSENT) && (dev->tuner_type)) {
2196                tun_setup.type   = dev->tuner_type;
2197                tun_setup.addr   = dev->tuner_addr;
2198
2199                v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_type_addr, &tun_setup);
2200        }
2201
2202        if (dev->tda9887_conf) {
2203                struct v4l2_priv_tun_config tda9887_cfg;
2204
2205                tda9887_cfg.tuner = TUNER_TDA9887;
2206                tda9887_cfg.priv = &dev->tda9887_conf;
2207
2208                v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &tda9887_cfg);
2209        }
2210
2211        if (dev->tuner_type == TUNER_XC2028) {
2212                struct v4l2_priv_tun_config  xc2028_cfg;
2213                struct xc2028_ctrl           ctl;
2214
2215                memset(&xc2028_cfg, 0, sizeof(xc2028_cfg));
2216                memset(&ctl, 0, sizeof(ctl));
2217
2218                em28xx_setup_xc3028(dev, &ctl);
2219
2220                xc2028_cfg.tuner = TUNER_XC2028;
2221                xc2028_cfg.priv  = &ctl;
2222
2223                v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_config, &xc2028_cfg);
2224        }
2225
2226        /* configure tuner */
2227        f.tuner = 0;
2228        f.type = V4L2_TUNER_ANALOG_TV;
2229        f.frequency = 9076;     /* just a magic number */
2230        dev->ctl_freq = f.frequency;
2231        v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, &f);
2232}
2233
2234static int em28xx_hint_board(struct em28xx *dev)
2235{
2236        int i;
2237
2238        /* HINT method: EEPROM
2239         *
2240         * This method works only for boards with eeprom.
2241         * Uses a hash of all eeprom bytes. The hash should be
2242         * unique for a vendor/tuner pair.
2243         * There are a high chance that tuners for different
2244         * video standards produce different hashes.
2245         */
2246        for (i = 0; i < ARRAY_SIZE(em28xx_eeprom_hash); i++) {
2247                if (dev->hash == em28xx_eeprom_hash[i].hash) {
2248                        dev->model = em28xx_eeprom_hash[i].model;
2249                        dev->tuner_type = em28xx_eeprom_hash[i].tuner;
2250
2251                        em28xx_errdev("Your board has no unique USB ID.\n");
2252                        em28xx_errdev("A hint were successfully done, "
2253                                      "based on eeprom hash.\n");
2254                        em28xx_errdev("This method is not 100%% failproof.\n");
2255                        em28xx_errdev("If the board were missdetected, "
2256                                      "please email this log to:\n");
2257                        em28xx_errdev("\tV4L Mailing List "
2258                                      " <linux-media@vger.kernel.org>\n");
2259                        em28xx_errdev("Board detected as %s\n",
2260                                      em28xx_boards[dev->model].name);
2261
2262                        return 0;
2263                }
2264        }
2265
2266        /* HINT method: I2C attached devices
2267         *
2268         * This method works for all boards.
2269         * Uses a hash of i2c scanned devices.
2270         * Devices with the same i2c attached chips will
2271         * be considered equal.
2272         * This method is less precise than the eeprom one.
2273         */
2274
2275        /* user did not request i2c scanning => do it now */
2276        if (!dev->i2c_hash)
2277                em28xx_do_i2c_scan(dev);
2278
2279        for (i = 0; i < ARRAY_SIZE(em28xx_i2c_hash); i++) {
2280                if (dev->i2c_hash == em28xx_i2c_hash[i].hash) {
2281                        dev->model = em28xx_i2c_hash[i].model;
2282                        dev->tuner_type = em28xx_i2c_hash[i].tuner;
2283                        em28xx_errdev("Your board has no unique USB ID.\n");
2284                        em28xx_errdev("A hint were successfully done, "
2285                                      "based on i2c devicelist hash.\n");
2286                        em28xx_errdev("This method is not 100%% failproof.\n");
2287                        em28xx_errdev("If the board were missdetected, "
2288                                      "please email this log to:\n");
2289                        em28xx_errdev("\tV4L Mailing List "
2290                                      " <linux-media@vger.kernel.org>\n");
2291                        em28xx_errdev("Board detected as %s\n",
2292                                      em28xx_boards[dev->model].name);
2293
2294                        return 0;
2295                }
2296        }
2297
2298        em28xx_errdev("Your board has no unique USB ID and thus need a "
2299                      "hint to be detected.\n");
2300        em28xx_errdev("You may try to use card=<n> insmod option to "
2301                      "workaround that.\n");
2302        em28xx_errdev("Please send an email with this log to:\n");
2303        em28xx_errdev("\tV4L Mailing List <linux-media@vger.kernel.org>\n");
2304        em28xx_errdev("Board eeprom hash is 0x%08lx\n", dev->hash);
2305        em28xx_errdev("Board i2c devicelist hash is 0x%08lx\n", dev->i2c_hash);
2306
2307        em28xx_errdev("Here is a list of valid choices for the card=<n>"
2308                      " insmod option:\n");
2309        for (i = 0; i < em28xx_bcount; i++) {
2310                em28xx_errdev("    card=%d -> %s\n",
2311                                i, em28xx_boards[i].name);
2312        }
2313        return -1;
2314}
2315
2316/* ----------------------------------------------------------------------- */
2317void em28xx_register_i2c_ir(struct em28xx *dev)
2318{
2319        /* Leadtek winfast tv USBII deluxe can find a non working IR-device */
2320        /* at address 0x18, so if that address is needed for another board in */
2321        /* the future, please put it after 0x1f. */
2322        struct i2c_board_info info;
2323        const unsigned short addr_list[] = {
2324                 0x1f, 0x30, 0x47, I2C_CLIENT_END
2325        };
2326
2327        if (disable_ir)
2328                return;
2329
2330        memset(&info, 0, sizeof(struct i2c_board_info));
2331        memset(&dev->init_data, 0, sizeof(dev->init_data));
2332        strlcpy(info.type, "ir_video", I2C_NAME_SIZE);
2333
2334        /* detect & configure */
2335        switch (dev->model) {
2336        case EM2800_BOARD_TERRATEC_CINERGY_200:
2337        case EM2820_BOARD_TERRATEC_CINERGY_250:
2338                dev->init_data.ir_codes = RC_MAP_EM_TERRATEC;
2339                dev->init_data.get_key = em28xx_get_key_terratec;
2340                dev->init_data.name = "i2c IR (EM28XX Terratec)";
2341                break;
2342        case EM2820_BOARD_PINNACLE_USB_2:
2343                dev->init_data.ir_codes = RC_MAP_PINNACLE_GREY;
2344                dev->init_data.get_key = em28xx_get_key_pinnacle_usb_grey;
2345                dev->init_data.name = "i2c IR (EM28XX Pinnacle PCTV)";
2346                break;
2347        case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2348                dev->init_data.ir_codes = RC_MAP_RC5_HAUPPAUGE_NEW;
2349                dev->init_data.get_key = em28xx_get_key_em_haup;
2350                dev->init_data.name = "i2c IR (EM2840 Hauppauge)";
2351        case EM2820_BOARD_LEADTEK_WINFAST_USBII_DELUXE:
2352                dev->init_data.ir_codes = RC_MAP_WINFAST_USBII_DELUXE;;
2353                dev->init_data.get_key = em28xx_get_key_winfast_usbii_deluxe;
2354                dev->init_data.name = "i2c IR (EM2820 Winfast TV USBII Deluxe)";
2355                break;
2356        }
2357
2358        if (dev->init_data.name)
2359                info.platform_data = &dev->init_data;
2360        i2c_new_probed_device(&dev->i2c_adap, &info, addr_list);
2361}
2362
2363void em28xx_card_setup(struct em28xx *dev)
2364{
2365        /*
2366         * If the device can be a webcam, seek for a sensor.
2367         * If sensor is not found, then it isn't a webcam.
2368         */
2369        if (dev->board.is_webcam) {
2370                if (em28xx_hint_sensor(dev) < 0)
2371                        dev->board.is_webcam = 0;
2372                else
2373                        dev->progressive = 1;
2374        } else
2375                em28xx_set_model(dev);
2376
2377        em28xx_info("Identified as %s (card=%d)\n",
2378                    dev->board.name, dev->model);
2379
2380        dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2381        if (em28xx_boards[dev->model].tuner_addr)
2382                dev->tuner_addr = em28xx_boards[dev->model].tuner_addr;
2383
2384        if (em28xx_boards[dev->model].tda9887_conf)
2385                dev->tda9887_conf = em28xx_boards[dev->model].tda9887_conf;
2386
2387        /* request some modules */
2388        switch (dev->model) {
2389        case EM2820_BOARD_HAUPPAUGE_WINTV_USB_2:
2390        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
2391        case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900_R2:
2392        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_850:
2393        case EM2883_BOARD_HAUPPAUGE_WINTV_HVR_950:
2394        {
2395                struct tveeprom tv;
2396#if defined(CONFIG_MODULES) && defined(MODULE)
2397                request_module("tveeprom");
2398#endif
2399                /* Call first TVeeprom */
2400
2401                dev->i2c_client.addr = 0xa0 >> 1;
2402                tveeprom_hauppauge_analog(&dev->i2c_client, &tv, dev->eedata);
2403
2404                dev->tuner_type = tv.tuner_type;
2405
2406                if (tv.audio_processor == V4L2_IDENT_MSPX4XX) {
2407                        dev->i2s_speed = 2048000;
2408                        dev->board.has_msp34xx = 1;
2409                }
2410                break;
2411        }
2412        case EM2882_BOARD_KWORLD_ATSC_315U:
2413                em28xx_write_reg(dev, 0x0d, 0x42);
2414                msleep(10);
2415                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
2416                msleep(10);
2417                break;
2418        case EM2820_BOARD_KWORLD_PVRTV2800RF:
2419                /* GPIO enables sound on KWORLD PVR TV 2800RF */
2420                em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf9);
2421                break;
2422        case EM2820_BOARD_UNKNOWN:
2423        case EM2800_BOARD_UNKNOWN:
2424                /*
2425                 * The K-WORLD DVB-T 310U is detected as an MSI Digivox AD.
2426                 *
2427                 * This occurs because they share identical USB vendor and
2428                 * product IDs.
2429                 *
2430                 * What we do here is look up the EEPROM hash of the K-WORLD
2431                 * and if it is found then we decide that we do not have
2432                 * a DIGIVOX and reset the device to the K-WORLD instead.
2433                 *
2434                 * This solution is only valid if they do not share eeprom
2435                 * hash identities which has not been determined as yet.
2436                 */
2437        case EM2880_BOARD_MSI_DIGIVOX_AD:
2438                if (!em28xx_hint_board(dev))
2439                        em28xx_set_model(dev);
2440
2441                /* In cases where we had to use a board hint, the call to
2442                   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
2443                   so make the call now so the analog GPIOs are set properly
2444                   before probing the i2c bus. */
2445                em28xx_gpio_set(dev, dev->board.tuner_gpio);
2446                em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2447                break;
2448
2449/*
2450                 * The Dikom DK300 is detected as an Kworld VS-DVB-T 323UR.
2451                 *
2452                 * This occurs because they share identical USB vendor and
2453                 * product IDs.
2454                 *
2455                 * What we do here is look up the EEPROM hash of the Dikom
2456                 * and if it is found then we decide that we do not have
2457                 * a Kworld and reset the device to the Dikom instead.
2458                 *
2459                 * This solution is only valid if they do not share eeprom
2460                 * hash identities which has not been determined as yet.
2461                 */
2462        case EM2882_BOARD_KWORLD_VS_DVBT:
2463                if (!em28xx_hint_board(dev))
2464                        em28xx_set_model(dev);
2465
2466                /* In cases where we had to use a board hint, the call to
2467                   em28xx_set_mode() in em28xx_pre_card_setup() was a no-op,
2468                   so make the call now so the analog GPIOs are set properly
2469                   before probing the i2c bus. */
2470                em28xx_gpio_set(dev, dev->board.tuner_gpio);
2471                em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2472                break;
2473        }
2474
2475#if defined(CONFIG_MODULES) && defined(MODULE)
2476        if (dev->board.has_ir_i2c && !disable_ir)
2477                request_module("ir-kbd-i2c");
2478#endif
2479        if (dev->board.has_snapshot_button)
2480                em28xx_register_snapshot_button(dev);
2481
2482        if (dev->board.valid == EM28XX_BOARD_NOT_VALIDATED) {
2483                em28xx_errdev("\n\n");
2484                em28xx_errdev("The support for this board weren't "
2485                              "valid yet.\n");
2486                em28xx_errdev("Please send a report of having this working\n");
2487                em28xx_errdev("not to V4L mailing list (and/or to other "
2488                                "addresses)\n\n");
2489        }
2490
2491        /* Allow override tuner type by a module parameter */
2492        if (tuner >= 0)
2493                dev->tuner_type = tuner;
2494
2495        /* request some modules */
2496        if (dev->board.has_msp34xx)
2497                v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2498                        "msp3400", "msp3400", 0, msp3400_addrs);
2499
2500        if (dev->board.decoder == EM28XX_SAA711X)
2501                v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2502                        "saa7115", "saa7115_auto", 0, saa711x_addrs);
2503
2504        if (dev->board.decoder == EM28XX_TVP5150)
2505                v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2506                        "tvp5150", "tvp5150", 0, tvp5150_addrs);
2507
2508        if (dev->em28xx_sensor == EM28XX_MT9V011) {
2509                struct v4l2_subdev *sd;
2510
2511                sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2512                         &dev->i2c_adap, "mt9v011", "mt9v011", 0, mt9v011_addrs);
2513                v4l2_subdev_call(sd, core, s_config, 0, &dev->sensor_xtal);
2514        }
2515
2516
2517        if (dev->board.adecoder == EM28XX_TVAUDIO)
2518                v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2519                        "tvaudio", "tvaudio", dev->board.tvaudio_addr, NULL);
2520
2521        if (dev->board.tuner_type != TUNER_ABSENT) {
2522                int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
2523
2524                if (dev->board.radio.type)
2525                        v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2526                                "tuner", "tuner", dev->board.radio_addr, NULL);
2527
2528                if (has_demod)
2529                        v4l2_i2c_new_subdev(&dev->v4l2_dev,
2530                                &dev->i2c_adap, "tuner", "tuner",
2531                                0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
2532                if (dev->tuner_addr == 0) {
2533                        enum v4l2_i2c_tuner_type type =
2534                                has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
2535                        struct v4l2_subdev *sd;
2536
2537                        sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
2538                                &dev->i2c_adap, "tuner", "tuner",
2539                                0, v4l2_i2c_tuner_addrs(type));
2540
2541                        if (sd)
2542                                dev->tuner_addr = v4l2_i2c_subdev_addr(sd);
2543                } else {
2544                        v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
2545                                "tuner", "tuner", dev->tuner_addr, NULL);
2546                }
2547        }
2548
2549        em28xx_tuner_setup(dev);
2550
2551        if(!disable_ir)
2552                em28xx_ir_init(dev);
2553}
2554
2555
2556#if defined(CONFIG_MODULES) && defined(MODULE)
2557static void request_module_async(struct work_struct *work)
2558{
2559        struct em28xx *dev = container_of(work,
2560                             struct em28xx, request_module_wk);
2561
2562        if (dev->has_audio_class)
2563                request_module("snd-usb-audio");
2564        else if (dev->has_alsa_audio)
2565                request_module("em28xx-alsa");
2566
2567        if (dev->board.has_dvb)
2568                request_module("em28xx-dvb");
2569}
2570
2571static void request_modules(struct em28xx *dev)
2572{
2573        INIT_WORK(&dev->request_module_wk, request_module_async);
2574        schedule_work(&dev->request_module_wk);
2575}
2576#else
2577#define request_modules(dev)
2578#endif /* CONFIG_MODULES */
2579
2580/*
2581 * em28xx_realease_resources()
2582 * unregisters the v4l2,i2c and usb devices
2583 * called when the device gets disconected or at module unload
2584*/
2585void em28xx_release_resources(struct em28xx *dev)
2586{
2587        if (dev->sbutton_input_dev)
2588                em28xx_deregister_snapshot_button(dev);
2589
2590        if (dev->ir)
2591                em28xx_ir_fini(dev);
2592
2593        /*FIXME: I2C IR should be disconnected */
2594
2595        em28xx_release_analog_resources(dev);
2596
2597        em28xx_remove_from_devlist(dev);
2598
2599        em28xx_i2c_unregister(dev);
2600
2601        v4l2_device_unregister(&dev->v4l2_dev);
2602
2603        usb_put_dev(dev->udev);
2604
2605        /* Mark device as unused */
2606        em28xx_devused &= ~(1 << dev->devno);
2607};
2608
2609/*
2610 * em28xx_init_dev()
2611 * allocates and inits the device structs, registers i2c bus and v4l device
2612 */
2613static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2614                           struct usb_interface *interface,
2615                           int minor)
2616{
2617        struct em28xx *dev = *devhandle;
2618        int retval;
2619        int errCode;
2620
2621        dev->udev = udev;
2622        mutex_init(&dev->ctrl_urb_lock);
2623        spin_lock_init(&dev->slock);
2624        init_waitqueue_head(&dev->open);
2625        init_waitqueue_head(&dev->wait_frame);
2626        init_waitqueue_head(&dev->wait_stream);
2627
2628        dev->em28xx_write_regs = em28xx_write_regs;
2629        dev->em28xx_read_reg = em28xx_read_reg;
2630        dev->em28xx_read_reg_req_len = em28xx_read_reg_req_len;
2631        dev->em28xx_write_regs_req = em28xx_write_regs_req;
2632        dev->em28xx_read_reg_req = em28xx_read_reg_req;
2633        dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
2634
2635        em28xx_set_model(dev);
2636
2637        /* Set the default GPO/GPIO for legacy devices */
2638        dev->reg_gpo_num = EM2880_R04_GPO;
2639        dev->reg_gpio_num = EM28XX_R08_GPIO;
2640
2641        dev->wait_after_write = 5;
2642
2643        /* Based on the Chip ID, set the device configuration */
2644        retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
2645        if (retval > 0) {
2646                dev->chip_id = retval;
2647
2648                switch (dev->chip_id) {
2649                case CHIP_ID_EM2800:
2650                        em28xx_info("chip ID is em2800\n");
2651                        break;
2652                case CHIP_ID_EM2710:
2653                        em28xx_info("chip ID is em2710\n");
2654                        break;
2655                case CHIP_ID_EM2750:
2656                        em28xx_info("chip ID is em2750\n");
2657                        break;
2658                case CHIP_ID_EM2820:
2659                        em28xx_info("chip ID is em2820 (or em2710)\n");
2660                        break;
2661                case CHIP_ID_EM2840:
2662                        em28xx_info("chip ID is em2840\n");
2663                        break;
2664                case CHIP_ID_EM2860:
2665                        em28xx_info("chip ID is em2860\n");
2666                        break;
2667                case CHIP_ID_EM2870:
2668                        em28xx_info("chip ID is em2870\n");
2669                        dev->wait_after_write = 0;
2670                        break;
2671                case CHIP_ID_EM2874:
2672                        em28xx_info("chip ID is em2874\n");
2673                        dev->reg_gpio_num = EM2874_R80_GPIO;
2674                        dev->wait_after_write = 0;
2675                        break;
2676                case CHIP_ID_EM2883:
2677                        em28xx_info("chip ID is em2882/em2883\n");
2678                        dev->wait_after_write = 0;
2679                        break;
2680                default:
2681                        em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
2682                }
2683        }
2684
2685        /* Prepopulate cached GPO register content */
2686        retval = em28xx_read_reg(dev, dev->reg_gpo_num);
2687        if (retval >= 0)
2688                dev->reg_gpo = retval;
2689
2690        em28xx_pre_card_setup(dev);
2691
2692        if (!dev->board.is_em2800) {
2693                /* Sets I2C speed to 100 KHz */
2694                retval = em28xx_write_reg(dev, EM28XX_R06_I2C_CLK, 0x40);
2695                if (retval < 0) {
2696                        em28xx_errdev("%s: em28xx_write_regs_req failed!"
2697                                      " retval [%d]\n",
2698                                      __func__, retval);
2699                        return retval;
2700                }
2701        }
2702
2703        retval = v4l2_device_register(&interface->dev, &dev->v4l2_dev);
2704        if (retval < 0) {
2705                em28xx_errdev("Call to v4l2_device_register() failed!\n");
2706                return retval;
2707        }
2708
2709        /* register i2c bus */
2710        errCode = em28xx_i2c_register(dev);
2711        if (errCode < 0) {
2712                v4l2_device_unregister(&dev->v4l2_dev);
2713                em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n",
2714                        __func__, errCode);
2715                return errCode;
2716        }
2717
2718        /*
2719         * Default format, used for tvp5150 or saa711x output formats
2720         */
2721        dev->vinmode = 0x10;
2722        dev->vinctl  = EM28XX_VINCTRL_INTERLACED |
2723                       EM28XX_VINCTRL_CCIR656_ENABLE;
2724
2725        /* Do board specific init and eeprom reading */
2726        em28xx_card_setup(dev);
2727
2728        /* Configure audio */
2729        errCode = em28xx_audio_setup(dev);
2730        if (errCode < 0) {
2731                v4l2_device_unregister(&dev->v4l2_dev);
2732                em28xx_errdev("%s: Error while setting audio - errCode [%d]!\n",
2733                        __func__, errCode);
2734        }
2735
2736        /* wake i2c devices */
2737        em28xx_wake_i2c(dev);
2738
2739        /* init video dma queues */
2740        INIT_LIST_HEAD(&dev->vidq.active);
2741        INIT_LIST_HEAD(&dev->vidq.queued);
2742        INIT_LIST_HEAD(&dev->vbiq.active);
2743        INIT_LIST_HEAD(&dev->vbiq.queued);
2744
2745        if (dev->board.has_msp34xx) {
2746                /* Send a reset to other chips via gpio */
2747                errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xf7);
2748                if (errCode < 0) {
2749                        em28xx_errdev("%s: em28xx_write_regs_req - "
2750                                      "msp34xx(1) failed! errCode [%d]\n",
2751                                      __func__, errCode);
2752                        return errCode;
2753                }
2754                msleep(3);
2755
2756                errCode = em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xff);
2757                if (errCode < 0) {
2758                        em28xx_errdev("%s: em28xx_write_regs_req - "
2759                                      "msp34xx(2) failed! errCode [%d]\n",
2760                                      __func__, errCode);
2761                        return errCode;
2762                }
2763                msleep(3);
2764        }
2765
2766        em28xx_add_into_devlist(dev);
2767
2768        retval = em28xx_register_analog_devices(dev);
2769        if (retval < 0) {
2770                em28xx_release_resources(dev);
2771                goto fail_reg_devices;
2772        }
2773
2774        em28xx_init_extension(dev);
2775
2776        /* Save some power by putting tuner to sleep */
2777        v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_power, 0);
2778
2779        return 0;
2780
2781fail_reg_devices:
2782        return retval;
2783}
2784
2785/*
2786 * em28xx_usb_probe()
2787 * checks for supported devices
2788 */
2789static int em28xx_usb_probe(struct usb_interface *interface,
2790                            const struct usb_device_id *id)
2791{
2792        const struct usb_endpoint_descriptor *endpoint;
2793        struct usb_device *udev;
2794        struct usb_interface *uif;
2795        struct em28xx *dev = NULL;
2796        int retval;
2797        int i, nr, ifnum, isoc_pipe;
2798        char *speed;
2799        char descr[255] = "";
2800
2801        udev = usb_get_dev(interface_to_usbdev(interface));
2802        ifnum = interface->altsetting[0].desc.bInterfaceNumber;
2803
2804        /* Check to see next free device and mark as used */
2805        nr = find_first_zero_bit(&em28xx_devused, EM28XX_MAXBOARDS);
2806        em28xx_devused |= 1<<nr;
2807
2808        /* Don't register audio interfaces */
2809        if (interface->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2810                em28xx_err(DRIVER_NAME " audio device (%04x:%04x): "
2811                        "interface %i, class %i\n",
2812                        le16_to_cpu(udev->descriptor.idVendor),
2813                        le16_to_cpu(udev->descriptor.idProduct),
2814                        ifnum,
2815                        interface->altsetting[0].desc.bInterfaceClass);
2816
2817                em28xx_devused &= ~(1<<nr);
2818                retval = -ENODEV;
2819                goto err;
2820        }
2821
2822        endpoint = &interface->cur_altsetting->endpoint[0].desc;
2823
2824        /* check if the device has the iso in endpoint at the correct place */
2825        if (usb_endpoint_xfer_isoc(endpoint)
2826            &&
2827            (interface->altsetting[1].endpoint[0].desc.wMaxPacketSize == 940)) {
2828                /* It's a newer em2874/em2875 device */
2829                isoc_pipe = 0;
2830        } else {
2831                int check_interface = 1;
2832                isoc_pipe = 1;
2833                endpoint = &interface->cur_altsetting->endpoint[1].desc;
2834                if (!usb_endpoint_xfer_isoc(endpoint))
2835                        check_interface = 0;
2836
2837                if (usb_endpoint_dir_out(endpoint))
2838                        check_interface = 0;
2839
2840                if (!check_interface) {
2841                        em28xx_err(DRIVER_NAME " video device (%04x:%04x): "
2842                                "interface %i, class %i found.\n",
2843                                le16_to_cpu(udev->descriptor.idVendor),
2844                                le16_to_cpu(udev->descriptor.idProduct),
2845                                ifnum,
2846                                interface->altsetting[0].desc.bInterfaceClass);
2847
2848                        em28xx_err(DRIVER_NAME " This is an anciliary "
2849                                "interface not used by the driver\n");
2850
2851                        em28xx_devused &= ~(1<<nr);
2852                        retval = -ENODEV;
2853                        goto err;
2854                }
2855        }
2856
2857        switch (udev->speed) {
2858        case USB_SPEED_LOW:
2859                speed = "1.5";
2860                break;
2861        case USB_SPEED_UNKNOWN:
2862        case USB_SPEED_FULL:
2863                speed = "12";
2864                break;
2865        case USB_SPEED_HIGH:
2866                speed = "480";
2867                break;
2868        default:
2869                speed = "unknown";
2870        }
2871
2872        if (udev->manufacturer)
2873                strlcpy(descr, udev->manufacturer, sizeof(descr));
2874
2875        if (udev->product) {
2876                if (*descr)
2877                        strlcat(descr, " ", sizeof(descr));
2878                strlcat(descr, udev->product, sizeof(descr));
2879        }
2880        if (*descr)
2881                strlcat(descr, " ", sizeof(descr));
2882
2883        printk(DRIVER_NAME ": New device %s@ %s Mbps "
2884                "(%04x:%04x, interface %d, class %d)\n",
2885                descr,
2886                speed,
2887                le16_to_cpu(udev->descriptor.idVendor),
2888                le16_to_cpu(udev->descriptor.idProduct),
2889                ifnum,
2890                interface->altsetting->desc.bInterfaceNumber);
2891
2892        /*
2893         * Make sure we have 480 Mbps of bandwidth, otherwise things like
2894         * video stream wouldn't likely work, since 12 Mbps is generally
2895         * not enough even for most Digital TV streams.
2896         */
2897        if (udev->speed != USB_SPEED_HIGH && disable_usb_speed_check == 0) {
2898                printk(DRIVER_NAME ": Device initialization failed.\n");
2899                printk(DRIVER_NAME ": Device must be connected to a high-speed"
2900                       " USB 2.0 port.\n");
2901                em28xx_devused &= ~(1<<nr);
2902                retval = -ENODEV;
2903                goto err;
2904        }
2905
2906        if (nr >= EM28XX_MAXBOARDS) {
2907                printk(DRIVER_NAME ": Supports only %i em28xx boards.\n",
2908                                EM28XX_MAXBOARDS);
2909                em28xx_devused &= ~(1<<nr);
2910                retval = -ENOMEM;
2911                goto err;
2912        }
2913
2914        /* allocate memory for our device state and initialize it */
2915        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
2916        if (dev == NULL) {
2917                em28xx_err(DRIVER_NAME ": out of memory!\n");
2918                em28xx_devused &= ~(1<<nr);
2919                retval = -ENOMEM;
2920                goto err;
2921        }
2922
2923        snprintf(dev->name, 29, "em28xx #%d", nr);
2924        dev->devno = nr;
2925        dev->model = id->driver_info;
2926        dev->alt   = -1;
2927
2928        /* Checks if audio is provided by some interface */
2929        for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
2930                uif = udev->config->interface[i];
2931                if (uif->altsetting[0].desc.bInterfaceClass == USB_CLASS_AUDIO) {
2932                        dev->has_audio_class = 1;
2933                        break;
2934                }
2935        }
2936
2937        /* compute alternate max packet sizes */
2938        uif = udev->actconfig->interface[0];
2939
2940        dev->num_alt = uif->num_altsetting;
2941        dev->alt_max_pkt_size = kmalloc(32 * dev->num_alt, GFP_KERNEL);
2942
2943        if (dev->alt_max_pkt_size == NULL) {
2944                em28xx_errdev("out of memory!\n");
2945                em28xx_devused &= ~(1<<nr);
2946                kfree(dev);
2947                retval = -ENOMEM;
2948                goto err;
2949        }
2950
2951        for (i = 0; i < dev->num_alt ; i++) {
2952                u16 tmp = le16_to_cpu(uif->altsetting[i].endpoint[isoc_pipe].desc.wMaxPacketSize);
2953                dev->alt_max_pkt_size[i] =
2954                    (tmp & 0x07ff) * (((tmp & 0x1800) >> 11) + 1);
2955        }
2956
2957        if ((card[nr] >= 0) && (card[nr] < em28xx_bcount))
2958                dev->model = card[nr];
2959
2960        /* allocate device struct */
2961        mutex_init(&dev->lock);
2962        mutex_lock(&dev->lock);
2963        retval = em28xx_init_dev(&dev, udev, interface, nr);
2964        if (retval) {
2965                em28xx_devused &= ~(1<<dev->devno);
2966                mutex_unlock(&dev->lock);
2967                kfree(dev);
2968                goto err;
2969        }
2970
2971        /* save our data pointer in this interface device */
2972        usb_set_intfdata(interface, dev);
2973
2974        request_modules(dev);
2975
2976        /* Should be the last thing to do, to avoid newer udev's to
2977           open the device before fully initializing it
2978         */
2979        mutex_unlock(&dev->lock);
2980
2981        return 0;
2982
2983err:
2984        return retval;
2985}
2986
2987/*
2988 * em28xx_usb_disconnect()
2989 * called when the device gets diconencted
2990 * video device will be unregistered on v4l2_close in case it is still open
2991 */
2992static void em28xx_usb_disconnect(struct usb_interface *interface)
2993{
2994        struct em28xx *dev;
2995
2996        dev = usb_get_intfdata(interface);
2997        usb_set_intfdata(interface, NULL);
2998
2999        if (!dev)
3000                return;
3001
3002        em28xx_info("disconnecting %s\n", dev->vdev->name);
3003
3004        /* wait until all current v4l2 io is finished then deallocate
3005           resources */
3006        mutex_lock(&dev->lock);
3007
3008        wake_up_interruptible_all(&dev->open);
3009
3010        v4l2_device_disconnect(&dev->v4l2_dev);
3011
3012        if (dev->users) {
3013                em28xx_warn
3014                    ("device %s is open! Deregistration and memory "
3015                     "deallocation are deferred on close.\n",
3016                     video_device_node_name(dev->vdev));
3017
3018                dev->state |= DEV_MISCONFIGURED;
3019                em28xx_uninit_isoc(dev);
3020                dev->state |= DEV_DISCONNECTED;
3021                wake_up_interruptible(&dev->wait_frame);
3022                wake_up_interruptible(&dev->wait_stream);
3023        } else {
3024                dev->state |= DEV_DISCONNECTED;
3025                em28xx_release_resources(dev);
3026        }
3027
3028        em28xx_close_extension(dev);
3029
3030        mutex_unlock(&dev->lock);
3031
3032        if (!dev->users) {
3033                kfree(dev->alt_max_pkt_size);
3034                kfree(dev);
3035        }
3036}
3037
3038static struct usb_driver em28xx_usb_driver = {
3039        .name = "em28xx",
3040        .probe = em28xx_usb_probe,
3041        .disconnect = em28xx_usb_disconnect,
3042        .id_table = em28xx_id_table,
3043};
3044
3045static int __init em28xx_module_init(void)
3046{
3047        int result;
3048
3049        /* register this driver with the USB subsystem */
3050        result = usb_register(&em28xx_usb_driver);
3051        if (result)
3052                em28xx_err(DRIVER_NAME
3053                           " usb_register failed. Error number %d.\n", result);
3054
3055        printk(KERN_INFO DRIVER_NAME " driver loaded\n");
3056
3057        return result;
3058}
3059
3060static void __exit em28xx_module_exit(void)
3061{
3062        /* deregister this driver with the USB subsystem */
3063        usb_deregister(&em28xx_usb_driver);
3064}
3065
3066module_init(em28xx_module_init);
3067module_exit(em28xx_module_exit);
3068