1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  *    Support for LG Electronics LGDT3304 and LGDT3305 - VSB/QAM
4  *
5  *    Copyright (C) 2008, 2009, 2010 Michael Krufky <mkrufky@linuxtv.org>
6  */
7 
8 #ifndef _LGDT3305_H_
9 #define _LGDT3305_H_
10 
11 #include <linux/i2c.h>
12 #include <media/dvb_frontend.h>
13 
14 
15 enum lgdt3305_mpeg_mode {
16 	LGDT3305_MPEG_PARALLEL = 0,
17 	LGDT3305_MPEG_SERIAL = 1,
18 };
19 
20 enum lgdt3305_tp_clock_edge {
21 	LGDT3305_TPCLK_RISING_EDGE = 0,
22 	LGDT3305_TPCLK_FALLING_EDGE = 1,
23 };
24 
25 enum lgdt3305_tp_clock_mode {
26 	LGDT3305_TPCLK_GATED = 0,
27 	LGDT3305_TPCLK_FIXED = 1,
28 };
29 
30 enum lgdt3305_tp_valid_polarity {
31 	LGDT3305_TP_VALID_LOW = 0,
32 	LGDT3305_TP_VALID_HIGH = 1,
33 };
34 
35 enum lgdt_demod_chip_type {
36 	LGDT3305 = 0,
37 	LGDT3304 = 1,
38 };
39 
40 struct lgdt3305_config {
41 	u8 i2c_addr;
42 
43 	/* user defined IF frequency in KHz */
44 	u16 qam_if_khz;
45 	u16 vsb_if_khz;
46 
47 	/* AGC Power reference - defaults are used if left unset */
48 	u16 usref_8vsb;   /* default: 0x32c4 */
49 	u16 usref_qam64;  /* default: 0x5400 */
50 	u16 usref_qam256; /* default: 0x2a80 */
51 
52 	/* disable i2c repeater - 0:repeater enabled 1:repeater disabled */
53 	unsigned int deny_i2c_rptr:1;
54 
55 	/* spectral inversion - 0:disabled 1:enabled */
56 	unsigned int spectral_inversion:1;
57 
58 	/* use RF AGC loop - 0:disabled 1:enabled */
59 	unsigned int rf_agc_loop:1;
60 
61 	enum lgdt3305_mpeg_mode mpeg_mode;
62 	enum lgdt3305_tp_clock_edge tpclk_edge;
63 	enum lgdt3305_tp_clock_mode tpclk_mode;
64 	enum lgdt3305_tp_valid_polarity tpvalid_polarity;
65 	enum lgdt_demod_chip_type demod_chip;
66 };
67 
68 #if IS_REACHABLE(CONFIG_DVB_LGDT3305)
69 extern
70 struct dvb_frontend *lgdt3305_attach(const struct lgdt3305_config *config,
71 				     struct i2c_adapter *i2c_adap);
72 #else
73 static inline
74 struct dvb_frontend *lgdt3305_attach(const struct lgdt3305_config *config,
75 				     struct i2c_adapter *i2c_adap)
76 {
77 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
78 	return NULL;
79 }
80 #endif /* CONFIG_DVB_LGDT3305 */
81 
82 #endif /* _LGDT3305_H_ */
83