blob: 1408c0c449172cfd16f3d9e25dc115e8cb062333 [file] [log] [blame]
Thomas Gleixner74ba9202019-05-20 09:19:02 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Manu Abraham8be969b2008-01-25 18:20:48 -03002/*
3 STB6100 Silicon Tuner
4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)
5
6 Copyright (C) ST Microelectronics
7
Manu Abraham8be969b2008-01-25 18:20:48 -03008*/
9
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020010#include <linux/dvb/frontend.h>
Mauro Carvalho Chehabfada1932017-12-28 13:03:51 -050011#include <media/dvb_frontend.h>
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020012
Manu Abraham8be969b2008-01-25 18:20:48 -030013static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
14{
Emil Goode20721182014-06-24 18:42:27 -030015 struct dvb_frontend_ops *frontend_ops = &fe->ops;
16 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
Manu Abraham8be969b2008-01-25 18:20:48 -030017 int err = 0;
18
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020019 if (tuner_ops->get_frequency) {
20 err = tuner_ops->get_frequency(fe, frequency);
Emil Goode8f73b482014-06-24 18:42:28 -030021 if (err < 0) {
Manu Abraham8be969b2008-01-25 18:20:48 -030022 printk("%s: Invalid parameter\n", __func__);
23 return err;
24 }
Manu Abraham8be969b2008-01-25 18:20:48 -030025 }
26 return 0;
27}
28
29static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
30{
Emil Goode20721182014-06-24 18:42:27 -030031 struct dvb_frontend_ops *frontend_ops = &fe->ops;
32 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020033 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
34 u32 bw = c->bandwidth_hz;
Manu Abraham8be969b2008-01-25 18:20:48 -030035 int err = 0;
36
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020037 c->frequency = frequency;
38 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
Emil Goode20721182014-06-24 18:42:27 -030039
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020040 if (tuner_ops->set_params) {
41 err = tuner_ops->set_params(fe);
42 c->bandwidth_hz = bw;
Emil Goode8f73b482014-06-24 18:42:28 -030043 if (err < 0) {
Manu Abraham8be969b2008-01-25 18:20:48 -030044 printk("%s: Invalid parameter\n", __func__);
45 return err;
46 }
47 }
Manu Abraham8be969b2008-01-25 18:20:48 -030048 return 0;
49}
50
51static 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 Abraham8be969b2008-01-25 18:20:48 -030055 int err = 0;
56
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020057 if (tuner_ops->get_bandwidth) {
58 err = tuner_ops->get_bandwidth(fe, bandwidth);
Emil Goode8f73b482014-06-24 18:42:28 -030059 if (err < 0) {
Manu Abraham8be969b2008-01-25 18:20:48 -030060 printk("%s: Invalid parameter\n", __func__);
61 return err;
62 }
Manu Abraham8be969b2008-01-25 18:20:48 -030063 }
Manu Abraham8be969b2008-01-25 18:20:48 -030064 return 0;
65}
66
67static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
68{
Emil Goode20721182014-06-24 18:42:27 -030069 struct dvb_frontend_ops *frontend_ops = &fe->ops;
70 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020071 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
72 u32 freq = c->frequency;
Manu Abraham8be969b2008-01-25 18:20:48 -030073 int err = 0;
74
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020075 c->bandwidth_hz = bandwidth;
76 c->frequency = 0; /* Don't adjust the frequency */
Emil Goode20721182014-06-24 18:42:27 -030077
Mauro Carvalho Chehab65f0f682015-11-11 18:42:00 -020078 if (tuner_ops->set_params) {
79 err = tuner_ops->set_params(fe);
80 c->frequency = freq;
Emil Goode8f73b482014-06-24 18:42:28 -030081 if (err < 0) {
Manu Abraham8be969b2008-01-25 18:20:48 -030082 printk("%s: Invalid parameter\n", __func__);
83 return err;
84 }
85 }
Manu Abraham8be969b2008-01-25 18:20:48 -030086 return 0;
87}