stb6100_proc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. #include <linux/dvb/frontend.h>
  17. #include "dvb_frontend.h"
  18. static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
  19. {
  20. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  21. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  22. int err = 0;
  23. if (tuner_ops->get_frequency) {
  24. if (frontend_ops->i2c_gate_ctrl)
  25. frontend_ops->i2c_gate_ctrl(fe, 1);
  26. err = tuner_ops->get_frequency(fe, frequency);
  27. if (err < 0) {
  28. printk("%s: Invalid parameter\n", __func__);
  29. return err;
  30. }
  31. if (frontend_ops->i2c_gate_ctrl)
  32. frontend_ops->i2c_gate_ctrl(fe, 0);
  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 dtv_frontend_properties *c = &fe->dtv_property_cache;
  41. u32 bw = c->bandwidth_hz;
  42. int err = 0;
  43. c->frequency = frequency;
  44. c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
  45. if (tuner_ops->set_params) {
  46. if (frontend_ops->i2c_gate_ctrl)
  47. frontend_ops->i2c_gate_ctrl(fe, 1);
  48. err = tuner_ops->set_params(fe);
  49. c->bandwidth_hz = bw;
  50. if (err < 0) {
  51. printk("%s: Invalid parameter\n", __func__);
  52. return err;
  53. }
  54. if (frontend_ops->i2c_gate_ctrl)
  55. frontend_ops->i2c_gate_ctrl(fe, 0);
  56. }
  57. return 0;
  58. }
  59. static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
  60. {
  61. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  62. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  63. int err = 0;
  64. if (tuner_ops->get_bandwidth) {
  65. if (frontend_ops->i2c_gate_ctrl)
  66. frontend_ops->i2c_gate_ctrl(fe, 1);
  67. err = tuner_ops->get_bandwidth(fe, bandwidth);
  68. if (err < 0) {
  69. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  70. return err;
  71. }
  72. if (frontend_ops->i2c_gate_ctrl)
  73. frontend_ops->i2c_gate_ctrl(fe, 0);
  74. }
  75. return 0;
  76. }
  77. static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
  78. {
  79. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  80. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  81. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  82. u32 freq = c->frequency;
  83. int err = 0;
  84. c->bandwidth_hz = bandwidth;
  85. c->frequency = 0; /* Don't adjust the frequency */
  86. if (tuner_ops->set_params) {
  87. if (frontend_ops->i2c_gate_ctrl)
  88. frontend_ops->i2c_gate_ctrl(fe, 1);
  89. err = tuner_ops->set_params(fe);
  90. c->frequency = freq;
  91. if (err < 0) {
  92. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  93. return err;
  94. }
  95. if (frontend_ops->i2c_gate_ctrl)
  96. frontend_ops->i2c_gate_ctrl(fe, 0);
  97. }
  98. return 0;
  99. }