dvb_dummy_fe.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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, fe_status_t* status)
  31. {
  32. *status = FE_HAS_SIGNAL
  33. | FE_HAS_CARRIER
  34. | FE_HAS_VITERBI
  35. | FE_HAS_SYNC
  36. | FE_HAS_LOCK;
  37. return 0;
  38. }
  39. static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
  40. {
  41. *ber = 0;
  42. return 0;
  43. }
  44. static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
  45. {
  46. *strength = 0;
  47. return 0;
  48. }
  49. static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
  50. {
  51. *snr = 0;
  52. return 0;
  53. }
  54. static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
  55. {
  56. *ucblocks = 0;
  57. return 0;
  58. }
  59. static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
  60. {
  61. return 0;
  62. }
  63. static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
  64. {
  65. if (fe->ops.tuner_ops.set_params) {
  66. fe->ops.tuner_ops.set_params(fe, p);
  67. if (fe->ops.i2c_gate_ctrl)
  68. fe->ops.i2c_gate_ctrl(fe, 0);
  69. }
  70. return 0;
  71. }
  72. static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
  73. {
  74. return 0;
  75. }
  76. static int dvb_dummy_fe_init(struct dvb_frontend* fe)
  77. {
  78. return 0;
  79. }
  80. static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
  81. {
  82. return 0;
  83. }
  84. static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
  85. {
  86. return 0;
  87. }
  88. static void dvb_dummy_fe_release(struct dvb_frontend* fe)
  89. {
  90. struct dvb_dummy_fe_state* state = fe->demodulator_priv;
  91. kfree(state);
  92. }
  93. static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
  94. struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
  95. {
  96. struct dvb_dummy_fe_state* state = NULL;
  97. /* allocate memory for the internal state */
  98. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  99. if (state == NULL) goto error;
  100. /* create dvb_frontend */
  101. memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
  102. state->frontend.demodulator_priv = state;
  103. return &state->frontend;
  104. error:
  105. kfree(state);
  106. return NULL;
  107. }
  108. static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
  109. struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
  110. {
  111. struct dvb_dummy_fe_state* state = NULL;
  112. /* allocate memory for the internal state */
  113. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  114. if (state == NULL) goto error;
  115. /* create dvb_frontend */
  116. memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
  117. state->frontend.demodulator_priv = state;
  118. return &state->frontend;
  119. error:
  120. kfree(state);
  121. return NULL;
  122. }
  123. static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
  124. struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
  125. {
  126. struct dvb_dummy_fe_state* state = NULL;
  127. /* allocate memory for the internal state */
  128. state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
  129. if (state == NULL) goto error;
  130. /* create dvb_frontend */
  131. memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
  132. state->frontend.demodulator_priv = state;
  133. return &state->frontend;
  134. error:
  135. kfree(state);
  136. return NULL;
  137. }
  138. static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
  139. .info = {
  140. .name = "Dummy DVB-T",
  141. .type = FE_OFDM,
  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. .info = {
  166. .name = "Dummy DVB-C",
  167. .type = FE_QAM,
  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. .info = {
  190. .name = "Dummy DVB-S",
  191. .type = FE_QPSK,
  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);