include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / drivers / media / video / au0828 / au0828-dvb.c
index 584a83a..f1edf1d 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Driver for the Auvitek USB bridge
  *
- *  Copyright (c) 2008 Steven Toth <stoth@hauppauge.com>
+ *  Copyright (c) 2008 Steven Toth <stoth@linuxtv.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -20,6 +20,7 @@
  */
 
 #include <linux/module.h>
+#include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/suspend.h>
 #include "au8522.h"
 #include "xc5000.h"
 #include "mxl5007t.h"
+#include "tda18271.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 
 #define _AU0828_BULKPIPE 0x83
 #define _BULKPIPESIZE 0xe522
 
+static u8 hauppauge_hvr950q_led_states[] = {
+       0x00, /* off */
+       0x02, /* yellow */
+       0x04, /* green */
+};
+
+static struct au8522_led_config hauppauge_hvr950q_led_cfg = {
+       .gpio_output = 0x00e0,
+       .gpio_output_enable  = 0x6006,
+       .gpio_output_disable = 0x0660,
+
+       .gpio_leds = 0x00e2,
+       .led_states  = hauppauge_hvr950q_led_states,
+       .num_led_states = sizeof(hauppauge_hvr950q_led_states),
+
+       .vsb8_strong   = 20 /* dB */ * 10,
+       .qam64_strong  = 25 /* dB */ * 10,
+       .qam256_strong = 32 /* dB */ * 10,
+};
+
 static struct au8522_config hauppauge_hvr950q_config = {
        .demod_address = 0x8e >> 1,
        .status_mode   = AU8522_DEMODLOCKING,
+       .qam_if        = AU8522_IF_6MHZ,
+       .vsb_if        = AU8522_IF_6MHZ,
+       .led_cfg       = &hauppauge_hvr950q_led_cfg,
+};
+
+static struct au8522_config fusionhdtv7usb_config = {
+       .demod_address = 0x8e >> 1,
+       .status_mode   = AU8522_DEMODLOCKING,
+       .qam_if        = AU8522_IF_6MHZ,
+       .vsb_if        = AU8522_IF_6MHZ,
+};
+
+static struct au8522_config hauppauge_woodbury_config = {
+       .demod_address = 0x8e >> 1,
+       .status_mode   = AU8522_DEMODLOCKING,
+       .qam_if        = AU8522_IF_4MHZ,
+       .vsb_if        = AU8522_IF_3_25MHZ,
 };
 
 static struct xc5000_config hauppauge_hvr950q_tunerconfig = {
        .i2c_address      = 0x61,
        .if_khz           = 6000,
-       .tuner_callback   = au0828_tuner_callback
 };
 
 static struct mxl5007t_config mxl5007t_hvr950q_config = {
@@ -51,6 +89,10 @@ static struct mxl5007t_config mxl5007t_hvr950q_config = {
        .if_freq_hz = MxL_IF_6_MHZ,
 };
 
+static struct tda18271_config hauppauge_woodbury_tunerconfig = {
+       .gate    = TDA18271_GATE_DIGITAL,
+};
+
 /*-------------------------------------------------------------------*/
 static void urb_completion(struct urb *purb)
 {
@@ -110,7 +152,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
        dprintk(2, "%s()\n", __func__);
 
        if (dev->urb_streaming) {
-               dprintk(2, "%s: iso xfer already running!\n", __func__);
+               dprintk(2, "%s: bulk xfer already running!\n", __func__);
                return 0;
        }
 
@@ -132,7 +174,8 @@ static int start_urb_transfer(struct au0828_dev *dev)
                purb->status = -EINPROGRESS;
                usb_fill_bulk_urb(purb,
                                  dev->usbdev,
-                                 usb_rcvbulkpipe(dev->usbdev, _AU0828_BULKPIPE),
+                                 usb_rcvbulkpipe(dev->usbdev,
+                                       _AU0828_BULKPIPE),
                                  purb->transfer_buffer,
                                  URB_BUFSIZE,
                                  urb_completion,
@@ -336,17 +379,15 @@ int au0828_dvb_register(struct au0828_dev *dev)
        dprintk(1, "%s()\n", __func__);
 
        /* init frontend */
-       switch (dev->board) {
+       switch (dev->boardnr) {
        case AU0828_BOARD_HAUPPAUGE_HVR850:
        case AU0828_BOARD_HAUPPAUGE_HVR950Q:
-       case AU0828_BOARD_DVICO_FUSIONHDTV7:
                dvb->frontend = dvb_attach(au8522_attach,
                                &hauppauge_hvr950q_config,
                                &dev->i2c_adap);
                if (dvb->frontend != NULL)
-                       dvb_attach(xc5000_attach, dvb->frontend,
-                               &dev->i2c_adap,
-                               &hauppauge_hvr950q_tunerconfig, dev);
+                       dvb_attach(xc5000_attach, dvb->frontend, &dev->i2c_adap,
+                                  &hauppauge_hvr950q_tunerconfig);
                break;
        case AU0828_BOARD_HAUPPAUGE_HVR950Q_MXL:
                dvb->frontend = dvb_attach(au8522_attach,
@@ -357,6 +398,25 @@ int au0828_dvb_register(struct au0828_dev *dev)
                                   &dev->i2c_adap, 0x60,
                                   &mxl5007t_hvr950q_config);
                break;
+       case AU0828_BOARD_HAUPPAUGE_WOODBURY:
+               dvb->frontend = dvb_attach(au8522_attach,
+                               &hauppauge_woodbury_config,
+                               &dev->i2c_adap);
+               if (dvb->frontend != NULL)
+                       dvb_attach(tda18271_attach, dvb->frontend,
+                                  0x60, &dev->i2c_adap,
+                                  &hauppauge_woodbury_tunerconfig);
+               break;
+       case AU0828_BOARD_DVICO_FUSIONHDTV7:
+               dvb->frontend = dvb_attach(au8522_attach,
+                               &fusionhdtv7usb_config,
+                               &dev->i2c_adap);
+               if (dvb->frontend != NULL) {
+                       dvb_attach(xc5000_attach, dvb->frontend,
+                               &dev->i2c_adap,
+                               &hauppauge_hvr950q_tunerconfig);
+               }
+               break;
        default:
                printk(KERN_WARNING "The frontend of your DVB/ATSC card "
                       "isn't supported yet\n");
@@ -367,6 +427,8 @@ int au0828_dvb_register(struct au0828_dev *dev)
                       __func__);
                return -1;
        }
+       /* define general-purpose callback pointer */
+       dvb->frontend->callback = au0828_tuner_callback;
 
        /* register everything */
        ret = dvb_register(dev);