stb6100_proc.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 = &fe->ops;
  19. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  20. struct tuner_state state;
  21. int err = 0;
  22. if (tuner_ops->get_state) {
  23. if (frontend_ops->i2c_gate_ctrl)
  24. frontend_ops->i2c_gate_ctrl(fe, 1);
  25. err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  26. if (err < 0) {
  27. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  28. return err;
  29. }
  30. if (frontend_ops->i2c_gate_ctrl)
  31. frontend_ops->i2c_gate_ctrl(fe, 0);
  32. *frequency = state.frequency;
  33. }
  34. return 0;
  35. }
  36. static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
  37. {
  38. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  39. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  40. struct tuner_state state;
  41. int err = 0;
  42. state.frequency = frequency;
  43. if (tuner_ops->set_state) {
  44. if (frontend_ops->i2c_gate_ctrl)
  45. frontend_ops->i2c_gate_ctrl(fe, 1);
  46. err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &state);
  47. if (err < 0) {
  48. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  49. return err;
  50. }
  51. if (frontend_ops->i2c_gate_ctrl)
  52. frontend_ops->i2c_gate_ctrl(fe, 0);
  53. }
  54. return 0;
  55. }
  56. static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
  57. {
  58. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  59. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  60. struct tuner_state state;
  61. int err = 0;
  62. if (tuner_ops->get_state) {
  63. if (frontend_ops->i2c_gate_ctrl)
  64. frontend_ops->i2c_gate_ctrl(fe, 1);
  65. err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
  66. if (err < 0) {
  67. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  68. return err;
  69. }
  70. if (frontend_ops->i2c_gate_ctrl)
  71. frontend_ops->i2c_gate_ctrl(fe, 0);
  72. *bandwidth = state.bandwidth;
  73. }
  74. return 0;
  75. }
  76. static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
  77. {
  78. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  79. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  80. struct tuner_state state;
  81. int err = 0;
  82. state.bandwidth = bandwidth;
  83. if (tuner_ops->set_state) {
  84. if (frontend_ops->i2c_gate_ctrl)
  85. frontend_ops->i2c_gate_ctrl(fe, 1);
  86. err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &state);
  87. if (err < 0) {
  88. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  89. return err;
  90. }
  91. if (frontend_ops->i2c_gate_ctrl)
  92. frontend_ops->i2c_gate_ctrl(fe, 0);
  93. }
  94. return 0;
  95. }