dst_common.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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/smp_lock.h>
  20. #include <linux/dvb/frontend.h>
  21. #include <linux/device.h>
  22. #include <linux/mutex.h>
  23. #include "bt878.h"
  24. #include "dst_ca.h"
  25. #define NO_DELAY 0
  26. #define LONG_DELAY 1
  27. #define DEVICE_INIT 2
  28. #define DELAY 1
  29. #define DST_TYPE_IS_SAT 0
  30. #define DST_TYPE_IS_TERR 1
  31. #define DST_TYPE_IS_CABLE 2
  32. #define DST_TYPE_IS_ATSC 3
  33. #define DST_TYPE_HAS_NEWTUNE 1
  34. #define DST_TYPE_HAS_TS204 2
  35. #define DST_TYPE_HAS_SYMDIV 4
  36. #define DST_TYPE_HAS_FW_1 8
  37. #define DST_TYPE_HAS_FW_2 16
  38. #define DST_TYPE_HAS_FW_3 32
  39. #define DST_TYPE_HAS_FW_BUILD 64
  40. #define DST_TYPE_HAS_OBS_REGS 128
  41. #define DST_TYPE_HAS_INC_COUNT 256
  42. #define DST_TYPE_HAS_MULTI_FE 512
  43. /* Card capability list */
  44. #define DST_TYPE_HAS_MAC 1
  45. #define DST_TYPE_HAS_DISEQC3 2
  46. #define DST_TYPE_HAS_DISEQC4 4
  47. #define DST_TYPE_HAS_DISEQC5 8
  48. #define DST_TYPE_HAS_MOTO 16
  49. #define DST_TYPE_HAS_CA 32
  50. #define DST_TYPE_HAS_ANALOG 64 /* Analog inputs */
  51. #define DST_TYPE_HAS_SESSION 128
  52. #define RDC_8820_PIO_0_DISABLE 0
  53. #define RDC_8820_PIO_0_ENABLE 1
  54. #define RDC_8820_INT 2
  55. #define RDC_8820_RESET 4
  56. /* DST Communication */
  57. #define GET_REPLY 1
  58. #define NO_REPLY 0
  59. #define GET_ACK 1
  60. #define FIXED_COMM 8
  61. #define ACK 0xff
  62. struct dst_state {
  63. struct i2c_adapter* i2c;
  64. struct bt878* bt;
  65. struct dvb_frontend_ops ops;
  66. /* configuration settings */
  67. const struct dst_config* config;
  68. struct dvb_frontend frontend;
  69. /* private ASIC data */
  70. u8 tx_tuna[10];
  71. u8 rx_tuna[10];
  72. u8 rxbuffer[10];
  73. u8 diseq_flags;
  74. u8 dst_type;
  75. u32 type_flags;
  76. u32 frequency; /* intermediate frequency in kHz for QPSK */
  77. fe_spectral_inversion_t inversion;
  78. u32 symbol_rate; /* symbol rate in Symbols per second */
  79. fe_code_rate_t fec;
  80. fe_sec_voltage_t voltage;
  81. fe_sec_tone_mode_t tone;
  82. u32 decode_freq;
  83. u8 decode_lock;
  84. u16 decode_strength;
  85. u16 decode_snr;
  86. unsigned long cur_jiff;
  87. u8 k22;
  88. fe_bandwidth_t bandwidth;
  89. u32 dst_hw_cap;
  90. u8 dst_fw_version;
  91. fe_sec_mini_cmd_t minicmd;
  92. fe_modulation_t modulation;
  93. u8 messages[256];
  94. u8 mac_address[8];
  95. u8 fw_version[8];
  96. u8 card_info[8];
  97. u8 vendor[8];
  98. u8 board_info[8];
  99. struct mutex dst_mutex;
  100. };
  101. struct dst_types {
  102. char *device_id;
  103. int offset;
  104. u8 dst_type;
  105. u32 type_flags;
  106. u32 dst_feature;
  107. };
  108. struct dst_config
  109. {
  110. /* the ASIC i2c address */
  111. u8 demod_address;
  112. };
  113. int rdc_reset_state(struct dst_state *state);
  114. int rdc_8820_reset(struct dst_state *state);
  115. int dst_wait_dst_ready(struct dst_state *state, u8 delay_mode);
  116. int dst_pio_enable(struct dst_state *state);
  117. int dst_pio_disable(struct dst_state *state);
  118. int dst_error_recovery(struct dst_state* state);
  119. int dst_error_bailout(struct dst_state *state);
  120. int dst_comm_init(struct dst_state* state);
  121. int write_dst(struct dst_state *state, u8 * data, u8 len);
  122. int read_dst(struct dst_state *state, u8 * ret, u8 len);
  123. u8 dst_check_sum(u8 * buf, u32 len);
  124. struct dst_state* dst_attach(struct dst_state* state, struct dvb_adapter *dvb_adapter);
  125. int dst_ca_attach(struct dst_state *state, struct dvb_adapter *dvb_adapter);
  126. int dst_gpio_outb(struct dst_state* state, u32 mask, u32 enbb, u32 outhigh, int delay);
  127. int dst_command(struct dst_state* state, u8 * data, u8 len);
  128. #endif // DST_COMMON_H