aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/dvb-frontends/stb6100.c46
-rw-r--r--drivers/media/dvb-frontends/stb6100_cfg.h37
-rw-r--r--drivers/media/dvb-frontends/stb6100_proc.h43
3 files changed, 54 insertions, 72 deletions
diff --git a/drivers/media/dvb-frontends/stb6100.c b/drivers/media/dvb-frontends/stb6100.c
index 5d8dbde03249..c978c801c7aa 100644
--- a/drivers/media/dvb-frontends/stb6100.c
+++ b/drivers/media/dvb-frontends/stb6100.c
@@ -502,49 +502,22 @@ static int stb6100_init(struct dvb_frontend *fe)
502 * iqsense = 1 502 * iqsense = 1
503 * tunerstep = 125000 503 * tunerstep = 125000
504 */ 504 */
505 state->bandwidth = 36000000; /* Hz */ 505 state->bandwidth = 36000000; /* Hz */
506 state->reference = refclk / 1000; /* kHz */ 506 state->reference = refclk / 1000; /* kHz */
507 507
508 /* Set default bandwidth. Modified, PN 13-May-10 */ 508 /* Set default bandwidth. Modified, PN 13-May-10 */
509 return 0; 509 return 0;
510} 510}
511 511
512static int stb6100_get_state(struct dvb_frontend *fe, 512static int stb6100_set_params(struct dvb_frontend *fe)
513 enum tuner_param param,
514 struct tuner_state *state)
515{ 513{
516 switch (param) { 514 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
517 case DVBFE_TUNER_FREQUENCY:
518 stb6100_get_frequency(fe, &state->frequency);
519 break;
520 case DVBFE_TUNER_BANDWIDTH:
521 stb6100_get_bandwidth(fe, &state->bandwidth);
522 break;
523 default:
524 break;
525 }
526 515
527 return 0; 516 if (c->frequency > 0)
528} 517 stb6100_set_frequency(fe, c->frequency);
529 518
530static int stb6100_set_state(struct dvb_frontend *fe, 519 if (c->bandwidth_hz > 0)
531 enum tuner_param param, 520 stb6100_set_bandwidth(fe, c->bandwidth_hz);
532 struct tuner_state *state)
533{
534 struct stb6100_state *tstate = fe->tuner_priv;
535
536 switch (param) {
537 case DVBFE_TUNER_FREQUENCY:
538 stb6100_set_frequency(fe, state->frequency);
539 tstate->frequency = state->frequency;
540 break;
541 case DVBFE_TUNER_BANDWIDTH:
542 stb6100_set_bandwidth(fe, state->bandwidth);
543 tstate->bandwidth = state->bandwidth;
544 break;
545 default:
546 break;
547 }
548 521
549 return 0; 522 return 0;
550} 523}
@@ -560,8 +533,9 @@ static struct dvb_tuner_ops stb6100_ops = {
560 .init = stb6100_init, 533 .init = stb6100_init,
561 .sleep = stb6100_sleep, 534 .sleep = stb6100_sleep,
562 .get_status = stb6100_get_status, 535 .get_status = stb6100_get_status,
563 .get_state = stb6100_get_state, 536 .set_params = stb6100_set_params,
564 .set_state = stb6100_set_state, 537 .get_frequency = stb6100_get_frequency,
538 .get_bandwidth = stb6100_get_bandwidth,
565 .release = stb6100_release 539 .release = stb6100_release
566}; 540};
567 541
diff --git a/drivers/media/dvb-frontends/stb6100_cfg.h b/drivers/media/dvb-frontends/stb6100_cfg.h
index 6edc15365847..2ef67aa768b9 100644
--- a/drivers/media/dvb-frontends/stb6100_cfg.h
+++ b/drivers/media/dvb-frontends/stb6100_cfg.h
@@ -19,20 +19,21 @@
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#include <linux/dvb/frontend.h>
23#include "dvb_frontend.h"
24
22static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency) 25static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
23{ 26{
24 struct dvb_frontend_ops *frontend_ops = &fe->ops; 27 struct dvb_frontend_ops *frontend_ops = &fe->ops;
25 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 28 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
26 struct tuner_state t_state;
27 int err = 0; 29 int err = 0;
28 30
29 if (tuner_ops->get_state) { 31 if (tuner_ops->get_frequency) {
30 err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &t_state); 32 err = tuner_ops->get_frequency(fe, frequency);
31 if (err < 0) { 33 if (err < 0) {
32 printk("%s: Invalid parameter\n", __func__); 34 printk("%s: Invalid parameter\n", __func__);
33 return err; 35 return err;
34 } 36 }
35 *frequency = t_state.frequency;
36 } 37 }
37 return 0; 38 return 0;
38} 39}
@@ -41,13 +42,16 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
41{ 42{
42 struct dvb_frontend_ops *frontend_ops = &fe->ops; 43 struct dvb_frontend_ops *frontend_ops = &fe->ops;
43 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 44 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
44 struct tuner_state t_state; 45 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
46 u32 bw = c->bandwidth_hz;
45 int err = 0; 47 int err = 0;
46 48
47 t_state.frequency = frequency; 49 c->frequency = frequency;
50 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
48 51
49 if (tuner_ops->set_state) { 52 if (tuner_ops->set_params) {
50 err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &t_state); 53 err = tuner_ops->set_params(fe);
54 c->bandwidth_hz = bw;
51 if (err < 0) { 55 if (err < 0) {
52 printk("%s: Invalid parameter\n", __func__); 56 printk("%s: Invalid parameter\n", __func__);
53 return err; 57 return err;
@@ -60,16 +64,14 @@ static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
60{ 64{
61 struct dvb_frontend_ops *frontend_ops = &fe->ops; 65 struct dvb_frontend_ops *frontend_ops = &fe->ops;
62 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 66 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
63 struct tuner_state t_state;
64 int err = 0; 67 int err = 0;
65 68
66 if (tuner_ops->get_state) { 69 if (tuner_ops->get_bandwidth) {
67 err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state); 70 err = tuner_ops->get_bandwidth(fe, bandwidth);
68 if (err < 0) { 71 if (err < 0) {
69 printk("%s: Invalid parameter\n", __func__); 72 printk("%s: Invalid parameter\n", __func__);
70 return err; 73 return err;
71 } 74 }
72 *bandwidth = t_state.bandwidth;
73 } 75 }
74 return 0; 76 return 0;
75} 77}
@@ -78,13 +80,16 @@ static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
78{ 80{
79 struct dvb_frontend_ops *frontend_ops = &fe->ops; 81 struct dvb_frontend_ops *frontend_ops = &fe->ops;
80 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 82 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
81 struct tuner_state t_state; 83 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
84 u32 freq = c->frequency;
82 int err = 0; 85 int err = 0;
83 86
84 t_state.bandwidth = bandwidth; 87 c->bandwidth_hz = bandwidth;
88 c->frequency = 0; /* Don't adjust the frequency */
85 89
86 if (tuner_ops->set_state) { 90 if (tuner_ops->set_params) {
87 err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state); 91 err = tuner_ops->set_params(fe);
92 c->frequency = freq;
88 if (err < 0) { 93 if (err < 0) {
89 printk("%s: Invalid parameter\n", __func__); 94 printk("%s: Invalid parameter\n", __func__);
90 return err; 95 return err;
diff --git a/drivers/media/dvb-frontends/stb6100_proc.h b/drivers/media/dvb-frontends/stb6100_proc.h
index bd8a0ec9e2cc..50ffa21e3871 100644
--- a/drivers/media/dvb-frontends/stb6100_proc.h
+++ b/drivers/media/dvb-frontends/stb6100_proc.h
@@ -17,27 +17,27 @@
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18*/ 18*/
19 19
20#include <linux/dvb/frontend.h>
21#include "dvb_frontend.h"
22
20static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency) 23static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
21{ 24{
22 struct dvb_frontend_ops *frontend_ops = &fe->ops; 25 struct dvb_frontend_ops *frontend_ops = &fe->ops;
23 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 26 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
24 struct tuner_state state;
25 int err = 0; 27 int err = 0;
26 28
27 if (tuner_ops->get_state) { 29 if (tuner_ops->get_frequency) {
28 if (frontend_ops->i2c_gate_ctrl) 30 if (frontend_ops->i2c_gate_ctrl)
29 frontend_ops->i2c_gate_ctrl(fe, 1); 31 frontend_ops->i2c_gate_ctrl(fe, 1);
30 32
31 err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &state); 33 err = tuner_ops->get_frequency(fe, frequency);
32 if (err < 0) { 34 if (err < 0) {
33 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 35 printk("%s: Invalid parameter\n", __func__);
34 return err; 36 return err;
35 } 37 }
36 38
37 if (frontend_ops->i2c_gate_ctrl) 39 if (frontend_ops->i2c_gate_ctrl)
38 frontend_ops->i2c_gate_ctrl(fe, 0); 40 frontend_ops->i2c_gate_ctrl(fe, 0);
39
40 *frequency = state.frequency;
41 } 41 }
42 42
43 return 0; 43 return 0;
@@ -47,18 +47,21 @@ static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
47{ 47{
48 struct dvb_frontend_ops *frontend_ops = &fe->ops; 48 struct dvb_frontend_ops *frontend_ops = &fe->ops;
49 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 49 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
50 struct tuner_state state; 50 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
51 u32 bw = c->bandwidth_hz;
51 int err = 0; 52 int err = 0;
52 53
53 state.frequency = frequency; 54 c->frequency = frequency;
55 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
54 56
55 if (tuner_ops->set_state) { 57 if (tuner_ops->set_params) {
56 if (frontend_ops->i2c_gate_ctrl) 58 if (frontend_ops->i2c_gate_ctrl)
57 frontend_ops->i2c_gate_ctrl(fe, 1); 59 frontend_ops->i2c_gate_ctrl(fe, 1);
58 60
59 err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &state); 61 err = tuner_ops->set_params(fe);
62 c->bandwidth_hz = bw;
60 if (err < 0) { 63 if (err < 0) {
61 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 64 printk("%s: Invalid parameter\n", __func__);
62 return err; 65 return err;
63 } 66 }
64 67
@@ -74,14 +77,13 @@ static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
74{ 77{
75 struct dvb_frontend_ops *frontend_ops = &fe->ops; 78 struct dvb_frontend_ops *frontend_ops = &fe->ops;
76 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 79 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
77 struct tuner_state state;
78 int err = 0; 80 int err = 0;
79 81
80 if (tuner_ops->get_state) { 82 if (tuner_ops->get_bandwidth) {
81 if (frontend_ops->i2c_gate_ctrl) 83 if (frontend_ops->i2c_gate_ctrl)
82 frontend_ops->i2c_gate_ctrl(fe, 1); 84 frontend_ops->i2c_gate_ctrl(fe, 1);
83 85
84 err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &state); 86 err = tuner_ops->get_bandwidth(fe, bandwidth);
85 if (err < 0) { 87 if (err < 0) {
86 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 88 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
87 return err; 89 return err;
@@ -89,8 +91,6 @@ static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
89 91
90 if (frontend_ops->i2c_gate_ctrl) 92 if (frontend_ops->i2c_gate_ctrl)
91 frontend_ops->i2c_gate_ctrl(fe, 0); 93 frontend_ops->i2c_gate_ctrl(fe, 0);
92
93 *bandwidth = state.bandwidth;
94 } 94 }
95 95
96 return 0; 96 return 0;
@@ -100,16 +100,19 @@ static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
100{ 100{
101 struct dvb_frontend_ops *frontend_ops = &fe->ops; 101 struct dvb_frontend_ops *frontend_ops = &fe->ops;
102 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 102 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
103 struct tuner_state state; 103 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
104 u32 freq = c->frequency;
104 int err = 0; 105 int err = 0;
105 106
106 state.bandwidth = bandwidth; 107 c->bandwidth_hz = bandwidth;
108 c->frequency = 0; /* Don't adjust the frequency */
107 109
108 if (tuner_ops->set_state) { 110 if (tuner_ops->set_params) {
109 if (frontend_ops->i2c_gate_ctrl) 111 if (frontend_ops->i2c_gate_ctrl)
110 frontend_ops->i2c_gate_ctrl(fe, 1); 112 frontend_ops->i2c_gate_ctrl(fe, 1);
111 113
112 err = tuner_ops->set_state(fe, DVBFE_TUNER_BANDWIDTH, &state); 114 err = tuner_ops->set_params(fe);
115 c->frequency = freq;
113 if (err < 0) { 116 if (err < 0) {
114 printk(KERN_ERR "%s: Invalid parameter\n", __func__); 117 printk(KERN_ERR "%s: Invalid parameter\n", __func__);
115 return err; 118 return err;