All of lore.kernel.org
 help / color / mirror / Atom feed
From: Corentin FERRY <cocodidouf@gmail.com>
To: linux-media@vger.kernel.org
Subject: PCTV 340e: tuning again
Date: Wed, 25 Jun 2014 17:01:20 +0200	[thread overview]
Message-ID: <53AAE440.5020909@gmail.com> (raw)

Starting with kernel 3.11 (or a little bit earlier), the PCTV 340e DVB-T 
tuner would no longer tune to any channel.
There's been a patch which introduced a frequency offset in dib7000p, 
based on tuner frequency, here: 
https://github.com/torvalds/linux/commit/6fe10 
99c7aecc54ebf2fcf8e3af2225cd7bfa550 .
Yet, there should be no offset with the PCTV 340e's DIB7000P, as the 
COFDM demodulator is already set at the right frequency, i.e. the one 
the XC4000 tuner passes its data on.
In order to make the PCTV 340e work again, I have done the following:

In drivers/media/dvb-frontends/dib7000p.c :

static void dib7000p_set_dds(struct dib7000p_state *state, s32 offset_khz)
{
	u32 internal = dib7000p_get_internal_freq(state);
	s32 unit_khz_dds_val = 67108864 / (internal);	/* 2**26 / Fsampling is 
the unit 1KHz offset */
	u32 abs_offset_khz = ABS(offset_khz);
	u32 dds = state->cfg.bw->ifreq & 0x1ffffff;
	u8 invert = !!(state->cfg.bw->ifreq & (1 << 25));

	dprintk("setting a frequency offset of %dkHz internal freq = %d invert 
= %d", offset_khz, internal, invert);

	if (offset_khz < 0)
		unit_khz_dds_val *= -1;

	/* IF tuner */
//comment out the lines that involve the offset
//	if (invert)
//		dds -= (abs_offset_khz * unit_khz_dds_val);	/* /100 because of /100 
on the unit_khz_dds_val line calc for better accuracy */
//	else
//		dds += (abs_offset_khz * unit_khz_dds_val);

	if (abs_offset_khz <= (internal / 2)) {	/* Max dds offset is the half 
of the demod freq */
		dib7000p_write_word(state, 21, (u16) (((dds >> 16) & 0x1ff) | (0 << 
10) | (invert << 9)));
		dib7000p_write_word(state, 22, (u16) (dds & 0xffff));
	}
}

Restoring dib7000p_set_dds(state, 0); instead of the if 
(demod->ops.tuner_ops.get_frequency) {...} didn't do the trick (or I did 
something wrong with it...)).

This is a basic workaround to get it working, yet there may be units 
which embed a DIB7000P demodulator, and where this offset is required.
Does anybody out there have such an unit, or a justification for this 
offset setting?

Cheers,
Corentin FERRY

                 reply	other threads:[~2014-06-25 15:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53AAE440.5020909@gmail.com \
    --to=cocodidouf@gmail.com \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.