[PATCH 1/1] [media] radio-keene: Use module_usb_driver

2014-01-27 Thread Sachin Kamat
module_usb_driver eliminates the boilerplate and makes the code simpler.

Signed-off-by: Sachin Kamat 
---
 drivers/media/radio/radio-keene.c |   19 +--
 1 file changed, 1 insertion(+), 18 deletions(-)

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index fa3964022b96..3d127825eceb 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -416,22 +416,5 @@ static struct usb_driver usb_keene_driver = {
.reset_resume   = usb_keene_resume,
 };
 
-static int __init keene_init(void)
-{
-   int retval = usb_register(&usb_keene_driver);
-
-   if (retval)
-   pr_err(KBUILD_MODNAME
-   ": usb_register failed. Error number %d\n", retval);
-
-   return retval;
-}
-
-static void __exit keene_exit(void)
-{
-   usb_deregister(&usb_keene_driver);
-}
-
-module_init(keene_init);
-module_exit(keene_exit);
+module_usb_driver(usb_keene_driver);
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/14] radio-keene: fix sparse warning

2013-10-04 Thread Hans Verkuil
From: Hans Verkuil 

drivers/media/radio/radio-keene.c:126:45: warning: dubious: !x | y

Signed-off-by: Hans Verkuil 
---
 drivers/media/radio/radio-keene.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 21db23b..fa39640 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -123,7 +123,7 @@ static int keene_cmd_set(struct keene_device *radio)
/* If bit 0 is set, then transmit mono, otherwise stereo.
   If bit 2 is set, then enable 75 us preemphasis, otherwise
   it is 50 us. */
-   radio->buffer[3] = (!radio->stereo) | (radio->preemph_75_us ? 4 : 0);
+   radio->buffer[3] = (radio->stereo ? 0 : 1) | (radio->preemph_75_us ? 4 
: 0);
radio->buffer[4] = 0x00;
radio->buffer[5] = 0x00;
radio->buffer[6] = 0x00;
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] Keene

2013-06-02 Thread Antti Palosaari
From: Hans Verkuil 

Can you try this patch:
---
 drivers/media/radio/radio-keene.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 4c9ae76..99da3d4 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
unsigned freq, bool play)
/* If bit 4 is set, then tune to the frequency.
   If bit 3 is set, then unmute; if bit 2 is set, then mute.
   If bit 1 is set, then enter idle mode; if bit 0 is set,
-  then enter transit mode.
+  then enter transmit mode.
 */
radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
(freq ? 0x10 : 0);
@@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
radio->pa = 118;
radio->tx = 0x32;
radio->stereo = true;
-   radio->curfreq = 95.16 * FREQ_MUL;
if (hdl->error) {
retval = hdl->error;
 
@@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
video_set_drvdata(&radio->vdev, radio);
set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
 
+   keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
+
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n");
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] Keene delay

2013-06-02 Thread Antti Palosaari
Hans, here you are!

Antti Palosaari (1):
  keene: add delay in order to settle hardware

Hans Verkuil (1):
  Keene

 drivers/media/radio/radio-keene.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] keene: add delay in order to settle hardware

2013-06-02 Thread Antti Palosaari
It was found by trial and error testing that at least 11 ms delay is
needed before first I/O, otherwise device will skip given command.

Signed-off-by: Antti Palosaari 
---
 drivers/media/radio/radio-keene.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 99da3d4..21db23b 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -382,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
video_set_drvdata(&radio->vdev, radio);
set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
 
+   /* at least 11ms is needed in order to settle hardware */
+   msleep(20);
keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
 
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-05-31 Thread Hans Verkuil
On Thu May 30 2013 01:52:02 Antti Palosaari wrote:
> On 05/29/2013 08:58 PM, Antti Palosaari wrote:
> > On 05/29/2013 05:26 PM, Hans Verkuil wrote:
> >> On Fri April 19 2013 11:11:27 Antti Palosaari wrote:
> >>> On 04/19/2013 10:12 AM, Hans Verkuil wrote:
>  On Wed April 17 2013 21:45:24 Antti Palosaari wrote:
> > On 04/15/2013 09:55 AM, Hans Verkuil wrote:
> >> On Fri April 12 2013 02:11:41 Antti Palosaari wrote:
> >>> Hello Hans,
> >>> That device is working very, thank you for it. Anyhow, I noticed
> >>> two things.
> >>>
> >>> 1) it does not start transmitting just after I plug it - I have to
> >>> retune it!
> >>> Output says it is tuned to 95.16 MHz by default, but it is not.
> >>> After I issue retune, just to same channel it starts working.
> >>> $ v4l2-ctl -d /dev/radio0 --set-freq=95.16
> >>
> >> Can you try this patch:
> >>
> >
> > It does not resolve the problem. It is quite strange behavior. After I
> > install modules, and modules are unload, plug stick in first time, it
> > usually (not every-time) starts TX. But when I replug it without
> > unloading modules, it will never start TX. Tx is started always when I
> > set freq using v4l2-ctl.
> 
>  If you replace 'false' by 'true' in the cmd_main, does that make it
>  work?
>  I'm fairly certain that's the problem.
> >>>
> >>> Nope, I replaces all 'false' with 'true' and problem remains. When
> >>> modules were unload and device is plugged it starts TX. When I replug it
> >>> doesn't start anymore.
> >>>
> >>> I just added msleep(1000); just before keene_cmd_main() in .probe() and
> >>> now it seems to work every-time. So it is definitely timing issue. I
> >>> will try to find out some smallest suitable value for sleep and and sent
> >>> patch.
> >>
> >> Have you had time to find a smaller msleep value?
> >
> > Nope, but I will do it today (if I don't meet any problems when
> > upgrading to latest master).
> >
> > regards
> > Antti
> >
> 
> Attached patch gives some idea. Do what you want, I have no idea how it 
> should be.
> 
> Interesting thing I saw there was some automatic on/off Tx logic, but 
> unfortunately it was enabled randomly.
> 
> Also keene_cmd_main() play parameter does not have any effect.

Can you replace mdelay(11) with msleep(20)? If that works, then I'll use
that. That's still very short but it is non-blocking and has more margin.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-05-29 Thread Antti Palosaari

On 05/29/2013 08:58 PM, Antti Palosaari wrote:

On 05/29/2013 05:26 PM, Hans Verkuil wrote:

On Fri April 19 2013 11:11:27 Antti Palosaari wrote:

On 04/19/2013 10:12 AM, Hans Verkuil wrote:

On Wed April 17 2013 21:45:24 Antti Palosaari wrote:

On 04/15/2013 09:55 AM, Hans Verkuil wrote:

On Fri April 12 2013 02:11:41 Antti Palosaari wrote:

Hello Hans,
That device is working very, thank you for it. Anyhow, I noticed
two things.

1) it does not start transmitting just after I plug it - I have to
retune it!
Output says it is tuned to 95.16 MHz by default, but it is not.
After I issue retune, just to same channel it starts working.
$ v4l2-ctl -d /dev/radio0 --set-freq=95.16


Can you try this patch:



It does not resolve the problem. It is quite strange behavior. After I
install modules, and modules are unload, plug stick in first time, it
usually (not every-time) starts TX. But when I replug it without
unloading modules, it will never start TX. Tx is started always when I
set freq using v4l2-ctl.


If you replace 'false' by 'true' in the cmd_main, does that make it
work?
I'm fairly certain that's the problem.


Nope, I replaces all 'false' with 'true' and problem remains. When
modules were unload and device is plugged it starts TX. When I replug it
doesn't start anymore.

I just added msleep(1000); just before keene_cmd_main() in .probe() and
now it seems to work every-time. So it is definitely timing issue. I
will try to find out some smallest suitable value for sleep and and sent
patch.


Have you had time to find a smaller msleep value?


Nope, but I will do it today (if I don't meet any problems when
upgrading to latest master).

regards
Antti



Attached patch gives some idea. Do what you want, I have no idea how it 
should be.


Interesting thing I saw there was some automatic on/off Tx logic, but 
unfortunately it was enabled randomly.


Also keene_cmd_main() play parameter does not have any effect.

regards
Antti


--
http://palosaari.fi/
>From 59257e5556a5ac4d19111e35001ced5b4d53b5c2 Mon Sep 17 00:00:00 2001
From: Antti Palosaari 
Date: Thu, 30 May 2013 02:45:47 +0300
Subject: [PATCH] Keene: start Tx by default

Signed-off-by: Antti Palosaari 
---
 drivers/media/radio/radio-keene.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/drivers/media/radio/radio-keene.c b/drivers/media/radio/radio-keene.c
index 4c9ae76..d710529 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -383,6 +383,20 @@ static int usb_keene_probe(struct usb_interface *intf,
 	video_set_drvdata(&radio->vdev, radio);
 	set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
 
+	/*
+	 * mdelay(11) needed in order to apply keene_cmd_main() command.
+	 * mdelay(10) is not enough, it works sometimes but usually not.
+	 *
+	 * keene_cmd_main() 3rd parameter (play) does not has any effect.
+	 * It starts Tx regardless of that parameter.
+	 *
+	 * Sometimes it enters mode where it stops Tx automatically after input
+	 * is silent 60 sec and also starts Tx automatically when there is
+	 * noise on input. It is not clear how to enable that...
+	 */
+	mdelay(11);
+	keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
+
 	retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
 	if (retval < 0) {
 		dev_err(&intf->dev, "could not register video device\n");
-- 
1.7.11.7



Re: Keene

2013-05-29 Thread Antti Palosaari

On 05/29/2013 05:26 PM, Hans Verkuil wrote:

On Fri April 19 2013 11:11:27 Antti Palosaari wrote:

On 04/19/2013 10:12 AM, Hans Verkuil wrote:

On Wed April 17 2013 21:45:24 Antti Palosaari wrote:

On 04/15/2013 09:55 AM, Hans Verkuil wrote:

On Fri April 12 2013 02:11:41 Antti Palosaari wrote:

Hello Hans,
That device is working very, thank you for it. Anyhow, I noticed two things.

1) it does not start transmitting just after I plug it - I have to
retune it!
Output says it is tuned to 95.16 MHz by default, but it is not.
After I issue retune, just to same channel it starts working.
$ v4l2-ctl -d /dev/radio0 --set-freq=95.16


Can you try this patch:



It does not resolve the problem. It is quite strange behavior. After I
install modules, and modules are unload, plug stick in first time, it
usually (not every-time) starts TX. But when I replug it without
unloading modules, it will never start TX. Tx is started always when I
set freq using v4l2-ctl.


If you replace 'false' by 'true' in the cmd_main, does that make it work?
I'm fairly certain that's the problem.


Nope, I replaces all 'false' with 'true' and problem remains. When
modules were unload and device is plugged it starts TX. When I replug it
doesn't start anymore.

I just added msleep(1000); just before keene_cmd_main() in .probe() and
now it seems to work every-time. So it is definitely timing issue. I
will try to find out some smallest suitable value for sleep and and sent
patch.


Have you had time to find a smaller msleep value?


Nope, but I will do it today (if I don't meet any problems when 
upgrading to latest master).


regards
Antti

--
http://palosaari.fi/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-05-29 Thread Hans Verkuil
On Fri April 19 2013 11:11:27 Antti Palosaari wrote:
> On 04/19/2013 10:12 AM, Hans Verkuil wrote:
> > On Wed April 17 2013 21:45:24 Antti Palosaari wrote:
> >> On 04/15/2013 09:55 AM, Hans Verkuil wrote:
> >>> On Fri April 12 2013 02:11:41 Antti Palosaari wrote:
>  Hello Hans,
>  That device is working very, thank you for it. Anyhow, I noticed two 
>  things.
> 
>  1) it does not start transmitting just after I plug it - I have to
>  retune it!
>  Output says it is tuned to 95.16 MHz by default, but it is not.
>  After I issue retune, just to same channel it starts working.
>  $ v4l2-ctl -d /dev/radio0 --set-freq=95.16
> >>>
> >>> Can you try this patch:
> >>>
> >>
> >> It does not resolve the problem. It is quite strange behavior. After I
> >> install modules, and modules are unload, plug stick in first time, it
> >> usually (not every-time) starts TX. But when I replug it without
> >> unloading modules, it will never start TX. Tx is started always when I
> >> set freq using v4l2-ctl.
> >
> > If you replace 'false' by 'true' in the cmd_main, does that make it work?
> > I'm fairly certain that's the problem.
> 
> Nope, I replaces all 'false' with 'true' and problem remains. When 
> modules were unload and device is plugged it starts TX. When I replug it 
> doesn't start anymore.
> 
> I just added msleep(1000); just before keene_cmd_main() in .probe() and 
> now it seems to work every-time. So it is definitely timing issue. I 
> will try to find out some smallest suitable value for sleep and and sent 
> patch.

Have you had time to find a smaller msleep value?

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-04-19 Thread Devin Heitmueller
On Fri, Apr 19, 2013 at 5:58 AM, Hans Verkuil  wrote:
> So perhaps this can be solved with two generic controls:
>
> bool CID_POWER_OFF_AT_LAST_CLOSE
> int CID_POWER_OFF_DELAY (unit: seconds)
>
> If POWER_OFF_AT_LAST_CLOSE is false, then you never power off. If it is true,
> then power off after a given delay. If the delay == 0 then power off 
> immediately.
>
> Drivers can decide on proper default values. But radio devices must start
> with CID_POWER_OFF_AT_LAST_CLOSE set to false for compatibility reasons.
>
> I don't have time for the next few weeks to investigate this further, so if
> you are interested...

Bear in mind that deferred shutdown opens a huge set of problems with
hybrid tuners.  We already have many, many race known conditions
related to closing V4L and then immediately opening the corresponding
DVB device (and closing DVB then immediately opening the V4L device).
Without a proper framework, a change such as this will exacerbate the
problem.

These race conditions typically result in completely undefined
behavior, as you either having both sides of the device powered up at
the same time, or you have the second half powered up and then
conflicting commands are received to power it down because of deferred
commands for the first half to go to sleep.

It's an absolute mess.

And please don't forget that this isn't just about a shared tuner chip
- it's about the state of video decoders and demodulators as well.
You cannot just introduce simple locking in tuner-core and hope that
resolves the problem.

Devin

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-04-19 Thread Hans Verkuil
Regards,

Hans

> Here is power consumption I measured:
> 26.5mA play=false (idle mode)
> 39.0mA Tx on 95.16 MHz
> 
> It wastes 12.5mA (from USB Vcc 5v) when Tx is enabled.
> 
> regards
> Antti
> 
> >
> > Regards,
> >
> > Hans
> >
> >>
> >>
> >> regards
> >> Antti
> >>
> >>
> >>
> >>
> >>
> >>
> >>> diff --git a/drivers/media/radio/radio-keene.c 
> >>> b/drivers/media/radio/radio-keene.c
> >>> index 4c9ae76..99da3d4 100644
> >>> --- a/drivers/media/radio/radio-keene.c
> >>> +++ b/drivers/media/radio/radio-keene.c
> >>> @@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
> >>> unsigned freq, bool play)
> >>>   /* If bit 4 is set, then tune to the frequency.
> >>>  If bit 3 is set, then unmute; if bit 2 is set, then mute.
> >>>  If bit 1 is set, then enter idle mode; if bit 0 is set,
> >>> -then enter transit mode.
> >>> +then enter transmit mode.
> >>>*/
> >>>   radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
> >>>   (freq ? 0x10 : 
> >>> 0);
> >>> @@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
> >>>   radio->pa = 118;
> >>>   radio->tx = 0x32;
> >>>   radio->stereo = true;
> >>> - radio->curfreq = 95.16 * FREQ_MUL;
> >>>   if (hdl->error) {
> >>>   retval = hdl->error;
> >>>
> >>> @@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
> >>>   video_set_drvdata(&radio->vdev, radio);
> >>>   set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
> >>>
> >>> + keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
> >>> +
> >>>   retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, 
> >>> -1);
> >>>   if (retval < 0) {
> >>>   dev_err(&intf->dev, "could not register video 
> >>> device\n");
> >>>
> >>>
> >>>> 2) What is that log printing?
> >>>> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
> >>>> (id 13)
> >>>>
> >>>>
> >>>> usb 5-2: new full-speed USB device number 3 using ohci_hcd
> >>>> usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
> >>>> usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
> >>>> usb 5-2: Product: B-LINK USB Audio
> >>>> usb 5-2: Manufacturer: HOLTEK
> >>>> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
> >>>> (id 13)
> >>>> radio-keene 5-2:1.2: V4L2 device registered as radio0
> >>>
> >>> No idea, and I don't get that message either.
> >>>
> >>> Regards,
> >>>
> >>>   Hans
> >>>
> >>>>
> >>>>
> >>>> $ v4l2-ctl -d /dev/radio0 --all -L
> >>>> Driver Info (not using libv4l2):
> >>>>  Driver name   : radio-keene
> >>>>  Card type : Keene FM Transmitter
> >>>>  Bus info  : usb-:00:13.0-2
> >>>>  Driver version: 3.9.0
> >>>>  Capabilities  : 0x800C
> >>>>  Modulator
> >>>>  Radio
> >>>> Frequency: 1522560 (95.16 MHz)
> >>>> Modulator:
> >>>>  Name : FM
> >>>>  Capabilities : 62.5 Hz stereo
> >>>>  Frequency range  : 76.0 MHz - 108.0 MHz
> >>>>  Subchannel modulation: stereo
> >>>> Priority: 2
> >>>>
> >>>> User Controls
> >>>>
> >>>>   mute (bool)   : default=0 value=0
> >>>>
> >>>> FM Radio Modulator Controls
> >>>>
> >>>> audio_compression_gain (int): min=-15 max=18 step=3
> >>>> default=0 value=0 flags=slider
> >>>>   pre_emphasis (menu)   : min=0 max=2 default=1 
> >>>> value=1
> >>>>  1: 50 Microseconds
> >>>>  2: 75 Microseconds
> >>>>   tune_power_level (int): min=84 max=118 step=1
> >>>> default=118 value=118 flags=slider
> >>>>
> >>>>
> >>>> regards
> >>>> Antti
> >>>>
> >>>>
> >>
> >>
> >>
> 
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-04-19 Thread Antti Palosaari

On 04/19/2013 10:12 AM, Hans Verkuil wrote:

On Wed April 17 2013 21:45:24 Antti Palosaari wrote:

On 04/15/2013 09:55 AM, Hans Verkuil wrote:

On Fri April 12 2013 02:11:41 Antti Palosaari wrote:

Hello Hans,
That device is working very, thank you for it. Anyhow, I noticed two things.

1) it does not start transmitting just after I plug it - I have to
retune it!
Output says it is tuned to 95.16 MHz by default, but it is not.
After I issue retune, just to same channel it starts working.
$ v4l2-ctl -d /dev/radio0 --set-freq=95.16


Can you try this patch:



It does not resolve the problem. It is quite strange behavior. After I
install modules, and modules are unload, plug stick in first time, it
usually (not every-time) starts TX. But when I replug it without
unloading modules, it will never start TX. Tx is started always when I
set freq using v4l2-ctl.


If you replace 'false' by 'true' in the cmd_main, does that make it work?
I'm fairly certain that's the problem.


Nope, I replaces all 'false' with 'true' and problem remains. When 
modules were unload and device is plugged it starts TX. When I replug it 
doesn't start anymore.


I just added msleep(1000); just before keene_cmd_main() in .probe() and 
now it seems to work every-time. So it is definitely timing issue. I 
will try to find out some smallest suitable value for sleep and and sent 
patch.







Possible timing issue?


Is there some flag API flag to tell start / stop device? For my mind
correct behavior is to stop TX and sleep when device is plugged/module
load. Something like set freq 0 when device is not active to tell user
it is not sending/receiving and must be tuned in order to operate.


This is actually a core problem with the radio API: there is no clear
way of turning the tuner or modulator on and off on command. With video
you know that you can turn off the tuner if no filehandle is open. But
with radio you do not have that luxury since audio can go through alsa
or through an audio jack.

One option is to use mute. Most radio receivers start off muted and you
have to unmute first. This could be used as a signal for receivers to
turn the tuner on/off. But for a modulator that's not an option: turning
off the modulator means turning off the transmitter, and that's not what
you want if you are, say, the presenter of a radio program and you want
to quickly mute because you feel a sneeze coming :-)

I think we need a specific API for this, but in the absence of one we should
just leave the modulator enabled from the start.


yeah, that's just the issue I was wondering. Is there some reason 
frequency value could not be used? Defining frequency to 0MHz or -1MHz 
and Tx (maybe Rx too) is off?


Here is power consumption I measured:
26.5mA play=false (idle mode)
39.0mA Tx on 95.16 MHz

It wastes 12.5mA (from USB Vcc 5v) when Tx is enabled.

regards
Antti



Regards,

Hans




regards
Antti







diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 4c9ae76..99da3d4 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
unsigned freq, bool play)
/* If bit 4 is set, then tune to the frequency.
   If bit 3 is set, then unmute; if bit 2 is set, then mute.
   If bit 1 is set, then enter idle mode; if bit 0 is set,
-  then enter transit mode.
+  then enter transmit mode.
 */
radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
(freq ? 0x10 : 0);
@@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
radio->pa = 118;
radio->tx = 0x32;
radio->stereo = true;
-   radio->curfreq = 95.16 * FREQ_MUL;
if (hdl->error) {
retval = hdl->error;

@@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
video_set_drvdata(&radio->vdev, radio);
set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);

+   keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
+
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n");



2) What is that log printing?
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
(id 13)


usb 5-2: new full-speed USB device number 3 using ohci_hcd
usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 5-2: Product: B-LINK USB Audio
usb 5-2: Manufacturer: HOLTEK
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
(id 13)
radio-keene 5-2:1.2: V4L2 device registered as radio0


No idea, and I don't get that m

Re: Keene

2013-04-19 Thread Hans Verkuil
On Wed April 17 2013 21:45:24 Antti Palosaari wrote:
> On 04/15/2013 09:55 AM, Hans Verkuil wrote:
> > On Fri April 12 2013 02:11:41 Antti Palosaari wrote:
> >> Hello Hans,
> >> That device is working very, thank you for it. Anyhow, I noticed two 
> >> things.
> >>
> >> 1) it does not start transmitting just after I plug it - I have to
> >> retune it!
> >> Output says it is tuned to 95.16 MHz by default, but it is not.
> >> After I issue retune, just to same channel it starts working.
> >> $ v4l2-ctl -d /dev/radio0 --set-freq=95.16
> >
> > Can you try this patch:
> >
> 
> It does not resolve the problem. It is quite strange behavior. After I 
> install modules, and modules are unload, plug stick in first time, it 
> usually (not every-time) starts TX. But when I replug it without 
> unloading modules, it will never start TX. Tx is started always when I 
> set freq using v4l2-ctl.

If you replace 'false' by 'true' in the cmd_main, does that make it work?
I'm fairly certain that's the problem.

> 
> Possible timing issue?
> 
> 
> Is there some flag API flag to tell start / stop device? For my mind 
> correct behavior is to stop TX and sleep when device is plugged/module 
> load. Something like set freq 0 when device is not active to tell user 
> it is not sending/receiving and must be tuned in order to operate.

This is actually a core problem with the radio API: there is no clear
way of turning the tuner or modulator on and off on command. With video
you know that you can turn off the tuner if no filehandle is open. But
with radio you do not have that luxury since audio can go through alsa
or through an audio jack.

One option is to use mute. Most radio receivers start off muted and you
have to unmute first. This could be used as a signal for receivers to
turn the tuner on/off. But for a modulator that's not an option: turning
off the modulator means turning off the transmitter, and that's not what
you want if you are, say, the presenter of a radio program and you want
to quickly mute because you feel a sneeze coming :-)

I think we need a specific API for this, but in the absence of one we should
just leave the modulator enabled from the start.

Regards,

Hans

> 
> 
> regards
> Antti
> 
> 
> 
> 
> 
> 
> > diff --git a/drivers/media/radio/radio-keene.c 
> > b/drivers/media/radio/radio-keene.c
> > index 4c9ae76..99da3d4 100644
> > --- a/drivers/media/radio/radio-keene.c
> > +++ b/drivers/media/radio/radio-keene.c
> > @@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
> > unsigned freq, bool play)
> > /* If bit 4 is set, then tune to the frequency.
> >If bit 3 is set, then unmute; if bit 2 is set, then mute.
> >If bit 1 is set, then enter idle mode; if bit 0 is set,
> > -  then enter transit mode.
> > +  then enter transmit mode.
> >  */
> > radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
> > (freq ? 0x10 : 0);
> > @@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
> > radio->pa = 118;
> > radio->tx = 0x32;
> > radio->stereo = true;
> > -   radio->curfreq = 95.16 * FREQ_MUL;
> > if (hdl->error) {
> > retval = hdl->error;
> >
> > @@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
> > video_set_drvdata(&radio->vdev, radio);
> > set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
> >
> > +   keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
> > +
> > retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
> > if (retval < 0) {
> > dev_err(&intf->dev, "could not register video device\n");
> >
> >
> >> 2) What is that log printing?
> >> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
> >> (id 13)
> >>
> >>
> >> usb 5-2: new full-speed USB device number 3 using ohci_hcd
> >> usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
> >> usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
> >> usb 5-2: Product: B-LINK USB Audio
> >> usb 5-2: Manufacturer: HOLTEK
> >> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
> >> (id 13)
> >> radio-keene 5-2:1.2: V4L2 device registered as radio0
> >
> > No idea, and I don't get that message either.
> >
> > Regards,
> >
> > Han

Re: Keene

2013-04-17 Thread Antti Palosaari

On 04/15/2013 09:55 AM, Hans Verkuil wrote:

On Fri April 12 2013 02:11:41 Antti Palosaari wrote:

Hello Hans,
That device is working very, thank you for it. Anyhow, I noticed two things.

1) it does not start transmitting just after I plug it - I have to
retune it!
Output says it is tuned to 95.16 MHz by default, but it is not.
After I issue retune, just to same channel it starts working.
$ v4l2-ctl -d /dev/radio0 --set-freq=95.16


Can you try this patch:



It does not resolve the problem. It is quite strange behavior. After I 
install modules, and modules are unload, plug stick in first time, it 
usually (not every-time) starts TX. But when I replug it without 
unloading modules, it will never start TX. Tx is started always when I 
set freq using v4l2-ctl.


Possible timing issue?


Is there some flag API flag to tell start / stop device? For my mind 
correct behavior is to stop TX and sleep when device is plugged/module 
load. Something like set freq 0 when device is not active to tell user 
it is not sending/receiving and must be tuned in order to operate.



regards
Antti







diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 4c9ae76..99da3d4 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
unsigned freq, bool play)
/* If bit 4 is set, then tune to the frequency.
   If bit 3 is set, then unmute; if bit 2 is set, then mute.
   If bit 1 is set, then enter idle mode; if bit 0 is set,
-  then enter transit mode.
+  then enter transmit mode.
 */
radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
(freq ? 0x10 : 0);
@@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
radio->pa = 118;
radio->tx = 0x32;
radio->stereo = true;
-   radio->curfreq = 95.16 * FREQ_MUL;
if (hdl->error) {
retval = hdl->error;

@@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
video_set_drvdata(&radio->vdev, radio);
set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);

+   keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
+
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n");



2) What is that log printing?
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
(id 13)


usb 5-2: new full-speed USB device number 3 using ohci_hcd
usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 5-2: Product: B-LINK USB Audio
usb 5-2: Manufacturer: HOLTEK
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2
(id 13)
radio-keene 5-2:1.2: V4L2 device registered as radio0


No idea, and I don't get that message either.

Regards,

Hans




$ v4l2-ctl -d /dev/radio0 --all -L
Driver Info (not using libv4l2):
Driver name   : radio-keene
Card type : Keene FM Transmitter
Bus info  : usb-:00:13.0-2
Driver version: 3.9.0
Capabilities  : 0x800C
Modulator
Radio
Frequency: 1522560 (95.16 MHz)
Modulator:
Name : FM
Capabilities : 62.5 Hz stereo
Frequency range  : 76.0 MHz - 108.0 MHz
Subchannel modulation: stereo
Priority: 2

User Controls

 mute (bool)   : default=0 value=0

FM Radio Modulator Controls

   audio_compression_gain (int): min=-15 max=18 step=3
default=0 value=0 flags=slider
 pre_emphasis (menu)   : min=0 max=2 default=1 value=1
1: 50 Microseconds
2: 75 Microseconds
 tune_power_level (int): min=84 max=118 step=1
default=118 value=118 flags=slider


regards
Antti





--
http://palosaari.fi/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Keene

2013-04-14 Thread Hans Verkuil
On Fri April 12 2013 02:11:41 Antti Palosaari wrote:
> Hello Hans,
> That device is working very, thank you for it. Anyhow, I noticed two things.
> 
> 1) it does not start transmitting just after I plug it - I have to 
> retune it!
> Output says it is tuned to 95.16 MHz by default, but it is not. 
> After I issue retune, just to same channel it starts working.
> $ v4l2-ctl -d /dev/radio0 --set-freq=95.16

Can you try this patch:

diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
index 4c9ae76..99da3d4 100644
--- a/drivers/media/radio/radio-keene.c
+++ b/drivers/media/radio/radio-keene.c
@@ -93,7 +93,7 @@ static int keene_cmd_main(struct keene_device *radio, 
unsigned freq, bool play)
/* If bit 4 is set, then tune to the frequency.
   If bit 3 is set, then unmute; if bit 2 is set, then mute.
   If bit 1 is set, then enter idle mode; if bit 0 is set,
-  then enter transit mode.
+  then enter transmit mode.
 */
radio->buffer[5] = (radio->muted ? 4 : 8) | (play ? 1 : 2) |
(freq ? 0x10 : 0);
@@ -350,7 +350,6 @@ static int usb_keene_probe(struct usb_interface *intf,
radio->pa = 118;
radio->tx = 0x32;
radio->stereo = true;
-   radio->curfreq = 95.16 * FREQ_MUL;
if (hdl->error) {
retval = hdl->error;
 
@@ -383,6 +382,8 @@ static int usb_keene_probe(struct usb_interface *intf,
video_set_drvdata(&radio->vdev, radio);
set_bit(V4L2_FL_USE_FH_PRIO, &radio->vdev.flags);
 
+   keene_cmd_main(radio, 95.16 * FREQ_MUL, false);
+
retval = video_register_device(&radio->vdev, VFL_TYPE_RADIO, -1);
if (retval < 0) {
dev_err(&intf->dev, "could not register video device\n");


> 2) What is that log printing?
> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2 
> (id 13)
> 
> 
> usb 5-2: new full-speed USB device number 3 using ohci_hcd
> usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
> usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
> usb 5-2: Product: B-LINK USB Audio
> usb 5-2: Manufacturer: HOLTEK
> ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2 
> (id 13)
> radio-keene 5-2:1.2: V4L2 device registered as radio0

No idea, and I don't get that message either.

Regards,

Hans

> 
> 
> $ v4l2-ctl -d /dev/radio0 --all -L
> Driver Info (not using libv4l2):
>   Driver name   : radio-keene
>   Card type : Keene FM Transmitter
>   Bus info  : usb-:00:13.0-2
>   Driver version: 3.9.0
>   Capabilities  : 0x800C
>   Modulator
>   Radio
> Frequency: 1522560 (95.16 MHz)
> Modulator:
>   Name : FM
>   Capabilities : 62.5 Hz stereo
>   Frequency range  : 76.0 MHz - 108.0 MHz
>   Subchannel modulation: stereo
> Priority: 2
> 
> User Controls
> 
> mute (bool)   : default=0 value=0
> 
> FM Radio Modulator Controls
> 
>   audio_compression_gain (int): min=-15 max=18 step=3 
> default=0 value=0 flags=slider
> pre_emphasis (menu)   : min=0 max=2 default=1 value=1
>   1: 50 Microseconds
>   2: 75 Microseconds
> tune_power_level (int): min=84 max=118 step=1 
> default=118 value=118 flags=slider
> 
> 
> regards
> Antti
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Keene

2013-04-11 Thread Antti Palosaari

Hello Hans,
That device is working very, thank you for it. Anyhow, I noticed two things.

1) it does not start transmitting just after I plug it - I have to 
retune it!
Output says it is tuned to 95.16 MHz by default, but it is not. 
After I issue retune, just to same channel it starts working.

$ v4l2-ctl -d /dev/radio0 --set-freq=95.16

2) What is that log printing?
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2 
(id 13)



usb 5-2: new full-speed USB device number 3 using ohci_hcd
usb 5-2: New USB device found, idVendor=046d, idProduct=0a0e
usb 5-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 5-2: Product: B-LINK USB Audio
usb 5-2: Manufacturer: HOLTEK
ALSA sound/usb/mixer.c:932 13:0: cannot get min/max values for control 2 
(id 13)

radio-keene 5-2:1.2: V4L2 device registered as radio0


$ v4l2-ctl -d /dev/radio0 --all -L
Driver Info (not using libv4l2):
Driver name   : radio-keene
Card type : Keene FM Transmitter
Bus info  : usb-:00:13.0-2
Driver version: 3.9.0
Capabilities  : 0x800C
Modulator
Radio
Frequency: 1522560 (95.16 MHz)
Modulator:
Name : FM
Capabilities : 62.5 Hz stereo
Frequency range  : 76.0 MHz - 108.0 MHz
Subchannel modulation: stereo
Priority: 2

User Controls

   mute (bool)   : default=0 value=0

FM Radio Modulator Controls

 audio_compression_gain (int): min=-15 max=18 step=3 
default=0 value=0 flags=slider

   pre_emphasis (menu)   : min=0 max=2 default=1 value=1
1: 50 Microseconds
2: 75 Microseconds
   tune_power_level (int): min=84 max=118 step=1 
default=118 value=118 flags=slider



regards
Antti

--
http://palosaari.fi/
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/15] MAINTAINERS: add radio-keene entry.

2012-11-23 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 MAINTAINERS |8 
 1 file changed, 8 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5d5462d..95f1181 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -4275,6 +4275,14 @@ W:   http://lse.sourceforge.net/kdump/
 S: Maintained
 F: Documentation/kdump/
 
+KEENE FM RADIO TRANSMITTER DRIVER
+M: Hans Verkuil 
+L: linux-media@vger.kernel.org
+T: git git://linuxtv.org/media_tree.git
+W: http://linuxtv.org
+S: Maintained
+F: drivers/media/radio/radio-keene*
+
 KERNEL AUTOMOUNTER v4 (AUTOFS4)
 M: Ian Kent 
 L: aut...@vger.kernel.org
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL FOR v3.5] An ivtv fix and support suspend/resume in radio-keene

2012-04-29 Thread Andy Walls
On Fri, 2012-04-27 at 13:56 +0200, Hans Verkuil wrote:
> Hi Mauro,
> 
> One small trivial ivtv fix and a patch that adds support for suspend/resume
> to the radio-keene driver.
> 
> Regards,
> 
>   Hans
> 
> The following changes since commit bcb2cf6e0bf033d79821c89e5ccb328bfbd44907:
> 
>   [media] ngene: remove an unneeded condition (2012-04-26 15:29:23 -0300)
> 
> are available in the git repository at:
> 
>   git://linuxtv.org/hverkuil/media_tree.git fixes
> 
> for you to fetch changes up to 71ea18d3e92d834926751f8460cf6893424b3852:
> 
>   radio-keene: support suspend/resume. (2012-04-27 09:57:02 +0200)
> 
> 
> Hans Verkuil (2):
>   ivtv: set max/step to 0 for PTS and FRAME controls.
>   radio-keene: support suspend/resume.

The ivtv change looks OK to me.  Even though v4l2_ctrl_fill() fixes up
those errors anyway.

Reviewed-by: Andy Walls 

Regards,
Andy 

> 
>  drivers/media/radio/radio-keene.c  |   20 
>  drivers/media/video/ivtv/ivtv-driver.c |4 ++--
>  2 files changed, 22 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [GIT PULL FOR v3.5] An ivtv fix and support suspend/resume in radio-keene

2012-04-28 Thread Hans Verkuil
Hi Mauro,

One other fix was added:

  radio-isa: fix memory leak

 drivers/media/radio/radio-isa.c|8 +++-

v4l2_ctrl_handler_free wasn't called if there was a problem creating controls.

Regards,

Hans

On Friday, April 27, 2012 13:56:37 Hans Verkuil wrote:
> Hi Mauro,
> 
> One small trivial ivtv fix and a patch that adds support for suspend/resume
> to the radio-keene driver.
> 
> Regards,
> 
>   Hans
> 
> The following changes since commit bcb2cf6e0bf033d79821c89e5ccb328bfbd44907:
> 
>   [media] ngene: remove an unneeded condition (2012-04-26 15:29:23 -0300)
> 
> are available in the git repository at:
> 
>   git://linuxtv.org/hverkuil/media_tree.git fixes
> 
> for you to fetch changes up to 71ea18d3e92d834926751f8460cf6893424b3852:
> 
>   radio-keene: support suspend/resume. (2012-04-27 09:57:02 +0200)
> 
> 
> Hans Verkuil (2):
>   ivtv: set max/step to 0 for PTS and FRAME controls.
>   radio-keene: support suspend/resume.
> 
>  drivers/media/radio/radio-keene.c  |   20 
>  drivers/media/video/ivtv/ivtv-driver.c |4 ++--
>  2 files changed, 22 insertions(+), 2 deletions(-)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[GIT PULL FOR v3.5] An ivtv fix and support suspend/resume in radio-keene

2012-04-27 Thread Hans Verkuil
Hi Mauro,

One small trivial ivtv fix and a patch that adds support for suspend/resume
to the radio-keene driver.

Regards,

Hans

The following changes since commit bcb2cf6e0bf033d79821c89e5ccb328bfbd44907:

  [media] ngene: remove an unneeded condition (2012-04-26 15:29:23 -0300)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git fixes

for you to fetch changes up to 71ea18d3e92d834926751f8460cf6893424b3852:

  radio-keene: support suspend/resume. (2012-04-27 09:57:02 +0200)


Hans Verkuil (2):
  ivtv: set max/step to 0 for PTS and FRAME controls.
  radio-keene: support suspend/resume.

 drivers/media/radio/radio-keene.c  |   20 
 drivers/media/video/ivtv/ivtv-driver.c |4 ++--
 2 files changed, 22 insertions(+), 2 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 6/6] hid-core: ignore the Keene FM transmitter.

2012-02-02 Thread Jiri Kosina
On Thu, 2 Feb 2012, Hans Verkuil wrote:

> From: Hans Verkuil 
> 
> The Keene FM transmitter USB device has the same USB ID as
> the Logitech AudioHub Speaker, but it should ignore the hid.
> Check if the name is that of the Keene device.
> 
> Signed-off-by: Hans Verkuil 

Mauro, feel free to take this one with the rest of the patchset with my

Signed-off-by: Jiri Kosina 

Thanks,

-- 
Jiri Kosina
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] hid-core: ignore the Keene FM transmitter.

2012-02-02 Thread Hans Verkuil
From: Hans Verkuil 

The Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker, but it should ignore the hid.
Check if the name is that of the Keene device.

Signed-off-by: Hans Verkuil 
---
 drivers/hid/hid-core.c |   10 ++
 drivers/hid/hid-ids.h  |1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index af08ce7..dd1bab4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1993,6 +1993,16 @@ static bool hid_ignore(struct hid_device *hdev)
if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
hdev->product <= 
USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
return true;
+   /*
+    * The Keene FM transmitter USB device has the same USB ID as
+* the Logitech AudioHub Speaker, but it should ignore the hid.
+* Check if the name is that of the Keene device.
+* For reference: the name of the AudioHub is
+* "HOLTEK  AudioHub Speaker".
+*/
+   if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
+   !strcmp(hdev->name, "HOLTEK  B-LINK USB Audio  "))
+   return true;
break;
case USB_VENDOR_ID_SOUNDGRAPH:
if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index b8574cd..e1c4535 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -451,6 +451,7 @@
 #define USB_DEVICE_ID_LG_MULTITOUCH0x0064
 
 #define USB_VENDOR_ID_LOGITECH 0x046d
+#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
 #define USB_DEVICE_ID_LOGITECH_RECEIVER0xc101
 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST  0xc110
 #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
-- 
1.7.8.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] radio-keene: add a driver for the Keene FM Transmitter.

2012-02-02 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/radio/Kconfig   |   10 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/radio-keene.c |  427 +
 3 files changed, 438 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/radio-keene.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index e954781..48747df 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -80,6 +80,16 @@ config RADIO_SI4713
  To compile this driver as a module, choose M here: the
  module will be called radio-si4713.
 
+config USB_KEENE
+   tristate "Keene FM Transmitter USB support"
+   depends on USB && VIDEO_V4L2
+   ---help---
+ Say Y here if you want to connect this type of FM transmitter
+ to your computer's USB port.
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-keene.
+
 config RADIO_TEA5764
tristate "TEA5764 I2C FM radio support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 390daf9..aec5f6f 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
 obj-$(CONFIG_USB_DSBR) += dsbr100.o
 obj-$(CONFIG_RADIO_SI470X) += si470x/
 obj-$(CONFIG_USB_MR800) += radio-mr800.o
+obj-$(CONFIG_USB_KEENE) += radio-keene.o
 obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
new file mode 100644
index 000..55bd1d2
--- /dev/null
+++ b/drivers/media/radio/radio-keene.c
@@ -0,0 +1,427 @@
+/*
+ * Copyright (c) 2012 Hans Verkuil 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* kernel includes */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* driver and module definitions */
+MODULE_AUTHOR("Hans Verkuil ");
+MODULE_DESCRIPTION("Keene FM Transmitter driver");
+MODULE_LICENSE("GPL");
+
+/* Actually, it advertises itself as a Logitech */
+#define USB_KEENE_VENDOR 0x046d
+#define USB_KEENE_PRODUCT 0x0a0e
+
+/* Probably USB_TIMEOUT should be modified in module parameter */
+#define BUFFER_LENGTH 8
+#define USB_TIMEOUT 500
+
+/* Frequency limits in MHz */
+#define FREQ_MIN  76U
+#define FREQ_MAX 108U
+#define FREQ_MUL 16000U
+
+/* USB Device ID List */
+static struct usb_device_id usb_keene_device_table[] = {
+   {USB_DEVICE_AND_INTERFACE_INFO(USB_KEENE_VENDOR, USB_KEENE_PRODUCT,
+   USB_CLASS_HID, 0, 0) },
+   { } /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, usb_keene_device_table);
+
+struct keene_device {
+   struct usb_device *usbdev;
+   struct usb_interface *intf;
+   struct video_device vdev;
+   struct v4l2_device v4l2_dev;
+   struct v4l2_ctrl_handler hdl;
+   struct mutex lock;
+
+   u8 *buffer;
+   unsigned curfreq;
+   u8 tx;
+   u8 pa;
+   bool stereo;
+   bool muted;
+   bool preemph_75_us;
+};
+
+static inline struct keene_device *to_keene_dev(struct v4l2_device *v4l2_dev)
+{
+   return container_of(v4l2_dev, struct keene_device, v4l2_dev);
+}
+
+/* Set frequency (if non-0), PA, mute and turn on/off the FM transmitter. */
+static int keene_cmd_main(struct keene_device *radio, unsigned freq, bool play)
+{
+   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
+   int ret;
+
+   radio->buffer[0] = 0x00;
+   radio->buffer[1] = 0x50;
+   radio->buffer[2] = (freq_send >> 8) & 0xff;
+   radio->buffer[3] = freq_send & 0xff;
+   radio->buffer[4] = radio->pa;
+   /* If bit 4 is set, then tune to the frequency.
+  If bit 3 is set, then unmute; if bit 2 is set, then mute.
+  If bit 1 is set, then enter idle mode; if bit 0 is set,
+ 

[PATCH 0/6] Add support functions and the radio-keene driver

2012-02-02 Thread Hans Verkuil
This patch series is for 3.4. It adds a V4L2 driver for the Keene USB FM
Transmitter:

http://www.amazon.co.uk/Keene-Electronics-USB-FM-Transmitter/dp/B003GCHPDY

This device is very useful to test V4L2 FM radio receivers.

Changes since RFCv2 of the radio-keene driver:

- Use the new v4l2 support functions.
- Fix a QUERYCAP compliancy issue for 3.4.

The first four add some v4l2 support functions that are used by the
radio-keene driver in the fifth patch (and upcoming driver improvements
in the near future).

Note that the Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker. Since the radio-keene driver needs to
hijack the HID something needed to be done to differentiate the two.

So hid-core was modified to decide this based on the product name.

I have tested that this works with both a Keene device and a Logitech
AudioHub device hooked up at the same time.

Jiri is OK with it as well. This sixth patch is independent from the
other five and can be merged either through linux-media (makes the most
sense to me) or through linux-input. I leave that up to Mauro and Jiri.

This patch series is also available in my git tree:

The following changes since commit 59b30294e14fa6a370fdd2bc2921cca1f977ef16:

  Merge branch 'v4l_for_linus' into staging/for_v3.4 (2012-01-23 18:11:30 -0200)

are available in the git repository at:

  git://linuxtv.org/hverkuil/media_tree.git keene

Hans Verkuil (6):
  v4l2: standardize log start/end message.
  v4l2-subdev: add start/end messages for log_status.
  v4l2-ctrls: add helper functions for control events.
  vivi: use v4l2_ctrl_subscribe_event.
  radio-keene: add a driver for the Keene FM Transmitter.
  hid-core: ignore the Keene FM transmitter.

 drivers/hid/hid-core.c|   10 +
 drivers/hid/hid-ids.h |1 +
 drivers/media/radio/Kconfig   |   10 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/radio-keene.c |  427 +
 drivers/media/video/bt8xx/bttv-driver.c   |4 -
 drivers/media/video/cx18/cx18-ioctl.c |4 -
 drivers/media/video/ivtv/ivtv-ioctl.c |5 -
 drivers/media/video/pwc/pwc-v4l.c |   10 +-
 drivers/media/video/saa7164/saa7164-encoder.c |6 -
 drivers/media/video/saa7164/saa7164-vbi.c |6 - 
  
 drivers/media/video/v4l2-ctrls.c  |   32 ++
  
 drivers/media/video/v4l2-ioctl.c  |6 + 
  
 drivers/media/video/v4l2-subdev.c |   12 +-
  
 drivers/media/video/vivi.c|   23 +--   
  
 include/media/v4l2-ctrls.h|   13 + 
  
 16 files changed, 513 insertions(+), 57 deletions(-)   
  
 create mode 100644 drivers/media/radio/radio-keene.c 

Regards,

Hans

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 1/2] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-22 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/radio/Kconfig   |   10 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/radio-keene.c |  437 +
 3 files changed, 448 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/radio-keene.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index e954781..48747df 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -80,6 +80,16 @@ config RADIO_SI4713
  To compile this driver as a module, choose M here: the
  module will be called radio-si4713.
 
+config USB_KEENE
+   tristate "Keene FM Transmitter USB support"
+   depends on USB && VIDEO_V4L2
+   ---help---
+ Say Y here if you want to connect this type of FM transmitter
+ to your computer's USB port.
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-keene.
+
 config RADIO_TEA5764
tristate "TEA5764 I2C FM radio support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 390daf9..aec5f6f 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
 obj-$(CONFIG_USB_DSBR) += dsbr100.o
 obj-$(CONFIG_RADIO_SI470X) += si470x/
 obj-$(CONFIG_USB_MR800) += radio-mr800.o
+obj-$(CONFIG_USB_KEENE) += radio-keene.o
 obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
new file mode 100644
index 000..32d0a2a
--- /dev/null
+++ b/drivers/media/radio/radio-keene.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright (c) 2012 Hans Verkuil 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* kernel includes */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* driver and module definitions */
+MODULE_AUTHOR("Hans Verkuil ");
+MODULE_DESCRIPTION("Keene FM Transmitter driver");
+MODULE_LICENSE("GPL");
+
+/* Actually, it advertises itself as a Logitech */
+#define USB_KEENE_VENDOR 0x046d
+#define USB_KEENE_PRODUCT 0x0a0e
+
+/* Probably USB_TIMEOUT should be modified in module parameter */
+#define BUFFER_LENGTH 8
+#define USB_TIMEOUT 500
+
+/* Frequency limits in MHz */
+#define FREQ_MIN  76U
+#define FREQ_MAX 108U
+#define FREQ_MUL 16000U
+
+/* USB Device ID List */
+static struct usb_device_id usb_keene_device_table[] = {
+   {USB_DEVICE_AND_INTERFACE_INFO(USB_KEENE_VENDOR, USB_KEENE_PRODUCT,
+   USB_CLASS_HID, 0, 0) },
+   { } /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, usb_keene_device_table);
+
+struct keene_device {
+   struct usb_device *usbdev;
+   struct usb_interface *intf;
+   struct video_device vdev;
+   struct v4l2_device v4l2_dev;
+   struct v4l2_ctrl_handler hdl;
+   struct mutex lock;
+
+   u8 *buffer;
+   unsigned curfreq;
+   u8 tx;
+   u8 pa;
+   bool stereo;
+   bool muted;
+   bool preemph_75_us;
+};
+
+static inline struct keene_device *to_keene_dev(struct v4l2_device *v4l2_dev)
+{
+   return container_of(v4l2_dev, struct keene_device, v4l2_dev);
+}
+
+/* Set frequency (if non-0), PA, mute and turn on/off the FM transmitter. */
+static int keene_cmd_main(struct keene_device *radio, unsigned freq, bool play)
+{
+   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
+   int ret;
+
+   radio->buffer[0] = 0x00;
+   radio->buffer[1] = 0x50;
+   radio->buffer[2] = (freq_send >> 8) & 0xff;
+   radio->buffer[3] = freq_send & 0xff;
+   radio->buffer[4] = radio->pa;
+   /* If bit 4 is set, then tune to the frequency.
+  If bit 3 is set, then unmute; if bit 2 is set, then mute.
+  If bit 1 is set, then enter idle mode; if bit 0 is set,
+ 

[RFCv2 PATCH 0/2] New driver for the Keene USB FM Transmitter

2012-01-22 Thread Hans Verkuil
Hi all,

Here is a V4L2 driver for the Keene USB FM Transmitter:

http://www.amazon.co.uk/Keene-Electronics-USB-FM-Transmitter/dp/B003GCHPDY

Changes from v1:

Incorporated comments from Oliver Neukum:

- Use kmalloc to allocate the DMA buffer
- Check the product name in the keene driver as well in case it is loaded
  before the usbhid driver.

It's been very useful to test V4L2 FM radio receivers.

Note that the Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker. Since the radio-keene driver needs to
hijack the HID something needed to be done to differentiate the two.

So hid-core was modified to decide this based on the product name.

I have tested that this works with both a Keene device and a Logitech
AudioHub device hooked up at the same time.

Jiri, can you look at the last patch and let me know if it is OK
from a HID point of view? If there are no more comments then I'd like
to have it merged in the linux-media tree for v3.4 by the end of the week,
but I need you Ack for the hid-core patch in order to do that.

Regards,

Hans

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFCv2 PATCH 2/2] hid-core: ignore the Keene FM transmitter.

2012-01-22 Thread Hans Verkuil
From: Hans Verkuil 

The Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker, but it should ignore the hid.
Check if the name is that of the Keene device.

Signed-off-by: Hans Verkuil 
---
 drivers/hid/hid-core.c |   10 ++
 drivers/hid/hid-ids.h  |1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index af08ce7..dd1bab4 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1993,6 +1993,16 @@ static bool hid_ignore(struct hid_device *hdev)
if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
hdev->product <= 
USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
return true;
+   /*
+    * The Keene FM transmitter USB device has the same USB ID as
+* the Logitech AudioHub Speaker, but it should ignore the hid.
+* Check if the name is that of the Keene device.
+* For reference: the name of the AudioHub is
+* "HOLTEK  AudioHub Speaker".
+*/
+   if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
+   !strcmp(hdev->name, "HOLTEK  B-LINK USB Audio  "))
+   return true;
break;
case USB_VENDOR_ID_SOUNDGRAPH:
if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index b8574cd..e1c4535 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -451,6 +451,7 @@
 #define USB_DEVICE_ID_LG_MULTITOUCH0x0064
 
 #define USB_VENDOR_ID_LOGITECH 0x046d
+#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
 #define USB_DEVICE_ID_LOGITECH_RECEIVER0xc101
 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST  0xc110
 #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Alan Cox
On Mon, 16 Jan 2012 14:11:20 +0100
Oliver Neukum  wrote:

> Am Montag, 16. Januar 2012, 14:02:05 schrieb Hans Verkuil:
> > > > +/* Set frequency (if non-0), PA, mute and turn on/off the FM
> > > > transmitter. */ +static int keene_cmd_main(struct keene_device *radio,
> > > > unsigned freq, bool play) +{
> > > > +   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
> > > > +   int ret;
> > > > +
> > > > +   radio->buffer[0] = 0x00;
> > > > +   radio->buffer[1] = 0x50;
> > > > +   radio->buffer[2] = (freq_send >> 8) & 0xff;
> > > > +   radio->buffer[3] = freq_send & 0xff;
> > > 
> > > Please use the endianness macro appropriate here
> > 
> > I don't see any endianness issues here, but perhaps I missed something.
> 
> You are doing the endianness conversion by hand. We have a nice macro

No - it's packing bytes into a buffer from a u16. That doesn't have a
macro.

Alan
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Oliver Neukum
Am Montag, 16. Januar 2012, 14:03:07 schrieb Hans Verkuil:
> > Oh, I forgot. You have no guarantee the hid driver is already loaded.
> > This driver needs to also gracefully handle being called for a HID
> > device.
> 
> And how do I do that? Do you have a pointer to another driver for me?

As you've tested that rejecting the device in usbhid works, I suggest you do
it as usbhid does it. Which reminds me, have you tested that it works the
second time also? The behavior is different if both drivers are resident
in memory.

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Oliver Neukum
Am Montag, 16. Januar 2012, 14:02:05 schrieb Hans Verkuil:
> > > +/* Set frequency (if non-0), PA, mute and turn on/off the FM
> > > transmitter. */ +static int keene_cmd_main(struct keene_device *radio,
> > > unsigned freq, bool play) +{
> > > +   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
> > > +   int ret;
> > > +
> > > +   radio->buffer[0] = 0x00;
> > > +   radio->buffer[1] = 0x50;
> > > +   radio->buffer[2] = (freq_send >> 8) & 0xff;
> > > +   radio->buffer[3] = freq_send & 0xff;
> > 
> > Please use the endianness macro appropriate here
> 
> I don't see any endianness issues here, but perhaps I missed something.

You are doing the endianness conversion by hand. We have a nice macro
for that that assures that special swapping cpu instructions will be used.

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Hans Verkuil
On Monday 16 January 2012 13:46:46 Oliver Neukum wrote:
> Am Montag, 16. Januar 2012, 13:29:19 schrieb Hans Verkuil:
> > +/* check if the device is present and register with v4l and usb if it is
> > */ +static int usb_keene_probe(struct usb_interface *intf,
> > +   const struct usb_device_id *id)
> > +{
> > +   struct keene_device *radio;
> > +   struct v4l2_ctrl_handler *hdl;
> > +   int retval = 0;
> > +
> > +   radio = kzalloc(sizeof(struct keene_device), GFP_KERNEL);
> > +
> > +   if (!radio) {
> > +   dev_err(&intf->dev, "kmalloc for keene_device failed\n");
> > +   retval = -ENOMEM;
> > +   goto err;
> > +   }
> 
> Oh, I forgot. You have no guarantee the hid driver is already loaded.
> This driver needs to also gracefully handle being called for a HID
> device.

And how do I do that? Do you have a pointer to another driver for me?

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Hans Verkuil
On Monday 16 January 2012 13:44:37 Oliver Neukum wrote:
> Am Montag, 16. Januar 2012, 13:29:19 schrieb Hans Verkuil:
> > From: Hans Verkuil 
> > 
> > +MODULE_DEVICE_TABLE(usb, usb_keene_device_table);
> > +
> > +struct keene_device {
> > +   struct usb_device *usbdev;
> > +   struct usb_interface *intf;
> > +   struct video_device vdev;
> > +   struct v4l2_device v4l2_dev;
> > +   struct v4l2_ctrl_handler hdl;
> > +   struct mutex lock;
> > +
> > +   u8 buffer[BUFFER_LENGTH];
> 
> This is a violation of the DMA  API. You need to alocate the buffer with
> a separate kmalloc.

OK.

> > +   unsigned curfreq;
> > +   u8 tx;
> > +   u8 pa;
> > +   bool stereo;
> > +   bool muted;
> > +   bool preemph_75_us;
> > +};
> > +
> > +static inline struct keene_device *to_keene_dev(struct v4l2_device
> > *v4l2_dev) +{
> > +   return container_of(v4l2_dev, struct keene_device, v4l2_dev);
> > +}
> > +
> > +/* Set frequency (if non-0), PA, mute and turn on/off the FM
> > transmitter. */ +static int keene_cmd_main(struct keene_device *radio,
> > unsigned freq, bool play) +{
> > +   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
> > +   int ret;
> > +
> > +   radio->buffer[0] = 0x00;
> > +   radio->buffer[1] = 0x50;
> > +   radio->buffer[2] = (freq_send >> 8) & 0xff;
> > +   radio->buffer[3] = freq_send & 0xff;
> 
> Please use the endianness macro appropriate here

I don't see any endianness issues here, but perhaps I missed something.

Regards,

Hans
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Oliver Neukum
Am Montag, 16. Januar 2012, 13:29:19 schrieb Hans Verkuil:
> +/* check if the device is present and register with v4l and usb if it is */
> +static int usb_keene_probe(struct usb_interface *intf,
> +   const struct usb_device_id *id)
> +{
> +   struct keene_device *radio;
> +   struct v4l2_ctrl_handler *hdl;
> +   int retval = 0;
> +
> +   radio = kzalloc(sizeof(struct keene_device), GFP_KERNEL);
> +
> +   if (!radio) {
> +   dev_err(&intf->dev, "kmalloc for keene_device failed\n");
> +   retval = -ENOMEM;
> +   goto err;
> +   }

Oh, I forgot. You have no guarantee the hid driver is already loaded.
This driver needs to also gracefully handle being called for a HID
device.

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Oliver Neukum
Am Montag, 16. Januar 2012, 13:29:19 schrieb Hans Verkuil:
> From: Hans Verkuil 

> +MODULE_DEVICE_TABLE(usb, usb_keene_device_table);
> +
> +struct keene_device {
> + struct usb_device *usbdev;
> + struct usb_interface *intf;
> + struct video_device vdev;
> + struct v4l2_device v4l2_dev;
> + struct v4l2_ctrl_handler hdl;
> + struct mutex lock;
> +
> + u8 buffer[BUFFER_LENGTH];

This is a violation of the DMA  API. You need to alocate the buffer with
a separate kmalloc.

> + unsigned curfreq;
> + u8 tx;
> + u8 pa;
> + bool stereo;
> + bool muted;
> + bool preemph_75_us;
> +};
> +
> +static inline struct keene_device *to_keene_dev(struct v4l2_device *v4l2_dev)
> +{
> + return container_of(v4l2_dev, struct keene_device, v4l2_dev);
> +}
> +
> +/* Set frequency (if non-0), PA, mute and turn on/off the FM transmitter. */
> +static int keene_cmd_main(struct keene_device *radio, unsigned freq, bool 
> play)
> +{
> + unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
> + int ret;
> +
> + radio->buffer[0] = 0x00;
> + radio->buffer[1] = 0x50;
> + radio->buffer[2] = (freq_send >> 8) & 0xff;
> + radio->buffer[3] = freq_send & 0xff;

Please use the endianness macro appropriate here

Regards
Oliver
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 0/3] New driver for the Keene USB FM Transmitter

2012-01-16 Thread Hans Verkuil
Hi all,

Here is a V4L2 driver for the Keene USB FM Transmitter:

http://www.amazon.co.uk/Keene-Electronics-USB-FM-Transmitter/dp/B003GCHPDY

It's been very useful to test V4L2 FM radio receivers.

Note that the Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker. Since the radio-keene driver needs to
hijack the HID something needed to be done to differentiate the two.

So hid-core was modified to decide this based on the product name.

I have tested that this works with both a Keene device and a Logitech
AudioHub device hooked up at the same time.

Jiri, can you look at the last patch and let me know if it is OK
from a HID point of view?

Regards,

Hans

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 3/3] hid-core: ignore the Keene FM transmitter.

2012-01-16 Thread Hans Verkuil
From: Hans Verkuil 

The Keene FM transmitter USB device has the same USB ID as
the Logitech AudioHub Speaker, but it should ignore the hid.
Check if the name is that of the Keene device.

Signed-off-by: Hans Verkuil 
---
 drivers/hid/hid-core.c |   10 ++
 drivers/hid/hid-ids.h  |1 +
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index af35384..f02d197 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1973,6 +1973,16 @@ static bool hid_ignore(struct hid_device *hdev)
if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST &&
hdev->product <= 
USB_DEVICE_ID_LOGITECH_HARMONY_LAST)
return true;
+   /*
+    * The Keene FM transmitter USB device has the same USB ID as
+* the Logitech AudioHub Speaker, but it should ignore the hid.
+* Check if the name is that of the Keene device.
+* For reference: the name of the AudioHub is
+* "HOLTEK  AudioHub Speaker".
+*/
+   if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB &&
+   !strcmp(hdev->name, "HOLTEK  B-LINK USB Audio  "))
+   return true;
break;
case USB_VENDOR_ID_SOUNDGRAPH:
if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST &&
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 4a441a6..2f6dc92 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -440,6 +440,7 @@
 #define USB_DEVICE_ID_LG_MULTITOUCH0x0064
 
 #define USB_VENDOR_ID_LOGITECH 0x046d
+#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e
 #define USB_DEVICE_ID_LOGITECH_RECEIVER0xc101
 #define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST  0xc110
 #define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH 2/3] radio-keene: add a driver for the Keene FM Transmitter.

2012-01-16 Thread Hans Verkuil
From: Hans Verkuil 

Signed-off-by: Hans Verkuil 
---
 drivers/media/radio/Kconfig   |   10 +
 drivers/media/radio/Makefile  |1 +
 drivers/media/radio/radio-keene.c |  419 +
 3 files changed, 430 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/radio/radio-keene.c

diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig
index e954781..48747df 100644
--- a/drivers/media/radio/Kconfig
+++ b/drivers/media/radio/Kconfig
@@ -80,6 +80,16 @@ config RADIO_SI4713
  To compile this driver as a module, choose M here: the
  module will be called radio-si4713.
 
+config USB_KEENE
+   tristate "Keene FM Transmitter USB support"
+   depends on USB && VIDEO_V4L2
+   ---help---
+ Say Y here if you want to connect this type of FM transmitter
+ to your computer's USB port.
+
+ To compile this driver as a module, choose M here: the
+ module will be called radio-keene.
+
 config RADIO_TEA5764
tristate "TEA5764 I2C FM radio support"
depends on I2C && VIDEO_V4L2
diff --git a/drivers/media/radio/Makefile b/drivers/media/radio/Makefile
index 390daf9..aec5f6f 100644
--- a/drivers/media/radio/Makefile
+++ b/drivers/media/radio/Makefile
@@ -20,6 +20,7 @@ obj-$(CONFIG_RADIO_MIROPCM20) += radio-miropcm20.o
 obj-$(CONFIG_USB_DSBR) += dsbr100.o
 obj-$(CONFIG_RADIO_SI470X) += si470x/
 obj-$(CONFIG_USB_MR800) += radio-mr800.o
+obj-$(CONFIG_USB_KEENE) += radio-keene.o
 obj-$(CONFIG_RADIO_TEA5764) += radio-tea5764.o
 obj-$(CONFIG_RADIO_SAA7706H) += saa7706h.o
 obj-$(CONFIG_RADIO_TEF6862) += tef6862.o
diff --git a/drivers/media/radio/radio-keene.c 
b/drivers/media/radio/radio-keene.c
new file mode 100644
index 000..1647a7f
--- /dev/null
+++ b/drivers/media/radio/radio-keene.c
@@ -0,0 +1,419 @@
+/*
+ * Copyright (c) 2012 Hans Verkuil 
+ *
+ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* kernel includes */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* driver and module definitions */
+MODULE_AUTHOR("Hans Verkuil ");
+MODULE_DESCRIPTION("Keene FM Transmitter driver");
+MODULE_LICENSE("GPL");
+
+/* Actually, it advertises itself as a Logitech */
+#define USB_KEENE_VENDOR 0x046d
+#define USB_KEENE_PRODUCT 0x0a0e
+
+/* Probably USB_TIMEOUT should be modified in module parameter */
+#define BUFFER_LENGTH 8
+#define USB_TIMEOUT 500
+
+/* Frequency limits in MHz */
+#define FREQ_MIN  76U
+#define FREQ_MAX 108U
+#define FREQ_MUL 16000U
+
+/* USB Device ID List */
+static struct usb_device_id usb_keene_device_table[] = {
+   {USB_DEVICE_AND_INTERFACE_INFO(USB_KEENE_VENDOR, USB_KEENE_PRODUCT,
+   USB_CLASS_HID, 0, 0) },
+   { } /* Terminating entry */
+};
+
+MODULE_DEVICE_TABLE(usb, usb_keene_device_table);
+
+struct keene_device {
+   struct usb_device *usbdev;
+   struct usb_interface *intf;
+   struct video_device vdev;
+   struct v4l2_device v4l2_dev;
+   struct v4l2_ctrl_handler hdl;
+   struct mutex lock;
+
+   u8 buffer[BUFFER_LENGTH];
+   unsigned curfreq;
+   u8 tx;
+   u8 pa;
+   bool stereo;
+   bool muted;
+   bool preemph_75_us;
+};
+
+static inline struct keene_device *to_keene_dev(struct v4l2_device *v4l2_dev)
+{
+   return container_of(v4l2_dev, struct keene_device, v4l2_dev);
+}
+
+/* Set frequency (if non-0), PA, mute and turn on/off the FM transmitter. */
+static int keene_cmd_main(struct keene_device *radio, unsigned freq, bool play)
+{
+   unsigned short freq_send = freq ? (freq - 76 * 16000) / 800 : 0;
+   int ret;
+
+   radio->buffer[0] = 0x00;
+   radio->buffer[1] = 0x50;
+   radio->buffer[2] = (freq_send >> 8) & 0xff;
+   radio->buffer[3] = freq_send & 0xff;
+   radio->buffer[4] = radio->pa;
+   /* If bit 4 is set, then tune to the frequency.
+  If bit 3 is set, then unmute; if bit 2 is set, then mute.
+  If bit 1 is set, then enter idle mode; if bit 0 is set,
+