2 * b2c2-common.c - common methods for the B2C2/Technisat SkyStar2 PCI DVB card and
3 * for the B2C2/Technisat Sky/Cable/AirStar USB devices
4 * based on the FlexCopII/FlexCopIII by B2C2, Inc.
6 * Copyright (C) 2003 Vadim Catana, skystar@moldova.cc
8 * FIX: DISEQC Tone Burst in flexcop_diseqc_ioctl()
9 * FIX: FULL soft DiSEqC for skystar2 (FlexCopII rev 130) VP310 equipped
10 * Vincenzo Di Massa, hawk.it at tiscalinet.it
12 * Converted to Linux coding style
13 * Misc reorganization, polishing, restyling
14 * Roberto Ragusa, r.ragusa at libero.it
16 * Added hardware filtering support,
17 * Niklas Peinecke, peinecke at gdv.uni-hannover.de
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU Lesser General Public License
21 * as published by the Free Software Foundation; either version 2.1
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU Lesser General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 static int samsung_tbmu24112_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
43 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
44 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
45 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
46 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
47 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
48 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
50 stv0299_writereg (fe, 0x13, aclk);
51 stv0299_writereg (fe, 0x14, bclk);
52 stv0299_writereg (fe, 0x1f, (ratio >> 16) & 0xff);
53 stv0299_writereg (fe, 0x20, (ratio >> 8) & 0xff);
54 stv0299_writereg (fe, 0x21, (ratio ) & 0xf0);
59 static int samsung_tbmu24112_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
63 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
64 // struct adapter* adapter = (struct adapter*) fe->dvb->priv;
66 div = params->frequency / 125;
68 buf[0] = (div >> 8) & 0x7f;
70 buf[2] = 0x84; // 0xC4
73 if (params->frequency < 1500000) buf[3] |= 0x10;
75 // if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
79 static u8 samsung_tbmu24112_inittab[] = {
124 static struct stv0299_config samsung_tbmu24112_config = {
125 .demod_address = 0x68,
126 .inittab = samsung_tbmu24112_inittab,
129 .enhanced_tuning = 0,
131 .lock_output = STV0229_LOCKOUTPUT_LK,
132 .volt13_op0_op1 = STV0299_VOLT13_OP1,
134 .set_symbol_rate = samsung_tbmu24112_set_symbol_rate,
135 .pll_set = samsung_tbmu24112_pll_set,
142 static int samsung_tdtc9251dh0_demod_init(struct dvb_frontend* fe)
144 static u8 mt352_clock_config [] = { 0x89, 0x10, 0x2d };
145 static u8 mt352_reset [] = { 0x50, 0x80 };
146 static u8 mt352_adc_ctl_1_cfg [] = { 0x8E, 0x40 };
147 static u8 mt352_agc_cfg [] = { 0x67, 0x28, 0xa1 };
148 static u8 mt352_capt_range_cfg[] = { 0x75, 0x32 };
150 mt352_write(fe, mt352_clock_config, sizeof(mt352_clock_config));
152 mt352_write(fe, mt352_reset, sizeof(mt352_reset));
153 mt352_write(fe, mt352_adc_ctl_1_cfg, sizeof(mt352_adc_ctl_1_cfg));
155 mt352_write(fe, mt352_agc_cfg, sizeof(mt352_agc_cfg));
156 mt352_write(fe, mt352_capt_range_cfg, sizeof(mt352_capt_range_cfg));
161 static int samsung_tdtc9251dh0_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params, u8* pllbuf)
164 unsigned char bs = 0;
166 #define IF_FREQUENCYx6 217 /* 6 * 36.16666666667MHz */
167 div = (((params->frequency + 83333) * 3) / 500000) + IF_FREQUENCYx6;
169 if (params->frequency >= 48000000 && params->frequency <= 154000000) bs = 0x09;
170 if (params->frequency >= 161000000 && params->frequency <= 439000000) bs = 0x0a;
171 if (params->frequency >= 447000000 && params->frequency <= 863000000) bs = 0x08;
173 pllbuf[0] = 0xc2; // Note: non-linux standard PLL i2c address
174 pllbuf[1] = div >> 8;
175 pllbuf[2] = div & 0xff;
182 static struct mt352_config samsung_tdtc9251dh0_config = {
184 .demod_address = 0x0f,
185 .demod_init = samsung_tdtc9251dh0_demod_init,
186 .pll_set = samsung_tdtc9251dh0_pll_set,
189 static int skystar23_samsung_tbdu18132_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
193 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };
194 // struct adapter* adapter = (struct adapter*) fe->dvb->priv;
196 div = (params->frequency + (125/2)) / 125;
198 buf[0] = (div >> 8) & 0x7f;
199 buf[1] = (div >> 0) & 0xff;
200 buf[2] = 0x84 | ((div >> 10) & 0x60);
203 if (params->frequency < 1550000)
206 //if (i2c_transfer (&adapter->i2c_adap, &msg, 1) != 1) return -EIO;
210 static struct mt312_config skystar23_samsung_tbdu18132_config = {
212 .demod_address = 0x0e,
213 .pll_set = skystar23_samsung_tbdu18132_pll_set,