diff options
author | Antti Palosaari <crope@iki.fi> | 2013-02-26 18:34:06 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2013-03-21 17:57:17 -0400 |
commit | ebb0662cee9e6d8f7110c1217a7bd14315fdd148 (patch) | |
tree | d2f4d9bc1ca714deaf7d021213294da44a680e33 | |
parent | df8f1be14fa68f99b426c7c413a60fb368b8c522 (diff) |
[media] it913x: merge it913x_fe_start() to it913x_init_tuner()
Merge those functions to one and disable sleep.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/tuners/it913x.c | 165 |
1 files changed, 45 insertions, 120 deletions
diff --git a/drivers/media/tuners/it913x.c b/drivers/media/tuners/it913x.c index 6ee4f97f586e..f1938a13eace 100644 --- a/drivers/media/tuners/it913x.c +++ b/drivers/media/tuners/it913x.c | |||
@@ -43,7 +43,6 @@ struct it913x_fe_state { | |||
43 | u32 ucblocks; | 43 | u32 ucblocks; |
44 | }; | 44 | }; |
45 | 45 | ||
46 | |||
47 | static int it913x_read_reg(struct it913x_fe_state *state, | 46 | static int it913x_read_reg(struct it913x_fe_state *state, |
48 | u32 reg, u8 *data, u8 count) | 47 | u32 reg, u8 *data, u8 count) |
49 | { | 48 | { |
@@ -147,10 +146,54 @@ static int it913x_init_tuner(struct dvb_frontend *fe) | |||
147 | { | 146 | { |
148 | struct it913x_fe_state *state = fe->tuner_priv; | 147 | struct it913x_fe_state *state = fe->tuner_priv; |
149 | int ret, i, reg; | 148 | int ret, i, reg; |
149 | struct it913xset *set_lna; | ||
150 | u8 val, nv_val; | 150 | u8 val, nv_val; |
151 | u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2}; | 151 | u8 nv[] = {48, 32, 24, 16, 12, 8, 6, 4, 2}; |
152 | u8 b[2]; | 152 | u8 b[2]; |
153 | 153 | ||
154 | /* v1 or v2 tuner script */ | ||
155 | if (state->config->chip_ver > 1) | ||
156 | ret = it913x_fe_script_loader(state, it9135_v2); | ||
157 | else | ||
158 | ret = it913x_fe_script_loader(state, it9135_v1); | ||
159 | if (ret < 0) | ||
160 | return ret; | ||
161 | |||
162 | /* LNA Scripts */ | ||
163 | switch (state->tuner_type) { | ||
164 | case IT9135_51: | ||
165 | set_lna = it9135_51; | ||
166 | break; | ||
167 | case IT9135_52: | ||
168 | set_lna = it9135_52; | ||
169 | break; | ||
170 | case IT9135_60: | ||
171 | set_lna = it9135_60; | ||
172 | break; | ||
173 | case IT9135_61: | ||
174 | set_lna = it9135_61; | ||
175 | break; | ||
176 | case IT9135_62: | ||
177 | set_lna = it9135_62; | ||
178 | break; | ||
179 | case IT9135_38: | ||
180 | default: | ||
181 | set_lna = it9135_38; | ||
182 | } | ||
183 | pr_info("Tuner LNA type :%02x\n", state->tuner_type); | ||
184 | |||
185 | ret = it913x_fe_script_loader(state, set_lna); | ||
186 | if (ret < 0) | ||
187 | return ret; | ||
188 | |||
189 | if (state->config->chip_ver == 2) { | ||
190 | ret = it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1); | ||
191 | ret |= it913x_write_reg(state, PRO_LINK, PADODPU, 0x0); | ||
192 | ret |= it913x_write_reg(state, PRO_LINK, AGC_O_D, 0x0); | ||
193 | } | ||
194 | if (ret < 0) | ||
195 | return -ENODEV; | ||
196 | |||
154 | reg = it913x_read_reg_u8(state, 0xec86); | 197 | reg = it913x_read_reg_u8(state, 0xec86); |
155 | switch (reg) { | 198 | switch (reg) { |
156 | case 0: | 199 | case 0: |
@@ -361,6 +404,7 @@ static int it9137_set_tuner(struct dvb_frontend *fe) | |||
361 | static int it913x_fe_suspend(struct it913x_fe_state *state) | 404 | static int it913x_fe_suspend(struct it913x_fe_state *state) |
362 | { | 405 | { |
363 | int ret = 0; | 406 | int ret = 0; |
407 | return 0; | ||
364 | #if 0 | 408 | #if 0 |
365 | int ret, i; | 409 | int ret, i; |
366 | u8 b; | 410 | u8 b; |
@@ -397,121 +441,6 @@ static int it913x_fe_sleep(struct dvb_frontend *fe) | |||
397 | return it913x_fe_suspend(state); | 441 | return it913x_fe_suspend(state); |
398 | } | 442 | } |
399 | 443 | ||
400 | static int it913x_fe_start(struct dvb_frontend *fe) | ||
401 | { | ||
402 | struct it913x_fe_state *state = fe->tuner_priv; | ||
403 | struct it913xset *set_lna; | ||
404 | // struct it913xset *set_mode; | ||
405 | int ret; | ||
406 | // u8 adf = (state->config->adf & 0xf); | ||
407 | // u32 adc, xtal; | ||
408 | // u8 b[4]; | ||
409 | |||
410 | if (state->config->chip_ver == 1) | ||
411 | ret = it913x_init_tuner(fe); | ||
412 | |||
413 | #if 0 | ||
414 | pr_info("ADF table value :%02x\n", adf); | ||
415 | |||
416 | if (adf < 10) { | ||
417 | state->crystalFrequency = fe_clockTable[adf].xtal ; | ||
418 | state->table = fe_clockTable[adf].table; | ||
419 | state->adcFrequency = state->table->adcFrequency; | ||
420 | |||
421 | adc = compute_div(state->adcFrequency, 1000000ul, 19ul); | ||
422 | xtal = compute_div(state->crystalFrequency, 1000000ul, 19ul); | ||
423 | |||
424 | } else | ||
425 | return -EINVAL; | ||
426 | |||
427 | /* Set LED indicator on GPIOH3 */ | ||
428 | ret = it913x_write_reg(state, PRO_LINK, GPIOH3_EN, 0x1); | ||
429 | ret |= it913x_write_reg(state, PRO_LINK, GPIOH3_ON, 0x1); | ||
430 | ret |= it913x_write_reg(state, PRO_LINK, GPIOH3_O, 0x1); | ||
431 | |||
432 | ret |= it913x_write_reg(state, PRO_LINK, 0xf641, state->tuner_type); | ||
433 | ret |= it913x_write_reg(state, PRO_DMOD, 0xf5ca, 0x01); | ||
434 | ret |= it913x_write_reg(state, PRO_DMOD, 0xf715, 0x01); | ||
435 | |||
436 | b[0] = xtal & 0xff; | ||
437 | b[1] = (xtal >> 8) & 0xff; | ||
438 | b[2] = (xtal >> 16) & 0xff; | ||
439 | b[3] = (xtal >> 24); | ||
440 | ret |= it913x_write(state, PRO_DMOD, XTAL_CLK, b , 4); | ||
441 | |||
442 | b[0] = adc & 0xff; | ||
443 | b[1] = (adc >> 8) & 0xff; | ||
444 | b[2] = (adc >> 16) & 0xff; | ||
445 | ret |= it913x_write(state, PRO_DMOD, ADC_FREQ, b, 3); | ||
446 | |||
447 | if (state->config->adc_x2) | ||
448 | ret |= it913x_write_reg(state, PRO_DMOD, ADC_X_2, 0x01); | ||
449 | b[0] = 0; | ||
450 | b[1] = 0; | ||
451 | b[2] = 0; | ||
452 | ret |= it913x_write(state, PRO_DMOD, 0x0029, b, 3); | ||
453 | |||
454 | pr_info("Crystal Frequency :%d Adc Frequency :%d ADC X2: %02x\n", | ||
455 | state->crystalFrequency, state->adcFrequency, | ||
456 | state->config->adc_x2); | ||
457 | pr_debug("Xtal value :%04x Adc value :%04x\n", xtal, adc); | ||
458 | |||
459 | if (ret < 0) | ||
460 | return -ENODEV; | ||
461 | #endif | ||
462 | |||
463 | /* v1 or v2 tuner script */ | ||
464 | if (state->config->chip_ver > 1) | ||
465 | ret = it913x_fe_script_loader(state, it9135_v2); | ||
466 | else | ||
467 | ret = it913x_fe_script_loader(state, it9135_v1); | ||
468 | if (ret < 0) | ||
469 | return ret; | ||
470 | |||
471 | /* LNA Scripts */ | ||
472 | switch (state->tuner_type) { | ||
473 | case IT9135_51: | ||
474 | set_lna = it9135_51; | ||
475 | break; | ||
476 | case IT9135_52: | ||
477 | set_lna = it9135_52; | ||
478 | break; | ||
479 | case IT9135_60: | ||
480 | set_lna = it9135_60; | ||
481 | break; | ||
482 | case IT9135_61: | ||
483 | set_lna = it9135_61; | ||
484 | break; | ||
485 | case IT9135_62: | ||
486 | set_lna = it9135_62; | ||
487 | break; | ||
488 | case IT9135_38: | ||
489 | default: | ||
490 | set_lna = it9135_38; | ||
491 | } | ||
492 | pr_info("Tuner LNA type :%02x\n", state->tuner_type); | ||
493 | |||
494 | ret = it913x_fe_script_loader(state, set_lna); | ||
495 | if (ret < 0) | ||
496 | return ret; | ||
497 | |||
498 | if (state->config->chip_ver == 2) { | ||
499 | ret = it913x_write_reg(state, PRO_DMOD, TRIGGER_OFSM, 0x1); | ||
500 | ret |= it913x_write_reg(state, PRO_LINK, PADODPU, 0x0); | ||
501 | ret |= it913x_write_reg(state, PRO_LINK, AGC_O_D, 0x0); | ||
502 | ret |= it913x_init_tuner(fe); | ||
503 | } | ||
504 | if (ret < 0) | ||
505 | return -ENODEV; | ||
506 | |||
507 | /* Always solo frontend */ | ||
508 | // set_mode = set_solo_fe; | ||
509 | // ret |= it913x_fe_script_loader(state, set_mode); | ||
510 | |||
511 | ret |= it913x_fe_suspend(state); | ||
512 | return (ret < 0) ? -ENODEV : 0; | ||
513 | } | ||
514 | |||
515 | static int it913x_release(struct dvb_frontend *fe) | 444 | static int it913x_release(struct dvb_frontend *fe) |
516 | { | 445 | { |
517 | kfree(fe->tuner_priv); | 446 | kfree(fe->tuner_priv); |
@@ -566,10 +495,6 @@ struct dvb_frontend *it913x_attach(struct dvb_frontend *fe, | |||
566 | memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops, | 495 | memcpy(&fe->ops.tuner_ops, &it913x_tuner_ops, |
567 | sizeof(struct dvb_tuner_ops)); | 496 | sizeof(struct dvb_tuner_ops)); |
568 | 497 | ||
569 | ret = it913x_fe_start(fe); | ||
570 | if (ret < 0) | ||
571 | goto error; | ||
572 | |||
573 | pr_info("%s: ITE Tech IT913X attached\n", KBUILD_MODNAME); | 498 | pr_info("%s: ITE Tech IT913X attached\n", KBUILD_MODNAME); |
574 | 499 | ||
575 | return fe; | 500 | return fe; |