Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003     STB6100 Silicon Tuner wrapper
0004     Copyright (C)2009 Igor M. Liplianin (liplianin@me.by)
0005 
0006 */
0007 
0008 #include <linux/dvb/frontend.h>
0009 #include <media/dvb_frontend.h>
0010 
0011 static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
0012 {
0013     struct dvb_frontend_ops *frontend_ops = &fe->ops;
0014     struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
0015     int err = 0;
0016 
0017     if (tuner_ops->get_frequency) {
0018         if (frontend_ops->i2c_gate_ctrl)
0019             frontend_ops->i2c_gate_ctrl(fe, 1);
0020 
0021         err = tuner_ops->get_frequency(fe, frequency);
0022         if (err < 0) {
0023             printk("%s: Invalid parameter\n", __func__);
0024             return err;
0025         }
0026 
0027         if (frontend_ops->i2c_gate_ctrl)
0028             frontend_ops->i2c_gate_ctrl(fe, 0);
0029     }
0030 
0031     return 0;
0032 }
0033 
0034 static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
0035 {
0036     struct dvb_frontend_ops *frontend_ops = &fe->ops;
0037     struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
0038     struct dtv_frontend_properties *c = &fe->dtv_property_cache;
0039     u32 bw = c->bandwidth_hz;
0040     int err = 0;
0041 
0042     c->frequency = frequency;
0043     c->bandwidth_hz = 0;        /* Don't adjust the bandwidth */
0044 
0045     if (tuner_ops->set_params) {
0046         if (frontend_ops->i2c_gate_ctrl)
0047             frontend_ops->i2c_gate_ctrl(fe, 1);
0048 
0049         err = tuner_ops->set_params(fe);
0050         c->bandwidth_hz = bw;
0051         if (err < 0) {
0052             printk("%s: Invalid parameter\n", __func__);
0053             return err;
0054         }
0055 
0056         if (frontend_ops->i2c_gate_ctrl)
0057             frontend_ops->i2c_gate_ctrl(fe, 0);
0058 
0059     }
0060 
0061     return 0;
0062 }
0063 
0064 static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
0065 {
0066     struct dvb_frontend_ops *frontend_ops = &fe->ops;
0067     struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
0068     int err = 0;
0069 
0070     if (tuner_ops->get_bandwidth) {
0071         if (frontend_ops->i2c_gate_ctrl)
0072             frontend_ops->i2c_gate_ctrl(fe, 1);
0073 
0074         err = tuner_ops->get_bandwidth(fe, bandwidth);
0075         if (err < 0) {
0076             printk(KERN_ERR "%s: Invalid parameter\n", __func__);
0077             return err;
0078         }
0079 
0080         if (frontend_ops->i2c_gate_ctrl)
0081             frontend_ops->i2c_gate_ctrl(fe, 0);
0082     }
0083 
0084     return 0;
0085 }
0086 
0087 static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
0088 {
0089     struct dvb_frontend_ops *frontend_ops = &fe->ops;
0090     struct dvb_tuner_ops    *tuner_ops = &frontend_ops->tuner_ops;
0091     struct dtv_frontend_properties *c = &fe->dtv_property_cache;
0092     u32 freq = c->frequency;
0093     int err = 0;
0094 
0095     c->bandwidth_hz = bandwidth;
0096     c->frequency = 0;       /* Don't adjust the frequency */
0097 
0098     if (tuner_ops->set_params) {
0099         if (frontend_ops->i2c_gate_ctrl)
0100             frontend_ops->i2c_gate_ctrl(fe, 1);
0101 
0102         err = tuner_ops->set_params(fe);
0103         c->frequency = freq;
0104         if (err < 0) {
0105             printk(KERN_ERR "%s: Invalid parameter\n", __func__);
0106             return err;
0107         }
0108 
0109         if (frontend_ops->i2c_gate_ctrl)
0110             frontend_ops->i2c_gate_ctrl(fe, 0);
0111 
0112     }
0113 
0114     return 0;
0115 }