Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] tm6000: add support for control events and prio handling

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
770056c4 9f747359

+25 -8
+23 -8
drivers/media/usb/tm6000/tm6000-video.c
··· 34 34 #include <linux/usb.h> 35 35 #include <linux/videodev2.h> 36 36 #include <media/v4l2-ioctl.h> 37 + #include <media/v4l2-event.h> 37 38 #include <media/tuner.h> 38 39 #include <linux/interrupt.h> 39 40 #include <linux/kthread.h> ··· 1351 1350 return -ENOMEM; 1352 1351 } 1353 1352 1353 + v4l2_fh_init(&fh->fh, vdev); 1354 1354 file->private_data = fh; 1355 1355 fh->dev = dev; 1356 1356 fh->radio = radio; ··· 1395 1393 tm6000_prepare_isoc(dev); 1396 1394 tm6000_start_thread(dev); 1397 1395 } 1396 + v4l2_fh_add(&fh->fh); 1398 1397 1399 1398 return 0; 1400 1399 } ··· 1436 1433 static unsigned int 1437 1434 __tm6000_poll(struct file *file, struct poll_table_struct *wait) 1438 1435 { 1436 + unsigned long req_events = poll_requested_events(wait); 1439 1437 struct tm6000_fh *fh = file->private_data; 1440 1438 struct tm6000_buffer *buf; 1439 + int res = 0; 1441 1440 1441 + if (v4l2_event_pending(&fh->fh)) 1442 + res = POLLPRI; 1443 + else if (req_events & POLLPRI) 1444 + poll_wait(file, &fh->fh.wait, wait); 1442 1445 if (V4L2_BUF_TYPE_VIDEO_CAPTURE != fh->type) 1443 - return POLLERR; 1446 + return res | POLLERR; 1444 1447 1445 1448 if (!!is_res_streaming(fh->dev, fh)) 1446 - return POLLERR; 1449 + return res | POLLERR; 1447 1450 1448 1451 if (!is_res_read(fh->dev, fh)) { 1449 1452 /* streaming capture */ 1450 1453 if (list_empty(&fh->vb_vidq.stream)) 1451 - return POLLERR; 1454 + return res | POLLERR; 1452 1455 buf = list_entry(fh->vb_vidq.stream.next, struct tm6000_buffer, vb.stream); 1453 - } else { 1456 + } else if (req_events & (POLLIN | POLLRDNORM)) { 1454 1457 /* read() capture */ 1455 - return videobuf_poll_stream(file, &fh->vb_vidq, wait); 1458 + return res | videobuf_poll_stream(file, &fh->vb_vidq, wait); 1456 1459 } 1457 1460 poll_wait(file, &buf->vb.done, wait); 1458 1461 if (buf->vb.state == VIDEOBUF_DONE || 1459 1462 buf->vb.state == VIDEOBUF_ERROR) 1460 - return POLLIN | POLLRDNORM; 1461 - return 0; 1463 + return res | POLLIN | POLLRDNORM; 1464 + return res; 1462 1465 } 1463 1466 1464 1467 static unsigned int tm6000_poll(struct file *file, struct poll_table_struct *wait) ··· 1514 1505 if (!fh->radio) 1515 1506 videobuf_mmap_free(&fh->vb_vidq); 1516 1507 } 1517 - 1508 + v4l2_fh_del(&fh->fh); 1509 + v4l2_fh_exit(&fh->fh); 1518 1510 kfree(fh); 1519 1511 mutex_unlock(&dev->lock); 1520 1512 ··· 1565 1555 .vidioc_querybuf = vidioc_querybuf, 1566 1556 .vidioc_qbuf = vidioc_qbuf, 1567 1557 .vidioc_dqbuf = vidioc_dqbuf, 1558 + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 1559 + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1568 1560 }; 1569 1561 1570 1562 static struct video_device tm6000_template = { ··· 1591 1579 .vidioc_s_tuner = radio_s_tuner, 1592 1580 .vidioc_g_frequency = vidioc_g_frequency, 1593 1581 .vidioc_s_frequency = vidioc_s_frequency, 1582 + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 1583 + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1594 1584 }; 1595 1585 1596 1586 static struct video_device tm6000_radio_template = { ··· 1621 1607 vfd->release = video_device_release; 1622 1608 vfd->debug = tm6000_debug; 1623 1609 vfd->lock = &dev->lock; 1610 + set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); 1624 1611 1625 1612 snprintf(vfd->name, sizeof(vfd->name), "%s %s", dev->name, type_name); 1626 1613
+2
drivers/media/usb/tm6000/tm6000.h
··· 28 28 #include <linux/mutex.h> 29 29 #include <media/v4l2-device.h> 30 30 #include <media/v4l2-ctrls.h> 31 + #include <media/v4l2-fh.h> 31 32 32 33 #include <linux/dvb/frontend.h> 33 34 #include "dvb_demux.h" ··· 291 290 }; 292 291 293 292 struct tm6000_fh { 293 + struct v4l2_fh fh; 294 294 struct tm6000_core *dev; 295 295 unsigned int radio; 296 296