Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b6af10cd authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

[media] v4l: vsp1: Move video operations to vsp1_rwpf



This removes the dependency of vsp1_rpf and vsp1_wpf on vsp1_video,
making it possible to reuse the operations without a V4L2 video device
node.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 86960eec
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -186,10 +186,8 @@ static struct v4l2_subdev_ops rpf_ops = {
 * Video Device Operations
 * Video Device Operations
 */
 */


static void rpf_vdev_queue(struct vsp1_video *video,
static void rpf_buf_queue(struct vsp1_rwpf *rpf, struct vsp1_video_buffer *buf)
			   struct vsp1_video_buffer *buf)
{
{
	struct vsp1_rwpf *rpf = container_of(video, struct vsp1_rwpf, video);
	unsigned int i;
	unsigned int i;


	for (i = 0; i < 3; ++i)
	for (i = 0; i < 3; ++i)
@@ -208,8 +206,8 @@ static void rpf_vdev_queue(struct vsp1_video *video,
			       buf->addr[2] + rpf->offsets[1]);
			       buf->addr[2] + rpf->offsets[1]);
}
}


static const struct vsp1_video_operations rpf_vdev_ops = {
static const struct vsp1_rwpf_operations rpf_vdev_ops = {
	.queue = rpf_vdev_queue,
	.queue = rpf_buf_queue,
};
};


/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
@@ -227,6 +225,8 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
	if (rpf == NULL)
	if (rpf == NULL)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	rpf->ops = &rpf_vdev_ops;

	rpf->max_width = RPF_MAX_WIDTH;
	rpf->max_width = RPF_MAX_WIDTH;
	rpf->max_height = RPF_MAX_HEIGHT;
	rpf->max_height = RPF_MAX_HEIGHT;


@@ -269,7 +269,6 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)


	video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
	video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
	video->vsp1 = vsp1;
	video->vsp1 = vsp1;
	video->ops = &rpf_vdev_ops;


	ret = vsp1_video_init(video, rpf);
	ret = vsp1_video_init(video, rpf);
	if (ret < 0)
	if (ret < 0)
+9 −0
Original line number Original line Diff line number Diff line
@@ -24,11 +24,20 @@
#define RWPF_PAD_SINK				0
#define RWPF_PAD_SINK				0
#define RWPF_PAD_SOURCE				1
#define RWPF_PAD_SOURCE				1


struct vsp1_rwpf;
struct vsp1_video_buffer;

struct vsp1_rwpf_operations {
	void (*queue)(struct vsp1_rwpf *rwpf, struct vsp1_video_buffer *buf);
};

struct vsp1_rwpf {
struct vsp1_rwpf {
	struct vsp1_entity entity;
	struct vsp1_entity entity;
	struct vsp1_video video;
	struct vsp1_video video;
	struct v4l2_ctrl_handler ctrls;
	struct v4l2_ctrl_handler ctrls;


	const struct vsp1_rwpf_operations *ops;

	unsigned int max_width;
	unsigned int max_width;
	unsigned int max_height;
	unsigned int max_height;


+2 −2
Original line number Original line Diff line number Diff line
@@ -646,7 +646,7 @@ static void vsp1_video_frame_end(struct vsp1_pipeline *pipe,


	spin_lock_irqsave(&pipe->irqlock, flags);
	spin_lock_irqsave(&pipe->irqlock, flags);


	video->ops->queue(video, buf);
	video->rwpf->ops->queue(video->rwpf, buf);
	pipe->buffers_ready |= 1 << video->pipe_index;
	pipe->buffers_ready |= 1 << video->pipe_index;


	spin_unlock_irqrestore(&pipe->irqlock, flags);
	spin_unlock_irqrestore(&pipe->irqlock, flags);
@@ -873,7 +873,7 @@ static void vsp1_video_buffer_queue(struct vb2_buffer *vb)


	spin_lock_irqsave(&pipe->irqlock, flags);
	spin_lock_irqsave(&pipe->irqlock, flags);


	video->ops->queue(video, buf);
	video->rwpf->ops->queue(video->rwpf, buf);
	pipe->buffers_ready |= 1 << video->pipe_index;
	pipe->buffers_ready |= 1 << video->pipe_index;


	if (vb2_is_streaming(&video->queue) &&
	if (vb2_is_streaming(&video->queue) &&
+0 −6
Original line number Original line Diff line number Diff line
@@ -108,16 +108,10 @@ to_vsp1_video_buffer(struct vb2_v4l2_buffer *vbuf)
	return container_of(vbuf, struct vsp1_video_buffer, buf);
	return container_of(vbuf, struct vsp1_video_buffer, buf);
}
}


struct vsp1_video_operations {
	void (*queue)(struct vsp1_video *video, struct vsp1_video_buffer *buf);
};

struct vsp1_video {
struct vsp1_video {
	struct vsp1_device *vsp1;
	struct vsp1_device *vsp1;
	struct vsp1_rwpf *rwpf;
	struct vsp1_rwpf *rwpf;


	const struct vsp1_video_operations *ops;

	struct video_device video;
	struct video_device video;
	enum v4l2_buf_type type;
	enum v4l2_buf_type type;
	struct media_pad pad;
	struct media_pad pad;
+5 −7
Original line number Original line Diff line number Diff line
@@ -195,11 +195,8 @@ static struct v4l2_subdev_ops wpf_ops = {
 * Video Device Operations
 * Video Device Operations
 */
 */


static void wpf_vdev_queue(struct vsp1_video *video,
static void wpf_buf_queue(struct vsp1_rwpf *wpf, struct vsp1_video_buffer *buf)
			   struct vsp1_video_buffer *buf)
{
{
	struct vsp1_rwpf *wpf = container_of(video, struct vsp1_rwpf, video);

	vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, buf->addr[0]);
	vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_Y, buf->addr[0]);
	if (buf->buf.vb2_buf.num_planes > 1)
	if (buf->buf.vb2_buf.num_planes > 1)
		vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, buf->addr[1]);
		vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C0, buf->addr[1]);
@@ -207,8 +204,8 @@ static void wpf_vdev_queue(struct vsp1_video *video,
		vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, buf->addr[2]);
		vsp1_wpf_write(wpf, VI6_WPF_DSTM_ADDR_C1, buf->addr[2]);
}
}


static const struct vsp1_video_operations wpf_vdev_ops = {
static const struct vsp1_rwpf_operations wpf_vdev_ops = {
	.queue = wpf_vdev_queue,
	.queue = wpf_buf_queue,
};
};


/* -----------------------------------------------------------------------------
/* -----------------------------------------------------------------------------
@@ -226,6 +223,8 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
	if (wpf == NULL)
	if (wpf == NULL)
		return ERR_PTR(-ENOMEM);
		return ERR_PTR(-ENOMEM);


	wpf->ops = &wpf_vdev_ops;

	wpf->max_width = WPF_MAX_WIDTH;
	wpf->max_width = WPF_MAX_WIDTH;
	wpf->max_height = WPF_MAX_HEIGHT;
	wpf->max_height = WPF_MAX_HEIGHT;


@@ -268,7 +267,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)


	video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
	video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
	video->vsp1 = vsp1;
	video->vsp1 = vsp1;
	video->ops = &wpf_vdev_ops;


	ret = vsp1_video_init(video, wpf);
	ret = vsp1_video_init(video, wpf);
	if (ret < 0)
	if (ret < 0)