1 /* 2 TDA8261 8PSK/QPSK tuner driver 3 Copyright (C) Manu Abraham (abraham.manu@gmail.com) 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 static int tda8261_get_frequency(struct dvb_frontend *fe, u32 *frequency) 21 { 22 struct dvb_frontend_ops *frontend_ops = NULL; 23 struct dvb_tuner_ops *tuner_ops = NULL; 24 struct tuner_state t_state; 25 int err = 0; 26 27 if (&fe->ops) 28 frontend_ops = &fe->ops; 29 if (&frontend_ops->tuner_ops) 30 tuner_ops = &frontend_ops->tuner_ops; 31 if (tuner_ops->get_state) { 32 if ((err = tuner_ops->get_state(fe, DVBFE_TUNER_FREQUENCY, &t_state)) < 0) { 33 printk("%s: Invalid parameter\n", __func__); 34 return err; 35 } 36 *frequency = t_state.frequency; 37 printk("%s: Frequency=%d\n", __func__, t_state.frequency); 38 } 39 return 0; 40 } 41 42 static int tda8261_set_frequency(struct dvb_frontend *fe, u32 frequency) 43 { 44 struct dvb_frontend_ops *frontend_ops = NULL; 45 struct dvb_tuner_ops *tuner_ops = NULL; 46 struct tuner_state t_state; 47 int err = 0; 48 49 t_state.frequency = frequency; 50 if (&fe->ops) 51 frontend_ops = &fe->ops; 52 if (&frontend_ops->tuner_ops) 53 tuner_ops = &frontend_ops->tuner_ops; 54 if (tuner_ops->set_state) { 55 if ((err = tuner_ops->set_state(fe, DVBFE_TUNER_FREQUENCY, &t_state)) < 0) { 56 printk("%s: Invalid parameter\n", __func__); 57 return err; 58 } 59 } 60 printk("%s: Frequency=%d\n", __func__, t_state.frequency); 61 return 0; 62 } 63 64 static int tda8261_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) 65 { 66 struct dvb_frontend_ops *frontend_ops = &fe->ops; 67 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; 68 struct tuner_state t_state; 69 int err = 0; 70 71 if (&fe->ops) 72 frontend_ops = &fe->ops; 73 if (&frontend_ops->tuner_ops) 74 tuner_ops = &frontend_ops->tuner_ops; 75 if (tuner_ops->get_state) { 76 if ((err = tuner_ops->get_state(fe, DVBFE_TUNER_BANDWIDTH, &t_state)) < 0) { 77 printk("%s: Invalid parameter\n", __func__); 78 return err; 79 } 80 *bandwidth = t_state.bandwidth; 81 printk("%s: Bandwidth=%d\n", __func__, t_state.bandwidth); 82 } 83 return 0; 84 } 85