blob: 8552c6ae0d1f046a1ca6d2071731e2ea53db613e [file] [log] [blame]
Michael Krufky6ca04de2007-11-23 16:52:15 -03001/*
2 tda18271-priv.h - private header for the NXP TDA18271 silicon tuner
3
4 Copyright (C) 2007 Michael Krufky (mkrufky@linuxtv.org)
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 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19*/
20
21#ifndef __TDA18271_PRIV_H__
22#define __TDA18271_PRIV_H__
23
Michael Krufkyb5f3e1e2007-12-02 16:36:05 -030024#include <linux/kernel.h>
Michael Krufky6ca04de2007-11-23 16:52:15 -030025#include <linux/types.h>
Michael Krufkyd3714212007-12-24 14:38:41 -030026#include "tda18271.h"
Michael Krufky6ca04de2007-11-23 16:52:15 -030027
28#define R_ID 0x00 /* ID byte */
29#define R_TM 0x01 /* Thermo byte */
30#define R_PL 0x02 /* Power level byte */
31#define R_EP1 0x03 /* Easy Prog byte 1 */
32#define R_EP2 0x04 /* Easy Prog byte 2 */
33#define R_EP3 0x05 /* Easy Prog byte 3 */
34#define R_EP4 0x06 /* Easy Prog byte 4 */
35#define R_EP5 0x07 /* Easy Prog byte 5 */
36#define R_CPD 0x08 /* Cal Post-Divider byte */
37#define R_CD1 0x09 /* Cal Divider byte 1 */
38#define R_CD2 0x0a /* Cal Divider byte 2 */
39#define R_CD3 0x0b /* Cal Divider byte 3 */
40#define R_MPD 0x0c /* Main Post-Divider byte */
41#define R_MD1 0x0d /* Main Divider byte 1 */
42#define R_MD2 0x0e /* Main Divider byte 2 */
43#define R_MD3 0x0f /* Main Divider byte 3 */
44#define R_EB1 0x10 /* Extended byte 1 */
45#define R_EB2 0x11 /* Extended byte 2 */
46#define R_EB3 0x12 /* Extended byte 3 */
47#define R_EB4 0x13 /* Extended byte 4 */
48#define R_EB5 0x14 /* Extended byte 5 */
49#define R_EB6 0x15 /* Extended byte 6 */
50#define R_EB7 0x16 /* Extended byte 7 */
51#define R_EB8 0x17 /* Extended byte 8 */
52#define R_EB9 0x18 /* Extended byte 9 */
53#define R_EB10 0x19 /* Extended byte 10 */
54#define R_EB11 0x1a /* Extended byte 11 */
55#define R_EB12 0x1b /* Extended byte 12 */
56#define R_EB13 0x1c /* Extended byte 13 */
57#define R_EB14 0x1d /* Extended byte 14 */
58#define R_EB15 0x1e /* Extended byte 15 */
59#define R_EB16 0x1f /* Extended byte 16 */
60#define R_EB17 0x20 /* Extended byte 17 */
61#define R_EB18 0x21 /* Extended byte 18 */
62#define R_EB19 0x22 /* Extended byte 19 */
63#define R_EB20 0x23 /* Extended byte 20 */
64#define R_EB21 0x24 /* Extended byte 21 */
65#define R_EB22 0x25 /* Extended byte 22 */
66#define R_EB23 0x26 /* Extended byte 23 */
67
68#define TDA18271_NUM_REGS 39
69
Michael Krufkyd3714212007-12-24 14:38:41 -030070/*---------------------------------------------------------------------*/
71
Michael Krufky255b5112008-01-01 22:52:09 -030072struct tda18271_rf_tracking_filter_cal {
73 u32 rfmax;
74 u8 rfband;
75 u32 rf1_def;
76 u32 rf2_def;
77 u32 rf3_def;
78 u32 rf1;
79 u32 rf2;
80 u32 rf3;
81 int rf_a1;
82 int rf_b1;
83 int rf_a2;
84 int rf_b2;
85};
86
87struct tda18271_std_map_item {
88 u32 if_freq;
89 u8 std_bits;
90};
91
92struct tda18271_std_map {
93 struct tda18271_std_map_item atv_b;
94 struct tda18271_std_map_item atv_dk;
95 struct tda18271_std_map_item atv_gh;
96 struct tda18271_std_map_item atv_i;
97 struct tda18271_std_map_item atv_l;
98 struct tda18271_std_map_item atv_lc;
99 struct tda18271_std_map_item atv_mn;
100 struct tda18271_std_map_item atsc_6;
101 struct tda18271_std_map_item dvbt_6;
102 struct tda18271_std_map_item dvbt_7;
103 struct tda18271_std_map_item dvbt_8;
104 struct tda18271_std_map_item qam_6;
105 struct tda18271_std_map_item qam_8;
106};
107
Michael Krufkyd3714212007-12-24 14:38:41 -0300108enum tda18271_mode {
109 TDA18271_ANALOG,
110 TDA18271_DIGITAL,
111};
112
Michael Krufky255b5112008-01-01 22:52:09 -0300113struct tda18271_map_layout;
114
115enum tda18271_ver {
116 TDA18271HDC1,
117 TDA18271HDC2,
118};
119
Michael Krufkyd3714212007-12-24 14:38:41 -0300120struct tda18271_priv {
121 u8 i2c_addr;
122 struct i2c_adapter *i2c_adap;
123 unsigned char tda18271_regs[TDA18271_NUM_REGS];
124
125 enum tda18271_mode mode;
126 enum tda18271_i2c_gate gate;
Michael Krufky255b5112008-01-01 22:52:09 -0300127 enum tda18271_ver id;
128
129 unsigned int cal_initialized:1;
130
131 struct tda18271_std_map *std;
132 struct tda18271_map_layout *maps;
133 struct tda18271_rf_tracking_filter_cal rf_cal_state[8];
134
135 int (*tune) (struct dvb_frontend *fe,
136 u32 ifc, u32 freq, u32 bw, u8 std);
Michael Krufkyd3714212007-12-24 14:38:41 -0300137
138 u32 frequency;
139 u32 bandwidth;
140};
141
142/*---------------------------------------------------------------------*/
143
Michael Krufkyb5f3e1e2007-12-02 16:36:05 -0300144extern int tda18271_debug;
Michael Krufky6ca04de2007-11-23 16:52:15 -0300145
Michael Krufkyb5f3e1e2007-12-02 16:36:05 -0300146#define DBG_INFO 1
147#define DBG_MAP 2
148#define DBG_REG 4
Michael Krufky255b5112008-01-01 22:52:09 -0300149#define DBG_ADV 8
Michael Krufky6ca04de2007-11-23 16:52:15 -0300150
Michael Krufky182519f2007-12-25 15:10:11 -0300151#define tda_printk(kern, fmt, arg...) \
152 printk(kern "%s: " fmt, __FUNCTION__, ##arg)
153
154#define dprintk(kern, lvl, fmt, arg...) do {\
155 if (tda18271_debug & lvl) \
156 tda_printk(kern, fmt, ##arg); } while (0)
157
158#define tda_info(fmt, arg...) printk(KERN_INFO fmt, ##arg)
159#define tda_warn(fmt, arg...) tda_printk(KERN_WARNING, fmt, ##arg)
160#define tda_err(fmt, arg...) tda_printk(KERN_ERR, fmt, ##arg)
161#define tda_dbg(fmt, arg...) dprintk(KERN_DEBUG, DBG_INFO, fmt, ##arg)
162#define tda_map(fmt, arg...) dprintk(KERN_DEBUG, DBG_MAP, fmt, ##arg)
163#define tda_reg(fmt, arg...) dprintk(KERN_DEBUG, DBG_REG, fmt, ##arg)
Michael Krufkyb5f3e1e2007-12-02 16:36:05 -0300164
165/*---------------------------------------------------------------------*/
166
Michael Krufky2f27dfc2007-12-25 00:39:37 -0300167enum tda18271_map_type {
168 /* tda18271_pll_map */
169 MAIN_PLL,
170 CAL_PLL,
171 /* tda18271_map */
172 RF_CAL,
173 RF_CAL_KMCO,
Michael Krufky255b5112008-01-01 22:52:09 -0300174 RF_CAL_DC_OVER_DT,
Michael Krufky2f27dfc2007-12-25 00:39:37 -0300175 BP_FILTER,
176 RF_BAND,
177 GAIN_TAPER,
178 IR_MEASURE,
179};
Michael Krufkyb5f3e1e2007-12-02 16:36:05 -0300180
Michael Krufky255b5112008-01-01 22:52:09 -0300181extern int tda18271_lookup_pll_map(struct dvb_frontend *fe,
182 enum tda18271_map_type map_type,
Michael Krufky2f27dfc2007-12-25 00:39:37 -0300183 u32 *freq, u8 *post_div, u8 *div);
Michael Krufky255b5112008-01-01 22:52:09 -0300184extern int tda18271_lookup_map(struct dvb_frontend *fe,
185 enum tda18271_map_type map_type,
Michael Krufky2f27dfc2007-12-25 00:39:37 -0300186 u32 *freq, u8 *val);
Michael Krufky6ca04de2007-11-23 16:52:15 -0300187
Michael Krufky255b5112008-01-01 22:52:09 -0300188extern int tda18271_lookup_thermometer(struct dvb_frontend *fe);
189
190extern int tda18271_lookup_rf_band(struct dvb_frontend *fe,
191 u32 *freq, u8 *rf_band);
192
193extern int tda18271_lookup_cid_target(struct dvb_frontend *fe,
194 u32 *freq, u8 *cid_target,
195 u16 *count_limit);
196
197extern int tda18271_assign_map_layout(struct dvb_frontend *fe);
198
Michael Krufky6ca04de2007-11-23 16:52:15 -0300199#endif /* __TDA18271_PRIV_H__ */
200
201/*
202 * Overrides for Emacs so that we follow Linus's tabbing style.
203 * ---------------------------------------------------------------------------
204 * Local variables:
205 * c-basic-offset: 8
206 * End:
207 */