[PATCH/RFC v2 5/9] media: i2c: ar0144: Add image stream

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In preparation for embedded data stream support, introduce a new
ar0144_stream_ids enumeration for stream IDs, with a single value,
AR0144_STREAM_IMAGE for the image data stream. Use it when accessing the
formats, crop and compose rectangles on the source pad. This is meant to
reduce the size of further commits, and doesn't introduce any functional
change.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
 drivers/media/i2c/ar0144.c | 35 ++++++++++++++++++++++++-----------
 1 file changed, 24 insertions(+), 11 deletions(-)

diff --git a/drivers/media/i2c/ar0144.c b/drivers/media/i2c/ar0144.c
index ea76d484e6d1..432f2dba58d2 100644
--- a/drivers/media/i2c/ar0144.c
+++ b/drivers/media/i2c/ar0144.c
@@ -342,6 +342,10 @@ enum ar0144_pad_ids {
 	AR0144_NUM_PADS,
 };
 
+enum ar0144_stream_ids {
+	AR0144_STREAM_IMAGE,
+};
+
 struct ar0144_model {
 	bool mono;
 };
@@ -534,7 +538,8 @@ static int ar0144_start_streaming(struct ar0144 *sensor,
 	 */
 	__v4l2_ctrl_grab(sensor->link_freq, true);
 
-	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					      AR0144_STREAM_IMAGE);
 	crop = v4l2_subdev_state_get_crop(state, AR0144_PAD_IMAGE);
 	compose = v4l2_subdev_state_get_compose(state, AR0144_PAD_IMAGE);
 	info = ar0144_format_info(sensor, format->code, true);
@@ -890,7 +895,8 @@ static int ar0144_s_ctrl(struct v4l2_ctrl *ctrl)
 	 * configuration.
 	 */
 	state = v4l2_subdev_get_locked_active_state(&sensor->sd);
-	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					      AR0144_STREAM_IMAGE);
 	info = ar0144_format_info(sensor, format->code, true);
 	crop = v4l2_subdev_state_get_crop(state, AR0144_PAD_IMAGE);
 
@@ -1180,7 +1186,8 @@ static int ar0144_enum_frame_size(struct v4l2_subdev *sd,
 		if (!info)
 			return -EINVAL;
 
-		fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+		fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+						   AR0144_STREAM_IMAGE);
 		break;
 
 	default:
@@ -1207,15 +1214,17 @@ static int ar0144_set_fmt(struct v4l2_subdev *sd,
 	    format->which == V4L2_SUBDEV_FORMAT_ACTIVE)
 		return -EBUSY;
 
-	/* The format can only be set on the source pad. */
-	if (format->pad != AR0144_PAD_SOURCE)
+	/* The format can only be set for the image stream on the source pad. */
+	if (format->pad != AR0144_PAD_SOURCE ||
+	    format->stream != AR0144_STREAM_IMAGE)
 		return v4l2_subdev_get_fmt(sd, state, format);
 
 	/*
 	 * Only the media bus code can be updated on the source pad, dimensions
 	 * are set by the compose on the image pad rectangle.
 	 */
-	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					   AR0144_STREAM_IMAGE);
 	info = ar0144_format_info(sensor, format->format.code, true);
 	fmt->code = ar0144_format_code(sensor, info);
 
@@ -1339,7 +1348,8 @@ static int ar0144_set_selection(struct v4l2_subdev *sd,
 	}
 
 	/* Propagate the compose rectangle to the output format. */
-	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					   AR0144_STREAM_IMAGE);
 	fmt->width = compose->width;
 	fmt->height = compose->height;
 
@@ -1359,7 +1369,8 @@ static int ar0144_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 		return -EINVAL;
 
 	state = v4l2_subdev_lock_and_get_active_state(sd);
-	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					   AR0144_STREAM_IMAGE);
 	code = fmt->code;
 	v4l2_subdev_unlock_state(state);
 
@@ -1369,7 +1380,7 @@ static int ar0144_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 	fd->num_entries = 1;
 
 	fd->entry[0].pixelcode = code;
-	fd->entry[0].stream = 0;
+	fd->entry[0].stream = AR0144_STREAM_IMAGE;
 	fd->entry[0].bus.csi2.vc = 0;
 	fd->entry[0].bus.csi2.dt = info->dt;
 
@@ -1467,7 +1478,8 @@ static int ar0144_entity_init_state(struct v4l2_subdev *sd,
 
 	info = ar0144_format_info(sensor, 0, true);
 
-	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	fmt = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					   AR0144_STREAM_IMAGE);
 	fmt->width = AR0144_DEF_WIDTH;
 	fmt->height = AR0144_DEF_HEIGHT;
 	fmt->code = ar0144_format_code(sensor, info);
@@ -1544,7 +1556,8 @@ static int ar0144_init_subdev(struct ar0144 *sensor)
 	 * rate) and blanking controls.
 	 */
 	state = v4l2_subdev_lock_and_get_active_state(sd);
-	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE);
+	format = v4l2_subdev_state_get_format(state, AR0144_PAD_SOURCE,
+					      AR0144_STREAM_IMAGE);
 	info = ar0144_format_info(sensor, format->code, true);
 
 	ar0144_update_link_freqs(sensor, info);
-- 
Regards,

Laurent Pinchart





[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux