0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BSBE1_H
0009 #define BSBE1_H
0010
0011 static u8 alps_bsbe1_inittab[] = {
0012 0x01, 0x15,
0013 0x02, 0x30,
0014 0x03, 0x00,
0015 0x04, 0x7d,
0016 0x05, 0x05,
0017 0x06, 0x00,
0018 0x08, 0x40,
0019 0x09, 0x00,
0020 0x0c, 0x51,
0021 0x0d, 0x82,
0022 0x0f, 0x92,
0023 0x10, 0x34,
0024 0x11, 0x84,
0025 0x12, 0xb9,
0026 0x15, 0xc9,
0027 0x28, 0x00,
0028 0x33, 0xfc,
0029 0x34, 0x93,
0030 0xff, 0xff
0031 };
0032
0033
0034 static int alps_bsbe1_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
0035 {
0036 u8 aclk = 0;
0037 u8 bclk = 0;
0038
0039 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
0040 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
0041 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
0042 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
0043 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
0044 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
0045
0046 stv0299_writereg(fe, 0x13, aclk);
0047 stv0299_writereg(fe, 0x14, bclk);
0048 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
0049 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
0050 stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
0051
0052 return 0;
0053 }
0054
0055 static int alps_bsbe1_tuner_set_params(struct dvb_frontend *fe)
0056 {
0057 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
0058 int ret;
0059 u8 data[4];
0060 u32 div;
0061 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
0062 struct i2c_adapter *i2c = fe->tuner_priv;
0063
0064 if ((p->frequency < 950000) || (p->frequency > 2150000))
0065 return -EINVAL;
0066
0067 div = p->frequency / 1000;
0068 data[0] = (div >> 8) & 0x7f;
0069 data[1] = div & 0xff;
0070 data[2] = 0x80 | ((div & 0x18000) >> 10) | 0x1;
0071 data[3] = 0xe0;
0072
0073 if (fe->ops.i2c_gate_ctrl)
0074 fe->ops.i2c_gate_ctrl(fe, 1);
0075 ret = i2c_transfer(i2c, &msg, 1);
0076 return (ret != 1) ? -EIO : 0;
0077 }
0078
0079 static struct stv0299_config alps_bsbe1_config = {
0080 .demod_address = 0x68,
0081 .inittab = alps_bsbe1_inittab,
0082 .mclk = 88000000UL,
0083 .invert = 1,
0084 .skip_reinit = 0,
0085 .min_delay_ms = 100,
0086 .set_symbol_rate = alps_bsbe1_set_symbol_rate,
0087 };
0088
0089 #endif