Merge branch 'akpm' (Andrew's patch-bomb)
[firefly-linux-kernel-4.4.55.git] / drivers / media / dvb / frontends / tda10071_priv.h
1 /*
2  * NXP TDA10071 + Conexant CX24118A DVB-S/S2 demodulator + tuner driver
3  *
4  * Copyright (C) 2011 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 #ifndef TDA10071_PRIV
22 #define TDA10071_PRIV
23
24 #include "dvb_frontend.h"
25 #include "tda10071.h"
26 #include <linux/firmware.h>
27
28 #define LOG_PREFIX "tda10071"
29
30 #undef dbg
31 #define dbg(f, arg...) \
32         if (tda10071_debug) \
33                 printk(KERN_INFO   LOG_PREFIX": " f "\n" , ## arg)
34 #undef err
35 #define err(f, arg...)  printk(KERN_ERR     LOG_PREFIX": " f "\n" , ## arg)
36 #undef info
37 #define info(f, arg...) printk(KERN_INFO    LOG_PREFIX": " f "\n" , ## arg)
38 #undef warn
39 #define warn(f, arg...) printk(KERN_WARNING LOG_PREFIX": " f "\n" , ## arg)
40
41 struct tda10071_priv {
42         struct i2c_adapter *i2c;
43         struct dvb_frontend fe;
44         struct tda10071_config cfg;
45
46         u8 meas_count[2];
47         u32 ber;
48         u32 ucb;
49         fe_status_t fe_status;
50         fe_delivery_system_t delivery_system;
51         bool warm; /* FW running */
52 };
53
54 static struct tda10071_modcod {
55         fe_delivery_system_t delivery_system;
56         fe_modulation_t modulation;
57         fe_code_rate_t fec;
58         u8 val;
59 } TDA10071_MODCOD[] = {
60         /* NBC-QPSK */
61         { SYS_DVBS2, QPSK,  FEC_AUTO, 0x00 },
62         { SYS_DVBS2, QPSK,  FEC_1_2,  0x04 },
63         { SYS_DVBS2, QPSK,  FEC_3_5,  0x05 },
64         { SYS_DVBS2, QPSK,  FEC_2_3,  0x06 },
65         { SYS_DVBS2, QPSK,  FEC_3_4,  0x07 },
66         { SYS_DVBS2, QPSK,  FEC_4_5,  0x08 },
67         { SYS_DVBS2, QPSK,  FEC_5_6,  0x09 },
68         { SYS_DVBS2, QPSK,  FEC_8_9,  0x0a },
69         { SYS_DVBS2, QPSK,  FEC_9_10, 0x0b },
70         /* 8PSK */
71         { SYS_DVBS2, PSK_8, FEC_3_5,  0x0c },
72         { SYS_DVBS2, PSK_8, FEC_2_3,  0x0d },
73         { SYS_DVBS2, PSK_8, FEC_3_4,  0x0e },
74         { SYS_DVBS2, PSK_8, FEC_5_6,  0x0f },
75         { SYS_DVBS2, PSK_8, FEC_8_9,  0x10 },
76         { SYS_DVBS2, PSK_8, FEC_9_10, 0x11 },
77         /* QPSK */
78         { SYS_DVBS,  QPSK,  FEC_AUTO, 0x2d },
79         { SYS_DVBS,  QPSK,  FEC_1_2,  0x2e },
80         { SYS_DVBS,  QPSK,  FEC_2_3,  0x2f },
81         { SYS_DVBS,  QPSK,  FEC_3_4,  0x30 },
82         { SYS_DVBS,  QPSK,  FEC_5_6,  0x31 },
83         { SYS_DVBS,  QPSK,  FEC_7_8,  0x32 },
84 };
85
86 struct tda10071_reg_val_mask {
87         u8 reg;
88         u8 val;
89         u8 mask;
90 };
91
92 /* firmware filename */
93 #define TDA10071_DEFAULT_FIRMWARE      "dvb-fe-tda10071.fw"
94
95 /* firmware commands */
96 #define CMD_DEMOD_INIT          0x10
97 #define CMD_CHANGE_CHANNEL      0x11
98 #define CMD_MPEG_CONFIG         0x13
99 #define CMD_TUNER_INIT          0x15
100 #define CMD_GET_AGCACC          0x1a
101
102 #define CMD_LNB_CONFIG          0x20
103 #define CMD_LNB_SEND_DISEQC     0x21
104 #define CMD_LNB_SET_DC_LEVEL    0x22
105 #define CMD_LNB_PCB_CONFIG      0x23
106 #define CMD_LNB_SEND_TONEBURST  0x24
107 #define CMD_LNB_UPDATE_REPLY    0x25
108
109 #define CMD_GET_FW_VERSION      0x35
110 #define CMD_SET_SLEEP_MODE      0x36
111 #define CMD_BER_CONTROL         0x3e
112 #define CMD_BER_UPDATE_COUNTERS 0x3f
113
114 /* firmare command struct */
115 #define TDA10071_ARGLEN      0x1e
116 struct tda10071_cmd {
117         u8 args[TDA10071_ARGLEN];
118         u8 len;
119 };
120
121
122 #endif /* TDA10071_PRIV */