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

[media] saa7146: support control events and priority handling

Use v4l2_fh which gives you control events and priority handling for free.

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
537fa492 9bb60193

+19 -6
+12 -6
drivers/media/common/saa7146_fops.c
··· 198 198 struct saa7146_dev *dev = video_drvdata(file); 199 199 struct saa7146_fh *fh = NULL; 200 200 int result = 0; 201 - 202 201 enum v4l2_buf_type type; 203 202 204 203 DEB_EE("file:%p, dev:%s\n", file, video_device_node_name(vdev)); ··· 226 227 goto out; 227 228 } 228 229 229 - file->private_data = fh; 230 + v4l2_fh_init(&fh->fh, vdev); 231 + 232 + file->private_data = &fh->fh; 230 233 fh->dev = dev; 231 234 232 235 if (vdev->vfl_type == VFL_TYPE_VBI) { ··· 252 251 } 253 252 254 253 result = 0; 254 + v4l2_fh_add(&fh->fh); 255 255 out: 256 256 if (fh && result != 0) { 257 257 kfree(fh); ··· 282 280 saa7146_video_uops.release(dev,file); 283 281 } 284 282 283 + v4l2_fh_del(&fh->fh); 284 + v4l2_fh_exit(&fh->fh); 285 285 module_put(dev->ext->module); 286 286 file->private_data = NULL; 287 287 kfree(fh); ··· 326 322 struct saa7146_fh *fh = file->private_data; 327 323 struct videobuf_buffer *buf = NULL; 328 324 struct videobuf_queue *q; 325 + unsigned int res = v4l2_ctrl_poll(file, wait); 329 326 330 327 DEB_EE("file:%p, poll:%p\n", file, wait); 331 328 332 329 if (vdev->vfl_type == VFL_TYPE_VBI) { 333 330 if( 0 == fh->vbi_q.streaming ) 334 - return videobuf_poll_stream(file, &fh->vbi_q, wait); 331 + return res | videobuf_poll_stream(file, &fh->vbi_q, wait); 335 332 q = &fh->vbi_q; 336 333 } else { 337 334 DEB_D("using video queue\n"); ··· 344 339 345 340 if (!buf) { 346 341 DEB_D("buf == NULL!\n"); 347 - return POLLERR; 342 + return res | POLLERR; 348 343 } 349 344 350 345 poll_wait(file, &buf->done, wait); 351 346 if (buf->state == VIDEOBUF_DONE || buf->state == VIDEOBUF_ERROR) { 352 347 DEB_D("poll succeeded!\n"); 353 - return POLLIN|POLLRDNORM; 348 + return res | POLLIN | POLLRDNORM; 354 349 } 355 350 356 351 DEB_D("nothing to poll for, buf->state:%d\n", buf->state); 357 - return 0; 352 + return res; 358 353 } 359 354 360 355 static ssize_t fops_read(struct file *file, char __user *data, size_t count, loff_t *ppos) ··· 588 583 vfd->lock = &dev->v4l2_lock; 589 584 vfd->v4l2_dev = &dev->v4l2_dev; 590 585 vfd->tvnorms = 0; 586 + set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); 591 587 for (i = 0; i < dev->ext_vv_data->num_stds; i++) 592 588 vfd->tvnorms |= dev->ext_vv_data->stds[i].id; 593 589 strlcpy(vfd->name, name, sizeof(vfd->name));
+4
drivers/media/common/saa7146_video.c
··· 2 2 3 3 #include <media/saa7146_vv.h> 4 4 #include <media/v4l2-chip-ident.h> 5 + #include <media/v4l2-event.h> 6 + #include <media/v4l2-ctrls.h> 5 7 #include <linux/module.h> 6 8 7 9 static int max_memory = 32; ··· 1023 1021 .vidioc_streamon = vidioc_streamon, 1024 1022 .vidioc_streamoff = vidioc_streamoff, 1025 1023 .vidioc_g_parm = vidioc_g_parm, 1024 + .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, 1025 + .vidioc_unsubscribe_event = v4l2_event_unsubscribe, 1026 1026 }; 1027 1027 1028 1028 /*********************************************************************************/
+3
include/media/saa7146_vv.h
··· 3 3 4 4 #include <media/v4l2-common.h> 5 5 #include <media/v4l2-ioctl.h> 6 + #include <media/v4l2-fh.h> 6 7 #include <media/saa7146.h> 7 8 #include <media/videobuf-dma-sg.h> 8 9 ··· 85 84 86 85 /* per open data */ 87 86 struct saa7146_fh { 87 + /* Must be the first field! */ 88 + struct v4l2_fh fh; 88 89 struct saa7146_dev *dev; 89 90 90 91 /* video capture */