Thomas Gleixner | 74ba920 | 2019-05-20 09:19:02 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 2 | /* |
| 3 | STB6100 Silicon Tuner |
| 4 | Copyright (C) Manu Abraham (abraham.manu@gmail.com) |
| 5 | |
| 6 | Copyright (C) ST Microelectronics |
| 7 | |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 8 | */ |
| 9 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 10 | #include <linux/dvb/frontend.h> |
Mauro Carvalho Chehab | fada193 | 2017-12-28 13:03:51 -0500 | [diff] [blame] | 11 | #include <media/dvb_frontend.h> |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 12 | |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 13 | static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency) |
| 14 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 15 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 16 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 17 | int err = 0; |
| 18 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 19 | if (tuner_ops->get_frequency) { |
| 20 | err = tuner_ops->get_frequency(fe, frequency); |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 21 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 22 | printk("%s: Invalid parameter\n", __func__); |
| 23 | return err; |
| 24 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 25 | } |
| 26 | return 0; |
| 27 | } |
| 28 | |
| 29 | static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency) |
| 30 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 31 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 32 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 33 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 34 | u32 bw = c->bandwidth_hz; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 35 | int err = 0; |
| 36 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 37 | c->frequency = frequency; |
| 38 | c->bandwidth_hz = 0; /* Don't adjust the bandwidth */ |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 39 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 40 | if (tuner_ops->set_params) { |
| 41 | err = tuner_ops->set_params(fe); |
| 42 | c->bandwidth_hz = bw; |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 43 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 44 | printk("%s: Invalid parameter\n", __func__); |
| 45 | return err; |
| 46 | } |
| 47 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth) |
| 52 | { |
| 53 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 54 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 55 | int err = 0; |
| 56 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 57 | if (tuner_ops->get_bandwidth) { |
| 58 | err = tuner_ops->get_bandwidth(fe, bandwidth); |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 59 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 60 | printk("%s: Invalid parameter\n", __func__); |
| 61 | return err; |
| 62 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 63 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth) |
| 68 | { |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 69 | struct dvb_frontend_ops *frontend_ops = &fe->ops; |
| 70 | struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops; |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 71 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 72 | u32 freq = c->frequency; |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 73 | int err = 0; |
| 74 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 75 | c->bandwidth_hz = bandwidth; |
| 76 | c->frequency = 0; /* Don't adjust the frequency */ |
Emil Goode | 2072118 | 2014-06-24 18:42:27 -0300 | [diff] [blame] | 77 | |
Mauro Carvalho Chehab | 65f0f68 | 2015-11-11 18:42:00 -0200 | [diff] [blame] | 78 | if (tuner_ops->set_params) { |
| 79 | err = tuner_ops->set_params(fe); |
| 80 | c->frequency = freq; |
Emil Goode | 8f73b48 | 2014-06-24 18:42:28 -0300 | [diff] [blame] | 81 | if (err < 0) { |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 82 | printk("%s: Invalid parameter\n", __func__); |
| 83 | return err; |
| 84 | } |
| 85 | } |
Manu Abraham | 8be969b | 2008-01-25 18:20:48 -0300 | [diff] [blame] | 86 | return 0; |
| 87 | } |