dtv5100-fe.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * DVB USB Linux driver for AME DTV-5100 USB2.0 DVB-T
  3. *
  4. * Copyright (C) 2008 Antoine Jacquet <royale@zerezo.com>
  5. * http://royale.zerezo.com/dtv5100/
  6. *
  7. * Inspired by dvb_dummy_fe.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. */
  23. #include "dvb-usb.h"
  24. #include "qt1010_priv.h"
  25. struct dtv5100_fe_state {
  26. struct dvb_frontend frontend;
  27. };
  28. static int dtv5100_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
  29. {
  30. *status = FE_HAS_SIGNAL
  31. | FE_HAS_CARRIER
  32. | FE_HAS_VITERBI
  33. | FE_HAS_SYNC
  34. | FE_HAS_LOCK;
  35. return 0;
  36. }
  37. static int dtv5100_fe_read_ber(struct dvb_frontend* fe, u32* ber)
  38. {
  39. *ber = 0;
  40. return 0;
  41. }
  42. static int dtv5100_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
  43. {
  44. *strength = 0;
  45. return 0;
  46. }
  47. static int dtv5100_fe_read_snr(struct dvb_frontend* fe, u16* snr)
  48. {
  49. *snr = 0;
  50. return 0;
  51. }
  52. static int dtv5100_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
  53. {
  54. *ucblocks = 0;
  55. return 0;
  56. }
  57. static int dtv5100_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
  58. {
  59. return 0;
  60. }
  61. static int dtv5100_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
  62. {
  63. if (fe->ops.tuner_ops.set_params) {
  64. fe->ops.tuner_ops.set_params(fe, p);
  65. if (fe->ops.i2c_gate_ctrl) fe->ops.i2c_gate_ctrl(fe, 0);
  66. }
  67. return 0;
  68. }
  69. static int dtv5100_fe_sleep(struct dvb_frontend* fe)
  70. {
  71. return 0;
  72. }
  73. static int dtv5100_fe_init(struct dvb_frontend* fe)
  74. {
  75. return 0;
  76. }
  77. static void dtv5100_fe_release(struct dvb_frontend* fe)
  78. {
  79. struct dtv5100_fe_state* state = fe->demodulator_priv;
  80. kfree(state);
  81. }
  82. static struct dvb_frontend_ops dtv5100_fe_ops;
  83. struct dvb_frontend* dtv5100_fe_attach(void)
  84. {
  85. struct dtv5100_fe_state* state = NULL;
  86. /* allocate memory for the internal state */
  87. state = kmalloc(sizeof(struct dtv5100_fe_state), GFP_KERNEL);
  88. if (state == NULL) goto error;
  89. /* create dvb_frontend */
  90. memcpy(&state->frontend.ops, &dtv5100_fe_ops, sizeof(struct dvb_frontend_ops));
  91. state->frontend.demodulator_priv = state;
  92. return &state->frontend;
  93. error:
  94. kfree(state);
  95. return NULL;
  96. }
  97. static struct dvb_frontend_ops dtv5100_fe_ops = {
  98. .info = {
  99. .name = "Dummy DVB-T",
  100. .type = FE_OFDM,
  101. .frequency_min = QT1010_MIN_FREQ,
  102. .frequency_max = QT1010_MAX_FREQ,
  103. .frequency_stepsize = QT1010_STEP,
  104. .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
  105. FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
  106. FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
  107. FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
  108. FE_CAN_TRANSMISSION_MODE_AUTO |
  109. FE_CAN_GUARD_INTERVAL_AUTO |
  110. FE_CAN_HIERARCHY_AUTO,
  111. },
  112. .release = dtv5100_fe_release,
  113. .init = dtv5100_fe_init,
  114. .sleep = dtv5100_fe_sleep,
  115. .set_frontend = dtv5100_fe_set_frontend,
  116. .get_frontend = dtv5100_fe_get_frontend,
  117. .read_status = dtv5100_fe_read_status,
  118. .read_ber = dtv5100_fe_read_ber,
  119. .read_signal_strength = dtv5100_fe_read_signal_strength,
  120. .read_snr = dtv5100_fe_read_snr,
  121. .read_ucblocks = dtv5100_fe_read_ucblocks,
  122. };