1 /*
2 	STV6110(A) Silicon tuner driver
3 
4 	Copyright (C) Manu Abraham <abraham.manu@gmail.com>
5 
6 	Copyright (C) ST Microelectronics
7 
8 	This program is free software; you can redistribute it and/or modify
9 	it under the terms of the GNU General Public License as published by
10 	the Free Software Foundation; either version 2 of the License, or
11 	(at your option) any later version.
12 
13 	This program is distributed in the hope that it will be useful,
14 	but WITHOUT ANY WARRANTY; without even the implied warranty of
15 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 	GNU General Public License for more details.
17 
18 	You should have received a copy of the GNU General Public License
19 	along with this program; if not, write to the Free Software
20 	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22 
23 #ifndef __STV6110x_PRIV_H
24 #define __STV6110x_PRIV_H
25 
26 #define FE_ERROR				0
27 #define FE_NOTICE				1
28 #define FE_INFO					2
29 #define FE_DEBUG				3
30 #define FE_DEBUGREG				4
31 
32 #define dprintk(__y, __z, format, arg...) do {						\
33 	if (__z) {									\
34 		if	((verbose > FE_ERROR) && (verbose > __y))			\
35 			printk(KERN_ERR "%s: " format "\n", __func__ , ##arg);		\
36 		else if	((verbose > FE_NOTICE) && (verbose > __y))			\
37 			printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg);	\
38 		else if ((verbose > FE_INFO) && (verbose > __y))			\
39 			printk(KERN_INFO "%s: " format "\n", __func__ , ##arg);		\
40 		else if ((verbose > FE_DEBUG) && (verbose > __y))			\
41 			printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg);	\
42 	} else {									\
43 		if (verbose > __y)							\
44 			printk(format, ##arg);						\
45 	}										\
46 } while (0)
47 
48 
49 #define STV6110x_SETFIELD(mask, bitf, val)				\
50 	(mask = (mask & (~(((1 << STV6110x_WIDTH_##bitf) - 1) <<	\
51 				  STV6110x_OFFST_##bitf))) |		\
52 			  (val << STV6110x_OFFST_##bitf))
53 
54 #define STV6110x_GETFIELD(bitf, val)					\
55 	((val >> STV6110x_OFFST_##bitf) &				\
56 	((1 << STV6110x_WIDTH_##bitf) - 1))
57 
58 #define MAKEWORD16(a, b)			(((a) << 8) | (b))
59 
60 #define LSB(x)					((x & 0xff))
61 #define MSB(y)					((y >> 8) & 0xff)
62 
63 #define TRIALS					10
64 #define R_DIV(__div)				(1 << (__div + 1))
65 #define REFCLOCK_kHz				(stv6110x->config->refclk /    1000)
66 #define REFCLOCK_MHz				(stv6110x->config->refclk / 1000000)
67 
68 struct stv6110x_state {
69 	struct i2c_adapter		*i2c;
70 	const struct stv6110x_config	*config;
71 	u8				regs[8];
72 
73 	const struct stv6110x_devctl	*devctl;
74 };
75 
76 #endif /* __STV6110x_PRIV_H */
77