]>
Commit | Line | Data |
---|---|---|
a0c7056f | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
81ae953b OE |
2 | /* |
3 | * tdhd1.h - ALPS TDHD1-204A tuner support | |
4 | * | |
5 | * Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de> | |
6 | * | |
991ce92f | 7 | * The project's page is at https://linuxtv.org |
81ae953b OE |
8 | */ |
9 | ||
10 | #ifndef TDHD1_H | |
11 | #define TDHD1_H | |
12 | ||
13 | #include "tda1004x.h" | |
14 | ||
83512e20 OE |
15 | static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name); |
16 | ||
81ae953b OE |
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, | |
83512e20 | 24 | .request_firmware = alps_tdhd1_204_request_firmware |
81ae953b OE |
25 | }; |
26 | ||
14d24d14 | 27 | static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe) |
81ae953b | 28 | { |
e7e10deb | 29 | struct dtv_frontend_properties *p = &fe->dtv_property_cache; |
81ae953b OE |
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 | ||
e7e10deb | 35 | div = (p->frequency + 36166666) / 166666; |
81ae953b OE |
36 | |
37 | data[0] = (div >> 8) & 0x7f; | |
38 | data[1] = div & 0xff; | |
39 | data[2] = 0x85; | |
40 | ||
e7e10deb | 41 | if (p->frequency >= 174000000 && p->frequency <= 230000000) |
81ae953b | 42 | data[3] = 0x02; |
e7e10deb | 43 | else if (p->frequency >= 470000000 && p->frequency <= 823000000) |
81ae953b | 44 | data[3] = 0x0C; |
e7e10deb | 45 | else if (p->frequency > 823000000 && p->frequency <= 862000000) |
81ae953b OE |
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 */ |