Add changes from the Linux-2.6 tree.
[linux-2.6.git] / drivers / media / dvb / ttpci / budget-patch.c
index 05d63b6..9a15539 100644 (file)
@@ -258,7 +258,7 @@ static int budget_patch_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_c
        return 0;
 }
 
-static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int alps_bsrv2_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
        struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
        u8 pwr = 0;
@@ -281,7 +281,10 @@ static int alps_bsrv2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_param
        // NOTE: since we're using a prescaler of 2, we set the
        // divisor frequency to 62.5kHz and divide by 125 above
 
-       if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+       if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
+               return -EIO;
        return 0;
 }
 
@@ -289,10 +292,9 @@ static struct ves1x93_config alps_bsrv2_config = {
        .demod_address = 0x08,
        .xin = 90100000UL,
        .invert_pwm = 0,
-       .pll_set = alps_bsrv2_pll_set,
 };
 
-static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
+static int grundig_29504_451_tuner_set_params(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
 {
        struct budget_patch* budget = (struct budget_patch*) fe->dvb->priv;
        u32 div;
@@ -305,13 +307,15 @@ static int grundig_29504_451_pll_set(struct dvb_frontend* fe, struct dvb_fronten
        data[2] = 0x8e;
        data[3] = 0x00;
 
-       if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1) return -EIO;
+       if (fe->ops.i2c_gate_ctrl)
+               fe->ops.i2c_gate_ctrl(fe, 1);
+       if (i2c_transfer (&budget->i2c_adap, &msg, 1) != 1)
+               return -EIO;
        return 0;
 }
 
 static struct tda8083_config grundig_29504_451_config = {
        .demod_address = 0x68,
-       .pll_set = grundig_29504_451_pll_set,
 };
 
 static void frontend_init(struct budget_patch* budget)
@@ -321,29 +325,34 @@ static void frontend_init(struct budget_patch* budget)
        case 0x1013: // SATELCO Multimedia PCI
 
                // try the ALPS BSRV2 first of all
-               budget->dvb_frontend = ves1x93_attach(&alps_bsrv2_config, &budget->i2c_adap);
+               budget->dvb_frontend = dvb_attach(ves1x93_attach, &alps_bsrv2_config, &budget->i2c_adap);
                if (budget->dvb_frontend) {
-                       budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
-                       budget->dvb_frontend->ops->diseqc_send_burst = budget_patch_diseqc_send_burst;
-                       budget->dvb_frontend->ops->set_tone = budget_patch_set_tone;
+                       budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsrv2_tuner_set_params;
+                       budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_patch_diseqc_send_master_cmd;
+                       budget->dvb_frontend->ops.diseqc_send_burst = budget_patch_diseqc_send_burst;
+                       budget->dvb_frontend->ops.set_tone = budget_patch_set_tone;
                        break;
                }
 
                // try the ALPS BSRU6 now
-               budget->dvb_frontend = stv0299_attach(&alps_bsru6_config, &budget->i2c_adap);
+               budget->dvb_frontend = dvb_attach(stv0299_attach, &alps_bsru6_config, &budget->i2c_adap);
                if (budget->dvb_frontend) {
-                       budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
-                       budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst;
-                       budget->dvb_frontend->ops->set_tone = budget_set_tone;
+                       budget->dvb_frontend->ops.tuner_ops.set_params = alps_bsru6_tuner_set_params;
+                       budget->dvb_frontend->tuner_priv = &budget->i2c_adap;
+
+                       budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
+                       budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
+                       budget->dvb_frontend->ops.set_tone = budget_set_tone;
                        break;
                }
 
                // Try the grundig 29504-451
-               budget->dvb_frontend = tda8083_attach(&grundig_29504_451_config, &budget->i2c_adap);
+               budget->dvb_frontend = dvb_attach(tda8083_attach, &grundig_29504_451_config, &budget->i2c_adap);
                if (budget->dvb_frontend) {
-                       budget->dvb_frontend->ops->diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
-                       budget->dvb_frontend->ops->diseqc_send_burst = budget_diseqc_send_burst;
-                       budget->dvb_frontend->ops->set_tone = budget_set_tone;
+                       budget->dvb_frontend->ops.tuner_ops.set_params = grundig_29504_451_tuner_set_params;
+                       budget->dvb_frontend->ops.diseqc_send_master_cmd = budget_diseqc_send_master_cmd;
+                       budget->dvb_frontend->ops.diseqc_send_burst = budget_diseqc_send_burst;
+                       budget->dvb_frontend->ops.set_tone = budget_set_tone;
                        break;
                }
                break;
@@ -358,8 +367,7 @@ static void frontend_init(struct budget_patch* budget)
        } else {
                if (dvb_register_frontend(&budget->dvb_adapter, budget->dvb_frontend)) {
                        printk("budget-av: Frontend registration failed!\n");
-                       if (budget->dvb_frontend->ops->release)
-                               budget->dvb_frontend->ops->release(budget->dvb_frontend);
+                       dvb_frontend_detach(budget->dvb_frontend);
                        budget->dvb_frontend = NULL;
                }
        }
@@ -492,14 +500,14 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
 
 /*      New design (By Emard)
 **      this rps1 code will copy internal HS event to GPIO3 pin.
-**      GPIO3 is in budget-patch hardware connectd to port B VSYNC
+**      GPIO3 is in budget-patch hardware connected to port B VSYNC
 
 **      HS is an internal event of 7146, accessible with RPS
 **      and temporarily raised high every n lines
 **      (n in defined in the RPS_THRESH1 counter threshold)
 **      I think HS is raised high on the beginning of the n-th line
 **      and remains high until this n-th line that triggered
-**      it is completely received. When the receiption of n-th line
+**      it is completely received. When the reception of n-th line
 **      ends, HS is lowered.
 
 **      To transmit data over DMA, 7146 needs changing state at
@@ -533,7 +541,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
 **      hardware debug note: a working budget card (including budget patch)
 **      with vpeirq() interrupt setup in mode "0x90" (every 64K) will
 **      generate 3 interrupts per 25-Hz DMA frame of 2*188*512 bytes
-**      and that means 3*25=75 Hz of interrupt freqency, as seen by
+**      and that means 3*25=75 Hz of interrupt frequency, as seen by
 **      watch cat /proc/interrupts
 **
 **      If this frequency is 3x lower (and data received in the DMA
@@ -542,7 +550,7 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
 **      this means VSYNC line is not connected in the hardware.
 **      (check soldering pcb and pins)
 **      The same behaviour of missing VSYNC can be duplicated on budget
-**      cards, by seting DD1_INIT trigger mode 7 in 3rd nibble.
+**      cards, by setting DD1_INIT trigger mode 7 in 3rd nibble.
 */
 
        // Setup RPS1 "program" (p35)
@@ -608,6 +616,8 @@ static int budget_patch_attach (struct saa7146_dev* dev, struct saa7146_pci_exte
        budget->dvb_adapter.priv = budget;
        frontend_init(budget);
 
+       ttpci_budget_init_hooks(budget);
+
        return 0;
 }
 
@@ -616,8 +626,10 @@ static int budget_patch_detach (struct saa7146_dev* dev)
        struct budget_patch *budget = (struct budget_patch*) dev->ext_priv;
        int err;
 
-       if (budget->dvb_frontend) dvb_unregister_frontend(budget->dvb_frontend);
-
+       if (budget->dvb_frontend) {
+               dvb_unregister_frontend(budget->dvb_frontend);
+               dvb_frontend_detach(budget->dvb_frontend);
+       }
        err = ttpci_budget_deinit (budget);
 
        kfree (budget);