]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/media/tuners/e4000_priv.h
[media] e4000: implement controls via v4l2 control framework
[karo-tx-linux.git] / drivers / media / tuners / e4000_priv.h
1 /*
2  * Elonics E4000 silicon tuner driver
3  *
4  * Copyright (C) 2012 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 E4000_PRIV_H
22 #define E4000_PRIV_H
23
24 #include "e4000.h"
25 #include <media/v4l2-ctrls.h>
26 #include <media/v4l2-subdev.h>
27
28 struct e4000_priv {
29         struct i2c_client *client;
30         u32 clock;
31         struct dvb_frontend *fe;
32         struct v4l2_subdev sd;
33
34         /* Controls */
35         struct v4l2_ctrl_handler hdl;
36         struct v4l2_ctrl *bandwidth_auto;
37         struct v4l2_ctrl *bandwidth;
38         struct v4l2_ctrl *lna_gain_auto;
39         struct v4l2_ctrl *lna_gain;
40         struct v4l2_ctrl *mixer_gain_auto;
41         struct v4l2_ctrl *mixer_gain;
42         struct v4l2_ctrl *if_gain_auto;
43         struct v4l2_ctrl *if_gain;
44 };
45
46 struct e4000_pll {
47         u32 freq;
48         u8 div;
49         u8 mul;
50 };
51
52 static const struct e4000_pll e4000_pll_lut[] = {
53 /*                                      VCO min    VCO max */
54         {   72400000, 0x0f, 48 }, /* .......... 3475200000 */
55         {   81200000, 0x0e, 40 }, /* 2896000000 3248000000 */
56         {  108300000, 0x0d, 32 }, /* 2598400000 3465600000 */
57         {  162500000, 0x0c, 24 }, /* 2599200000 3900000000 */
58         {  216600000, 0x0b, 16 }, /* 2600000000 3465600000 */
59         {  325000000, 0x0a, 12 }, /* 2599200000 3900000000 */
60         {  350000000, 0x09,  8 }, /* 2600000000 2800000000 */
61         {  432000000, 0x03,  8 }, /* 2800000000 3456000000 */
62         {  667000000, 0x02,  6 }, /* 2592000000 4002000000 */
63         { 1200000000, 0x01,  4 }, /* 2668000000 4800000000 */
64         { 0xffffffff, 0x00,  2 }, /* 2400000000 .......... */
65 };
66
67 struct e4000_lna_filter {
68         u32 freq;
69         u8 val;
70 };
71
72 static const struct e4000_lna_filter e400_lna_filter_lut[] = {
73         {  370000000,  0 },
74         {  392500000,  1 },
75         {  415000000,  2 },
76         {  437500000,  3 },
77         {  462500000,  4 },
78         {  490000000,  5 },
79         {  522500000,  6 },
80         {  557500000,  7 },
81         {  595000000,  8 },
82         {  642500000,  9 },
83         {  695000000, 10 },
84         {  740000000, 11 },
85         {  800000000, 12 },
86         {  865000000, 13 },
87         {  930000000, 14 },
88         { 1000000000, 15 },
89         { 1310000000,  0 },
90         { 1340000000,  1 },
91         { 1385000000,  2 },
92         { 1427500000,  3 },
93         { 1452500000,  4 },
94         { 1475000000,  5 },
95         { 1510000000,  6 },
96         { 1545000000,  7 },
97         { 1575000000,  8 },
98         { 1615000000,  9 },
99         { 1650000000, 10 },
100         { 1670000000, 11 },
101         { 1690000000, 12 },
102         { 1710000000, 13 },
103         { 1735000000, 14 },
104         { 0xffffffff, 15 },
105 };
106
107 struct e4000_band {
108         u32 freq;
109         u8 reg07_val;
110         u8 reg78_val;
111 };
112
113 static const struct e4000_band e4000_band_lut[] = {
114         {  140000000, 0x01, 0x03 },
115         {  350000000, 0x03, 0x03 },
116         { 1000000000, 0x05, 0x03 },
117         { 0xffffffff, 0x07, 0x00 },
118 };
119
120 struct e4000_if_filter {
121         u32 freq;
122         u8 reg11_val;
123         u8 reg12_val;
124 };
125
126 static const struct e4000_if_filter e4000_if_filter_lut[] = {
127         {    4300000, 0xfd, 0x1f },
128         {    4400000, 0xfd, 0x1e },
129         {    4480000, 0xfc, 0x1d },
130         {    4560000, 0xfc, 0x1c },
131         {    4600000, 0xfc, 0x1b },
132         {    4800000, 0xfc, 0x1a },
133         {    4900000, 0xfc, 0x19 },
134         {    5000000, 0xfc, 0x18 },
135         {    5100000, 0xfc, 0x17 },
136         {    5200000, 0xfc, 0x16 },
137         {    5400000, 0xfc, 0x15 },
138         {    5500000, 0xfc, 0x14 },
139         {    5600000, 0xfc, 0x13 },
140         {    5800000, 0xfb, 0x12 },
141         {    5900000, 0xfb, 0x11 },
142         {    6000000, 0xfb, 0x10 },
143         {    6200000, 0xfb, 0x0f },
144         {    6400000, 0xfa, 0x0e },
145         {    6600000, 0xfa, 0x0d },
146         {    6800000, 0xf9, 0x0c },
147         {    7200000, 0xf9, 0x0b },
148         {    7400000, 0xf9, 0x0a },
149         {    7600000, 0xf8, 0x09 },
150         {    7800000, 0xf8, 0x08 },
151         {    8200000, 0xf8, 0x07 },
152         {    8600000, 0xf7, 0x06 },
153         {    8800000, 0xf7, 0x05 },
154         {    9200000, 0xf7, 0x04 },
155         {    9600000, 0xf6, 0x03 },
156         {   10000000, 0xf6, 0x02 },
157         {   10600000, 0xf5, 0x01 },
158         {   11000000, 0xf5, 0x00 },
159         { 0xffffffff, 0x00, 0x20 },
160 };
161
162 struct e4000_if_gain {
163         u8 reg16_val;
164         u8 reg17_val;
165 };
166
167 static const struct e4000_if_gain e4000_if_gain_lut[] = {
168         {0x00, 0x00},
169         {0x20, 0x00},
170         {0x40, 0x00},
171         {0x02, 0x00},
172         {0x22, 0x00},
173         {0x42, 0x00},
174         {0x04, 0x00},
175         {0x24, 0x00},
176         {0x44, 0x00},
177         {0x01, 0x00},
178         {0x21, 0x00},
179         {0x41, 0x00},
180         {0x03, 0x00},
181         {0x23, 0x00},
182         {0x43, 0x00},
183         {0x05, 0x00},
184         {0x25, 0x00},
185         {0x45, 0x00},
186         {0x07, 0x00},
187         {0x27, 0x00},
188         {0x47, 0x00},
189         {0x0f, 0x00},
190         {0x2f, 0x00},
191         {0x4f, 0x00},
192         {0x17, 0x00},
193         {0x37, 0x00},
194         {0x57, 0x00},
195         {0x1f, 0x00},
196         {0x3f, 0x00},
197         {0x5f, 0x00},
198         {0x1f, 0x01},
199         {0x3f, 0x01},
200         {0x5f, 0x01},
201         {0x1f, 0x02},
202         {0x3f, 0x02},
203         {0x5f, 0x02},
204         {0x1f, 0x03},
205         {0x3f, 0x03},
206         {0x5f, 0x03},
207         {0x1f, 0x04},
208         {0x3f, 0x04},
209         {0x5f, 0x04},
210         {0x1f, 0x0c},
211         {0x3f, 0x0c},
212         {0x5f, 0x0c},
213         {0x1f, 0x14},
214         {0x3f, 0x14},
215         {0x5f, 0x14},
216         {0x1f, 0x1c},
217         {0x3f, 0x1c},
218         {0x5f, 0x1c},
219         {0x1f, 0x24},
220         {0x3f, 0x24},
221         {0x5f, 0x24},
222         {0x7f, 0x24},
223 };
224
225 #endif