1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 STV0900/0903 Multistandard Broadcast Frontend driver
4 Copyright (C) Manu Abraham <abraham.manu@gmail.com>
6 Copyright (C) ST Microelectronics
10 #ifndef __STV090x_PRIV_H
11 #define __STV090x_PRIV_H
13 #include <media/dvb_frontend.h>
21 #define dprintk(__y, __z, format, arg...) do { \
23 if ((verbose > FE_ERROR) && (verbose > __y)) \
24 printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
25 else if ((verbose > FE_NOTICE) && (verbose > __y)) \
26 printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
27 else if ((verbose > FE_INFO) && (verbose > __y)) \
28 printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
29 else if ((verbose > FE_DEBUG) && (verbose > __y)) \
30 printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
33 printk(format, ##arg); \
37 #define STV090x_READ_DEMOD(__state, __reg) (( \
38 (__state)->demod == STV090x_DEMODULATOR_1) ? \
39 stv090x_read_reg(__state, STV090x_P2_##__reg) : \
40 stv090x_read_reg(__state, STV090x_P1_##__reg))
42 #define STV090x_WRITE_DEMOD(__state, __reg, __data) (( \
43 (__state)->demod == STV090x_DEMODULATOR_1) ? \
44 stv090x_write_reg(__state, STV090x_P2_##__reg, __data) :\
45 stv090x_write_reg(__state, STV090x_P1_##__reg, __data))
47 #define STV090x_ADDR_OFFST(__state, __x) (( \
48 (__state->demod) == STV090x_DEMODULATOR_1) ? \
53 #define STV090x_SETFIELD(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_##bitf) - 1) <<\
54 STV090x_OFFST_##bitf))) | \
55 (val << STV090x_OFFST_##bitf))
57 #define STV090x_GETFIELD(val, bitf) ((val >> STV090x_OFFST_##bitf) & ((1 << STV090x_WIDTH_##bitf) - 1))
60 #define STV090x_SETFIELD_Px(mask, bitf, val) (mask = (mask & (~(((1 << STV090x_WIDTH_Px_##bitf) - 1) <<\
61 STV090x_OFFST_Px_##bitf))) | \
62 (val << STV090x_OFFST_Px_##bitf))
64 #define STV090x_GETFIELD_Px(val, bitf) ((val >> STV090x_OFFST_Px_##bitf) & ((1 << STV090x_WIDTH_Px_##bitf) - 1))
66 #define MAKEWORD16(__a, __b) (((__a) << 8) | (__b))
68 #define MSB(__x) ((__x >> 8) & 0xff)
69 #define LSB(__x) (__x & 0xff)
72 #define STV090x_IQPOWER_THRESHOLD 30
73 #define STV090x_SEARCH_AGC2_TH_CUT20 700
74 #define STV090x_SEARCH_AGC2_TH_CUT30 1400
76 #define STV090x_SEARCH_AGC2_TH(__ver) \
78 STV090x_SEARCH_AGC2_TH_CUT20 : \
79 STV090x_SEARCH_AGC2_TH_CUT30)
81 enum stv090x_signal_state
{
103 enum stv090x_modulation
{
121 enum stv090x_rolloff
{
127 enum stv090x_inversion
{
133 enum stv090x_modcod
{
134 STV090x_DUMMY_PLF
= 0,
163 STV090x_MODCODE_UNKNOWN
166 enum stv090x_search
{
167 STV090x_SEARCH_DSS
= 0,
168 STV090x_SEARCH_DVBS1
,
169 STV090x_SEARCH_DVBS2
,
174 STV090x_BLIND_SEARCH
,
179 enum stv090x_delsys
{
186 struct stv090x_long_frame_crloop
{
187 enum stv090x_modcod modcod
;
194 u8 crl_pilots_off_10
;
196 u8 crl_pilots_off_20
;
198 u8 crl_pilots_off_30
;
201 struct stv090x_short_frame_crloop
{
202 enum stv090x_modulation modulation
;
204 u8 crl_2
; /* SR < 3M */
205 u8 crl_5
; /* 3 < SR <= 7M */
206 u8 crl_10
; /* 7 < SR <= 15M */
207 u8 crl_20
; /* 10 < SR <= 25M */
208 u8 crl_30
; /* 10 < SR <= 45M */
221 struct stv090x_internal
{
222 struct i2c_adapter
*i2c_adap
;
225 struct mutex demod_lock
; /* Lock access to shared register */
226 struct mutex tuner_lock
; /* Lock access to tuners */
227 s32 mclk
; /* Masterclock Divider factor */
233 struct stv090x_state
{
234 enum stv090x_device device
;
235 enum stv090x_demodulator demod
;
236 enum stv090x_mode demod_mode
;
237 struct stv090x_internal
*internal
;
239 struct i2c_adapter
*i2c
;
240 struct stv090x_config
*config
;
241 struct dvb_frontend frontend
;
243 u32
*verbose
; /* Cached module verbosity */
245 enum stv090x_delsys delsys
;
246 enum stv090x_fec fec
;
247 enum stv090x_modulation modulation
;
248 enum stv090x_modcod modcod
;
249 enum stv090x_search search_mode
;
250 enum stv090x_frame frame_len
;
251 enum stv090x_pilot pilots
;
252 enum stv090x_rolloff rolloff
;
253 enum stv090x_inversion inversion
;
254 enum stv090x_algo algo
;
267 #endif /* __STV090x_PRIV_H */