tdhd1.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * tdhd1.h - ALPS TDHD1-204A tuner support
  4. *
  5. * Copyright (C) 2008 Oliver Endriss <[email protected]>
  6. *
  7. * The project's page is at https://linuxtv.org
  8. */
  9. #ifndef TDHD1_H
  10. #define TDHD1_H
  11. #include "tda1004x.h"
  12. static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name);
  13. static struct tda1004x_config alps_tdhd1_204a_config = {
  14. .demod_address = 0x8,
  15. .invert = 1,
  16. .invert_oclk = 0,
  17. .xtal_freq = TDA10046_XTAL_4M,
  18. .agc_config = TDA10046_AGC_DEFAULT,
  19. .if_freq = TDA10046_FREQ_3617,
  20. .request_firmware = alps_tdhd1_204_request_firmware
  21. };
  22. static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe)
  23. {
  24. struct dtv_frontend_properties *p = &fe->dtv_property_cache;
  25. struct i2c_adapter *i2c = fe->tuner_priv;
  26. u8 data[4];
  27. struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
  28. u32 div;
  29. div = (p->frequency + 36166666) / 166666;
  30. data[0] = (div >> 8) & 0x7f;
  31. data[1] = div & 0xff;
  32. data[2] = 0x85;
  33. if (p->frequency >= 174000000 && p->frequency <= 230000000)
  34. data[3] = 0x02;
  35. else if (p->frequency >= 470000000 && p->frequency <= 823000000)
  36. data[3] = 0x0C;
  37. else if (p->frequency > 823000000 && p->frequency <= 862000000)
  38. data[3] = 0x8C;
  39. else
  40. return -EINVAL;
  41. if (fe->ops.i2c_gate_ctrl)
  42. fe->ops.i2c_gate_ctrl(fe, 1);
  43. if (i2c_transfer(i2c, &msg, 1) != 1)
  44. return -EIO;
  45. return 0;
  46. }
  47. #endif /* TDHD1_H */