Thomas Gleixner | a0c7056 | 2019-05-23 11:14:50 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 2 | /* |
| 3 | * tdhd1.h - ALPS TDHD1-204A tuner support |
| 4 | * |
| 5 | * Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de> |
| 6 | * |
Mauro Carvalho Chehab | 991ce92 | 2015-12-04 10:38:59 -0200 | [diff] [blame] | 7 | * The project's page is at https://linuxtv.org |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 8 | */ |
| 9 | |
| 10 | #ifndef TDHD1_H |
| 11 | #define TDHD1_H |
| 12 | |
| 13 | #include "tda1004x.h" |
| 14 | |
Oliver Endriss | 83512e2 | 2008-09-04 20:35:19 -0300 | [diff] [blame] | 15 | static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name); |
| 16 | |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 17 | static struct tda1004x_config alps_tdhd1_204a_config = { |
| 18 | .demod_address = 0x8, |
| 19 | .invert = 1, |
| 20 | .invert_oclk = 0, |
| 21 | .xtal_freq = TDA10046_XTAL_4M, |
| 22 | .agc_config = TDA10046_AGC_DEFAULT, |
| 23 | .if_freq = TDA10046_FREQ_3617, |
Oliver Endriss | 83512e2 | 2008-09-04 20:35:19 -0300 | [diff] [blame] | 24 | .request_firmware = alps_tdhd1_204_request_firmware |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 25 | }; |
| 26 | |
Mauro Carvalho Chehab | 14d24d1 | 2011-12-24 12:24:33 -0300 | [diff] [blame] | 27 | static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe) |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 28 | { |
Mauro Carvalho Chehab | e7e10de | 2011-12-23 18:27:35 -0300 | [diff] [blame] | 29 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 30 | struct i2c_adapter *i2c = fe->tuner_priv; |
| 31 | u8 data[4]; |
| 32 | struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) }; |
| 33 | u32 div; |
| 34 | |
Mauro Carvalho Chehab | e7e10de | 2011-12-23 18:27:35 -0300 | [diff] [blame] | 35 | div = (p->frequency + 36166666) / 166666; |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 36 | |
| 37 | data[0] = (div >> 8) & 0x7f; |
| 38 | data[1] = div & 0xff; |
| 39 | data[2] = 0x85; |
| 40 | |
Mauro Carvalho Chehab | e7e10de | 2011-12-23 18:27:35 -0300 | [diff] [blame] | 41 | if (p->frequency >= 174000000 && p->frequency <= 230000000) |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 42 | data[3] = 0x02; |
Mauro Carvalho Chehab | e7e10de | 2011-12-23 18:27:35 -0300 | [diff] [blame] | 43 | else if (p->frequency >= 470000000 && p->frequency <= 823000000) |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 44 | data[3] = 0x0C; |
Mauro Carvalho Chehab | e7e10de | 2011-12-23 18:27:35 -0300 | [diff] [blame] | 45 | else if (p->frequency > 823000000 && p->frequency <= 862000000) |
Oliver Endriss | 81ae953 | 2008-09-03 18:16:09 -0300 | [diff] [blame] | 46 | data[3] = 0x8C; |
| 47 | else |
| 48 | return -EINVAL; |
| 49 | |
| 50 | if (fe->ops.i2c_gate_ctrl) |
| 51 | fe->ops.i2c_gate_ctrl(fe, 1); |
| 52 | if (i2c_transfer(i2c, &msg, 1) != 1) |
| 53 | return -EIO; |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | #endif /* TDHD1_H */ |