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 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 22 | #include <linux/dvb/frontend.h> |
| 23 | #include "dvb_frontend.h" |
| 24 | |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 25 | static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 26 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 27 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 28 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 29 | int err = 0; |
| 30 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 31 | if (tuner_ops->get_frequency) { |
| 32 | err = tuner_ops->get_frequency(fe, frequency); |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 33 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 34 | printk("%s: Invalid parameter\n", __func__); |
| 35 | return err; |
| 36 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 37 | } |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency) |
| 42 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 43 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 44 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 45 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 46 | u32 bw = c->bandwidth_hz; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 47 | int err = 0; |
| 48 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 49 | c->frequency = frequency; |
| 50 | c->bandwidth_hz = 0; /* Don't adjust the bandwidth */ |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 51 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 52 | if (tuner_ops->set_params) { |
| 53 | err = tuner_ops->set_params(fe); |
| 54 | c->bandwidth_hz = bw; |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 55 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 56 | printk("%s: Invalid parameter\n", __func__); |
| 57 | return err; |
| 58 | } |
| 59 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | |
| 63 | static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 64 | { |
| 65 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 66 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 67 | int err = 0; |
| 68 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 69 | if (tuner_ops->get_bandwidth) { |
| 70 | err = tuner_ops->get_bandwidth(fe, bandwidth); |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 71 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 72 | printk("%s: Invalid parameter\n", __func__); |
| 73 | return err; |
| 74 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 75 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 76 | return 0; |
| 77 | } |
| 78 | |
| 79 | static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth) |
| 80 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 81 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 82 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 83 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 84 | u32 freq = c->frequency; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 85 | int err = 0; |
| 86 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 87 | c->bandwidth_hz = bandwidth; |
| 88 | c->frequency = 0; /* Don't adjust the frequency */ |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 89 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 90 | if (tuner_ops->set_params) { |
| 91 | err = tuner_ops->set_params(fe); |
| 92 | c->frequency = freq; |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 93 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 94 | printk("%s: Invalid parameter\n", __func__); |
| 95 | return err; |
| 96 | } |
| 97 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 98 | return 0; |
| 99 | } |