ChangeSet 1.1094.6.9, 2003/03/14 10:53:01-08:00, [EMAIL PROTECTED]

[PATCH] USB: Patch for DSBR-100 driver

I since you are  listed as the maintainer of the USB subsystem and
I can't really see who else applies, I'm sending you a patch to my
driver for the DSBR-100 USB radio.  This is mainly code cosmetics
(fixed ugly missing spaces after commas I inherited from the
aztech driver, some constants moved to preprocessor symbols), but
there's one technical change: I used to stop the radio when my
file descriptor was closed.  Petr Slansky <[EMAIL PROTECTED]>
pointed out that the other radio drivers don't do that, so
now I just let the radio run.


 drivers/usb/media/dsbr100.c |   75 ++++++++++++++++++++++++--------------------
 1 files changed, 41 insertions(+), 34 deletions(-)


diff -Nru a/drivers/usb/media/dsbr100.c b/drivers/usb/media/dsbr100.c
--- a/drivers/usb/media/dsbr100.c       Mon Mar 17 11:46:35 2003
+++ b/drivers/usb/media/dsbr100.c       Mon Mar 17 11:46:35 2003
@@ -33,6 +33,12 @@
 
  History:
 
+ Version 0.30:
+       Markus: Updates for 2.5.x kernel and more ISO compiant source
+
+ Version 0.25:
+        PSL and Markus: Cleanup, radio now doesn't stop on device close
+
  Version 0.24:
        Markus: Hope I got these silly VIDEO_TUNER_LOW issues finally
        right.  Some minor cleanup, improved standalone compilation
@@ -69,15 +75,22 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "v0.24"
+#define DRIVER_VERSION "v0.25"
 #define DRIVER_AUTHOR "Markus Demleitner <[EMAIL PROTECTED]>"
-#define DRIVER_DESC "D-Link DSB-R100 USB radio driver"
+#define DRIVER_DESC "D-Link DSB-R100 USB FM radio driver"
 
 #define DSB100_VENDOR 0x04b4
 #define DSB100_PRODUCT 0x1002
 
 #define TB_LEN 16
 
+/* Frequency limits in MHz -- these are European values.  For Japanese
+devices, that would be 76 and 91.  */
+#define FREQ_MIN  87.5
+#define FREQ_MAX 108.0
+#define FREQ_MUL 16000
+
+
 static int usb_dsbr100_probe(struct usb_interface *intf,
                             const struct usb_device_id *id);
 static void usb_dsbr100_disconnect(struct usb_interface *intf);
@@ -108,7 +121,7 @@
 static struct video_device usb_dsbr100_radio=
 {
        .owner =        THIS_MODULE,
-       .name =         "D-Link DSB R-100 USB radio",
+       .name =         "D-Link DSB-R 100",
        .type =         VID_TYPE_TUNER,
        .hardware =     VID_HARDWARE_AZTECH,
        .fops =         &usb_dsbr100_fops,
@@ -189,7 +202,7 @@
                return -ENOMEM;
        usb_dsbr100_radio.priv = radio;
        radio->dev = interface_to_usbdev (intf);
-       radio->curfreq = 1454000;
+       radio->curfreq = FREQ_MIN*FREQ_MUL;
        usb_set_intfdata (intf, radio);
        return 0;
 }
@@ -225,11 +238,11 @@
        {
                case VIDIOCGCAP: {
                        struct video_capability *v = arg;
-                       memset(v,0,sizeof(*v));
-                       v->type=VID_TYPE_TUNER;
-                       v->channels=1;
-                       v->audios=1;
-                       strcpy(v->name, "D-Link R-100 USB Radio");
+                       memset(v, 0, sizeof(*v));
+                       v->type = VID_TYPE_TUNER;
+                       v->channels = 1;
+                       v->audios = 1;
+                       strcpy(v->name, "D-Link R-100 USB FM Radio");
                        return 0;
                }
                case VIDIOCGTUNER: {
@@ -237,8 +250,8 @@
                        dsbr100_getstat(radio);
                        if(v->tuner)    /* Only 1 tuner */ 
                                return -EINVAL;
-                       v->rangelow = 87*16000;
-                       v->rangehigh = 108*16000;
+                       v->rangelow = FREQ_MIN*FREQ_MUL;
+                       v->rangehigh = FREQ_MAX*FREQ_MUL;
                        v->flags = VIDEO_TUNER_LOW;
                        v->mode = VIDEO_MODE_AUTO;
                        v->signal = radio->stereo*0x7000;
@@ -268,31 +281,31 @@
 
                        radio->curfreq = *freq;
                        if (dsbr100_setfreq(radio, radio->curfreq)==-1)
-                               warn("set frequency failed");
+                               warn("Set frequency failed");
                        return 0;
                }
                case VIDIOCGAUDIO: {
                        struct video_audio *v = arg;
-                       memset(v,0, sizeof(*v));
-                       v->flags|=VIDEO_AUDIO_MUTABLE;
-                       v->mode=VIDEO_SOUND_STEREO;
-                       v->volume=1;
-                       v->step=1;
+                       memset(v, 0, sizeof(*v));
+                       v->flags |= VIDEO_AUDIO_MUTABLE;
+                       v->mode = VIDEO_SOUND_STEREO;
+                       v->volume = 1;
+                       v->step = 1;
                        strcpy(v->name, "Radio");
                        return 0;                       
                }
                case VIDIOCSAUDIO: {
                        struct video_audio *v = arg;
-                       if(v->audio) 
+                       if (v->audio) 
                                return -EINVAL;
 
-                       if(v->flags&VIDEO_AUDIO_MUTE) {
+                       if (v->flags&VIDEO_AUDIO_MUTE) {
                                if (dsbr100_stop(radio)==-1)
-                                       warn("radio did not respond properly");
+                                       warn("Radio did not respond properly");
                        }
                        else
                                if (dsbr100_start(radio)==-1)
-                                       warn("radio did not respond properly");
+                                       warn("Radio did not respond properly");
                        return 0;
                }
                default:
@@ -312,18 +325,18 @@
        usb_dsbr100 *radio=dev->priv;
 
        if (! radio) {
-               warn("radio not initialised");
+               warn("Radio not initialised");
                return -EAGAIN;
        }
        if(users)
        {
-               warn("radio in use");
+               warn("Radio in use");
                return -EBUSY;
        }
        users++;
        if (dsbr100_start(radio)<0)
-               warn("radio did not start up properly");
-       dsbr100_setfreq(radio,radio->curfreq);
+               warn("Radio did not start up properly");
+       dsbr100_setfreq(radio, radio->curfreq);
        return 0;
 }
 
@@ -335,7 +348,6 @@
        if (!radio)
                return -ENODEV;
        users--;
-       dsbr100_stop(radio);
        return 0;
 }
 
@@ -343,8 +355,9 @@
 {
        usb_dsbr100_radio.priv = NULL;
        usb_register(&usb_dsbr100_driver);
-       if (video_register_device(&usb_dsbr100_radio,VFL_TYPE_RADIO,radio_nr)==-1) {   
 
-               warn("couldn't register video device");
+       if (video_register_device(&usb_dsbr100_radio, VFL_TYPE_RADIO,
+               radio_nr)==-1) {        
+               warn("Couldn't register video device");
                return -EINVAL;
        }
        info(DRIVER_VERSION ":" DRIVER_DESC);
@@ -367,9 +380,3 @@
 MODULE_AUTHOR( DRIVER_AUTHOR );
 MODULE_DESCRIPTION( DRIVER_DESC );
 MODULE_LICENSE("GPL");
-
-/*
-vi: ts=8
-Sigh.  Of course, I am one of the ts=2 heretics, but Linus' wish is
-my command.
-*/



-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open! 
Get cracking and register here for some mind boggling fun and 
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to