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

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

[media] v4l: vsp1: Move video device out of struct vsp1_rwpf



To make the video device nodes optional we need to decouple the [rw]pf
instances from the video devices. Move video devices out of struct
vsp1_rwpf and instantiate them dynamically in the core driver code.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent f7ebf3ca
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ struct vsp1_device {
	struct vsp1_rwpf *wpf[VSP1_MAX_WPF];

	struct list_head entities;
	struct list_head videos;

	struct v4l2_device v4l2_dev;
	struct media_device media_dev;
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include "vsp1.h"
#include "vsp1_bru.h"
#include "vsp1_rwpf.h"
#include "vsp1_video.h"

#define BRU_MIN_SIZE				1U
#define BRU_MAX_SIZE				8190U
+33 −7
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
#include "vsp1_rwpf.h"
#include "vsp1_sru.h"
#include "vsp1_uds.h"
#include "vsp1_video.h"

/* -----------------------------------------------------------------------------
 * Interrupt Handling
@@ -88,8 +89,8 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)
		/* RPFs have no source entities, just connect their source pad
		 * to their video device.
		 */
		return media_create_pad_link(&rpf->video.video.entity, 0,
					     &rpf->entity.subdev.entity,
		return media_create_pad_link(&rpf->entity.video->video.entity,
					     0, &rpf->entity.subdev.entity,
					     RWPF_PAD_SINK,
					     MEDIA_LNK_FL_ENABLED |
					     MEDIA_LNK_FL_IMMUTABLE);
@@ -138,8 +139,8 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)

		return media_create_pad_link(&wpf->entity.subdev.entity,
					     RWPF_PAD_SOURCE,
					     &wpf->video.video.entity, 0,
					     flags);
					     &wpf->entity.video->video.entity,
					     0, flags);
	}

	return 0;
@@ -147,14 +148,19 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink)

static void vsp1_destroy_entities(struct vsp1_device *vsp1)
{
	struct vsp1_entity *entity;
	struct vsp1_entity *next;
	struct vsp1_entity *entity, *_entity;
	struct vsp1_video *video, *_video;

	list_for_each_entry_safe(entity, next, &vsp1->entities, list_dev) {
	list_for_each_entry_safe(entity, _entity, &vsp1->entities, list_dev) {
		list_del(&entity->list_dev);
		vsp1_entity_destroy(entity);
	}

	list_for_each_entry_safe(video, _video, &vsp1->videos, list) {
		list_del(&video->list);
		vsp1_video_cleanup(video);
	}

	v4l2_device_unregister(&vsp1->v4l2_dev);
	media_device_unregister(&vsp1->media_dev);
	media_device_cleanup(&vsp1->media_dev);
@@ -228,6 +234,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
	}

	for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
		struct vsp1_video *video;
		struct vsp1_rwpf *rpf;

		rpf = vsp1_rpf_create(vsp1, i);
@@ -238,6 +245,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)

		vsp1->rpf[i] = rpf;
		list_add_tail(&rpf->entity.list_dev, &vsp1->entities);

		video = vsp1_video_create(vsp1, rpf);
		if (IS_ERR(video)) {
			ret = PTR_ERR(video);
			goto done;
		}

		list_add_tail(&video->list, &vsp1->videos);
	}

	if (vsp1->pdata.features & VSP1_HAS_SRU) {
@@ -264,6 +279,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
	}

	for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
		struct vsp1_video *video;
		struct vsp1_rwpf *wpf;

		wpf = vsp1_wpf_create(vsp1, i);
@@ -274,6 +290,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)

		vsp1->wpf[i] = wpf;
		list_add_tail(&wpf->entity.list_dev, &vsp1->entities);

		video = vsp1_video_create(vsp1, wpf);
		if (IS_ERR(video)) {
			ret = PTR_ERR(video);
			goto done;
		}

		list_add_tail(&video->list, &vsp1->videos);
		wpf->entity.sink = &video->video.entity;
	}

	/* Register all subdevs. */
@@ -515,6 +540,7 @@ static int vsp1_probe(struct platform_device *pdev)
	vsp1->dev = &pdev->dev;
	mutex_init(&vsp1->lock);
	INIT_LIST_HEAD(&vsp1->entities);
	INIT_LIST_HEAD(&vsp1->videos);

	ret = vsp1_parse_dt(vsp1);
	if (ret < 0)
+0 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@

#include "vsp1.h"
#include "vsp1_entity.h"
#include "vsp1_video.h"

bool vsp1_entity_is_streaming(struct vsp1_entity *entity)
{
@@ -225,8 +224,6 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,

void vsp1_entity_destroy(struct vsp1_entity *entity)
{
	if (entity->video)
		vsp1_video_cleanup(entity->video);
	if (entity->subdev.ctrl_handler)
		v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
	media_entity_cleanup(&entity->subdev.entity);
+0 −13
Original line number Diff line number Diff line
@@ -217,7 +217,6 @@ static const struct vsp1_rwpf_operations rpf_vdev_ops = {
struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
{
	struct v4l2_subdev *subdev;
	struct vsp1_video *video;
	struct vsp1_rwpf *rpf;
	int ret;

@@ -264,18 +263,6 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
		goto error;
	}

	/* Initialize the video device. */
	video = &rpf->video;

	video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
	video->vsp1 = vsp1;

	ret = vsp1_video_init(video, rpf);
	if (ret < 0)
		goto error;

	rpf->entity.video = video;

	return rpf;

error:
Loading