patch-2.1.127 linux/drivers/char/radio-sf16fmi.c

Next file: linux/drivers/char/riscom8.c
Previous file: linux/drivers/char/qpmouse.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.126/linux/drivers/char/radio-sf16fmi.c linux/drivers/char/radio-sf16fmi.c
@@ -43,7 +43,7 @@
  * 92.7400017 -> 92.75
  */
 #define RSF16_ENCODE(x)	((x)/800+214)
-#define RSF16_MINFREQ 88*16000
+#define RSF16_MINFREQ 87*16000
 #define RSF16_MAXFREQ 108*16000
 
 static void outbits(int bits, unsigned int data, int port)
@@ -64,27 +64,31 @@
 	}
 }
 
-static void fmi_mute(int port)
+static inline void fmi_mute(int port)
 {
 	outb(0x00, port);
 }
 
-static void fmi_unmute(int port)
+static inline void fmi_unmute(int port)
 {
 	outb(0x08, port);
 }
 
-static int fmi_setfreq(struct fmi_device *dev, unsigned long freq)
+static inline int fmi_setfreq(struct fmi_device *dev, unsigned long freq)
 {
         int myport = dev->port;
 
 	outbits(16, RSF16_ENCODE(freq), myport);
 	outbits(8, 0xC0, myport);
-	/* we should wait here... */
+	/* it is better than udelay(140000), isn't it? */
+	current->state = TASK_INTERRUPTIBLE;
+	schedule_timeout(HZ/7);
+	/* ignore signals, we really should restore volume */
+	if (dev->curvol) fmi_unmute(myport);
 	return 0;
 }
 
-static int fmi_getsigstr(struct fmi_device *dev)
+static inline int fmi_getsigstr(struct fmi_device *dev)
 {
 	int val;
 	int res;
@@ -93,10 +97,16 @@
 	val = dev->curvol ? 0x08 : 0x00;	/* unmute/mute */
 	outb(val, myport);
 	outb(val | 0x10, myport);
-	udelay(140000);
+	/* it is better than udelay(140000), isn't it? */
+	current->state = TASK_INTERRUPTIBLE;
+	schedule_timeout(HZ/7);
+	/* do not do it..., 140ms is very looong time to get signal in real program 
+	if (signal_pending(current))
+	    return -EINTR;
+	*/
 	res = (int)inb(myport+1);
 	outb(val, myport);
-	return (res & 2) ? 0 : 1;
+	return (res & 2) ? 0 : 0xFFFF;
 }
 
 static int fmi_ioctl(struct video_device *dev, unsigned int cmd, void *arg)
@@ -136,7 +146,7 @@
 			v.rangehigh = RSF16_MAXFREQ/mult;
 			v.flags=fmi->flags;
 			v.mode=VIDEO_MODE_AUTO;
-			v.signal=0xFFFF*fmi_getsigstr(fmi);
+			v.signal = fmi_getsigstr(fmi);
 			if(copy_to_user(arg,&v, sizeof(v)))
 				return -EFAULT;
 			return 0;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov