Commit bc7584b0 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab
Browse files

[media] exynos4-is: Add struct exynos_video_entity



This patch introduces common structure for the video entities
to handle all video nodes and media pipelines associated with
them in more generic way.

Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 045a1fac
Loading
Loading
Loading
Loading
+25 −18
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@ static void buffer_queue(struct vb2_buffer *vb);
int fimc_capture_resume(struct fimc_dev *fimc)
{
	struct fimc_vid_cap *vid_cap = &fimc->vid_cap;
	struct exynos_video_entity *ve = &vid_cap->ve;
	struct fimc_vid_buffer *buf;
	int i;

@@ -329,7 +330,7 @@ int fimc_capture_resume(struct fimc_dev *fimc)
	INIT_LIST_HEAD(&fimc->vid_cap.active_buf_q);
	vid_cap->buf_index = 0;
	fimc_pipeline_call(fimc, open, &fimc->pipeline,
			   &vid_cap->vfd.entity, false);
			   &ve->vdev.entity, false);
	fimc_capture_hw_init(fimc);

	clear_bit(ST_CAPT_SUSPENDED, &fimc->state);
@@ -397,7 +398,7 @@ static int buffer_prepare(struct vb2_buffer *vb)
		unsigned long size = ctx->d_frame.payload[i];

		if (vb2_plane_size(vb, i) < size) {
			v4l2_err(&ctx->fimc_dev->vid_cap.vfd,
			v4l2_err(&ctx->fimc_dev->vid_cap.ve.vdev,
				 "User buffer too small (%ld < %ld)\n",
				 vb2_plane_size(vb, i), size);
			return -EINVAL;
@@ -415,6 +416,7 @@ static void buffer_queue(struct vb2_buffer *vb)
	struct fimc_ctx *ctx = vb2_get_drv_priv(vb->vb2_queue);
	struct fimc_dev *fimc = ctx->fimc_dev;
	struct fimc_vid_cap *vid_cap = &fimc->vid_cap;
	struct exynos_video_entity *ve = &vid_cap->ve;
	unsigned long flags;
	int min_bufs;

@@ -454,7 +456,7 @@ static void buffer_queue(struct vb2_buffer *vb)

		ret = fimc_pipeline_call(fimc, set_stream, &fimc->pipeline, 1);
		if (ret < 0)
			v4l2_err(&vid_cap->vfd, "stream on failed: %d\n", ret);
			v4l2_err(&ve->vdev, "stream on failed: %d\n", ret);
		return;
	}
	spin_unlock_irqrestore(&fimc->slock, flags);
@@ -503,11 +505,12 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc);
static int fimc_capture_open(struct file *file)
{
	struct fimc_dev *fimc = video_drvdata(file);
	struct exynos_video_entity *ve = &fimc->vid_cap.ve;
	int ret = -EBUSY;

	dbg("pid: %d, state: 0x%lx", task_pid_nr(current), fimc->state);

	fimc_md_graph_lock(fimc);
	fimc_md_graph_lock(ve);
	mutex_lock(&fimc->lock);

	if (fimc_m2m_active(fimc))
@@ -526,7 +529,7 @@ static int fimc_capture_open(struct file *file)

	if (v4l2_fh_is_singular_file(file)) {
		ret = fimc_pipeline_call(fimc, open, &fimc->pipeline,
					 &fimc->vid_cap.vfd.entity, true);
					 &fimc->vid_cap.ve.vdev.entity, true);

		if (!ret && !fimc->vid_cap.user_subdev_api)
			ret = fimc_capture_set_default_format(fimc);
@@ -544,7 +547,7 @@ static int fimc_capture_open(struct file *file)
	}
unlock:
	mutex_unlock(&fimc->lock);
	fimc_md_graph_unlock(fimc);
	fimc_md_graph_unlock(ve);
	return ret;
}

@@ -560,7 +563,7 @@ static int fimc_capture_release(struct file *file)

	if (v4l2_fh_is_singular_file(file)) {
		if (vc->streaming) {
			media_entity_pipeline_stop(&vc->vfd.entity);
			media_entity_pipeline_stop(&vc->ve.vdev.entity);
			vc->streaming = false;
		}
		clear_bit(ST_CAPT_BUSY, &fimc->state);
@@ -935,11 +938,12 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh,
	struct v4l2_pix_format_mplane *pix = &f->fmt.pix_mp;
	struct fimc_dev *fimc = video_drvdata(file);
	struct fimc_ctx *ctx = fimc->vid_cap.ctx;
	struct exynos_video_entity *ve = &fimc->vid_cap.ve;
	struct v4l2_mbus_framefmt mf;
	struct fimc_fmt *ffmt = NULL;
	int ret = 0;

	fimc_md_graph_lock(fimc);
	fimc_md_graph_lock(ve);
	mutex_lock(&fimc->lock);

	if (fimc_jpeg_fourcc(pix->pixelformat)) {
@@ -975,7 +979,7 @@ static int fimc_cap_try_fmt_mplane(struct file *file, void *fh,
					pix->plane_fmt, ffmt->memplanes, true);
unlock:
	mutex_unlock(&fimc->lock);
	fimc_md_graph_unlock(fimc);
	fimc_md_graph_unlock(ve);

	return ret;
}
@@ -1076,7 +1080,7 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
	struct fimc_dev *fimc = video_drvdata(file);
	int ret;

	fimc_md_graph_lock(fimc);
	fimc_md_graph_lock(&fimc->vid_cap.ve);
	mutex_lock(&fimc->lock);
	/*
	 * The graph is walked within __fimc_capture_set_format() to set
@@ -1088,8 +1092,8 @@ static int fimc_cap_s_fmt_mplane(struct file *file, void *priv,
	 */
	ret = __fimc_capture_set_format(fimc, f);

	fimc_md_graph_unlock(&fimc->vid_cap.ve);
	mutex_unlock(&fimc->lock);
	fimc_md_graph_unlock(fimc);
	return ret;
}

@@ -1209,7 +1213,7 @@ static int fimc_cap_streamon(struct file *file, void *priv,
	struct fimc_dev *fimc = video_drvdata(file);
	struct fimc_pipeline *p = &fimc->pipeline;
	struct fimc_vid_cap *vc = &fimc->vid_cap;
	struct media_entity *entity = &vc->vfd.entity;
	struct media_entity *entity = &vc->ve.vdev.entity;
	struct fimc_source_info *si = NULL;
	struct v4l2_subdev *sd;
	int ret;
@@ -1259,14 +1263,15 @@ static int fimc_cap_streamoff(struct file *file, void *priv,
			    enum v4l2_buf_type type)
{
	struct fimc_dev *fimc = video_drvdata(file);
	struct fimc_vid_cap *vc = &fimc->vid_cap;
	int ret;

	ret = vb2_ioctl_streamoff(file, priv, type);
	if (ret < 0)
		return ret;

	media_entity_pipeline_stop(&fimc->vid_cap.vfd.entity);
	fimc->vid_cap.streaming = false;
	media_entity_pipeline_stop(&vc->ve.vdev.entity);
	vc->streaming = false;
	return 0;
}

@@ -1735,7 +1740,7 @@ static int fimc_capture_set_default_format(struct fimc_dev *fimc)
static int fimc_register_capture_device(struct fimc_dev *fimc,
				 struct v4l2_device *v4l2_dev)
{
	struct video_device *vfd = &fimc->vid_cap.vfd;
	struct video_device *vfd = &fimc->vid_cap.ve.vdev;
	struct vb2_queue *q = &fimc->vid_cap.vbq;
	struct fimc_ctx *ctx;
	struct fimc_vid_cap *vid_cap;
@@ -1840,15 +1845,17 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd)
static void fimc_capture_subdev_unregistered(struct v4l2_subdev *sd)
{
	struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
	struct video_device *vdev;

	if (fimc == NULL)
		return;

	fimc_unregister_m2m_device(fimc);
	vdev = &fimc->vid_cap.ve.vdev;

	if (video_is_registered(&fimc->vid_cap.vfd)) {
		video_unregister_device(&fimc->vid_cap.vfd);
		media_entity_cleanup(&fimc->vid_cap.vfd.entity);
	if (video_is_registered(vdev)) {
		video_unregister_device(vdev);
		media_entity_cleanup(&vdev->entity);
		fimc->pipeline_ops = NULL;
	}
	kfree(fimc->vid_cap.ctx);
+2 −2
Original line number Diff line number Diff line
@@ -283,8 +283,8 @@ struct fimc_m2m_device {
/**
 * struct fimc_vid_cap - camera capture device information
 * @ctx: hardware context data
 * @vfd: video device node for camera capture mode
 * @subdev: subdev exposing the FIMC processing block
 * @ve: exynos video device entity structure
 * @vd_pad: fimc video capture node pad
 * @sd_pads: fimc video processing block pads
 * @ci_fmt: image format at the FIMC camera input (and the scaler output)
@@ -305,8 +305,8 @@ struct fimc_m2m_device {
struct fimc_vid_cap {
	struct fimc_ctx			*ctx;
	struct vb2_alloc_ctx		*alloc_ctx;
	struct video_device		vfd;
	struct v4l2_subdev		subdev;
	struct exynos_video_entity	ve;
	struct media_pad		vd_pad;
	struct media_pad		sd_pads[FIMC_SD_PADS_NUM];
	struct v4l2_mbus_framefmt	ci_fmt;
+1 −1
Original line number Diff line number Diff line
@@ -137,7 +137,7 @@ void flite_hw_set_source_format(struct fimc_lite *dev, struct flite_frame *f)
	}

	if (i == 0 && src_pixfmt_map[i][0] != pixelcode) {
		v4l2_err(&dev->vfd,
		v4l2_err(&dev->ve.vdev,
			 "Unsupported pixel code, falling back to %#08x\n",
			 src_pixfmt_map[i][0]);
	}
+10 −10
Original line number Diff line number Diff line
@@ -392,7 +392,7 @@ static int buffer_prepare(struct vb2_buffer *vb)
		unsigned long size = fimc->payload[i];

		if (vb2_plane_size(vb, i) < size) {
			v4l2_err(&fimc->vfd,
			v4l2_err(&fimc->ve.vdev,
				 "User buffer too small (%ld < %ld)\n",
				 vb2_plane_size(vb, i), size);
			return -EINVAL;
@@ -458,7 +458,7 @@ static void fimc_lite_clear_event_counters(struct fimc_lite *fimc)
static int fimc_lite_open(struct file *file)
{
	struct fimc_lite *fimc = video_drvdata(file);
	struct media_entity *me = &fimc->vfd.entity;
	struct media_entity *me = &fimc->ve.vdev.entity;
	int ret;

	mutex_lock(&me->parent->graph_mutex);
@@ -509,7 +509,7 @@ static int fimc_lite_release(struct file *file)
	if (v4l2_fh_is_singular_file(file) &&
	    atomic_read(&fimc->out_path) == FIMC_IO_DMA) {
		if (fimc->streaming) {
			media_entity_pipeline_stop(&fimc->vfd.entity);
			media_entity_pipeline_stop(&fimc->ve.vdev.entity);
			fimc->streaming = false;
		}
		clear_bit(ST_FLITE_IN_USE, &fimc->state);
@@ -792,7 +792,7 @@ static int fimc_lite_streamon(struct file *file, void *priv,
			      enum v4l2_buf_type type)
{
	struct fimc_lite *fimc = video_drvdata(file);
	struct media_entity *entity = &fimc->vfd.entity;
	struct media_entity *entity = &fimc->ve.vdev.entity;
	struct fimc_pipeline *p = &fimc->pipeline;
	int ret;

@@ -830,7 +830,7 @@ static int fimc_lite_streamoff(struct file *file, void *priv,
	if (ret < 0)
		return ret;

	media_entity_pipeline_stop(&fimc->vfd.entity);
	media_entity_pipeline_stop(&fimc->ve.vdev.entity);
	fimc->streaming = false;
	return 0;
}
@@ -1234,7 +1234,7 @@ static int fimc_lite_subdev_registered(struct v4l2_subdev *sd)
{
	struct fimc_lite *fimc = v4l2_get_subdevdata(sd);
	struct vb2_queue *q = &fimc->vb_queue;
	struct video_device *vfd = &fimc->vfd;
	struct video_device *vfd = &fimc->ve.vdev;
	int ret;

	memset(vfd, 0, sizeof(*vfd));
@@ -1298,9 +1298,9 @@ static void fimc_lite_subdev_unregistered(struct v4l2_subdev *sd)
	if (fimc == NULL)
		return;

	if (video_is_registered(&fimc->vfd)) {
		video_unregister_device(&fimc->vfd);
		media_entity_cleanup(&fimc->vfd.entity);
	if (video_is_registered(&fimc->ve.vdev)) {
		video_unregister_device(&fimc->ve.vdev);
		media_entity_cleanup(&fimc->ve.vdev.entity);
		fimc->pipeline_ops = NULL;
	}
}
@@ -1548,7 +1548,7 @@ static int fimc_lite_resume(struct device *dev)

	INIT_LIST_HEAD(&fimc->active_buf_q);
	fimc_pipeline_call(fimc, open, &fimc->pipeline,
			   &fimc->vfd.entity, false);
			   &fimc->ve.vdev.entity, false);
	fimc_lite_hw_init(fimc, atomic_read(&fimc->out_path) == FIMC_IO_ISP);
	clear_bit(ST_FLITE_SUSPENDED, &fimc->state);

+2 −2
Original line number Diff line number Diff line
@@ -95,8 +95,8 @@ struct flite_buffer {
 * struct fimc_lite - fimc lite structure
 * @pdev: pointer to FIMC-LITE platform device
 * @dd: SoC specific driver data structure
 * @ve: exynos video device entity structure
 * @v4l2_dev: pointer to top the level v4l2_device
 * @vfd: video device node
 * @fh: v4l2 file handle
 * @alloc_ctx: videobuf2 memory allocator context
 * @subdev: FIMC-LITE subdev
@@ -130,8 +130,8 @@ struct flite_buffer {
struct fimc_lite {
	struct platform_device	*pdev;
	struct flite_drvdata	*dd;
	struct exynos_video_entity ve;
	struct v4l2_device	*v4l2_dev;
	struct video_device	vfd;
	struct v4l2_fh		fh;
	struct vb2_alloc_ctx	*alloc_ctx;
	struct v4l2_subdev	subdev;
Loading