stb6100_proc.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. STB6100 Silicon Tuner wrapper
  3. Copyright (C)2009 Igor M. Liplianin (liplianin@me.by)
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
  17. {
  18. struct dvb_frontend_ops *frontend_ops = NULL;
  19. struct dvb_tuner_ops *tuner_ops = NULL;
  20. struct tuner_state state;
  21. int err = 0;
  22. if (&fe->ops)
  23. frontend_ops = &fe->ops;
  24. if (&frontend_ops->tuner_ops)
  25. tuner_ops = &frontend_ops->tuner_ops;
  26. if (tuner_ops->get_state) {
  27. if (frontend_ops->i2c_gate_ctrl)
  28. frontend_ops->i2c_gate_ctrl(fe, 1);
  29. err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  30. if (err < 0) {
  31. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  32. return err;
  33. }
  34. if (frontend_ops->i2c_gate_ctrl)
  35. frontend_ops->i2c_gate_ctrl(fe, 0);
  36. *frequency = state.frequency;
  37. }
  38. return 0;
  39. }
  40. static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
  41. {
  42. struct dvb_frontend_ops *frontend_ops = NULL;
  43. struct dvb_tuner_ops *tuner_ops = NULL;
  44. struct tuner_state state;
  45. int err = 0;
  46. state.frequency = frequency;
  47. if (&fe->ops)
  48. frontend_ops = &fe->ops;
  49. if (&frontend_ops->tuner_ops)
  50. tuner_ops = &frontend_ops->tuner_ops;
  51. if (tuner_ops->set_state) {
  52. if (frontend_ops->i2c_gate_ctrl)
  53. frontend_ops->i2c_gate_ctrl(fe, 1);
  54. err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  55. if (err < 0) {
  56. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  57. return err;
  58. }
  59. if (frontend_ops->i2c_gate_ctrl)
  60. frontend_ops->i2c_gate_ctrl(fe, 0);
  61. }
  62. return 0;
  63. }
  64. static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
  65. {
  66. struct dvb_frontend_ops *frontend_ops = NULL;
  67. struct dvb_tuner_ops *tuner_ops = NULL;
  68. struct tuner_state state;
  69. int err = 0;
  70. if (&fe->ops)
  71. frontend_ops = &fe->ops;
  72. if (&frontend_ops->tuner_ops)
  73. tuner_ops = &frontend_ops->tuner_ops;
  74. if (tuner_ops->get_state) {
  75. if (frontend_ops->i2c_gate_ctrl)
  76. frontend_ops->i2c_gate_ctrl(fe, 1);
  77. err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
  78. if (err < 0) {
  79. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  80. return err;
  81. }
  82. if (frontend_ops->i2c_gate_ctrl)
  83. frontend_ops->i2c_gate_ctrl(fe, 0);
  84. *bandwidth = state.bandwidth;
  85. }
  86. return 0;
  87. }
  88. static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
  89. {
  90. struct dvb_frontend_ops *frontend_ops = NULL;
  91. struct dvb_tuner_ops *tuner_ops = NULL;
  92. struct tuner_state state;
  93. int err = 0;
  94. state.bandwidth = bandwidth;
  95. if (&fe->ops)
  96. frontend_ops = &fe->ops;
  97. if (&frontend_ops->tuner_ops)
  98. tuner_ops = &frontend_ops->tuner_ops;
  99. if (tuner_ops->set_state) {
  100. if (frontend_ops->i2c_gate_ctrl)
  101. frontend_ops->i2c_gate_ctrl(fe, 1);
  102. err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
  103. if (err < 0) {
  104. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  105. return err;
  106. }
  107. if (frontend_ops->i2c_gate_ctrl)
  108. frontend_ops->i2c_gate_ctrl(fe, 0);
  109. }
  110. return 0;
  111. }