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