diff options
Diffstat (limited to 'drivers/media/radio/radio-maxiradio.c')
-rw-r--r-- | drivers/media/radio/radio-maxiradio.c | 166 |
1 files changed, 103 insertions, 63 deletions
diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c index f93d7afe7304..c2eeae7a10d0 100644 --- a/drivers/media/radio/radio-maxiradio.c +++ b/drivers/media/radio/radio-maxiradio.c | |||
@@ -20,13 +20,14 @@ | |||
20 | * 0.75b | 20 | * 0.75b |
21 | * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr> | 21 | * - better pci interface thanks to Francois Romieu <romieu@cogenit.fr> |
22 | * | 22 | * |
23 | * 0.75 | 23 | * 0.75 Sun Feb 4 22:51:27 EET 2001 |
24 | * - tiding up | 24 | * - tiding up |
25 | * - removed support for multiple devices as it didn't work anyway | 25 | * - removed support for multiple devices as it didn't work anyway |
26 | * | 26 | * |
27 | * BUGS: | 27 | * BUGS: |
28 | * - card unmutes if you change frequency | 28 | * - card unmutes if you change frequency |
29 | * | 29 | * |
30 | * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> | ||
30 | */ | 31 | */ |
31 | 32 | ||
32 | 33 | ||
@@ -40,11 +41,24 @@ | |||
40 | #include <linux/mutex.h> | 41 | #include <linux/mutex.h> |
41 | 42 | ||
42 | #include <linux/pci.h> | 43 | #include <linux/pci.h> |
43 | #include <linux/videodev.h> | 44 | #include <linux/videodev2.h> |
44 | #include <media/v4l2-common.h> | 45 | #include <media/v4l2-common.h> |
45 | 46 | ||
46 | /* version 0.75 Sun Feb 4 22:51:27 EET 2001 */ | 47 | #define DRIVER_VERSION "0.76" |
47 | #define DRIVER_VERSION "0.75" | 48 | |
49 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
50 | #define RADIO_VERSION KERNEL_VERSION(0,7,6) | ||
51 | |||
52 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
53 | { | ||
54 | .id = V4L2_CID_AUDIO_MUTE, | ||
55 | .name = "Mute", | ||
56 | .minimum = 0, | ||
57 | .maximum = 1, | ||
58 | .default_value = 1, | ||
59 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
60 | } | ||
61 | }; | ||
48 | 62 | ||
49 | #ifndef PCI_VENDOR_ID_GUILLEMOT | 63 | #ifndef PCI_VENDOR_ID_GUILLEMOT |
50 | #define PCI_VENDOR_ID_GUILLEMOT 0x5046 | 64 | #define PCI_VENDOR_ID_GUILLEMOT 0x5046 |
@@ -90,7 +104,6 @@ static struct video_device maxiradio_radio = | |||
90 | .owner = THIS_MODULE, | 104 | .owner = THIS_MODULE, |
91 | .name = "Maxi Radio FM2000 radio", | 105 | .name = "Maxi Radio FM2000 radio", |
92 | .type = VID_TYPE_TUNER, | 106 | .type = VID_TYPE_TUNER, |
93 | .hardware = VID_HARDWARE_SF16MI, | ||
94 | .fops = &maxiradio_fops, | 107 | .fops = &maxiradio_fops, |
95 | }; | 108 | }; |
96 | 109 | ||
@@ -176,89 +189,116 @@ static inline int radio_function(struct inode *inode, struct file *file, | |||
176 | struct radio_device *card=dev->priv; | 189 | struct radio_device *card=dev->priv; |
177 | 190 | ||
178 | switch(cmd) { | 191 | switch(cmd) { |
179 | case VIDIOCGCAP: { | 192 | case VIDIOC_QUERYCAP: |
180 | struct video_capability *v = arg; | 193 | { |
181 | 194 | struct v4l2_capability *v = arg; | |
182 | memset(v,0,sizeof(*v)); | 195 | memset(v,0,sizeof(*v)); |
183 | strcpy(v->name, "Maxi Radio FM2000 radio"); | 196 | strlcpy(v->driver, "radio-maxiradio", sizeof (v->driver)); |
184 | v->type=VID_TYPE_TUNER; | 197 | strlcpy(v->card, "Maxi Radio FM2000 radio", sizeof (v->card)); |
185 | v->channels=v->audios=1; | 198 | sprintf(v->bus_info,"ISA"); |
199 | v->version = RADIO_VERSION; | ||
200 | v->capabilities = V4L2_CAP_TUNER; | ||
201 | |||
186 | return 0; | 202 | return 0; |
187 | } | 203 | } |
188 | case VIDIOCGTUNER: { | 204 | case VIDIOC_G_TUNER: |
189 | struct video_tuner *v = arg; | 205 | { |
206 | struct v4l2_tuner *v = arg; | ||
190 | 207 | ||
191 | if(v->tuner) | 208 | if (v->index > 0) |
192 | return -EINVAL; | 209 | return -EINVAL; |
193 | 210 | ||
194 | card->stereo = 0xffff * get_stereo(card->io); | 211 | memset(v,0,sizeof(*v)); |
195 | card->tuned = 0xffff * get_tune(card->io); | ||
196 | |||
197 | v->flags = VIDEO_TUNER_LOW | card->stereo; | ||
198 | v->signal = card->tuned; | ||
199 | |||
200 | strcpy(v->name, "FM"); | 212 | strcpy(v->name, "FM"); |
201 | 213 | v->type = V4L2_TUNER_RADIO; | |
202 | v->rangelow = FREQ_LO; | 214 | |
203 | v->rangehigh = FREQ_HI; | 215 | v->rangelow=FREQ_LO; |
204 | v->mode = VIDEO_MODE_AUTO; | 216 | v->rangehigh=FREQ_HI; |
217 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; | ||
218 | v->capability=V4L2_TUNER_CAP_LOW; | ||
219 | if(get_stereo(card->io)) | ||
220 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
221 | else | ||
222 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
223 | v->signal=0xffff*get_tune(card->io); | ||
205 | 224 | ||
206 | return 0; | 225 | return 0; |
207 | } | 226 | } |
208 | case VIDIOCSTUNER: { | 227 | case VIDIOC_S_TUNER: |
209 | struct video_tuner *v = arg; | 228 | { |
210 | if(v->tuner!=0) | 229 | struct v4l2_tuner *v = arg; |
230 | |||
231 | if (v->index > 0) | ||
211 | return -EINVAL; | 232 | return -EINVAL; |
212 | return 0; | ||
213 | } | ||
214 | case VIDIOCGFREQ: { | ||
215 | unsigned long *freq = arg; | ||
216 | 233 | ||
217 | *freq = card->freq; | ||
218 | return 0; | 234 | return 0; |
219 | } | 235 | } |
220 | case VIDIOCSFREQ: { | 236 | case VIDIOC_S_FREQUENCY: |
221 | unsigned long *freq = arg; | 237 | { |
238 | struct v4l2_frequency *f = arg; | ||
222 | 239 | ||
223 | if (*freq < FREQ_LO || *freq > FREQ_HI) | 240 | if (f->frequency < FREQ_LO || f->frequency > FREQ_HI) |
224 | return -EINVAL; | 241 | return -EINVAL; |
225 | card->freq = *freq; | 242 | |
243 | card->freq = f->frequency; | ||
226 | set_freq(card->io, FREQ2BITS(card->freq)); | 244 | set_freq(card->io, FREQ2BITS(card->freq)); |
227 | msleep(125); | 245 | msleep(125); |
228 | return 0; | 246 | return 0; |
229 | } | 247 | } |
230 | case VIDIOCGAUDIO: { | 248 | case VIDIOC_G_FREQUENCY: |
231 | struct video_audio *v = arg; | 249 | { |
232 | memset(v,0,sizeof(*v)); | 250 | struct v4l2_frequency *f = arg; |
233 | strcpy(v->name, "Radio"); | ||
234 | v->flags=VIDEO_AUDIO_MUTABLE | card->muted; | ||
235 | v->mode=VIDEO_SOUND_STEREO; | ||
236 | return 0; | ||
237 | } | ||
238 | 251 | ||
239 | case VIDIOCSAUDIO: { | 252 | f->type = V4L2_TUNER_RADIO; |
240 | struct video_audio *v = arg; | 253 | f->frequency = card->freq; |
241 | 254 | ||
242 | if(v->audio) | ||
243 | return -EINVAL; | ||
244 | card->muted = v->flags & VIDEO_AUDIO_MUTE; | ||
245 | if(card->muted) | ||
246 | turn_power(card->io, 0); | ||
247 | else | ||
248 | set_freq(card->io, FREQ2BITS(card->freq)); | ||
249 | return 0; | 255 | return 0; |
250 | } | 256 | } |
251 | case VIDIOCGUNIT: { | 257 | case VIDIOC_QUERYCTRL: |
252 | struct video_unit *v = arg; | 258 | { |
253 | 259 | struct v4l2_queryctrl *qc = arg; | |
254 | v->video=VIDEO_NO_UNIT; | 260 | int i; |
255 | v->vbi=VIDEO_NO_UNIT; | 261 | |
256 | v->radio=dev->minor; | 262 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
257 | v->audio=0; | 263 | if (qc->id && qc->id == radio_qctrl[i].id) { |
258 | v->teletext=VIDEO_NO_UNIT; | 264 | memcpy(qc, &(radio_qctrl[i]), |
259 | return 0; | 265 | sizeof(*qc)); |
266 | return (0); | ||
267 | } | ||
268 | } | ||
269 | return -EINVAL; | ||
270 | } | ||
271 | case VIDIOC_G_CTRL: | ||
272 | { | ||
273 | struct v4l2_control *ctrl= arg; | ||
274 | |||
275 | switch (ctrl->id) { | ||
276 | case V4L2_CID_AUDIO_MUTE: | ||
277 | ctrl->value=card->muted; | ||
278 | return (0); | ||
279 | } | ||
280 | return -EINVAL; | ||
260 | } | 281 | } |
261 | default: return -ENOIOCTLCMD; | 282 | case VIDIOC_S_CTRL: |
283 | { | ||
284 | struct v4l2_control *ctrl= arg; | ||
285 | |||
286 | switch (ctrl->id) { | ||
287 | case V4L2_CID_AUDIO_MUTE: | ||
288 | card->muted = ctrl->value; | ||
289 | if(card->muted) | ||
290 | turn_power(card->io, 0); | ||
291 | else | ||
292 | set_freq(card->io, FREQ2BITS(card->freq)); | ||
293 | return 0; | ||
294 | } | ||
295 | return -EINVAL; | ||
296 | } | ||
297 | |||
298 | default: | ||
299 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | ||
300 | radio_function); | ||
301 | |||
262 | } | 302 | } |
263 | } | 303 | } |
264 | 304 | ||