Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) 	STB6100 Silicon Tuner wrapper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) 	Copyright (C)2009 Igor M. Liplianin (liplianin@me.by)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/dvb/frontend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <media/dvb_frontend.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) static int stb6100_get_freq(struct dvb_frontend *fe, u32 *frequency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	struct dvb_frontend_ops	*frontend_ops = &fe->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	struct dvb_tuner_ops	*tuner_ops = &frontend_ops->tuner_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	if (tuner_ops->get_frequency) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 			frontend_ops->i2c_gate_ctrl(fe, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		err = tuner_ops->get_frequency(fe, frequency);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 			printk("%s: Invalid parameter\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 			frontend_ops->i2c_gate_ctrl(fe, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) static int stb6100_set_freq(struct dvb_frontend *fe, u32 frequency)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct dvb_frontend_ops	*frontend_ops = &fe->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct dvb_tuner_ops	*tuner_ops = &frontend_ops->tuner_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u32 bw = c->bandwidth_hz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	c->frequency = frequency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	c->bandwidth_hz = 0;		/* Don't adjust the bandwidth */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (tuner_ops->set_params) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			frontend_ops->i2c_gate_ctrl(fe, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		err = tuner_ops->set_params(fe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		c->bandwidth_hz = bw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 			printk("%s: Invalid parameter\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 			frontend_ops->i2c_gate_ctrl(fe, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static int stb6100_get_bandw(struct dvb_frontend *fe, u32 *bandwidth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	struct dvb_frontend_ops	*frontend_ops = &fe->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	struct dvb_tuner_ops	*tuner_ops = &frontend_ops->tuner_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	if (tuner_ops->get_bandwidth) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 			frontend_ops->i2c_gate_ctrl(fe, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		err = tuner_ops->get_bandwidth(fe, bandwidth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			printk(KERN_ERR "%s: Invalid parameter\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 			frontend_ops->i2c_gate_ctrl(fe, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static int stb6100_set_bandw(struct dvb_frontend *fe, u32 bandwidth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct dvb_frontend_ops	*frontend_ops = &fe->ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	struct dvb_tuner_ops	*tuner_ops = &frontend_ops->tuner_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	u32 freq = c->frequency;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	c->bandwidth_hz = bandwidth;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	c->frequency = 0;		/* Don't adjust the frequency */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	if (tuner_ops->set_params) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			frontend_ops->i2c_gate_ctrl(fe, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 		err = tuner_ops->set_params(fe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		c->frequency = freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		if (err < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 			printk(KERN_ERR "%s: Invalid parameter\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 			return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		if (frontend_ops->i2c_gate_ctrl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 			frontend_ops->i2c_gate_ctrl(fe, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }