2019-05-23 12:14:50 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2008-09-04 01:16:09 +04:00
|
|
|
/*
|
|
|
|
* tdhd1.h - ALPS TDHD1-204A tuner support
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Oliver Endriss <o.endriss@gmx.de>
|
|
|
|
*
|
2015-12-04 15:38:59 +03:00
|
|
|
* The project's page is at https://linuxtv.org
|
2008-09-04 01:16:09 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TDHD1_H
|
|
|
|
#define TDHD1_H
|
|
|
|
|
|
|
|
#include "tda1004x.h"
|
|
|
|
|
2008-09-05 03:35:19 +04:00
|
|
|
static int alps_tdhd1_204_request_firmware(struct dvb_frontend *fe, const struct firmware **fw, char *name);
|
|
|
|
|
2008-09-04 01:16:09 +04:00
|
|
|
static struct tda1004x_config alps_tdhd1_204a_config = {
|
|
|
|
.demod_address = 0x8,
|
|
|
|
.invert = 1,
|
|
|
|
.invert_oclk = 0,
|
|
|
|
.xtal_freq = TDA10046_XTAL_4M,
|
|
|
|
.agc_config = TDA10046_AGC_DEFAULT,
|
|
|
|
.if_freq = TDA10046_FREQ_3617,
|
2008-09-05 03:35:19 +04:00
|
|
|
.request_firmware = alps_tdhd1_204_request_firmware
|
2008-09-04 01:16:09 +04:00
|
|
|
};
|
|
|
|
|
2011-12-24 19:24:33 +04:00
|
|
|
static int alps_tdhd1_204a_tuner_set_params(struct dvb_frontend *fe)
|
2008-09-04 01:16:09 +04:00
|
|
|
{
|
2011-12-24 01:27:35 +04:00
|
|
|
struct dtv_frontend_properties *p = &fe->dtv_property_cache;
|
2008-09-04 01:16:09 +04:00
|
|
|
struct i2c_adapter *i2c = fe->tuner_priv;
|
|
|
|
u8 data[4];
|
|
|
|
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
|
|
|
|
u32 div;
|
|
|
|
|
2011-12-24 01:27:35 +04:00
|
|
|
div = (p->frequency + 36166666) / 166666;
|
2008-09-04 01:16:09 +04:00
|
|
|
|
|
|
|
data[0] = (div >> 8) & 0x7f;
|
|
|
|
data[1] = div & 0xff;
|
|
|
|
data[2] = 0x85;
|
|
|
|
|
2011-12-24 01:27:35 +04:00
|
|
|
if (p->frequency >= 174000000 && p->frequency <= 230000000)
|
2008-09-04 01:16:09 +04:00
|
|
|
data[3] = 0x02;
|
2011-12-24 01:27:35 +04:00
|
|
|
else if (p->frequency >= 470000000 && p->frequency <= 823000000)
|
2008-09-04 01:16:09 +04:00
|
|
|
data[3] = 0x0C;
|
2011-12-24 01:27:35 +04:00
|
|
|
else if (p->frequency > 823000000 && p->frequency <= 862000000)
|
2008-09-04 01:16:09 +04:00
|
|
|
data[3] = 0x8C;
|
|
|
|
else
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (fe->ops.i2c_gate_ctrl)
|
|
|
|
fe->ops.i2c_gate_ctrl(fe, 1);
|
|
|
|
if (i2c_transfer(i2c, &msg, 1) != 1)
|
|
|
|
return -EIO;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* TDHD1_H */
|