--- zzzz-none-000/linux-3.10.107/drivers/media/pci/cx18/cx18-fileops.c 2017-06-27 09:49:32.000000000 +0000 +++ scorpion-7490-727/linux-3.10.107/drivers/media/pci/cx18/cx18-fileops.c 2021-02-04 17:41:59.000000000 +0000 @@ -34,6 +34,7 @@ #include "cx18-controls.h" #include "cx18-ioctl.h" #include "cx18-cards.h" +#include /* This function tries to claim the stream for a specific file descriptor. If no one else is using this stream then the stream is claimed and @@ -609,13 +610,16 @@ unsigned int cx18_v4l2_enc_poll(struct file *filp, poll_table *wait) { + unsigned long req_events = poll_requested_events(wait); struct cx18_open_id *id = file2id(filp); struct cx18 *cx = id->cx; struct cx18_stream *s = &cx->streams[id->type]; int eof = test_bit(CX18_F_S_STREAMOFF, &s->s_flags); + unsigned res = 0; /* Start a capture if there is none */ - if (!eof && !test_bit(CX18_F_S_STREAMING, &s->s_flags)) { + if (!eof && !test_bit(CX18_F_S_STREAMING, &s->s_flags) && + (req_events & (POLLIN | POLLRDNORM))) { int rc; mutex_lock(&cx->serialize_lock); @@ -632,21 +636,26 @@ if ((s->vb_type == V4L2_BUF_TYPE_VIDEO_CAPTURE) && (id->type == CX18_ENC_STREAM_TYPE_YUV)) { int videobuf_poll = videobuf_poll_stream(filp, &s->vbuf_q, wait); + + if (v4l2_event_pending(&id->fh)) + res |= POLLPRI; if (eof && videobuf_poll == POLLERR) - return POLLHUP; - else - return videobuf_poll; + return res | POLLHUP; + return res | videobuf_poll; } /* add stream's waitq to the poll list */ CX18_DEBUG_HI_FILE("Encoder poll\n"); - poll_wait(filp, &s->waitq, wait); + if (v4l2_event_pending(&id->fh)) + res |= POLLPRI; + else + poll_wait(filp, &s->waitq, wait); if (atomic_read(&s->q_full.depth)) - return POLLIN | POLLRDNORM; + return res | POLLIN | POLLRDNORM; if (eof) - return POLLHUP; - return 0; + return res | POLLHUP; + return res; } int cx18_v4l2_mmap(struct file *file, struct vm_area_struct *vma) @@ -760,7 +769,7 @@ /* Mark that the radio is no longer in use */ clear_bit(CX18_F_I_RADIO_USER, &cx->i_flags); /* Switch tuner to TV */ - cx18_call_all(cx, core, s_std, cx->std); + cx18_call_all(cx, video, s_std, cx->std); /* Select correct audio input (i.e. TV tuner or Line in) */ cx18_audio_set_io(cx); if (atomic_read(&cx->ana_capturing) > 0) { @@ -797,7 +806,7 @@ CX18_DEBUG_WARN("nomem on v4l2 open\n"); return -ENOMEM; } - v4l2_fh_init(&item->fh, s->video_dev); + v4l2_fh_init(&item->fh, &s->video_dev); item->cx = cx; item->type = s->type;