All of lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
@ 2012-03-30 12:33 Antti Palosaari
  2012-03-30 21:45 ` Michael Büsch
                   ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-03-30 12:33 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media

Terve Mauro and all the other hackers,

I did some massive rewrite for my old AF9035/AF9033 driver that was 
never merged. Anyhow, here it is.

New drivers here are:
Infineon TUA 9001 silicon tuner driver
Afatech AF9033 DVB-T demodulator driver
Afatech AF9035 DVB USB driver

AF9035 integrates AF9033. Both chips are also sold separately. AF9033 
will not likely work as a stand-alone since I didn't have hardware to 
test, but in theory it is quite well split out from the DVB USB 
interface driver (AF9035).

Tips for cheap AF9035 based dual devices are welcome!

regards
Antti


The following changes since commit 26315a507f6acda933f0d41200de8fec51775867:

   em28xx-dvb: stop URBs when stopping the streaming (2012-03-28 
15:32:23 +0300)

are available in the git repository at:
   git://linuxtv.org/anttip/media_tree.git af9035

Antti Palosaari (3):
       Infineon TUA 9001 silicon tuner driver
       Afatech AF9033 DVB-T demodulator driver
       Afatech AF9035 DVB USB driver

  drivers/media/common/tuners/Kconfig        |    6 +
  drivers/media/common/tuners/Makefile       |    1 +
  drivers/media/common/tuners/tua9001.c      |  215 ++++++++
  drivers/media/common/tuners/tua9001.h      |   46 ++
  drivers/media/common/tuners/tua9001_priv.h |   34 ++
  drivers/media/dvb/dvb-usb/Kconfig          |    9 +
  drivers/media/dvb/dvb-usb/Makefile         |    3 +
  drivers/media/dvb/dvb-usb/af9035.c         |  799 
++++++++++++++++++++++++++++
  drivers/media/dvb/dvb-usb/af9035.h         |  102 ++++
  drivers/media/dvb/dvb-usb/dvb-usb-ids.h    |    1 +
  drivers/media/dvb/frontends/Kconfig        |    5 +
  drivers/media/dvb/frontends/Makefile       |    1 +
  drivers/media/dvb/frontends/af9033.c       |  706 ++++++++++++++++++++++++
  drivers/media/dvb/frontends/af9033.h       |   73 +++
  drivers/media/dvb/frontends/af9033_priv.h  |  242 +++++++++
  15 files changed, 2243 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/common/tuners/tua9001.c
  create mode 100644 drivers/media/common/tuners/tua9001.h
  create mode 100644 drivers/media/common/tuners/tua9001_priv.h
  create mode 100644 drivers/media/dvb/dvb-usb/af9035.c
  create mode 100644 drivers/media/dvb/dvb-usb/af9035.h
  create mode 100644 drivers/media/dvb/frontends/af9033.c
  create mode 100644 drivers/media/dvb/frontends/af9033.h
  create mode 100644 drivers/media/dvb/frontends/af9033_priv.h
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-30 12:33 [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Antti Palosaari
@ 2012-03-30 21:45 ` Michael Büsch
  2012-03-30 22:00   ` Antti Palosaari
  2012-04-06 11:11 ` Antti Palosaari
  2012-05-07 18:44 ` [GIT PULL FOR 3.5] AF9035/AF9033 Antti Palosaari
  2 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-03-30 21:45 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media

[-- Attachment #1: Type: text/plain, Size: 777 bytes --]

On Fri, 30 Mar 2012 15:33:02 +0300
Antti Palosaari <crope@iki.fi> wrote:

> Terve Mauro and all the other hackers,
> 
> I did some massive rewrite for my old AF9035/AF9033 driver that was 
> never merged. Anyhow, here it is.
> 
> New drivers here are:
> Infineon TUA 9001 silicon tuner driver
> Afatech AF9033 DVB-T demodulator driver
> Afatech AF9035 DVB USB driver

This looks pretty nice.

I recently wrote a tuner driver for the fc0011 tuner, which is used in some
af9035 sticks:
http://patchwork.linuxtv.org/patch/10503/

It was developed against an af903x driver by Hans-Frieder Vogt.

I'll port it to your AF9035 driver, ASAP, to check whether this works
on my DVB USB stick.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-30 21:45 ` Michael Büsch
@ 2012-03-30 22:00   ` Antti Palosaari
  2012-03-30 22:14     ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-03-30 22:00 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Mauro Carvalho Chehab, linux-media

On 31.03.2012 00:45, Michael Büsch wrote:
> On Fri, 30 Mar 2012 15:33:02 +0300
> Antti Palosaari<crope@iki.fi>  wrote:
>
>> Terve Mauro and all the other hackers,
>>
>> I did some massive rewrite for my old AF9035/AF9033 driver that was
>> never merged. Anyhow, here it is.
>>
>> New drivers here are:
>> Infineon TUA 9001 silicon tuner driver
>> Afatech AF9033 DVB-T demodulator driver
>> Afatech AF9035 DVB USB driver
>
> This looks pretty nice.
>
> I recently wrote a tuner driver for the fc0011 tuner, which is used in some
> af9035 sticks:
> http://patchwork.linuxtv.org/patch/10503/
>
> It was developed against an af903x driver by Hans-Frieder Vogt.
>
> I'll port it to your AF9035 driver, ASAP, to check whether this works
> on my DVB USB stick.

Feel free to do that. Actually, I just tried it about 2 hours ago. But I 
failed, since there callbacks given as a param for tuner attach and it 
is wrong. There is frontend callback defined just for that. Look example 
from some Xceive tuners also hd29l2 demod driver contains one example. 
Use git grep DVB_FRONTEND_COMPONENT_ drivers/media/ to see all those 
existing callbacks.

struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe, struct 
i2c_adapter *i2c, u8 i2c_address, int (*tuner_reset)(unsigned long, 
unsigned long),unsigned long tuner_reset_arg0,unsigned long 
tuner_reset_arg1)

My short term plans are now
* fix af9033 IF freq control (now Zero-IF only)
* change firmware download to use new firmware syntax
* dual tuner support
* check if IT9035 is enough similar (My personal suspicion is that 
integrated tuner is only main difference, whilst USB-interface and demod 
are same. But someone has told that it is quite different design though.)
* implement SNR, BER and USB counters
* implement remote controller

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-30 22:00   ` Antti Palosaari
@ 2012-03-30 22:14     ` Michael Büsch
  2012-03-31 14:04       ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-03-30 22:14 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media

[-- Attachment #1: Type: text/plain, Size: 1073 bytes --]

On Sat, 31 Mar 2012 01:00:21 +0300
Antti Palosaari <crope@iki.fi> wrote:

> Feel free to do that. Actually, I just tried it about 2 hours ago. But I 
> failed, since there callbacks given as a param for tuner attach and it 
> is wrong. There is frontend callback defined just for that. Look example 
> from some Xceive tuners also hd29l2 demod driver contains one example. 
> Use git grep DVB_FRONTEND_COMPONENT_ drivers/media/ to see all those 
> existing callbacks.

Cool. Thanks for the hint. I'll fix this.

> My short term plans are now
> * fix af9033 IF freq control (now Zero-IF only)
> * change firmware download to use new firmware syntax
> * dual tuner support
> * check if IT9035 is enough similar (My personal suspicion is that 
> integrated tuner is only main difference, whilst USB-interface and demod 
> are same. But someone has told that it is quite different design though.)
> * implement SNR, BER and USB counters
> * implement remote controller

Sounds good.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-30 22:14     ` Michael Büsch
@ 2012-03-31 14:04       ` Michael Büsch
  2012-03-31 14:28         ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-03-31 14:04 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media

[-- Attachment #1: Type: text/plain, Size: 796 bytes --]

On Sat, 31 Mar 2012 00:14:58 +0200
Michael Büsch <m@bues.ch> wrote:

> On Sat, 31 Mar 2012 01:00:21 +0300
> Antti Palosaari <crope@iki.fi> wrote:
> 
> > Feel free to do that. Actually, I just tried it about 2 hours ago. But I 
> > failed, since there callbacks given as a param for tuner attach and it 
> > is wrong. There is frontend callback defined just for that. Look example 
> > from some Xceive tuners also hd29l2 demod driver contains one example. 
> > Use git grep DVB_FRONTEND_COMPONENT_ drivers/media/ to see all those 
> > existing callbacks.
> 
> Cool. Thanks for the hint. I'll fix this.

Ok, so I cooked something up here.
I'm wondering where to get the firmware file from, so I can test it.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 14:04       ` Michael Büsch
@ 2012-03-31 14:28         ` Antti Palosaari
  2012-03-31 16:29           ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-03-31 14:28 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Mauro Carvalho Chehab, linux-media

On 31.03.2012 17:04, Michael Büsch wrote:
> On Sat, 31 Mar 2012 00:14:58 +0200
> Michael Büsch<m@bues.ch>  wrote:
>
>> On Sat, 31 Mar 2012 01:00:21 +0300
>> Antti Palosaari<crope@iki.fi>  wrote:
>>
>>> Feel free to do that. Actually, I just tried it about 2 hours ago. But I
>>> failed, since there callbacks given as a param for tuner attach and it
>>> is wrong. There is frontend callback defined just for that. Look example
>>> from some Xceive tuners also hd29l2 demod driver contains one example.
>>> Use git grep DVB_FRONTEND_COMPONENT_ drivers/media/ to see all those
>>> existing callbacks.
>>
>> Cool. Thanks for the hint. I'll fix this.
>
> Ok, so I cooked something up here.
> I'm wondering where to get the firmware file from, so I can test it.

Googling the filename reveals many links, here is one:
http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw

I will try to make new firmware loader during that weekend, now I am 
busy hacking with it9035 I have. It is rather similar, but for some 
nasty reason I haven't got lock. If it does not found soon I will jump 
back for implementing those missing basic features.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 14:28         ` Antti Palosaari
@ 2012-03-31 16:29           ` Michael Büsch
  2012-03-31 16:34             ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-03-31 16:29 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media

[-- Attachment #1: Type: text/plain, Size: 722 bytes --]

On Sat, 31 Mar 2012 17:28:38 +0300
Antti Palosaari <crope@iki.fi> wrote:

> Googling the filename reveals many links, here is one:
> http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw

Hm, on tuner register access I get these errors:

[ 9259.080907] af9035_ctrl_msg: command=03 failed fw error=2
[ 9259.080922] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f

Is it possible that this firmware is incompatible with my stick?
The firmware that I successfully used with the other af9035 driver seems to
be incompatible with your driver, though. It crashes it somewhere
on firmware download in one of the USB transfer's memcpy.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 16:29           ` Michael Büsch
@ 2012-03-31 16:34             ` Antti Palosaari
  2012-03-31 16:48               ` Antti Palosaari
  2012-03-31 16:49               ` [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Michael Büsch
  0 siblings, 2 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-03-31 16:34 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Mauro Carvalho Chehab, linux-media

On 31.03.2012 19:29, Michael Büsch wrote:
> On Sat, 31 Mar 2012 17:28:38 +0300
> Antti Palosaari<crope@iki.fi>  wrote:
>
>> Googling the filename reveals many links, here is one:
>> http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw
>
> Hm, on tuner register access I get these errors:
>
> [ 9259.080907] af9035_ctrl_msg: command=03 failed fw error=2
> [ 9259.080922] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f
>
> Is it possible that this firmware is incompatible with my stick?
> The firmware that I successfully used with the other af9035 driver seems to
> be incompatible with your driver, though. It crashes it somewhere
> on firmware download in one of the USB transfer's memcpy.

Most likely it is incompatible. It is surely one of the earliest 
firmwares. I will try to make that new fw downloaded ASAP, likely 
tomorrow morning it is done.

And good news about IT9035 support - it is working. It was very few 
changes needed, new initialization tables for af9033 and new firmware 
uploader for af9035. Of course new tuner drivers is also needed, but it 
seems to be very simple. yay, AF9035 is basically same as IT9035 + 
integrated tuner.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 16:34             ` Antti Palosaari
@ 2012-03-31 16:48               ` Antti Palosaari
  2012-03-31 16:52                 ` Michael Büsch
  2012-03-31 16:49               ` [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Michael Büsch
  1 sibling, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-03-31 16:48 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media

I dropped Mauro from cc since he is not likely interested of that 
development.

On 31.03.2012 19:34, Antti Palosaari wrote:
> On 31.03.2012 19:29, Michael Büsch wrote:
>> On Sat, 31 Mar 2012 17:28:38 +0300
>> Antti Palosaari<crope@iki.fi> wrote:
>>
>>> Googling the filename reveals many links, here is one:
>>> http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw
>>
>> Hm, on tuner register access I get these errors:
>>
>> [ 9259.080907] af9035_ctrl_msg: command=03 failed fw error=2
>> [ 9259.080922] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f
>>
>> Is it possible that this firmware is incompatible with my stick?
>> The firmware that I successfully used with the other af9035 driver
>> seems to
>> be incompatible with your driver, though. It crashes it somewhere
>> on firmware download in one of the USB transfer's memcpy.
>
> Most likely it is incompatible. It is surely one of the earliest
> firmwares. I will try to make that new fw downloaded ASAP, likely
> tomorrow morning it is done.
>
> And good news about IT9035 support - it is working. It was very few
> changes needed, new initialization tables for af9033 and new firmware
> uploader for af9035. Of course new tuner drivers is also needed, but it
> seems to be very simple. yay, AF9035 is basically same as IT9035 +
> integrated tuner.

Ooops, I mean IT9135.

And about the new FW downloader, that supports those new firmwares, feel 
free to implement it if you wish too. I will now goto out of house and 
will back during few hours. If you wish to do it just reply during 4 
hours, and I will not start working for it. Instead I will continue with 
IT9135.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 16:34             ` Antti Palosaari
  2012-03-31 16:48               ` Antti Palosaari
@ 2012-03-31 16:49               ` Michael Büsch
  1 sibling, 0 replies; 45+ messages in thread
From: Michael Büsch @ 2012-03-31 16:49 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Mauro Carvalho Chehab, linux-media


[-- Attachment #1.1: Type: text/plain, Size: 1158 bytes --]

On Sat, 31 Mar 2012 19:34:23 +0300
Antti Palosaari <crope@iki.fi> wrote:

> On 31.03.2012 19:29, Michael Büsch wrote:
> > On Sat, 31 Mar 2012 17:28:38 +0300
> > Antti Palosaari<crope@iki.fi>  wrote:
> >
> >> Googling the filename reveals many links, here is one:
> >> http://xgazza.altervista.org/Linux/DVB/dvb-usb-af9035-01.fw
> >
> > Hm, on tuner register access I get these errors:
> >
> > [ 9259.080907] af9035_ctrl_msg: command=03 failed fw error=2
> > [ 9259.080922] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f
> >
> > Is it possible that this firmware is incompatible with my stick?
> > The firmware that I successfully used with the other af9035 driver seems to
> > be incompatible with your driver, though. It crashes it somewhere
> > on firmware download in one of the USB transfer's memcpy.
> 
> Most likely it is incompatible. It is surely one of the earliest 
> firmwares. I will try to make that new fw downloaded ASAP, likely 
> tomorrow morning it is done.

Ok, thanks a lot.

Attached are my current fc0011 patches. Just for reference.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: fc0011-tuner.patch --]
[-- Type: text/x-patch, Size: 16820 bytes --]

Index: linux/drivers/media/common/tuners/Kconfig
===================================================================
--- linux.orig/drivers/media/common/tuners/Kconfig	2012-03-31 00:32:25.000000000 +0200
+++ linux/drivers/media/common/tuners/Kconfig	2012-03-31 13:03:07.279334714 +0200
@@ -204,6 +204,13 @@
 	help
 	  NXP TDA18218 silicon tuner driver.
 
+config MEDIA_TUNER_FC0011
+	tristate "Fitipower FC0011 silicon tuner"
+	depends on VIDEO_MEDIA && I2C
+	default m if MEDIA_TUNER_CUSTOMISE
+	help
+	  Fitipower FC0011 silicon tuner driver.
+
 config MEDIA_TUNER_TDA18212
 	tristate "NXP TDA18212 silicon tuner"
 	depends on VIDEO_MEDIA && I2C
Index: linux/drivers/media/common/tuners/Makefile
===================================================================
--- linux.orig/drivers/media/common/tuners/Makefile	2012-03-31 00:32:25.000000000 +0200
+++ linux/drivers/media/common/tuners/Makefile	2012-03-31 13:03:42.444806267 +0200
@@ -29,6 +29,7 @@
 obj-$(CONFIG_MEDIA_TUNER_TDA18218) += tda18218.o
 obj-$(CONFIG_MEDIA_TUNER_TDA18212) += tda18212.o
 obj-$(CONFIG_MEDIA_TUNER_TUA9001) += tua9001.o
+obj-$(CONFIG_MEDIA_TUNER_FC0011) += fc0011.o
 
 ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
Index: linux/drivers/media/common/tuners/fc0011.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/media/common/tuners/fc0011.c	2012-03-31 14:30:24.122314647 +0200
@@ -0,0 +1,489 @@
+/*
+ * Fitipower FC0011 tuner driver
+ *
+ * Copyright (C) 2012 Michael Buesch <m@bues.ch>
+ *
+ * Derived from FC0012 tuner driver:
+ * Copyright (C) 2012 Hans-Frieder Vogt <hfvogt@gmx.net>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#include "fc0011.h"
+
+
+/* Tuner registers */
+enum {
+	FC11_REG_0,
+	FC11_REG_FA,		/* FA */
+	FC11_REG_FP,		/* FP */
+	FC11_REG_XINHI,		/* XIN high 8 bit */
+	FC11_REG_XINLO,		/* XIN low 8 bit */
+	FC11_REG_VCO,		/* VCO */
+	FC11_REG_VCOSEL,	/* VCO select */
+	FC11_REG_7,		/* Unknown tune reg 7 */
+	FC11_REG_8,		/* Unknown tune reg 8 */
+	FC11_REG_9,
+	FC11_REG_10,		/* Unknown tune reg 10 */
+	FC11_REG_11,		/* Unknown tune reg 11 */
+	FC11_REG_12,
+	FC11_REG_RCCAL,		/* RC calibrate */
+	FC11_REG_VCOCAL,	/* VCO calibrate */
+	FC11_REG_15,
+	FC11_REG_16,		/* Unknown tune reg 16 */
+	FC11_REG_17,
+
+	FC11_NR_REGS,		/* Number of registers */
+};
+
+enum FC11_REG_VCOSEL_bits {
+	FC11_VCOSEL_2		= 0x08, /* VCO select 2 */
+	FC11_VCOSEL_1		= 0x10, /* VCO select 1 */
+	FC11_VCOSEL_CLKOUT	= 0x20, /* Fix clock out */
+	FC11_VCOSEL_BW7M	= 0x40, /* 7MHz bw */
+	FC11_VCOSEL_BW6M	= 0x80, /* 6MHz bw */
+};
+
+enum FC11_REG_RCCAL_bits {
+	FC11_RCCAL_FORCE	= 0x10, /* force */
+};
+
+enum FC11_REG_VCOCAL_bits {
+	FC11_VCOCAL_RUN		= 0,	/* VCO calibration run */
+	FC11_VCOCAL_VALUEMASK	= 0x3F,	/* VCO calibration value mask */
+	FC11_VCOCAL_OK		= 0x40,	/* VCO calibration Ok */
+	FC11_VCOCAL_RESET	= 0x80, /* VCO calibration reset */
+};
+
+
+struct fc0011_priv {
+	struct i2c_adapter *i2c;
+	u8 addr;
+
+	u32 frequency;
+	u32 bandwidth;
+};
+
+
+static int fc0011_writereg(struct fc0011_priv *priv, u8 reg, u8 val)
+{
+	u8 buf[2] = { reg, val };
+	struct i2c_msg msg = { .addr = priv->addr,
+		.flags = 0, .buf = buf, .len = 2 };
+
+	msleep(1);
+	if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
+		dev_err(&priv->i2c->dev,
+			"I2C write reg failed, reg: %02x, val: %02x\n",
+			reg, val);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
+{
+	struct i2c_msg msg[2] = {
+		{ .addr = priv->addr,
+		  .flags = 0, .buf = &reg, .len = 1 },
+		{ .addr = priv->addr,
+		  .flags = I2C_M_RD, .buf = val, .len = 1 },
+	};
+
+	if (i2c_transfer(priv->i2c, msg, 2) != 2) {
+		dev_err(&priv->i2c->dev,
+			"I2C read failed, reg: %02x\n", reg);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int fc0011_release(struct dvb_frontend *fe)
+{
+	kfree(fe->tuner_priv);
+	fe->tuner_priv = NULL;
+
+	return 0;
+}
+
+static int fc0011_init(struct dvb_frontend *fe)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+	int err;
+
+	if (WARN_ON(!fe->callback))
+		return -EINVAL;
+	err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
+			   FC0011_FE_CALLBACK_POWER, 0);
+	if (err) {
+		dev_err(&priv->i2c->dev, "power-on callback failed\n");
+		return err;
+	}
+
+	return 0;
+}
+
+static int fc0011_set_params(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	struct fc0011_priv *priv = fe->tuner_priv;
+	int err;
+	unsigned int i;
+	u32 freq = p->frequency / 1000;
+	u32 bandwidth = p->bandwidth_hz / 1000;
+	u32 fvco, xin, xdiv, xdivr;
+	u16 frac;
+	u8 fa, fp, vco_sel, vco_cal;
+	u8 regs[FC11_NR_REGS] = { };
+
+	regs[FC11_REG_7] = 0x0F;
+	regs[FC11_REG_8] = 0x3E;
+	regs[FC11_REG_10] = 0xB8;
+	regs[FC11_REG_11] = 0x80;
+	regs[FC11_REG_RCCAL] = 0x04;
+	err = fc0011_writereg(priv, FC11_REG_7, regs[FC11_REG_7]);
+	err |= fc0011_writereg(priv, FC11_REG_8, regs[FC11_REG_8]);
+	err |= fc0011_writereg(priv, FC11_REG_10, regs[FC11_REG_10]);
+	err |= fc0011_writereg(priv, FC11_REG_11, regs[FC11_REG_11]);
+	err |= fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+	if (err)
+		return -EIO;
+
+	/* Set VCO freq and VCO div */
+	if (freq < 54000) {
+		fvco = freq * 64;
+		regs[FC11_REG_VCO] = 0x82;
+	} else if (freq < 108000) {
+		fvco = freq * 32;
+		regs[FC11_REG_VCO] = 0x42;
+	} else if (freq < 216000) {
+		fvco = freq * 16;
+		regs[FC11_REG_VCO] = 0x22;
+	} else if (freq < 432000) {
+		fvco = freq * 8;
+		regs[FC11_REG_VCO] = 0x12;
+	} else {
+		fvco = freq * 4;
+		regs[FC11_REG_VCO] = 0x0A;
+	}
+
+	/* Calc XIN. The PLL reference frequency is 18 MHz. */
+	xdiv = fvco / 18000;
+	frac = fvco - xdiv * 18000;
+	frac = (frac << 15) / 18000;
+	if (frac >= 16384)
+		frac += 32786;
+	if (!frac)
+		xin = 0;
+	else if (frac < 511)
+		xin = 512;
+	else if (frac < 65026)
+		xin = frac;
+	else
+		xin = 65024;
+	regs[FC11_REG_XINHI] = xin >> 8;
+	regs[FC11_REG_XINLO] = xin;
+
+	/* Calc FP and FA */
+	xdivr = xdiv;
+	if (fvco - xdiv * 18000 >= 9000)
+		xdivr += 1; /* round */
+	fp = xdivr / 8;
+	fa = xdivr - fp * 8;
+	if (fa < 2) {
+		fp -= 1;
+		fa += 8;
+	}
+	if (fp > 0x1F) {
+		fp &= 0x1F;
+		fa &= 0xF;
+	}
+	if (fa >= fp) {
+		dev_warn(&priv->i2c->dev,
+			 "fa %02X >= fp %02X, but trying to continue\n",
+			 (unsigned int)(u8)fa, (unsigned int)(u8)fp);
+	}
+	regs[FC11_REG_FA] = fa;
+	regs[FC11_REG_FP] = fp;
+
+	/* Select bandwidth */
+	switch (bandwidth) {
+	case 8000:
+		break;
+	case 7000:
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW7M;
+		break;
+	default:
+	case 6000:
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW6M;
+		break;
+	}
+
+	/* Pre VCO select */
+	if (fvco < 2320000) {
+		vco_sel = 0;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+	} else if (fvco < 3080000) {
+		vco_sel = 1;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+	} else {
+		vco_sel = 2;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+	}
+
+	/* Fix for low freqs */
+	if (freq < 45000) {
+		regs[FC11_REG_FA] = 0x6;
+		regs[FC11_REG_FP] = 0x11;
+	}
+
+	/* Clock out fix */
+	regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_CLKOUT;
+
+	/* Write the cached registers */
+	for (i = FC11_REG_FA; i <= FC11_REG_VCOSEL; i++) {
+		err = fc0011_writereg(priv, i, regs[i]);
+		if (err)
+			return err;
+	}
+
+	/* VCO calibration */
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RESET);
+	if (err)
+		return err;
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	/* Read calib val */
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	msleep(10);
+	err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+	if (err)
+		return err;
+	if (!(vco_cal & FC11_VCOCAL_OK)) {
+		/* Reset the tuner and try again */
+		err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
+				   FC0011_FE_CALLBACK_RESET, 0);
+		if (err) {
+			dev_err(&priv->i2c->dev, "Failed to reset tuner\n");
+			return err;
+		}
+		/* Reinit tuner config */
+		err = 0;
+		for (i = FC11_REG_FA; i <= FC11_REG_VCOSEL; i++)
+			err |= fc0011_writereg(priv, i, regs[i]);
+		err |= fc0011_writereg(priv, FC11_REG_7, regs[FC11_REG_7]);
+		err |= fc0011_writereg(priv, FC11_REG_8, regs[FC11_REG_8]);
+		err |= fc0011_writereg(priv, FC11_REG_10, regs[FC11_REG_10]);
+		err |= fc0011_writereg(priv, FC11_REG_11, regs[FC11_REG_11]);
+		err |= fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+		if (err)
+			return -EIO;
+		/* VCO calibration */
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RESET);
+		if (err)
+			return err;
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+		if (err)
+			return err;
+		/* Read calib val */
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+		if (err)
+			return err;
+		msleep(10);
+		err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+		if (err)
+			return err;
+	}
+	if (!(vco_cal & FC11_VCOCAL_OK)) {
+		dev_err(&priv->i2c->dev, "Failed to read VCO calibration value\n");
+		return -EIO;
+	}
+	vco_cal &= FC11_VCOCAL_VALUEMASK;
+
+	switch (vco_sel) {
+	case 0:
+		if (vco_cal < 8) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		}
+		break;
+	case 1:
+		if (vco_cal < 5) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else if (vco_cal <= 48) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		}
+		break;
+	case 2:
+		if (vco_cal > 53) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		}
+		break;
+	}
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	msleep(10);
+	err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+	if (err)
+		return err;
+	msleep(10);
+
+	err = fc0011_readreg(priv, FC11_REG_RCCAL, &regs[FC11_REG_RCCAL]);
+	if (err)
+		return err;
+	regs[FC11_REG_RCCAL] |= FC11_RCCAL_FORCE;
+	err = fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+	if (err)
+		return err;
+	err = fc0011_writereg(priv, FC11_REG_16, 0xB);
+	if (err)
+		return err;
+
+	priv->frequency = p->frequency;
+	priv->bandwidth = p->bandwidth_hz;
+
+	return 0;
+}
+
+static int fc0011_get_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+
+	*frequency = priv->frequency;
+
+	return 0;
+}
+
+static int fc0011_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+	*frequency = 0;
+
+	return 0;
+}
+
+static int fc0011_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+
+	*bandwidth = priv->bandwidth;
+
+	return 0;
+}
+
+static const struct dvb_tuner_ops fc0011_tuner_ops = {
+	.info = {
+		.name		= "Fitipower FC0011",
+
+		.frequency_min	= 45000000,
+		.frequency_max	= 1000000000,
+	},
+
+	.release		= fc0011_release,
+	.init			= fc0011_init,
+
+	.set_params		= fc0011_set_params,
+
+	.get_frequency		= fc0011_get_frequency,
+	.get_if_frequency	= fc0011_get_if_frequency,
+	.get_bandwidth		= fc0011_get_bandwidth,
+};
+
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config)
+{
+	struct fc0011_priv *priv;
+
+	priv = kzalloc(sizeof(struct fc0011_priv), GFP_KERNEL);
+	if (!priv)
+		return NULL;
+
+	priv->i2c = i2c;
+	priv->addr = config->i2c_address;
+
+	fe->tuner_priv = priv;
+	fe->ops.tuner_ops = fc0011_tuner_ops;
+
+	dev_info(&priv->i2c->dev, "Fitipower FC0011 tuner attached\n");
+
+	return fe;
+}
+EXPORT_SYMBOL(fc0011_attach);
+
+MODULE_DESCRIPTION("Fitipower FC0011 silicon tuner driver");
+MODULE_AUTHOR("Michael Buesch <m@bues.ch>");
+MODULE_LICENSE("GPL");
Index: linux/drivers/media/common/tuners/fc0011.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/media/common/tuners/fc0011.h	2012-03-31 14:27:31.822958249 +0200
@@ -0,0 +1,41 @@
+#ifndef LINUX_FC0011_H_
+#define LINUX_FC0011_H_
+
+#include "dvb_frontend.h"
+
+
+/** struct fc0011_config - fc0011 hardware config
+ *
+ * @i2c_address: I2C bus address.
+ */
+struct fc0011_config {
+	u8 i2c_address;
+};
+
+/** enum fc0011_fe_callback_commands - Frontend callbacks
+ *
+ * @FC0011_FE_CALLBACK_POWER: Power on tuner hardware.
+ * @FC0011_FE_CALLBACK_RESET: Request a tuner reset.
+ */
+enum fc0011_fe_callback_commands {
+	FC0011_FE_CALLBACK_POWER,
+	FC0011_FE_CALLBACK_RESET,
+};
+
+#if defined(CONFIG_MEDIA_TUNER_FC0011) ||\
+    defined(CONFIG_MEDIA_TUNER_FC0011_MODULE)
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config);
+#else
+static inline
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config)
+{
+	dev_err(&i2c->dev, "fc0011 driver disabled in Kconfig\n");
+	return NULL;
+}
+#endif
+
+#endif /* LINUX_FC0011_H_ */
Index: linux/MAINTAINERS
===================================================================
--- linux.orig/MAINTAINERS	2012-03-31 00:32:24.000000000 +0200
+++ linux/MAINTAINERS	2012-03-31 13:03:07.291336671 +0200
@@ -2694,6 +2694,13 @@
 F:	Documentation/hwmon/f71805f
 F:	drivers/hwmon/f71805f.c
 
+FC0011 TUNER DRIVER
+M:	Michael Buesch <m@bues.ch>
+L:	linux-media@vger.kernel.org
+S:	Maintained
+F:	drivers/media/common/tuners/fc0011.h
+F:	drivers/media/common/tuners/fc0011.c
+
 FANOTIFY
 M:	Eric Paris <eparis@redhat.com>
 S:	Maintained

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: af9035-add-usbid.patch --]
[-- Type: text/x-patch, Size: 1127 bytes --]

Index: linux/drivers/media/dvb/dvb-usb/af9035.c
===================================================================
--- linux.orig/drivers/media/dvb/dvb-usb/af9035.c	2012-03-31 15:25:06.611122203 +0200
+++ linux/drivers/media/dvb/dvb-usb/af9035.c	2012-03-31 18:44:14.557214890 +0200
@@ -634,11 +634,17 @@
 
 enum af9035_id_entry {
 	AF9035_0CCD_0093,
+	AF9035_15A4_1001,
+	AF9035_15A4_9035,
 };
 
 static struct usb_device_id af9035_id[] = {
 	[AF9035_0CCD_0093] = {
 		USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK)},
+	[AF9035_15A4_1001] = {
+		USB_DEVICE(0x15A4, 0x1001)},
+	[AF9035_15A4_9035] = {
+		USB_DEVICE(0x15A4, 0x9035)},
 	{},
 };
 
@@ -681,14 +687,20 @@
 
 		.i2c_algo = &af9035_i2c_algo,
 
-		.num_device_descs = 1,
+		.num_device_descs = 2,
 		.devices = {
 			{
 				.name = "TerraTec Cinergy T Stick",
 				.cold_ids = {
 					&af9035_id[AF9035_0CCD_0093],
 				},
-			},
+			}, {
+				.name = "Afatech Technologies DVB-T stick",
+				.cold_ids = {
+					&af9035_id[AF9035_15A4_1001],
+					&af9035_id[AF9035_15A4_9035],
+				},
+			}
 		}
 	},
 };

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: af9035-add-fc0011-tuner.patch --]
[-- Type: text/x-patch, Size: 5663 bytes --]

Index: linux/drivers/media/dvb/dvb-usb/af9035.c
===================================================================
--- linux.orig/drivers/media/dvb/dvb-usb/af9035.c	2012-03-31 18:44:28.265457286 +0200
+++ linux/drivers/media/dvb/dvb-usb/af9035.c	2012-03-31 18:44:38.241633686 +0200
@@ -19,9 +19,12 @@
  *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#define DEBUG 1
+
 #include "af9035.h"
 #include "af9033.h"
 #include "tua9001.h"
+#include "fc0011.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 static DEFINE_MUTEX(af9035_usb_mutex);
@@ -486,6 +489,7 @@
 
 		switch (tmp) {
 		case AF9033_TUNER_TUA9001:
+		case AF9033_TUNER_FC0011:
 			af9035_af9033_config[i].spec_inv = 1;
 			break;
 		default:
@@ -531,6 +535,83 @@
 	return ret;
 }
 
+static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d,
+					int cmd, int arg)
+{
+	int err;
+
+	switch (cmd) {
+	case FC0011_FE_CALLBACK_POWER:
+		/* Tuner enable */
+		err = af9035_wr_reg_mask(d, 0xd8eb, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8ec, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8ed, 1, 1);
+		if (err)
+			return err;
+		/* LED */
+		err = af9035_wr_reg_mask(d, 0xd8d0, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8d1, 1, 1);
+		if (err)
+			return err;
+		msleep(10);
+		break;
+	case FC0011_FE_CALLBACK_RESET:
+		err = af9035_wr_reg(d, 0xd8e9, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg(d, 0xd8e8, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg(d, 0xd8e7, 1);
+		if (err)
+			return err;
+		msleep(10);
+		err = af9035_wr_reg(d, 0xd8e7, 0);
+		if (err)
+			return err;
+		msleep(10);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int af9035_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
+{
+	switch (af9035_af9033_config[0].tuner) {
+	case AF9033_TUNER_FC0011:
+		return af9035_fc0011_tuner_callback(d, cmd, arg);
+	default:
+		break;
+	}
+
+	return -ENODEV;
+}
+
+static int af9035_frontend_callback(void *adapter_priv, int component,
+				    int cmd, int arg)
+{
+	struct i2c_adapter *adap = adapter_priv;
+	struct dvb_usb_device *d = i2c_get_adapdata(adap);
+
+	switch (component) {
+	case DVB_FRONTEND_COMPONENT_TUNER:
+		return af9035_tuner_callback(d, cmd, arg);
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
 static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -554,6 +635,7 @@
 		ret = -ENODEV;
 		goto err;
 	}
+	adap->fe_adap[0].fe->callback = af9035_frontend_callback;
 
 	return 0;
 
@@ -567,6 +649,10 @@
 	.i2c_addr = 0x60,
 };
 
+static const struct fc0011_config af9035_fc0011_config = {
+	.i2c_address = 0xC0,
+};
+
 static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -615,6 +701,10 @@
 		fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
 				&adap->dev->i2c_adap, &af9035_tua9001_config);
 		break;
+	case AF9033_TUNER_FC0011:
+		fe = dvb_attach(fc0011_attach, adap->fe_adap[0].fe,
+				&adap->dev->i2c_adap, &af9035_fc0011_config);
+		break;
 	default:
 		fe = NULL;
 	}
Index: linux/drivers/media/dvb/frontends/af9033.c
===================================================================
--- linux.orig/drivers/media/dvb/frontends/af9033.c	2012-03-31 18:43:26.392363037 +0200
+++ linux/drivers/media/dvb/frontends/af9033.c	2012-03-31 18:44:38.241633686 +0200
@@ -297,6 +297,10 @@
 		len = ARRAY_SIZE(tuner_init_tua9001);
 		init = tuner_init_tua9001;
 		break;
+	case AF9033_TUNER_FC0011:
+		len = ARRAY_SIZE(tuner_init_fc0011);
+		init = tuner_init_fc0011;
+		break;
 	default:
 		pr_debug("%s: unsupported tuner ID=%d\n", __func__,
 				state->cfg.tuner);
Index: linux/drivers/media/dvb/frontends/af9033_priv.h
===================================================================
--- linux.orig/drivers/media/dvb/frontends/af9033_priv.h	2012-03-31 18:43:26.392363037 +0200
+++ linux/drivers/media/dvb/frontends/af9033_priv.h	2012-03-31 18:44:38.241633686 +0200
@@ -238,5 +238,66 @@
 	{ 0x80f1e6, 0x00 },
 };
 
+/* Fitipower fc0011 tuner init
+   AF9033_TUNER_FC0011    = 0x28 */
+static const struct reg_val tuner_init_fc0011[] = {
+	{ 0x800046, AF9033_TUNER_FC0011 },
+	{ 0x800057, 0x00 },
+	{ 0x800058, 0x01 },
+	{ 0x80005f, 0x00 },
+	{ 0x800060, 0x00 },
+	{ 0x800068, 0xa5 },
+	{ 0x80006e, 0x01 },
+	{ 0x800071, 0x0A },
+	{ 0x800072, 0x02 },
+	{ 0x800074, 0x01 },
+	{ 0x800079, 0x01 },
+	{ 0x800093, 0x00 },
+	{ 0x800094, 0x00 },
+	{ 0x800095, 0x00 },
+	{ 0x800096, 0x00 },
+	{ 0x80009b, 0x2D },
+	{ 0x80009c, 0x60 },
+	{ 0x80009d, 0x23 },
+	{ 0x8000a4, 0x50 },
+	{ 0x8000ad, 0x50 },
+	{ 0x8000b3, 0x01 },
+	{ 0x8000b7, 0x88 },
+	{ 0x8000b8, 0xa6 },
+	{ 0x8000c3, 0x01 },
+	{ 0x8000c4, 0x01 },
+	{ 0x8000c7, 0x69 },
+	{ 0x80F007, 0x00 },
+	{ 0x80F00A, 0x1B },
+	{ 0x80F00B, 0x1B },
+	{ 0x80F00C, 0x1B },
+	{ 0x80F00D, 0x1B },
+	{ 0x80F00E, 0xFF },
+	{ 0x80F00F, 0x01 },
+	{ 0x80F010, 0x00 },
+	{ 0x80F011, 0x02 },
+	{ 0x80F012, 0xFF },
+	{ 0x80F013, 0x01 },
+	{ 0x80F014, 0x00 },
+	{ 0x80F015, 0x02 },
+	{ 0x80F01B, 0xEF },
+	{ 0x80F01C, 0x01 },
+	{ 0x80F01D, 0x0f },
+	{ 0x80F01E, 0x02 },
+	{ 0x80F01F, 0x6E },
+	{ 0x80F020, 0x00 },
+	{ 0x80F025, 0xDE },
+	{ 0x80F026, 0x00 },
+	{ 0x80F027, 0x0A },
+	{ 0x80F028, 0x03 },
+	{ 0x80F029, 0x6E },
+	{ 0x80F02A, 0x00 },
+	{ 0x80F047, 0x00 },
+	{ 0x80F054, 0x00 },
+	{ 0x80F055, 0x00 },
+	{ 0x80F077, 0x01 },
+	{ 0x80F1E6, 0x00 },
+};
+
 #endif /* AF9033_PRIV_H */
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 16:48               ` Antti Palosaari
@ 2012-03-31 16:52                 ` Michael Büsch
  2012-04-01  4:51                   ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-03-31 16:52 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

[-- Attachment #1: Type: text/plain, Size: 599 bytes --]

On Sat, 31 Mar 2012 19:48:34 +0300
Antti Palosaari <crope@iki.fi> wrote:

> And about the new FW downloader, that supports those new firmwares, feel 
> free to implement it if you wish too. I will now goto out of house and 
> will back during few hours. If you wish to do it just reply during 4 
> hours, and I will not start working for it. Instead I will continue with 
> IT9135.

I have no clue about the firmware format, so it will probably be easier
if you'd dive into that stuff as you already seem to know it.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-31 16:52                 ` Michael Büsch
@ 2012-04-01  4:51                   ` Antti Palosaari
  2012-04-01  8:33                     ` Michael Büsch
                                       ` (3 more replies)
  0 siblings, 4 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01  4:51 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media, Daniel Glöckner

On 31.03.2012 19:52, Michael Büsch wrote:
> On Sat, 31 Mar 2012 19:48:34 +0300
> Antti Palosaari<crope@iki.fi>  wrote:
>
>> And about the new FW downloader, that supports those new firmwares, feel
>> free to implement it if you wish too. I will now goto out of house and
>> will back during few hours. If you wish to do it just reply during 4
>> hours, and I will not start working for it. Instead I will continue with
>> IT9135.
>
> I have no clue about the firmware format, so it will probably be easier
> if you'd dive into that stuff as you already seem to know it.

Done. I didn't have neither info, but there was good posting from Daniel 
Glöckner that documents it! Nice job Daniel, without that info I was 
surely implemented it differently and surely more wrong way.

I pushed my experimental tree out, patches are welcome top of that.
http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/af9035_experimental

I extracted three firmwares from windows binaries I have. I will sent 
those you, Michael, for testing. First, and oldest, is TUA9001, 2nd is 
from FC0012 device and 3rd no idea.

md5sum f71efe295151ba76cac2280680b69f3f
LINK=11.5.9.0 OFDM=5.17.9.1

md5sum 7cdc1e3aba54f3a9ad052dc6a29603fd
LINK=11.10.10.0 OFDM=5.33.10.0

md5sum 862604ab3fec0c94f4bf22b4cffd0d89
LINK=12.13.15.0 OFDM=6.20.15.0

I need more AF903x hardware, please give links to cheap eBay devices 
etc. Also I would like to get one device where is AF9033 but no AF9035 
at all just for stand-alone demodulator implementation. I know there is 
few such devices, like AverMedia A336 for example...

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01  4:51                   ` Antti Palosaari
@ 2012-04-01  8:33                     ` Michael Büsch
  2012-04-01 12:19                       ` Michael Büsch
  2012-04-01  9:56                     ` Gianluca Gennari
                                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-04-01  8:33 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media, Daniel Glöckner

[-- Attachment #1: Type: text/plain, Size: 1430 bytes --]

On Sun, 01 Apr 2012 07:51:33 +0300
Antti Palosaari <crope@iki.fi> wrote:
> > I have no clue about the firmware format, so it will probably be easier
> > if you'd dive into that stuff as you already seem to know it.
> 
> Done. I didn't have neither info, but there was good posting from Daniel 
> Glöckner that documents it! Nice job Daniel, without that info I was 
> surely implemented it differently and surely more wrong way.
> 
> I pushed my experimental tree out, patches are welcome top of that.
> http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/af9035_experimental
> 
> I extracted three firmwares from windows binaries I have. I will sent 
> those you, Michael, for testing. First, and oldest, is TUA9001, 2nd is 
> from FC0012 device and 3rd no idea.

Great work. I'll rebase my tree on the new branch and check those firmware files asap.

> I need more AF903x hardware, please give links to cheap eBay devices 
> etc. Also I would like to get one device where is AF9033 but no AF9035 
> at all just for stand-alone demodulator implementation. I know there is 
> few such devices, like AverMedia A336 for example...

This is my stick. It's a AF9035 with one FC0011 tuner chip:
http://www.amazon.de/Cabstone-DVB-T-Empf%C3%A4nger-Arbeitsspeicher-schwarz/dp/B00307551E/ref=sr_1_1?ie=UTF8&qid=1333268959&sr=8-1

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01  4:51                   ` Antti Palosaari
  2012-04-01  8:33                     ` Michael Büsch
@ 2012-04-01  9:56                     ` Gianluca Gennari
  2012-04-01 10:27                     ` Hans-Frieder Vogt
  2012-04-01 17:15                     ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner) Hans-Frieder Vogt
  3 siblings, 0 replies; 45+ messages in thread
From: Gianluca Gennari @ 2012-04-01  9:56 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: Michael Büsch, linux-media, Daniel Glöckner

Il 01/04/2012 06:51, Antti Palosaari ha scritto:

[snip]

> I need more AF903x hardware, please give links to cheap eBay devices
> etc. Also I would like to get one device where is AF9033 but no AF9035
> at all just for stand-alone demodulator implementation. I know there is
> few such devices, like AverMedia A336 for example...
> 
> regards
> Antti

Hi Antti,
here are a couple of links to buy cheap af9035 sticks.

Avermedia A835/B835: af9035 + tda18218, also known ad "Avermedia Volar
HD" or "Avermedia Volar HD Pro" or "Avermedia Volar Green HD".
The only difference between the models seems to be the presence of the
remote controller and the IR sensor. The link is for the cheaper one,
without the remote:

http://www.amazon.de/AverMedia-TV-USB-Stick-Volar/dp/B0039TFC7U/ref=sr_1_1?ie=UTF8&qid=1333272073&sr=8-1

Avermedia A867: af9035 + mxl5007t, also known as "Aver Media AVerTV 3D"
or "Sky Digital Key with blue led". You can buy them very cheap on Ebay
Italia because Sky Italia is giving away them almost for free to its
subscribers, to add DVB-T support to the Skyboxes. You can find dozens
of link like this:

http://www.ebay.it/itm/SKY-DIGITAL-KEY-ULTIMO-MODELLO-2012-LED-BLU-DIGITALE-TERRESTRE-USB-NUOVA-/110852763137?pt=Decoder_Satellitari_e_Digitali_Terrestri&hash=item19cf56ee01

The A867 and A835 are probably the most common DVB-T sticks here in
Italy, as they are very cheap and work pretty well. There is already
some support for them (based on your old driver and also on the driver
by Hans-Frieder Vogt) so I will look into porting it on the new driver.

Best regards,
Gianluca

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01  4:51                   ` Antti Palosaari
  2012-04-01  8:33                     ` Michael Büsch
  2012-04-01  9:56                     ` Gianluca Gennari
@ 2012-04-01 10:27                     ` Hans-Frieder Vogt
  2012-04-01 12:31                       ` Antti Palosaari
  2012-04-01 12:53                       ` Antti Palosaari
  2012-04-01 17:15                     ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner) Hans-Frieder Vogt
  3 siblings, 2 replies; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 10:27 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Antti,

nice work! I'll try to port the features that I have in my implementation of 
an af9035 driver into yours.

Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
> On 31.03.2012 19:52, Michael Büsch wrote:
> > On Sat, 31 Mar 2012 19:48:34 +0300
> > 
> > Antti Palosaari<crope@iki.fi>  wrote:
> >> And about the new FW downloader, that supports those new firmwares, feel
> >> free to implement it if you wish too. I will now goto out of house and
> >> will back during few hours. If you wish to do it just reply during 4
> >> hours, and I will not start working for it. Instead I will continue with
> >> IT9135.
> > 
> > I have no clue about the firmware format, so it will probably be easier
> > if you'd dive into that stuff as you already seem to know it.
> 
> Done. I didn't have neither info, but there was good posting from Daniel
> Glöckner that documents it! Nice job Daniel, without that info I was
> surely implemented it differently and surely more wrong way.
> 
> I pushed my experimental tree out, patches are welcome top of that.
> http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/af9035_exp
> erimental
> 
Your new firmware loader implies that the firmware is available as a type 
"download firmware". It seems this is indeed the case for most (all?) of the 
AF9035 devices. If the IT9135 driver should be merged, the "copy firmware" 
functionality (i.e. scatter write => command code 0x29) would need to be 
implemented.

> I extracted three firmwares from windows binaries I have. I will sent
> those you, Michael, for testing. First, and oldest, is TUA9001, 2nd is
> from FC0012 device and 3rd no idea.
> 
> md5sum f71efe295151ba76cac2280680b69f3f
> LINK=11.5.9.0 OFDM=5.17.9.1
> 
> md5sum 7cdc1e3aba54f3a9ad052dc6a29603fd
> LINK=11.10.10.0 OFDM=5.33.10.0
> 
> md5sum 862604ab3fec0c94f4bf22b4cffd0d89
> LINK=12.13.15.0 OFDM=6.20.15.0
>
I have got a firmware converted from the linux driver version 1.0.28 for the 
AVermedia AVerTV A867R (07ca:1867, tuner: MaxLinear Mxl5007t)
LINK=10.10.3.0 OFDM=4.21.6.251
(only 2 firmwares each for link and ofdm!)

For the same device the Windows driver verion 8.0.0.60 has a load of firmwares 
with
LINK=11.15.10.0 OFDM=5.48.10.0
(3 firmwares each for link and ofdm)

>From the Terratec T6 dual tuner device (fc0012) Windows driver version 
10.09.20.01 I have got (is probably the one that you have got as well)
LINK=12.13.15.0 OFDM=6.20.15.0
(3 firmwares each for link and ofdm)

I got an e-mail from Terratec support that they don't see a problem with the 
distribution of the firmware that I sniffed from the Terratec T6 running under 
Windows.

The Terratec Windows driver contains 3 firmwares that get selected depending on 
the available tuner:
firmware 1 for tuners TUA8010, TUA9001, TD1316AFIHP, TDA18271, TDA18291HN, 
XC3028L, XC4000, FC2580, FC0011, PICTOR, 0x40 (?), 0x43 (?)
firmware 2 for tuner MT2266
firmware 3 for tuners FC0012 and 0x37
>From this I conclude that there is not a single generic firmware that we could 
use for the af9035 devices, but maybe 3 are sufficient.

> I need more AF903x hardware, please give links to cheap eBay devices
> etc. Also I would like to get one device where is AF9033 but no AF9035
> at all just for stand-alone demodulator implementation. I know there is
> few such devices, like AverMedia A336 for example...
> 
> regards
> Antti

regards,
Hans-Frieder

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01  8:33                     ` Michael Büsch
@ 2012-04-01 12:19                       ` Michael Büsch
  2012-04-01 12:29                         ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 12:19 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media, Daniel Glöckner

[-- Attachment #1: Type: text/plain, Size: 3646 bytes --]

On Sun, 1 Apr 2012 10:33:15 +0200
Michael Büsch <m@bues.ch> wrote:

> On Sun, 01 Apr 2012 07:51:33 +0300
> Antti Palosaari <crope@iki.fi> wrote:
> > > I have no clue about the firmware format, so it will probably be easier
> > > if you'd dive into that stuff as you already seem to know it.
> > 
> > Done. I didn't have neither info, but there was good posting from Daniel 
> > Glöckner that documents it! Nice job Daniel, without that info I was 
> > surely implemented it differently and surely more wrong way.
> > 
> > I pushed my experimental tree out, patches are welcome top of that.
> > http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/af9035_experimental
> > 
> > I extracted three firmwares from windows binaries I have. I will sent 
> > those you, Michael, for testing. First, and oldest, is TUA9001, 2nd is 
> > from FC0012 device and 3rd no idea.
> 
> Great work. I'll rebase my tree on the new branch and check those firmware files asap.

Hm, none of these firmwares fix the problem. Maybe it's not a firmware
problem after all, but just incorrectly setup tuner-i2c.

Here's the dmesg log:

[  131.451556] usb 1-1.1: new high-speed USB device number 5 using ehci_hcd
[  131.550302] usb 1-1.1: New USB device found, idVendor=15a4, idProduct=9035
[  131.550315] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[  131.674657] af9035_usb_probe: interface=0
[  131.675169] af9035_identify_state: reply=00 00 00 00
[  131.675185] dvb-usb: found a 'Afatech Technologies DVB-T stick' in cold state, will try to load a firmware
[  131.691605] dvb-usb: downloading firmware from file 'dvb-usb-af9035-02.fw'
[  131.691626] af9035_download_firmware: core=1 addr=4100 data_len=3 checksum=fbbe
[  131.692696] af9035_download_firmware: data uploaded=10
[  131.692716] af9035_download_firmware: core=1 addr=4800 data_len=15014 checksum=587d
[  131.777793] af9035_download_firmware: data uploaded=15031
[  131.777807] af9035_download_firmware: core=1 addr=83e9 data_len=4 checksum=117c
[  131.778785] af9035_download_firmware: data uploaded=15042
[  131.778796] af9035_download_firmware: core=2 addr=4100 data_len=3 checksum=fabe
[  131.779785] af9035_download_firmware: data uploaded=15052
[  131.779799] af9035_download_firmware: core=2 addr=4550 data_len=27252 checksum=3950
[  131.936162] af9035_download_firmware: data uploaded=42311
[  131.999412] af9035: firmware version=11.10.10.0
[  131.999443] dvb-usb: found a 'Afatech Technologies DVB-T stick' in warm state.
[  131.999790] dvb-usb: will pass the complete MPEG2 transport stream to the software demuxer.
[  132.000122] DVB: registering new adapter (Afatech Technologies DVB-T stick)
[  132.000546] af9035_read_mac_address: dual mode=0
[  132.001027] af9035_read_mac_address: [0]tuner=28
[  132.002026] af9035_read_mac_address: [0]IF=36125
[  132.002413] dvb-usb: MAC address: 00:00:00:00:00:00
[  132.018549] af9033: firmware version: LINK=11.10.10.0 OFDM=5.33.10.0
[  132.018566] DVB: registering adapter 0 frontend 0 (Afatech AF9033 (DVB-T))...
[  132.028370] i2c i2c-8: Fitipower FC0011 tuner attached
[  132.028388] dvb-usb: Afatech Technologies DVB-T stick successfully initialized and connected.
[  132.028405] af9035_init: USB speed=3 frame_size=0ff9 packet_size=80
[  132.040019] usbcore: registered new interface driver dvb_usb_af9035
[  145.407991] af9035_ctrl_msg: command=03 failed fw error=2
[  145.408008] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f

I also tried the other firmware. Same result.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 12:19                       ` Michael Büsch
@ 2012-04-01 12:29                         ` Antti Palosaari
  2012-04-01 13:11                           ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 12:29 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media, Daniel Glöckner

On 01.04.2012 15:19, Michael Büsch wrote:
>> Great work. I'll rebase my tree on the new branch and check those firmware files asap.
> Hm, none of these firmwares fix the problem. Maybe it's not a firmware
> problem after all, but just incorrectly setup tuner-i2c.
>
> Here's the dmesg log:
[...]
> [  132.018549] af9033: firmware version: LINK=11.10.10.0 OFDM=5.33.10.0
> [  132.018566] DVB: registering adapter 0 frontend 0 (Afatech AF9033 (DVB-T))...
> [  132.028370] i2c i2c-8: Fitipower FC0011 tuner attached
> [  132.028388] dvb-usb: Afatech Technologies DVB-T stick successfully initialized and connected.
> [  132.028405] af9035_init: USB speed=3 frame_size=0ff9 packet_size=80
> [  132.040019] usbcore: registered new interface driver dvb_usb_af9035
> [  145.407991] af9035_ctrl_msg: command=03 failed fw error=2
> [  145.408008] i2c i2c-8: I2C write reg failed, reg: 07, val: 0f
>
> I also tried the other firmware. Same result.

It must then be I2C adapter or I2C client issue.
Adapter code is here, and it known to work with TUA9001. TUA9001 sends 
1x byte register and then followed 2xbytes data.

u8 buf[4 + msg[0].len];
struct usb_req req = { CMD_I2C_WR, 0, sizeof(buf), buf, 0, NULL };
buf[0] = msg[0].len;
buf[1] = msg[0].addr << 1;
buf[2] = 0x01;
buf[3] = 0x00;
memcpy(&buf[4], msg[0].buf, msg[0].len);
ret = af9035_ctrl_msg(d->udev, &req);

Maybe you have given I2C address as a "8bit" format? Maybe adapter bytes 
buf[2] and buf[3] are wrong? If you have taken sniffs from windows it is 
very easy to see what is wrong.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 10:27                     ` Hans-Frieder Vogt
@ 2012-04-01 12:31                       ` Antti Palosaari
  2012-04-01 14:31                         ` Hans-Frieder Vogt
  2012-04-01 12:53                       ` Antti Palosaari
  1 sibling, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 12:31 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 01.04.2012 13:27, Hans-Frieder Vogt wrote:
> nice work! I'll try to port the features that I have in my implementation of
> an af9035 driver into yours.

You are welcome! But please tell me what you are doing to avoid 
duplicate work. My today plan was to implement af9033 SNR, BER, UCB, but 
if you would like to then say it for me and I will jump back to IT9135 
support.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 10:27                     ` Hans-Frieder Vogt
  2012-04-01 12:31                       ` Antti Palosaari
@ 2012-04-01 12:53                       ` Antti Palosaari
  1 sibling, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 12:53 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

Ooops forget to comment these...

On 01.04.2012 13:27, Hans-Frieder Vogt wrote:
> Your new firmware loader implies that the firmware is available as a type
> "download firmware". It seems this is indeed the case for most (all?) of the
> AF9035 devices. If the IT9135 driver should be merged, the "copy firmware"
> functionality (i.e. scatter write =>  command code 0x29) would need to be
> implemented.

Technically correct way is to split out all functionality, I mean USB 
-interface, demodulator and tuner, as own driver modules and use same 
modules for all the hardware not caring integration level. Those are 
just logical entities put to inside same silicon or sold separately.

For the existing IT9135 driver, it is there and surely will not be 
removed unless it goes unmaintained. Still it is nice to offer modular 
implementation as a choice for upcoming devices.

I haven't looked so carefully IT9135 FW download process - only thing I 
noticed it uses totally much smaller firmware than af9035, which is 
somehow weird since it contains tuner which is main difference between 
af9035 and it9135 :) Maybe there is done some bug fixing or other 
improvements in silicon level too.

It is easy to implement 2 or more firmware downloader, one for each 
firmware type and select correct by driver.

>> I extracted three firmwares from windows binaries I have. I will sent
>> those you, Michael, for testing. First, and oldest, is TUA9001, 2nd is
>> from FC0012 device and 3rd no idea.
>>
>> md5sum f71efe295151ba76cac2280680b69f3f
>> LINK=11.5.9.0 OFDM=5.17.9.1

That was from TerraTec Cinergy T -Stick, the stick which was one of the 
first af9035 and I originally made driver for.

>> md5sum 7cdc1e3aba54f3a9ad052dc6a29603fd
>> LINK=11.10.10.0 OFDM=5.33.10.0

Some DealExtreme cheap stick.

>> md5sum 862604ab3fec0c94f4bf22b4cffd0d89
>> LINK=12.13.15.0 OFDM=6.20.15.0
>>
> I have got a firmware converted from the linux driver version 1.0.28 for the
> AVermedia AVerTV A867R (07ca:1867, tuner: MaxLinear Mxl5007t)
> LINK=10.10.3.0 OFDM=4.21.6.251
> (only 2 firmwares each for link and ofdm!)
>
> For the same device the Windows driver verion 8.0.0.60 has a load of firmwares
> with
> LINK=11.15.10.0 OFDM=5.48.10.0
> (3 firmwares each for link and ofdm)
>
>  From the Terratec T6 dual tuner device (fc0012) Windows driver version
> 10.09.20.01 I have got (is probably the one that you have got as well)
> LINK=12.13.15.0 OFDM=6.20.15.0
> (3 firmwares each for link and ofdm)

True.

> I got an e-mail from Terratec support that they don't see a problem with the
> distribution of the firmware that I sniffed from the Terratec T6 running under
> Windows.
>
> The Terratec Windows driver contains 3 firmwares that get selected depending on
> the available tuner:
> firmware 1 for tuners TUA8010, TUA9001, TD1316AFIHP, TDA18271, TDA18291HN,
> XC3028L, XC4000, FC2580, FC0011, PICTOR, 0x40 (?), 0x43 (?)
> firmware 2 for tuner MT2266
> firmware 3 for tuners FC0012 and 0x37
>  From this I conclude that there is not a single generic firmware that we could
> use for the af9035 devices, but maybe 3 are sufficient.

We should gather enough information to decide used firmware naming. 
Mainly for that reason I didn't release get_dvb_firmware changes I used 
to extract those.
So do you have the idea about firmware naming?
Reading tuner ID from eeprom before firmware download is needed as you 
point out. And then select firmware based of that. Or is it possible to 
split firmwares even smaller blocks like LINK and OFDM and download 
those separately. I think it is OFDM version which says if tuner is 
supported or not.


regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 12:29                         ` Antti Palosaari
@ 2012-04-01 13:11                           ` Michael Büsch
  2012-04-01 13:19                             ` Antti Palosaari
                                               ` (2 more replies)
  0 siblings, 3 replies; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 13:11 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media, Daniel Glöckner


[-- Attachment #1.1: Type: text/plain, Size: 776 bytes --]

On Sun, 01 Apr 2012 15:29:07 +0300
Antti Palosaari <crope@iki.fi> wrote:
> buf[1] = msg[0].addr << 1;
> Maybe you have given I2C address as a "8bit" format?

Uhh, the address is leftshifted by one.
So I changed the i2c address from 0xC0 to 0x60.

The i2c write seems to work now. At least it doesn't complain anymore
and it sorta seems to tune to the right frequency.
But i2c read may be broken.
I had to enable the commented read code, but it still fails to read
the VCO calibration value:

[ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)

It doesn't run into this check on the other af903x driver.
So I suspect an i2c read issue here.

Attached: The patches.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: fc0011-tuner.patch --]
[-- Type: text/x-patch, Size: 16868 bytes --]

Index: linux/drivers/media/common/tuners/Kconfig
===================================================================
--- linux.orig/drivers/media/common/tuners/Kconfig	2012-04-01 11:42:36.539532984 +0200
+++ linux/drivers/media/common/tuners/Kconfig	2012-04-01 11:42:38.803572117 +0200
@@ -204,6 +204,13 @@
 	help
 	  NXP TDA18218 silicon tuner driver.
 
+config MEDIA_TUNER_FC0011
+	tristate "Fitipower FC0011 silicon tuner"
+	depends on VIDEO_MEDIA && I2C
+	default m if MEDIA_TUNER_CUSTOMISE
+	help
+	  Fitipower FC0011 silicon tuner driver.
+
 config MEDIA_TUNER_TDA18212
 	tristate "NXP TDA18212 silicon tuner"
 	depends on VIDEO_MEDIA && I2C
Index: linux/drivers/media/common/tuners/Makefile
===================================================================
--- linux.orig/drivers/media/common/tuners/Makefile	2012-04-01 11:42:36.539532984 +0200
+++ linux/drivers/media/common/tuners/Makefile	2012-04-01 11:42:38.803572117 +0200
@@ -29,6 +29,7 @@
 obj-$(CONFIG_MEDIA_TUNER_TDA18218) += tda18218.o
 obj-$(CONFIG_MEDIA_TUNER_TDA18212) += tda18212.o
 obj-$(CONFIG_MEDIA_TUNER_TUA9001) += tua9001.o
+obj-$(CONFIG_MEDIA_TUNER_FC0011) += fc0011.o
 
 ccflags-y += -I$(srctree)/drivers/media/dvb/dvb-core
 ccflags-y += -I$(srctree)/drivers/media/dvb/frontends
Index: linux/drivers/media/common/tuners/fc0011.c
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/media/common/tuners/fc0011.c	2012-04-01 14:49:08.046382661 +0200
@@ -0,0 +1,491 @@
+/*
+ * Fitipower FC0011 tuner driver
+ *
+ * Copyright (C) 2012 Michael Buesch <m@bues.ch>
+ *
+ * Derived from FC0012 tuner driver:
+ * Copyright (C) 2012 Hans-Frieder Vogt <hfvogt@gmx.net>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * 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.
+ */
+
+#include "fc0011.h"
+
+
+/* Tuner registers */
+enum {
+	FC11_REG_0,
+	FC11_REG_FA,		/* FA */
+	FC11_REG_FP,		/* FP */
+	FC11_REG_XINHI,		/* XIN high 8 bit */
+	FC11_REG_XINLO,		/* XIN low 8 bit */
+	FC11_REG_VCO,		/* VCO */
+	FC11_REG_VCOSEL,	/* VCO select */
+	FC11_REG_7,		/* Unknown tune reg 7 */
+	FC11_REG_8,		/* Unknown tune reg 8 */
+	FC11_REG_9,
+	FC11_REG_10,		/* Unknown tune reg 10 */
+	FC11_REG_11,		/* Unknown tune reg 11 */
+	FC11_REG_12,
+	FC11_REG_RCCAL,		/* RC calibrate */
+	FC11_REG_VCOCAL,	/* VCO calibrate */
+	FC11_REG_15,
+	FC11_REG_16,		/* Unknown tune reg 16 */
+	FC11_REG_17,
+
+	FC11_NR_REGS,		/* Number of registers */
+};
+
+enum FC11_REG_VCOSEL_bits {
+	FC11_VCOSEL_2		= 0x08, /* VCO select 2 */
+	FC11_VCOSEL_1		= 0x10, /* VCO select 1 */
+	FC11_VCOSEL_CLKOUT	= 0x20, /* Fix clock out */
+	FC11_VCOSEL_BW7M	= 0x40, /* 7MHz bw */
+	FC11_VCOSEL_BW6M	= 0x80, /* 6MHz bw */
+};
+
+enum FC11_REG_RCCAL_bits {
+	FC11_RCCAL_FORCE	= 0x10, /* force */
+};
+
+enum FC11_REG_VCOCAL_bits {
+	FC11_VCOCAL_RUN		= 0,	/* VCO calibration run */
+	FC11_VCOCAL_VALUEMASK	= 0x3F,	/* VCO calibration value mask */
+	FC11_VCOCAL_OK		= 0x40,	/* VCO calibration Ok */
+	FC11_VCOCAL_RESET	= 0x80, /* VCO calibration reset */
+};
+
+
+struct fc0011_priv {
+	struct i2c_adapter *i2c;
+	u8 addr;
+
+	u32 frequency;
+	u32 bandwidth;
+};
+
+
+static int fc0011_writereg(struct fc0011_priv *priv, u8 reg, u8 val)
+{
+	u8 buf[2] = { reg, val };
+	struct i2c_msg msg = { .addr = priv->addr,
+		.flags = 0, .buf = buf, .len = 2 };
+
+	msleep(1);
+	if (i2c_transfer(priv->i2c, &msg, 1) != 1) {
+		dev_err(&priv->i2c->dev,
+			"I2C write reg failed, reg: %02x, val: %02x\n",
+			reg, val);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int fc0011_readreg(struct fc0011_priv *priv, u8 reg, u8 *val)
+{
+	struct i2c_msg msg[2] = {
+		{ .addr = priv->addr,
+		  .flags = 0, .buf = &reg, .len = 1 },
+		{ .addr = priv->addr,
+		  .flags = I2C_M_RD, .buf = val, .len = 1 },
+	};
+
+	if (i2c_transfer(priv->i2c, msg, 2) != 2) {
+		dev_err(&priv->i2c->dev,
+			"I2C read failed, reg: %02x\n", reg);
+		return -EIO;
+	}
+
+	return 0;
+}
+
+static int fc0011_release(struct dvb_frontend *fe)
+{
+	kfree(fe->tuner_priv);
+	fe->tuner_priv = NULL;
+
+	return 0;
+}
+
+static int fc0011_init(struct dvb_frontend *fe)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+	int err;
+
+	if (WARN_ON(!fe->callback))
+		return -EINVAL;
+	err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
+			   FC0011_FE_CALLBACK_POWER, 0);
+	if (err) {
+		dev_err(&priv->i2c->dev, "power-on callback failed\n");
+		return err;
+	}
+
+	return 0;
+}
+
+static int fc0011_set_params(struct dvb_frontend *fe)
+{
+	struct dtv_frontend_properties *p = &fe->dtv_property_cache;
+	struct fc0011_priv *priv = fe->tuner_priv;
+	int err;
+	unsigned int i;
+	u32 freq = p->frequency / 1000;
+	u32 bandwidth = p->bandwidth_hz / 1000;
+	u32 fvco, xin, xdiv, xdivr;
+	u16 frac;
+	u8 fa, fp, vco_sel, vco_cal;
+	u8 regs[FC11_NR_REGS] = { };
+
+	regs[FC11_REG_7] = 0x0F;
+	regs[FC11_REG_8] = 0x3E;
+	regs[FC11_REG_10] = 0xB8;
+	regs[FC11_REG_11] = 0x80;
+	regs[FC11_REG_RCCAL] = 0x04;
+	err = fc0011_writereg(priv, FC11_REG_7, regs[FC11_REG_7]);
+	err |= fc0011_writereg(priv, FC11_REG_8, regs[FC11_REG_8]);
+	err |= fc0011_writereg(priv, FC11_REG_10, regs[FC11_REG_10]);
+	err |= fc0011_writereg(priv, FC11_REG_11, regs[FC11_REG_11]);
+	err |= fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+	if (err)
+		return -EIO;
+
+	/* Set VCO freq and VCO div */
+	if (freq < 54000) {
+		fvco = freq * 64;
+		regs[FC11_REG_VCO] = 0x82;
+	} else if (freq < 108000) {
+		fvco = freq * 32;
+		regs[FC11_REG_VCO] = 0x42;
+	} else if (freq < 216000) {
+		fvco = freq * 16;
+		regs[FC11_REG_VCO] = 0x22;
+	} else if (freq < 432000) {
+		fvco = freq * 8;
+		regs[FC11_REG_VCO] = 0x12;
+	} else {
+		fvco = freq * 4;
+		regs[FC11_REG_VCO] = 0x0A;
+	}
+
+	/* Calc XIN. The PLL reference frequency is 18 MHz. */
+	xdiv = fvco / 18000;
+	frac = fvco - xdiv * 18000;
+	frac = (frac << 15) / 18000;
+	if (frac >= 16384)
+		frac += 32786;
+	if (!frac)
+		xin = 0;
+	else if (frac < 511)
+		xin = 512;
+	else if (frac < 65026)
+		xin = frac;
+	else
+		xin = 65024;
+	regs[FC11_REG_XINHI] = xin >> 8;
+	regs[FC11_REG_XINLO] = xin;
+
+	/* Calc FP and FA */
+	xdivr = xdiv;
+	if (fvco - xdiv * 18000 >= 9000)
+		xdivr += 1; /* round */
+	fp = xdivr / 8;
+	fa = xdivr - fp * 8;
+	if (fa < 2) {
+		fp -= 1;
+		fa += 8;
+	}
+	if (fp > 0x1F) {
+		fp &= 0x1F;
+		fa &= 0xF;
+	}
+	if (fa >= fp) {
+		dev_warn(&priv->i2c->dev,
+			 "fa %02X >= fp %02X, but trying to continue\n",
+			 (unsigned int)(u8)fa, (unsigned int)(u8)fp);
+	}
+	regs[FC11_REG_FA] = fa;
+	regs[FC11_REG_FP] = fp;
+
+	/* Select bandwidth */
+	switch (bandwidth) {
+	case 8000:
+		break;
+	case 7000:
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW7M;
+		break;
+	default:
+	case 6000:
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_BW6M;
+		break;
+	}
+
+	/* Pre VCO select */
+	if (fvco < 2320000) {
+		vco_sel = 0;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+	} else if (fvco < 3080000) {
+		vco_sel = 1;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+	} else {
+		vco_sel = 2;
+		regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+		regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+	}
+
+	/* Fix for low freqs */
+	if (freq < 45000) {
+		regs[FC11_REG_FA] = 0x6;
+		regs[FC11_REG_FP] = 0x11;
+	}
+
+	/* Clock out fix */
+	regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_CLKOUT;
+
+	/* Write the cached registers */
+	for (i = FC11_REG_FA; i <= FC11_REG_VCOSEL; i++) {
+		err = fc0011_writereg(priv, i, regs[i]);
+		if (err)
+			return err;
+	}
+
+	/* VCO calibration */
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RESET);
+	if (err)
+		return err;
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	/* Read calib val */
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	msleep(10);
+	err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+	if (err)
+		return err;
+	if (!(vco_cal & FC11_VCOCAL_OK)) {
+		/* Reset the tuner and try again */
+		err = fe->callback(priv->i2c, DVB_FRONTEND_COMPONENT_TUNER,
+				   FC0011_FE_CALLBACK_RESET, 0);
+		if (err) {
+			dev_err(&priv->i2c->dev, "Failed to reset tuner\n");
+			return err;
+		}
+		/* Reinit tuner config */
+		err = 0;
+		for (i = FC11_REG_FA; i <= FC11_REG_VCOSEL; i++)
+			err |= fc0011_writereg(priv, i, regs[i]);
+		err |= fc0011_writereg(priv, FC11_REG_7, regs[FC11_REG_7]);
+		err |= fc0011_writereg(priv, FC11_REG_8, regs[FC11_REG_8]);
+		err |= fc0011_writereg(priv, FC11_REG_10, regs[FC11_REG_10]);
+		err |= fc0011_writereg(priv, FC11_REG_11, regs[FC11_REG_11]);
+		err |= fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+		if (err)
+			return -EIO;
+		/* VCO calibration */
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RESET);
+		if (err)
+			return err;
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+		if (err)
+			return err;
+		/* Read calib val */
+		err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+		if (err)
+			return err;
+		msleep(10);
+		err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+		if (err)
+			return err;
+	}
+	if (!(vco_cal & FC11_VCOCAL_OK)) {
+		dev_err(&priv->i2c->dev,
+			"Failed to read VCO calibration value (got %02X)\n",
+			(unsigned int)(u8)vco_cal);
+		return -EIO;
+	}
+	vco_cal &= FC11_VCOCAL_VALUEMASK;
+
+	switch (vco_sel) {
+	case 0:
+		if (vco_cal < 8) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		}
+		break;
+	case 1:
+		if (vco_cal < 5) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else if (vco_cal <= 48) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		}
+		break;
+	case 2:
+		if (vco_cal > 53) {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_1;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RESET);
+			err |= fc0011_writereg(priv, FC11_REG_VCOCAL,
+					       FC11_VCOCAL_RUN);
+			if (err)
+				return -EIO;
+		} else {
+			regs[FC11_REG_VCOSEL] &= ~(FC11_VCOSEL_1 | FC11_VCOSEL_2);
+			regs[FC11_REG_VCOSEL] |= FC11_VCOSEL_2;
+			err = fc0011_writereg(priv, FC11_REG_VCOSEL,
+					      regs[FC11_REG_VCOSEL]);
+			if (err)
+				return err;
+		}
+		break;
+	}
+	err = fc0011_writereg(priv, FC11_REG_VCOCAL, FC11_VCOCAL_RUN);
+	if (err)
+		return err;
+	msleep(10);
+	err = fc0011_readreg(priv, FC11_REG_VCOCAL, &vco_cal);
+	if (err)
+		return err;
+	msleep(10);
+
+	err = fc0011_readreg(priv, FC11_REG_RCCAL, &regs[FC11_REG_RCCAL]);
+	if (err)
+		return err;
+	regs[FC11_REG_RCCAL] |= FC11_RCCAL_FORCE;
+	err = fc0011_writereg(priv, FC11_REG_RCCAL, regs[FC11_REG_RCCAL]);
+	if (err)
+		return err;
+	err = fc0011_writereg(priv, FC11_REG_16, 0xB);
+	if (err)
+		return err;
+
+	priv->frequency = p->frequency;
+	priv->bandwidth = p->bandwidth_hz;
+
+	return 0;
+}
+
+static int fc0011_get_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+
+	*frequency = priv->frequency;
+
+	return 0;
+}
+
+static int fc0011_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
+{
+	*frequency = 0;
+
+	return 0;
+}
+
+static int fc0011_get_bandwidth(struct dvb_frontend *fe, u32 *bandwidth)
+{
+	struct fc0011_priv *priv = fe->tuner_priv;
+
+	*bandwidth = priv->bandwidth;
+
+	return 0;
+}
+
+static const struct dvb_tuner_ops fc0011_tuner_ops = {
+	.info = {
+		.name		= "Fitipower FC0011",
+
+		.frequency_min	= 45000000,
+		.frequency_max	= 1000000000,
+	},
+
+	.release		= fc0011_release,
+	.init			= fc0011_init,
+
+	.set_params		= fc0011_set_params,
+
+	.get_frequency		= fc0011_get_frequency,
+	.get_if_frequency	= fc0011_get_if_frequency,
+	.get_bandwidth		= fc0011_get_bandwidth,
+};
+
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config)
+{
+	struct fc0011_priv *priv;
+
+	priv = kzalloc(sizeof(struct fc0011_priv), GFP_KERNEL);
+	if (!priv)
+		return NULL;
+
+	priv->i2c = i2c;
+	priv->addr = config->i2c_address;
+
+	fe->tuner_priv = priv;
+	fe->ops.tuner_ops = fc0011_tuner_ops;
+
+	dev_info(&priv->i2c->dev, "Fitipower FC0011 tuner attached\n");
+
+	return fe;
+}
+EXPORT_SYMBOL(fc0011_attach);
+
+MODULE_DESCRIPTION("Fitipower FC0011 silicon tuner driver");
+MODULE_AUTHOR("Michael Buesch <m@bues.ch>");
+MODULE_LICENSE("GPL");
Index: linux/drivers/media/common/tuners/fc0011.h
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ linux/drivers/media/common/tuners/fc0011.h	2012-04-01 11:42:38.807572185 +0200
@@ -0,0 +1,41 @@
+#ifndef LINUX_FC0011_H_
+#define LINUX_FC0011_H_
+
+#include "dvb_frontend.h"
+
+
+/** struct fc0011_config - fc0011 hardware config
+ *
+ * @i2c_address: I2C bus address.
+ */
+struct fc0011_config {
+	u8 i2c_address;
+};
+
+/** enum fc0011_fe_callback_commands - Frontend callbacks
+ *
+ * @FC0011_FE_CALLBACK_POWER: Power on tuner hardware.
+ * @FC0011_FE_CALLBACK_RESET: Request a tuner reset.
+ */
+enum fc0011_fe_callback_commands {
+	FC0011_FE_CALLBACK_POWER,
+	FC0011_FE_CALLBACK_RESET,
+};
+
+#if defined(CONFIG_MEDIA_TUNER_FC0011) ||\
+    defined(CONFIG_MEDIA_TUNER_FC0011_MODULE)
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config);
+#else
+static inline
+struct dvb_frontend *fc0011_attach(struct dvb_frontend *fe,
+				   struct i2c_adapter *i2c,
+				   const struct fc0011_config *config)
+{
+	dev_err(&i2c->dev, "fc0011 driver disabled in Kconfig\n");
+	return NULL;
+}
+#endif
+
+#endif /* LINUX_FC0011_H_ */
Index: linux/MAINTAINERS
===================================================================
--- linux.orig/MAINTAINERS	2012-04-01 11:42:36.539532984 +0200
+++ linux/MAINTAINERS	2012-04-01 11:42:38.819572398 +0200
@@ -2697,6 +2697,13 @@
 F:	Documentation/hwmon/f71805f
 F:	drivers/hwmon/f71805f.c
 
+FC0011 TUNER DRIVER
+M:	Michael Buesch <m@bues.ch>
+L:	linux-media@vger.kernel.org
+S:	Maintained
+F:	drivers/media/common/tuners/fc0011.h
+F:	drivers/media/common/tuners/fc0011.c
+
 FANOTIFY
 M:	Eric Paris <eparis@redhat.com>
 S:	Maintained

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: af9035-add-fc0011-tuner.patch --]
[-- Type: text/x-patch, Size: 6238 bytes --]

Index: linux/drivers/media/dvb/dvb-usb/af9035.c
===================================================================
--- linux.orig/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 11:42:38.867573221 +0200
+++ linux/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 14:44:20.848955668 +0200
@@ -22,6 +22,7 @@
 #include "af9035.h"
 #include "af9033.h"
 #include "tua9001.h"
+#include "fc0011.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 static DEFINE_MUTEX(af9035_usb_mutex);
@@ -209,12 +210,6 @@
 					msg[1].len);
 		} else {
 			/* I2C */
-#if 0
-			/*
-			 * FIXME: Keep that code. It should work but as it is
-			 * not tested I left it disabled and return -EOPNOTSUPP
-			 * for the sure.
-			 */
 			u8 buf[4 + msg[0].len];
 			struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
 					buf, msg[1].len, msg[1].buf };
@@ -224,9 +219,6 @@
 			buf[3] = 0x00;
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
-#endif
-			pr_debug("%s: I2C operation not supported\n", __func__);
-			ret = -EOPNOTSUPP;
 		}
 	} else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
 		if (msg[0].len > 40) {
@@ -480,6 +472,7 @@
 
 		switch (tmp) {
 		case AF9033_TUNER_TUA9001:
+		case AF9033_TUNER_FC0011:
 			af9035_af9033_config[i].spec_inv = 1;
 			break;
 		default:
@@ -524,6 +517,83 @@
 	return ret;
 }
 
+static int af9035_fc0011_tuner_callback(struct dvb_usb_device *d,
+					int cmd, int arg)
+{
+	int err;
+
+	switch (cmd) {
+	case FC0011_FE_CALLBACK_POWER:
+		/* Tuner enable */
+		err = af9035_wr_reg_mask(d, 0xd8eb, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8ec, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8ed, 1, 1);
+		if (err)
+			return err;
+		/* LED */
+		err = af9035_wr_reg_mask(d, 0xd8d0, 1, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg_mask(d, 0xd8d1, 1, 1);
+		if (err)
+			return err;
+		msleep(10);
+		break;
+	case FC0011_FE_CALLBACK_RESET:
+		err = af9035_wr_reg(d, 0xd8e9, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg(d, 0xd8e8, 1);
+		if (err)
+			return err;
+		err = af9035_wr_reg(d, 0xd8e7, 1);
+		if (err)
+			return err;
+		msleep(10);
+		err = af9035_wr_reg(d, 0xd8e7, 0);
+		if (err)
+			return err;
+		msleep(10);
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
+static int af9035_tuner_callback(struct dvb_usb_device *d, int cmd, int arg)
+{
+	switch (af9035_af9033_config[0].tuner) {
+	case AF9033_TUNER_FC0011:
+		return af9035_fc0011_tuner_callback(d, cmd, arg);
+	default:
+		break;
+	}
+
+	return -ENODEV;
+}
+
+static int af9035_frontend_callback(void *adapter_priv, int component,
+				    int cmd, int arg)
+{
+	struct i2c_adapter *adap = adapter_priv;
+	struct dvb_usb_device *d = i2c_get_adapdata(adap);
+
+	switch (component) {
+	case DVB_FRONTEND_COMPONENT_TUNER:
+		return af9035_tuner_callback(d, cmd, arg);
+	default:
+		break;
+	}
+
+	return -EINVAL;
+}
+
 static int af9035_frontend_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -552,6 +622,7 @@
 		ret = -ENODEV;
 		goto err;
 	}
+	adap->fe_adap[0].fe->callback = af9035_frontend_callback;
 
 	return 0;
 
@@ -565,6 +636,10 @@
 	.i2c_addr = 0x60,
 };
 
+static const struct fc0011_config af9035_fc0011_config = {
+	.i2c_address = 0x60,
+};
+
 static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -613,6 +688,10 @@
 		fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
 				&adap->dev->i2c_adap, &af9035_tua9001_config);
 		break;
+	case AF9033_TUNER_FC0011:
+		fe = dvb_attach(fc0011_attach, adap->fe_adap[0].fe,
+				&adap->dev->i2c_adap, &af9035_fc0011_config);
+		break;
 	default:
 		fe = NULL;
 	}
Index: linux/drivers/media/dvb/frontends/af9033.c
===================================================================
--- linux.orig/drivers/media/dvb/frontends/af9033.c	2012-04-01 11:42:36.147526208 +0200
+++ linux/drivers/media/dvb/frontends/af9033.c	2012-04-01 11:42:38.919574120 +0200
@@ -297,6 +297,10 @@
 		len = ARRAY_SIZE(tuner_init_tua9001);
 		init = tuner_init_tua9001;
 		break;
+	case AF9033_TUNER_FC0011:
+		len = ARRAY_SIZE(tuner_init_fc0011);
+		init = tuner_init_fc0011;
+		break;
 	default:
 		pr_debug("%s: unsupported tuner ID=%d\n", __func__,
 				state->cfg.tuner);
Index: linux/drivers/media/dvb/frontends/af9033_priv.h
===================================================================
--- linux.orig/drivers/media/dvb/frontends/af9033_priv.h	2012-04-01 11:42:36.147526208 +0200
+++ linux/drivers/media/dvb/frontends/af9033_priv.h	2012-04-01 11:42:38.919574120 +0200
@@ -238,5 +238,66 @@
 	{ 0x80f1e6, 0x00 },
 };
 
+/* Fitipower fc0011 tuner init
+   AF9033_TUNER_FC0011    = 0x28 */
+static const struct reg_val tuner_init_fc0011[] = {
+	{ 0x800046, AF9033_TUNER_FC0011 },
+	{ 0x800057, 0x00 },
+	{ 0x800058, 0x01 },
+	{ 0x80005f, 0x00 },
+	{ 0x800060, 0x00 },
+	{ 0x800068, 0xa5 },
+	{ 0x80006e, 0x01 },
+	{ 0x800071, 0x0A },
+	{ 0x800072, 0x02 },
+	{ 0x800074, 0x01 },
+	{ 0x800079, 0x01 },
+	{ 0x800093, 0x00 },
+	{ 0x800094, 0x00 },
+	{ 0x800095, 0x00 },
+	{ 0x800096, 0x00 },
+	{ 0x80009b, 0x2D },
+	{ 0x80009c, 0x60 },
+	{ 0x80009d, 0x23 },
+	{ 0x8000a4, 0x50 },
+	{ 0x8000ad, 0x50 },
+	{ 0x8000b3, 0x01 },
+	{ 0x8000b7, 0x88 },
+	{ 0x8000b8, 0xa6 },
+	{ 0x8000c3, 0x01 },
+	{ 0x8000c4, 0x01 },
+	{ 0x8000c7, 0x69 },
+	{ 0x80F007, 0x00 },
+	{ 0x80F00A, 0x1B },
+	{ 0x80F00B, 0x1B },
+	{ 0x80F00C, 0x1B },
+	{ 0x80F00D, 0x1B },
+	{ 0x80F00E, 0xFF },
+	{ 0x80F00F, 0x01 },
+	{ 0x80F010, 0x00 },
+	{ 0x80F011, 0x02 },
+	{ 0x80F012, 0xFF },
+	{ 0x80F013, 0x01 },
+	{ 0x80F014, 0x00 },
+	{ 0x80F015, 0x02 },
+	{ 0x80F01B, 0xEF },
+	{ 0x80F01C, 0x01 },
+	{ 0x80F01D, 0x0f },
+	{ 0x80F01E, 0x02 },
+	{ 0x80F01F, 0x6E },
+	{ 0x80F020, 0x00 },
+	{ 0x80F025, 0xDE },
+	{ 0x80F026, 0x00 },
+	{ 0x80F027, 0x0A },
+	{ 0x80F028, 0x03 },
+	{ 0x80F029, 0x6E },
+	{ 0x80F02A, 0x00 },
+	{ 0x80F047, 0x00 },
+	{ 0x80F054, 0x00 },
+	{ 0x80F055, 0x00 },
+	{ 0x80F077, 0x01 },
+	{ 0x80F1E6, 0x00 },
+};
+
 #endif /* AF9033_PRIV_H */
 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 13:11                           ` Michael Büsch
@ 2012-04-01 13:19                             ` Antti Palosaari
  2012-04-01 14:42                             ` Hans-Frieder Vogt
  2012-04-01 16:15                             ` Michael Büsch
  2 siblings, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 13:19 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media, Daniel Glöckner

On 01.04.2012 16:11, Michael Büsch wrote:
> On Sun, 01 Apr 2012 15:29:07 +0300
> Antti Palosaari<crope@iki.fi>  wrote:
>> buf[1] = msg[0].addr<<  1;
>> Maybe you have given I2C address as a "8bit" format?
>
> Uhh, the address is leftshifted by one.
> So I changed the i2c address from 0xC0 to 0x60.

That's a very common mistake, I2C addresses are 7 bit and LSB is 
direction. But it is very common to see used it as a "8bit" format, 0xC0 
write address and 0xc1 as a read address. Even some data-sheets have 
that "wrong" naming.
There is many drivers that is wrong and causing confusion, even my old 
AF9015... :]

> The i2c write seems to work now. At least it doesn't complain anymore
> and it sorta seems to tune to the right frequency.
> But i2c read may be broken.
> I had to enable the commented read code, but it still fails to read
> the VCO calibration value:
>
> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
>
> It doesn't run into this check on the other af903x driver.
> So I suspect an i2c read issue here.

That could be I2C adapter issue too, TUA9001 does not use it and thus 
not tested at all... But for my eyes it looks logically correct still.

> Attached: The patches.

Lets see.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 12:31                       ` Antti Palosaari
@ 2012-04-01 14:31                         ` Hans-Frieder Vogt
  2012-04-01 15:00                           ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 14:31 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Antti,

I could provide the SNR, BER and UCB implementation (simply porting from my 
draft driver to yours).
But I first need to implement the support for my AverMedia A867R device so that 
I am able to test the implementation. Therefore it could take a few hours 
(maybe until tomorrow).

Regards,
Hans-Frieder

Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
> On 01.04.2012 13:27, Hans-Frieder Vogt wrote:
> > nice work! I'll try to port the features that I have in my implementation
> > of an af9035 driver into yours.
> 
> You are welcome! But please tell me what you are doing to avoid
> duplicate work. My today plan was to implement af9033 SNR, BER, UCB, but
> if you would like to then say it for me and I will jump back to IT9135
> support.
> 
> regards
> Antti


Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 13:11                           ` Michael Büsch
  2012-04-01 13:19                             ` Antti Palosaari
@ 2012-04-01 14:42                             ` Hans-Frieder Vogt
  2012-04-01 14:56                               ` Michael Büsch
  2012-04-01 16:15                             ` Michael Büsch
  2 siblings, 1 reply; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 14:42 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Antti Palosaari, linux-media

Michael,

Am Sonntag, 1. April 2012 schrieb Michael Büsch:
> On Sun, 01 Apr 2012 15:29:07 +0300
> 
> Antti Palosaari <crope@iki.fi> wrote:
> > buf[1] = msg[0].addr << 1;
> > Maybe you have given I2C address as a "8bit" format?
> 
> Uhh, the address is leftshifted by one.
> So I changed the i2c address from 0xC0 to 0x60.
> 
> The i2c write seems to work now. At least it doesn't complain anymore
> and it sorta seems to tune to the right frequency.
> But i2c read may be broken.
> I had to enable the commented read code, but it still fails to read
> the VCO calibration value:
> 
> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
> 
> It doesn't run into this check on the other af903x driver.
> So I suspect an i2c read issue here.

I would first uncomment the i2c read functionality in Antti's driver!

> 
> Attached: The patches.

Cheers,

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 14:42                             ` Hans-Frieder Vogt
@ 2012-04-01 14:56                               ` Michael Büsch
  2012-04-01 16:24                                 ` Hans-Frieder Vogt
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 14:56 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: Antti Palosaari, linux-media

[-- Attachment #1: Type: text/plain, Size: 482 bytes --]

On Sun, 1 Apr 2012 16:42:34 +0200
"Hans-Frieder Vogt" <hfvogt@gmx.net> wrote:
> > [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
> > 
> > It doesn't run into this check on the other af903x driver.
> > So I suspect an i2c read issue here.
> 
> I would first uncomment the i2c read functionality in Antti's driver!

I did this.

> > Attached: The patches.

See the patches.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 14:31                         ` Hans-Frieder Vogt
@ 2012-04-01 15:00                           ` Antti Palosaari
  2012-04-01 15:04                             ` Hans-Frieder Vogt
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 15:00 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 01.04.2012 17:31, Hans-Frieder Vogt wrote:
> Antti,
>
> I could provide the SNR, BER and UCB implementation (simply porting from my
> draft driver to yours).
> But I first need to implement the support for my AverMedia A867R device so that
> I am able to test the implementation. Therefore it could take a few hours
> (maybe until tomorrow).

Aaah, OK, but I was just working with SNR. I see your driver SNR was 
just register scaled to 0-0xffff whilst we nowadays prefer dBs , most 
commonly unit of 0.1 dB. So if thats OK for you I will finish that, and 
you can do BER and UCB, OK?

regards

Antti


>
> Regards,
> Hans-Frieder
>
> Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
>> On 01.04.2012 13:27, Hans-Frieder Vogt wrote:
>>> nice work! I'll try to port the features that I have in my implementation
>>> of an af9035 driver into yours.
>>
>> You are welcome! But please tell me what you are doing to avoid
>> duplicate work. My today plan was to implement af9033 SNR, BER, UCB, but
>> if you would like to then say it for me and I will jump back to IT9135
>> support.
>>
>> regards
>> Antti
>
>
> Hans-Frieder Vogt                       e-mail: hfvogt<at>  gmx .dot. net


-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 15:00                           ` Antti Palosaari
@ 2012-04-01 15:04                             ` Hans-Frieder Vogt
  0 siblings, 0 replies; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 15:04 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
> On 01.04.2012 17:31, Hans-Frieder Vogt wrote:
> > Antti,
> > 
> > I could provide the SNR, BER and UCB implementation (simply porting from
> > my draft driver to yours).
> > But I first need to implement the support for my AverMedia A867R device
> > so that I am able to test the implementation. Therefore it could take a
> > few hours (maybe until tomorrow).
> 
> Aaah, OK, but I was just working with SNR. I see your driver SNR was
> just register scaled to 0-0xffff whilst we nowadays prefer dBs , most
> commonly unit of 0.1 dB. So if thats OK for you I will finish that, and
> you can do BER and UCB, OK?

OK, I'll focus on these.

> 
> regards
> 
> Antti

[...]

cheers,

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 13:11                           ` Michael Büsch
  2012-04-01 13:19                             ` Antti Palosaari
  2012-04-01 14:42                             ` Hans-Frieder Vogt
@ 2012-04-01 16:15                             ` Michael Büsch
  2012-04-01 16:20                               ` Antti Palosaari
  2 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 16:15 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Antti Palosaari, linux-media, Daniel Glöckner

[-- Attachment #1: Type: text/plain, Size: 447 bytes --]

On Sun, 1 Apr 2012 15:11:53 +0200
Michael Büsch <m@bues.ch> wrote:

> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)

Ok, it turns out that it doesn't fail all the time, but only sporadically.
So increasing the number of retries fixes (or at least works around) it.

No idea why this behaves differently from fc0011 on Hans' driver, though.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 16:15                             ` Michael Büsch
@ 2012-04-01 16:20                               ` Antti Palosaari
  2012-04-01 16:32                                 ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 16:20 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media, Daniel Glöckner

On 01.04.2012 19:15, Michael Büsch wrote:
> On Sun, 1 Apr 2012 15:11:53 +0200
> Michael Büsch<m@bues.ch>  wrote:
>
>> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
>
> Ok, it turns out that it doesn't fail all the time, but only sporadically.
> So increasing the number of retries fixes (or at least works around) it.

OK, feel free to add ~3 retries inside af9035_ctrl_msg() i think.

You didn't mention if error is coming from af9035 firmware or from USB 
stack. Just for the interest...

> No idea why this behaves differently from fc0011 on Hans' driver, though.

Maybe some delay or there is retry on error logic.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 14:56                               ` Michael Büsch
@ 2012-04-01 16:24                                 ` Hans-Frieder Vogt
  2012-04-01 16:36                                   ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 16:24 UTC (permalink / raw)
  To: Michael Büsch; +Cc: Antti Palosaari, linux-media

Am Sonntag, 1. April 2012 schrieb Michael Büsch:
> On Sun, 1 Apr 2012 16:42:34 +0200
> 
> "Hans-Frieder Vogt" <hfvogt@gmx.net> wrote:
> > > [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
> > > 
> > > It doesn't run into this check on the other af903x driver.
> > > So I suspect an i2c read issue here.
> > 
> > I would first uncomment the i2c read functionality in Antti's driver!
> 
> I did this.

sorry. I didn't check your patches. However, I found the problem: the buffer 
length needs to be msg[1].len, see below. For my mxl5007t based device it 
worked.

 --- old/af9035.c 2012-04-01 16:41:53.694103691 +0200
+++ new/af9035.c    2012-04-01 18:22:25.026930784 +0200
@@ -209,24 +209,15 @@
                                        msg[1].len);
                } else {
                        /* I2C */
-#if 0
-                       /*
-                        * FIXME: Keep that code. It should work but as it is
-                        * not tested I left it disabled and return -
EOPNOTSUPP
-                        * for the sure.
-                        */
                        u8 buf[4 + msg[0].len];
                        struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
                                        buf, msg[1].len, msg[1].buf };
-                       buf[0] = msg[0].len;
+                       buf[0] = msg[1].len;
                        buf[1] = msg[0].addr << 1;
                        buf[2] = 0x01;
                        buf[3] = 0x00;
                        memcpy(&buf[4], msg[0].buf, msg[0].len);
                        ret = af9035_ctrl_msg(d->udev, &req);
-#endif
-                       pr_debug("%s: I2C operation not supported\n", 
__func__);
-                       ret = -EOPNOTSUPP;
                }
        } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
                if (msg[0].len > 40) {


> > > Attached: The patches.
> 
> See the patches.

cheers,

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 16:20                               ` Antti Palosaari
@ 2012-04-01 16:32                                 ` Michael Büsch
  2012-04-01 16:39                                   ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 16:32 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media, Daniel Glöckner

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

On Sun, 01 Apr 2012 19:20:21 +0300
Antti Palosaari <crope@iki.fi> wrote:

> On 01.04.2012 19:15, Michael Büsch wrote:
> > On Sun, 1 Apr 2012 15:11:53 +0200
> > Michael Büsch<m@bues.ch>  wrote:
> >
> >> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
> >
> > Ok, it turns out that it doesn't fail all the time, but only sporadically.
> > So increasing the number of retries fixes (or at least works around) it.
> 
> OK, feel free to add ~3 retries inside af9035_ctrl_msg() i think.

Well I didn't retry at that level, but at the fc0011 driver level.
It does already retry once in fc0011 (with complete tuner reset).
I increased it to 6 times (3 was not enough).

I think we can't retry at af9035_ctrl_msg() level, because the
actual i2c/usb transfer does not fail. The received packet checksum even
is ok (although we currently don't check it. I'll send a patch for that later).

> You didn't mention if error is coming from af9035 firmware or from USB 
> stack. Just for the interest...

I don't know how much the firmware is involved in this, but _maybe_ this
glitch is caused by it.

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 16:24                                 ` Hans-Frieder Vogt
@ 2012-04-01 16:36                                   ` Michael Büsch
  0 siblings, 0 replies; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 16:36 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: Antti Palosaari, linux-media

[-- Attachment #1: Type: text/plain, Size: 1955 bytes --]

On Sun, 1 Apr 2012 18:24:09 +0200
"Hans-Frieder Vogt" <hfvogt@gmx.net> wrote:
> However, I found the problem: the buffer 
> length needs to be msg[1].len, see below.

I spotted this bug, too, but it didn't fix the problem, as len is 1 for
both packets in my specific case. So it doesn't make a difference in this case.

But as I said in the previous mail: I did more debugging and I'm pretty sure that
the actual i2c reads and writes work as expected. The problem is at another level.

>  --- old/af9035.c 2012-04-01 16:41:53.694103691 +0200
> +++ new/af9035.c    2012-04-01 18:22:25.026930784 +0200
> @@ -209,24 +209,15 @@
>                                         msg[1].len);
>                 } else {
>                         /* I2C */
> -#if 0
> -                       /*
> -                        * FIXME: Keep that code. It should work but as it is
> -                        * not tested I left it disabled and return -
> EOPNOTSUPP
> -                        * for the sure.
> -                        */
>                         u8 buf[4 + msg[0].len];
>                         struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
>                                         buf, msg[1].len, msg[1].buf };
> -                       buf[0] = msg[0].len;
> +                       buf[0] = msg[1].len;
>                         buf[1] = msg[0].addr << 1;
>                         buf[2] = 0x01;
>                         buf[3] = 0x00;
>                         memcpy(&buf[4], msg[0].buf, msg[0].len);
>                         ret = af9035_ctrl_msg(d->udev, &req);
> -#endif
> -                       pr_debug("%s: I2C operation not supported\n", 
> __func__);
> -                       ret = -EOPNOTSUPP;
>                 }
>         } else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
>                 if (msg[0].len > 40) {

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 16:32                                 ` Michael Büsch
@ 2012-04-01 16:39                                   ` Antti Palosaari
  2012-04-01 16:44                                     ` Michael Büsch
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 16:39 UTC (permalink / raw)
  To: Michael Büsch; +Cc: linux-media, Daniel Glöckner

On 01.04.2012 19:32, Michael Büsch wrote:
> On Sun, 01 Apr 2012 19:20:21 +0300
> Antti Palosaari<crope@iki.fi>  wrote:
>
>> On 01.04.2012 19:15, Michael Büsch wrote:
>>> On Sun, 1 Apr 2012 15:11:53 +0200
>>> Michael Büsch<m@bues.ch>   wrote:
>>>
>>>> [ 3101.940765] i2c i2c-8: Failed to read VCO calibration value (got 20)
>>>
>>> Ok, it turns out that it doesn't fail all the time, but only sporadically.
>>> So increasing the number of retries fixes (or at least works around) it.
>>
>> OK, feel free to add ~3 retries inside af9035_ctrl_msg() i think.
>
> Well I didn't retry at that level, but at the fc0011 driver level.
> It does already retry once in fc0011 (with complete tuner reset).
> I increased it to 6 times (3 was not enough).

Maybe some delay is needed in order to wait tuner wakes up after the 
reset. Reason it does not occur the other driver is likely there is some 
delay somewhere...

> I think we can't retry at af9035_ctrl_msg() level, because the
> actual i2c/usb transfer does not fail. The received packet checksum even
> is ok (although we currently don't check it. I'll send a patch for that later).
>
>> You didn't mention if error is coming from af9035 firmware or from USB
>> stack. Just for the interest...
>
> I don't know how much the firmware is involved in this, but _maybe_ this
> glitch is caused by it.

Indeed, you are correct, no changes for af9035_ctrl_msg() are not wanted 
as error is not coming from af9035. Likely some small delay for tuner in 
order to wake up it from the reset.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-04-01 16:39                                   ` Antti Palosaari
@ 2012-04-01 16:44                                     ` Michael Büsch
  0 siblings, 0 replies; 45+ messages in thread
From: Michael Büsch @ 2012-04-01 16:44 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media, Daniel Glöckner

[-- Attachment #1: Type: text/plain, Size: 741 bytes --]

On Sun, 01 Apr 2012 19:39:56 +0300
Antti Palosaari <crope@iki.fi> wrote:

> > Well I didn't retry at that level, but at the fc0011 driver level.
> > It does already retry once in fc0011 (with complete tuner reset).
> > I increased it to 6 times (3 was not enough).
> 
> Maybe some delay is needed in order to wait tuner wakes up after the 
> reset. Reason it does not occur the other driver is likely there is some 
> delay somewhere...

Yep, I suspect that, too. However, I already tried lots of things that didn't
really work. Such as adding 100ms delay before and after all i2c reads
and writes inside of the fc0011 driver.
I'll investigate further...

-- 
Greetings, Michael.

PGP encryption is encouraged / 908D8B0E

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner)
  2012-04-01  4:51                   ` Antti Palosaari
                                       ` (2 preceding siblings ...)
  2012-04-01 10:27                     ` Hans-Frieder Vogt
@ 2012-04-01 17:15                     ` Hans-Frieder Vogt
  2012-04-01 17:24                       ` Antti Palosaari
  3 siblings, 1 reply; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 17:15 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t (needs the i2c read bug fixed patch send earlier).

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>

 drivers/media/dvb/dvb-usb/af9033.c      |   36 +++++++++++---
 drivers/media/dvb/dvb-usb/af9033.h      |    6 ++
 drivers/media/dvb/dvb-usb/af9033_priv.h |   35 ++++++++++++++
 drivers/media/dvb/dvb-usb/af9035.c      |   78 +++++++++++++++++++++++++++++---
 drivers/media/dvb/dvb-usb/af9035.h      |   31 +++++++-----
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    1 
 6 files changed, 158 insertions(+), 29 deletions(-)

diff -Nupr a/drivers/media/dvb/dvb-usb/af9033.c b/drivers/media/dvb/dvb-usb/af9033.c
--- a/drivers/media/dvb/dvb-usb/af9033.c	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033.c	2012-04-01 19:03:01.119522845 +0200
@@ -297,6 +297,10 @@ static int af9033_init(struct dvb_fronte
 		len = ARRAY_SIZE(tuner_init_tua9001);
 		init = tuner_init_tua9001;
 		break;
+	case AF9033_TUNER_MXL5007T:
+		len = ARRAY_SIZE(tuner_init_mxl5007t);
+		init = tuner_init_mxl5007t;
+		break;
 	default:
 		pr_debug("%s: unsupported tuner ID=%d\n", __func__,
 				state->cfg.tuner);
@@ -387,9 +391,9 @@ static int af9033_set_frontend(struct dv
 {
 	struct af9033_state *state = fe->demodulator_priv;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-	int ret, i;
+	int ret, i, spec_inv;
 	u8 tmp, buf[3], bandwidth_reg_val;
-	u32 if_frequency, freq_cw;
+	u32 if_frequency, freq_cw, adc_freq;
 
 	pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency,
 			c->bandwidth_hz);
@@ -429,22 +433,36 @@ static int af9033_set_frontend(struct dv
 
 	/* program frequency control */
 	if (c->bandwidth_hz != state->bandwidth_hz) {
+		spec_inv = state->cfg.spec_inv ? -1 : 1;
+		adc_freq = state->cfg.adc_clock;
+
 		/* get used IF frequency */
 		if (fe->ops.tuner_ops.get_if_frequency)
 			fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
 		else
 			if_frequency = 0;
 
-		/* FIXME: we support only Zero-IF currently */
-		if (if_frequency != 0) {
-			pr_debug("%s: only Zero-IF supported currently\n",
-				__func__);
+		while (if_frequency > (adc_freq / 2))
+			if_frequency -= adc_freq;
+
+		if (if_frequency >= 0)
+			spec_inv *= -1;
+		else
+			if_frequency *= -1;
+
+		freq_cw = af9033_div(if_frequency, adc_freq, 23ul);
+
+		if (spec_inv == -1)
+			freq_cw *= -1;
 
-			ret = -ENODEV;
+		/* get adc multiplies */
+		ret = af9033_rd_reg(state, 0x800045, &tmp);
+		if (ret < 0)
 			goto err;
-		}
 
-		freq_cw = 0;
+		if (tmp == 1)
+			freq_cw /= 2;
+
 		buf[0] = (freq_cw >>  0) & 0xff;
 		buf[1] = (freq_cw >>  8) & 0xff;
 		buf[2] = (freq_cw >> 16) & 0x7f;
diff -Nupr a/drivers/media/dvb/dvb-usb/af9033.h b/drivers/media/dvb/dvb-usb/af9033.h
--- a/drivers/media/dvb/dvb-usb/af9033.h	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033.h	2012-04-01 17:52:42.851767290 +0200
@@ -36,10 +36,16 @@ struct af9033_config {
 	u32 clock;
 
 	/*
+	 * ADC clock Hz
+	 */
+	u32 adc_clock;
+
+	/*
 	 * tuner
 	 */
 #define AF9033_TUNER_TUA9001     0x27 /* Infineon TUA 9001 */
 #define AF9033_TUNER_FC0011      0x28 /* Fitipower FC0011 */
+#define AF9033_TUNER_MXL5007T    0xa0 /* MaxLinear MxL5007T */
 	u8 tuner;
 
 	/*
diff -Nupr a/drivers/media/dvb/dvb-usb/af9033_priv.h b/drivers/media/dvb/dvb-usb/af9033_priv.h
--- a/drivers/media/dvb/dvb-usb/af9033_priv.h	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033_priv.h	2012-04-01 17:30:34.989592418 +0200
@@ -238,5 +238,40 @@ static const struct reg_val tuner_init_t
 	{ 0x80f1e6, 0x00 },
 };
 
+/* MaxLinear MxL5007T tuner init
+   AF9033_TUNER_MXL5007T    = 0xa0 */
+static const struct reg_val tuner_init_mxl5007t[] = {
+	{ 0x800046, 0x1b },
+	{ 0x800057, 0x01 },
+	{ 0x800058, 0x01 },
+	{ 0x80005f, 0x00 },
+	{ 0x800060, 0x00 },
+	{ 0x800068, 0x96 },
+	{ 0x800071, 0x05 },
+	{ 0x800072, 0x02 },
+	{ 0x800074, 0x01 },
+	{ 0x800079, 0x01 },
+	{ 0x800093, 0x00 },
+	{ 0x800094, 0x00 },
+	{ 0x800095, 0x00 },
+	{ 0x800096, 0x00 },
+	{ 0x8000b3, 0x01 },
+	{ 0x8000c1, 0x01 },
+	{ 0x8000c2, 0x00 },
+	{ 0x80f007, 0x00 },
+	{ 0x80f00c, 0x19 },
+	{ 0x80f00d, 0x1a },
+	{ 0x80f012, 0xda },
+	{ 0x80f013, 0x00 },
+	{ 0x80f014, 0x00 },
+	{ 0x80f015, 0x02 },
+	{ 0x80f01f, 0x82 },
+	{ 0x80f020, 0x00 },
+	{ 0x80f029, 0x82 },
+	{ 0x80f02a, 0x00 },
+	{ 0x80f077, 0x02 },
+	{ 0x80f1e6, 0x00 },
+};
+
 #endif /* AF9033_PRIV_H */
 
diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c
--- a/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 18:22:25.026930784 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 19:03:21.796053677 +0200
@@ -22,6 +22,7 @@
 #include "af9035.h"
 #include "af9033.h"
 #include "tua9001.h"
+#include "mxl5007t.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 static DEFINE_MUTEX(af9035_usb_mutex);
@@ -214,8 +215,8 @@ static int af9035_i2c_master_xfer(struct
 					buf, msg[1].len, msg[1].buf };
 			buf[0] = msg[1].len;
 			buf[1] = msg[0].addr << 1;
-			buf[2] = 0x01;
-			buf[3] = 0x00;
+			buf[2] = 0x01;	/* address size */
+			buf[3] = 0x00;	/* high byte of reg. address */
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
 		}
@@ -236,8 +237,8 @@ static int af9035_i2c_master_xfer(struct
 					0, NULL };
 			buf[0] = msg[0].len;
 			buf[1] = msg[0].addr << 1;
-			buf[2] = 0x01;
-			buf[3] = 0x00;
+			buf[2] = 0x01;	/* address size */
+			buf[3] = 0x00;	/* high byte of reg. address */
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
 		}
@@ -471,6 +472,7 @@ static int af9035_read_mac_address(struc
 
 		switch (tmp) {
 		case AF9033_TUNER_TUA9001:
+		case AF9033_TUNER_MXL5007T:
 			af9035_af9033_config[i].spec_inv = 1;
 			break;
 		default:
@@ -504,8 +506,10 @@ static int af9035_read_mac_address(struc
 
 	tmp = (tmp >> 0) & 0x0f;
 
-	for (i = 0; i < af9035_properties[0].num_adapters; i++)
-		af9035_af9033_config[i].clock = clock_lut[tmp];
+	for (i = 0; i < af9035_properties[0].num_adapters; i++) {
+		af9035_af9033_config[i].clock = clock_lut[tmp].crystal;
+		af9035_af9033_config[i].adc_clock = clock_lut[tmp].adc;
+	}
 
 	return 0;
 
@@ -556,6 +560,15 @@ static struct tua9001_config af9035_tua9
 	.i2c_addr = 0x60,
 };
 
+static struct mxl5007t_config af9035_mxl5007t_config = {
+	.xtal_freq_hz = MxL_XTAL_24_MHZ,
+	.if_freq_hz = MxL_IF_4_57_MHZ,
+	.invert_if = 0,
+	.loop_thru_enable = 0,
+	.clk_out_enable = 0,
+	.clk_out_amp = MxL_CLKOUT_AMP_0_94V,
+};
+
 static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -604,6 +617,48 @@ static int af9035_tuner_attach(struct dv
 		fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
 				&adap->dev->i2c_adap, &af9035_tua9001_config);
 		break;
+	case AF9033_TUNER_MXL5007T:
+		ret = af9035_wr_reg(adap->dev, 0x00d8e0, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8e1, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8df, 0);
+		if (ret < 0)
+			goto err;
+
+		msleep(30);
+
+		ret = af9035_wr_reg(adap->dev, 0x00d8df, 1);
+		if (ret < 0)
+			goto err;
+
+		msleep(300);
+
+		ret = af9035_wr_reg(adap->dev, 0x00d8c0, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8c1, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8bf, 0);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b4, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b5, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b3, 1);
+		if (ret < 0)
+			goto err;
+
+		/* attach tuner */
+		fe = dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
+				&adap->dev->i2c_adap, 0x60, &af9035_mxl5007t_config);
+		break;
 	default:
 		fe = NULL;
 	}
@@ -623,11 +678,14 @@ err:
 
 enum af9035_id_entry {
 	AF9035_0CCD_0093,
+	AF9035_07CA_1867,
 };
 
 static struct usb_device_id af9035_id[] = {
 	[AF9035_0CCD_0093] = {
 		USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK)},
+	[AF9035_07CA_1867] = {
+		USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_1867)},
 	{},
 };
 
@@ -670,7 +728,7 @@ static struct dvb_usb_device_properties
 
 		.i2c_algo = &af9035_i2c_algo,
 
-		.num_device_descs = 1,
+		.num_device_descs = 2,
 		.devices = {
 			{
 				.name = "TerraTec Cinergy T Stick",
@@ -678,6 +736,12 @@ static struct dvb_usb_device_properties
 					&af9035_id[AF9035_0CCD_0093],
 				},
 			},
+			{
+				.name = "AVerMedia HD Volar",
+				.cold_ids = {
+					&af9035_id[AF9035_07CA_1867],
+				},
+			},
 		}
 	},
 };
diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.h b/drivers/media/dvb/dvb-usb/af9035.h
--- a/drivers/media/dvb/dvb-usb/af9035.h	2012-04-01 16:42:16.680606002 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.h	2012-04-01 17:51:37.739010279 +0200
@@ -66,19 +66,24 @@ struct fw_header {
 	struct fw_segment segment[SEGMENT_MAX_COUNT];
 };
 
-u32 clock_lut[] = {
-	20480000, /*      FPGA */
-	16384000, /* 16.38 MHz */
-	20480000, /* 20.48 MHz */
-	36000000, /* 36.00 MHz */
-	30000000, /* 30.00 MHz */
-	26000000, /* 26.00 MHz */
-	28000000, /* 28.00 MHz */
-	32000000, /* 32.00 MHz */
-	34000000, /* 34.00 MHz */
-	24000000, /* 24.00 MHz */
-	22000000, /* 22.00 MHz */
-	12000000, /* 12.00 MHz */
+struct af9035_clock {
+	u32 crystal;
+	u32 adc;
+};
+
+struct af9035_clock clock_lut[] = {
+	{ 20480000, 20480000 }, /*      FPGA */
+	{ 16384000, 20480000 }, /* 16.38 MHz */
+	{ 20480000, 20480000 }, /* 20.48 MHz */
+	{ 36000000, 20250000 }, /* 36.00 MHz */
+	{ 30000000, 20156250 }, /* 30.00 MHz */
+	{ 26000000, 20583333 }, /* 26.00 MHz */
+	{ 28000000, 20416667 }, /* 28.00 MHz */
+	{ 32000000, 20500000 }, /* 32.00 MHz */
+	{ 34000000, 20187500 }, /* 34.00 MHz */
+	{ 24000000, 20500000 }, /* 24.00 MHz */
+	{ 22000000, 20625000 }, /* 22.00 MHz */
+	{ 12000000, 20250000 }  /* 12.00 MHz */
 };
 
 /* EEPROM locations */
diff -Nupr a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	2012-03-09 05:45:19.000000000 +0100
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	2012-04-01 18:42:11.646802238 +0200
@@ -221,6 +221,7 @@
 #define USB_PID_AVERMEDIA_A850T				0x850b
 #define USB_PID_AVERMEDIA_A805				0xa805
 #define USB_PID_AVERMEDIA_A815M				0x815a
+#define USB_PID_AVERMEDIA_1867				0x1867
 #define USB_PID_TECHNOTREND_CONNECT_S2400               0x3006
 #define USB_PID_TECHNOTREND_CONNECT_CT3650		0x300d
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY	0x005a


Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner)
  2012-04-01 17:15                     ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner) Hans-Frieder Vogt
@ 2012-04-01 17:24                       ` Antti Palosaari
  2012-04-01 18:11                         ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix Hans-Frieder Vogt
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 17:24 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 01.04.2012 20:15, Hans-Frieder Vogt wrote:
> Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t (needs the i2c read bug fixed patch send earlier).

Could you sent separate patch for I2C read fix?

The only functional comment I has is about ADC frequency. There is 
Xtal/ADC lookup table already in af9033_priv.h. You could use it instead 
of adding new configuration parameter. Demodulator driver generally 
needs only Xtal frequency as a parameter, other can be usually 
discovered by driver.

But if you would not like to fix it, I will apply that as it is. It is 
not so important issue after all.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix
  2012-04-01 17:24                       ` Antti Palosaari
@ 2012-04-01 18:11                         ` Hans-Frieder Vogt
  2012-04-01 18:16                           ` Antti Palosaari
  2012-04-01 21:07                           ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Hans-Frieder Vogt
  0 siblings, 2 replies; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 18:11 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Antti,

attached is the i2c read fix (necessary e.g. for mxl5007t tuner, because it 
sends a 2 bytes for a read request, thus msg[0].len != msg[1].len).
 
Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
> On 01.04.2012 20:15, Hans-Frieder Vogt wrote:
> > Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t (needs the i2c
> > read bug fixed patch send earlier).
> 
> Could you sent separate patch for I2C read fix?
> 
> The only functional comment I has is about ADC frequency. There is
> Xtal/ADC lookup table already in af9033_priv.h. You could use it instead
> of adding new configuration parameter. Demodulator driver generally
> needs only Xtal frequency as a parameter, other can be usually
> discovered by driver.
> 
> But if you would not like to fix it, I will apply that as it is. It is
> not so important issue after all.
> 
> regards
> Antti

Enable i2c read requests.

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>

 drivers/media/dvb/dvb-usb/af9035.c |   11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-
usb/af9035.c
--- a/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 16:41:53.694103691 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 18:22:25.026930784 +0200
@@ -209,24 +209,15 @@ static int af9035_i2c_master_xfer(struct
 					msg[1].len);
 		} else {
 			/* I2C */
-#if 0
-			/*
-			 * FIXME: Keep that code. It should work but as it is
-			 * not tested I left it disabled and return -EOPNOTSUPP
-			 * for the sure.
-			 */
 			u8 buf[4 + msg[0].len];
 			struct usb_req req = { CMD_I2C_RD, 0, sizeof(buf),
 					buf, msg[1].len, msg[1].buf };
-			buf[0] = msg[0].len;
+			buf[0] = msg[1].len;
 			buf[1] = msg[0].addr << 1;
 			buf[2] = 0x01;
 			buf[3] = 0x00;
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
-#endif
-			pr_debug("%s: I2C operation not supported\n", __func__);
-			ret = -EOPNOTSUPP;
 		}
 	} else if (num == 1 && !(msg[0].flags & I2C_M_RD)) {
 		if (msg[0].len > 40) {


Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix
  2012-04-01 18:11                         ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix Hans-Frieder Vogt
@ 2012-04-01 18:16                           ` Antti Palosaari
  2012-04-01 21:07                           ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Hans-Frieder Vogt
  1 sibling, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 18:16 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 01.04.2012 21:11, Hans-Frieder Vogt wrote:
> attached is the i2c read fix (necessary e.g. for mxl5007t tuner, because it
> sends a 2 bytes for a read request, thus msg[0].len != msg[1].len).
>
> Enable i2c read requests.
>
> Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>

Applied, thank you!

http://git.linuxtv.org/anttip/media_tree.git/shortlog/refs/heads/af9035_experimental

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2
  2012-04-01 18:11                         ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix Hans-Frieder Vogt
  2012-04-01 18:16                           ` Antti Palosaari
@ 2012-04-01 21:07                           ` Hans-Frieder Vogt
  2012-04-01 21:19                             ` [PATCH] AF9033 read_ber and read_ucblocks implementation Hans-Frieder Vogt
  2012-04-01 21:32                             ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Antti Palosaari
  1 sibling, 2 replies; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 21:07 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t, second version of patch
(usage of clock_adc_lut instead of adc config variable)

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>

 drivers/media/dvb/dvb-usb/af9033.c      |   45 +++++++++++++++----
 drivers/media/dvb/dvb-usb/af9033.h      |    1 
 drivers/media/dvb/dvb-usb/af9033_priv.h |   35 ++++++++++++++
 drivers/media/dvb/dvb-usb/af9035.c      |   75 +++++++++++++++++++++++++++++---
 drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    1 
 5 files changed, 142 insertions(+), 15 deletions(-)

diff -Nupr a/drivers/media/dvb/dvb-usb/af9033.c b/drivers/media/dvb/dvb-usb/af9033.c
--- a/drivers/media/dvb/dvb-usb/af9033.c	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033.c	2012-04-01 22:41:45.378193253 +0200
@@ -297,6 +297,10 @@ static int af9033_init(struct dvb_fronte
 		len = ARRAY_SIZE(tuner_init_tua9001);
 		init = tuner_init_tua9001;
 		break;
+	case AF9033_TUNER_MXL5007T:
+		len = ARRAY_SIZE(tuner_init_mxl5007t);
+		init = tuner_init_mxl5007t;
+		break;
 	default:
 		pr_debug("%s: unsupported tuner ID=%d\n", __func__,
 				state->cfg.tuner);
@@ -387,9 +391,9 @@ static int af9033_set_frontend(struct dv
 {
 	struct af9033_state *state = fe->demodulator_priv;
 	struct dtv_frontend_properties *c = &fe->dtv_property_cache;
-	int ret, i;
+	int ret, i, spec_inv;
 	u8 tmp, buf[3], bandwidth_reg_val;
-	u32 if_frequency, freq_cw;
+	u32 if_frequency, freq_cw, adc_freq;
 
 	pr_debug("%s: frequency=%d bandwidth_hz=%d\n", __func__, c->frequency,
 			c->bandwidth_hz);
@@ -429,22 +433,45 @@ static int af9033_set_frontend(struct dv
 
 	/* program frequency control */
 	if (c->bandwidth_hz != state->bandwidth_hz) {
+		spec_inv = state->cfg.spec_inv ? -1 : 1;
+
+		for (i = 0; i < ARRAY_SIZE(clock_adc_lut); i++) {
+			if (clock_adc_lut[i].clock == state->cfg.clock)
+				break;
+		}
+		if (i >= ARRAY_SIZE(clock_adc_lut)) {
+			ret = -EINVAL;
+			goto err;
+		}
+		adc_freq = clock_adc_lut[i].adc;
+
 		/* get used IF frequency */
 		if (fe->ops.tuner_ops.get_if_frequency)
 			fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency);
 		else
 			if_frequency = 0;
 
-		/* FIXME: we support only Zero-IF currently */
-		if (if_frequency != 0) {
-			pr_debug("%s: only Zero-IF supported currently\n",
-				__func__);
+		while (if_frequency > (adc_freq / 2))
+			if_frequency -= adc_freq;
 
-			ret = -ENODEV;
+		if (if_frequency >= 0)
+			spec_inv *= -1;
+		else
+			if_frequency *= -1;
+
+		freq_cw = af9033_div(if_frequency, adc_freq, 23ul);
+
+		if (spec_inv == -1)
+			freq_cw *= -1;
+
+		/* get adc multiplies */
+		ret = af9033_rd_reg(state, 0x800045, &tmp);
+		if (ret < 0)
 			goto err;
-		}
 
-		freq_cw = 0;
+		if (tmp == 1)
+			freq_cw /= 2;
+
 		buf[0] = (freq_cw >>  0) & 0xff;
 		buf[1] = (freq_cw >>  8) & 0xff;
 		buf[2] = (freq_cw >> 16) & 0x7f;
diff -Nupr a/drivers/media/dvb/dvb-usb/af9033.h b/drivers/media/dvb/dvb-usb/af9033.h
--- a/drivers/media/dvb/dvb-usb/af9033.h	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033.h	2012-04-01 22:57:33.016761649 +0200
@@ -40,6 +40,7 @@ struct af9033_config {
 	 */
 #define AF9033_TUNER_TUA9001     0x27 /* Infineon TUA 9001 */
 #define AF9033_TUNER_FC0011      0x28 /* Fitipower FC0011 */
+#define AF9033_TUNER_MXL5007T    0xa0 /* MaxLinear MxL5007T */
 	u8 tuner;
 
 	/*
diff -Nupr a/drivers/media/dvb/dvb-usb/af9033_priv.h b/drivers/media/dvb/dvb-usb/af9033_priv.h
--- a/drivers/media/dvb/dvb-usb/af9033_priv.h	2012-03-31 17:41:11.584990674 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033_priv.h	2012-04-01 17:30:34.989592418 +0200
@@ -238,5 +238,40 @@ static const struct reg_val tuner_init_t
 	{ 0x80f1e6, 0x00 },
 };
 
+/* MaxLinear MxL5007T tuner init
+   AF9033_TUNER_MXL5007T    = 0xa0 */
+static const struct reg_val tuner_init_mxl5007t[] = {
+	{ 0x800046, 0x1b },
+	{ 0x800057, 0x01 },
+	{ 0x800058, 0x01 },
+	{ 0x80005f, 0x00 },
+	{ 0x800060, 0x00 },
+	{ 0x800068, 0x96 },
+	{ 0x800071, 0x05 },
+	{ 0x800072, 0x02 },
+	{ 0x800074, 0x01 },
+	{ 0x800079, 0x01 },
+	{ 0x800093, 0x00 },
+	{ 0x800094, 0x00 },
+	{ 0x800095, 0x00 },
+	{ 0x800096, 0x00 },
+	{ 0x8000b3, 0x01 },
+	{ 0x8000c1, 0x01 },
+	{ 0x8000c2, 0x00 },
+	{ 0x80f007, 0x00 },
+	{ 0x80f00c, 0x19 },
+	{ 0x80f00d, 0x1a },
+	{ 0x80f012, 0xda },
+	{ 0x80f013, 0x00 },
+	{ 0x80f014, 0x00 },
+	{ 0x80f015, 0x02 },
+	{ 0x80f01f, 0x82 },
+	{ 0x80f020, 0x00 },
+	{ 0x80f029, 0x82 },
+	{ 0x80f02a, 0x00 },
+	{ 0x80f077, 0x02 },
+	{ 0x80f1e6, 0x00 },
+};
+
 #endif /* AF9033_PRIV_H */
 
diff -Nupr a/drivers/media/dvb/dvb-usb/af9035.c b/drivers/media/dvb/dvb-usb/af9035.c
--- a/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 18:22:25.026930784 +0200
+++ b/drivers/media/dvb/dvb-usb/af9035.c	2012-04-01 22:37:44.003632270 +0200
@@ -22,6 +22,7 @@
 #include "af9035.h"
 #include "af9033.h"
 #include "tua9001.h"
+#include "mxl5007t.h"
 
 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
 static DEFINE_MUTEX(af9035_usb_mutex);
@@ -214,8 +215,8 @@ static int af9035_i2c_master_xfer(struct
 					buf, msg[1].len, msg[1].buf };
 			buf[0] = msg[1].len;
 			buf[1] = msg[0].addr << 1;
-			buf[2] = 0x01;
-			buf[3] = 0x00;
+			buf[2] = 0x01;	/* address size */
+			buf[3] = 0x00;	/* high byte of reg. address */
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
 		}
@@ -236,8 +237,8 @@ static int af9035_i2c_master_xfer(struct
 					0, NULL };
 			buf[0] = msg[0].len;
 			buf[1] = msg[0].addr << 1;
-			buf[2] = 0x01;
-			buf[3] = 0x00;
+			buf[2] = 0x01;	/* address size */
+			buf[3] = 0x00;	/* high byte of reg. address */
 			memcpy(&buf[4], msg[0].buf, msg[0].len);
 			ret = af9035_ctrl_msg(d->udev, &req);
 		}
@@ -471,6 +472,7 @@ static int af9035_read_mac_address(struc
 
 		switch (tmp) {
 		case AF9033_TUNER_TUA9001:
+		case AF9033_TUNER_MXL5007T:
 			af9035_af9033_config[i].spec_inv = 1;
 			break;
 		default:
@@ -504,8 +506,9 @@ static int af9035_read_mac_address(struc
 
 	tmp = (tmp >> 0) & 0x0f;
 
-	for (i = 0; i < af9035_properties[0].num_adapters; i++)
+	for (i = 0; i < af9035_properties[0].num_adapters; i++) {
 		af9035_af9033_config[i].clock = clock_lut[tmp];
+	}
 
 	return 0;
 
@@ -556,6 +559,15 @@ static struct tua9001_config af9035_tua9
 	.i2c_addr = 0x60,
 };
 
+static struct mxl5007t_config af9035_mxl5007t_config = {
+	.xtal_freq_hz = MxL_XTAL_24_MHZ,
+	.if_freq_hz = MxL_IF_4_57_MHZ,
+	.invert_if = 0,
+	.loop_thru_enable = 0,
+	.clk_out_enable = 0,
+	.clk_out_amp = MxL_CLKOUT_AMP_0_94V,
+};
+
 static int af9035_tuner_attach(struct dvb_usb_adapter *adap)
 {
 	int ret;
@@ -604,6 +616,48 @@ static int af9035_tuner_attach(struct dv
 		fe = dvb_attach(tua9001_attach, adap->fe_adap[0].fe,
 				&adap->dev->i2c_adap, &af9035_tua9001_config);
 		break;
+	case AF9033_TUNER_MXL5007T:
+		ret = af9035_wr_reg(adap->dev, 0x00d8e0, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8e1, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8df, 0);
+		if (ret < 0)
+			goto err;
+
+		msleep(30);
+
+		ret = af9035_wr_reg(adap->dev, 0x00d8df, 1);
+		if (ret < 0)
+			goto err;
+
+		msleep(300);
+
+		ret = af9035_wr_reg(adap->dev, 0x00d8c0, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8c1, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8bf, 0);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b4, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b5, 1);
+		if (ret < 0)
+			goto err;
+		ret = af9035_wr_reg(adap->dev, 0x00d8b3, 1);
+		if (ret < 0)
+			goto err;
+
+		/* attach tuner */
+		fe = dvb_attach(mxl5007t_attach, adap->fe_adap[0].fe,
+				&adap->dev->i2c_adap, 0x60, &af9035_mxl5007t_config);
+		break;
 	default:
 		fe = NULL;
 	}
@@ -623,11 +677,14 @@ err:
 
 enum af9035_id_entry {
 	AF9035_0CCD_0093,
+	AF9035_07CA_1867,
 };
 
 static struct usb_device_id af9035_id[] = {
 	[AF9035_0CCD_0093] = {
 		USB_DEVICE(USB_VID_TERRATEC, USB_PID_TERRATEC_CINERGY_T_STICK)},
+	[AF9035_07CA_1867] = {
+		USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_1867)},
 	{},
 };
 
@@ -670,7 +727,7 @@ static struct dvb_usb_device_properties
 
 		.i2c_algo = &af9035_i2c_algo,
 
-		.num_device_descs = 1,
+		.num_device_descs = 2,
 		.devices = {
 			{
 				.name = "TerraTec Cinergy T Stick",
@@ -678,6 +735,12 @@ static struct dvb_usb_device_properties
 					&af9035_id[AF9035_0CCD_0093],
 				},
 			},
+			{
+				.name = "AVerMedia HD Volar",
+				.cold_ids = {
+					&af9035_id[AF9035_07CA_1867],
+				},
+			},
 		}
 	},
 };
diff -Nupr a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h
--- a/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	2012-03-09 05:45:19.000000000 +0100
+++ b/drivers/media/dvb/dvb-usb/dvb-usb-ids.h	2012-04-01 18:42:11.646802238 +0200
@@ -221,6 +221,7 @@
 #define USB_PID_AVERMEDIA_A850T				0x850b
 #define USB_PID_AVERMEDIA_A805				0xa805
 #define USB_PID_AVERMEDIA_A815M				0x815a
+#define USB_PID_AVERMEDIA_1867				0x1867
 #define USB_PID_TECHNOTREND_CONNECT_S2400               0x3006
 #define USB_PID_TECHNOTREND_CONNECT_CT3650		0x300d
 #define USB_PID_TERRATEC_CINERGY_DT_XS_DIVERSITY	0x005a

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [PATCH] AF9033 read_ber and read_ucblocks implementation
  2012-04-01 21:07                           ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Hans-Frieder Vogt
@ 2012-04-01 21:19                             ` Hans-Frieder Vogt
  2012-04-01 21:56                               ` Antti Palosaari
  2012-04-01 21:32                             ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Antti Palosaari
  1 sibling, 1 reply; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-01 21:19 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Implementation of af9033_read_ber and af9033_read_ucblocks functions.

Signed-off-by: Hans-Frieder Vogt <hfvogt@gmx.net>

 drivers/media/dvb/dvb-usb/af9033.c |   68 +++++++++++++++++++++++++++++++++++--
 1 file changed, 66 insertions(+), 2 deletions(-)

diff -Nupr a/drivers/media/dvb/dvb-usb/af9033.c b/drivers/media/dvb/dvb-usb/af9033.c
--- a/drivers/media/dvb/dvb-usb/af9033.c	2012-04-01 22:41:45.378193253 +0200
+++ b/drivers/media/dvb/dvb-usb/af9033.c	2012-04-01 23:12:19.212643650 +0200
@@ -29,6 +29,10 @@ struct af9033_state {
 	u32 bandwidth_hz;
 	bool ts_mode_parallel;
 	bool ts_mode_serial;
+
+	u32 ber;
+	u32 ucb;
+	unsigned long last_stat_check;
 };
 
 /* write multiple registers */
@@ -594,16 +598,76 @@ err:
 	return ret;
 }
 
+static int af9033_update_ch_stat(struct af9033_state *state)
+{
+	int ret = 0;
+	u32 post_err_cnt, post_bit_cnt;
+	u16 abort_cnt;
+	u8 buf[7];
+	static u8 sw = 0;
+
+	/* only update data every half second */
+	if (time_after(jiffies, state->last_stat_check + 500 * HZ / 1000)) {
+		ret = af9033_rd_regs(state, 0x800032, buf, sizeof(buf));
+		if (ret < 0)
+			goto err;
+		abort_cnt = (buf[1] << 8) + buf[0];
+		post_err_cnt = (buf[4] << 16) + (buf[3] << 8) + buf[2];
+		post_bit_cnt = (buf[6] << 8) + buf[5];
+		if (post_bit_cnt == 0) {
+			abort_cnt = 1000;
+			post_err_cnt = 1;
+			post_bit_cnt = 2;
+		} else {
+			post_bit_cnt -= (u32)abort_cnt;
+			if (post_bit_cnt == 0) {
+				post_err_cnt = 1;
+				post_bit_cnt = 2;
+			} else {
+				post_err_cnt -= (u32)abort_cnt * 8 * 8;
+				post_bit_cnt *= 204 * 8;
+			}
+		}
+		state->ber = post_err_cnt * (0xffffffff / post_bit_cnt);
+		/* reset ucblocks value every second call */
+		if (sw)
+			state->ucb = abort_cnt;
+		else
+			state->ucb = +abort_cnt;
+		sw = ~sw;
+		state->last_stat_check = jiffies;
+	}
+
+	return 0;
+err:
+	pr_debug("%s: failed=%d\n", __func__, ret);
+	return ret;
+}
+
 static int af9033_read_ber(struct dvb_frontend *fe, u32 *ber)
 {
-	*ber = 0;
+	struct af9033_state *state = fe->demodulator_priv;
+	int ret;
+
+	ret = af9033_update_ch_stat(state);
+	if (ret < 0)
+		return ret;
+
+	*ber = state->ber;
 
 	return 0;
 }
 
 static int af9033_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
 {
-	*ucblocks = 0;
+	struct af9033_state *state = fe->demodulator_priv;
+	int ret;
+
+	ret = af9033_update_ch_stat(state);
+	if (ret < 0)
+		return ret;
+
+	*ucblocks = state->ucb;
 
 	return 0;
 }

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2
  2012-04-01 21:07                           ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Hans-Frieder Vogt
  2012-04-01 21:19                             ` [PATCH] AF9033 read_ber and read_ucblocks implementation Hans-Frieder Vogt
@ 2012-04-01 21:32                             ` Antti Palosaari
  2012-04-02 17:02                               ` Hans-Frieder Vogt
  1 sibling, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 21:32 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 02.04.2012 00:07, Hans-Frieder Vogt wrote:
> Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t, second version of patch
> (usage of clock_adc_lut instead of adc config variable)
>
> Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>

Patch does not apply.
wget -O - http://patchwork.linuxtv.org/patch/10536/mbox/ | git am -s
[...]
Applying: AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), 
version 2
error: drivers/media/dvb/dvb-usb/af9033.c: does not exist in index
error: drivers/media/dvb/dvb-usb/af9033.h: does not exist in index
error: drivers/media/dvb/dvb-usb/af9033_priv.h: does not exist in index

How is it possible you have the af9033 demod driver inside dvb-usb 
directory? Demod drivers are inside drivers/media/dvb/frontends/. DVB 
USB interface drivers are inside drivers/media/dvb/dvb-usb/.

Now it looks still much better than first version.

Here are still some comments of quick visual review:

> +		for (i = 0; i<  ARRAY_SIZE(clock_adc_lut); i++) {
> +			if (clock_adc_lut[i].clock == state->cfg.clock)
> +				break;
> +		}
> +		if (i>= ARRAY_SIZE(clock_adc_lut)) {
> +			ret = -EINVAL;
> +			goto err;
> +		}

That error check is useless in my understanding. It is never taken. 
Likely some Kernel semantic error checker will report it later...

> +		adc_freq = clock_adc_lut[i].adc;


> -	for (i = 0; i<  af9035_properties[0].num_adapters; i++)
> +	for (i = 0; i<  af9035_properties[0].num_adapters; i++) {
>   		af9035_af9033_config[i].clock = clock_lut[tmp];
> +	}

No braces allowed here as it is single line. You did not ran 
checkpatch.pl as it will report those.

Hans-Frieder, fix those findings and remember ran also Kernel 
checkpatch.pl - it may report some more findings.

You can ran it like that:
git diff drivers/media/dvb/frontends/af9033.c | ./scripts/checkpatch.pl -

Or if you have already added those files as git add then you can:
git diff --cached | ./scripts/checkpatch.pl -

Good work still! Next try should be OK :)

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] AF9033 read_ber and read_ucblocks implementation
  2012-04-01 21:19                             ` [PATCH] AF9033 read_ber and read_ucblocks implementation Hans-Frieder Vogt
@ 2012-04-01 21:56                               ` Antti Palosaari
  2012-04-01 22:11                                 ` Antti Palosaari
  0 siblings, 1 reply; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 21:56 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 02.04.2012 00:19, Hans-Frieder Vogt wrote:
> Implementation of af9033_read_ber and af9033_read_ucblocks functions.
>
> Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>

>   drivers/media/dvb/dvb-usb/af9033.c |   68 +++++++++++++++++++++++++++++++++++--

Same wrong path issue.

> +	/* only update data every half second */
> +	if (time_after(jiffies, state->last_stat_check + 500 * HZ / 1000)) {

500 * HZ looks odd. I suspect correct way is to use some macros for 
that. See af9013 example usage of jiffies or explain the reason why 500 
* HZ :)

> +		sw = ~sw;

I don't see any reason for that?


It looked somehow complex, but I trust those calculations are kinda correct.


IMHO it is enough to put random raw number from register to UCB and BER 
counters. Random numbers are good enough unless you are making 
measurement equipment. But off-course correct calculations are allowed.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] AF9033 read_ber and read_ucblocks implementation
  2012-04-01 21:56                               ` Antti Palosaari
@ 2012-04-01 22:11                                 ` Antti Palosaari
  0 siblings, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-01 22:11 UTC (permalink / raw)
  To: Hans-Frieder Vogt; +Cc: linux-media

On 02.04.2012 00:56, Antti Palosaari wrote:
> On 02.04.2012 00:19, Hans-Frieder Vogt wrote:
>> Implementation of af9033_read_ber and af9033_read_ucblocks functions.
>> + sw = ~sw;
>
> I don't see any reason for that?

Now I see, it is some kind of switch to make operation every second call?
As it is defined static:
+	static u8 sw = 0;
[...]
+		if (sw)
+			state->ucb = abort_cnt;
+		else
+			state->ucb = +abort_cnt;
+		sw = ~sw;

Unfortunately I am almost sure it will not work as it should. In my 
understanding this kind of static variables are shared between driver 
instances... and if you have device where is two or more af9033 demods 
it will share it. Also if you have multiple af9033 devices, are are 
shared. It works only if you have one af9033 demodulator in use.

Instead, this kind of switches should be but to driver private aka 
state. Also think twice if all that logic is correct and needed.

regards
Antti
-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2
  2012-04-01 21:32                             ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Antti Palosaari
@ 2012-04-02 17:02                               ` Hans-Frieder Vogt
  0 siblings, 0 replies; 45+ messages in thread
From: Hans-Frieder Vogt @ 2012-04-02 17:02 UTC (permalink / raw)
  To: Antti Palosaari; +Cc: linux-media

Antti,

I am currently working with a simple standalone test environment and therefore 
have manually (!) included the paths. Well, this went terribly wrong... Sorry.

Am Sonntag, 1. April 2012 schrieb Antti Palosaari:
> On 02.04.2012 00:07, Hans-Frieder Vogt wrote:
> > Support of AVerMedia AVerTV HD Volar, with tuner MxL5007t, second version
> > of patch (usage of clock_adc_lut instead of adc config variable)
> > 
> > Signed-off-by: Hans-Frieder Vogt<hfvogt@gmx.net>
> 
> Patch does not apply.
> wget -O - http://patchwork.linuxtv.org/patch/10536/mbox/ | git am -s
> [...]
> Applying: AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t),
> version 2
> error: drivers/media/dvb/dvb-usb/af9033.c: does not exist in index
> error: drivers/media/dvb/dvb-usb/af9033.h: does not exist in index
> error: drivers/media/dvb/dvb-usb/af9033_priv.h: does not exist in index
> 
> How is it possible you have the af9033 demod driver inside dvb-usb
> directory? Demod drivers are inside drivers/media/dvb/frontends/. DVB
> USB interface drivers are inside drivers/media/dvb/dvb-usb/.
> 
> Now it looks still much better than first version.
> 
> Here are still some comments of quick visual review:
> > +		for (i = 0; i<  ARRAY_SIZE(clock_adc_lut); i++) {
> > +			if (clock_adc_lut[i].clock == state->cfg.clock)
> > +				break;
> > +		}
> > +		if (i>= ARRAY_SIZE(clock_adc_lut)) {
> > +			ret = -EINVAL;
> > +			goto err;
> > +		}
I included this as a sanity check. It should not be needed if it can be 
ensured that the lookup tables clock_lut (in af9035.h) and clock_adc_lut (in 
af9033_priv.h) always contain the same Xtal frequencies. Maybe these two 
tables coule be merged...

> That error check is useless in my understanding. It is never taken.
> Likely some Kernel semantic error checker will report it later...
> 
> > +		adc_freq = clock_adc_lut[i].adc;
> > 
> > 
> > -	for (i = 0; i<  af9035_properties[0].num_adapters; i++)
> > +	for (i = 0; i<  af9035_properties[0].num_adapters; i++) {
> > 
> >   		af9035_af9033_config[i].clock = clock_lut[tmp];
> > 
> > +	}
> 
> No braces allowed here as it is single line. You did not ran
> checkpatch.pl as it will report those.
> 
> Hans-Frieder, fix those findings and remember ran also Kernel
> checkpatch.pl - it may report some more findings.
> 
> You can ran it like that:
> git diff drivers/media/dvb/frontends/af9033.c | ./scripts/checkpatch.pl -
> 
thanks very much. I'll send an updated patch soon...

> Or if you have already added those files as git add then you can:
> git diff --cached | ./scripts/checkpatch.pl -
> 
> Good work still! Next try should be OK :)
> 
> regards
> Antti

regards,

Hans-Frieder Vogt                       e-mail: hfvogt <at> gmx .dot. net

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093]
  2012-03-30 12:33 [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Antti Palosaari
  2012-03-30 21:45 ` Michael Büsch
@ 2012-04-06 11:11 ` Antti Palosaari
  2012-05-07 18:44 ` [GIT PULL FOR 3.5] AF9035/AF9033 Antti Palosaari
  2 siblings, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-04-06 11:11 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media
  Cc: Gianluca Gennari, Michael Büsch, Hans-Frieder Vogt,
	Pierangelo Terzulli

PULL-request update.

On 30.03.2012 15:33, Antti Palosaari wrote:
> Terve Mauro and all the other hackers,
>
> I did some massive rewrite for my old AF9035/AF9033 driver that was
> never merged. Anyhow, here it is.
>
> New drivers here are:
> Infineon TUA 9001 silicon tuner driver
> Afatech AF9033 DVB-T demodulator driver
> Afatech AF9035 DVB USB driver

Fitipower FC0011 silicon tuner driver

> AF9035 integrates AF9033. Both chips are also sold separately. AF9033
> will not likely work as a stand-alone since I didn't have hardware to
> test, but in theory it is quite well split out from the DVB USB
> interface driver (AF9035).

The following changes since commit 26315a507f6acda933f0d41200de8fec51775867:

   em28xx-dvb: stop URBs when stopping the streaming (2012-03-28 
15:32:23 +0300)

are available in the git repository at:
   git://linuxtv.org/anttip/media_tree.git af9035

Antti Palosaari (15):
       Infineon TUA 9001 silicon tuner driver
       Afatech AF9033 DVB-T demodulator driver
       Afatech AF9035 DVB USB driver
       af9035: enhancement for unknown tuner ID handling
       af9035: reimplement firmware downloader
       af9035: add missing error check
       af9033: correct debug print
       af9033: implement .read_snr()
       af9035: add log writing if unsupported Xtal freq is given
       af9035: fix and enhance I2C adapter
       af9035: initial support for IT9135 chip
       af9033: do some minor changes for .get_frontend()
       af9035: minor changes for af9035_fc0011_tuner_callback()
       af9035: reorganise USB ID and device list
       af9035: disable frontend0 I2C-gate control

Gianluca Gennari (5):
       af9035: add USB id for 07ca:a867
       af9035: add support for the tda18218 tuner
       af9035: use module_usb_driver macro
       af9035: fix warning
       af9033: implement get_frontend

Hans-Frieder Vogt (2):
       af9035: i2c read fix
       af9035: add Avermedia Volar HD (A867R) support

Michael Buesch (7):
       af9035: Add USB read checksumming
       Add fc0011 tuner driver
       af9035: Add fc0011 tuner support
       af9035: Add Afatech USB PIDs
       fc0011: use usleep_range()
       af9035: Use usleep_range() in fc0011 support code
       fc0011: Reduce number of retries

Pierangelo Terzulli (1):
       af9035: add AVerMedia Twinstar (A825) [07ca:0825]

  MAINTAINERS                                |    7 +
  drivers/media/common/tuners/Kconfig        |   13 +
  drivers/media/common/tuners/Makefile       |    2 +
  drivers/media/common/tuners/fc0011.c       |  524 +++++++++++++
  drivers/media/common/tuners/fc0011.h       |   41 +
  drivers/media/common/tuners/tua9001.c      |  215 +++++
  drivers/media/common/tuners/tua9001.h      |   46 ++
  drivers/media/common/tuners/tua9001_priv.h |   34 +
  drivers/media/dvb/dvb-usb/Kconfig          |   12 +
  drivers/media/dvb/dvb-usb/Makefile         |    3 +
  drivers/media/dvb/dvb-usb/af9035.c         | 1164 
++++++++++++++++++++++++++++
  drivers/media/dvb/dvb-usb/af9035.h         |  120 +++
  drivers/media/dvb/dvb-usb/dvb-usb-ids.h    |    8 +
  drivers/media/dvb/frontends/Kconfig        |    5 +
  drivers/media/dvb/frontends/Makefile       |    1 +
  drivers/media/dvb/frontends/af9033.c       |  919 ++++++++++++++++++++++
  drivers/media/dvb/frontends/af9033.h       |   75 ++
  drivers/media/dvb/frontends/af9033_priv.h  |  470 +++++++++++
  18 files changed, 3659 insertions(+), 0 deletions(-)
  create mode 100644 drivers/media/common/tuners/fc0011.c
  create mode 100644 drivers/media/common/tuners/fc0011.h
  create mode 100644 drivers/media/common/tuners/tua9001.c
  create mode 100644 drivers/media/common/tuners/tua9001.h
  create mode 100644 drivers/media/common/tuners/tua9001_priv.h
  create mode 100644 drivers/media/dvb/dvb-usb/af9035.c
  create mode 100644 drivers/media/dvb/dvb-usb/af9035.h
  create mode 100644 drivers/media/dvb/frontends/af9033.c
  create mode 100644 drivers/media/dvb/frontends/af9033.h
  create mode 100644 drivers/media/dvb/frontends/af9033_priv.h

-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

* [GIT PULL FOR 3.5] AF9035/AF9033
  2012-03-30 12:33 [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Antti Palosaari
  2012-03-30 21:45 ` Michael Büsch
  2012-04-06 11:11 ` Antti Palosaari
@ 2012-05-07 18:44 ` Antti Palosaari
  2 siblings, 0 replies; 45+ messages in thread
From: Antti Palosaari @ 2012-05-07 18:44 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, linux-media
  Cc: Gianluca Gennari, Michael Büsch, Hans-Frieder Vogt

Moikka Mauro,

Some AF9035/AF9033 changes for the 3.5!

Do you have idea about last date for the 3.5 PULL requests?

regards
Antti



The following changes since commit cd58ef79264198a905367d19b1a110c2f6ac1156:

   af9035: disable frontend0 I2C-gate control (2012-04-06 13:09:23 +0300)

are available in the git repository at:
   git://linuxtv.org/anttip/media_tree.git af9035

Antti Palosaari (5):
       af9035: various small changes for af9035_ctrl_msg()
       af9035: remove unused struct
       af9035: move device configuration to the state
       af9035: remove one config parameter
       af9035: add few new reference design USB IDs

Hans-Frieder Vogt (2):
       af9035: add remote control support
       af9033: implement ber and ucb functions

  drivers/media/dvb/dvb-usb/af9035.c      |  174 
++++++++++++++++++++++---------
  drivers/media/dvb/dvb-usb/af9035.h      |   23 ++---
  drivers/media/dvb/dvb-usb/dvb-usb-ids.h |    7 +-
  drivers/media/dvb/frontends/af9033.c    |   65 +++++++++++-
  4 files changed, 202 insertions(+), 67 deletions(-)


-- 
http://palosaari.fi/

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2012-05-07 18:44 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-30 12:33 [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Antti Palosaari
2012-03-30 21:45 ` Michael Büsch
2012-03-30 22:00   ` Antti Palosaari
2012-03-30 22:14     ` Michael Büsch
2012-03-31 14:04       ` Michael Büsch
2012-03-31 14:28         ` Antti Palosaari
2012-03-31 16:29           ` Michael Büsch
2012-03-31 16:34             ` Antti Palosaari
2012-03-31 16:48               ` Antti Palosaari
2012-03-31 16:52                 ` Michael Büsch
2012-04-01  4:51                   ` Antti Palosaari
2012-04-01  8:33                     ` Michael Büsch
2012-04-01 12:19                       ` Michael Büsch
2012-04-01 12:29                         ` Antti Palosaari
2012-04-01 13:11                           ` Michael Büsch
2012-04-01 13:19                             ` Antti Palosaari
2012-04-01 14:42                             ` Hans-Frieder Vogt
2012-04-01 14:56                               ` Michael Büsch
2012-04-01 16:24                                 ` Hans-Frieder Vogt
2012-04-01 16:36                                   ` Michael Büsch
2012-04-01 16:15                             ` Michael Büsch
2012-04-01 16:20                               ` Antti Palosaari
2012-04-01 16:32                                 ` Michael Büsch
2012-04-01 16:39                                   ` Antti Palosaari
2012-04-01 16:44                                     ` Michael Büsch
2012-04-01  9:56                     ` Gianluca Gennari
2012-04-01 10:27                     ` Hans-Frieder Vogt
2012-04-01 12:31                       ` Antti Palosaari
2012-04-01 14:31                         ` Hans-Frieder Vogt
2012-04-01 15:00                           ` Antti Palosaari
2012-04-01 15:04                             ` Hans-Frieder Vogt
2012-04-01 12:53                       ` Antti Palosaari
2012-04-01 17:15                     ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t tuner) Hans-Frieder Vogt
2012-04-01 17:24                       ` Antti Palosaari
2012-04-01 18:11                         ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 i2c read fix Hans-Frieder Vogt
2012-04-01 18:16                           ` Antti Palosaari
2012-04-01 21:07                           ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Hans-Frieder Vogt
2012-04-01 21:19                             ` [PATCH] AF9033 read_ber and read_ucblocks implementation Hans-Frieder Vogt
2012-04-01 21:56                               ` Antti Palosaari
2012-04-01 22:11                                 ` Antti Palosaari
2012-04-01 21:32                             ` [PATCH][GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 support for AverTV A867R (mxl5007t), version 2 Antti Palosaari
2012-04-02 17:02                               ` Hans-Frieder Vogt
2012-03-31 16:49               ` [GIT PULL FOR 3.5] AF9035/AF9033/TUA9001 => TerraTec Cinergy T Stick [0ccd:0093] Michael Büsch
2012-04-06 11:11 ` Antti Palosaari
2012-05-07 18:44 ` [GIT PULL FOR 3.5] AF9035/AF9033 Antti Palosaari

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.