1 /*
2  *  Samsung s5h1432 VSB/QAM demodulator driver
3  *
4  *  Copyright (C) 2009 Bill Liu <Bill.Liu@Conexant.com>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  */
17 
18 #ifndef __S5H1432_H__
19 #define __S5H1432_H__
20 
21 #include <linux/dvb/frontend.h>
22 
23 #define S5H1432_I2C_TOP_ADDR (0x02 >> 1)
24 
25 #define TAIWAN_HI_IF_FREQ_44_MHZ 44000000
26 #define EUROPE_HI_IF_FREQ_36_MHZ 36000000
27 #define IF_FREQ_6_MHZ             6000000
28 #define IF_FREQ_3point3_MHZ       3300000
29 #define IF_FREQ_3point5_MHZ       3500000
30 #define IF_FREQ_4_MHZ             4000000
31 
32 struct s5h1432_config {
33 
34 	/* serial/parallel output */
35 #define S5H1432_PARALLEL_OUTPUT 0
36 #define S5H1432_SERIAL_OUTPUT   1
37 	u8 output_mode;
38 
39 	/* GPIO Setting */
40 #define S5H1432_GPIO_OFF 0
41 #define S5H1432_GPIO_ON  1
42 	u8 gpio;
43 
44 	/* MPEG signal timing */
45 #define S5H1432_MPEGTIMING_CONTINUOUS_INVERTING_CLOCK       0
46 #define S5H1432_MPEGTIMING_CONTINUOUS_NONINVERTING_CLOCK    1
47 #define S5H1432_MPEGTIMING_NONCONTINUOUS_INVERTING_CLOCK    2
48 #define S5H1432_MPEGTIMING_NONCONTINUOUS_NONINVERTING_CLOCK 3
49 	u16 mpeg_timing;
50 
51 	/* IF Freq for QAM and VSB in KHz */
52 #define S5H1432_IF_3250  3250
53 #define S5H1432_IF_3500  3500
54 #define S5H1432_IF_4000  4000
55 #define S5H1432_IF_5380  5380
56 #define S5H1432_IF_44000 44000
57 #define S5H1432_VSB_IF_DEFAULT s5h1432_IF_44000
58 #define S5H1432_QAM_IF_DEFAULT s5h1432_IF_44000
59 	u16 qam_if;
60 	u16 vsb_if;
61 
62 	/* Spectral Inversion */
63 #define S5H1432_INVERSION_OFF 0
64 #define S5H1432_INVERSION_ON  1
65 	u8 inversion;
66 
67 	/* Return lock status based on tuner lock, or demod lock */
68 #define S5H1432_TUNERLOCKING 0
69 #define S5H1432_DEMODLOCKING 1
70 	u8 status_mode;
71 };
72 
73 #if IS_REACHABLE(CONFIG_DVB_S5H1432)
74 extern struct dvb_frontend *s5h1432_attach(const struct s5h1432_config *config,
75 					   struct i2c_adapter *i2c);
76 #else
77 static inline struct dvb_frontend *s5h1432_attach(const struct s5h1432_config
78 						  *config,
79 						  struct i2c_adapter *i2c)
80 {
81 	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
82 	return NULL;
83 }
84 #endif /* CONFIG_DVB_s5h1432 */
85 
86 #endif /* __s5h1432_H__ */
87