diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-08-08 08:10:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-09-26 08:03:17 -0400 |
commit | 46ff2c7250eece24974ddb2198421c83a69a6289 (patch) | |
tree | 4aebfd54e805108934b16c8bed1774b5eeb4c960 /drivers/media/radio | |
parent | b59b36db9e8f441868c9907d6ea8fe0cdcb77f39 (diff) |
V4L/DVB (4346): V4L2 conversion: radio_aimslab
Driver conversion to V4L2 API.
Require some testing, since this obsolete hardware is not
common those days.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/radio')
-rw-r--r-- | drivers/media/radio/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/radio/radio-aimslab.c | 148 |
2 files changed, 107 insertions, 43 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index 220076b1b956..f17fc21247e7 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -25,7 +25,7 @@ config RADIO_CADET | |||
25 | 25 | ||
26 | config RADIO_RTRACK | 26 | config RADIO_RTRACK |
27 | tristate "AIMSlab RadioTrack (aka RadioReveal) support" | 27 | tristate "AIMSlab RadioTrack (aka RadioReveal) support" |
28 | depends on ISA && VIDEO_V4L1 | 28 | depends on ISA && VIDEO_V4L2 |
29 | ---help--- | 29 | ---help--- |
30 | Choose Y here if you have one of these FM radio cards, and then fill | 30 | Choose Y here if you have one of these FM radio cards, and then fill |
31 | in the port address below. | 31 | in the port address below. |
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c index 5a9c1f14e353..7b9043f9d9bc 100644 --- a/drivers/media/radio/radio-aimslab.c +++ b/drivers/media/radio/radio-aimslab.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* radiotrack (radioreveal) driver for Linux radio support | 1 | /* radiotrack (radioreveal) driver for Linux radio support |
2 | * (c) 1997 M. Kirkwood | 2 | * (c) 1997 M. Kirkwood |
3 | * Converted to V4L2 API by Mauro Carvalho Chehab <mchehab@infradead.org> | ||
3 | * Converted to new API by Alan Cox <Alan.Cox@linux.org> | 4 | * Converted to new API by Alan Cox <Alan.Cox@linux.org> |
4 | * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org> | 5 | * Various bugfixes and enhancements by Russell Kroll <rkroll@exploits.org> |
5 | * | 6 | * |
@@ -33,10 +34,13 @@ | |||
33 | #include <linux/delay.h> /* udelay */ | 34 | #include <linux/delay.h> /* udelay */ |
34 | #include <asm/io.h> /* outb, outb_p */ | 35 | #include <asm/io.h> /* outb, outb_p */ |
35 | #include <asm/uaccess.h> /* copy to/from user */ | 36 | #include <asm/uaccess.h> /* copy to/from user */ |
36 | #include <linux/videodev.h> /* kernel radio structs */ | 37 | #include <linux/videodev2.h> /* kernel radio structs */ |
37 | #include <media/v4l2-common.h> | 38 | #include <media/v4l2-common.h> |
38 | #include <asm/semaphore.h> /* Lock for the I/O */ | 39 | #include <asm/semaphore.h> /* Lock for the I/O */ |
39 | 40 | ||
41 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
42 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | ||
43 | |||
40 | #ifndef CONFIG_RADIO_RTRACK_PORT | 44 | #ifndef CONFIG_RADIO_RTRACK_PORT |
41 | #define CONFIG_RADIO_RTRACK_PORT -1 | 45 | #define CONFIG_RADIO_RTRACK_PORT -1 |
42 | #endif | 46 | #endif |
@@ -208,6 +212,25 @@ static int rt_getsigstr(struct rt_device *dev) | |||
208 | return 1; /* signal present */ | 212 | return 1; /* signal present */ |
209 | } | 213 | } |
210 | 214 | ||
215 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
216 | { | ||
217 | .id = V4L2_CID_AUDIO_MUTE, | ||
218 | .name = "Mute", | ||
219 | .minimum = 0, | ||
220 | .maximum = 1, | ||
221 | .default_value = 1, | ||
222 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
223 | },{ | ||
224 | .id = V4L2_CID_AUDIO_VOLUME, | ||
225 | .name = "Volume", | ||
226 | .minimum = 0, | ||
227 | .maximum = 0xff, | ||
228 | .step = 1, | ||
229 | .default_value = 0xff, | ||
230 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
231 | } | ||
232 | }; | ||
233 | |||
211 | static int rt_do_ioctl(struct inode *inode, struct file *file, | 234 | static int rt_do_ioctl(struct inode *inode, struct file *file, |
212 | unsigned int cmd, void *arg) | 235 | unsigned int cmd, void *arg) |
213 | { | 236 | { |
@@ -216,73 +239,114 @@ static int rt_do_ioctl(struct inode *inode, struct file *file, | |||
216 | 239 | ||
217 | switch(cmd) | 240 | switch(cmd) |
218 | { | 241 | { |
219 | case VIDIOCGCAP: | 242 | case VIDIOC_QUERYCAP: |
220 | { | 243 | { |
221 | struct video_capability *v = arg; | 244 | struct v4l2_capability *v = arg; |
222 | memset(v,0,sizeof(*v)); | 245 | memset(v,0,sizeof(*v)); |
223 | v->type=VID_TYPE_TUNER; | 246 | strlcpy(v->driver, "radio-aimslab", sizeof (v->driver)); |
224 | v->channels=1; | 247 | strlcpy(v->card, "RadioTrack", sizeof (v->card)); |
225 | v->audios=1; | 248 | sprintf(v->bus_info,"ISA"); |
226 | strcpy(v->name, "RadioTrack"); | 249 | v->version = RADIO_VERSION; |
250 | v->capabilities = V4L2_CAP_TUNER; | ||
251 | |||
227 | return 0; | 252 | return 0; |
228 | } | 253 | } |
229 | case VIDIOCGTUNER: | 254 | case VIDIOC_G_TUNER: |
230 | { | 255 | { |
231 | struct video_tuner *v = arg; | 256 | struct v4l2_tuner *v = arg; |
232 | if(v->tuner) /* Only 1 tuner */ | 257 | |
258 | if (v->index > 0) | ||
233 | return -EINVAL; | 259 | return -EINVAL; |
260 | |||
261 | memset(v,0,sizeof(*v)); | ||
262 | strcpy(v->name, "FM"); | ||
263 | v->type = V4L2_TUNER_RADIO; | ||
264 | |||
234 | v->rangelow=(87*16000); | 265 | v->rangelow=(87*16000); |
235 | v->rangehigh=(108*16000); | 266 | v->rangehigh=(108*16000); |
236 | v->flags=VIDEO_TUNER_LOW; | 267 | v->rxsubchans =V4L2_TUNER_SUB_MONO; |
237 | v->mode=VIDEO_MODE_AUTO; | 268 | v->capability=V4L2_TUNER_CAP_LOW; |
238 | strcpy(v->name, "FM"); | 269 | v->audmode = V4L2_TUNER_MODE_MONO; |
239 | v->signal=0xFFFF*rt_getsigstr(rt); | 270 | v->signal=0xFFFF*rt_getsigstr(rt); |
271 | |||
240 | return 0; | 272 | return 0; |
241 | } | 273 | } |
242 | case VIDIOCSTUNER: | 274 | case VIDIOC_S_TUNER: |
243 | { | 275 | { |
244 | struct video_tuner *v = arg; | 276 | struct v4l2_tuner *v = arg; |
245 | if(v->tuner!=0) | 277 | |
278 | if (v->index > 0) | ||
246 | return -EINVAL; | 279 | return -EINVAL; |
247 | /* Only 1 tuner so no setting needed ! */ | 280 | |
248 | return 0; | 281 | return 0; |
249 | } | 282 | } |
250 | case VIDIOCGFREQ: | 283 | case VIDIOC_S_FREQUENCY: |
251 | { | 284 | { |
252 | unsigned long *freq = arg; | 285 | struct v4l2_frequency *f = arg; |
253 | *freq = rt->curfreq; | 286 | |
287 | rt->curfreq = f->frequency; | ||
288 | rt_setfreq(rt, rt->curfreq); | ||
254 | return 0; | 289 | return 0; |
255 | } | 290 | } |
256 | case VIDIOCSFREQ: | 291 | case VIDIOC_G_FREQUENCY: |
257 | { | 292 | { |
258 | unsigned long *freq = arg; | 293 | struct v4l2_frequency *f = arg; |
259 | rt->curfreq = *freq; | 294 | |
260 | rt_setfreq(rt, rt->curfreq); | 295 | f->type = V4L2_TUNER_RADIO; |
296 | f->frequency = rt->curfreq; | ||
297 | |||
261 | return 0; | 298 | return 0; |
262 | } | 299 | } |
263 | case VIDIOCGAUDIO: | 300 | case VIDIOC_QUERYCTRL: |
264 | { | 301 | { |
265 | struct video_audio *v = arg; | 302 | struct v4l2_queryctrl *qc = arg; |
266 | memset(v,0, sizeof(*v)); | 303 | int i; |
267 | v->flags|=VIDEO_AUDIO_MUTABLE|VIDEO_AUDIO_VOLUME; | 304 | |
268 | v->volume=rt->curvol * 6554; | 305 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { |
269 | v->step=6554; | 306 | if (qc->id && qc->id == radio_qctrl[i].id) { |
270 | strcpy(v->name, "Radio"); | 307 | memcpy(qc, &(radio_qctrl[i]), |
271 | return 0; | 308 | sizeof(*qc)); |
309 | return (0); | ||
310 | } | ||
311 | } | ||
312 | return -EINVAL; | ||
272 | } | 313 | } |
273 | case VIDIOCSAUDIO: | 314 | case VIDIOC_G_CTRL: |
274 | { | 315 | { |
275 | struct video_audio *v = arg; | 316 | struct v4l2_control *ctrl= arg; |
276 | if(v->audio) | 317 | |
277 | return -EINVAL; | 318 | switch (ctrl->id) { |
278 | if(v->flags&VIDEO_AUDIO_MUTE) | 319 | case V4L2_CID_AUDIO_MUTE: |
279 | rt_mute(rt); | 320 | ctrl->value=rt->muted; |
280 | else | 321 | return (0); |
281 | rt_setvol(rt,v->volume/6554); | 322 | case V4L2_CID_AUDIO_VOLUME: |
282 | return 0; | 323 | ctrl->value=rt->curvol * 6554; |
324 | return (0); | ||
325 | } | ||
326 | return -EINVAL; | ||
283 | } | 327 | } |
328 | case VIDIOC_S_CTRL: | ||
329 | { | ||
330 | struct v4l2_control *ctrl= arg; | ||
331 | |||
332 | switch (ctrl->id) { | ||
333 | case V4L2_CID_AUDIO_MUTE: | ||
334 | if (ctrl->value) { | ||
335 | rt_mute(rt); | ||
336 | } else { | ||
337 | rt_setvol(rt,rt->curvol); | ||
338 | } | ||
339 | return (0); | ||
340 | case V4L2_CID_AUDIO_VOLUME: | ||
341 | rt_setvol(rt,ctrl->value); | ||
342 | return (0); | ||
343 | } | ||
344 | return -EINVAL; | ||
345 | } | ||
346 | |||
284 | default: | 347 | default: |
285 | return -ENOIOCTLCMD; | 348 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, |
349 | rt_do_ioctl); | ||
286 | } | 350 | } |
287 | } | 351 | } |
288 | 352 | ||