1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 STB6100 Silicon Tuner wrapper
8 #include <linux/dvb/frontend.h>
9 #include <media/dvb_frontend.h>
11 static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
13 struct dvb_frontend_ops *frontend_ops = &fe->ops;
14 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
17 if (tuner_ops->get_frequency) {
18 if (frontend_ops->i2c_gate_ctrl)
19 frontend_ops->i2c_gate_ctrl(fe, 1);
21 err = tuner_ops->get_frequency(fe, frequency);
23 printk("%s: Invalid parameter\n", __func__);
27 if (frontend_ops->i2c_gate_ctrl)
28 frontend_ops->i2c_gate_ctrl(fe, 0);
34 static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
36 struct dvb_frontend_ops *frontend_ops = &fe->ops;
37 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
38 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
39 u32 bw = c->bandwidth_hz;
42 c->frequency = frequency;
43 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);
49 err = tuner_ops->set_params(fe);
52 printk("%s: Invalid parameter\n", __func__);
56 if (frontend_ops->i2c_gate_ctrl)
57 frontend_ops->i2c_gate_ctrl(fe, 0);
64 static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
66 struct dvb_frontend_ops *frontend_ops = &fe->ops;
67 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
70 if (tuner_ops->get_bandwidth) {
71 if (frontend_ops->i2c_gate_ctrl)
72 frontend_ops->i2c_gate_ctrl(fe, 1);
74 err = tuner_ops->get_bandwidth(fe, bandwidth);
76 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
80 if (frontend_ops->i2c_gate_ctrl)
81 frontend_ops->i2c_gate_ctrl(fe, 0);
87 static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
89 struct dvb_frontend_ops *frontend_ops = &fe->ops;
90 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
91 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
92 u32 freq = c->frequency;
95 c->bandwidth_hz = bandwidth;
96 c->frequency = 0; /* Don't adjust the frequency */
98 if (tuner_ops->set_params) {
99 if (frontend_ops->i2c_gate_ctrl)
100 frontend_ops->i2c_gate_ctrl(fe, 1);
102 err = tuner_ops->set_params(fe);
105 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
109 if (frontend_ops->i2c_gate_ctrl)
110 frontend_ops->i2c_gate_ctrl(fe, 0);