diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-08-08 08:10:04 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-09-26 10:53:15 -0400 |
commit | 2ab652993623954c7bfdadeba311d15a3e1494c0 (patch) | |
tree | d8098db596ffbed25bf83a0fea296a201d0124f0 /drivers/media/radio | |
parent | 30c48305ba3e785cef33ff90efcbf5d9bdc3cffe (diff) |
V4L/DVB (4358): V4L2 conversion: radio-zoltrix
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-zoltrix.c | 182 |
2 files changed, 125 insertions, 59 deletions
diff --git a/drivers/media/radio/Kconfig b/drivers/media/radio/Kconfig index e64f0aae7dea..1fe960c0f7e0 100644 --- a/drivers/media/radio/Kconfig +++ b/drivers/media/radio/Kconfig | |||
@@ -330,7 +330,7 @@ config RADIO_TYPHOON_MUTEFREQ | |||
330 | 330 | ||
331 | config RADIO_ZOLTRIX | 331 | config RADIO_ZOLTRIX |
332 | tristate "Zoltrix Radio" | 332 | tristate "Zoltrix Radio" |
333 | depends on ISA && VIDEO_V4L1 | 333 | depends on ISA && VIDEO_V4L2 |
334 | ---help--- | 334 | ---help--- |
335 | Choose Y here if you have one of these FM radio cards, and then fill | 335 | Choose Y here if you have one of these FM radio cards, and then fill |
336 | in the port address below. | 336 | in the port address below. |
diff --git a/drivers/media/radio/radio-zoltrix.c b/drivers/media/radio/radio-zoltrix.c index 432c3e2222d0..671fe1b1e5bc 100644 --- a/drivers/media/radio/radio-zoltrix.c +++ b/drivers/media/radio/radio-zoltrix.c | |||
@@ -24,6 +24,9 @@ | |||
24 | * - Added unmute function | 24 | * - Added unmute function |
25 | * - Reworked ioctl functions | 25 | * - Reworked ioctl functions |
26 | * 2002-07-15 - Fix Stereo typo | 26 | * 2002-07-15 - Fix Stereo typo |
27 | * | ||
28 | * 2006-07-24 - Converted to V4L2 API | ||
29 | * by Mauro Carvalho Chehab <mchehab@infradead.org> | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | #include <linux/module.h> /* Modules */ | 32 | #include <linux/module.h> /* Modules */ |
@@ -32,9 +35,31 @@ | |||
32 | #include <linux/delay.h> /* udelay, msleep */ | 35 | #include <linux/delay.h> /* udelay, msleep */ |
33 | #include <asm/io.h> /* outb, outb_p */ | 36 | #include <asm/io.h> /* outb, outb_p */ |
34 | #include <asm/uaccess.h> /* copy to/from user */ | 37 | #include <asm/uaccess.h> /* copy to/from user */ |
35 | #include <linux/videodev.h> /* kernel radio structs */ | 38 | #include <linux/videodev2.h> /* kernel radio structs */ |
36 | #include <media/v4l2-common.h> | 39 | #include <media/v4l2-common.h> |
37 | 40 | ||
41 | #include <linux/version.h> /* for KERNEL_VERSION MACRO */ | ||
42 | #define RADIO_VERSION KERNEL_VERSION(0,0,2) | ||
43 | |||
44 | static struct v4l2_queryctrl radio_qctrl[] = { | ||
45 | { | ||
46 | .id = V4L2_CID_AUDIO_MUTE, | ||
47 | .name = "Mute", | ||
48 | .minimum = 0, | ||
49 | .maximum = 1, | ||
50 | .default_value = 1, | ||
51 | .type = V4L2_CTRL_TYPE_BOOLEAN, | ||
52 | },{ | ||
53 | .id = V4L2_CID_AUDIO_VOLUME, | ||
54 | .name = "Volume", | ||
55 | .minimum = 0, | ||
56 | .maximum = 65535, | ||
57 | .step = 4096, | ||
58 | .default_value = 0xff, | ||
59 | .type = V4L2_CTRL_TYPE_INTEGER, | ||
60 | } | ||
61 | }; | ||
62 | |||
38 | #ifndef CONFIG_RADIO_ZOLTRIX_PORT | 63 | #ifndef CONFIG_RADIO_ZOLTRIX_PORT |
39 | #define CONFIG_RADIO_ZOLTRIX_PORT -1 | 64 | #define CONFIG_RADIO_ZOLTRIX_PORT -1 |
40 | #endif | 65 | #endif |
@@ -212,78 +237,116 @@ static int zol_do_ioctl(struct inode *inode, struct file *file, | |||
212 | struct zol_device *zol = dev->priv; | 237 | struct zol_device *zol = dev->priv; |
213 | 238 | ||
214 | switch (cmd) { | 239 | switch (cmd) { |
215 | case VIDIOCGCAP: | 240 | case VIDIOC_QUERYCAP: |
216 | { | 241 | { |
217 | struct video_capability *v = arg; | 242 | struct v4l2_capability *v = arg; |
218 | |||
219 | memset(v,0,sizeof(*v)); | 243 | memset(v,0,sizeof(*v)); |
220 | v->type = VID_TYPE_TUNER; | 244 | strlcpy(v->driver, "radio-zoltrix", sizeof (v->driver)); |
221 | v->channels = 1 + zol->stereo; | 245 | strlcpy(v->card, "Zoltrix Radio", sizeof (v->card)); |
222 | v->audios = 1; | 246 | sprintf(v->bus_info,"ISA"); |
223 | strcpy(v->name, "Zoltrix Radio"); | 247 | v->version = RADIO_VERSION; |
248 | v->capabilities = V4L2_CAP_TUNER; | ||
249 | |||
224 | return 0; | 250 | return 0; |
225 | } | 251 | } |
226 | case VIDIOCGTUNER: | 252 | case VIDIOC_G_TUNER: |
227 | { | 253 | { |
228 | struct video_tuner *v = arg; | 254 | struct v4l2_tuner *v = arg; |
229 | if (v->tuner) | 255 | |
256 | if (v->index > 0) | ||
230 | return -EINVAL; | 257 | return -EINVAL; |
258 | |||
259 | memset(v,0,sizeof(*v)); | ||
231 | strcpy(v->name, "FM"); | 260 | strcpy(v->name, "FM"); |
232 | v->rangelow = (int) (88.0 * 16000); | 261 | v->type = V4L2_TUNER_RADIO; |
233 | v->rangehigh = (int) (108.0 * 16000); | 262 | |
234 | v->flags = zol_is_stereo(zol) | 263 | v->rangelow=(88*16000); |
235 | ? VIDEO_TUNER_STEREO_ON : 0; | 264 | v->rangehigh=(108*16000); |
236 | v->flags |= VIDEO_TUNER_LOW; | 265 | v->rxsubchans =V4L2_TUNER_SUB_MONO|V4L2_TUNER_SUB_STEREO; |
237 | v->mode = VIDEO_MODE_AUTO; | 266 | v->capability=V4L2_TUNER_CAP_LOW; |
238 | v->signal = 0xFFFF * zol_getsigstr(zol); | 267 | if(zol_is_stereo(zol)) |
268 | v->audmode = V4L2_TUNER_MODE_STEREO; | ||
269 | else | ||
270 | v->audmode = V4L2_TUNER_MODE_MONO; | ||
271 | v->signal=0xFFFF*zol_getsigstr(zol); | ||
272 | |||
239 | return 0; | 273 | return 0; |
240 | } | 274 | } |
241 | case VIDIOCSTUNER: | 275 | case VIDIOC_S_TUNER: |
242 | { | 276 | { |
243 | struct video_tuner *v = arg; | 277 | struct v4l2_tuner *v = arg; |
244 | if (v->tuner != 0) | 278 | |
279 | if (v->index > 0) | ||
245 | return -EINVAL; | 280 | return -EINVAL; |
246 | /* Only 1 tuner so no setting needed ! */ | 281 | |
247 | return 0; | 282 | return 0; |
248 | } | 283 | } |
249 | case VIDIOCGFREQ: | 284 | case VIDIOC_S_FREQUENCY: |
250 | { | ||
251 | unsigned long *freq = arg; | ||
252 | *freq = zol->curfreq; | ||
253 | return 0; | ||
254 | } | ||
255 | case VIDIOCSFREQ: | ||
256 | { | ||
257 | unsigned long *freq = arg; | ||
258 | zol->curfreq = *freq; | ||
259 | zol_setfreq(zol, zol->curfreq); | ||
260 | return 0; | ||
261 | } | ||
262 | case VIDIOCGAUDIO: | ||
263 | { | 285 | { |
264 | struct video_audio *v = arg; | 286 | struct v4l2_frequency *f = arg; |
265 | memset(v, 0, sizeof(*v)); | 287 | |
266 | v->flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME; | 288 | zol->curfreq = f->frequency; |
267 | v->mode |= zol_is_stereo(zol) | 289 | zol_setfreq(zol, zol->curfreq); |
268 | ? VIDEO_SOUND_STEREO : VIDEO_SOUND_MONO; | ||
269 | v->volume = zol->curvol * 4096; | ||
270 | v->step = 4096; | ||
271 | strcpy(v->name, "Zoltrix Radio"); | ||
272 | return 0; | 290 | return 0; |
273 | } | 291 | } |
274 | case VIDIOCSAUDIO: | 292 | case VIDIOC_G_FREQUENCY: |
275 | { | 293 | { |
276 | struct video_audio *v = arg; | 294 | struct v4l2_frequency *f = arg; |
277 | if (v->audio) | ||
278 | return -EINVAL; | ||
279 | 295 | ||
280 | if (v->flags & VIDEO_AUDIO_MUTE) | 296 | f->type = V4L2_TUNER_RADIO; |
281 | zol_mute(zol); | 297 | f->frequency = zol->curfreq; |
282 | else { | ||
283 | zol_unmute(zol); | ||
284 | zol_setvol(zol, v->volume / 4096); | ||
285 | } | ||
286 | 298 | ||
299 | return 0; | ||
300 | } | ||
301 | case VIDIOC_QUERYCTRL: | ||
302 | { | ||
303 | struct v4l2_queryctrl *qc = arg; | ||
304 | int i; | ||
305 | |||
306 | for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) { | ||
307 | if (qc->id && qc->id == radio_qctrl[i].id) { | ||
308 | memcpy(qc, &(radio_qctrl[i]), | ||
309 | sizeof(*qc)); | ||
310 | return (0); | ||
311 | } | ||
312 | } | ||
313 | return -EINVAL; | ||
314 | } | ||
315 | case VIDIOC_G_CTRL: | ||
316 | { | ||
317 | struct v4l2_control *ctrl= arg; | ||
318 | |||
319 | switch (ctrl->id) { | ||
320 | case V4L2_CID_AUDIO_MUTE: | ||
321 | ctrl->value=zol->muted; | ||
322 | return (0); | ||
323 | case V4L2_CID_AUDIO_VOLUME: | ||
324 | ctrl->value=zol->curvol * 4096; | ||
325 | return (0); | ||
326 | } | ||
327 | return -EINVAL; | ||
328 | } | ||
329 | case VIDIOC_S_CTRL: | ||
330 | { | ||
331 | struct v4l2_control *ctrl= arg; | ||
332 | |||
333 | switch (ctrl->id) { | ||
334 | case V4L2_CID_AUDIO_MUTE: | ||
335 | if (ctrl->value) { | ||
336 | zol_mute(zol); | ||
337 | } else { | ||
338 | zol_unmute(zol); | ||
339 | zol_setvol(zol,zol->curvol); | ||
340 | } | ||
341 | return (0); | ||
342 | case V4L2_CID_AUDIO_VOLUME: | ||
343 | zol_setvol(zol,ctrl->value/4096); | ||
344 | return (0); | ||
345 | } | ||
346 | zol->stereo = 1; | ||
347 | zol_setfreq(zol, zol->curfreq); | ||
348 | #if 0 | ||
349 | /* FIXME: Implement stereo/mono switch on V4L2 */ | ||
287 | if (v->mode & VIDEO_SOUND_STEREO) { | 350 | if (v->mode & VIDEO_SOUND_STEREO) { |
288 | zol->stereo = 1; | 351 | zol->stereo = 1; |
289 | zol_setfreq(zol, zol->curfreq); | 352 | zol_setfreq(zol, zol->curfreq); |
@@ -292,10 +355,13 @@ static int zol_do_ioctl(struct inode *inode, struct file *file, | |||
292 | zol->stereo = 0; | 355 | zol->stereo = 0; |
293 | zol_setfreq(zol, zol->curfreq); | 356 | zol_setfreq(zol, zol->curfreq); |
294 | } | 357 | } |
295 | return 0; | 358 | #endif |
359 | return -EINVAL; | ||
296 | } | 360 | } |
297 | default: | 361 | |
298 | return -ENOIOCTLCMD; | 362 | default: |
363 | return v4l_compat_translate_ioctl(inode,file,cmd,arg, | ||
364 | zol_do_ioctl); | ||
299 | } | 365 | } |
300 | } | 366 | } |
301 | 367 | ||
@@ -322,7 +388,7 @@ static struct video_device zoltrix_radio = | |||
322 | .owner = THIS_MODULE, | 388 | .owner = THIS_MODULE, |
323 | .name = "Zoltrix Radio Plus", | 389 | .name = "Zoltrix Radio Plus", |
324 | .type = VID_TYPE_TUNER, | 390 | .type = VID_TYPE_TUNER, |
325 | .hardware = VID_HARDWARE_ZOLTRIX, | 391 | .hardware = 0, |
326 | .fops = &zoltrix_fops, | 392 | .fops = &zoltrix_fops, |
327 | }; | 393 | }; |
328 | 394 | ||