diff options
author | Thierry MERLE <thierry.merle@free.fr> | 2007-05-02 17:43:55 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2007-07-18 13:23:19 -0400 |
commit | ea1f83cee96badc28d3f67ef29ac29c9d0eb0a1b (patch) | |
tree | 44619e4ef3a46e184bd9da79ca3498457826b1a5 /drivers/media/video/usbvision | |
parent | 8c7189d1939f6e15c4ebc23a98b3b9f34bd004d7 (diff) |
V4L/DVB (5643): Usbvision: make common video and radio ioctls
Radio and video ioctls are the same,
delete the usbvision_do_radio_ioctl function
add the special cases for radio in usbvision_v4l2_do_ioctl
Signed-off-by: Thierry MERLE <thierry.merle@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/usbvision')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 166 |
1 files changed, 22 insertions, 144 deletions
diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index aa3258bbb4af..dab8bc968dfb 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c | |||
@@ -692,11 +692,18 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
692 | 692 | ||
693 | if (!usbvision->have_tuner || vt->index) // Only tuner 0 | 693 | if (!usbvision->have_tuner || vt->index) // Only tuner 0 |
694 | return -EINVAL; | 694 | return -EINVAL; |
695 | strcpy(vt->name, "Television"); | 695 | if(usbvision->radio) { |
696 | strcpy(vt->name, "Radio"); | ||
697 | vt->type = V4L2_TUNER_RADIO; | ||
698 | } | ||
699 | else { | ||
700 | strcpy(vt->name, "Television"); | ||
701 | } | ||
696 | /* Let clients fill in the remainder of this struct */ | 702 | /* Let clients fill in the remainder of this struct */ |
697 | call_i2c_clients(usbvision,VIDIOC_G_TUNER,vt); | 703 | call_i2c_clients(usbvision,VIDIOC_G_TUNER,vt); |
698 | 704 | ||
699 | PDEBUG(DBG_IOCTL, "VIDIOC_G_TUNER signal=%x, afc=%x",vt->signal,vt->afc); | 705 | PDEBUG(DBG_IOCTL, "VIDIOC_G_TUNER for %s signal=%x, afc=%x", |
706 | vt->name, vt->signal,vt->afc); | ||
700 | return 0; | 707 | return 0; |
701 | } | 708 | } |
702 | case VIDIOC_S_TUNER: | 709 | case VIDIOC_S_TUNER: |
@@ -717,7 +724,12 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
717 | struct v4l2_frequency *freq = arg; | 724 | struct v4l2_frequency *freq = arg; |
718 | 725 | ||
719 | freq->tuner = 0; // Only one tuner | 726 | freq->tuner = 0; // Only one tuner |
720 | freq->type = V4L2_TUNER_ANALOG_TV; | 727 | if(usbvision->radio) { |
728 | freq->type = V4L2_TUNER_RADIO; | ||
729 | } | ||
730 | else { | ||
731 | freq->type = V4L2_TUNER_ANALOG_TV; | ||
732 | } | ||
721 | freq->frequency = usbvision->freq; | 733 | freq->frequency = usbvision->freq; |
722 | PDEBUG(DBG_IOCTL, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)freq->frequency); | 734 | PDEBUG(DBG_IOCTL, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)freq->frequency); |
723 | return 0; | 735 | return 0; |
@@ -739,7 +751,12 @@ static int usbvision_v4l2_do_ioctl(struct inode *inode, struct file *file, | |||
739 | { | 751 | { |
740 | struct v4l2_audio *v = arg; | 752 | struct v4l2_audio *v = arg; |
741 | memset(v,0, sizeof(v)); | 753 | memset(v,0, sizeof(v)); |
742 | strcpy(v->name, "TV"); | 754 | if(usbvision->radio) { |
755 | strcpy(v->name,"Radio"); | ||
756 | } | ||
757 | else { | ||
758 | strcpy(v->name, "TV"); | ||
759 | } | ||
743 | PDEBUG(DBG_IOCTL, "VIDIOC_G_AUDIO"); | 760 | PDEBUG(DBG_IOCTL, "VIDIOC_G_AUDIO"); |
744 | return 0; | 761 | return 0; |
745 | } | 762 | } |
@@ -1219,7 +1236,6 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) | |||
1219 | { | 1236 | { |
1220 | struct video_device *dev = video_devdata(file); | 1237 | struct video_device *dev = video_devdata(file); |
1221 | struct usb_usbvision *usbvision = (struct usb_usbvision *) video_get_drvdata(dev); | 1238 | struct usb_usbvision *usbvision = (struct usb_usbvision *) video_get_drvdata(dev); |
1222 | struct v4l2_frequency freq; | ||
1223 | int errCode = 0; | 1239 | int errCode = 0; |
1224 | 1240 | ||
1225 | PDEBUG(DBG_IO, "%s:", __FUNCTION__); | 1241 | PDEBUG(DBG_IO, "%s:", __FUNCTION__); |
@@ -1249,8 +1265,6 @@ static int usbvision_radio_open(struct inode *inode, struct file *file) | |||
1249 | // If so far no errors then we shall start the radio | 1265 | // If so far no errors then we shall start the radio |
1250 | usbvision->radio = 1; | 1266 | usbvision->radio = 1; |
1251 | call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); | 1267 | call_i2c_clients(usbvision,AUDC_SET_RADIO,&usbvision->tuner_type); |
1252 | freq.frequency = 1517; //SWR3 @ 94.8MHz | ||
1253 | call_i2c_clients(usbvision, VIDIOC_S_FREQUENCY, &freq); | ||
1254 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); | 1268 | usbvision_set_audio(usbvision, USBVISION_AUDIO_RADIO); |
1255 | usbvision->user++; | 1269 | usbvision->user++; |
1256 | } | 1270 | } |
@@ -1304,146 +1318,10 @@ static int usbvision_radio_close(struct inode *inode, struct file *file) | |||
1304 | return errCode; | 1318 | return errCode; |
1305 | } | 1319 | } |
1306 | 1320 | ||
1307 | static int usbvision_do_radio_ioctl(struct inode *inode, struct file *file, | ||
1308 | unsigned int cmd, void *arg) | ||
1309 | { | ||
1310 | struct video_device *dev = video_devdata(file); | ||
1311 | struct usb_usbvision *usbvision = (struct usb_usbvision *) video_get_drvdata(dev); | ||
1312 | |||
1313 | if (!USBVISION_IS_OPERATIONAL(usbvision)) | ||
1314 | return -EIO; | ||
1315 | |||
1316 | switch (cmd) { | ||
1317 | case VIDIOC_QUERYCAP: | ||
1318 | { | ||
1319 | struct v4l2_capability *vc=arg; | ||
1320 | |||
1321 | memset(vc, 0, sizeof(*vc)); | ||
1322 | strlcpy(vc->driver, "USBVision", sizeof(vc->driver)); | ||
1323 | strlcpy(vc->card, usbvision_device_data[usbvision->DevModel].ModelString, | ||
1324 | sizeof(vc->card)); | ||
1325 | strlcpy(vc->bus_info, usbvision->dev->dev.bus_id, | ||
1326 | sizeof(vc->bus_info)); | ||
1327 | vc->version = USBVISION_DRIVER_VERSION; | ||
1328 | vc->capabilities = (usbvision->have_tuner ? V4L2_CAP_TUNER : 0); | ||
1329 | PDEBUG(DBG_IO, "VIDIOC_QUERYCAP"); | ||
1330 | return 0; | ||
1331 | } | ||
1332 | case VIDIOC_QUERYCTRL: | ||
1333 | { | ||
1334 | struct v4l2_queryctrl *ctrl = arg; | ||
1335 | int id=ctrl->id; | ||
1336 | |||
1337 | memset(ctrl,0,sizeof(*ctrl)); | ||
1338 | ctrl->id=id; | ||
1339 | |||
1340 | call_i2c_clients(usbvision, cmd, arg); | ||
1341 | PDEBUG(DBG_IO,"VIDIOC_QUERYCTRL id=%x value=%x",ctrl->id,ctrl->type); | ||
1342 | |||
1343 | if (ctrl->type) | ||
1344 | return 0; | ||
1345 | else | ||
1346 | return -EINVAL; | ||
1347 | |||
1348 | } | ||
1349 | case VIDIOC_G_CTRL: | ||
1350 | { | ||
1351 | struct v4l2_control *ctrl = arg; | ||
1352 | |||
1353 | call_i2c_clients(usbvision, VIDIOC_G_CTRL, ctrl); | ||
1354 | PDEBUG(DBG_IO,"VIDIOC_G_CTRL id=%x value=%x",ctrl->id,ctrl->value); | ||
1355 | return 0; | ||
1356 | } | ||
1357 | case VIDIOC_S_CTRL: | ||
1358 | { | ||
1359 | struct v4l2_control *ctrl = arg; | ||
1360 | |||
1361 | call_i2c_clients(usbvision, VIDIOC_S_CTRL, ctrl); | ||
1362 | PDEBUG(DBG_IO, "VIDIOC_S_CTRL id=%x value=%x",ctrl->id,ctrl->value); | ||
1363 | return 0; | ||
1364 | } | ||
1365 | case VIDIOC_G_TUNER: | ||
1366 | { | ||
1367 | struct v4l2_tuner *t = arg; | ||
1368 | |||
1369 | if (t->index > 0) | ||
1370 | return -EINVAL; | ||
1371 | |||
1372 | memset(t,0,sizeof(*t)); | ||
1373 | strcpy(t->name, "Radio"); | ||
1374 | t->type = V4L2_TUNER_RADIO; | ||
1375 | |||
1376 | /* Let clients fill in the remainder of this struct */ | ||
1377 | call_i2c_clients(usbvision,VIDIOC_G_TUNER,t); | ||
1378 | PDEBUG(DBG_IO, "VIDIOC_G_TUNER signal=%x, afc=%x",t->signal,t->afc); | ||
1379 | return 0; | ||
1380 | } | ||
1381 | case VIDIOC_S_TUNER: | ||
1382 | { | ||
1383 | struct v4l2_tuner *vt = arg; | ||
1384 | |||
1385 | // Only no or one tuner for now | ||
1386 | if (!usbvision->have_tuner || vt->index) | ||
1387 | return -EINVAL; | ||
1388 | /* let clients handle this */ | ||
1389 | call_i2c_clients(usbvision,VIDIOC_S_TUNER,vt); | ||
1390 | |||
1391 | PDEBUG(DBG_IO, "VIDIOC_S_TUNER"); | ||
1392 | return 0; | ||
1393 | } | ||
1394 | case VIDIOC_G_AUDIO: | ||
1395 | { | ||
1396 | struct v4l2_audio *a = arg; | ||
1397 | |||
1398 | memset(a,0,sizeof(*a)); | ||
1399 | strcpy(a->name,"Radio"); | ||
1400 | PDEBUG(DBG_IO, "VIDIOC_G_AUDIO"); | ||
1401 | return 0; | ||
1402 | } | ||
1403 | case VIDIOC_S_AUDIO: | ||
1404 | case VIDIOC_S_INPUT: | ||
1405 | case VIDIOC_S_STD: | ||
1406 | return 0; | ||
1407 | |||
1408 | case VIDIOC_G_FREQUENCY: | ||
1409 | { | ||
1410 | struct v4l2_frequency *f = arg; | ||
1411 | |||
1412 | memset(f,0,sizeof(*f)); | ||
1413 | |||
1414 | f->type = V4L2_TUNER_RADIO; | ||
1415 | f->frequency = usbvision->freq; | ||
1416 | call_i2c_clients(usbvision, cmd, f); | ||
1417 | PDEBUG(DBG_IO, "VIDIOC_G_FREQUENCY freq=0x%X", (unsigned)f->frequency); | ||
1418 | |||
1419 | return 0; | ||
1420 | } | ||
1421 | case VIDIOC_S_FREQUENCY: | ||
1422 | { | ||
1423 | struct v4l2_frequency *f = arg; | ||
1424 | |||
1425 | if (f->tuner != 0) | ||
1426 | return -EINVAL; | ||
1427 | usbvision->freq = f->frequency; | ||
1428 | call_i2c_clients(usbvision, cmd, f); | ||
1429 | PDEBUG(DBG_IO, "VIDIOC_S_FREQUENCY freq=0x%X", (unsigned)f->frequency); | ||
1430 | |||
1431 | return 0; | ||
1432 | } | ||
1433 | default: | ||
1434 | { | ||
1435 | PDEBUG(DBG_IO, "%s: Unknown command %x", __FUNCTION__, cmd); | ||
1436 | return -ENOIOCTLCMD; | ||
1437 | } | ||
1438 | } | ||
1439 | return 0; | ||
1440 | } | ||
1441 | |||
1442 | |||
1443 | static int usbvision_radio_ioctl(struct inode *inode, struct file *file, | 1321 | static int usbvision_radio_ioctl(struct inode *inode, struct file *file, |
1444 | unsigned int cmd, unsigned long arg) | 1322 | unsigned int cmd, unsigned long arg) |
1445 | { | 1323 | { |
1446 | return video_usercopy(inode, file, cmd, arg, usbvision_do_radio_ioctl); | 1324 | return video_usercopy(inode, file, cmd, arg, usbvision_v4l2_do_ioctl); |
1447 | } | 1325 | } |
1448 | 1326 | ||
1449 | 1327 | ||