stb6100_proc.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. STB6100 Silicon Tuner wrapper
  4. Copyright (C)2009 Igor M. Liplianin (liplianin@me.by)
  5. */
  6. #include <linux/dvb/frontend.h>
  7. #include <media/dvb_frontend.h>
  8. static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
  9. {
  10. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  11. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  12. int err = 0;
  13. if (tuner_ops->get_frequency) {
  14. if (frontend_ops->i2c_gate_ctrl)
  15. frontend_ops->i2c_gate_ctrl(fe, 1);
  16. err = tuner_ops->get_frequency(fe, frequency);
  17. if (err < 0) {
  18. printk("%s: Invalid parameter\n", __func__);
  19. return err;
  20. }
  21. if (frontend_ops->i2c_gate_ctrl)
  22. frontend_ops->i2c_gate_ctrl(fe, 0);
  23. }
  24. return 0;
  25. }
  26. static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
  27. {
  28. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  29. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  30. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  31. u32 bw = c->bandwidth_hz;
  32. int err = 0;
  33. c->frequency = frequency;
  34. c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
  35. if (tuner_ops->set_params) {
  36. if (frontend_ops->i2c_gate_ctrl)
  37. frontend_ops->i2c_gate_ctrl(fe, 1);
  38. err = tuner_ops->set_params(fe);
  39. c->bandwidth_hz = bw;
  40. if (err < 0) {
  41. printk("%s: Invalid parameter\n", __func__);
  42. return err;
  43. }
  44. if (frontend_ops->i2c_gate_ctrl)
  45. frontend_ops->i2c_gate_ctrl(fe, 0);
  46. }
  47. return 0;
  48. }
  49. static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
  50. {
  51. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  52. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  53. int err = 0;
  54. if (tuner_ops->get_bandwidth) {
  55. if (frontend_ops->i2c_gate_ctrl)
  56. frontend_ops->i2c_gate_ctrl(fe, 1);
  57. err = tuner_ops->get_bandwidth(fe, bandwidth);
  58. if (err < 0) {
  59. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  60. return err;
  61. }
  62. if (frontend_ops->i2c_gate_ctrl)
  63. frontend_ops->i2c_gate_ctrl(fe, 0);
  64. }
  65. return 0;
  66. }
  67. static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
  68. {
  69. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  70. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  71. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  72. u32 freq = c->frequency;
  73. int err = 0;
  74. c->bandwidth_hz = bandwidth;
  75. c->frequency = 0; /* Don't adjust the frequency */
  76. if (tuner_ops->set_params) {
  77. if (frontend_ops->i2c_gate_ctrl)
  78. frontend_ops->i2c_gate_ctrl(fe, 1);
  79. err = tuner_ops->set_params(fe);
  80. c->frequency = freq;
  81. if (err < 0) {
  82. printk(KERN_ERR "%s: Invalid parameter\n", __func__);
  83. return err;
  84. }
  85. if (frontend_ops->i2c_gate_ctrl)
  86. frontend_ops->i2c_gate_ctrl(fe, 0);
  87. }
  88. return 0;
  89. }