dst_common.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. Frontend-driver for TwinHan DST Frontend
  3. Copyright (C) 2003 Jamie Honan
  4. Copyright (C) 2004, 2005 Manu Abraham (manu@kromtek.com)
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #ifndef DST_COMMON_H
  18. #define DST_COMMON_H
  19. #include <linux/dvb/frontend.h>
  20. #include <linux/device.h>
  21. #include "bt878.h"
  22. #include "dst_ca.h"
  23. #define NO_DELAY 0
  24. #define LONG_DELAY 1
  25. #define DEVICE_INIT 2
  26. #define DELAY 1
  27. #define DST_TYPE_IS_SAT 0
  28. #define DST_TYPE_IS_TERR 1
  29. #define DST_TYPE_IS_CABLE 2
  30. #define DST_TYPE_IS_ATSC 3
  31. #define DST_TYPE_HAS_NEWTUNE 1
  32. #define DST_TYPE_HAS_TS204 2
  33. #define DST_TYPE_HAS_SYMDIV 4
  34. #define DST_TYPE_HAS_FW_1 8
  35. #define DST_TYPE_HAS_FW_2 16
  36. #define DST_TYPE_HAS_FW_3 32
  37. #define DST_TYPE_HAS_FW_BUILD 64
  38. #define DST_TYPE_HAS_OBS_REGS 128
  39. #define DST_TYPE_HAS_INC_COUNT 256
  40. /* Card capability list */
  41. #define DST_TYPE_HAS_MAC 1
  42. #define DST_TYPE_HAS_DISEQC3 2
  43. #define DST_TYPE_HAS_DISEQC4 4
  44. #define DST_TYPE_HAS_DISEQC5 8
  45. #define DST_TYPE_HAS_MOTO 16
  46. #define DST_TYPE_HAS_CA 32
  47. #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
  48. #define DST_TYPE_HAS_SESSION 128
  49. #define RDC_8820_PIO_0_DISABLE 0
  50. #define RDC_8820_PIO_0_ENABLE 1
  51. #define RDC_8820_INT 2
  52. #define RDC_8820_RESET 4
  53. /* DST Communication */
  54. #define GET_REPLY 1
  55. #define NO_REPLY 0
  56. #define GET_ACK 1
  57. #define FIXED_COMM 8
  58. #define ACK 0xff
  59. struct dst_state {
  60. struct i2c_adapter* i2c;
  61. struct bt878* bt;
  62. struct dvb_frontend_ops ops;
  63. /* configuration settings */
  64. const struct dst_config* config;
  65. struct dvb_frontend frontend;
  66. /* private ASIC data */
  67. u8 tx_tuna[10];
  68. u8 rx_tuna[10];
  69. u8 rxbuffer[10];
  70. u8 diseq_flags;
  71. u8 dst_type;
  72. u32 type_flags;
  73. u32 frequency; /* intermediate frequency in kHz for QPSK */
  74. fe_spectral_inversion_t inversion;
  75. u32 symbol_rate; /* symbol rate in Symbols per second */
  76. fe_code_rate_t fec;
  77. fe_sec_voltage_t voltage;
  78. fe_sec_tone_mode_t tone;
  79. u32 decode_freq;
  80. u8 decode_lock;
  81. u16 decode_strength;
  82. u16 decode_snr;
  83. unsigned long cur_jiff;
  84. u8 k22;
  85. fe_bandwidth_t bandwidth;
  86. u32 dst_hw_cap;
  87. u8 dst_fw_version;
  88. fe_sec_mini_cmd_t minicmd;
  89. fe_modulation_t modulation;
  90. u8 messages[256];
  91. u8 mac_address[8];
  92. u8 fw_version[8];
  93. u8 card_info[8];
  94. u8 vendor[8];
  95. };
  96. struct dst_types {
  97. char *device_id;
  98. int offset;
  99. u8 dst_type;
  100. u32 type_flags;
  101. u32 dst_feature;
  102. };
  103. struct dst_config
  104. {
  105. /* the ASIC i2c address */
  106. u8 demod_address;
  107. };
  108. int rdc_reset_state(struct dst_state *state);
  109. int rdc_8820_reset(struct dst_state *state);
  110. int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
  111. int dst_pio_enable(struct dst_state *state);
  112. int dst_pio_disable(struct dst_state *state);
  113. int dst_error_recovery(struct dst_state* state);
  114. int dst_error_bailout(struct dst_state *state);
  115. int dst_comm_init(struct dst_state* state);
  116. int write_dst(struct dst_state *state, u8 * data, u8 len);
  117. int read_dst(struct dst_state *state, u8 * ret, u8 len);
  118. u8 dst_check_sum(u8 * buf, u32 len);
  119. struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
  120. int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
  121. int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
  122. int dst_command(struct dst_state* state, u8 * data, u8 len);
  123. #endif // DST_COMMON_H