Path: blob/master/drivers/media/dvb/frontends/bsru6.h
15112 views
/*1* bsru6.h - ALPS BSRU6 tuner support (moved from budget-ci.c)2*3* This program is free software; you can redistribute it and/or4* modify it under the terms of the GNU General Public License5* as published by the Free Software Foundation; either version 26* of the License, or (at your option) any later version.7*8*9* This program is distributed in the hope that it will be useful,10* but WITHOUT ANY WARRANTY; without even the implied warranty of11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12* GNU General Public License for more details.13*14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.18* Or, point your browser to http://www.gnu.org/copyleft/gpl.html19*20*21* the project's page is at http://www.linuxtv.org22*/2324#ifndef BSRU6_H25#define BSRU6_H2627static u8 alps_bsru6_inittab[] = {280x01, 0x15,290x02, 0x30,300x03, 0x00,310x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */320x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */330x06, 0x40, /* DAC not used, set to high impendance mode */340x07, 0x00, /* DAC LSB */350x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */360x09, 0x00, /* FIFO */370x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */380x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */390x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */400x10, 0x3f, // AGC2 0x3d410x11, 0x84,420x12, 0xb9,430x15, 0xc9, // lock detector threshold440x16, 0x00,450x17, 0x00,460x18, 0x00,470x19, 0x00,480x1a, 0x00,490x1f, 0x50,500x20, 0x00,510x21, 0x00,520x22, 0x00,530x23, 0x00,540x28, 0x00, // out imp: normal out type: parallel FEC mode:0550x29, 0x1e, // 1/2 threshold560x2a, 0x14, // 2/3 threshold570x2b, 0x0f, // 3/4 threshold580x2c, 0x09, // 5/6 threshold590x2d, 0x05, // 7/8 threshold600x2e, 0x01,610x31, 0x1f, // test all FECs620x32, 0x19, // viterbi and synchro search630x33, 0xfc, // rs control640x34, 0x93, // error control650x0f, 0x52,660xff, 0xff67};6869static int alps_bsru6_set_symbol_rate(struct dvb_frontend *fe, u32 srate, u32 ratio)70{71u8 aclk = 0;72u8 bclk = 0;7374if (srate < 1500000) {75aclk = 0xb7;76bclk = 0x47;77} else if (srate < 3000000) {78aclk = 0xb7;79bclk = 0x4b;80} else if (srate < 7000000) {81aclk = 0xb7;82bclk = 0x4f;83} else if (srate < 14000000) {84aclk = 0xb7;85bclk = 0x53;86} else if (srate < 30000000) {87aclk = 0xb6;88bclk = 0x53;89} else if (srate < 45000000) {90aclk = 0xb4;91bclk = 0x51;92}9394stv0299_writereg(fe, 0x13, aclk);95stv0299_writereg(fe, 0x14, bclk);96stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);97stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);98stv0299_writereg(fe, 0x21, ratio & 0xf0);99100return 0;101}102103static int alps_bsru6_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)104{105u8 buf[4];106u32 div;107struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = buf, .len = sizeof(buf) };108struct i2c_adapter *i2c = fe->tuner_priv;109110if ((params->frequency < 950000) || (params->frequency > 2150000))111return -EINVAL;112113div = (params->frequency + (125 - 1)) / 125; // round correctly114buf[0] = (div >> 8) & 0x7f;115buf[1] = div & 0xff;116buf[2] = 0x80 | ((div & 0x18000) >> 10) | 4;117buf[3] = 0xC4;118119if (params->frequency > 1530000)120buf[3] = 0xc0;121122if (fe->ops.i2c_gate_ctrl)123fe->ops.i2c_gate_ctrl(fe, 1);124if (i2c_transfer(i2c, &msg, 1) != 1)125return -EIO;126return 0;127}128129static struct stv0299_config alps_bsru6_config = {130.demod_address = 0x68,131.inittab = alps_bsru6_inittab,132.mclk = 88000000UL,133.invert = 1,134.skip_reinit = 0,135.lock_output = STV0299_LOCKOUTPUT_1,136.volt13_op0_op1 = STV0299_VOLT13_OP1,137.min_delay_ms = 100,138.set_symbol_rate = alps_bsru6_set_symbol_rate,139};140141#endif142143144