cxd2820r_priv.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. #include <linux/gpio.h>
  27. #include <linux/math64.h>
  28. #include <linux/regmap.h>
  29. struct reg_val_mask {
  30. u32 reg;
  31. u8 val;
  32. u8 mask;
  33. };
  34. #define CXD2820R_CLK 41000000
  35. struct cxd2820r_priv {
  36. struct i2c_client *client[2];
  37. struct regmap *regmap[2];
  38. struct i2c_adapter *i2c;
  39. struct dvb_frontend fe;
  40. u8 ts_mode;
  41. bool ts_clk_inv;
  42. bool if_agc_polarity;
  43. bool spec_inv;
  44. u64 post_bit_error_prev_dvbv3;
  45. u64 post_bit_error;
  46. bool ber_running;
  47. #define GPIO_COUNT 3
  48. u8 gpio[GPIO_COUNT];
  49. #ifdef CONFIG_GPIOLIB
  50. struct gpio_chip gpio_chip;
  51. #endif
  52. enum fe_delivery_system delivery_system;
  53. bool last_tune_failed; /* 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, u8 *gpio);
  58. int cxd2820r_wr_reg_val_mask_tab(struct cxd2820r_priv *priv,
  59. const struct reg_val_mask *tab, int tab_len);
  60. int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
  61. u8 mask);
  62. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  63. int len);
  64. int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  65. int len);
  66. int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
  67. int len);
  68. int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
  69. int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
  70. /* cxd2820r_c.c */
  71. int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
  72. struct dtv_frontend_properties *p);
  73. int cxd2820r_set_frontend_c(struct dvb_frontend *fe);
  74. int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status);
  75. int cxd2820r_init_c(struct dvb_frontend *fe);
  76. int cxd2820r_sleep_c(struct dvb_frontend *fe);
  77. int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
  78. struct dvb_frontend_tune_settings *s);
  79. /* cxd2820r_t.c */
  80. int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
  81. struct dtv_frontend_properties *p);
  82. int cxd2820r_set_frontend_t(struct dvb_frontend *fe);
  83. int cxd2820r_read_status_t(struct dvb_frontend *fe, enum fe_status *status);
  84. int cxd2820r_init_t(struct dvb_frontend *fe);
  85. int cxd2820r_sleep_t(struct dvb_frontend *fe);
  86. int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
  87. struct dvb_frontend_tune_settings *s);
  88. /* cxd2820r_t2.c */
  89. int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
  90. struct dtv_frontend_properties *p);
  91. int cxd2820r_set_frontend_t2(struct dvb_frontend *fe);
  92. int cxd2820r_read_status_t2(struct dvb_frontend *fe, enum fe_status *status);
  93. int cxd2820r_init_t2(struct dvb_frontend *fe);
  94. int cxd2820r_sleep_t2(struct dvb_frontend *fe);
  95. int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
  96. struct dvb_frontend_tune_settings *s);
  97. #endif /* CXD2820R_PRIV_H */