[glsdk/meta-ti-glsdk.git] / recipes-bsp / linux / linux-omap / media / 0025-v4l-subdev-Add-a-new-file-operations-class.patch
1 From 4dc43ce10d8b66537a680635d4f2dbe0a1daa1d9 Mon Sep 17 00:00:00 2001
2 From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
3 Date: Mon, 2 Aug 2010 00:05:09 +0200
4 Subject: [PATCH 25/43] v4l: subdev: Add a new file operations class
6 V4L2 sub-devices store pad formats and crop settings in the file handle.
7 To let drivers initialize those settings properly, add a file::open
8 operation that is called when the subdev is opened as well as a
9 corresponding file::close operation.
11 Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
12 ---
13 drivers/media/video/v4l2-subdev.c | 13 ++++++++++---
14 include/media/v4l2-subdev.h | 10 ++++++++++
15 2 files changed, 20 insertions(+), 3 deletions(-)
17 diff --git a/drivers/media/video/v4l2-subdev.c b/drivers/media/video/v4l2-subdev.c
18 index 15449fc..0f904e2 100644
19 --- a/drivers/media/video/v4l2-subdev.c
20 +++ b/drivers/media/video/v4l2-subdev.c
21 @@ -61,7 +61,7 @@ static int subdev_open(struct file *file)
22 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
23 struct v4l2_subdev_fh *subdev_fh;
24 #if defined(CONFIG_MEDIA_CONTROLLER)
25 - struct media_entity *entity;
26 + struct media_entity *entity = NULL;
27 #endif
28 int ret;
30 @@ -104,9 +104,17 @@ static int subdev_open(struct file *file)
31 }
32 #endif
34 + ret = v4l2_subdev_call(sd, file, open, subdev_fh);
35 + if (ret < 0 && ret != -ENOIOCTLCMD)
36 + goto err;
37 +
38 return 0;
40 err:
41 +#if defined(CONFIG_MEDIA_CONTROLLER)
42 + if (entity)
43 + media_entity_put(entity);
44 +#endif
45 v4l2_fh_del(&subdev_fh->vfh);
46 v4l2_fh_exit(&subdev_fh->vfh);
47 subdev_fh_free(subdev_fh);
48 @@ -117,13 +125,12 @@ err:
50 static int subdev_close(struct file *file)
51 {
52 -#if defined(CONFIG_MEDIA_CONTROLLER)
53 struct video_device *vdev = video_devdata(file);
54 struct v4l2_subdev *sd = vdev_to_v4l2_subdev(vdev);
55 -#endif
56 struct v4l2_fh *vfh = file->private_data;
57 struct v4l2_subdev_fh *subdev_fh = to_v4l2_subdev_fh(vfh);
59 + v4l2_subdev_call(sd, file, close, subdev_fh);
60 #if defined(CONFIG_MEDIA_CONTROLLER)
61 if (sd->v4l2_dev->mdev)
62 media_entity_put(&sd->entity);
63 diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
64 index f8704ff..af704df 100644
65 --- a/include/media/v4l2-subdev.h
66 +++ b/include/media/v4l2-subdev.h
67 @@ -175,6 +175,15 @@ struct v4l2_subdev_core_ops {
68 struct v4l2_event_subscription *sub);
69 };
71 +/* open: called when the subdev device node is opened by an application.
72 +
73 + close: called when the subdev device node is close.
74 + */
75 +struct v4l2_subdev_file_ops {
76 + int (*open)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
77 + int (*close)(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh);
78 +};
79 +
80 /* s_mode: switch the tuner to a specific tuner mode. Replacement of s_radio.
82 s_radio: v4l device was opened in Radio mode, to be replaced by s_mode.
83 @@ -416,6 +425,7 @@ struct v4l2_subdev_ir_ops {
85 struct v4l2_subdev_ops {
86 const struct v4l2_subdev_core_ops *core;
87 + const struct v4l2_subdev_file_ops *file;
88 const struct v4l2_subdev_tuner_ops *tuner;
89 const struct v4l2_subdev_audio_ops *audio;
90 const struct v4l2_subdev_video_ops *video;
91 --
92 1.6.6.1