xref: /OK3568_Linux_fs/kernel/drivers/media/dvb-frontends/drxk.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _DRXK_H_
3*4882a593Smuzhiyun #define _DRXK_H_
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/types.h>
6*4882a593Smuzhiyun #include <linux/i2c.h>
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun /**
9*4882a593Smuzhiyun  * struct drxk_config - Configure the initial parameters for DRX-K
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  * @adr:		I2C address of the DRX-K
12*4882a593Smuzhiyun  * @parallel_ts:	True means that the device uses parallel TS,
13*4882a593Smuzhiyun  *			Serial otherwise.
14*4882a593Smuzhiyun  * @dynamic_clk:	True means that the clock will be dynamically
15*4882a593Smuzhiyun  *			adjusted. Static clock otherwise.
16*4882a593Smuzhiyun  * @enable_merr_cfg:	Enable SIO_PDR_PERR_CFG/SIO_PDR_MVAL_CFG.
17*4882a593Smuzhiyun  * @single_master:	Device is on the single master mode
18*4882a593Smuzhiyun  * @no_i2c_bridge:	Don't switch the I2C bridge to talk with tuner
19*4882a593Smuzhiyun  * @antenna_gpio:	GPIO bit used to control the antenna
20*4882a593Smuzhiyun  * @antenna_dvbt:	GPIO bit for changing antenna to DVB-C. A value of 1
21*4882a593Smuzhiyun  *			means that 1=DVBC, 0 = DVBT. Zero means the opposite.
22*4882a593Smuzhiyun  * @mpeg_out_clk_strength: DRXK Mpeg output clock drive strength.
23*4882a593Smuzhiyun  * @chunk_size:		maximum size for I2C messages
24*4882a593Smuzhiyun  * @microcode_name:	Name of the firmware file with the microcode
25*4882a593Smuzhiyun  * @qam_demod_parameter_count:	The number of parameters used for the command
26*4882a593Smuzhiyun  *				to set the demodulator parameters. All
27*4882a593Smuzhiyun  *				firmwares are using the 2-parameter command.
28*4882a593Smuzhiyun  *				An exception is the ``drxk_a3.mc`` firmware,
29*4882a593Smuzhiyun  *				which uses the 4-parameter command.
30*4882a593Smuzhiyun  *				A value of 0 (default) or lower indicates that
31*4882a593Smuzhiyun  *				the correct number of parameters will be
32*4882a593Smuzhiyun  *				automatically detected.
33*4882a593Smuzhiyun  *
34*4882a593Smuzhiyun  * On the ``*_gpio`` vars, bit 0 is UIO-1, bit 1 is UIO-2 and bit 2 is
35*4882a593Smuzhiyun  * UIO-3.
36*4882a593Smuzhiyun  */
37*4882a593Smuzhiyun struct drxk_config {
38*4882a593Smuzhiyun 	u8	adr;
39*4882a593Smuzhiyun 	bool	single_master;
40*4882a593Smuzhiyun 	bool	no_i2c_bridge;
41*4882a593Smuzhiyun 	bool	parallel_ts;
42*4882a593Smuzhiyun 	bool	dynamic_clk;
43*4882a593Smuzhiyun 	bool	enable_merr_cfg;
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun 	bool	antenna_dvbt;
46*4882a593Smuzhiyun 	u16	antenna_gpio;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	u8	mpeg_out_clk_strength;
49*4882a593Smuzhiyun 	int	chunk_size;
50*4882a593Smuzhiyun 
51*4882a593Smuzhiyun 	const char	*microcode_name;
52*4882a593Smuzhiyun 	int		 qam_demod_parameter_count;
53*4882a593Smuzhiyun };
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun #if IS_REACHABLE(CONFIG_DVB_DRXK)
56*4882a593Smuzhiyun /**
57*4882a593Smuzhiyun  * Attach a drxk demod
58*4882a593Smuzhiyun  *
59*4882a593Smuzhiyun  * @config: pointer to &struct drxk_config with demod configuration.
60*4882a593Smuzhiyun  * @i2c: i2c adapter to use.
61*4882a593Smuzhiyun  *
62*4882a593Smuzhiyun  * return: FE pointer on success, NULL on failure.
63*4882a593Smuzhiyun  */
64*4882a593Smuzhiyun extern struct dvb_frontend *drxk_attach(const struct drxk_config *config,
65*4882a593Smuzhiyun 					struct i2c_adapter *i2c);
66*4882a593Smuzhiyun #else
drxk_attach(const struct drxk_config * config,struct i2c_adapter * i2c)67*4882a593Smuzhiyun static inline struct dvb_frontend *drxk_attach(const struct drxk_config *config,
68*4882a593Smuzhiyun 					struct i2c_adapter *i2c)
69*4882a593Smuzhiyun {
70*4882a593Smuzhiyun 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
71*4882a593Smuzhiyun 	return NULL;
72*4882a593Smuzhiyun }
73*4882a593Smuzhiyun #endif
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun #endif
76