tdhd1.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * tdhd1.h - ALPS TDHD1-204A tuner support
  3. *
  4. * Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de>
  5. *
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. * To obtain the license, point your browser to
  17. * http://www.gnu.org/copyleft/gpl.html
  18. *
  19. *
  20. * The project's page is at https://linuxtv.org
  21. */
  22. #ifndef TDHD1_H
  23. #define TDHD1_H
  24. #include "tda1004x.h"
  25. static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name);
  26. static struct tda1004x_config alps_tdhd1_204a_config = {
  27. .demod_address = 0x8,
  28. .invert = 1,
  29. .invert_oclk = 0,
  30. .xtal_freq = TDA10046_XTAL_4M,
  31. .agc_config = TDA10046_AGC_DEFAULT,
  32. .if_freq = TDA10046_FREQ_3617,
  33. .request_firmware = alps_tdhd1_204_request_firmware
  34. };
  35. static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe)
  36. {
  37. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  38. struct i2c_adapter *i2c = fe->tuner_priv;
  39. u8 data[4];
  40. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
  41. u32 div;
  42. div = (p->frequency + 36166666) / 166666;
  43. data[0] = (div >> 8) & 0x7f;
  44. data[1] = div & 0xff;
  45. data[2] = 0x85;
  46. if (p->frequency >= 174000000 && p->frequency <= 230000000)
  47. data[3] = 0x02;
  48. else if (p->frequency >= 470000000 && p->frequency <= 823000000)
  49. data[3] = 0x0C;
  50. else if (p->frequency > 823000000 && p->frequency <= 862000000)
  51. data[3] = 0x8C;
  52. else
  53. return -EINVAL;
  54. if (fe->ops.i2c_gate_ctrl)
  55. fe->ops.i2c_gate_ctrl(fe, 1);
  56. if (i2c_transfer(i2c, &msg, 1) != 1)
  57. return -EIO;
  58. return 0;
  59. }
  60. #endif /* TDHD1_H */