aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/radio/radio-aimslab.c240
1 files changed, 136 insertions, 104 deletions
diff --git a/drivers/media/radio/radio-aimslab.c b/drivers/media/radio/radio-aimslab.c
index b2e88ad28977..5adc27c3ced9 100644
--- a/drivers/media/radio/radio-aimslab.c
+++ b/drivers/media/radio/radio-aimslab.c
@@ -231,129 +231,149 @@ static struct v4l2_queryctrl radio_qctrl[] = {
231 } 231 }
232}; 232};
233 233
234static int rt_do_ioctl(struct inode *inode, struct file *file, 234static int vidioc_querycap(struct file *file, void *priv,
235 unsigned int cmd, void *arg) 235 struct v4l2_capability *v)
236{
237 strlcpy(v->driver, "radio-aimslab", sizeof(v->driver));
238 strlcpy(v->card, "RadioTrack", sizeof(v->card));
239 sprintf(v->bus_info, "ISA");
240 v->version = RADIO_VERSION;
241 v->capabilities = V4L2_CAP_TUNER;
242 return 0;
243}
244
245static int vidioc_g_tuner(struct file *file, void *priv,
246 struct v4l2_tuner *v)
236{ 247{
237 struct video_device *dev = video_devdata(file); 248 struct video_device *dev = video_devdata(file);
238 struct rt_device *rt=dev->priv; 249 struct rt_device *rt = dev->priv;
239 250
240 switch(cmd) 251 if (v->index > 0)
241 { 252 return -EINVAL;
242 case VIDIOC_QUERYCAP:
243 {
244 struct v4l2_capability *v = arg;
245 memset(v,0,sizeof(*v));
246 strlcpy(v->driver, "radio-aimslab", sizeof (v->driver));
247 strlcpy(v->card, "RadioTrack", sizeof (v->card));
248 sprintf(v->bus_info,"ISA");
249 v->version = RADIO_VERSION;
250 v->capabilities = V4L2_CAP_TUNER;
251 253
252 return 0; 254 strcpy(v->name, "FM");
253 } 255 v->type = V4L2_TUNER_RADIO;
254 case VIDIOC_G_TUNER: 256 v->rangelow = (87*16000);
255 { 257 v->rangehigh = (108*16000);
256 struct v4l2_tuner *v = arg; 258 v->rxsubchans = V4L2_TUNER_SUB_MONO;
259 v->capability = V4L2_TUNER_CAP_LOW;
260 v->audmode = V4L2_TUNER_MODE_MONO;
261 v->signal = 0xffff*rt_getsigstr(rt);
262 return 0;
263}
264
265static int vidioc_s_tuner(struct file *file, void *priv,
266 struct v4l2_tuner *v)
267{
268 if (v->index > 0)
269 return -EINVAL;
270 return 0;
271}
257 272
258 if (v->index > 0) 273static int vidioc_s_frequency(struct file *file, void *priv,
259 return -EINVAL; 274 struct v4l2_frequency *f)
275{
276 struct video_device *dev = video_devdata(file);
277 struct rt_device *rt = dev->priv;
260 278
261 memset(v,0,sizeof(*v)); 279 rt->curfreq = f->frequency;
262 strcpy(v->name, "FM"); 280 rt_setfreq(rt, rt->curfreq);
263 v->type = V4L2_TUNER_RADIO; 281 return 0;
282}
264 283
265 v->rangelow=(87*16000); 284static int vidioc_g_frequency(struct file *file, void *priv,
266 v->rangehigh=(108*16000); 285 struct v4l2_frequency *f)
267 v->rxsubchans =V4L2_TUNER_SUB_MONO; 286{
268 v->capability=V4L2_TUNER_CAP_LOW; 287 struct video_device *dev = video_devdata(file);
269 v->audmode = V4L2_TUNER_MODE_MONO; 288 struct rt_device *rt = dev->priv;
270 v->signal=0xFFFF*rt_getsigstr(rt);
271 289
272 return 0; 290 f->type = V4L2_TUNER_RADIO;
273 } 291 f->frequency = rt->curfreq;
274 case VIDIOC_S_TUNER: 292 return 0;
275 { 293}
276 struct v4l2_tuner *v = arg;
277 294
278 if (v->index > 0) 295static int vidioc_queryctrl(struct file *file, void *priv,
279 return -EINVAL; 296 struct v4l2_queryctrl *qc)
297{
298 int i;
280 299
300 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
301 if (qc->id && qc->id == radio_qctrl[i].id) {
302 memcpy(qc, &(radio_qctrl[i]),
303 sizeof(*qc));
281 return 0; 304 return 0;
282 } 305 }
283 case VIDIOC_S_FREQUENCY: 306 }
284 { 307 return -EINVAL;
285 struct v4l2_frequency *f = arg; 308}
286 309
287 rt->curfreq = f->frequency; 310static int vidioc_g_ctrl(struct file *file, void *priv,
288 rt_setfreq(rt, rt->curfreq); 311 struct v4l2_control *ctrl)
289 return 0; 312{
290 } 313 struct video_device *dev = video_devdata(file);
291 case VIDIOC_G_FREQUENCY: 314 struct rt_device *rt = dev->priv;
292 {
293 struct v4l2_frequency *f = arg;
294 315
295 f->type = V4L2_TUNER_RADIO; 316 switch (ctrl->id) {
296 f->frequency = rt->curfreq; 317 case V4L2_CID_AUDIO_MUTE:
318 ctrl->value = rt->muted;
319 return 0;
320 case V4L2_CID_AUDIO_VOLUME:
321 ctrl->value = rt->curvol * 6554;
322 return 0;
323 }
324 return -EINVAL;
325}
297 326
298 return 0; 327static int vidioc_s_ctrl(struct file *file, void *priv,
299 } 328 struct v4l2_control *ctrl)
300 case VIDIOC_QUERYCTRL: 329{
301 { 330 struct video_device *dev = video_devdata(file);
302 struct v4l2_queryctrl *qc = arg; 331 struct rt_device *rt = dev->priv;
303 int i;
304
305 for (i = 0; i < ARRAY_SIZE(radio_qctrl); i++) {
306 if (qc->id && qc->id == radio_qctrl[i].id) {
307 memcpy(qc, &(radio_qctrl[i]),
308 sizeof(*qc));
309 return (0);
310 }
311 }
312 return -EINVAL;
313 }
314 case VIDIOC_G_CTRL:
315 {
316 struct v4l2_control *ctrl= arg;
317
318 switch (ctrl->id) {
319 case V4L2_CID_AUDIO_MUTE:
320 ctrl->value=rt->muted;
321 return (0);
322 case V4L2_CID_AUDIO_VOLUME:
323 ctrl->value=rt->curvol * 6554;
324 return (0);
325 }
326 return -EINVAL;
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 332
347 default: 333 switch (ctrl->id) {
348 return v4l_compat_translate_ioctl(inode,file,cmd,arg, 334 case V4L2_CID_AUDIO_MUTE:
349 rt_do_ioctl); 335 if (ctrl->value)
336 rt_mute(rt);
337 else
338 rt_setvol(rt,rt->curvol);
339 return 0;
340 case V4L2_CID_AUDIO_VOLUME:
341 rt_setvol(rt,ctrl->value);
342 return 0;
350 } 343 }
344 return -EINVAL;
345}
346
347static int vidioc_g_audio (struct file *file, void *priv,
348 struct v4l2_audio *a)
349{
350 if (a->index > 1)
351 return -EINVAL;
352
353 strcpy(a->name, "Radio");
354 a->capability = V4L2_AUDCAP_STEREO;
355 return 0;
356}
357
358static int vidioc_g_input(struct file *filp, void *priv, unsigned int *i)
359{
360 *i = 0;
361 return 0;
362}
363
364static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
365{
366 if (i != 0)
367 return -EINVAL;
368 return 0;
351} 369}
352 370
353static int rt_ioctl(struct inode *inode, struct file *file, 371static int vidioc_s_audio(struct file *file, void *priv,
354 unsigned int cmd, unsigned long arg) 372 struct v4l2_audio *a)
355{ 373{
356 return video_usercopy(inode, file, cmd, arg, rt_do_ioctl); 374 if (a->index != 0)
375 return -EINVAL;
376 return 0;
357} 377}
358 378
359static struct rt_device rtrack_unit; 379static struct rt_device rtrack_unit;
@@ -362,7 +382,7 @@ static const struct file_operations rtrack_fops = {
362 .owner = THIS_MODULE, 382 .owner = THIS_MODULE,
363 .open = video_exclusive_open, 383 .open = video_exclusive_open,
364 .release = video_exclusive_release, 384 .release = video_exclusive_release,
365 .ioctl = rt_ioctl, 385 .ioctl = video_ioctl2,
366 .compat_ioctl = v4l_compat_ioctl32, 386 .compat_ioctl = v4l_compat_ioctl32,
367 .llseek = no_llseek, 387 .llseek = no_llseek,
368}; 388};
@@ -374,6 +394,18 @@ static struct video_device rtrack_radio=
374 .type = VID_TYPE_TUNER, 394 .type = VID_TYPE_TUNER,
375 .hardware = 0, 395 .hardware = 0,
376 .fops = &rtrack_fops, 396 .fops = &rtrack_fops,
397 .vidioc_querycap = vidioc_querycap,
398 .vidioc_g_tuner = vidioc_g_tuner,
399 .vidioc_s_tuner = vidioc_s_tuner,
400 .vidioc_g_audio = vidioc_g_audio,
401 .vidioc_s_audio = vidioc_s_audio,
402 .vidioc_g_input = vidioc_g_input,
403 .vidioc_s_input = vidioc_s_input,
404 .vidioc_g_frequency = vidioc_g_frequency,
405 .vidioc_s_frequency = vidioc_s_frequency,
406 .vidioc_queryctrl = vidioc_queryctrl,
407 .vidioc_g_ctrl = vidioc_g_ctrl,
408 .vidioc_s_ctrl = vidioc_s_ctrl,
377}; 409};
378 410
379static int __init rtrack_init(void) 411static int __init rtrack_init(void)