cxd2820r_priv.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. /*
  38. * FIXME: These are totally wrong and must be added properly to the API.
  39. * Only temporary solution in order to get driver compile.
  40. */
  41. #define SYS_DVBT2 SYS_DAB
  42. #define TRANSMISSION_MODE_1K 0
  43. #define TRANSMISSION_MODE_16K 0
  44. #define TRANSMISSION_MODE_32K 0
  45. #define GUARD_INTERVAL_1_128 0
  46. #define GUARD_INTERVAL_19_128 0
  47. #define GUARD_INTERVAL_19_256 0
  48. struct reg_val_mask {
  49. u32 reg;
  50. u8 val;
  51. u8 mask;
  52. };
  53. struct cxd2820r_priv {
  54. struct i2c_adapter *i2c;
  55. struct dvb_frontend fe[2];
  56. struct cxd2820r_config cfg;
  57. struct i2c_adapter tuner_i2c_adapter;
  58. struct mutex fe_lock; /* FE lock */
  59. int active_fe:2; /* FE lock, -1=NONE, 0=DVB-T/T2, 1=DVB-C */
  60. int ber_running:1;
  61. u8 bank[2];
  62. u8 gpio[3];
  63. fe_delivery_system_t delivery_system;
  64. };
  65. /* cxd2820r_core.c */
  66. extern int cxd2820r_debug;
  67. int cxd2820r_gpio(struct dvb_frontend *fe);
  68. int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
  69. u8 mask);
  70. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  71. int len);
  72. u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor);
  73. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  74. int len);
  75. int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  76. int len);
  77. int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
  78. int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
  79. /* cxd2820r_c.c */
  80. int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
  81. struct dvb_frontend_parameters *p);
  82. int cxd2820r_set_frontend_c(struct dvb_frontend *fe,
  83. struct dvb_frontend_parameters *params);
  84. int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status);
  85. int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber);
  86. int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength);
  87. int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr);
  88. int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks);
  89. int cxd2820r_init_c(struct dvb_frontend *fe);
  90. int cxd2820r_sleep_c(struct dvb_frontend *fe);
  91. int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
  92. struct dvb_frontend_tune_settings *s);
  93. /* cxd2820r_t.c */
  94. int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
  95. struct dvb_frontend_parameters *p);
  96. int cxd2820r_set_frontend_t(struct dvb_frontend *fe,
  97. struct dvb_frontend_parameters *params);
  98. int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status);
  99. int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber);
  100. int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength);
  101. int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr);
  102. int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks);
  103. int cxd2820r_init_t(struct dvb_frontend *fe);
  104. int cxd2820r_sleep_t(struct dvb_frontend *fe);
  105. int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
  106. struct dvb_frontend_tune_settings *s);
  107. /* cxd2820r_t2.c */
  108. int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
  109. struct dvb_frontend_parameters *p);
  110. int cxd2820r_set_frontend_t2(struct dvb_frontend *fe,
  111. struct dvb_frontend_parameters *params);
  112. int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status);
  113. int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber);
  114. int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength);
  115. int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr);
  116. int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks);
  117. int cxd2820r_init_t2(struct dvb_frontend *fe);
  118. int cxd2820r_sleep_t2(struct dvb_frontend *fe);
  119. int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
  120. struct dvb_frontend_tune_settings *s);
  121. #endif /* CXD2820R_PRIV_H */