xref: /linux/drivers/media/dvb-frontends/stv6110x_priv.h (revision 79790b6818e96c58fe2bffee1b418c16e64e7b80)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 	STV6110(A) Silicon tuner driver
4 
5 	Copyright (C) Manu Abraham <abraham.manu@gmail.com>
6 
7 	Copyright (C) ST Microelectronics
8 
9 */
10 
11 #ifndef __STV6110x_PRIV_H
12 #define __STV6110x_PRIV_H
13 
14 #define FE_ERROR				0
15 #define FE_NOTICE				1
16 #define FE_INFO					2
17 #define FE_DEBUG				3
18 #define FE_DEBUGREG				4
19 
20 #define dprintk(__y, __z, format, arg...) do {						\
21 	if (__z) {									\
22 		if	((verbose > FE_ERROR) && (verbose > __y))			\
23 			printk(KERN_ERR "%s: " format "\n", __func__, ##arg);		\
24 		else if	((verbose > FE_NOTICE) && (verbose > __y))			\
25 			printk(KERN_NOTICE "%s: " format "\n", __func__, ##arg);	\
26 		else if ((verbose > FE_INFO) && (verbose > __y))			\
27 			printk(KERN_INFO "%s: " format "\n", __func__, ##arg);		\
28 		else if ((verbose > FE_DEBUG) && (verbose > __y))			\
29 			printk(KERN_DEBUG "%s: " format "\n", __func__, ##arg);	\
30 	} else {									\
31 		if (verbose > __y)							\
32 			printk(format, ##arg);						\
33 	}										\
34 } while (0)
35 
36 
37 #define STV6110x_SETFIELD(mask, bitf, val)				\
38 	(mask = (mask & (~(((1 << STV6110x_WIDTH_##bitf) - 1) <<	\
39 				  STV6110x_OFFST_##bitf))) |		\
40 			  (val << STV6110x_OFFST_##bitf))
41 
42 #define STV6110x_GETFIELD(bitf, val)					\
43 	((val >> STV6110x_OFFST_##bitf) &				\
44 	((1 << STV6110x_WIDTH_##bitf) - 1))
45 
46 #define MAKEWORD16(a, b)			(((a) << 8) | (b))
47 
48 #define LSB(x)					((x & 0xff))
49 #define MSB(y)					((y >> 8) & 0xff)
50 
51 #define TRIALS					10
52 #define R_DIV(__div)				(1 << (__div + 1))
53 #define REFCLOCK_kHz				(stv6110x->config->refclk /    1000)
54 #define REFCLOCK_MHz				(stv6110x->config->refclk / 1000000)
55 
56 struct stv6110x_state {
57 	struct dvb_frontend		*frontend;
58 	struct i2c_adapter		*i2c;
59 	const struct stv6110x_config	*config;
60 	u8				regs[8];
61 
62 	struct stv6110x_devctl	*devctl;
63 };
64 
65 #endif /* __STV6110x_PRIV_H */
66