Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  * tdhd1.h - ALPS TDHD1-204A tuner support
0004  *
0005  * Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de>
0006  *
0007  * The project's page is at https://linuxtv.org
0008  */
0009 
0010 #ifndef TDHD1_H
0011 #define TDHD1_H
0012 
0013 #include "tda1004x.h"
0014 
0015 static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name);
0016 
0017 static struct tda1004x_config alps_tdhd1_204a_config = {
0018     .demod_address = 0x8,
0019     .invert = 1,
0020     .invert_oclk = 0,
0021     .xtal_freq = TDA10046_XTAL_4M,
0022     .agc_config = TDA10046_AGC_DEFAULT,
0023     .if_freq = TDA10046_FREQ_3617,
0024     .request_firmware = alps_tdhd1_204_request_firmware
0025 };
0026 
0027 static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe)
0028 {
0029     struct dtv_frontend_properties *p = &fe->dtv_property_cache;
0030     struct i2c_adapter *i2c = fe->tuner_priv;
0031     u8 data[4];
0032     struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
0033     u32 div;
0034 
0035     div = (p->frequency + 36166666) / 166666;
0036 
0037     data[0] = (div >> 8) & 0x7f;
0038     data[1] = div & 0xff;
0039     data[2] = 0x85;
0040 
0041     if (p->frequency >= 174000000 && p->frequency <= 230000000)
0042         data[3] = 0x02;
0043     else if (p->frequency >= 470000000 && p->frequency <= 823000000)
0044         data[3] = 0x0C;
0045     else if (p->frequency > 823000000 && p->frequency <= 862000000)
0046         data[3] = 0x8C;
0047     else
0048         return -EINVAL;
0049 
0050     if (fe->ops.i2c_gate_ctrl)
0051         fe->ops.i2c_gate_ctrl(fe, 1);
0052     if (i2c_transfer(i2c, &msg, 1) != 1)
0053         return -EIO;
0054 
0055     return 0;
0056 }
0057 
0058 #endif /* TDHD1_H */