follow /dev/radio changes; from maintainer Vladimir Popov <pva48@mail.ru>

This commit is contained in:
naddy 2002-01-11 01:29:07 +00:00
parent da42792e3e
commit 49f4493e02

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
$OpenBSD: patch-src_wmtune_c,v 1.3 2002/01/11 01:29:07 naddy Exp $
--- src/wmtune.c.orig Sat Sep 11 11:49:24 1999
+++ src/wmtune.c Mon Dec 10 08:44:12 2001
@@ -18,102 +18,76 @@
+++ src/wmtune.c Fri Jan 11 00:51:57 2002
@@ -18,102 +18,74 @@
****************************************************************
*/
@ -146,8 +146,6 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+int VOLUME_STEP;
+static struct radio_info ri;
+char *radiodevice = NULL;
+#define GET_INFO 0
+#define SET_INFO 1
+#endif /* ZOLTRIX */
-// Functions
@ -159,7 +157,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
void RadioOff(void);
void RadioOn(void);
void DrawDigitalFreq(void);
@@ -127,7 +101,6 @@ void VolumeUp(void);
@@ -127,7 +99,6 @@ void VolumeUp(void);
void VolumeDown(void);
void TuneUp(void);
void TuneDown(void);
@ -167,7 +165,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
void PresetHandler(int);
void ScanUp(void);
void ScanDown(void);
@@ -137,333 +110,251 @@ void FastFreqUpdate(void);
@@ -137,333 +108,251 @@ void FastFreqUpdate(void);
void TuneRadio(void);
int TestTune(void);
void TestFreq(void);
@ -230,7 +228,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+#ifdef ZOLTRIX
CheckIOPerms();
+#else
+ if (SetGetRadioInfo(GET_INFO) < 0)
+ if (SetGetRadioInfo(RIOCGINFO) < 0)
+ errx(1, "Cannot manage the FM tuner");
+ GetVolumeStep();
#endif
@ -672,7 +670,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
GeneralFreqUpdate();
}
@@ -475,110 +366,65 @@ void GeneralFreqUpdate(void)
@@ -475,110 +364,65 @@ void GeneralFreqUpdate(void)
DrawDigitalFreq();
}
@ -812,7 +810,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
copyXPMArea((*p-'0')*6 + 1, 79, 5, 7, k, 50);
k += 6;
p++;
@@ -589,16 +435,15 @@ void DrawDigitalPreset(void)
@@ -589,16 +433,15 @@ void DrawDigitalPreset(void)
void DrawDigitalFreq(void)
{
@ -838,7 +836,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
copyXPMArea(76, 40, 6, 9, k, 7);
k += 7;
i--;
@@ -606,8 +451,7 @@ void DrawDigitalFreq(void)
@@ -606,8 +449,7 @@ void DrawDigitalFreq(void)
copyXPMArea((*p-'0')*7 + 1, 66, 7, 9, k, 7);
k += 7;
p++;
@ -848,7 +846,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
copyXPMArea(71, 66, 3, 9, k, 7);
k += 3;
p++;
@@ -619,30 +463,22 @@ void DrawDigitalFreq(void)
@@ -619,30 +461,22 @@ void DrawDigitalFreq(void)
void ScanUp(void)
{
@ -890,7 +888,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
RedrawWindowXYWH(44, 16, 13, 4); // Test Freq Field Only
return;
}
@@ -651,333 +487,155 @@ void ScanUp(void)
@@ -651,333 +485,155 @@ void ScanUp(void)
void ScanDown(void)
{
@ -1334,7 +1332,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
minute++;
}
DrawDigitalTime(hour,minute);
@@ -985,113 +643,48 @@ void TimeUp(void)
@@ -985,113 +641,48 @@ void TimeUp(void)
void TimeDown(void)
{
@ -1463,7 +1461,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
break;
}
RedrawWindowXYWH(44, 16, 13, 4);
@@ -1099,12 +692,10 @@ void TestFreq(void)
@@ -1099,12 +690,10 @@ void TestFreq(void)
void OnPreset(void)
{
@ -1479,7 +1477,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
preset_count = count;
DrawDigitalPreset();
return;
@@ -1113,28 +704,129 @@ void OnPreset(void)
@@ -1113,28 +702,129 @@ void OnPreset(void)
}
}
@ -1576,7 +1574,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+ cardRead(3);
+#else
+ ri.mute = 1;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
+#endif /* ZOLTRIX */
+ radio_status = OFF;
+ copyXPMArea(76, 40, 51, 13, 6, 7);
@ -1592,9 +1590,9 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+ tuneFreq(presets[0].freq, 1);
+#else
+ ri.freq = presets[0].freq * 1000;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
+ usleep(50000);
+ SetGetRadioInfo(GET_INFO);
+ SetGetRadioInfo(RIOCGINFO);
+ presets[0].freq = (float)ri.freq / 1000.;
+#endif
+}
@ -1607,9 +1605,9 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+ ri.freq = presets[0].freq * 1000;
+ ri.volume = volume * VOLUME_STEP;
+ ri.mute = 0;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
+ usleep(200000);
+ SetGetRadioInfo(GET_INFO);
+ SetGetRadioInfo(RIOCGINFO);
+ presets[0].freq = (float)ri.freq / 1000.;
+#endif /* ZOLTRIX */
+}
@ -1626,7 +1624,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
usleep(10000);
x1 = inb(rport);
@@ -1143,73 +835,165 @@ int TestTune(void)
@@ -1143,73 +833,165 @@ int TestTune(void)
if ((x1 == x2) && (x1 == 0xdf))
return 1;
@ -1642,7 +1640,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+#else
+ int ret = 0;
+
+ SetGetRadioInfo(GET_INFO);
+ SetGetRadioInfo(RIOCGINFO);
+ if (ri.info & RADIO_INFO_SIGNAL)
+ ret = 1;
+ if (ri.info & RADIO_INFO_STEREO)
@ -1680,7 +1678,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
- {
- return 1;
+ ri.volume = volume * VOLUME_STEP;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
+#endif
+}
+
@ -1695,7 +1693,7 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+ cardRead(2);
+#else
+ ri.volume = volume * VOLUME_STEP;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
+#endif
+}
+
@ -1769,14 +1767,14 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+SetGetRadioInfo(int setinfo) {
+ int rd;
+
+ rd = open(radiodevice, O_RDONLY);
+ rd = open(radiodevice, setinfo == RIOCSINFO ? O_RDWR : O_RDONLY);
+ if (rd < 0) {
+ warn("%s open error", radiodevice);
+ return -1;
+ }
+
+ if (ioctl(rd, setinfo == SET_INFO ? RIOCSINFO : RIOCGINFO, &ri) < 0) {
+ warn("%s", setinfo == SET_INFO ? "RIOCSINFO" : "RIOCGINFO");
+ if (ioctl(rd, setinfo, &ri) < 0) {
+ warn("%s", setinfo == RIOCSINFO ? "RIOCSINFO" : "RIOCGINFO");
+ return -1;
+ }
+
@ -1836,9 +1834,9 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
+
+ for (i = 0; i < 256; i++) {
+ ri.volume = i;
+ if (SetGetRadioInfo(SET_INFO) < 0)
+ if (SetGetRadioInfo(RIOCSINFO) < 0)
+ break;
+ if (SetGetRadioInfo(GET_INFO) < 0)
+ if (SetGetRadioInfo(RIOCGINFO) < 0)
+ break;
+ if (ri.volume) {
+ VOLUME_STEP = ri.volume;
@ -1850,6 +1848,6 @@ $OpenBSD: patch-src_wmtune_c,v 1.2 2001/12/20 21:18:02 naddy Exp $
- return 0;
+
+ ri.volume = oldvol;
+ SetGetRadioInfo(SET_INFO);
+ SetGetRadioInfo(RIOCSINFO);
}
+#endif