mantis_vp2033.c 1.9 KB

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