Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 76439
b: refs/heads/master
c: 794604c
h: refs/heads/master
i:
  76437: 7d8d53e
  76435: 688cbbc
  76431: 301ea5c
v: v3
  • Loading branch information
Chris Pascoe authored and Mauro Carvalho Chehab committed Jan 25, 2008
1 parent 90a96c5 commit 7bc8b17
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 58d834ea89664b41e6e21ed2d8dc5680d0dd76b6
refs/heads/master: 794604c3efb511b74fb664af72c5dd7046e91075
42 changes: 37 additions & 5 deletions trunk/drivers/media/dvb/frontends/zl10353.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
* Copyright (C) 2006, 2007 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <linux/kernel.h>
Expand All @@ -25,6 +25,7 @@
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/div64.h>

#include "dvb_frontend.h"
#include "zl10353_priv.h"
Expand Down Expand Up @@ -148,6 +149,35 @@ static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
__FUNCTION__, bw, adc_clock, *nominal_rate);
}

static void zl10353_calc_input_freq(struct dvb_frontend *fe,
u16 *input_freq)
{
struct zl10353_state *state = fe->demodulator_priv;
u32 adc_clock = 45056; /* 45.056 MHz */
int if2 = 36167; /* 36.167 MHz */
int ife;
u64 value;

if (state->config.adc_clock)
adc_clock = state->config.adc_clock;
if (state->config.if2)
if2 = state->config.if2;

if (adc_clock >= if2 * 2)
ife = if2;
else {
ife = adc_clock - (if2 % adc_clock);
if (ife > adc_clock / 2)
ife = adc_clock - ife;
}
value = 65536ULL * ife + adc_clock / 2;
do_div(value, adc_clock);
*input_freq = -value;

dprintk("%s: if2 %d, ife %d, adc_clock %d => %d / 0x%x\n",
__FUNCTION__, if2, ife, adc_clock, -(int)value, *input_freq);
}

static int zl10353_sleep(struct dvb_frontend *fe)
{
static u8 zl10353_softdown[] = { 0x50, 0x0C, 0x44 };
Expand All @@ -160,7 +190,7 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
struct dvb_frontend_parameters *param)
{
struct zl10353_state *state = fe->demodulator_priv;
u16 nominal_rate;
u16 nominal_rate, input_freq;
u8 pllbuf[6] = { 0x67 };

/* These settings set "auto-everything" and start the FSM. */
Expand All @@ -178,8 +208,10 @@ static int zl10353_set_parameters(struct dvb_frontend *fe,
zl10353_single_write(fe, TRL_NOMINAL_RATE_1, msb(nominal_rate));
zl10353_single_write(fe, TRL_NOMINAL_RATE_0, lsb(nominal_rate));

zl10353_single_write(fe, 0x6C, 0xCD);
zl10353_single_write(fe, 0x6D, 0x7E);
zl10353_calc_input_freq(fe, &input_freq);
zl10353_single_write(fe, INPUT_FREQ_1, msb(input_freq));
zl10353_single_write(fe, INPUT_FREQ_0, lsb(input_freq));

if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 0);

Expand Down
3 changes: 2 additions & 1 deletion trunk/drivers/media/dvb/frontends/zl10353.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
* Copyright (C) 2006, 2007 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,6 +31,7 @@ struct zl10353_config

/* frequencies in kHz */
int adc_clock; /* default: 45056 */
int if2; /* default: 36167 */

/* set if no pll is connected to the secondary i2c bus */
int no_tuner;
Expand Down
6 changes: 4 additions & 2 deletions trunk/drivers/media/dvb/frontends/zl10353_priv.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Driver for Zarlink DVB-T ZL10353 demodulator
*
* Copyright (C) 2006 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
* Copyright (C) 2006, 2007 Christopher Pascoe <c.pascoe@itee.uq.edu.au>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef _ZL10353_PRIV_
Expand Down Expand Up @@ -48,6 +48,8 @@ enum zl10353_reg_addr {
RS_UBC_0 = 0x15,
TRL_NOMINAL_RATE_1 = 0x65,
TRL_NOMINAL_RATE_0 = 0x66,
INPUT_FREQ_1 = 0x6C,
INPUT_FREQ_0 = 0x6D,
TUNER_GO = 0x70,
FSM_GO = 0x71,
CHIP_ID = 0x7F,
Expand Down

0 comments on commit 7bc8b17

Please sign in to comment.