xref: /OK3568_Linux_fs/kernel/drivers/media/dvb-frontends/si21xx.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef SI21XX_H
3*4882a593Smuzhiyun #define SI21XX_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/dvb/frontend.h>
6*4882a593Smuzhiyun #include <media/dvb_frontend.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun struct si21xx_config {
9*4882a593Smuzhiyun 	/* the demodulator's i2c address */
10*4882a593Smuzhiyun 	u8 demod_address;
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun 	/* minimum delay before retuning */
13*4882a593Smuzhiyun 	int min_delay_ms;
14*4882a593Smuzhiyun };
15*4882a593Smuzhiyun 
16*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_DVB_SI21XX)
17*4882a593Smuzhiyun extern struct dvb_frontend *si21xx_attach(const struct si21xx_config *config,
18*4882a593Smuzhiyun 						struct i2c_adapter *i2c);
19*4882a593Smuzhiyun #else
si21xx_attach(const struct si21xx_config * config,struct i2c_adapter * i2c)20*4882a593Smuzhiyun static inline struct dvb_frontend *si21xx_attach(
21*4882a593Smuzhiyun 		const struct si21xx_config *config, struct i2c_adapter *i2c)
22*4882a593Smuzhiyun {
23*4882a593Smuzhiyun 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
24*4882a593Smuzhiyun 	return NULL;
25*4882a593Smuzhiyun }
26*4882a593Smuzhiyun #endif
27*4882a593Smuzhiyun 
si21xx_writeregister(struct dvb_frontend * fe,u8 reg,u8 val)28*4882a593Smuzhiyun static inline int si21xx_writeregister(struct dvb_frontend *fe, u8 reg, u8 val)
29*4882a593Smuzhiyun {
30*4882a593Smuzhiyun 	int r = 0;
31*4882a593Smuzhiyun 	u8 buf[] = {reg, val};
32*4882a593Smuzhiyun 	if (fe->ops.write)
33*4882a593Smuzhiyun 		r = fe->ops.write(fe, buf, 2);
34*4882a593Smuzhiyun 	return r;
35*4882a593Smuzhiyun }
36*4882a593Smuzhiyun 
37*4882a593Smuzhiyun #endif
38