-static int mxl5005s_reset(struct dvb_frontend *fe)
-{
- struct mxl5005s_state *state = fe->tuner_priv;
- int ret = 0;
-
- u8 buf[2] = { 0xff, 0x00 };
- struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
- .buf = buf, .len = 2 };
-
- dprintk(2, "%s()\n", __func__);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
-
- if (i2c_transfer(state->i2c, &msg, 1) != 1) {
- printk(KERN_WARNING "mxl5005s I2C reset failed\n");
- ret = -EREMOTEIO;
- }
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
-
- return ret;
-}
-
-/* Write a single byte to a single reg */
-static int mxl5005s_writereg(struct dvb_frontend *fe, u8 reg, u8 val, int latch)
-{
- struct mxl5005s_state *state = fe->tuner_priv;
- u8 buf[3] = { reg, val, MXL5005S_LATCH_BYTE };
- struct i2c_msg msg = { .addr = state->config->i2c_address, .flags = 0,
- .buf = buf, .len = 3 };
-
- if(latch == 0)
- msg.len = 2;
-
- dprintk(2, "%s(reg = 0x%x val = 0x%x addr = 0x%x)\n", __func__, reg, val, msg.addr);
-
- if (i2c_transfer(state->i2c, &msg, 1) != 1) {
- printk(KERN_WARNING "mxl5005s I2C write failed\n");
- return -EREMOTEIO;
- }
- return 0;
-}
-
-int mxl5005s_SetRegsWithTable(struct dvb_frontend *fe, u8 *pAddrTable, u8 *pByteTable, int TableLen)
-{
- int i, ret = 0;
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 1);
-
- for( i = 0 ; i < TableLen - 1 ; i++)
- {
- ret = mxl5005s_writereg(fe, pAddrTable[i], pByteTable[i], 0);
- if (ret < 0)
- break;
- }
-
- ret = mxl5005s_writereg(fe, pAddrTable[i], pByteTable[i], 1);
-
- if (fe->ops.i2c_gate_ctrl)
- fe->ops.i2c_gate_ctrl(fe, 0);
-
- return ret;
-}
-
-int mxl5005s_SetRegMaskBits(struct dvb_frontend *fe,
- unsigned char RegAddr,
- unsigned char Msb,
- unsigned char Lsb,
- const unsigned char WritingValue
- )
-{
- int i;
-
- unsigned char Mask;
- unsigned char Shift;
- unsigned char RegByte;
-
- /* Generate mask and shift according to MSB and LSB. */
- Mask = 0;
- for(i = Lsb; i < (unsigned char)(Msb + 1); i++)
- Mask |= 0x1 << i;
-
- Shift = Lsb;
-
- /* Get tuner register byte according to register adddress. */
- MXL_RegRead(fe, RegAddr, &RegByte);
-
- /* Reserve register byte unmask bit with mask and inlay writing value into it. */
- RegByte &= ~Mask;
- RegByte |= (WritingValue << Shift) & Mask;
-
- /* Update tuner register byte table. */
- MXL_RegWrite(fe, RegAddr, RegByte);
-
- /* Write tuner register byte with writing byte. */
- return mxl5005s_SetRegsWithTable(fe, &RegAddr, &RegByte, 1);
-}
-
-
-// The following context is source code provided by MaxLinear.
-// MaxLinear source code - MXL5005_Initialize.cpp
-// DONE