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