]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
V4L/DVB (10802): Add more headers for ST STV0900 dual demodulator.
authorIgor M. Liplianin <liplianin@netup.ru>
Tue, 3 Mar 2009 14:41:39 +0000 (11:41 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Mon, 30 Mar 2009 15:43:04 +0000 (12:43 -0300)
Signed-off-by: Igor M. Liplianin <liplianin@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/frontends/stv0900_init.h [new file with mode: 0644]
drivers/media/dvb/frontends/stv0900_priv.h [new file with mode: 0644]

diff --git a/drivers/media/dvb/frontends/stv0900_init.h b/drivers/media/dvb/frontends/stv0900_init.h
new file mode 100644 (file)
index 0000000..fa8dbe1
--- /dev/null
@@ -0,0 +1,439 @@
+/*
+ * stv0900_init.h
+ *
+ * Driver for ST STV0900 satellite demodulator IC.
+ *
+ * Copyright (C) ST Microelectronics.
+ * Copyright (C) 2009 NetUP Inc.
+ * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef STV0900_INIT_H
+#define STV0900_INIT_H
+
+#include "stv0900_priv.h"
+
+/* DVBS2 C/N Look-Up table */
+static const struct stv0900_table stv0900_s2_cn = {
+       55,
+       {
+               { -30,  13348 }, /*C/N=-3dB*/
+               { -20,  12640 }, /*C/N=-2dB*/
+               { -10,  11883 }, /*C/N=-1dB*/
+               { 0,    11101 }, /*C/N=-0dB*/
+               { 5,    10718 }, /*C/N=0.5dB*/
+               { 10,   10339 }, /*C/N=1.0dB*/
+               { 15,   9947 }, /*C/N=1.5dB*/
+               { 20,   9552 }, /*C/N=2.0dB*/
+               { 25,   9183 }, /*C/N=2.5dB*/
+               { 30,   8799 }, /*C/N=3.0dB*/
+               { 35,   8422 }, /*C/N=3.5dB*/
+               { 40,   8062 }, /*C/N=4.0dB*/
+               { 45,   7707 }, /*C/N=4.5dB*/
+               { 50,   7353 }, /*C/N=5.0dB*/
+               { 55,   7025 }, /*C/N=5.5dB*/
+               { 60,   6684 }, /*C/N=6.0dB*/
+               { 65,   6331 }, /*C/N=6.5dB*/
+               { 70,   6036 }, /*C/N=7.0dB*/
+               { 75,   5727 }, /*C/N=7.5dB*/
+               { 80,   5437 }, /*C/N=8.0dB*/
+               { 85,   5164 }, /*C/N=8.5dB*/
+               { 90,   4902 }, /*C/N=9.0dB*/
+               { 95,   4653 }, /*C/N=9.5dB*/
+               { 100,  4408 }, /*C/N=10.0dB*/
+               { 105,  4187 }, /*C/N=10.5dB*/
+               { 110,  3961 }, /*C/N=11.0dB*/
+               { 115,  3751 }, /*C/N=11.5dB*/
+               { 120,  3558 }, /*C/N=12.0dB*/
+               { 125,  3368 }, /*C/N=12.5dB*/
+               { 130,  3191 }, /*C/N=13.0dB*/
+               { 135,  3017 }, /*C/N=13.5dB*/
+               { 140,  2862 }, /*C/N=14.0dB*/
+               { 145,  2710 }, /*C/N=14.5dB*/
+               { 150,  2565 }, /*C/N=15.0dB*/
+               { 160,  2300 }, /*C/N=16.0dB*/
+               { 170,  2058 }, /*C/N=17.0dB*/
+               { 180,  1849 }, /*C/N=18.0dB*/
+               { 190,  1663 }, /*C/N=19.0dB*/
+               { 200,  1495 }, /*C/N=20.0dB*/
+               { 210,  1349 }, /*C/N=21.0dB*/
+               { 220,  1222 }, /*C/N=22.0dB*/
+               { 230,  1110 }, /*C/N=23.0dB*/
+               { 240,  1011 }, /*C/N=24.0dB*/
+               { 250,  925 }, /*C/N=25.0dB*/
+               { 260,  853 }, /*C/N=26.0dB*/
+               { 270,  789 }, /*C/N=27.0dB*/
+               { 280,  734 }, /*C/N=28.0dB*/
+               { 290,  690 }, /*C/N=29.0dB*/
+               { 300,  650 }, /*C/N=30.0dB*/
+               { 310,  619 }, /*C/N=31.0dB*/
+               { 320,  593 }, /*C/N=32.0dB*/
+               { 330,  571 }, /*C/N=33.0dB*/
+               { 400,  498 }, /*C/N=40.0dB*/
+               { 450,  484 }, /*C/N=45.0dB*/
+               { 500,  481 }  /*C/N=50.0dB*/
+       }
+};
+
+/* RF level C/N Look-Up table */
+static const struct stv0900_table stv0900_rf = {
+       14,
+       {
+               { -5, 0xCAA1 }, /*-5dBm*/
+               { -10, 0xC229 }, /*-10dBm*/
+               { -15, 0xBB08 }, /*-15dBm*/
+               { -20, 0xB4BC }, /*-20dBm*/
+               { -25, 0xAD5A }, /*-25dBm*/
+               { -30, 0xA298 }, /*-30dBm*/
+               { -35, 0x98A8 }, /*-35dBm*/
+               { -40, 0x8389 }, /*-40dBm*/
+               { -45, 0x59BE }, /*-45dBm*/
+               { -50, 0x3A14 }, /*-50dBm*/
+               { -55, 0x2D11 }, /*-55dBm*/
+               { -60, 0x210D }, /*-60dBm*/
+               { -65, 0xA14F }, /*-65dBm*/
+               { -70, 0x7AA }  /*-70dBm*/
+       }
+};
+
+struct stv0900_car_loop_optim {
+       enum fe_stv0900_modcode modcode;
+       u8 car_loop_pilots_on_2;
+       u8 car_loop_pilots_off_2;
+       u8 car_loop_pilots_on_5;
+       u8 car_loop_pilots_off_5;
+       u8 car_loop_pilots_on_10;
+       u8 car_loop_pilots_off_10;
+       u8 car_loop_pilots_on_20;
+       u8 car_loop_pilots_off_20;
+       u8 car_loop_pilots_on_30;
+       u8 car_loop_pilots_off_30;
+
+};
+
+struct stv0900_short_frames_car_loop_optim {
+       enum fe_stv0900_modulation modulation;
+       u8 car_loop_cut12_2;    /* Cut 1.2,   SR<=3msps     */
+       u8 car_loop_cut20_2;    /* Cut 2.0,   SR<3msps      */
+       u8 car_loop_cut12_5;    /* Cut 1.2,   3<SR<=7msps   */
+       u8 car_loop_cut20_5;    /* Cut 2.0,   3<SR<=7msps   */
+       u8 car_loop_cut12_10;   /* Cut 1.2,   7<SR<=15msps  */
+       u8 car_loop_cut20_10;   /* Cut 2.0,   7<SR<=15msps  */
+       u8 car_loop_cut12_20;   /* Cut 1.2,   10<SR<=25msps */
+       u8 car_loop_cut20_20;   /* Cut 2.0,   10<SR<=25msps */
+       u8 car_loop_cut12_30;   /* Cut 1.2,   25<SR<=45msps */
+       u8 car_loop_cut20_30;   /* Cut 2.0,   10<SR<=45msps */
+
+};
+
+/* Cut 1.x Tracking carrier loop carrier QPSK 1/2 to 8PSK 9/10 long Frame */
+static const struct stv0900_car_loop_optim     FE_STV0900_S2CarLoop[14] = {
+       /*Modcod                2MPon   2MPoff  5MPon   5MPoff  10MPon  10MPoff 20MPon  20MPoff 30MPon  30MPoff */
+       { STV0900_QPSK_12,      0x1C,   0x0D,   0x1B,   0x2C,   0x3A,   0x1C,   0x2A,   0x3B,   0x2A,   0x1B },
+       { STV0900_QPSK_35,      0x2C,   0x0D,   0x2B,   0x2C,   0x3A,   0x0C,   0x3A,   0x2B,   0x2A,   0x0B },
+       { STV0900_QPSK_23,      0x2C,   0x0D,   0x2B,   0x2C,   0x0B,   0x0C,   0x3A,   0x1B,   0x2A,   0x3A },
+       { STV0900_QPSK_34,      0x3C,   0x0D,   0x3B,   0x1C,   0x0B,   0x3B,   0x3A,   0x0B,   0x2A,   0x3A },
+       { STV0900_QPSK_45,      0x3C,   0x0D,   0x3B,   0x1C,   0x0B,   0x3B,   0x3A,   0x0B,   0x2A,   0x3A },
+       { STV0900_QPSK_56,      0x0D,   0x0D,   0x3B,   0x1C,   0x0B,   0x3B,   0x3A,   0x0B,   0x2A,   0x3A },
+       { STV0900_QPSK_89,      0x0D,   0x0D,   0x3B,   0x1C,   0x1B,   0x3B,   0x3A,   0x0B,   0x2A,   0x3A },
+       { STV0900_QPSK_910,     0x1D,   0x0D,   0x3B,   0x1C,   0x1B,   0x3B,   0x3A,   0x0B,   0x2A,   0x3A },
+       { STV0900_8PSK_35,      0x29,   0x3B,   0x09,   0x2B,   0x38,   0x0B,   0x18,   0x1A,   0x08,   0x0A },
+       { STV0900_8PSK_23,      0x0A,   0x3B,   0x29,   0x2B,   0x19,   0x0B,   0x38,   0x1A,   0x18,   0x0A },
+       { STV0900_8PSK_34,      0x3A,   0x3B,   0x2A,   0x2B,   0x39,   0x0B,   0x19,   0x1A,   0x38,   0x0A },
+       { STV0900_8PSK_56,      0x1B,   0x3B,   0x0B,   0x2B,   0x1A,   0x0B,   0x39,   0x1A,   0x19,   0x0A },
+       { STV0900_8PSK_89,      0x3B,   0x3B,   0x0B,   0x2B,   0x2A,   0x0B,   0x39,   0x1A,   0x29,   0x39 },
+       { STV0900_8PSK_910,     0x3B,   0x3B,   0x0B,   0x2B,   0x2A,   0x0B,   0x39,   0x1A,   0x29,   0x39 }
+};
+
+
+/* Cut 2.0 Tracking carrier loop carrier QPSK 1/2 to 8PSK 9/10 long Frame */
+static const struct stv0900_car_loop_optim     FE_STV0900_S2CarLoopCut20[14]   = {
+       /* Modcod               2MPon   2MPoff  5MPon   5MPoff  10MPon  10MPoff 20MPon  20MPoff 30MPon  30MPoff */
+       { STV0900_QPSK_12,      0x1F,   0x3F,   0x1E,   0x3F,   0x3D,   0x1F,   0x3D,   0x3E,   0x3D,   0x1E },
+       { STV0900_QPSK_35,      0x2F,   0x3F,   0x2E,   0x2F,   0x3D,   0x0F,   0x0E,   0x2E,   0x3D,   0x0E },
+       { STV0900_QPSK_23,      0x2F,   0x3F,   0x2E,   0x2F,   0x0E,   0x0F,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_QPSK_34,      0x3F,   0x3F,   0x3E,   0x1F,   0x0E,   0x3E,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_QPSK_45,      0x3F,   0x3F,   0x3E,   0x1F,   0x0E,   0x3E,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_QPSK_56,      0x3F,   0x3F,   0x3E,   0x1F,   0x0E,   0x3E,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_QPSK_89,      0x3F,   0x3F,   0x3E,   0x1F,   0x1E,   0x3E,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_QPSK_910,     0x3F,   0x3F,   0x3E,   0x1F,   0x1E,   0x3E,   0x0E,   0x1E,   0x3D,   0x3D },
+       { STV0900_8PSK_35,      0x3c,   0x0c,   0x1c,   0x3b,   0x0c,   0x3b,   0x2b,   0x2b,   0x1b,   0x2b },
+       { STV0900_8PSK_23,      0x1d,   0x0c,   0x3c,   0x0c,   0x2c,   0x3b,   0x0c,   0x2b,   0x2b,   0x2b },
+       { STV0900_8PSK_34,      0x0e,   0x1c,   0x3d,   0x0c,   0x0d,   0x3b,   0x2c,   0x3b,   0x0c,   0x2b },
+       { STV0900_8PSK_56,      0x2e,   0x3e,   0x1e,   0x2e,   0x2d,   0x1e,   0x3c,   0x2d,   0x2c,   0x1d },
+       { STV0900_8PSK_89,      0x3e,   0x3e,   0x1e,   0x2e,   0x3d,   0x1e,   0x0d,   0x2d,   0x3c,   0x1d },
+       { STV0900_8PSK_910,     0x3e,   0x3e,   0x1e,   0x2e,   0x3d,   0x1e,   0x1d,   0x2d,   0x0d,   0x1d }
+};
+
+
+
+/* Cut 2.0 Tracking carrier loop carrier 16APSK 2/3 to 32APSK 9/10 long Frame */
+static const struct stv0900_car_loop_optim FE_STV0900_S2APSKCarLoopCut20[11] = {
+       /* Modcod               2MPon   2MPoff  5MPon   5MPoff  10MPon  10MPoff 20MPon  20MPoff 30MPon  30MPoff */
+       { STV0900_16APSK_23,    0x0C,   0x0C,   0x0C,   0x0C,   0x1D,   0x0C,   0x3C,   0x0C,   0x2C,   0x0C },
+       { STV0900_16APSK_34,    0x0C,   0x0C,   0x0C,   0x0C,   0x0E,   0x0C,   0x2D,   0x0C,   0x1D,   0x0C },
+       { STV0900_16APSK_45,    0x0C,   0x0C,   0x0C,   0x0C,   0x1E,   0x0C,   0x3D,   0x0C,   0x2D,   0x0C },
+       { STV0900_16APSK_56,    0x0C,   0x0C,   0x0C,   0x0C,   0x1E,   0x0C,   0x3D,   0x0C,   0x2D,   0x0C },
+       { STV0900_16APSK_89,    0x0C,   0x0C,   0x0C,   0x0C,   0x2E,   0x0C,   0x0E,   0x0C,   0x3D,   0x0C },
+       { STV0900_16APSK_910,   0x0C,   0x0C,   0x0C,   0x0C,   0x2E,   0x0C,   0x0E,   0x0C,   0x3D,   0x0C },
+       { STV0900_32APSK_34,    0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C },
+       { STV0900_32APSK_45,    0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C },
+       { STV0900_32APSK_56,    0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C },
+       { STV0900_32APSK_89,    0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C },
+       { STV0900_32APSK_910,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C,   0x0C }
+};
+
+
+/* Cut 2.0 Tracking carrier loop carrier QPSK 1/4 to QPSK 2/5 long Frame */
+static const struct stv0900_car_loop_optim FE_STV0900_S2LowQPCarLoopCut20[3] = {
+       /* Modcod               2MPon   2MPoff  5MPon   5MPoff  10MPon  10MPoff 20MPon  20MPoff 30MPon  30MPoff */
+       { STV0900_QPSK_14,      0x0F,   0x3F,   0x0E,   0x3F,   0x2D,   0x2F,   0x2D,   0x1F,   0x3D,   0x3E },
+       { STV0900_QPSK_13,      0x0F,   0x3F,   0x0E,   0x3F,   0x2D,   0x2F,   0x3D,   0x0F,   0x3D,   0x2E },
+       { STV0900_QPSK_25,      0x1F,   0x3F,   0x1E,   0x3F,   0x3D,   0x1F,   0x3D,   0x3E,   0x3D,   0x2E }
+};
+
+
+/* Cut 2.0 Tracking carrier loop carrier  short Frame, cut 1.2 and 2.0 */
+static const struct stv0900_short_frames_car_loop_optim FE_STV0900_S2ShortCarLoop[4]   = {
+       /*Mod   2M_cut1.2 2M_cut2.0 5M_cut1.2 5M_cut2.0 10M_cut1.2 10M_cut2.0 20M_cut1.2 20M_cut2.0 30M_cut1.2 30M_cut2.0 */
+       { STV0900_QPSK,         0x3C,   0x2F,   0x2B,   0x2E,   0x0B,   0x0E,   0x3A,   0x0E,   0x2A,   0x3D },
+       { STV0900_8PSK,         0x0B,   0x3E,   0x2A,   0x0E,   0x0A,   0x2D,   0x19,   0x0D,   0x09,   0x3C },
+       { STV0900_16APSK,       0x1B,   0x1E,   0x1B,   0x1E,   0x1B,   0x1E,   0x3A,   0x3D,   0x2A,   0x2D },
+       { STV0900_32APSK,       0x1B,   0x1E,   0x1B,   0x1E,   0x1B,   0x1E,   0x3A,   0x3D,   0x2A,   0x2D }
+};
+
+static const u16 STV0900_InitVal[180][2] = {
+       { R0900_OUTCFG          , 0x00  },
+       { R0900_MODECFG         , 0xff  },
+       { R0900_AGCRF1CFG       , 0x11  },
+       { R0900_AGCRF2CFG       , 0x13  },
+       { R0900_TSGENERAL1X     , 0x14  },
+       { R0900_TSTTNR2         , 0x21  },
+       { R0900_TSTTNR4         , 0x21  },
+       { R0900_P2_DISTXCTL     , 0x22  },
+       { R0900_P2_F22TX        , 0xc0  },
+       { R0900_P2_F22RX        , 0xc0  },
+       { R0900_P2_DISRXCTL     , 0x00  },
+       { R0900_P2_TNRSTEPS     , 0x87  },
+       { R0900_P2_TNRGAIN      , 0x09  },
+       { R0900_P2_DMDCFGMD     , 0xF9  },
+       { R0900_P2_DEMOD        , 0x08  },
+       { R0900_P2_DMDCFG3      , 0xc4  },
+       { R0900_P2_CARFREQ      , 0xed  },
+       { R0900_P2_TNRCFG2      , 0x02  },
+       { R0900_P2_TNRCFG3      , 0x02  },
+       { R0900_P2_LDT          , 0xd0  },
+       { R0900_P2_LDT2         , 0xb8  },
+       { R0900_P2_TMGCFG       , 0xd2  },
+       { R0900_P2_TMGTHRISE    , 0x20  },
+       { R0900_P2_TMGTHFALL    , 0x00  },
+       { R0900_P2_FECSPY       , 0x88  },
+       { R0900_P2_FSPYDATA     , 0x3a  },
+       { R0900_P2_FBERCPT4     , 0x00  },
+       { R0900_P2_FSPYBER      , 0x10  },
+       { R0900_P2_ERRCTRL1     , 0x35  },
+       { R0900_P2_ERRCTRL2     , 0xc1  },
+       { R0900_P2_CFRICFG      , 0xf8  },
+       { R0900_P2_NOSCFG       , 0x1c  },
+       { R0900_P2_DMDT0M       , 0x20  },
+       { R0900_P2_CORRELMANT   , 0x70  },
+       { R0900_P2_CORRELABS    , 0x88  },
+       { R0900_P2_AGC2O        , 0x5b  },
+       { R0900_P2_AGC2REF      , 0x38  },
+       { R0900_P2_CARCFG       , 0xe4  },
+       { R0900_P2_ACLC         , 0x1A  },
+       { R0900_P2_BCLC         , 0x09  },
+       { R0900_P2_CARHDR       , 0x08  },
+       { R0900_P2_KREFTMG      , 0xc1  },
+       { R0900_P2_SFRUPRATIO   , 0xf0  },
+       { R0900_P2_SFRLOWRATIO  , 0x70  },
+       { R0900_P2_SFRSTEP      , 0x58  },
+       { R0900_P2_TMGCFG2      , 0x01  },
+       { R0900_P2_CAR2CFG      , 0x26  },
+       { R0900_P2_BCLC2S2Q     , 0x86  },
+       { R0900_P2_BCLC2S28     , 0x86  },
+       { R0900_P2_SMAPCOEF7    , 0x77  },
+       { R0900_P2_SMAPCOEF6    , 0x85  },
+       { R0900_P2_SMAPCOEF5    , 0x77  },
+       { R0900_P2_TSCFGL       , 0x20  },
+       { R0900_P2_DMDCFG2      , 0x3b  },
+       { R0900_P2_MODCODLST0   , 0xff  },
+       { R0900_P2_MODCODLST1   , 0xff  },
+       { R0900_P2_MODCODLST2   , 0xff  },
+       { R0900_P2_MODCODLST3   , 0xff  },
+       { R0900_P2_MODCODLST4   , 0xff  },
+       { R0900_P2_MODCODLST5   , 0xff  },
+       { R0900_P2_MODCODLST6   , 0xff  },
+       { R0900_P2_MODCODLST7   , 0xcc  },
+       { R0900_P2_MODCODLST8   , 0xcc  },
+       { R0900_P2_MODCODLST9   , 0xcc  },
+       { R0900_P2_MODCODLSTA   , 0xcc  },
+       { R0900_P2_MODCODLSTB   , 0xcc  },
+       { R0900_P2_MODCODLSTC   , 0xcc  },
+       { R0900_P2_MODCODLSTD   , 0xcc  },
+       { R0900_P2_MODCODLSTE   , 0xcc  },
+       { R0900_P2_MODCODLSTF   , 0xcf  },
+       { R0900_P1_DISTXCTL     , 0x22  },
+       { R0900_P1_F22TX        , 0xc0  },
+       { R0900_P1_F22RX        , 0xc0  },
+       { R0900_P1_DISRXCTL     , 0x00  },
+       { R0900_P1_TNRSTEPS     , 0x87  },
+       { R0900_P1_TNRGAIN      , 0x09  },
+       { R0900_P1_DMDCFGMD     , 0xf9  },
+       { R0900_P1_DEMOD        , 0x08  },
+       { R0900_P1_DMDCFG3      , 0xc4  },
+       { R0900_P1_DMDT0M       , 0x20  },
+       { R0900_P1_CARFREQ      , 0xed  },
+       { R0900_P1_TNRCFG2      , 0x82  },
+       { R0900_P1_TNRCFG3      , 0x02  },
+       { R0900_P1_LDT          , 0xd0  },
+       { R0900_P1_LDT2         , 0xb8  },
+       { R0900_P1_TMGCFG       , 0xd2  },
+       { R0900_P1_TMGTHRISE    , 0x20  },
+       { R0900_P1_TMGTHFALL    , 0x00  },
+       { R0900_P1_SFRUPRATIO   , 0xf0  },
+       { R0900_P1_SFRLOWRATIO  , 0x70  },
+       { R0900_P1_TSCFGL       , 0x20  },
+       { R0900_P1_FECSPY       , 0x88  },
+       { R0900_P1_FSPYDATA     , 0x3a  },
+       { R0900_P1_FBERCPT4     , 0x00  },
+       { R0900_P1_FSPYBER      , 0x10  },
+       { R0900_P1_ERRCTRL1     , 0x35  },
+       { R0900_P1_ERRCTRL2     , 0xc1  },
+       { R0900_P1_CFRICFG      , 0xf8  },
+       { R0900_P1_NOSCFG       , 0x1c  },
+       { R0900_P1_CORRELMANT   , 0x70  },
+       { R0900_P1_CORRELABS    , 0x88  },
+       { R0900_P1_AGC2O        , 0x5b  },
+       { R0900_P1_AGC2REF      , 0x38  },
+       { R0900_P1_CARCFG       , 0xe4  },
+       { R0900_P1_ACLC         , 0x1A  },
+       { R0900_P1_BCLC         , 0x09  },
+       { R0900_P1_CARHDR       , 0x08  },
+       { R0900_P1_KREFTMG      , 0xc1  },
+       { R0900_P1_SFRSTEP      , 0x58  },
+       { R0900_P1_TMGCFG2      , 0x01  },
+       { R0900_P1_CAR2CFG      , 0x26  },
+       { R0900_P1_BCLC2S2Q     , 0x86  },
+       { R0900_P1_BCLC2S28     , 0x86  },
+       { R0900_P1_SMAPCOEF7    , 0x77  },
+       { R0900_P1_SMAPCOEF6    , 0x85  },
+       { R0900_P1_SMAPCOEF5    , 0x77  },
+       { R0900_P1_DMDCFG2      , 0x3b  },
+       { R0900_P1_MODCODLST0   , 0xff  },
+       { R0900_P1_MODCODLST1   , 0xff  },
+       { R0900_P1_MODCODLST2   , 0xff  },
+       { R0900_P1_MODCODLST3   , 0xff  },
+       { R0900_P1_MODCODLST4   , 0xff  },
+       { R0900_P1_MODCODLST5   , 0xff  },
+       { R0900_P1_MODCODLST6   , 0xff  },
+       { R0900_P1_MODCODLST7   , 0xcc  },
+       { R0900_P1_MODCODLST8   , 0xcc  },
+       { R0900_P1_MODCODLST9   , 0xcc  },
+       { R0900_P1_MODCODLSTA   , 0xcc  },
+       { R0900_P1_MODCODLSTB   , 0xcc  },
+       { R0900_P1_MODCODLSTC   , 0xcc  },
+       { R0900_P1_MODCODLSTD   , 0xcc  },
+       { R0900_P1_MODCODLSTE   , 0xcc  },
+       { R0900_P1_MODCODLSTF   , 0xcf  },
+       { R0900_GENCFG          , 0x1d  },
+       { R0900_NBITER_NF4      , 0x37  },
+       { R0900_NBITER_NF5      , 0x29  },
+       { R0900_NBITER_NF6      , 0x37  },
+       { R0900_NBITER_NF7      , 0x33  },
+       { R0900_NBITER_NF8      , 0x31  },
+       { R0900_NBITER_NF9      , 0x2f  },
+       { R0900_NBITER_NF10     , 0x39  },
+       { R0900_NBITER_NF11     , 0x3a  },
+       { R0900_NBITER_NF12     , 0x29  },
+       { R0900_NBITER_NF13     , 0x37  },
+       { R0900_NBITER_NF14     , 0x33  },
+       { R0900_NBITER_NF15     , 0x2f  },
+       { R0900_NBITER_NF16     , 0x39  },
+       { R0900_NBITER_NF17     , 0x3a  },
+       { R0900_NBITERNOERR     , 0x04  },
+       { R0900_GAINLLR_NF4     , 0x0C  },
+       { R0900_GAINLLR_NF5     , 0x0F  },
+       { R0900_GAINLLR_NF6     , 0x11  },
+       { R0900_GAINLLR_NF7     , 0x14  },
+       { R0900_GAINLLR_NF8     , 0x17  },
+       { R0900_GAINLLR_NF9     , 0x19  },
+       { R0900_GAINLLR_NF10    , 0x20  },
+       { R0900_GAINLLR_NF11    , 0x21  },
+       { R0900_GAINLLR_NF12    , 0x0D  },
+       { R0900_GAINLLR_NF13    , 0x0F  },
+       { R0900_GAINLLR_NF14    , 0x13  },
+       { R0900_GAINLLR_NF15    , 0x1A  },
+       { R0900_GAINLLR_NF16    , 0x1F  },
+       { R0900_GAINLLR_NF17    , 0x21  },
+       { R0900_RCCFGH          , 0x20  },
+       { R0900_P1_FECM         , 0x01  }, /*disable DSS modes*/
+       { R0900_P2_FECM         , 0x01  }, /*disable DSS modes*/
+       { R0900_P1_PRVIT        , 0x2F  }, /*disable puncture rate 6/7*/
+       { R0900_P2_PRVIT        , 0x2F  }, /*disable puncture rate 6/7*/
+       { R0900_STROUT1CFG      , 0x4c  },
+       { R0900_STROUT2CFG      , 0x4c  },
+       { R0900_CLKOUT1CFG      , 0x50  },
+       { R0900_CLKOUT2CFG      , 0x50  },
+       { R0900_DPN1CFG         , 0x4a  },
+       { R0900_DPN2CFG         , 0x4a  },
+       { R0900_DATA71CFG       , 0x52  },
+       { R0900_DATA72CFG       , 0x52  },
+       { R0900_P1_TSCFGM       , 0xc0  },
+       { R0900_P2_TSCFGM       , 0xc0  },
+       { R0900_P1_TSSPEED      , 0x40  },
+       { R0900_P2_TSSPEED      , 0x40  },
+};
+
+static const u16 STV0900_Cut20_AddOnVal[32][2] = {
+       { R0900_P2_DMDCFG3      , 0xe8  },
+       { R0900_P2_DMDCFG4      , 0x10  },
+       { R0900_P2_CARFREQ      , 0x38  },
+       { R0900_P2_CARHDR       , 0x20  },
+       { R0900_P2_KREFTMG      , 0x5a  },
+       { R0900_P2_SMAPCOEF7    , 0x06  },
+       { R0900_P2_SMAPCOEF6    , 0x00  },
+       { R0900_P2_SMAPCOEF5    , 0x04  },
+       { R0900_P2_NOSCFG       , 0x0c  },
+       { R0900_P1_DMDCFG3      , 0xe8  },
+       { R0900_P1_DMDCFG4      , 0x10  },
+       { R0900_P1_CARFREQ      , 0x38  },
+       { R0900_P1_CARHDR       , 0x20  },
+       { R0900_P1_KREFTMG      , 0x5a  },
+       { R0900_P1_SMAPCOEF7    , 0x06  },
+       { R0900_P1_SMAPCOEF6    , 0x00  },
+       { R0900_P1_SMAPCOEF5    , 0x04  },
+       { R0900_P1_NOSCFG       , 0x0c  },
+       { R0900_GAINLLR_NF4     , 0x21  },
+       { R0900_GAINLLR_NF5     , 0x21  },
+       { R0900_GAINLLR_NF6     , 0x20  },
+       { R0900_GAINLLR_NF7     , 0x1F  },
+       { R0900_GAINLLR_NF8     , 0x1E  },
+       { R0900_GAINLLR_NF9     , 0x1E  },
+       { R0900_GAINLLR_NF10    , 0x1D  },
+       { R0900_GAINLLR_NF11    , 0x1B  },
+       { R0900_GAINLLR_NF12    , 0x20  },
+       { R0900_GAINLLR_NF13    , 0x20  },
+       { R0900_GAINLLR_NF14    , 0x20  },
+       { R0900_GAINLLR_NF15    , 0x20  },
+       { R0900_GAINLLR_NF16    , 0x20  },
+       { R0900_GAINLLR_NF17    , 0x21  }
+
+};
+
+#endif
diff --git a/drivers/media/dvb/frontends/stv0900_priv.h b/drivers/media/dvb/frontends/stv0900_priv.h
new file mode 100644 (file)
index 0000000..28350fb
--- /dev/null
@@ -0,0 +1,430 @@
+/*
+ * stv0900_priv.h
+ *
+ * Driver for ST STV0900 satellite demodulator IC.
+ *
+ * Copyright (C) ST Microelectronics.
+ * Copyright (C) 2009 NetUP Inc.
+ * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef STV0900_PRIV_H
+#define STV0900_PRIV_H
+
+#include <linux/i2c.h>
+
+#define ABS(X) ((X) < 0 ? (-1 * (X)) : (X))
+#define INRANGE(X, Y, Z) ((((X) <= (Y)) && ((Y) <= (Z))) \
+               || (((Z) <= (Y)) && ((Y) <= (X))) ? 1 : 0)
+
+#ifndef MAKEWORD
+#define MAKEWORD(X, Y) (((X) << 8) + (Y))
+#endif
+
+#define LSB(X) (((X) & 0xFF))
+#define MSB(Y) (((Y) >> 8) & 0xFF)
+
+#ifndef TRUE
+#define TRUE (1 == 1)
+#endif
+#ifndef FALSE
+#define FALSE (!TRUE)
+#endif
+
+#define        dmd_reg(a, b, c) \
+       do { \
+               a = 0; \
+               switch (demod) { \
+               case STV0900_DEMOD_1: \
+               default: \
+                       a = b; \
+                       break; \
+               case STV0900_DEMOD_2: \
+                       a = c; \
+                       break; \
+               } \
+       } while (0)
+
+#define dmd_choose(a, b)       (demod = STV0900_DEMOD_2 ? b : a))
+
+extern int debug;
+
+#define dprintk(args...) \
+       do { \
+               if (debug) \
+                       printk(KERN_DEBUG args); \
+       } while (0)
+
+#define STV0900_MAXLOOKUPSIZE 500
+#define STV0900_BLIND_SEARCH_AGC2_TH 700
+
+/* One point of the lookup table */
+struct stv000_lookpoint {
+       s32 realval;/* real value */
+       s32 regval;/* binary value */
+};
+
+/* Lookup table definition */
+struct stv0900_table{
+       s32 size;/* Size of the lookup table */
+       struct stv000_lookpoint table[STV0900_MAXLOOKUPSIZE];/* Lookup table */
+};
+
+enum fe_stv0900_error {
+       STV0900_NO_ERROR = 0,
+       STV0900_INVALID_HANDLE,
+       STV0900_BAD_PARAMETER,
+       STV0900_I2C_ERROR,
+       STV0900_SEARCH_FAILED,
+};
+
+enum fe_stv0900_clock_type {
+       STV0900_USE_REGISTERS_DEFAULT,
+       STV0900_SERIAL_PUNCT_CLOCK,/*Serial punctured clock */
+       STV0900_SERIAL_CONT_CLOCK,/*Serial continues clock */
+       STV0900_PARALLEL_PUNCT_CLOCK,/*Parallel punctured clock */
+       STV0900_DVBCI_CLOCK/*Parallel continues clock : DVBCI */
+};
+
+enum fe_stv0900_search_state {
+       STV0900_SEARCH = 0,
+       STV0900_PLH_DETECTED,
+       STV0900_DVBS2_FOUND,
+       STV0900_DVBS_FOUND
+
+};
+
+enum fe_stv0900_ldpc_state {
+       STV0900_PATH1_OFF_PATH2_OFF = 0,
+       STV0900_PATH1_ON_PATH2_OFF = 1,
+       STV0900_PATH1_OFF_PATH2_ON = 2,
+       STV0900_PATH1_ON_PATH2_ON = 3
+};
+
+enum fe_stv0900_signal_type {
+       STV0900_NOAGC1 = 0,
+       STV0900_AGC1OK,
+       STV0900_NOTIMING,
+       STV0900_ANALOGCARRIER,
+       STV0900_TIMINGOK,
+       STV0900_NOAGC2,
+       STV0900_AGC2OK,
+       STV0900_NOCARRIER,
+       STV0900_CARRIEROK,
+       STV0900_NODATA,
+       STV0900_DATAOK,
+       STV0900_OUTOFRANGE,
+       STV0900_RANGEOK
+};
+
+enum fe_stv0900_demod_num {
+       STV0900_DEMOD_1,
+       STV0900_DEMOD_2
+};
+
+enum fe_stv0900_tracking_standard {
+       STV0900_DVBS1_STANDARD,/* Found Standard*/
+       STV0900_DVBS2_STANDARD,
+       STV0900_DSS_STANDARD,
+       STV0900_TURBOCODE_STANDARD,
+       STV0900_UNKNOWN_STANDARD
+};
+
+enum fe_stv0900_search_standard {
+       STV0900_AUTO_SEARCH,
+       STV0900_SEARCH_DVBS1,/* Search Standard*/
+       STV0900_SEARCH_DVBS2,
+       STV0900_SEARCH_DSS,
+       STV0900_SEARCH_TURBOCODE
+};
+
+enum fe_stv0900_search_algo {
+       STV0900_BLIND_SEARCH,/* offset freq and SR are Unknown */
+       STV0900_COLD_START,/* only the SR is known */
+       STV0900_WARM_START/* offset freq and SR are known */
+};
+
+enum fe_stv0900_modulation {
+       STV0900_QPSK,
+       STV0900_8PSK,
+       STV0900_16APSK,
+       STV0900_32APSK,
+       STV0900_UNKNOWN
+};
+
+enum fe_stv0900_modcode {
+       STV0900_DUMMY_PLF,
+       STV0900_QPSK_14,
+       STV0900_QPSK_13,
+       STV0900_QPSK_25,
+       STV0900_QPSK_12,
+       STV0900_QPSK_35,
+       STV0900_QPSK_23,
+       STV0900_QPSK_34,
+       STV0900_QPSK_45,
+       STV0900_QPSK_56,
+       STV0900_QPSK_89,
+       STV0900_QPSK_910,
+       STV0900_8PSK_35,
+       STV0900_8PSK_23,
+       STV0900_8PSK_34,
+       STV0900_8PSK_56,
+       STV0900_8PSK_89,
+       STV0900_8PSK_910,
+       STV0900_16APSK_23,
+       STV0900_16APSK_34,
+       STV0900_16APSK_45,
+       STV0900_16APSK_56,
+       STV0900_16APSK_89,
+       STV0900_16APSK_910,
+       STV0900_32APSK_34,
+       STV0900_32APSK_45,
+       STV0900_32APSK_56,
+       STV0900_32APSK_89,
+       STV0900_32APSK_910,
+       STV0900_MODCODE_UNKNOWN
+};
+
+enum fe_stv0900_fec {/*DVBS1, DSS and turbo code puncture rate*/
+       STV0900_FEC_1_2 = 0,
+       STV0900_FEC_2_3,
+       STV0900_FEC_3_4,
+       STV0900_FEC_4_5,/*for turbo code only*/
+       STV0900_FEC_5_6,
+       STV0900_FEC_6_7,/*for DSS only */
+       STV0900_FEC_7_8,
+       STV0900_FEC_8_9,/*for turbo code only*/
+       STV0900_FEC_UNKNOWN
+};
+
+enum fe_stv0900_frame_length {
+       STV0900_LONG_FRAME,
+       STV0900_SHORT_FRAME
+};
+
+enum fe_stv0900_pilot {
+       STV0900_PILOTS_OFF,
+       STV0900_PILOTS_ON
+};
+
+enum fe_stv0900_rolloff {
+       STV0900_35,
+       STV0900_25,
+       STV0900_20
+};
+
+enum fe_stv0900_search_iq {
+       STV0900_IQ_AUTO,
+       STV0900_IQ_AUTO_NORMAL_FIRST,
+       STV0900_IQ_FORCE_NORMAL,
+       STV0900_IQ_FORCE_SWAPPED
+};
+
+enum stv0900_iq_inversion {
+       STV0900_IQ_NORMAL,
+       STV0900_IQ_SWAPPED
+};
+
+enum fe_stv0900_diseqc_mode {
+       STV0900_22KHZ_Continues = 0,
+       STV0900_DISEQC_2_3_PWM = 2,
+       STV0900_DISEQC_3_3_PWM = 3,
+       STV0900_DISEQC_2_3_ENVELOP = 4,
+       STV0900_DISEQC_3_3_ENVELOP = 5
+};
+
+enum fe_stv0900_demod_mode {
+       STV0900_SINGLE = 0,
+       STV0900_DUAL
+};
+
+struct stv0900_init_params{
+       u32     dmd_ref_clk;/* Refrence,Input clock for the demod in Hz */
+
+       /* Demodulator Type (single demod or dual demod) */
+       enum fe_stv0900_demod_mode      demod_mode;
+       enum fe_stv0900_rolloff         rolloff;
+       enum fe_stv0900_clock_type      path1_ts_clock;
+
+       u8      tun1_maddress;
+       int     tuner1_adc;
+
+       /* IQ from the tuner1 to the demod */
+       enum stv0900_iq_inversion       tun1_iq_inversion;
+       enum fe_stv0900_clock_type      path2_ts_clock;
+
+       u8      tun2_maddress;
+       int     tuner2_adc;
+
+       /* IQ from the tuner2 to the demod */
+       enum stv0900_iq_inversion       tun2_iq_inversion;
+};
+
+struct stv0900_search_params {
+       enum fe_stv0900_demod_num       path;/* Path Used demod1 or 2 */
+
+       u32     frequency;/* Transponder frequency (in KHz) */
+       u32     symbol_rate;/* Transponder symbol rate  (in bds)*/
+       u32     search_range;/* Range of the search (in Hz) */
+
+       enum fe_stv0900_search_standard standard;
+       enum fe_stv0900_modulation      modulation;
+       enum fe_stv0900_fec             fec;
+       enum fe_stv0900_modcode         modcode;
+       enum fe_stv0900_search_iq       iq_inversion;
+       enum fe_stv0900_search_algo     search_algo;
+
+};
+
+struct stv0900_signal_info {
+       int     locked;/* Transponder locked */
+       u32     frequency;/* Transponder frequency (in KHz) */
+       u32     symbol_rate;/* Transponder symbol rate  (in Mbds) */
+
+       enum fe_stv0900_tracking_standard       standard;
+       enum fe_stv0900_fec                     fec;
+       enum fe_stv0900_modcode                 modcode;
+       enum fe_stv0900_modulation              modulation;
+       enum fe_stv0900_pilot                   pilot;
+       enum fe_stv0900_frame_length            frame_length;
+       enum stv0900_iq_inversion               spectrum;
+       enum fe_stv0900_rolloff                 rolloff;
+
+       s32 Power;/* Power of the RF signal (dBm) */
+       s32 C_N;/* Carrier to noise ratio (dB x10)*/
+       u32 BER;/* Bit error rate (x10^7) */
+
+};
+
+struct stv0900_internal{
+       s32     quartz;
+       s32     mclk;
+       /* manual RollOff for DVBS1/DSS only */
+       enum fe_stv0900_rolloff         rolloff;
+       /* Demodulator use for single demod or for dual demod) */
+       enum fe_stv0900_demod_mode      demod_mode;
+
+       /*Demod 1*/
+       s32     tuner1_freq;
+       s32     tuner1_bw;
+       s32     dmd1_symbol_rate;
+       s32     dmd1_srch_range;
+
+       /* algorithm for search Blind, Cold or Warm*/
+       enum fe_stv0900_search_algo     dmd1_srch_algo;
+       /* search standard: Auto, DVBS1/DSS only or DVBS2 only*/
+       enum fe_stv0900_search_standard dmd1_srch_standard;
+       /* inversion search : auto, auto norma first, normal or inverted */
+       enum fe_stv0900_search_iq       dmd1_srch_iq_inv;
+       enum fe_stv0900_modcode         dmd1_modcode;
+       enum fe_stv0900_modulation      dmd1_modulation;
+       enum fe_stv0900_fec             dmd1_fec;
+
+       struct stv0900_signal_info      dmd1_rslts;
+       enum fe_stv0900_signal_type     dmd1_state;
+
+       enum fe_stv0900_error           dmd1_err;
+
+       /*Demod 2*/
+       s32     tuner2_freq;
+       s32     tuner2_bw;
+       s32     dmd2_symbol_rate;
+       s32     dmd2_srch_range;
+
+       enum fe_stv0900_search_algo     dmd2_srch_algo;
+       enum fe_stv0900_search_standard dmd2_srch_stndrd;
+       /* inversion search : auto, auto normal first, normal or inverted */
+       enum fe_stv0900_search_iq       dmd2_srch_iq_inv;
+       enum fe_stv0900_modcode         dmd2_modcode;
+       enum fe_stv0900_modulation      dmd2_modulation;
+       enum fe_stv0900_fec             dmd2_fec;
+
+       /* results of the search*/
+       struct stv0900_signal_info      dmd2_rslts;
+       /* current state of the search algorithm */
+       enum fe_stv0900_signal_type     dmd2_state;
+
+       enum fe_stv0900_error           dmd2_err;
+
+       struct i2c_adapter      *i2c_adap;
+       u8                      i2c_addr;
+       u8                      clkmode;/* 0 for CLKI, 2 for XTALI */
+       u8                      chip_id;
+       enum fe_stv0900_error   errs;
+       int dmds_used;
+};
+
+/* state for each demod */
+struct stv0900_state {
+       /* pointer for internal params, one for each pair of demods */
+       struct stv0900_internal         *internal;
+       struct i2c_adapter              *i2c_adap;
+       const struct stv0900_config     *config;
+       struct dvb_frontend             frontend;
+       int demod;
+};
+
+extern s32 ge2comp(s32 a, s32 width);
+
+extern void stv0900_write_reg(struct stv0900_internal *i_params,
+                               u16 reg_addr, u8 reg_data);
+
+extern u8 stv0900_read_reg(struct stv0900_internal *i_params,
+                               u16 reg_addr);
+
+extern void stv0900_write_bits(struct stv0900_internal *i_params,
+                               u32 label, u8 val);
+
+extern u8 stv0900_get_bits(struct stv0900_internal *i_params,
+                               u32 label);
+
+extern int stv0900_get_demod_lock(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod, s32 time_out);
+extern int stv0900_check_signal_presence(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod);
+
+extern enum fe_stv0900_signal_type stv0900_algo(struct dvb_frontend *fe);
+
+extern void stv0900_set_tuner(struct dvb_frontend *fe, u32 frequency,
+                               u32 bandwidth);
+extern void stv0900_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth);
+
+extern void stv0900_start_search(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod);
+
+extern u8 stv0900_get_optim_carr_loop(s32 srate,
+                               enum fe_stv0900_modcode modcode,
+                               s32 pilot, u8 chip_id);
+
+extern u8 stv0900_get_optim_short_carr_loop(s32 srate,
+                               enum fe_stv0900_modulation modulation,
+                               u8 chip_id);
+
+extern void stv0900_stop_all_s2_modcod(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod);
+
+extern void stv0900_activate_s2_modcode(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod);
+
+extern void stv0900_activate_s2_modcode_single(struct stv0900_internal *i_params,
+                               enum fe_stv0900_demod_num demod);
+
+extern enum fe_stv0900_tracking_standard stv0900_get_standard(struct dvb_frontend *fe,
+                               enum fe_stv0900_demod_num demod);
+
+#endif