mantis_vp2033.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #define MANTIS_MODEL_NAME "VP-2033"
  28. #define MANTIS_DEV_TYPE "DVB-C"
  29. struct mantis_hwconfig vp2033_mantis_config = {
  30. .model_name = MANTIS_MODEL_NAME,
  31. .dev_type = MANTIS_DEV_TYPE,
  32. };
  33. struct cu1216_config philips_cu1216_config = {
  34. .demod_address = 0x18 >> 1,
  35. .pll_set = philips_cu1216_tuner_set,
  36. // .fe_reset = mantis_fe_reset,
  37. };
  38. int philips_cu1216_tuner_set(struct dvb_frontend *fe,
  39. struct dvb_frontend_parameters *params)
  40. {
  41. // struct tda10021_state *state = fe->demodulator_priv;
  42. struct mantis_pci *mantis = fe->dvb->priv;
  43. u8 buf[4];
  44. struct i2c_msg msg = {
  45. .addr = 0xc0 >> 1,
  46. .flags = 0,
  47. .buf = buf,
  48. .len = sizeof (buf)
  49. };
  50. #define TUNER_MUL 62500
  51. u32 div = (params->frequency + 36125000 + TUNER_MUL / 2) / TUNER_MUL;
  52. buf[0] = (div >> 8) & 0x7f;
  53. buf[1] = div & 0xff;
  54. buf[2] = 0x86;
  55. buf[3] = (params->frequency < 150000000 ? 0xA1 :
  56. params->frequency < 445000000 ? 0x92 : 0x34);
  57. // if (i2c_transfer(state->i2c, &msg, 1) < 0) {
  58. if (i2c_transfer(&mantis->adapter, &msg, 1) < 0) {
  59. printk("%s tuner not ack!\n", __FUNCTION__);
  60. return -EIO;
  61. }
  62. msleep(100);
  63. return 0;
  64. }