V4L/DVB (13214): tda18271: allow for i2c buses that cant send 16 bytes at once
authorMichael Krufky <mkrufky@kernellabs.com>
Fri, 23 Oct 2009 05:47:49 +0000 (02:47 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 5 Dec 2009 20:40:55 +0000 (18:40 -0200)
There is already an option for sending 16 byte chunks rather that writing
39 bytes all at once during the tuner's initialization.  Some i2c buses
can't send 16 bytes at once, so create an option for sending 8 byte chunks.

Signed-off-by: Michael Krufky <mkrufky@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/common/tuners/tda18271-common.c
drivers/media/common/tuners/tda18271-fe.c
drivers/media/common/tuners/tda18271-priv.h
drivers/media/common/tuners/tda18271.h

index 155c93e..e1f6782 100644 (file)
@@ -326,12 +326,24 @@ int tda18271_init_regs(struct dvb_frontend *fe)
        regs[R_EB22] = 0x48;
        regs[R_EB23] = 0xb0;
 
-       if (priv->small_i2c) {
+       switch (priv->small_i2c) {
+       case TDA18271_08_BYTE_CHUNK_INIT:
+               tda18271_write_regs(fe, 0x00, 0x08);
+               tda18271_write_regs(fe, 0x08, 0x08);
+               tda18271_write_regs(fe, 0x10, 0x08);
+               tda18271_write_regs(fe, 0x18, 0x08);
+               tda18271_write_regs(fe, 0x20, 0x07);
+               break;
+       case TDA18271_16_BYTE_CHUNK_INIT:
                tda18271_write_regs(fe, 0x00, 0x10);
                tda18271_write_regs(fe, 0x10, 0x10);
                tda18271_write_regs(fe, 0x20, 0x07);
-       } else
+               break;
+       case TDA18271_39_BYTE_CHUNK_INIT:
+       default:
                tda18271_write_regs(fe, 0x00, TDA18271_NUM_REGS);
+               break;
+       }
 
        /* setup agc1 gain */
        regs[R_EB17] = 0x00;
index e0fd9f5..eb77241 100644 (file)
@@ -1224,7 +1224,8 @@ struct dvb_frontend *tda18271_attach(struct dvb_frontend *fe, u8 addr,
                priv->gate = (cfg) ? cfg->gate : TDA18271_GATE_AUTO;
                priv->role = (cfg) ? cfg->role : TDA18271_MASTER;
                priv->config = (cfg) ? cfg->config : 0;
-               priv->small_i2c = (cfg) ? cfg->small_i2c : 0;
+               priv->small_i2c = (cfg) ?
+                       cfg->small_i2c : TDA18271_39_BYTE_CHUNK_INIT;
                priv->output_opt = (cfg) ?
                        cfg->output_opt : TDA18271_OUTPUT_LT_XT_ON;
 
index 7047680..9589ab0 100644 (file)
@@ -109,10 +109,10 @@ struct tda18271_priv {
        enum tda18271_i2c_gate gate;
        enum tda18271_ver id;
        enum tda18271_output_options output_opt;
+       enum tda18271_small_i2c small_i2c;
 
        unsigned int config; /* interface to saa713x / tda829x */
        unsigned int cal_initialized:1;
-       unsigned int small_i2c:1;
 
        u8 tm_rfcal;
 
index 323f291..d7fcc36 100644 (file)
@@ -78,6 +78,12 @@ enum tda18271_output_options {
        TDA18271_OUTPUT_XT_OFF = 2,
 };
 
+enum tda18271_small_i2c {
+       TDA18271_39_BYTE_CHUNK_INIT = 0,
+       TDA18271_16_BYTE_CHUNK_INIT = 1,
+       TDA18271_08_BYTE_CHUNK_INIT = 2,
+};
+
 struct tda18271_config {
        /* override default if freq / std settings (optional) */
        struct tda18271_std_map *std_map;
@@ -91,12 +97,12 @@ struct tda18271_config {
        /* output options that can be disabled */
        enum tda18271_output_options output_opt;
 
+       /* some i2c providers cant write all 39 registers at once */
+       enum tda18271_small_i2c small_i2c;
+
        /* force rf tracking filter calibration on startup */
        unsigned int rf_cal_on_startup:1;
 
-       /* some i2c providers cant write all 39 registers at once */
-       unsigned int small_i2c:1;
-
        /* interface to saa713x / tda829x */
        unsigned int config;
 };