cxd2820r_priv.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /*
  2. * Sony CXD2820R demodulator driver
  3. *
  4. * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. */
  20. #ifndef CXD2820R_PRIV_H
  21. #define CXD2820R_PRIV_H
  22. #include <linux/dvb/version.h>
  23. #include "dvb_frontend.h"
  24. #include "dvb_math.h"
  25. #include "cxd2820r.h"
  26. #define LOG_PREFIX "cxd2820r"
  27. #undef dbg
  28. #define dbg(f, arg...) \
  29. if (cxd2820r_debug) \
  30. printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
  31. #undef err
  32. #define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg)
  33. #undef info
  34. #define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
  35. #undef warn
  36. #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg)
  37. struct reg_val_mask {
  38. u32 reg;
  39. u8 val;
  40. u8 mask;
  41. };
  42. struct cxd2820r_priv {
  43. struct i2c_adapter *i2c;
  44. struct dvb_frontend fe[2];
  45. struct cxd2820r_config cfg;
  46. struct i2c_adapter tuner_i2c_adapter;
  47. struct mutex fe_lock; /* FE lock */
  48. int active_fe:2; /* FE lock, -1=NONE, 0=DVB-T/T2, 1=DVB-C */
  49. int ber_running:1;
  50. u8 bank[2];
  51. u8 gpio[3];
  52. fe_delivery_system_t delivery_system;
  53. int last_tune_failed:1; /* for switch between T and T2 tune */
  54. };
  55. /* cxd2820r_core.c */
  56. extern int cxd2820r_debug;
  57. int cxd2820r_gpio(struct dvb_frontend *fe);
  58. int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
  59. u8 mask);
  60. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  61. int len);
  62. u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor);
  63. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  64. int len);
  65. int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  66. int len);
  67. int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
  68. int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
  69. /* cxd2820r_c.c */
  70. int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
  71. struct dvb_frontend_parameters *p);
  72. int cxd2820r_set_frontend_c(struct dvb_frontend *fe,
  73. struct dvb_frontend_parameters *params);
  74. int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status);
  75. int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber);
  76. int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength);
  77. int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr);
  78. int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks);
  79. int cxd2820r_init_c(struct dvb_frontend *fe);
  80. int cxd2820r_sleep_c(struct dvb_frontend *fe);
  81. int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
  82. struct dvb_frontend_tune_settings *s);
  83. /* cxd2820r_t.c */
  84. int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
  85. struct dvb_frontend_parameters *p);
  86. int cxd2820r_set_frontend_t(struct dvb_frontend *fe,
  87. struct dvb_frontend_parameters *params);
  88. int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status);
  89. int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber);
  90. int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength);
  91. int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr);
  92. int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks);
  93. int cxd2820r_init_t(struct dvb_frontend *fe);
  94. int cxd2820r_sleep_t(struct dvb_frontend *fe);
  95. int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
  96. struct dvb_frontend_tune_settings *s);
  97. /* cxd2820r_t2.c */
  98. int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
  99. struct dvb_frontend_parameters *p);
  100. int cxd2820r_set_frontend_t2(struct dvb_frontend *fe,
  101. struct dvb_frontend_parameters *params);
  102. int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status);
  103. int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber);
  104. int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength);
  105. int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr);
  106. int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks);
  107. int cxd2820r_init_t2(struct dvb_frontend *fe);
  108. int cxd2820r_sleep_t2(struct dvb_frontend *fe);
  109. int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
  110. struct dvb_frontend_tune_settings *s);
  111. #endif /* CXD2820R_PRIV_H */