1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/dvb/frontend.h>
21#include <media/dvb_frontend.h>
22
23static int stb6100_get_freq(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 int err = 0;
28
29 if (tuner_ops->get_frequency) {
30 if (frontend_ops->i2c_gate_ctrl)
31 frontend_ops->i2c_gate_ctrl(fe, 1);
32
33 err = tuner_ops->get_frequency(fe, frequency);
34 if (err < 0) {
35 printk("%s: Invalid parameter\n", __func__);
36 return err;
37 }
38
39 if (frontend_ops->i2c_gate_ctrl)
40 frontend_ops->i2c_gate_ctrl(fe, 0);
41 }
42
43 return 0;
44}
45
46static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
47{
48 struct dvb_frontend_ops *frontend_ops = &fe->ops;
49 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
50 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
51 u32 bw = c->bandwidth_hz;
52 int err = 0;
53
54 c->frequency = frequency;
55 c->bandwidth_hz = 0;
56
57 if (tuner_ops->set_params) {
58 if (frontend_ops->i2c_gate_ctrl)
59 frontend_ops->i2c_gate_ctrl(fe, 1);
60
61 err = tuner_ops->set_params(fe);
62 c->bandwidth_hz = bw;
63 if (err < 0) {
64 printk("%s: Invalid parameter\n", __func__);
65 return err;
66 }
67
68 if (frontend_ops->i2c_gate_ctrl)
69 frontend_ops->i2c_gate_ctrl(fe, 0);
70
71 }
72
73 return 0;
74}
75
76static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
77{
78 struct dvb_frontend_ops *frontend_ops = &fe->ops;
79 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
80 int err = 0;
81
82 if (tuner_ops->get_bandwidth) {
83 if (frontend_ops->i2c_gate_ctrl)
84 frontend_ops->i2c_gate_ctrl(fe, 1);
85
86 err = tuner_ops->get_bandwidth(fe, bandwidth);
87 if (err < 0) {
88 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
89 return err;
90 }
91
92 if (frontend_ops->i2c_gate_ctrl)
93 frontend_ops->i2c_gate_ctrl(fe, 0);
94 }
95
96 return 0;
97}
98
99static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
100{
101 struct dvb_frontend_ops *frontend_ops = &fe->ops;
102 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
103 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
104 u32 freq = c->frequency;
105 int err = 0;
106
107 c->bandwidth_hz = bandwidth;
108 c->frequency = 0;
109
110 if (tuner_ops->set_params) {
111 if (frontend_ops->i2c_gate_ctrl)
112 frontend_ops->i2c_gate_ctrl(fe, 1);
113
114 err = tuner_ops->set_params(fe);
115 c->frequency = freq;
116 if (err < 0) {
117 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
118 return err;
119 }
120
121 if (frontend_ops->i2c_gate_ctrl)
122 frontend_ops->i2c_gate_ctrl(fe, 0);
123
124 }
125
126 return 0;
127}
128