Manu Abraham | 41e840b | 2009-12-02 21:57:10 -0300 | [diff] [blame^] | 1 | /* |
| 2 | Mantis VP-2033 driver |
| 3 | |
| 4 | Copyright (C) 2005, 2006 Manu Abraham (abraham.manu@gmail.com) |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2 of the License, or |
| 9 | (at your option) any later version. |
| 10 | |
| 11 | This program is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | GNU General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU General Public License |
| 17 | along with this program; if not, write to the Free Software |
| 18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "mantis_common.h" |
| 22 | #include "mantis_vp2033.h" |
| 23 | |
| 24 | struct tda10021_state { |
| 25 | struct i2c_adapter *i2c; |
| 26 | struct dvb_frontend_ops ops; |
| 27 | /* configuration settings */ |
| 28 | const struct tda10021_config *config; |
| 29 | struct dvb_frontend frontend; |
| 30 | |
| 31 | u8 pwm; |
| 32 | u8 reg0; |
| 33 | }; |
| 34 | |
| 35 | struct cu1216_config philips_cu1216_config = { |
| 36 | .demod_address = 0x18 >> 1, |
| 37 | .pll_set = philips_cu1216_tuner_set, |
| 38 | // .fe_reset = mantis_fe_reset, |
| 39 | }; |
| 40 | |
| 41 | int philips_cu1216_tuner_set(struct dvb_frontend *fe, |
| 42 | struct dvb_frontend_parameters *params) |
| 43 | { |
| 44 | // struct tda10021_state *state = fe->demodulator_priv; |
| 45 | struct mantis_pci *mantis = fe->dvb->priv; |
| 46 | |
| 47 | u8 buf[4]; |
| 48 | |
| 49 | struct i2c_msg msg = { |
| 50 | .addr = 0xc0 >> 1, |
| 51 | .flags = 0, |
| 52 | .buf = buf, |
| 53 | .len = sizeof (buf) |
| 54 | }; |
| 55 | |
| 56 | #define TUNER_MUL 62500 |
| 57 | |
| 58 | u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL; |
| 59 | |
| 60 | buf[0] = (div >> 8) & 0x7f; |
| 61 | buf[1] = div & 0xff; |
| 62 | buf[2] = 0x86; |
| 63 | buf[3] = (params->frequency < 150000000 ? 0xA1 : |
| 64 | params->frequency < 445000000 ? 0x92 : 0x34); |
| 65 | |
| 66 | // if (i2c_transfer(state->i2c, &msg, 1) < 0) { |
| 67 | if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) { |
| 68 | printk("%s tuner not ack!\n", __FUNCTION__); |
| 69 | return -EIO; |
| 70 | } |
| 71 | msleep(100); |
| 72 | return 0; |
| 73 | } |