stb6100_cfg.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. STB6100 Silicon Tuner
  4. Copyright (C) Manu Abraham (abraham.manu@gmail.com)
  5. Copyright (C) ST Microelectronics
  6. */
  7. #include <linux/dvb/frontend.h>
  8. #include <media/dvb_frontend.h>
  9. static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
  10. {
  11. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  12. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  13. int err = 0;
  14. if (tuner_ops->get_frequency) {
  15. err = tuner_ops->get_frequency(fe, frequency);
  16. if (err < 0) {
  17. printk("%s: Invalid parameter\n", __func__);
  18. return err;
  19. }
  20. }
  21. return 0;
  22. }
  23. static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
  24. {
  25. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  26. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  27. struct dtv_frontend_properties *c = &fe->dtv_property_cache;
  28. u32 bw = c->bandwidth_hz;
  29. int err = 0;
  30. c->frequency = frequency;
  31. c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
  32. if (tuner_ops->set_params) {
  33. err = tuner_ops->set_params(fe);
  34. c->bandwidth_hz = bw;
  35. if (err < 0) {
  36. printk("%s: Invalid parameter\n", __func__);
  37. return err;
  38. }
  39. }
  40. return 0;
  41. }
  42. static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
  43. {
  44. struct dvb_frontend_ops *frontend_ops = &fe->ops;
  45. struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
  46. int err = 0;
  47. if (tuner_ops->get_bandwidth) {
  48. err = tuner_ops->get_bandwidth(fe, bandwidth);
  49. if (err < 0) {
  50. printk("%s: Invalid parameter\n", __func__);
  51. return err;
  52. }
  53. }
  54. return 0;
  55. }
  56. static int stb6100_set_bandwidth(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 dtv_frontend_properties *c = &fe->dtv_property_cache;
  61. u32 freq = c->frequency;
  62. int err = 0;
  63. c->bandwidth_hz = bandwidth;
  64. c->frequency = 0; /* Don't adjust the frequency */
  65. if (tuner_ops->set_params) {
  66. err = tuner_ops->set_params(fe);
  67. c->frequency = freq;
  68. if (err < 0) {
  69. printk("%s: Invalid parameter\n", __func__);
  70. return err;
  71. }
  72. }
  73. return 0;
  74. }