2 * Copyright (C) 12 Jun 2003 Tomas Cermak
4 * This file is part of wmradio program.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 #include <sys/ioctl.h>
30 #include <linux/videodev.h>
32 char *device
= "/dev/radio";
34 int get_freq_fact(int fd
)
36 struct video_tuner tuner
;
39 if (ioctl (fd
, VIDIOCGTUNER
, &tuner
) < 0)
41 if ((tuner
.flags
& VIDEO_TUNER_LOW
) == 0)
46 int radio_setfreq(int fd
, int freq
)
48 int ifreq
= (freq
/100.0+1.0/32.0)*get_freq_fact(fd
);
49 return ioctl(fd
, VIDIOCSFREQ
, &ifreq
);
52 void radio_unmute(int fd
)
54 struct video_audio vid_aud
;
56 if (ioctl(fd
, VIDIOCGAUDIO
, &vid_aud
))
57 perror("VIDIOCGAUDIO");
58 if (vid_aud
.volume
== 0)
59 vid_aud
.volume
= 65535;
60 vid_aud
.flags
&= ~VIDEO_AUDIO_MUTE
;
61 if (ioctl(fd
, VIDIOCSAUDIO
, &vid_aud
))
62 perror("VIDIOCSAUDIO");
65 void radio_mute(int fd
)
67 struct video_audio vid_aud
;
69 if (ioctl(fd
, VIDIOCGAUDIO
, &vid_aud
))
70 perror("VIDIOCGAUDIO");
71 vid_aud
.flags
|= VIDEO_AUDIO_MUTE
;
72 if (ioctl(fd
, VIDIOCSAUDIO
, &vid_aud
))
73 perror("VIDIOCSAUDIO");
76 int radio_getstereo(int fd
)
78 struct video_audio va
;
80 if(ioctl(fd
, VIDIOCGAUDIO
, &va
) < 0) return 0;
81 return va
.mode
== VIDEO_SOUND_STEREO
? 1 : 0;
84 int radio_getsignal(int fd
)
86 struct video_tuner vt
;
89 memset(&vt
,0,sizeof(vt
));
90 ioctl (fd
, VIDIOCGTUNER
, &vt
);