Bug 13131 - FM tuner works but `ivtv-radio` cannot find any active radio channels on GotView PCI DVD Lite card
Summary: FM tuner works but `ivtv-radio` cannot find any active radio channels on GotV...
Status: CLOSED CODE_FIX
Alias: None
Product: v4l-dvb
Classification: Unclassified
Component: radio (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Hans Verkuil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-17 22:08 UTC by Artem S. Tashkinov
Modified: 2012-05-30 16:17 UTC (History)
3 users (show)

See Also:
Kernel Version: GIT
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmesg (12.64 KB, application/octet-stream)
2009-06-12 19:08 UTC, Artem S. Tashkinov
Details
tuner-xc2028.c.diff by Hans Verkuil (662 bytes, patch)
2009-06-20 10:49 UTC, Artem S. Tashkinov
Details | Diff

Description Artem S. Tashkinov 2009-04-17 22:08:02 UTC
ivtv-radio cannot find any active radio channels:

./ivtv-radio -vv -s
87.00, 1392: 0
87.06, 1393: 0
87.12, 1394: 0
87.19, 1395: 0
...
107.81, 1725: 0
107.88, 1726: 0
107.94, 1727: 0

Hardware in question:

01:07.0 Multimedia video controller: Internext Compression Inc iTVC16 (CX23416) MPEG-2 Encoder (rev 01)
        Subsystem: Device ffad:0600
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 64 (32000ns min, 2000ns max), Cache Line Size: 32 bytes
        Interrupt: pin A routed to IRQ 17
        Region 0: Memory at d8000000 (32-bit, prefetchable) [size=64M]
        Capabilities: [44] Power Management version 2
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=0mA PME(D0-,D1-,D2-,D3hot-,D3cold-)
                Status: D0 PME-Enable- DSel=0 DScale=0 PME-
        Kernel driver in use: ivtv
        Kernel modules: ivtv

Apr 18 04:02:22 localhost kernel: ivtv: Start initialization, version 1.4.1
Apr 18 04:02:22 localhost kernel: ivtv 0000:01:07.0: Non-NULL drvdata on register
Apr 18 04:02:22 localhost kernel: ivtv0: Initializing card 0
Apr 18 04:02:22 localhost kernel: ivtv0: Autodetected Yuan PG600-2, GotView PCI DVD Lite card (cx23416 based)
Apr 18 04:02:22 localhost kernel: ivtv0:  info: base addr: 0xd8000000
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Enabling pci device
Apr 18 04:02:22 localhost kernel: ivtv 0000:01:07.0: PCI INT A -> Link[APC2] -> GSI 17 (level, low) -> IRQ 17
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Attempting to enable Bus Mastering
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Bus Mastering Enabled.
Apr 18 04:02:22 localhost kernel: ivtv0:  info: 22 (rev 1) at 01:07.0, irq: 17, latency: 64, memory: 0xd8000000
Apr 18 04:02:22 localhost kernel: ivtv0:  info: attempting ioremap at 0xd8000000 len 0x00800000
Apr 18 04:02:22 localhost kernel: ivtv0:  info: attempting ioremap at 0xda000000 len 0x00010000
Apr 18 04:02:22 localhost kernel: ivtv0:  info: GPIO initial dir: 0000d000 out: 00001000
Apr 18 04:02:22 localhost kernel: ivtv0:  info: activating i2c...
Apr 18 04:02:22 localhost kernel: cx25840 2-0044: cx25843-24 found @ 0x88 (ivtv i2c driver #0)
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Allocate DMA encoder MPG stream: 128 x 32768 buffers (4096kB total)
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Allocate DMA encoder YUV stream: 64 x 32768 buffers (2048kB total)
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Allocate DMA encoder VBI stream: 61 x 17472 buffers (1040kB total)
Apr 18 04:02:22 localhost kernel: ivtv0:  info: Allocate DMA encoder PCM stream: 72 x 4608 buffers (324kB total)
Apr 18 04:02:22 localhost kernel: ivtv0: Registered device video0 for encoder MPG (4096 kB)
Apr 18 04:02:22 localhost kernel: ivtv0: Registered device video32 for encoder YUV (2048 kB)
Apr 18 04:02:22 localhost kernel: ivtv0: Registered device vbi0 for encoder VBI (1024 kB)
Apr 18 04:02:22 localhost kernel: ivtv0: Registered device video24 for encoder PCM (320 kB)
Apr 18 04:02:22 localhost kernel: ivtv0: Registered device radio0 for encoder radio
Apr 18 04:02:22 localhost kernel: ivtv0: Initialized card: Yuan PG600-2, GotView PCI DVD Lite
Apr 18 04:02:22 localhost kernel: ivtv: End initialization
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Preparing for firmware halt.
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Stopping VDM
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Stopping AO
Apr 18 04:02:26 localhost kernel: ivtv0:  info: pinging (?) APU
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Stopping VPU
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Resetting Hw Blocks
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Stopping SPU
Apr 18 04:02:26 localhost kernel: ivtv0:  info: init Encoder SDRAM pre-charge
Apr 18 04:02:26 localhost kernel: ivtv0:  info: init Encoder SDRAM refresh to 1us
Apr 18 04:02:26 localhost kernel: ivtv0:  info: Sleeping for 600ms
Apr 18 04:02:27 localhost kernel: ivtv0:  info: Loading encoder image
Apr 18 04:02:27 localhost kernel: ivtv 0000:01:07.0: firmware: requesting v4l-cx2341x-enc.fw
Apr 18 04:02:27 localhost kernel: ivtv0: Loaded v4l-cx2341x-enc.fw firmware (376836 bytes)
Apr 18 04:02:27 localhost kernel: ivtv0:  info: Getting firmware version..
Apr 18 04:02:27 localhost kernel: ivtv0: Encoder revision: 0x02060039
Apr 18 04:02:27 localhost kernel: cx25840 2-0044: firmware: requesting v4l-cx25840.fw
Apr 18 04:02:30 localhost kernel: cx25840 2-0044: loaded v4l-cx25840.fw firmware (16382 bytes)

Last year's hack suggested by Mauro Carvalho Chehab doesn't help (adding .input1 = 1, to struct xc2028_ctrl of ivtv-driver.c file).
Comment 1 Artem S. Tashkinov 2009-04-17 22:10:06 UTC
It's not a regression, FM radio on this TV/FM tuner has never worked in Linux.
Comment 2 Hans Verkuil 2009-06-11 21:02:33 UTC
I may be mistaken, but I don't believe anyone managed to get radio working on a xceive 2028 + cx25840 card.
Comment 3 Artem S. Tashkinov 2009-06-12 07:05:27 UTC
Are there any chances that this device will work on Linux?
Comment 4 Hans Verkuil 2009-06-12 16:14:17 UTC
Try this: in ivtv-cards.c in the ivtv_card_pg600v2 card definition there is this line:

.radio_input = { IVTV_CARD_INPUT_AUD_TUNER, CX25840_AUDIO5 },

Try to test the radio using values CX25840_AUDIO4, AUDIO6, 7, 8 and CX25840_AUDIO_SERIAL. Perhaps they wired the radio sound differently.

It's unlikely, but nevertheless worth testing.

If this doesn't work, then the chances are pretty slim.
Comment 5 Artem S. Tashkinov 2009-06-12 19:08:12 UTC
Created attachment 21885 [details]
dmesg

Wow!

I've just downloaded and installed v4l-dvb-bff77ec33116 and radio indeed works without any hacks!!

The attachment is dmesg output for vanilla kernel 2.6.30. At first vanilla ivtv driver is automatically loaded, then I manually rmmod'ed it and installed ivtv bff77ec33116 hg snapshot.
Comment 6 Artem S. Tashkinov 2009-06-12 19:18:08 UTC
Thank you very much for your hard work, but, please, don't break tuner_xc2028 driver in the future :)

As a side note I should mention that ivtv-radio utility doesn't work correctly: for both -s and -a modes it cannot detect a single FM radio station, but as soon as I manually run it with a frequency of my choice (like ./ivtv-radio -f 100.0), I can hear the radio station clearly.

./ivtv-radio -vv -a
65.00, 1040000: 0
65.06, 1041000: 0
65.12, 1042000: 0

...
100.00, 1600000: 0 (a working radio station but it's not reported as working)
...
Comment 7 Hans Verkuil 2009-06-20 07:42:59 UTC
Hmm, looking at the code I think that the signal strength detection is broken.

Can you try this:

Edit drivers/media/common/tuners/tuner-xc2028.c, go to function xc2028_signal and replace this code:

        /* Frequency is locked */
        if (frq_lock == 1)
                signal = 32768;

        /* Get SNR of the video signal */
        rc = xc2028_get_reg(priv, 0x0040, &signal);
        if (rc < 0)
                goto ret;

        /* Use both frq_lock and signal to generate the result */
        signal = signal || ((signal & 0x07) << 12);

with this code:

        /* Frequency is locked */
        if (frq_lock == 1) {
                signal = 32768;
        } else {
                /* Get SNR of the video signal */
                rc = xc2028_get_reg(priv, 0x0040, &signal);
                if (rc < 0)
                        goto ret;

                signal = (signal & 0x07) << 12;
        }

Let me know if you now get a correct signal strength.
Comment 8 Hans Verkuil 2009-06-20 07:44:14 UTC
Reopened to investigate the signal strength issue.
Comment 9 Artem S. Tashkinov 2009-06-20 10:49:55 UTC
Created attachment 22020 [details]
tuner-xc2028.c.diff by Hans Verkuil

(In reply to comment #7)
> Hmm, looking at the code I think that the signal strength detection is
> broken.
> 
> Can you try this:
> 
> Edit drivers/media/common/tuners/tuner-xc2028.c, go to function xc2028_signal
> and replace this code:

If I got your code right, it still doesn't produce meaningful results. ivtv-radio works but it's unable to show working radio stations.

I was testing against hg snapshot v4l-dvb-bff77ec33116.
Comment 10 Hans Verkuil 2009-06-26 18:20:22 UTC
Just a quick update: I verified that the old code was indeed wrong. Whether the new code works or not is hard to tell for me at the moment as I do not have a proper cable for the radio antenna. I won't be able to get hold of that until 3 weeks from now. When I have it I can do some more testing.

It would not surprise me if this signal strength register only works with TV and not with radio signals.
Comment 11 Artem S. Tashkinov 2009-06-27 14:57:53 UTC
This brings an idea that you probably have to add a remark to ivtv-radio manual and say that some fm tuners do not report signal strength thus looking for radio stations is futile.

Or probably you have to rework a signal strength detection code of ivtv-radio so that it actually "listens" (detects actual signal/noise ratio) to the frequencies it's turning/switching to.

Note You need to log in before you can comment on or make changes to this bug.