1*74ba9207SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
29a0bf528SMauro Carvalho Chehab /*
39a0bf528SMauro Carvalho Chehab STB6100 Silicon Tuner
49a0bf528SMauro Carvalho Chehab Copyright (C) Manu Abraham (abraham.manu@gmail.com)
59a0bf528SMauro Carvalho Chehab
69a0bf528SMauro Carvalho Chehab Copyright (C) ST Microelectronics
79a0bf528SMauro Carvalho Chehab
89a0bf528SMauro Carvalho Chehab */
99a0bf528SMauro Carvalho Chehab
1065f0f686SMauro Carvalho Chehab #include <linux/dvb/frontend.h>
11fada1935SMauro Carvalho Chehab #include <media/dvb_frontend.h>
1265f0f686SMauro Carvalho Chehab
stb6100_get_frequency(struct dvb_frontend * fe,u32 * frequency)139a0bf528SMauro Carvalho Chehab static int stb6100_get_frequency(struct dvb_frontend *fe, u32 *frequency)
149a0bf528SMauro Carvalho Chehab {
1520721185SEmil Goode struct dvb_frontend_ops *frontend_ops = &fe->ops;
1620721185SEmil Goode struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
179a0bf528SMauro Carvalho Chehab int err = 0;
189a0bf528SMauro Carvalho Chehab
1965f0f686SMauro Carvalho Chehab if (tuner_ops->get_frequency) {
2065f0f686SMauro Carvalho Chehab err = tuner_ops->get_frequency(fe, frequency);
218f73b481SEmil Goode if (err < 0) {
229a0bf528SMauro Carvalho Chehab printk("%s: Invalid parameter\n", __func__);
239a0bf528SMauro Carvalho Chehab return err;
249a0bf528SMauro Carvalho Chehab }
259a0bf528SMauro Carvalho Chehab }
269a0bf528SMauro Carvalho Chehab return 0;
279a0bf528SMauro Carvalho Chehab }
289a0bf528SMauro Carvalho Chehab
stb6100_set_frequency(struct dvb_frontend * fe,u32 frequency)299a0bf528SMauro Carvalho Chehab static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency)
309a0bf528SMauro Carvalho Chehab {
3120721185SEmil Goode struct dvb_frontend_ops *frontend_ops = &fe->ops;
3220721185SEmil Goode struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
3365f0f686SMauro Carvalho Chehab struct dtv_frontend_properties *c = &fe->dtv_property_cache;
3465f0f686SMauro Carvalho Chehab u32 bw = c->bandwidth_hz;
359a0bf528SMauro Carvalho Chehab int err = 0;
369a0bf528SMauro Carvalho Chehab
3765f0f686SMauro Carvalho Chehab c->frequency = frequency;
3865f0f686SMauro Carvalho Chehab c->bandwidth_hz = 0; /* Don't adjust the bandwidth */
3920721185SEmil Goode
4065f0f686SMauro Carvalho Chehab if (tuner_ops->set_params) {
4165f0f686SMauro Carvalho Chehab err = tuner_ops->set_params(fe);
4265f0f686SMauro Carvalho Chehab c->bandwidth_hz = bw;
438f73b481SEmil Goode if (err < 0) {
449a0bf528SMauro Carvalho Chehab printk("%s: Invalid parameter\n", __func__);
459a0bf528SMauro Carvalho Chehab return err;
469a0bf528SMauro Carvalho Chehab }
479a0bf528SMauro Carvalho Chehab }
489a0bf528SMauro Carvalho Chehab return 0;
499a0bf528SMauro Carvalho Chehab }
509a0bf528SMauro Carvalho Chehab
stb6100_get_bandwidth(struct dvb_frontend * fe,u32 * bandwidth)519a0bf528SMauro Carvalho Chehab static int stb6100_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
529a0bf528SMauro Carvalho Chehab {
539a0bf528SMauro Carvalho Chehab struct dvb_frontend_ops *frontend_ops = &fe->ops;
549a0bf528SMauro Carvalho Chehab struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
559a0bf528SMauro Carvalho Chehab int err = 0;
569a0bf528SMauro Carvalho Chehab
5765f0f686SMauro Carvalho Chehab if (tuner_ops->get_bandwidth) {
5865f0f686SMauro Carvalho Chehab err = tuner_ops->get_bandwidth(fe, bandwidth);
598f73b481SEmil Goode if (err < 0) {
609a0bf528SMauro Carvalho Chehab printk("%s: Invalid parameter\n", __func__);
619a0bf528SMauro Carvalho Chehab return err;
629a0bf528SMauro Carvalho Chehab }
639a0bf528SMauro Carvalho Chehab }
649a0bf528SMauro Carvalho Chehab return 0;
659a0bf528SMauro Carvalho Chehab }
669a0bf528SMauro Carvalho Chehab
stb6100_set_bandwidth(struct dvb_frontend * fe,u32 bandwidth)679a0bf528SMauro Carvalho Chehab static int stb6100_set_bandwidth(struct dvb_frontend *fe, u32 bandwidth)
689a0bf528SMauro Carvalho Chehab {
6920721185SEmil Goode struct dvb_frontend_ops *frontend_ops = &fe->ops;
7020721185SEmil Goode struct dvb_tuner_ops *tuner_ops = &frontend_ops->tuner_ops;
7165f0f686SMauro Carvalho Chehab struct dtv_frontend_properties *c = &fe->dtv_property_cache;
7265f0f686SMauro Carvalho Chehab u32 freq = c->frequency;
739a0bf528SMauro Carvalho Chehab int err = 0;
749a0bf528SMauro Carvalho Chehab
7565f0f686SMauro Carvalho Chehab c->bandwidth_hz = bandwidth;
7665f0f686SMauro Carvalho Chehab c->frequency = 0; /* Don't adjust the frequency */
7720721185SEmil Goode
7865f0f686SMauro Carvalho Chehab if (tuner_ops->set_params) {
7965f0f686SMauro Carvalho Chehab err = tuner_ops->set_params(fe);
8065f0f686SMauro Carvalho Chehab c->frequency = freq;
818f73b481SEmil Goode if (err < 0) {
829a0bf528SMauro Carvalho Chehab printk("%s: Invalid parameter\n", __func__);
839a0bf528SMauro Carvalho Chehab return err;
849a0bf528SMauro Carvalho Chehab }
859a0bf528SMauro Carvalho Chehab }
869a0bf528SMauro Carvalho Chehab return 0;
879a0bf528SMauro Carvalho Chehab }
88