dvb_dummy_fe.c 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. /*
  2. * Driver for Dummy Frontend
  3. *
  4. * Written by Emard <emard@softhome.net>
  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. *
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
  20. */
  21. #include <linux/module.h>
  22. #include <linux/init.h>
  23. #include <linux/string.h>
  24. #include <linux/slab.h>
  25. #include "dvb_frontend.h"
  26. #include "dvb_dummy_fe.h"
  27. struct dvb_dummy_fe_state {
  28. struct dvb_frontend frontend;
  29. };
  30. static int dvb_dummy_fe_read_status(struct dvb_frontend *fe,
  31. enum fe_status *status)
  32. {
  33. *status = FE_HAS_SIGNAL
  34. | FE_HAS_CARRIER
  35. | FE_HAS_VITERBI
  36. | FE_HAS_SYNC
  37. | FE_HAS_LOCK;
  38. return 0;
  39. }
  40. static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
  41. {
  42. *ber = 0;
  43. return 0;
  44. }
  45. static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
  46. {
  47. *strength = 0;
  48. return 0;
  49. }
  50. static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
  51. {
  52. *snr = 0;
  53. return 0;
  54. }
  55. static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
  56. {
  57. *ucblocks = 0;
  58. return 0;
  59. }
  60. /*
  61. * Only needed if it actually reads something from the hardware
  62. */
  63. static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe)
  64. {
  65. return 0;
  66. }
  67. static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe)
  68. {
  69. if (fe->ops.tuner_ops.set_params) {
  70. fe->ops.tuner_ops.set_params(fe);
  71. if (fe->ops.i2c_gate_ctrl)
  72. fe->ops.i2c_gate_ctrl(fe, 0);
  73. }
  74. return 0;
  75. }
  76. static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
  77. {
  78. return 0;
  79. }
  80. static int dvb_dummy_fe_init(struct dvb_frontend* fe)
  81. {
  82. return 0;
  83. }
  84. static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
  85. enum fe_sec_tone_mode tone)
  86. {
  87. return 0;
  88. }
  89. static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
  90. enum fe_sec_voltage voltage)
  91. {
  92. return 0;
  93. }
  94. static void dvb_dummy_fe_release(struct dvb_frontend* fe)
  95. {
  96. struct dvb_dummy_fe_state* state = fe->demodulator_priv;
  97. kfree(state);
  98. }
  99. static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
  100. struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
  101. {
  102. struct dvb_dummy_fe_state* state = NULL;
  103. /* allocate memory for the internal state */
  104. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  105. if (!state)
  106. return NULL;
  107. /* create dvb_frontend */
  108. memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
  109. state->frontend.demodulator_priv = state;
  110. return &state->frontend;
  111. }
  112. static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
  113. struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
  114. {
  115. struct dvb_dummy_fe_state* state = NULL;
  116. /* allocate memory for the internal state */
  117. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  118. if (!state)
  119. return NULL;
  120. /* create dvb_frontend */
  121. memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
  122. state->frontend.demodulator_priv = state;
  123. return &state->frontend;
  124. }
  125. static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
  126. struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
  127. {
  128. struct dvb_dummy_fe_state* state = NULL;
  129. /* allocate memory for the internal state */
  130. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  131. if (!state)
  132. return NULL;
  133. /* create dvb_frontend */
  134. memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
  135. state->frontend.demodulator_priv = state;
  136. return &state->frontend;
  137. }
  138. static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
  139. .delsys = { SYS_DVBT },
  140. .info = {
  141. .name = "Dummy DVB-T",
  142. .frequency_min = 0,
  143. .frequency_max = 863250000,
  144. .frequency_stepsize = 62500,
  145. .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
  146. FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
  147. FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
  148. FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
  149. FE_CAN_TRANSMISSION_MODE_AUTO |
  150. FE_CAN_GUARD_INTERVAL_AUTO |
  151. FE_CAN_HIERARCHY_AUTO,
  152. },
  153. .release = dvb_dummy_fe_release,
  154. .init = dvb_dummy_fe_init,
  155. .sleep = dvb_dummy_fe_sleep,
  156. .set_frontend = dvb_dummy_fe_set_frontend,
  157. .get_frontend = dvb_dummy_fe_get_frontend,
  158. .read_status = dvb_dummy_fe_read_status,
  159. .read_ber = dvb_dummy_fe_read_ber,
  160. .read_signal_strength = dvb_dummy_fe_read_signal_strength,
  161. .read_snr = dvb_dummy_fe_read_snr,
  162. .read_ucblocks = dvb_dummy_fe_read_ucblocks,
  163. };
  164. static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
  165. .delsys = { SYS_DVBC_ANNEX_A },
  166. .info = {
  167. .name = "Dummy DVB-C",
  168. .frequency_stepsize = 62500,
  169. .frequency_min = 51000000,
  170. .frequency_max = 858000000,
  171. .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
  172. .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
  173. .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
  174. FE_CAN_QAM_128 | FE_CAN_QAM_256 |
  175. FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
  176. },
  177. .release = dvb_dummy_fe_release,
  178. .init = dvb_dummy_fe_init,
  179. .sleep = dvb_dummy_fe_sleep,
  180. .set_frontend = dvb_dummy_fe_set_frontend,
  181. .get_frontend = dvb_dummy_fe_get_frontend,
  182. .read_status = dvb_dummy_fe_read_status,
  183. .read_ber = dvb_dummy_fe_read_ber,
  184. .read_signal_strength = dvb_dummy_fe_read_signal_strength,
  185. .read_snr = dvb_dummy_fe_read_snr,
  186. .read_ucblocks = dvb_dummy_fe_read_ucblocks,
  187. };
  188. static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
  189. .delsys = { SYS_DVBS },
  190. .info = {
  191. .name = "Dummy DVB-S",
  192. .frequency_min = 950000,
  193. .frequency_max = 2150000,
  194. .frequency_stepsize = 250, /* kHz for QPSK frontends */
  195. .frequency_tolerance = 29500,
  196. .symbol_rate_min = 1000000,
  197. .symbol_rate_max = 45000000,
  198. .caps = FE_CAN_INVERSION_AUTO |
  199. FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
  200. FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
  201. FE_CAN_QPSK
  202. },
  203. .release = dvb_dummy_fe_release,
  204. .init = dvb_dummy_fe_init,
  205. .sleep = dvb_dummy_fe_sleep,
  206. .set_frontend = dvb_dummy_fe_set_frontend,
  207. .get_frontend = dvb_dummy_fe_get_frontend,
  208. .read_status = dvb_dummy_fe_read_status,
  209. .read_ber = dvb_dummy_fe_read_ber,
  210. .read_signal_strength = dvb_dummy_fe_read_signal_strength,
  211. .read_snr = dvb_dummy_fe_read_snr,
  212. .read_ucblocks = dvb_dummy_fe_read_ucblocks,
  213. .set_voltage = dvb_dummy_fe_set_voltage,
  214. .set_tone = dvb_dummy_fe_set_tone,
  215. };
  216. MODULE_DESCRIPTION("DVB DUMMY Frontend");
  217. MODULE_AUTHOR("Emard");
  218. MODULE_LICENSE("GPL");
  219. EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
  220. EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
  221. EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);