tuner_r82xx.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Rafael Micro R820T/R828D driver
  3. *
  4. * Copyright (C) 2013 Mauro Carvalho Chehab <mchehab@redhat.com>
  5. * Copyright (C) 2013 Steve Markgraf <steve@steve-m.de>
  6. *
  7. * This driver is a heavily modified version of the driver found in the
  8. * Linux kernel:
  9. * http://git.linuxtv.org/linux-2.6.git/history/HEAD:/drivers/media/tuners/r820t.c
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation, either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. */
  24. #ifndef R82XX_H
  25. #define R82XX_H
  26. #define R820T_I2C_ADDR 0x34
  27. #define R828D_I2C_ADDR 0x74
  28. #define R828D_XTAL_FREQ 16000000
  29. #define R82XX_CHECK_ADDR 0x00
  30. #define R82XX_CHECK_VAL 0x69
  31. #define R82XX_IF_FREQ 3570000
  32. #define REG_SHADOW_START 5
  33. #define NUM_REGS 30
  34. #define NUM_IMR 5
  35. #define IMR_TRIAL 9
  36. #define VER_NUM 49
  37. enum r82xx_chip {
  38. CHIP_R820T,
  39. CHIP_R620D,
  40. CHIP_R828D,
  41. CHIP_R828,
  42. CHIP_R828S,
  43. CHIP_R820C,
  44. };
  45. enum r82xx_tuner_type {
  46. TUNER_RADIO = 1,
  47. TUNER_ANALOG_TV,
  48. TUNER_DIGITAL_TV
  49. };
  50. enum r82xx_xtal_cap_value {
  51. XTAL_LOW_CAP_30P = 0,
  52. XTAL_LOW_CAP_20P,
  53. XTAL_LOW_CAP_10P,
  54. XTAL_LOW_CAP_0P,
  55. XTAL_HIGH_CAP_0P
  56. };
  57. struct r82xx_config {
  58. uint8_t i2c_addr;
  59. uint32_t xtal;
  60. enum r82xx_chip rafael_chip;
  61. unsigned int max_i2c_msg_len;
  62. int use_predetect;
  63. };
  64. struct r82xx_priv {
  65. struct r82xx_config *cfg;
  66. uint8_t regs[NUM_REGS];
  67. uint8_t buf[NUM_REGS + 1];
  68. enum r82xx_xtal_cap_value xtal_cap_sel;
  69. uint16_t pll; /* kHz */
  70. uint32_t int_freq;
  71. uint8_t fil_cal_code;
  72. uint8_t input;
  73. int has_lock;
  74. int init_done;
  75. /* Store current mode */
  76. uint32_t delsys;
  77. enum r82xx_tuner_type type;
  78. uint32_t bw; /* in MHz */
  79. void *rtl_dev;
  80. };
  81. struct r82xx_freq_range {
  82. uint32_t freq;
  83. uint8_t open_d;
  84. uint8_t rf_mux_ploy;
  85. uint8_t tf_c;
  86. uint8_t xtal_cap20p;
  87. uint8_t xtal_cap10p;
  88. uint8_t xtal_cap0p;
  89. };
  90. enum r82xx_delivery_system {
  91. SYS_UNDEFINED,
  92. SYS_DVBT,
  93. SYS_DVBT2,
  94. SYS_ISDBT,
  95. };
  96. int r82xx_standby(struct r82xx_priv *priv);
  97. int r82xx_init(struct r82xx_priv *priv);
  98. int r82xx_set_freq(struct r82xx_priv *priv, uint32_t freq);
  99. int r82xx_set_gain(struct r82xx_priv *priv, int set_manual_gain, int gain);
  100. #endif