diff options
author | Felipe Balbi <felipe.balbi@nokia.com> | 2008-08-19 19:40:30 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:51 -0400 |
commit | 06a3f58496462f25cc031d1cb6d49cb78af1f636 (patch) | |
tree | 4e2419212d517111a53b18cb3a5cbb76cfdfb7cb /drivers | |
parent | e758c6f86bc53009893dfa517b9bb3a408d7a2e2 (diff) |
V4L/DVB (8724): dvb: drx397xD: checkpatch.pl cleanups
This driver sure needs some rework. For now, let's
try to clean it up a bit before start reimplementing
anything.
checkpatch.pl still not happy with this driver after
this patch, but the most annoying errors are gone,
comments now use C-style only, labels are well placed
and some other minor fixes.
Some more clean up patches will come as I work on this
driver. Please review it carefully.
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Henk Vergonet <henk.vergonet@gmail.com>
[mchehab@infradead.org: Manually fixed some conflicts with a previous patch]
Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/frontends/drx397xD.c | 242 |
1 files changed, 124 insertions, 118 deletions
diff --git a/drivers/media/dvb/frontends/drx397xD.c b/drivers/media/dvb/frontends/drx397xD.c index e19147bad178..77dd4f2c6260 100644 --- a/drivers/media/dvb/frontends/drx397xD.c +++ b/drivers/media/dvb/frontends/drx397xD.c | |||
@@ -38,35 +38,32 @@ static const char mod_name[] = "drx397xD"; | |||
38 | #define F_SET_0D0h 1 | 38 | #define F_SET_0D0h 1 |
39 | #define F_SET_0D4h 2 | 39 | #define F_SET_0D4h 2 |
40 | 40 | ||
41 | typedef enum fw_ix { | 41 | enum fw_ix { |
42 | #define _FW_ENTRY(a, b) b | 42 | #define _FW_ENTRY(a, b) b |
43 | #include "drx397xD_fw.h" | 43 | #include "drx397xD_fw.h" |
44 | } fw_ix_t; | 44 | }; |
45 | 45 | ||
46 | /* chip specifics */ | 46 | /* chip specifics */ |
47 | struct drx397xD_state { | 47 | struct drx397xD_state { |
48 | struct i2c_adapter *i2c; | 48 | struct i2c_adapter *i2c; |
49 | struct dvb_frontend frontend; | 49 | struct dvb_frontend frontend; |
50 | struct drx397xD_config config; | 50 | struct drx397xD_config config; |
51 | fw_ix_t chip_rev; | 51 | enum fw_ix chip_rev; |
52 | int flags; | 52 | int flags; |
53 | u32 bandwidth_parm; /* internal bandwidth conversions */ | 53 | u32 bandwidth_parm; /* internal bandwidth conversions */ |
54 | u32 f_osc; /* w90: actual osc frequency [Hz] */ | 54 | u32 f_osc; /* w90: actual osc frequency [Hz] */ |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /******************************************************************************* | 57 | /* Firmware */ |
58 | * Firmware | ||
59 | ******************************************************************************/ | ||
60 | |||
61 | static const char *blob_name[] = { | 58 | static const char *blob_name[] = { |
62 | #define _BLOB_ENTRY(a, b) a | 59 | #define _BLOB_ENTRY(a, b) a |
63 | #include "drx397xD_fw.h" | 60 | #include "drx397xD_fw.h" |
64 | }; | 61 | }; |
65 | 62 | ||
66 | typedef enum blob_ix { | 63 | enum blob_ix { |
67 | #define _BLOB_ENTRY(a, b) b | 64 | #define _BLOB_ENTRY(a, b) b |
68 | #include "drx397xD_fw.h" | 65 | #include "drx397xD_fw.h" |
69 | } blob_ix_t; | 66 | }; |
70 | 67 | ||
71 | static struct { | 68 | static struct { |
72 | const char *name; | 69 | const char *name; |
@@ -85,7 +82,7 @@ static struct { | |||
85 | }; | 82 | }; |
86 | 83 | ||
87 | /* use only with writer lock aquired */ | 84 | /* use only with writer lock aquired */ |
88 | static void _drx_release_fw(struct drx397xD_state *s, fw_ix_t ix) | 85 | static void _drx_release_fw(struct drx397xD_state *s, enum fw_ix ix) |
89 | { | 86 | { |
90 | memset(&fw[ix].data[0], 0, sizeof(fw[0].data)); | 87 | memset(&fw[ix].data[0], 0, sizeof(fw[0].data)); |
91 | if (fw[ix].file) | 88 | if (fw[ix].file) |
@@ -94,7 +91,7 @@ static void _drx_release_fw(struct drx397xD_state *s, fw_ix_t ix) | |||
94 | 91 | ||
95 | static void drx_release_fw(struct drx397xD_state *s) | 92 | static void drx_release_fw(struct drx397xD_state *s) |
96 | { | 93 | { |
97 | fw_ix_t ix = s->chip_rev; | 94 | enum fw_ix ix = s->chip_rev; |
98 | 95 | ||
99 | pr_debug("%s\n", __func__); | 96 | pr_debug("%s\n", __func__); |
100 | 97 | ||
@@ -107,7 +104,7 @@ static void drx_release_fw(struct drx397xD_state *s) | |||
107 | write_unlock(&fw[ix].lock); | 104 | write_unlock(&fw[ix].lock); |
108 | } | 105 | } |
109 | 106 | ||
110 | static int drx_load_fw(struct drx397xD_state *s, fw_ix_t ix) | 107 | static int drx_load_fw(struct drx397xD_state *s, enum fw_ix ix) |
111 | { | 108 | { |
112 | const u8 *data; | 109 | const u8 *data; |
113 | size_t size, len; | 110 | size_t size, len; |
@@ -175,26 +172,28 @@ static int drx_load_fw(struct drx397xD_state *s, fw_ix_t ix) | |||
175 | goto exit_corrupt; | 172 | goto exit_corrupt; |
176 | } | 173 | } |
177 | } while (i < size); | 174 | } while (i < size); |
178 | exit_corrupt: | 175 | |
176 | exit_corrupt: | ||
179 | printk(KERN_ERR "%s: Firmware is corrupt\n", mod_name); | 177 | printk(KERN_ERR "%s: Firmware is corrupt\n", mod_name); |
180 | exit_err: | 178 | exit_err: |
181 | _drx_release_fw(s, ix); | 179 | _drx_release_fw(s, ix); |
182 | fw[ix].refcnt--; | 180 | fw[ix].refcnt--; |
183 | exit_ok: | 181 | exit_ok: |
184 | fw[ix].refcnt++; | 182 | fw[ix].refcnt++; |
185 | write_unlock(&fw[ix].lock); | 183 | write_unlock(&fw[ix].lock); |
184 | |||
186 | return rc; | 185 | return rc; |
187 | } | 186 | } |
188 | 187 | ||
189 | /******************************************************************************* | 188 | /* i2c bus IO */ |
190 | * i2c bus IO | 189 | static int write_fw(struct drx397xD_state *s, enum blob_ix ix) |
191 | ******************************************************************************/ | ||
192 | |||
193 | static int write_fw(struct drx397xD_state *s, blob_ix_t ix) | ||
194 | { | 190 | { |
195 | struct i2c_msg msg = {.addr = s->config.demod_address,.flags = 0 }; | ||
196 | const u8 *data; | 191 | const u8 *data; |
197 | int len, rc = 0, i = 0; | 192 | int len, rc = 0, i = 0; |
193 | struct i2c_msg msg = { | ||
194 | .addr = s->config.demod_address, | ||
195 | .flags = 0 | ||
196 | }; | ||
198 | 197 | ||
199 | if (ix < 0 || ix >= ARRAY_SIZE(blob_name)) { | 198 | if (ix < 0 || ix >= ARRAY_SIZE(blob_name)) { |
200 | pr_debug("%s drx_fw_ix_t out of range\n", __func__); | 199 | pr_debug("%s drx_fw_ix_t out of range\n", __func__); |
@@ -229,8 +228,9 @@ static int write_fw(struct drx397xD_state *s, blob_ix_t ix) | |||
229 | goto exit_rc; | 228 | goto exit_rc; |
230 | } | 229 | } |
231 | } | 230 | } |
232 | exit_rc: | 231 | exit_rc: |
233 | read_unlock(&fw[s->chip_rev].lock); | 232 | read_unlock(&fw[s->chip_rev].lock); |
233 | |||
234 | return 0; | 234 | return 0; |
235 | } | 235 | } |
236 | 236 | ||
@@ -242,17 +242,16 @@ static int _read16(struct drx397xD_state *s, u32 i2c_adr) | |||
242 | u16 v; | 242 | u16 v; |
243 | struct i2c_msg msg[2] = { | 243 | struct i2c_msg msg[2] = { |
244 | { | 244 | { |
245 | .addr = s->config.demod_address, | 245 | .addr = s->config.demod_address, |
246 | .flags = 0, | 246 | .flags = 0, |
247 | .buf = a, | 247 | .buf = a, |
248 | .len = sizeof(a) | 248 | .len = sizeof(a) |
249 | } | 249 | }, { |
250 | , { | 250 | .addr = s->config.demod_address, |
251 | .addr = s->config.demod_address, | 251 | .flags = I2C_M_RD, |
252 | .flags = I2C_M_RD, | 252 | .buf = (u8 *) &v, |
253 | .buf = (u8 *) & v, | 253 | .len = sizeof(v) |
254 | .len = sizeof(v) | 254 | } |
255 | } | ||
256 | }; | 255 | }; |
257 | 256 | ||
258 | *(u32 *) a = i2c_adr; | 257 | *(u32 *) a = i2c_adr; |
@@ -277,27 +276,27 @@ static int _write16(struct drx397xD_state *s, u32 i2c_adr, u16 val) | |||
277 | }; | 276 | }; |
278 | 277 | ||
279 | *(u32 *) a = i2c_adr; | 278 | *(u32 *) a = i2c_adr; |
280 | *(u16 *) & a[4] = val; | 279 | *(u16 *) &a[4] = val; |
281 | 280 | ||
282 | rc = i2c_transfer(s->i2c, &msg, 1); | 281 | rc = i2c_transfer(s->i2c, &msg, 1); |
283 | if (rc != 1) | 282 | if (rc != 1) |
284 | return -EIO; | 283 | return -EIO; |
284 | |||
285 | return 0; | 285 | return 0; |
286 | } | 286 | } |
287 | 287 | ||
288 | #define WR16(ss,adr, val) \ | 288 | #define WR16(ss, adr, val) \ |
289 | _write16(ss, I2C_ADR_C0(adr), cpu_to_le16(val)) | 289 | _write16(ss, I2C_ADR_C0(adr), cpu_to_le16(val)) |
290 | #define WR16_E0(ss,adr, val) \ | 290 | #define WR16_E0(ss, adr, val) \ |
291 | _write16(ss, I2C_ADR_E0(adr), cpu_to_le16(val)) | 291 | _write16(ss, I2C_ADR_E0(adr), cpu_to_le16(val)) |
292 | #define RD16(ss,adr) \ | 292 | #define RD16(ss, adr) \ |
293 | _read16(ss, I2C_ADR_C0(adr)) | 293 | _read16(ss, I2C_ADR_C0(adr)) |
294 | 294 | ||
295 | #define EXIT_RC( cmd ) if ( (rc = (cmd)) < 0) goto exit_rc | 295 | #define EXIT_RC(cmd) \ |
296 | 296 | if ((rc = (cmd)) < 0) \ | |
297 | /******************************************************************************* | 297 | goto exit_rc |
298 | * Tuner callback | ||
299 | ******************************************************************************/ | ||
300 | 298 | ||
299 | /* Tuner callback */ | ||
301 | static int PLL_Set(struct drx397xD_state *s, | 300 | static int PLL_Set(struct drx397xD_state *s, |
302 | struct dvb_frontend_parameters *fep, int *df_tuner) | 301 | struct dvb_frontend_parameters *fep, int *df_tuner) |
303 | { | 302 | { |
@@ -331,10 +330,7 @@ static int PLL_Set(struct drx397xD_state *s, | |||
331 | return 0; | 330 | return 0; |
332 | } | 331 | } |
333 | 332 | ||
334 | /******************************************************************************* | 333 | /* Demodulator helper functions */ |
335 | * Demodulator helper functions | ||
336 | ******************************************************************************/ | ||
337 | |||
338 | static int SC_WaitForReady(struct drx397xD_state *s) | 334 | static int SC_WaitForReady(struct drx397xD_state *s) |
339 | { | 335 | { |
340 | int cnt = 1000; | 336 | int cnt = 1000; |
@@ -347,6 +343,7 @@ static int SC_WaitForReady(struct drx397xD_state *s) | |||
347 | if (rc == 0) | 343 | if (rc == 0) |
348 | return 0; | 344 | return 0; |
349 | } | 345 | } |
346 | |||
350 | return -1; | 347 | return -1; |
351 | } | 348 | } |
352 | 349 | ||
@@ -361,6 +358,7 @@ static int SC_SendCommand(struct drx397xD_state *s, int cmd) | |||
361 | rc = RD16(s, 0x820042); | 358 | rc = RD16(s, 0x820042); |
362 | if ((rc & 0xffff) == 0xffff) | 359 | if ((rc & 0xffff) == 0xffff) |
363 | return -1; | 360 | return -1; |
361 | |||
364 | return 0; | 362 | return 0; |
365 | } | 363 | } |
366 | 364 | ||
@@ -383,6 +381,7 @@ static int HI_Command(struct drx397xD_state *s, u16 cmd) | |||
383 | if (rc < 0) | 381 | if (rc < 0) |
384 | return rc; | 382 | return rc; |
385 | } while (--cnt); | 383 | } while (--cnt); |
384 | |||
386 | return rc; | 385 | return rc; |
387 | } | 386 | } |
388 | 387 | ||
@@ -392,13 +391,14 @@ static int HI_CfgCommand(struct drx397xD_state *s) | |||
392 | pr_debug("%s\n", __func__); | 391 | pr_debug("%s\n", __func__); |
393 | 392 | ||
394 | WR16(s, 0x420033, 0x3973); | 393 | WR16(s, 0x420033, 0x3973); |
395 | WR16(s, 0x420034, s->config.w50); // code 4, log 4 | 394 | WR16(s, 0x420034, s->config.w50); /* code 4, log 4 */ |
396 | WR16(s, 0x420035, s->config.w52); // code 15, log 9 | 395 | WR16(s, 0x420035, s->config.w52); /* code 15, log 9 */ |
397 | WR16(s, 0x420036, s->config.demod_address << 1); | 396 | WR16(s, 0x420036, s->config.demod_address << 1); |
398 | WR16(s, 0x420037, s->config.w56); // code (set_i2c ?? initX 1 ), log 1 | 397 | WR16(s, 0x420037, s->config.w56); /* code (set_i2c ?? initX 1 ), log 1 */ |
399 | // WR16(s, 0x420033, 0x3973); | 398 | /* WR16(s, 0x420033, 0x3973); */ |
400 | if ((s->config.w56 & 8) == 0) | 399 | if ((s->config.w56 & 8) == 0) |
401 | return HI_Command(s, 3); | 400 | return HI_Command(s, 3); |
401 | |||
402 | return WR16(s, 0x420032, 0x3); | 402 | return WR16(s, 0x420032, 0x3); |
403 | } | 403 | } |
404 | 404 | ||
@@ -468,7 +468,7 @@ static int SetCfgIfAgc(struct drx397xD_state *s, struct drx397xD_CfgIfAgc *agc) | |||
468 | i = slowIncrDecLUT_15272[rem / 28]; | 468 | i = slowIncrDecLUT_15272[rem / 28]; |
469 | EXIT_RC(WR16(s, 0x0c2002b, i)); | 469 | EXIT_RC(WR16(s, 0x0c2002b, i)); |
470 | rc = WR16(s, 0x0c2002c, i); | 470 | rc = WR16(s, 0x0c2002c, i); |
471 | exit_rc: | 471 | exit_rc: |
472 | return rc; | 472 | return rc; |
473 | } | 473 | } |
474 | 474 | ||
@@ -498,7 +498,7 @@ static int SetCfgRfAgc(struct drx397xD_state *s, struct drx397xD_CfgRfAgc *agc) | |||
498 | rc &= ~2; | 498 | rc &= ~2; |
499 | break; | 499 | break; |
500 | case 0: | 500 | case 0: |
501 | // loc_8000659 | 501 | /* loc_8000659 */ |
502 | s->config.w9C &= ~2; | 502 | s->config.w9C &= ~2; |
503 | EXIT_RC(WR16(s, 0x0c20015, s->config.w9C)); | 503 | EXIT_RC(WR16(s, 0x0c20015, s->config.w9C)); |
504 | EXIT_RC(RD16(s, 0x0c20010)); | 504 | EXIT_RC(RD16(s, 0x0c20010)); |
@@ -522,7 +522,8 @@ static int SetCfgRfAgc(struct drx397xD_state *s, struct drx397xD_CfgRfAgc *agc) | |||
522 | rc |= 2; | 522 | rc |= 2; |
523 | } | 523 | } |
524 | rc = WR16(s, 0x0c20013, rc); | 524 | rc = WR16(s, 0x0c20013, rc); |
525 | exit_rc: | 525 | |
526 | exit_rc: | ||
526 | return rc; | 527 | return rc; |
527 | } | 528 | } |
528 | 529 | ||
@@ -602,7 +603,8 @@ static int CorrectSysClockDeviation(struct drx397xD_state *s) | |||
602 | s->config.f_osc * 1000, clk - s->config.f_osc * 1000); | 603 | s->config.f_osc * 1000, clk - s->config.f_osc * 1000); |
603 | } | 604 | } |
604 | rc = WR16(s, 0x08200e8, 0); | 605 | rc = WR16(s, 0x08200e8, 0); |
605 | exit_rc: | 606 | |
607 | exit_rc: | ||
606 | return rc; | 608 | return rc; |
607 | } | 609 | } |
608 | 610 | ||
@@ -620,17 +622,17 @@ static int ConfigureMPEGOutput(struct drx397xD_state *s, int type) | |||
620 | si &= ~1; | 622 | si &= ~1; |
621 | bp = 0x200; | 623 | bp = 0x200; |
622 | } | 624 | } |
623 | if (s->config.w9A == 0) { | 625 | if (s->config.w9A == 0) |
624 | si |= 0x80; | 626 | si |= 0x80; |
625 | } else { | 627 | else |
626 | si &= ~0x80; | 628 | si &= ~0x80; |
627 | } | ||
628 | 629 | ||
629 | EXIT_RC(WR16(s, 0x2150045, 0)); | 630 | EXIT_RC(WR16(s, 0x2150045, 0)); |
630 | EXIT_RC(WR16(s, 0x2150010, si)); | 631 | EXIT_RC(WR16(s, 0x2150010, si)); |
631 | EXIT_RC(WR16(s, 0x2150011, bp)); | 632 | EXIT_RC(WR16(s, 0x2150011, bp)); |
632 | rc = WR16(s, 0x2150012, (type == 0 ? 0xfff : 0)); | 633 | rc = WR16(s, 0x2150012, (type == 0 ? 0xfff : 0)); |
633 | exit_rc: | 634 | |
635 | exit_rc: | ||
634 | return rc; | 636 | return rc; |
635 | } | 637 | } |
636 | 638 | ||
@@ -658,7 +660,7 @@ static int drx_tune(struct drx397xD_state *s, | |||
658 | rc = ConfigureMPEGOutput(s, 0); | 660 | rc = ConfigureMPEGOutput(s, 0); |
659 | if (rc < 0) | 661 | if (rc < 0) |
660 | goto set_tuner; | 662 | goto set_tuner; |
661 | set_tuner: | 663 | set_tuner: |
662 | 664 | ||
663 | rc = PLL_Set(s, fep, &df_tuner); | 665 | rc = PLL_Set(s, fep, &df_tuner); |
664 | if (rc < 0) { | 666 | if (rc < 0) { |
@@ -835,16 +837,16 @@ static int drx_tune(struct drx397xD_state *s, | |||
835 | rc = WR16(s, 0x2010012, 0); | 837 | rc = WR16(s, 0x2010012, 0); |
836 | if (rc < 0) | 838 | if (rc < 0) |
837 | goto exit_rc; | 839 | goto exit_rc; |
838 | // QPSK QAM16 QAM64 | 840 | /* QPSK QAM16 QAM64 */ |
839 | ebx = 0x19f; // 62 | 841 | ebx = 0x19f; /* 62 */ |
840 | ebp = 0x1fb; // 15 | 842 | ebp = 0x1fb; /* 15 */ |
841 | v20 = 0x16a; // 62 | 843 | v20 = 0x16a; /* 62 */ |
842 | v1E = 0x195; // 62 | 844 | v1E = 0x195; /* 62 */ |
843 | v16 = 0x1bb; // 15 | 845 | v16 = 0x1bb; /* 15 */ |
844 | v14 = 0x1ef; // 15 | 846 | v14 = 0x1ef; /* 15 */ |
845 | v12 = 5; // 16 | 847 | v12 = 5; /* 16 */ |
846 | v10 = 5; // 16 | 848 | v10 = 5; /* 16 */ |
847 | v0E = 5; // 16 | 849 | v0E = 5; /* 16 */ |
848 | } | 850 | } |
849 | 851 | ||
850 | switch (fep->u.ofdm.constellation) { | 852 | switch (fep->u.ofdm.constellation) { |
@@ -997,17 +999,17 @@ static int drx_tune(struct drx397xD_state *s, | |||
997 | case BANDWIDTH_8_MHZ: /* 0 */ | 999 | case BANDWIDTH_8_MHZ: /* 0 */ |
998 | case BANDWIDTH_AUTO: | 1000 | case BANDWIDTH_AUTO: |
999 | rc = WR16(s, 0x0c2003f, 0x32); | 1001 | rc = WR16(s, 0x0c2003f, 0x32); |
1000 | s->bandwidth_parm = ebx = 0x8b8249; // 9142857 | 1002 | s->bandwidth_parm = ebx = 0x8b8249; |
1001 | edx = 0; | 1003 | edx = 0; |
1002 | break; | 1004 | break; |
1003 | case BANDWIDTH_7_MHZ: | 1005 | case BANDWIDTH_7_MHZ: |
1004 | rc = WR16(s, 0x0c2003f, 0x3b); | 1006 | rc = WR16(s, 0x0c2003f, 0x3b); |
1005 | s->bandwidth_parm = ebx = 0x7a1200; // 8000000 | 1007 | s->bandwidth_parm = ebx = 0x7a1200; |
1006 | edx = 0x4807; | 1008 | edx = 0x4807; |
1007 | break; | 1009 | break; |
1008 | case BANDWIDTH_6_MHZ: | 1010 | case BANDWIDTH_6_MHZ: |
1009 | rc = WR16(s, 0x0c2003f, 0x47); | 1011 | rc = WR16(s, 0x0c2003f, 0x47); |
1010 | s->bandwidth_parm = ebx = 0x68a1b6; // 6857142 | 1012 | s->bandwidth_parm = ebx = 0x68a1b6; |
1011 | edx = 0x0f07; | 1013 | edx = 0x0f07; |
1012 | break; | 1014 | break; |
1013 | }; | 1015 | }; |
@@ -1060,8 +1062,6 @@ static int drx_tune(struct drx397xD_state *s, | |||
1060 | WR16(s, 0x0820040, 1); | 1062 | WR16(s, 0x0820040, 1); |
1061 | SC_SendCommand(s, 1); | 1063 | SC_SendCommand(s, 1); |
1062 | 1064 | ||
1063 | // rc = WR16(s, 0x2150000, 1); | ||
1064 | // if (rc < 0) goto exit_rc; | ||
1065 | 1065 | ||
1066 | rc = WR16(s, 0x2150000, 2); | 1066 | rc = WR16(s, 0x2150000, 2); |
1067 | rc = WR16(s, 0x2150016, a); | 1067 | rc = WR16(s, 0x2150016, a); |
@@ -1069,7 +1069,8 @@ static int drx_tune(struct drx397xD_state *s, | |||
1069 | rc = WR16(s, 0x2150036, 0); | 1069 | rc = WR16(s, 0x2150036, 0); |
1070 | rc = WR16(s, 0x2150000, 1); | 1070 | rc = WR16(s, 0x2150000, 1); |
1071 | s->config.d60 = 2; | 1071 | s->config.d60 = 2; |
1072 | exit_rc: | 1072 | |
1073 | exit_rc: | ||
1073 | return rc; | 1074 | return rc; |
1074 | } | 1075 | } |
1075 | 1076 | ||
@@ -1102,18 +1103,18 @@ static int drx397x_init(struct dvb_frontend *fe) | |||
1102 | 1103 | ||
1103 | /* HI_CfgCommand */ | 1104 | /* HI_CfgCommand */ |
1104 | s->config.w50 = 4; | 1105 | s->config.w50 = 4; |
1105 | s->config.w52 = 9; // 0xf; | 1106 | s->config.w52 = 9; |
1106 | 1107 | ||
1107 | s->config.f_if = 42800000; /* d14: intermediate frequency [Hz] */ | 1108 | s->config.f_if = 42800000; /* d14: intermediate frequency [Hz] */ |
1108 | s->config.f_osc = 48000; /* s66 : oscillator frequency [kHz] */ | 1109 | s->config.f_osc = 48000; /* s66 : oscillator frequency [kHz] */ |
1109 | s->config.w92 = 12000; // 20000; | 1110 | s->config.w92 = 12000; |
1110 | 1111 | ||
1111 | s->config.w9C = 0x000e; | 1112 | s->config.w9C = 0x000e; |
1112 | s->config.w9E = 0x0000; | 1113 | s->config.w9E = 0x0000; |
1113 | 1114 | ||
1114 | /* ConfigureMPEGOutput params */ | 1115 | /* ConfigureMPEGOutput params */ |
1115 | s->config.wA0 = 4; | 1116 | s->config.wA0 = 4; |
1116 | s->config.w98 = 1; // 0; | 1117 | s->config.w98 = 1; |
1117 | s->config.w9A = 1; | 1118 | s->config.w9A = 1; |
1118 | 1119 | ||
1119 | /* get chip revision */ | 1120 | /* get chip revision */ |
@@ -1248,7 +1249,7 @@ static int drx397x_init(struct dvb_frontend *fe) | |||
1248 | rc = WR16(s, 0x0c20012, 1); | 1249 | rc = WR16(s, 0x0c20012, 1); |
1249 | } | 1250 | } |
1250 | 1251 | ||
1251 | write_DRXD_InitFE_1: | 1252 | write_DRXD_InitFE_1: |
1252 | 1253 | ||
1253 | rc = write_fw(s, DRXD_InitFE_1); | 1254 | rc = write_fw(s, DRXD_InitFE_1); |
1254 | if (rc < 0) | 1255 | if (rc < 0) |
@@ -1311,7 +1312,8 @@ static int drx397x_init(struct dvb_frontend *fe) | |||
1311 | s->config.d5C = 0; | 1312 | s->config.d5C = 0; |
1312 | s->config.d60 = 1; | 1313 | s->config.d60 = 1; |
1313 | s->config.d48 = 1; | 1314 | s->config.d48 = 1; |
1314 | error: | 1315 | |
1316 | error: | ||
1315 | return rc; | 1317 | return rc; |
1316 | } | 1318 | } |
1317 | 1319 | ||
@@ -1326,7 +1328,8 @@ static int drx397x_set_frontend(struct dvb_frontend *fe, | |||
1326 | { | 1328 | { |
1327 | struct drx397xD_state *s = fe->demodulator_priv; | 1329 | struct drx397xD_state *s = fe->demodulator_priv; |
1328 | 1330 | ||
1329 | s->config.s20d24 = 1; // 0; | 1331 | s->config.s20d24 = 1; |
1332 | |||
1330 | return drx_tune(s, params); | 1333 | return drx_tune(s, params); |
1331 | } | 1334 | } |
1332 | 1335 | ||
@@ -1337,18 +1340,16 @@ static int drx397x_get_tune_settings(struct dvb_frontend *fe, | |||
1337 | fe_tune_settings->min_delay_ms = 10000; | 1340 | fe_tune_settings->min_delay_ms = 10000; |
1338 | fe_tune_settings->step_size = 0; | 1341 | fe_tune_settings->step_size = 0; |
1339 | fe_tune_settings->max_drift = 0; | 1342 | fe_tune_settings->max_drift = 0; |
1343 | |||
1340 | return 0; | 1344 | return 0; |
1341 | } | 1345 | } |
1342 | 1346 | ||
1343 | static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t * status) | 1347 | static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t *status) |
1344 | { | 1348 | { |
1345 | struct drx397xD_state *s = fe->demodulator_priv; | 1349 | struct drx397xD_state *s = fe->demodulator_priv; |
1346 | int lockstat; | 1350 | int lockstat; |
1347 | 1351 | ||
1348 | GetLockStatus(s, &lockstat); | 1352 | GetLockStatus(s, &lockstat); |
1349 | /* TODO */ | ||
1350 | // if (lockstat & 1) | ||
1351 | // CorrectSysClockDeviation(s); | ||
1352 | 1353 | ||
1353 | *status = 0; | 1354 | *status = 0; |
1354 | if (lockstat & 2) { | 1355 | if (lockstat & 2) { |
@@ -1356,9 +1357,8 @@ static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t * status) | |||
1356 | ConfigureMPEGOutput(s, 1); | 1357 | ConfigureMPEGOutput(s, 1); |
1357 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI; | 1358 | *status = FE_HAS_LOCK | FE_HAS_SYNC | FE_HAS_VITERBI; |
1358 | } | 1359 | } |
1359 | if (lockstat & 4) { | 1360 | if (lockstat & 4) |
1360 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; | 1361 | *status |= FE_HAS_CARRIER | FE_HAS_SIGNAL; |
1361 | } | ||
1362 | 1362 | ||
1363 | return 0; | 1363 | return 0; |
1364 | } | 1364 | } |
@@ -1366,16 +1366,18 @@ static int drx397x_read_status(struct dvb_frontend *fe, fe_status_t * status) | |||
1366 | static int drx397x_read_ber(struct dvb_frontend *fe, unsigned int *ber) | 1366 | static int drx397x_read_ber(struct dvb_frontend *fe, unsigned int *ber) |
1367 | { | 1367 | { |
1368 | *ber = 0; | 1368 | *ber = 0; |
1369 | |||
1369 | return 0; | 1370 | return 0; |
1370 | } | 1371 | } |
1371 | 1372 | ||
1372 | static int drx397x_read_snr(struct dvb_frontend *fe, u16 * snr) | 1373 | static int drx397x_read_snr(struct dvb_frontend *fe, u16 *snr) |
1373 | { | 1374 | { |
1374 | *snr = 0; | 1375 | *snr = 0; |
1376 | |||
1375 | return 0; | 1377 | return 0; |
1376 | } | 1378 | } |
1377 | 1379 | ||
1378 | static int drx397x_read_signal_strength(struct dvb_frontend *fe, u16 * strength) | 1380 | static int drx397x_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
1379 | { | 1381 | { |
1380 | struct drx397xD_state *s = fe->demodulator_priv; | 1382 | struct drx397xD_state *s = fe->demodulator_priv; |
1381 | int rc; | 1383 | int rc; |
@@ -1401,6 +1403,7 @@ static int drx397x_read_signal_strength(struct dvb_frontend *fe, u16 * strength) | |||
1401 | * The following does the same but with less rounding errors: | 1403 | * The following does the same but with less rounding errors: |
1402 | */ | 1404 | */ |
1403 | *strength = ~(7720 + (rc * 30744 >> 10)); | 1405 | *strength = ~(7720 + (rc * 30744 >> 10)); |
1406 | |||
1404 | return 0; | 1407 | return 0; |
1405 | } | 1408 | } |
1406 | 1409 | ||
@@ -1408,6 +1411,7 @@ static int drx397x_read_ucblocks(struct dvb_frontend *fe, | |||
1408 | unsigned int *ucblocks) | 1411 | unsigned int *ucblocks) |
1409 | { | 1412 | { |
1410 | *ucblocks = 0; | 1413 | *ucblocks = 0; |
1414 | |||
1411 | return 0; | 1415 | return 0; |
1412 | } | 1416 | } |
1413 | 1417 | ||
@@ -1436,22 +1440,22 @@ static struct dvb_frontend_ops drx397x_ops = { | |||
1436 | .frequency_max = 855250000, | 1440 | .frequency_max = 855250000, |
1437 | .frequency_stepsize = 166667, | 1441 | .frequency_stepsize = 166667, |
1438 | .frequency_tolerance = 0, | 1442 | .frequency_tolerance = 0, |
1439 | .caps = /* 0x0C01B2EAE */ | 1443 | .caps = /* 0x0C01B2EAE */ |
1440 | FE_CAN_FEC_1_2 | // = 0x2, | 1444 | FE_CAN_FEC_1_2 | /* = 0x2, */ |
1441 | FE_CAN_FEC_2_3 | // = 0x4, | 1445 | FE_CAN_FEC_2_3 | /* = 0x4, */ |
1442 | FE_CAN_FEC_3_4 | // = 0x8, | 1446 | FE_CAN_FEC_3_4 | /* = 0x8, */ |
1443 | FE_CAN_FEC_5_6 | // = 0x20, | 1447 | FE_CAN_FEC_5_6 | /* = 0x20, */ |
1444 | FE_CAN_FEC_7_8 | // = 0x80, | 1448 | FE_CAN_FEC_7_8 | /* = 0x80, */ |
1445 | FE_CAN_FEC_AUTO | // = 0x200, | 1449 | FE_CAN_FEC_AUTO | /* = 0x200, */ |
1446 | FE_CAN_QPSK | // = 0x400, | 1450 | FE_CAN_QPSK | /* = 0x400, */ |
1447 | FE_CAN_QAM_16 | // = 0x800, | 1451 | FE_CAN_QAM_16 | /* = 0x800, */ |
1448 | FE_CAN_QAM_64 | // = 0x2000, | 1452 | FE_CAN_QAM_64 | /* = 0x2000, */ |
1449 | FE_CAN_QAM_AUTO | // = 0x10000, | 1453 | FE_CAN_QAM_AUTO | /* = 0x10000, */ |
1450 | FE_CAN_TRANSMISSION_MODE_AUTO | // = 0x20000, | 1454 | FE_CAN_TRANSMISSION_MODE_AUTO | /* = 0x20000, */ |
1451 | FE_CAN_GUARD_INTERVAL_AUTO | // = 0x80000, | 1455 | FE_CAN_GUARD_INTERVAL_AUTO | /* = 0x80000, */ |
1452 | FE_CAN_HIERARCHY_AUTO | // = 0x100000, | 1456 | FE_CAN_HIERARCHY_AUTO | /* = 0x100000, */ |
1453 | FE_CAN_RECOVER | // = 0x40000000, | 1457 | FE_CAN_RECOVER | /* = 0x40000000, */ |
1454 | FE_CAN_MUTE_TS // = 0x80000000 | 1458 | FE_CAN_MUTE_TS /* = 0x80000000 */ |
1455 | }, | 1459 | }, |
1456 | 1460 | ||
1457 | .release = drx397x_release, | 1461 | .release = drx397x_release, |
@@ -1472,33 +1476,35 @@ static struct dvb_frontend_ops drx397x_ops = { | |||
1472 | struct dvb_frontend *drx397xD_attach(const struct drx397xD_config *config, | 1476 | struct dvb_frontend *drx397xD_attach(const struct drx397xD_config *config, |
1473 | struct i2c_adapter *i2c) | 1477 | struct i2c_adapter *i2c) |
1474 | { | 1478 | { |
1475 | struct drx397xD_state *s = NULL; | 1479 | struct drx397xD_state *state; |
1476 | 1480 | ||
1477 | /* allocate memory for the internal state */ | 1481 | /* allocate memory for the internal state */ |
1478 | s = kzalloc(sizeof(struct drx397xD_state), GFP_KERNEL); | 1482 | state = kzalloc(sizeof(struct drx397xD_state), GFP_KERNEL); |
1479 | if (s == NULL) | 1483 | if (!state) |
1480 | goto error; | 1484 | goto error; |
1481 | 1485 | ||
1482 | /* setup the state */ | 1486 | /* setup the state */ |
1483 | s->i2c = i2c; | 1487 | state->i2c = i2c; |
1484 | memcpy(&s->config, config, sizeof(struct drx397xD_config)); | 1488 | memcpy(&state->config, config, sizeof(struct drx397xD_config)); |
1485 | 1489 | ||
1486 | /* check if the demod is there */ | 1490 | /* check if the demod is there */ |
1487 | if (RD16(s, 0x2410019) < 0) | 1491 | if (RD16(s, 0x2410019) < 0) |
1488 | goto error; | 1492 | goto error; |
1489 | 1493 | ||
1490 | /* create dvb_frontend */ | 1494 | /* create dvb_frontend */ |
1491 | memcpy(&s->frontend.ops, &drx397x_ops, sizeof(struct dvb_frontend_ops)); | 1495 | memcpy(&state->frontend.ops, &drx397x_ops, |
1492 | s->frontend.demodulator_priv = s; | 1496 | sizeof(struct dvb_frontend_ops)); |
1497 | state->frontend.demodulator_priv = s; | ||
1498 | |||
1499 | return &state->frontend; | ||
1500 | error: | ||
1501 | kfree(state); | ||
1493 | 1502 | ||
1494 | return &s->frontend; | ||
1495 | error: | ||
1496 | kfree(s); | ||
1497 | return NULL; | 1503 | return NULL; |
1498 | } | 1504 | } |
1505 | EXPORT_SYMBOL(drx397xD_attach); | ||
1499 | 1506 | ||
1500 | MODULE_DESCRIPTION("Micronas DRX397xD DVB-T Frontend"); | 1507 | MODULE_DESCRIPTION("Micronas DRX397xD DVB-T Frontend"); |
1501 | MODULE_AUTHOR("Henk Vergonet"); | 1508 | MODULE_AUTHOR("Henk Vergonet"); |
1502 | MODULE_LICENSE("GPL"); | 1509 | MODULE_LICENSE("GPL"); |
1503 | 1510 | ||
1504 | EXPORT_SYMBOL(drx397xD_attach); | ||