Bug 2249 - FM Radio frequency not set for use in Japan
: FM Radio frequency not set for use in Japan
Status: RESOLVED WONTFIX
Product: Core
Kernel
: 4.0
: N800 Maemo
: Low enhancement (vote)
: ---
Assigned To: unassigned
: linux-kernel-bugs
:
: community-diablo, patch
:
:
  Show dependency tree
 
Reported: 2007-11-10 12:32 UTC by Kenroy Harrison
Modified: 2009-10-22 07:56 UTC (History)
7 users (show)

See Also:


Attachments
patch to enable FM band selection in tea5761 (3.69 KB, patch)
2007-11-14 22:54 UTC, Martin Grimme
Details
fixed patch (3.69 KB, patch)
2007-11-14 23:14 UTC, Martin Grimme
Details
Test Output from pyFMRadio (945 bytes, text/plain)
2007-11-19 11:31 UTC, Kenroy Harrison
Details
Cleaned up patch following the kernel coding guidelines (3.93 KB, patch)
2007-11-21 23:51 UTC, Martin Grimme
Details


Note

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


Description Kenroy Harrison (reporter) 2007-11-10 12:32:09 UTC
EXPECTED OUTCOME: Ability to select band to enable receiving broadcasts in
Japan.

ACTUAL OUTCOME: Frequencies only available for US and Europe.

The product data sheet states:

The TEA5761UK can be switched to the Japanese FM band or to the US and Europe
FM
band. Setting bit BLIM to logic 0 the band range is 87.5 MHz to 108 MHz;
setting bit
BLIM to logic 1 selects the Japanese band range of 76 MHz to 90 MHz.
Comment 1 Jason Carter 2007-11-11 08:54:15 UTC
Seeing that the tablets never were released in Japan, it seems reasonable that
the FM radio program was never set up to allow receiving Japanese FM radio
signals. I honestly doubt we'll see this happen, especially since no one would
be able to really confirm that a fix would be working or not. I guess never say
never.

Changed severity to enhancement and target milestone to future, as there's no
way this would make it into the next target, 4.0 release.. which is more or
less already out the door.
Comment 2 Kenroy Harrison (reporter) 2007-11-11 09:03:51 UTC
Since the internet tablet is considered to be a mobile device, it would be
reasonable to assume that one would take it with them on their trip to Japan.
The capability of switching to the Japanese FM band would be desirable in this
case.

(In reply to comment #1)
> Seeing that the tablets never were released in Japan, it seems reasonable that
> the FM radio program was never set up to allow receiving Japanese FM radio
> signals. I honestly doubt we'll see this happen, especially since no one would
> be able to really confirm that a fix would be working or not. I guess never say
> never.
> 
> Changed severity to enhancement and target milestone to future, as there's no
> way this would make it into the next target, 4.0 release.. which is more or
> less already out the door.
>
Comment 3 timeless 2007-11-13 03:58:28 UTC
a version of the fmradio code has:
#define FM_FREQ_MAX 108.0
#define FM_FREQ_MIN 87.5
(i.e., it's hard coded, so dealing w/ this would require quite a bit of work at
the client level.)

From reading w/ Google, the following information seems publicly available:
http://linux.omap.com/pipermail/linux-omap-open-source/2007-February/009067.html

This seems to be fairly close to the driver code that's actually used (well,
give it was taken from the public source drop, i suppose it should be
identical, but whatever).

I'm not a kernel dev, and it's after 3am, but it looks like you need:
r->tnctrl |= TEA5761_TNCTRL_BLIM
if you want to do what you described in comment 0, and afaict from reading look
at the cited URL, that just isn't a reachable state.

there's also TEA5761_TNCTRL_HLSI which to me seems to be similarly interesting,
but again, it too appears immutable.

If I'm correct, someone should file a bug using:
https://bugs.maemo.org/enter_bug.cgi?product=System+Software&component=Kernel&format=guided&rep_platform=N800&op_sys=ITOS&version=4.0&blocked=2249&bug_file_loc=http://linux.omap.com/pipermail/linux-omap-open-source/2007-February/009067.html&short_desc=TEA5761+does+not+support+setting+BLIM+and+HLSI

(or something like that, please fill in other details)

However, do keep in mind, that it's quite likely that Nokia did not apply for
regulatory approval to use an FM Radio in the n800 in Japan (given that Nokia
presumably did not intend to sell the product in Japan). I have no idea how
that plays w/ a kernel, but, the consequences for a user could be quite
interesting.

The code I was reading was equivalent to the code for 4.0 at some point in
time. I have no idea about kernel update plans, but probably the right thing to
do would be to (a) get upstream fixed and (b) write patches for kernels that
run on the n800.

FWIW, every time I tried looking for information about this code, I hit
garage/mplayer code, that code seems to be at:
http://timeless.justdave.net/mxr-test/garage/source/mplayer/trunk/stream/stream_radio.c

So, I think the thing for you to do (near term) is grab the n800 kernel sources
(pick a version), fix the kernel driver (assuming I'm right), and get things
working w/ MPlayer.

If I'm wrong, sample (bsd) code w/ ioctls would probably be a reasonable start.

Note of course that the fmradio applet is really from our perspective second
party code (it's not made by the people who make ITOS), and while they seem to
have made some minor commitment to encourage bug report filings, they are not
particularly responsive (I've filed a couple of bugs, which they poked them as
recently as last august, merely indicating that they would think about them for
a future release. I suppose the good thing is that it means they're not quite
dead yet).

Note: I'm confirming this bug to force an email to a certain user, not because
I necessarily agree that this is a bug in the indicated product (dear sir:
welcome).
Comment 4 Martin Grimme 2007-11-14 22:54:32 UTC
Created an attachment (id=609) [details]
patch to enable FM band selection in tea5761

I have made a patch for the tea5761.c driver code. This is not yet tested (I'm
not in Japan), but since it switches the BLIM bit, it should work as expected.
Comment 5 Martin Grimme 2007-11-14 23:07:04 UTC
Just adding myself to the CC list. I'm the author of pyFMRadio and this is were
this feature request came up originally.
Comment 6 Martin Grimme 2007-11-14 23:14:02 UTC
Created an attachment (id=610) [details]
fixed patch

Oops, found some bug in the patch. Here's a new patch.
Comment 7 Martin Grimme 2007-11-18 18:01:46 UTC
Is there somebody in Japan at the moment to be able to test this?

https://garage.maemo.org/forum/forum.php?forum_id=1877

Sample Python code for testing:

from FMRadio import FMRadio
import time

r = FMRadio()
r.set_fm_band(r.FM_BAND_JPN)
for freq in r.scan():
    r.set_frequency(freq)
    r.set_volume(50)
    time.sleep(3)
r.close()
Comment 8 Kenroy Harrison (reporter) 2007-11-19 11:31:38 UTC
Created an attachment (id=616) [details]
Test Output from pyFMRadio
Comment 9 Kenroy Harrison (reporter) 2007-11-19 11:32:46 UTC
(In reply to comment #8)
> Created an attachment (id=616) [details] [details]
> Test Output from pyFMRadio
> 

(In reply to comment #4)
> Created an attachment (id=609) [details] [details]
> patch to enable FM band selection in tea5761
> 
> I have made a patch for the tea5761.c driver code. This is not yet tested (I'm
> not in Japan), but since it switches the BLIM bit, it should work as expected.
> 

I tested Martin's patched kernel using the python sample code and was able to
tune in Japanese stations.
------
from FMRadio import FMRadio
import time

r = FMRadio()
r.set_fm_band(r.FM_BAND_JPN)
print r.get_frequency_range()

for freq in r.scan():
   r.set_frequency(freq)
   r.set_volume(50)
   print r.get_frequency()
   time.sleep(3)
r.close()
Comment 10 timeless 2007-11-19 11:46:55 UTC
(From update of attachment 610 [details])
afaict the file being patched doesn't use spaces for indentation. if this were
code for projects i'd work on, i'd reject the patch for not matching style
(tabs only).

please consider posting a patch that correctly follows file style (only tabs,
not spaces) for indentation.

hopefully we can find someone to upstream this patch.
Comment 11 Martin Grimme 2007-11-19 12:29:29 UTC
Thanks for testing the patch!

Now that the patch was confirmed to work, I'll clean it up and fix the style.

The patch uses the unused V4L2_CID_BRIGHTNESS ioctl for setting the FM band.
Since a FM radio doesn't use brightness, we shouldn't get any conflict. AFAIK,
there are no ioctl constants predefined in V4L for setting the FM band.
Comment 12 timeless 2007-11-20 11:18:24 UTC
since you're more worried about the kernel level than the radio applet, I'm
moving this bug to the kernel side.
Comment 13 Martin Grimme 2007-11-21 23:51:14 UTC
Created an attachment (id=620) [details]
Cleaned up patch following the kernel coding guidelines

This patch now tries to follow the kernel coding guidelines. How are the
chances to get this upstream and into Nokia's official kernels?
Comment 14 Hiroki Tamakoshi 2008-07-30 11:25:41 UTC
I appreciate this patch, because I'm living in Japan, has bought N800 and am
listing to radio everyday.
If I can listen to radio with N800, I'm happy.

Of course, I can apply this patch, and use another FM radio client distributed
at http://pyfmradio.garage.maemo.org/.
But, I must apply the patch EVERY kernel(ITOS) release.
It's hard.

I wish this patch is applied to the official ITOS, and the official FM radio
client is changed to reflect the patcth(or make the closed source be open).
Comment 15 Andre Klapper maemo.org 2009-04-09 12:11:23 UTC
CC'ing Carsten - patch available.
Comment 16 Andre Klapper maemo.org 2009-05-20 15:29:11 UTC
FM Radio functionality has been dropped for future development and no more
development will be done for it in Diablo/Chinook by Nokia. Sorry...
Comment 17 Tomasz Dominikowski 2009-07-12 13:30:27 UTC
Patch added to kernel-source-diablo, in N8x0:Testing, should be a part of the
next release of Mer (0.15).
Comment 18 Lucas Maneos 2009-10-22 07:56:38 UTC
Marking patches of interest to Diablo (Maemo4) community updates, please excuse
the noise.