Skip to content

Commit

Permalink
v4l: subdev: Add support for sub-streams
Browse files Browse the repository at this point in the history
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: Wanhui Sun <wanhui.sun@intel.com>
Signed-off-by: Chen Meng J <meng.j.chen@intel.com>
Signed-off-by: Meng Wei <wei.meng@intel.com>
  • Loading branch information
wanhuisu authored and krispan-intel committed Jul 2, 2021
1 parent e822d33 commit f139781
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions drivers/media/v4l2-core/v4l2-subdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ static inline int check_format(struct v4l2_subdev *sd,
if (!format)
return -EINVAL;

if (!(sd->flags & V4L2_SUBDEV_FL_HAS_SUBSTREAMS) && format->stream)
return -EINVAL;

return check_which(format->which) ? : check_pad(sd, format->pad) ? :
check_cfg(format->which, cfg);
}
Expand Down
2 changes: 2 additions & 0 deletions include/media/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,8 @@ struct v4l2_subdev_internal_ops {
* should set this flag.
*/
#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;

Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/media.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
23 changes: 18 additions & 5 deletions include/uapi/linux/v4l2-subdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,29 @@ 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];
};

/**
* struct v4l2_subdev_crop - Pad-level crop settings
* @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];
};

#define V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE 0x00000001
Expand All @@ -78,14 +82,19 @@ struct v4l2_subdev_crop {
* @code: format code (MEDIA_BUS_FMT_ definitions)
* @which: format type (from enum v4l2_subdev_format_whence)
* @flags: flags set by the driver, (V4L2_SUBDEV_MBUS_CODE_*)
* @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 flags;
__u32 reserved[7];
__u32 stream;
__u32 reserved[6];
};

/**
Expand All @@ -94,6 +103,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;
Expand All @@ -104,7 +114,8 @@ struct v4l2_subdev_frame_size_enum {
__u32 min_height;
__u32 max_height;
__u32 which;
__u32 reserved[8];
__u32 stream;
__u32 reserved[7];
};

/**
Expand Down Expand Up @@ -148,6 +159,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.
Expand All @@ -160,7 +172,8 @@ struct v4l2_subdev_selection {
__u32 target;
__u32 flags;
struct v4l2_rect r;
__u32 reserved[8];
__u32 stream;
__u32 reserved[7];
};

/**
Expand Down

0 comments on commit f139781

Please sign in to comment.