88 lines · c
1/* SPDX-License-Identifier: GPL-2.0-or-later */2/*3 STB6100 Silicon Tuner4 Copyright (C) Manu Abraham (abraham.manu@gmail.com)5 6 Copyright (C) ST Microelectronics7 8*/9 10#include <linux/dvb/frontend.h>11#include <media/dvb_frontend.h>12 13static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)14{15 struct dvb_frontend_ops *frontend_ops = &fe->ops;16 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;17 int err = 0;18 19 if (tuner_ops->get_frequency) {20 err = tuner_ops->get_frequency(fe, frequency);21 if (err < 0) {22 printk("%s: Invalid parameter\n", __func__);23 return err;24 }25 }26 return 0;27}28 29static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)30{31 struct dvb_frontend_ops *frontend_ops = &fe->ops;32 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;33 struct dtv_frontend_properties *c = &fe->dtv_property_cache;34 u32 bw = c->bandwidth_hz;35 int err = 0;36 37 c->frequency = frequency;38 c->bandwidth_hz = 0; /* Don't adjust the bandwidth */39 40 if (tuner_ops->set_params) {41 err = tuner_ops->set_params(fe);42 c->bandwidth_hz = bw;43 if (err < 0) {44 printk("%s: Invalid parameter\n", __func__);45 return err;46 }47 }48 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;55 int err = 0;56 57 if (tuner_ops->get_bandwidth) {58 err = tuner_ops->get_bandwidth(fe, bandwidth);59 if (err < 0) {60 printk("%s: Invalid parameter\n", __func__);61 return err;62 }63 }64 return 0;65}66 67static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)68{69 struct dvb_frontend_ops *frontend_ops = &fe->ops;70 struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;71 struct dtv_frontend_properties *c = &fe->dtv_property_cache;72 u32 freq = c->frequency;73 int err = 0;74 75 c->bandwidth_hz = bandwidth;76 c->frequency = 0; /* Don't adjust the frequency */77 78 if (tuner_ops->set_params) {79 err = tuner_ops->set_params(fe);80 c->frequency = freq;81 if (err < 0) {82 printk("%s: Invalid parameter\n", __func__);83 return err;84 }85 }86 return 0;87}88