]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/dvb/frontends/nxt200x.c
Pull sn-handle-sc-powerdown into release branch
[linux-2.6-omap-h63xx.git] / drivers / media / dvb / frontends / nxt200x.c
index bad0933eb7146663124339b366c53e47295bd4a8..9e35353945099f69d073c24996802fa57ab53701 100644 (file)
@@ -1,9 +1,10 @@
 /*
  *    Support for NXT2002 and NXT2004 - VSB/QAM
  *
- *    Copyright (C) 2005 Kirk Lapray (kirk.lapray@gmail.com)
+ *    Copyright (C) 2005 Kirk Lapray <kirk.lapray@gmail.com>
+ *    Copyright (C) 2006 Michael Krufky <mkrufky@m1k.net>
  *    based on nxt2002 by Taylor Jacob <rtjacob@earthlink.net>
- *    and nxt2004 by Jean-Francois Thibert (jeanfrancois@sagetv.com)
+ *    and nxt2004 by Jean-Francois Thibert <jeanfrancois@sagetv.com>
  *
  *    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
@@ -44,6 +45,8 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
+#include <linux/slab.h>
+#include <linux/string.h>
 
 #include "dvb_frontend.h"
 #include "dvb-pll.h"
@@ -337,7 +340,7 @@ static int nxt200x_writetuner (struct nxt200x_state* state, u8* data)
        switch (state->demod_chip) {
                case NXT2004:
                        if (i2c_writebytes(state, state->config->pll_address, data, 4))
-                               printk(KERN_WARNING "nxt200x: error writing to tuner\n");
+                               printk(KERN_WARNING "nxt200x: error writing to tuner\n");
                        /* wait until we have a lock */
                        while (count < 20) {
                                i2c_readbytes(state, state->config->pll_address, &buf, 1);
@@ -495,7 +498,7 @@ static int nxt2004_load_firmware (struct dvb_frontend* fe, const struct firmware
 
        /* calculate firmware CRC */
        for (position = 0; position < fw->size; position++) {
-               crc = nxt200x_crc(crc, fw->data[position]);
+               crc = nxt200x_crc(crc, fw->data[position]);
        }
 
        buf[0] = rambase >> 8;
@@ -612,7 +615,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
        /* write sdm1 input */
        buf[0] = 0x10;
        buf[1] = 0x00;
-       nxt200x_writebytes(state, 0x58, buf, 2);
+       switch (state->demod_chip) {
+               case NXT2002:
+                       nxt200x_writereg_multibyte(state, 0x58, buf, 2);
+                       break;
+               case NXT2004:
+                       nxt200x_writebytes(state, 0x58, buf, 2);
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+       }
 
        /* write sdmx input */
        switch (p->u.vsb.modulation) {
@@ -630,7 +643,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
                                break;
        }
        buf[1] = 0x00;
-       nxt200x_writebytes(state, 0x5C, buf, 2);
+       switch (state->demod_chip) {
+               case NXT2002:
+                       nxt200x_writereg_multibyte(state, 0x5C, buf, 2);
+                       break;
+               case NXT2004:
+                       nxt200x_writebytes(state, 0x5C, buf, 2);
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+       }
 
        /* write adc power lpf fc */
        buf[0] = 0x05;
@@ -646,7 +669,17 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
        /* write accumulator2 input */
        buf[0] = 0x80;
        buf[1] = 0x00;
-       nxt200x_writebytes(state, 0x4B, buf, 2);
+       switch (state->demod_chip) {
+               case NXT2002:
+                       nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
+                       break;
+               case NXT2004:
+                       nxt200x_writebytes(state, 0x4B, buf, 2);
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+       }
 
        /* write kg1 */
        buf[0] = 0x00;
@@ -712,8 +745,19 @@ static int nxt200x_setup_frontend_parameters (struct dvb_frontend* fe,
        /* write accumulator2 input */
        buf[0] = 0x80;
        buf[1] = 0x00;
-       nxt200x_writebytes(state, 0x49, buf,2);
-       nxt200x_writebytes(state, 0x4B, buf,2);
+       switch (state->demod_chip) {
+               case NXT2002:
+                       nxt200x_writereg_multibyte(state, 0x49, buf, 2);
+                       nxt200x_writereg_multibyte(state, 0x4B, buf, 2);
+                       break;
+               case NXT2004:
+                       nxt200x_writebytes(state, 0x49, buf, 2);
+                       nxt200x_writebytes(state, 0x4B, buf, 2);
+                       break;
+               default:
+                       return -EINVAL;
+                       break;
+       }
 
        /* write agc control reg */
        buf[0] = 0x04;
@@ -1108,10 +1152,9 @@ struct dvb_frontend* nxt200x_attach(const struct nxt200x_config* config,
        u8 buf [] = {0,0,0,0,0};
 
        /* allocate memory for the internal state */
-       state = (struct nxt200x_state*) kmalloc(sizeof(struct nxt200x_state), GFP_KERNEL);
+       state = kzalloc(sizeof(struct nxt200x_state), GFP_KERNEL);
        if (state == NULL)
                goto error;
-       memset(state,0,sizeof(*state));
 
        /* setup the state */
        state->config = config;
@@ -1198,7 +1241,7 @@ module_param(debug, int, 0644);
 MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
 
 MODULE_DESCRIPTION("NXT200X (ATSC 8VSB & ITU-T J.83 AnnexB 64/256 QAM) Demodulator Driver");
-MODULE_AUTHOR("Kirk Lapray, Jean-Francois Thibert, and Taylor Jacob");
+MODULE_AUTHOR("Kirk Lapray, Michael Krufky, Jean-Francois Thibert, and Taylor Jacob");
 MODULE_LICENSE("GPL");
 
 EXPORT_SYMBOL(nxt200x_attach);