cxd2820r_priv.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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;
  45. struct cxd2820r_config cfg;
  46. bool ber_running;
  47. u8 bank[2];
  48. u8 gpio[3];
  49. fe_delivery_system_t delivery_system;
  50. bool last_tune_failed; /* for switch between T and T2 tune */
  51. };
  52. /* cxd2820r_core.c */
  53. extern int cxd2820r_debug;
  54. int cxd2820r_gpio(struct dvb_frontend *fe);
  55. int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
  56. u8 mask);
  57. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  58. int len);
  59. u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor);
  60. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  61. int len);
  62. int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  63. int len);
  64. int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
  65. int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
  66. /* cxd2820r_c.c */
  67. int cxd2820r_get_frontend_c(struct dvb_frontend *fe);
  68. int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
  69. int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status);
  70. int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber);
  71. int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength);
  72. int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr);
  73. int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks);
  74. int cxd2820r_init_c(struct dvb_frontend *fe);
  75. int cxd2820r_sleep_c(struct dvb_frontend *fe);
  76. int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
  77. struct dvb_frontend_tune_settings *s);
  78. /* cxd2820r_t.c */
  79. int cxd2820r_get_frontend_t(struct dvb_frontend *fe);
  80. int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
  81. int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status);
  82. int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber);
  83. int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength);
  84. int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr);
  85. int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks);
  86. int cxd2820r_init_t(struct dvb_frontend *fe);
  87. int cxd2820r_sleep_t(struct dvb_frontend *fe);
  88. int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
  89. struct dvb_frontend_tune_settings *s);
  90. /* cxd2820r_t2.c */
  91. int cxd2820r_get_frontend_t2(struct dvb_frontend *fe);
  92. int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
  93. int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status);
  94. int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber);
  95. int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength);
  96. int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr);
  97. int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks);
  98. int cxd2820r_init_t2(struct dvb_frontend *fe);
  99. int cxd2820r_sleep_t2(struct dvb_frontend *fe);
  100. int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
  101. struct dvb_frontend_tune_settings *s);
  102. #endif /* CXD2820R_PRIV_H */