summaryrefslogtreecommitdiff
path: root/drivers/media/dvb/frontends/drx397xD.h
blob: ba05d17290c633e51fdc30e0dc0055d9702affeb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
 *  Driver for Micronas DVB-T drx397xD demodulator
 *
 *  Copyright (C) 2007 Henk vergonet <Henk.Vergonet@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
 */

#ifndef _DRX397XD_H_INCLUDED
#define _DRX397XD_H_INCLUDED

#include <linux/dvb/frontend.h>

#define DRX_F_STEPSIZE	166667
#define DRX_F_OFFSET	36000000

#define I2C_ADR_C0(x) \
(	cpu_to_le32( \
		(u32)( \
			(((u32)(x) & (u32)0x000000ffUL)      ) | \
			(((u32)(x) & (u32)0x0000ff00UL) << 16) | \
			(((u32)(x) & (u32)0x0fff0000UL) >>  8) | \
			 (	     (u32)0x00c00000UL)          \
		      )) \
)

#define I2C_ADR_E0(x) \
(	cpu_to_le32( \
		(u32)( \
			(((u32)(x) & (u32)0x000000ffUL)      ) | \
			(((u32)(x) & (u32)0x0000ff00UL) << 16) | \
			(((u32)(x) & (u32)0x0fff0000UL) >>  8) | \
			 (	     (u32)0x00e00000UL)          \
		      )) \
)

struct drx397xD_CfgRfAgc	/* 0x7c */
{
	int d00;	/* 2 */
	u16 w04;
	u16 w06;
};

struct drx397xD_CfgIfAgc	/* 0x68 */
{
	int d00;	/* 0 */
	u16 w04;	/* 0 */
	u16 w06;
	u16 w08;
	u16 w0A;
	u16 w0C;
};

struct drx397xD_s20 {
	int d04;
	u32 d18;
	u32 d1C;
	u32 d20;
	u32 d14;
	u32 d24;
	u32 d0C;
	u32 d08;
};

struct drx397xD_config
{
	/* demodulator's I2C address */
	u8	demod_address;		/* 0x0f */

	struct drx397xD_CfgIfAgc  ifagc;  /* 0x68 */
	struct drx397xD_CfgRfAgc  rfagc;  /* 0x7c */
	u32	s20d24;

	/* HI_CfgCommand parameters */
	u16	w50, w52, /* w54, */ w56;

	int	d5C;
	int	d60;
	int	d48;
	int	d28;

	u32	f_if;	/* d14: intermediate frequency [Hz]		*/
			/*	36000000 on Cinergy 2400i DT		*/
			/*	42800000 on Pinnacle Hybrid PRO 330e	*/

	u16	f_osc;	/* s66: 48000 oscillator frequency [kHz]	*/

	u16	w92;	/* 20000 */

	u16	wA0;
	u16	w98;
	u16	w9A;

	u16	w9C;	/* 0xe0 */
	u16	w9E;	/* 0x00 */

	/* used for signal strength calculations in
	   drx397x_read_signal_strength
	*/
	u16	ss78;	// 2200
	u16	ss7A;	// 150
	u16	ss76;	// 820
};

#if defined(CONFIG_DVB_DRX397XD) || (defined(CONFIG_DVB_DRX397XD_MODULE) && defined(MODULE))
extern struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
					   struct i2c_adapter *i2c);
#else
static inline struct dvb_frontend* drx397xD_attach(const struct drx397xD_config *config,
					   struct i2c_adapter *i2c)
{
	printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
	return NULL;
}
#endif /* CONFIG_DVB_DRX397XD */

#endif /* _DRX397XD_H_INCLUDED */