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