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