aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/tda18271-tables.c
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2007-12-02 14:36:05 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:03:13 -0500
commitb5f3e1e153b60f7bc338cdd6eefacd59c2dfb375 (patch)
tree75a18d39c89b415c10aaa2152730944135e5ff7c /drivers/media/dvb/frontends/tda18271-tables.c
parentaaeccba68a60eedee5fe90f9e1478367b1f97345 (diff)
V4L/DVB (6727): tda18271: convert table lookup loops to functions
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/dvb/frontends/tda18271-tables.c')
-rw-r--r--drivers/media/dvb/frontends/tda18271-tables.c106
1 files changed, 98 insertions, 8 deletions
diff --git a/drivers/media/dvb/frontends/tda18271-tables.c b/drivers/media/dvb/frontends/tda18271-tables.c
index d65d3411e362..65387bb059eb 100644
--- a/drivers/media/dvb/frontends/tda18271-tables.c
+++ b/drivers/media/dvb/frontends/tda18271-tables.c
@@ -20,7 +20,20 @@
20 20
21#include "tda18271-priv.h" 21#include "tda18271-priv.h"
22 22
23struct tda18271_pll_map tda18271_main_pll[] = { 23struct tda18271_pll_map {
24 u32 lomax;
25 u8 pd; /* post div */
26 u8 d; /* div */
27};
28
29struct tda18271_map {
30 u32 rfmax;
31 u8 val;
32};
33
34/*---------------------------------------------------------------------*/
35
36static struct tda18271_pll_map tda18271_main_pll[] = {
24 { .lomax = 32000, .pd = 0x5f, .d = 0xf0 }, 37 { .lomax = 32000, .pd = 0x5f, .d = 0xf0 },
25 { .lomax = 35000, .pd = 0x5e, .d = 0xe0 }, 38 { .lomax = 35000, .pd = 0x5e, .d = 0xe0 },
26 { .lomax = 37000, .pd = 0x5d, .d = 0xd0 }, 39 { .lomax = 37000, .pd = 0x5d, .d = 0xd0 },
@@ -64,7 +77,7 @@ struct tda18271_pll_map tda18271_main_pll[] = {
64 { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ 77 { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */
65}; 78};
66 79
67struct tda18271_pll_map tda18271_cal_pll[] = { 80static struct tda18271_pll_map tda18271_cal_pll[] = {
68 { .lomax = 33000, .pd = 0xdd, .d = 0xd0 }, 81 { .lomax = 33000, .pd = 0xdd, .d = 0xd0 },
69 { .lomax = 36000, .pd = 0xdc, .d = 0xc0 }, 82 { .lomax = 36000, .pd = 0xdc, .d = 0xc0 },
70 { .lomax = 40000, .pd = 0xdb, .d = 0xb0 }, 83 { .lomax = 40000, .pd = 0xdb, .d = 0xb0 },
@@ -103,7 +116,7 @@ struct tda18271_pll_map tda18271_cal_pll[] = {
103 { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */ 116 { .lomax = 0, .pd = 0x00, .d = 0x00 }, /* end */
104}; 117};
105 118
106struct tda18271_map tda18271_bp_filter[] = { 119static struct tda18271_map tda18271_bp_filter[] = {
107 { .rfmax = 62000, .val = 0x00 }, 120 { .rfmax = 62000, .val = 0x00 },
108 { .rfmax = 84000, .val = 0x01 }, 121 { .rfmax = 84000, .val = 0x01 },
109 { .rfmax = 100000, .val = 0x02 }, 122 { .rfmax = 100000, .val = 0x02 },
@@ -114,7 +127,7 @@ struct tda18271_map tda18271_bp_filter[] = {
114 { .rfmax = 0, .val = 0x00 }, /* end */ 127 { .rfmax = 0, .val = 0x00 }, /* end */
115}; 128};
116 129
117struct tda18271_map tda18271_km[] = { 130static struct tda18271_map tda18271_km[] = {
118 { .rfmax = 61100, .val = 0x74 }, 131 { .rfmax = 61100, .val = 0x74 },
119 { .rfmax = 350000, .val = 0x40 }, 132 { .rfmax = 350000, .val = 0x40 },
120 { .rfmax = 720000, .val = 0x30 }, 133 { .rfmax = 720000, .val = 0x30 },
@@ -122,7 +135,7 @@ struct tda18271_map tda18271_km[] = {
122 { .rfmax = 0, .val = 0x00 }, /* end */ 135 { .rfmax = 0, .val = 0x00 }, /* end */
123}; 136};
124 137
125struct tda18271_map tda18271_rf_band[] = { 138static struct tda18271_map tda18271_rf_band[] = {
126 { .rfmax = 47900, .val = 0x00 }, 139 { .rfmax = 47900, .val = 0x00 },
127 { .rfmax = 61100, .val = 0x01 }, 140 { .rfmax = 61100, .val = 0x01 },
128/* { .rfmax = 152600, .val = 0x02 }, */ 141/* { .rfmax = 152600, .val = 0x02 }, */
@@ -134,7 +147,7 @@ struct tda18271_map tda18271_rf_band[] = {
134 { .rfmax = 0, .val = 0x00 }, /* end */ 147 { .rfmax = 0, .val = 0x00 }, /* end */
135}; 148};
136 149
137struct tda18271_map tda18271_gain_taper[] = { 150static struct tda18271_map tda18271_gain_taper[] = {
138 { .rfmax = 45400, .val = 0x1f }, 151 { .rfmax = 45400, .val = 0x1f },
139 { .rfmax = 45800, .val = 0x1e }, 152 { .rfmax = 45800, .val = 0x1e },
140 { .rfmax = 46200, .val = 0x1d }, 153 { .rfmax = 46200, .val = 0x1d },
@@ -223,7 +236,7 @@ struct tda18271_map tda18271_gain_taper[] = {
223 { .rfmax = 0, .val = 0x00 }, /* end */ 236 { .rfmax = 0, .val = 0x00 }, /* end */
224}; 237};
225 238
226struct tda18271_map tda18271_rf_cal[] = { 239static struct tda18271_map tda18271_rf_cal[] = {
227 { .rfmax = 41000, .val = 0x1e }, 240 { .rfmax = 41000, .val = 0x1e },
228 { .rfmax = 43000, .val = 0x30 }, 241 { .rfmax = 43000, .val = 0x30 },
229 { .rfmax = 45000, .val = 0x43 }, 242 { .rfmax = 45000, .val = 0x43 },
@@ -244,7 +257,7 @@ struct tda18271_map tda18271_rf_cal[] = {
244 { .rfmax = 0, .val = 0x00 }, /* end */ 257 { .rfmax = 0, .val = 0x00 }, /* end */
245}; 258};
246 259
247struct tda18271_map tda18271_ir_measure[] = { 260static struct tda18271_map tda18271_ir_measure[] = {
248 { .rfmax = 30000, .val = 4}, 261 { .rfmax = 30000, .val = 4},
249 { .rfmax = 200000, .val = 5}, 262 { .rfmax = 200000, .val = 5},
250 { .rfmax = 600000, .val = 6}, 263 { .rfmax = 600000, .val = 6},
@@ -252,6 +265,83 @@ struct tda18271_map tda18271_ir_measure[] = {
252 { .rfmax = 0, .val = 0}, /* end */ 265 { .rfmax = 0, .val = 0}, /* end */
253}; 266};
254 267
268/*---------------------------------------------------------------------*/
269
270static void tda18271_lookup_map(struct tda18271_map *map,
271 u32 *freq, u8 *val)
272{
273 int i = 0;
274 while ((map[i].rfmax * 1000) < *freq) {
275 if (map[i + 1].rfmax == 0)
276 break;
277 i++;
278 }
279 *val = map[i].val;
280}
281
282static void tda18271_lookup_pll_map(struct tda18271_pll_map *map,
283 u32 *freq, u8 *post_div, u8 *div)
284{
285 int i = 0;
286 while ((map[i].lomax * 1000) < *freq) {
287 if (map[i + 1].lomax == 0)
288 break;
289 i++;
290 }
291 *post_div = map[i].pd;
292 *div = map[i].d;
293}
294
295/*---------------------------------------------------------------------*/
296
297void tda18271_calc_cal_pll(u32 *freq, u8 *post_div, u8 *div)
298{
299 tda18271_lookup_pll_map(tda18271_cal_pll, freq, post_div, div);
300 dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div);
301}
302
303void tda18271_calc_main_pll(u32 *freq, u8 *post_div, u8 *div)
304{
305 tda18271_lookup_pll_map(tda18271_main_pll, freq, post_div, div);
306 dbg_map("post div = 0x%02x, div = 0x%02x\n", *post_div, *div);
307}
308
309void tda18271_calc_bp_filter(u32 *freq, u8 *val)
310{
311 tda18271_lookup_map(tda18271_bp_filter, freq, val);
312 dbg_map("0x%02x\n", *val);
313}
314
315void tda18271_calc_km(u32 *freq, u8 *val)
316{
317 tda18271_lookup_map(tda18271_km, freq, val);
318 dbg_map("0x%02x\n", *val);
319}
320
321void tda18271_calc_rf_band(u32 *freq, u8 *val)
322{
323 tda18271_lookup_map(tda18271_rf_band, freq, val);
324 dbg_map("0x%02x\n", *val);
325}
326
327void tda18271_calc_gain_taper(u32 *freq, u8 *val)
328{
329 tda18271_lookup_map(tda18271_gain_taper, freq, val);
330 dbg_map("0x%02x\n", *val);
331}
332
333void tda18271_calc_rf_cal(u32 *freq, u8 *val)
334{
335 tda18271_lookup_map(tda18271_rf_cal, freq, val);
336 dbg_map("0x%02x\n", *val);
337}
338
339void tda18271_calc_ir_measure(u32 *freq, u8 *val)
340{
341 tda18271_lookup_map(tda18271_ir_measure, freq, val);
342 dbg_map("0x%02x\n", *val);
343}
344
255/* 345/*
256 * Overrides for Emacs so that we follow Linus's tabbing style. 346 * Overrides for Emacs so that we follow Linus's tabbing style.
257 * --------------------------------------------------------------------------- 347 * ---------------------------------------------------------------------------