This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
0047-v4l-subdev-Add-support-for-sub-streams.patch
170 lines (152 loc) · 5.06 KB
/
0047-v4l-subdev-Add-support-for-sub-streams.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Meng Wei <[email protected]>
Date: Fri, 26 Oct 2018 09:52:10 +0800
Subject: [PATCH] v4l: subdev: Add support for sub-streams
The stream id tells which stream the IOCTLs address.
The concept of stream ID makes it possible
to differentiate between several streams that
traverse the same image pipeline
but the properties of which are different.
Add pad flag MEDIA_PAD_FL_MULTIPLEX to indicate
which pad is multiplex.
Add format enumeration flag V4L2_SUBDEV_FLAG_NEXT_STREAM
to iterate stream id.
Signed-off-by: Chang Ying <[email protected]>
Signed-off-by: Meng Wei <[email protected]>
---
drivers/media/v4l2-core/v4l2-subdev.c | 6 ++++++
include/media/v4l2-subdev.h | 2 ++
include/uapi/linux/media.h | 1 +
include/uapi/linux/v4l2-subdev.h | 23 ++++++++++++++++++-----
4 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index 2b63fa6b6fc9..12eb646c4bc7 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -135,6 +135,9 @@ static int check_format(struct v4l2_subdev *sd,
if (format->pad >= sd->entity.num_pads)
return -EINVAL;
+ if (!(sd->flags & V4L2_SUBDEV_FL_HAS_SUBSTREAMS) && format->stream)
+ return -EINVAL;
+
return 0;
}
@@ -160,6 +163,9 @@ static int check_selection(struct v4l2_subdev *sd,
if (sel->pad >= sd->entity.num_pads)
return -EINVAL;
+ if (!(sd->flags & V4L2_SUBDEV_FL_HAS_SUBSTREAMS) && sel->stream)
+ return -EINVAL;
+
return 0;
}
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index 9102d6ca566e..6f87e7f81759 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -778,6 +778,8 @@ struct v4l2_subdev_internal_ops {
#define V4L2_SUBDEV_FL_HAS_DEVNODE (1U << 2)
/* Set this flag if this subdev generates events. */
#define V4L2_SUBDEV_FL_HAS_EVENTS (1U << 3)
+/* Set this flag if this sub-device supports substreams. */
+#define V4L2_SUBDEV_FL_HAS_SUBSTREAMS (1U << 4)
struct regulator_bulk_data;
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h
index 4506519c7b38..585a53bd1461 100644
--- a/include/uapi/linux/media.h
+++ b/include/uapi/linux/media.h
@@ -210,6 +210,7 @@ struct media_entity_desc {
#define MEDIA_PAD_FL_SINK (1 << 0)
#define MEDIA_PAD_FL_SOURCE (1 << 1)
#define MEDIA_PAD_FL_MUST_CONNECT (1 << 2)
+#define MEDIA_PAD_FL_MULTIPLEX (1 << 3)
struct media_pad_desc {
__u32 entity; /* entity ID */
diff --git a/include/uapi/linux/v4l2-subdev.h b/include/uapi/linux/v4l2-subdev.h
index 03970ce30741..51f637dff468 100644
--- a/include/uapi/linux/v4l2-subdev.h
+++ b/include/uapi/linux/v4l2-subdev.h
@@ -44,12 +44,14 @@ enum v4l2_subdev_format_whence {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @format: media bus format (format code and frame size)
+ * @stream: sub-stream id
*/
struct v4l2_subdev_format {
__u32 which;
__u32 pad;
struct v4l2_mbus_framefmt format;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -57,12 +59,14 @@ struct v4l2_subdev_format {
* @which: format type (from enum v4l2_subdev_format_whence)
* @pad: pad number, as reported by the media API
* @rect: pad crop rectangle boundaries
+ * @stream: sub-stream id
*/
struct v4l2_subdev_crop {
__u32 which;
__u32 pad;
struct v4l2_rect rect;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -71,13 +75,18 @@ struct v4l2_subdev_crop {
* @index: format index during enumeration
* @code: format code (MEDIA_BUS_FMT_ definitions)
* @which: format type (from enum v4l2_subdev_format_whence)
+ * @stream: sub-stream id
*/
+
+#define V4L2_SUBDEV_FLAG_NEXT_STREAM 0x80000000
+
struct v4l2_subdev_mbus_code_enum {
__u32 pad;
__u32 index;
__u32 code;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -86,6 +95,7 @@ struct v4l2_subdev_mbus_code_enum {
* @index: format index during enumeration
* @code: format code (MEDIA_BUS_FMT_ definitions)
* @which: format type (from enum v4l2_subdev_format_whence)
+ * @stream: sub-stream id
*/
struct v4l2_subdev_frame_size_enum {
__u32 index;
@@ -96,7 +106,8 @@ struct v4l2_subdev_frame_size_enum {
__u32 min_height;
__u32 max_height;
__u32 which;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/**
@@ -140,6 +151,7 @@ struct v4l2_subdev_frame_interval_enum {
* defined in v4l2-common.h; V4L2_SEL_TGT_* .
* @flags: constraint flags, defined in v4l2-common.h; V4L2_SEL_FLAG_*.
* @r: coordinates of the selection window
+ * @stream: sub-stream id
* @reserved: for future use, set to zero for now
*
* Hardware may use multiple helper windows to process a video stream.
@@ -152,7 +164,8 @@ struct v4l2_subdev_selection {
__u32 target;
__u32 flags;
struct v4l2_rect r;
- __u32 reserved[8];
+ __u32 stream;
+ __u32 reserved[7];
};
/* Backwards compatibility define --- to be removed */
--
https://clearlinux.org