dvb_frontend.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. /*
  2. * dvb_frontend.h
  3. *
  4. * Copyright (C) 2001 convergence integrated media GmbH
  5. * Copyright (C) 2004 convergence GmbH
  6. *
  7. * Written by Ralph Metzler
  8. * Overhauled by Holger Waechtler
  9. * Kernel I2C stuff by Michael Hunold <hunold@convergence.de>
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public License
  13. * as published by the Free Software Foundation; either version 2.1
  14. * of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  24. *
  25. */
  26. #ifndef _DVB_FRONTEND_H_
  27. #define _DVB_FRONTEND_H_
  28. #include <linux/types.h>
  29. #include <linux/sched.h>
  30. #include <linux/ioctl.h>
  31. #include <linux/i2c.h>
  32. #include <linux/module.h>
  33. #include <linux/errno.h>
  34. #include <linux/delay.h>
  35. #include <linux/mutex.h>
  36. #include <linux/dvb/frontend.h>
  37. #include "dvbdev.h"
  38. struct dvb_frontend_tune_settings {
  39. int min_delay_ms;
  40. int step_size;
  41. int max_drift;
  42. struct dvb_frontend_parameters parameters;
  43. };
  44. struct dvb_frontend;
  45. struct dvb_tuner_info {
  46. char name[128];
  47. u32 frequency_min;
  48. u32 frequency_max;
  49. u32 frequency_step;
  50. u32 bandwidth_min;
  51. u32 bandwidth_max;
  52. u32 bandwidth_step;
  53. };
  54. struct analog_parameters {
  55. unsigned int frequency;
  56. unsigned int mode;
  57. unsigned int audmode;
  58. u64 std;
  59. };
  60. struct dvb_tuner_ops {
  61. struct dvb_tuner_info info;
  62. int (*release)(struct dvb_frontend *fe);
  63. int (*init)(struct dvb_frontend *fe);
  64. int (*sleep)(struct dvb_frontend *fe);
  65. /** This is for simple PLLs - set all parameters in one go. */
  66. int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
  67. int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
  68. /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
  69. int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
  70. /** This is to allow setting tuner-specific configs */
  71. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  72. int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
  73. int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
  74. #define TUNER_STATUS_LOCKED 1
  75. #define TUNER_STATUS_STEREO 2
  76. int (*get_status)(struct dvb_frontend *fe, u32 *status);
  77. int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
  78. /** These are provided seperately from set_params in order to facilitate silicon
  79. * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
  80. int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
  81. int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
  82. };
  83. struct analog_demod_info {
  84. char *name;
  85. };
  86. struct analog_demod_ops {
  87. struct analog_demod_info info;
  88. void (*set_params)(struct dvb_frontend *fe,
  89. struct analog_parameters *params);
  90. int (*has_signal)(struct dvb_frontend *fe);
  91. int (*is_stereo)(struct dvb_frontend *fe);
  92. int (*get_afc)(struct dvb_frontend *fe);
  93. void (*tuner_status)(struct dvb_frontend *fe);
  94. void (*standby)(struct dvb_frontend *fe);
  95. void (*release)(struct dvb_frontend *fe);
  96. int (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
  97. /** This is to allow setting tuner-specific configuration */
  98. int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
  99. };
  100. struct dvb_frontend_ops {
  101. struct dvb_frontend_info info;
  102. void (*release)(struct dvb_frontend* fe);
  103. void (*release_sec)(struct dvb_frontend* fe);
  104. int (*init)(struct dvb_frontend* fe);
  105. int (*sleep)(struct dvb_frontend* fe);
  106. int (*write)(struct dvb_frontend* fe, u8* buf, int len);
  107. /* if this is set, it overrides the default swzigzag */
  108. int (*tune)(struct dvb_frontend* fe,
  109. struct dvb_frontend_parameters* params,
  110. unsigned int mode_flags,
  111. unsigned int *delay,
  112. fe_status_t *status);
  113. /* get frontend tuning algorithm from the module */
  114. int (*get_frontend_algo)(struct dvb_frontend *fe);
  115. /* these two are only used for the swzigzag code */
  116. int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
  117. int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
  118. int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
  119. int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
  120. int (*read_ber)(struct dvb_frontend* fe, u32* ber);
  121. int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
  122. int (*read_snr)(struct dvb_frontend* fe, u16* snr);
  123. int (*read_ucblocks)(struct dvb_frontend* fe, u32* ucblocks);
  124. int (*diseqc_reset_overload)(struct dvb_frontend* fe);
  125. int (*diseqc_send_master_cmd)(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd* cmd);
  126. int (*diseqc_recv_slave_reply)(struct dvb_frontend* fe, struct dvb_diseqc_slave_reply* reply);
  127. int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
  128. int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
  129. int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
  130. int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
  131. int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
  132. int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
  133. int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
  134. struct dvb_tuner_ops tuner_ops;
  135. struct analog_demod_ops analog_ops;
  136. int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  137. int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
  138. };
  139. #define MAX_EVENT 8
  140. struct dvb_fe_events {
  141. struct dvb_frontend_event events[MAX_EVENT];
  142. int eventw;
  143. int eventr;
  144. int overflow;
  145. wait_queue_head_t wait_queue;
  146. struct mutex mtx;
  147. };
  148. struct dtv_frontend_properties {
  149. /* Cache State */
  150. u32 state;
  151. u32 frequency;
  152. fe_modulation_t modulation;
  153. fe_sec_voltage_t voltage;
  154. fe_sec_tone_mode_t sectone;
  155. fe_spectral_inversion_t inversion;
  156. fe_code_rate_t fec_inner;
  157. fe_transmit_mode_t transmission_mode;
  158. u32 bandwidth_hz; /* 0 = AUTO */
  159. fe_guard_interval_t guard_interval;
  160. fe_hierarchy_t hierarchy;
  161. u32 symbol_rate;
  162. fe_code_rate_t code_rate_HP;
  163. fe_code_rate_t code_rate_LP;
  164. fe_pilot_t pilot;
  165. fe_rolloff_t rolloff;
  166. fe_delivery_system_t delivery_system;
  167. };
  168. struct dvb_frontend {
  169. struct dvb_frontend_ops ops;
  170. struct dvb_adapter *dvb;
  171. void *demodulator_priv;
  172. void *tuner_priv;
  173. void *frontend_priv;
  174. void *sec_priv;
  175. void *analog_demod_priv;
  176. struct dtv_frontend_properties dtv_property_cache;
  177. #define DVB_FRONTEND_COMPONENT_TUNER 0
  178. int (*callback)(void *adapter_priv, int component, int cmd, int arg);
  179. int id;
  180. };
  181. extern int dvb_register_frontend(struct dvb_adapter *dvb,
  182. struct dvb_frontend *fe);
  183. extern int dvb_unregister_frontend(struct dvb_frontend *fe);
  184. extern void dvb_frontend_detach(struct dvb_frontend *fe);
  185. extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
  186. extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
  187. extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
  188. #endif