blob: 2437d51bdae348ea383b02bf21ebbe248fd7f7cb [file] [log] [blame]
Antti Palosaari27cfc852011-04-07 16:27:43 -03001/*
2 * Sony CXD2820R demodulator driver
3 *
4 * Copyright (C) 2010 Antti Palosaari <crope@iki.fi>
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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21
22#ifndef CXD2820R_PRIV_H
23#define CXD2820R_PRIV_H
24
Steve Kerrison9ac51c52011-05-02 18:19:13 -030025#include <linux/dvb/version.h>
Antti Palosaari27cfc852011-04-07 16:27:43 -030026#include "dvb_frontend.h"
27#include "dvb_math.h"
28#include "cxd2820r.h"
29
30#define LOG_PREFIX "cxd2820r"
31
32#undef dbg
33#define dbg(f, arg...) \
34 if (cxd2820r_debug) \
35 printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
36#undef err
37#define err(f, arg...) printk(KERN_ERR LOG_PREFIX": " f "\n" , ## arg)
38#undef info
39#define info(f, arg...) printk(KERN_INFO LOG_PREFIX": " f "\n" , ## arg)
40#undef warn
41#define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg)
42
43/*
44 * FIXME: These are totally wrong and must be added properly to the API.
45 * Only temporary solution in order to get driver compile.
46 */
47#define SYS_DVBT2 SYS_DAB
48#define TRANSMISSION_MODE_1K 0
49#define TRANSMISSION_MODE_16K 0
50#define TRANSMISSION_MODE_32K 0
51#define GUARD_INTERVAL_1_128 0
52#define GUARD_INTERVAL_19_128 0
53#define GUARD_INTERVAL_19_256 0
54
55struct reg_val_mask {
56 u32 reg;
57 u8 val;
58 u8 mask;
59};
60
61struct cxd2820r_priv {
62 struct i2c_adapter *i2c;
63 struct dvb_frontend fe[2];
64 struct cxd2820r_config cfg;
65 struct i2c_adapter tuner_i2c_adapter;
66
67 struct mutex fe_lock; /* FE lock */
68 int active_fe:2; /* FE lock, -1=NONE, 0=DVB-T/T2, 1=DVB-C */
69
70 int ber_running:1;
71
72 u8 bank[2];
73 u8 gpio[3];
Steve Kerrison9ac51c52011-05-02 18:19:13 -030074
Antti Palosaari27cfc852011-04-07 16:27:43 -030075 fe_delivery_system_t delivery_system;
76};
77
Steve Kerrison9ac51c52011-05-02 18:19:13 -030078/* cxd2820r_core.c */
79
80extern int cxd2820r_debug;
81
82int cxd2820r_gpio(struct dvb_frontend *fe);
83
84int cxd2820r_wr_reg_mask(struct cxd2820r_priv *priv, u32 reg, u8 val,
85 u8 mask);
86
87int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
88 int len);
89
90u32 cxd2820r_div_u64_round_closest(u64 dividend, u32 divisor);
91
92int cxd2820r_wr_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
93 int len);
94
95int cxd2820r_rd_regs(struct cxd2820r_priv *priv, u32 reginfo, u8 *val,
96 int len);
97
98int cxd2820r_wr_reg(struct cxd2820r_priv *priv, u32 reg, u8 val);
99
100int cxd2820r_rd_reg(struct cxd2820r_priv *priv, u32 reg, u8 *val);
101
102/* cxd2820r_c.c */
103
104int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
105 struct dvb_frontend_parameters *p);
106
107int cxd2820r_set_frontend_c(struct dvb_frontend *fe,
108 struct dvb_frontend_parameters *params);
109
110int cxd2820r_read_status_c(struct dvb_frontend *fe, fe_status_t *status);
111
112int cxd2820r_read_ber_c(struct dvb_frontend *fe, u32 *ber);
113
114int cxd2820r_read_signal_strength_c(struct dvb_frontend *fe, u16 *strength);
115
116int cxd2820r_read_snr_c(struct dvb_frontend *fe, u16 *snr);
117
118int cxd2820r_read_ucblocks_c(struct dvb_frontend *fe, u32 *ucblocks);
119
120int cxd2820r_init_c(struct dvb_frontend *fe);
121
122int cxd2820r_sleep_c(struct dvb_frontend *fe);
123
124int cxd2820r_get_tune_settings_c(struct dvb_frontend *fe,
125 struct dvb_frontend_tune_settings *s);
126
127/* cxd2820r_t.c */
128
129int cxd2820r_get_frontend_t(struct dvb_frontend *fe,
130 struct dvb_frontend_parameters *p);
131
132int cxd2820r_set_frontend_t(struct dvb_frontend *fe,
133 struct dvb_frontend_parameters *params);
134
135int cxd2820r_read_status_t(struct dvb_frontend *fe, fe_status_t *status);
136
137int cxd2820r_read_ber_t(struct dvb_frontend *fe, u32 *ber);
138
139int cxd2820r_read_signal_strength_t(struct dvb_frontend *fe, u16 *strength);
140
141int cxd2820r_read_snr_t(struct dvb_frontend *fe, u16 *snr);
142
143int cxd2820r_read_ucblocks_t(struct dvb_frontend *fe, u32 *ucblocks);
144
145int cxd2820r_init_t(struct dvb_frontend *fe);
146
147int cxd2820r_sleep_t(struct dvb_frontend *fe);
148
149int cxd2820r_get_tune_settings_t(struct dvb_frontend *fe,
150 struct dvb_frontend_tune_settings *s);
151
152/* cxd2820r_t2.c */
153
154int cxd2820r_get_frontend_t2(struct dvb_frontend *fe,
155 struct dvb_frontend_parameters *p);
156
157int cxd2820r_set_frontend_t2(struct dvb_frontend *fe,
158 struct dvb_frontend_parameters *params);
159
160int cxd2820r_read_status_t2(struct dvb_frontend *fe, fe_status_t *status);
161
162int cxd2820r_read_ber_t2(struct dvb_frontend *fe, u32 *ber);
163
164int cxd2820r_read_signal_strength_t2(struct dvb_frontend *fe, u16 *strength);
165
166int cxd2820r_read_snr_t2(struct dvb_frontend *fe, u16 *snr);
167
168int cxd2820r_read_ucblocks_t2(struct dvb_frontend *fe, u32 *ucblocks);
169
170int cxd2820r_init_t2(struct dvb_frontend *fe);
171
172int cxd2820r_sleep_t2(struct dvb_frontend *fe);
173
174int cxd2820r_get_tune_settings_t2(struct dvb_frontend *fe,
175 struct dvb_frontend_tune_settings *s);
176
Antti Palosaari27cfc852011-04-07 16:27:43 -0300177#endif /* CXD2820R_PRIV_H */