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

[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
...@@ -71,6 +71,7 @@ struct vsp1_device { ...@@ -71,6 +71,7 @@ struct vsp1_device {
struct vsp1_rwpf *wpf[VSP1_MAX_WPF]; struct vsp1_rwpf *wpf[VSP1_MAX_WPF];
struct list_head entities; struct list_head entities;
struct list_head videos;
struct v4l2_device v4l2_dev; struct v4l2_device v4l2_dev;
struct media_device media_dev; struct media_device media_dev;
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include "vsp1.h" #include "vsp1.h"
#include "vsp1_bru.h" #include "vsp1_bru.h"
#include "vsp1_rwpf.h" #include "vsp1_rwpf.h"
#include "vsp1_video.h"
#define BRU_MIN_SIZE 1U #define BRU_MIN_SIZE 1U
#define BRU_MAX_SIZE 8190U #define BRU_MAX_SIZE 8190U
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "vsp1_rwpf.h" #include "vsp1_rwpf.h"
#include "vsp1_sru.h" #include "vsp1_sru.h"
#include "vsp1_uds.h" #include "vsp1_uds.h"
#include "vsp1_video.h"
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Interrupt Handling * Interrupt Handling
...@@ -88,8 +89,8 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink) ...@@ -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 /* RPFs have no source entities, just connect their source pad
* to their video device. * to their video device.
*/ */
return media_create_pad_link(&rpf->video.video.entity, 0, return media_create_pad_link(&rpf->entity.video->video.entity,
&rpf->entity.subdev.entity, 0, &rpf->entity.subdev.entity,
RWPF_PAD_SINK, RWPF_PAD_SINK,
MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE); MEDIA_LNK_FL_IMMUTABLE);
...@@ -138,8 +139,8 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink) ...@@ -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, return media_create_pad_link(&wpf->entity.subdev.entity,
RWPF_PAD_SOURCE, RWPF_PAD_SOURCE,
&wpf->video.video.entity, 0, &wpf->entity.video->video.entity,
flags); 0, flags);
} }
return 0; return 0;
...@@ -147,14 +148,19 @@ static int vsp1_create_links(struct vsp1_device *vsp1, struct vsp1_entity *sink) ...@@ -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) static void vsp1_destroy_entities(struct vsp1_device *vsp1)
{ {
struct vsp1_entity *entity; struct vsp1_entity *entity, *_entity;
struct vsp1_entity *next; 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); list_del(&entity->list_dev);
vsp1_entity_destroy(entity); 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); v4l2_device_unregister(&vsp1->v4l2_dev);
media_device_unregister(&vsp1->media_dev); media_device_unregister(&vsp1->media_dev);
media_device_cleanup(&vsp1->media_dev); media_device_cleanup(&vsp1->media_dev);
...@@ -228,6 +234,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ...@@ -228,6 +234,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
} }
for (i = 0; i < vsp1->pdata.rpf_count; ++i) { for (i = 0; i < vsp1->pdata.rpf_count; ++i) {
struct vsp1_video *video;
struct vsp1_rwpf *rpf; struct vsp1_rwpf *rpf;
rpf = vsp1_rpf_create(vsp1, i); rpf = vsp1_rpf_create(vsp1, i);
...@@ -238,6 +245,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ...@@ -238,6 +245,14 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
vsp1->rpf[i] = rpf; vsp1->rpf[i] = rpf;
list_add_tail(&rpf->entity.list_dev, &vsp1->entities); 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) { if (vsp1->pdata.features & VSP1_HAS_SRU) {
...@@ -264,6 +279,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ...@@ -264,6 +279,7 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
} }
for (i = 0; i < vsp1->pdata.wpf_count; ++i) { for (i = 0; i < vsp1->pdata.wpf_count; ++i) {
struct vsp1_video *video;
struct vsp1_rwpf *wpf; struct vsp1_rwpf *wpf;
wpf = vsp1_wpf_create(vsp1, i); wpf = vsp1_wpf_create(vsp1, i);
...@@ -274,6 +290,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ...@@ -274,6 +290,15 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
vsp1->wpf[i] = wpf; vsp1->wpf[i] = wpf;
list_add_tail(&wpf->entity.list_dev, &vsp1->entities); 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. */ /* Register all subdevs. */
...@@ -515,6 +540,7 @@ static int vsp1_probe(struct platform_device *pdev) ...@@ -515,6 +540,7 @@ static int vsp1_probe(struct platform_device *pdev)
vsp1->dev = &pdev->dev; vsp1->dev = &pdev->dev;
mutex_init(&vsp1->lock); mutex_init(&vsp1->lock);
INIT_LIST_HEAD(&vsp1->entities); INIT_LIST_HEAD(&vsp1->entities);
INIT_LIST_HEAD(&vsp1->videos);
ret = vsp1_parse_dt(vsp1); ret = vsp1_parse_dt(vsp1);
if (ret < 0) if (ret < 0)
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "vsp1.h" #include "vsp1.h"
#include "vsp1_entity.h" #include "vsp1_entity.h"
#include "vsp1_video.h"
bool vsp1_entity_is_streaming(struct vsp1_entity *entity) 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, ...@@ -225,8 +224,6 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
void vsp1_entity_destroy(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) if (entity->subdev.ctrl_handler)
v4l2_ctrl_handler_free(entity->subdev.ctrl_handler); v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
media_entity_cleanup(&entity->subdev.entity); media_entity_cleanup(&entity->subdev.entity);
......
...@@ -217,7 +217,6 @@ static const struct vsp1_rwpf_operations rpf_vdev_ops = { ...@@ -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 vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
{ {
struct v4l2_subdev *subdev; struct v4l2_subdev *subdev;
struct vsp1_video *video;
struct vsp1_rwpf *rpf; struct vsp1_rwpf *rpf;
int ret; int ret;
...@@ -264,18 +263,6 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -264,18 +263,6 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
goto error; 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; return rpf;
error: error:
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "vsp1.h" #include "vsp1.h"
#include "vsp1_entity.h" #include "vsp1_entity.h"
#include "vsp1_video.h"
#define RWPF_PAD_SINK 0 #define RWPF_PAD_SINK 0
#define RWPF_PAD_SOURCE 1 #define RWPF_PAD_SOURCE 1
...@@ -33,7 +32,6 @@ struct vsp1_rwpf_operations { ...@@ -33,7 +32,6 @@ struct vsp1_rwpf_operations {
struct vsp1_rwpf { struct vsp1_rwpf {
struct vsp1_entity entity; struct vsp1_entity entity;
struct vsp1_video video;
struct v4l2_ctrl_handler ctrls; struct v4l2_ctrl_handler ctrls;
const struct vsp1_rwpf_operations *ops; const struct vsp1_rwpf_operations *ops;
......
...@@ -448,11 +448,11 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe, ...@@ -448,11 +448,11 @@ static int vsp1_pipeline_validate(struct vsp1_pipeline *pipe,
if (e->type == VSP1_ENTITY_RPF) { if (e->type == VSP1_ENTITY_RPF) {
rwpf = to_rwpf(subdev); rwpf = to_rwpf(subdev);
pipe->inputs[pipe->num_inputs++] = rwpf; pipe->inputs[pipe->num_inputs++] = rwpf;
rwpf->video.pipe_index = pipe->num_inputs; rwpf->entity.video->pipe_index = pipe->num_inputs;
} else if (e->type == VSP1_ENTITY_WPF) { } else if (e->type == VSP1_ENTITY_WPF) {
rwpf = to_rwpf(subdev); rwpf = to_rwpf(subdev);
pipe->output = to_rwpf(subdev); pipe->output = to_rwpf(subdev);
rwpf->video.pipe_index = 0; rwpf->entity.video->pipe_index = 0;
} else if (e->type == VSP1_ENTITY_LIF) { } else if (e->type == VSP1_ENTITY_LIF) {
pipe->lif = e; pipe->lif = e;
} else if (e->type == VSP1_ENTITY_BRU) { } else if (e->type == VSP1_ENTITY_BRU) {
...@@ -663,10 +663,10 @@ void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe) ...@@ -663,10 +663,10 @@ void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe)
/* Complete buffers on all video nodes. */ /* Complete buffers on all video nodes. */
for (i = 0; i < pipe->num_inputs; ++i) for (i = 0; i < pipe->num_inputs; ++i)
vsp1_video_frame_end(pipe, &pipe->inputs[i]->video); vsp1_video_frame_end(pipe, pipe->inputs[i]->entity.video);
if (!pipe->lif) if (!pipe->lif)
vsp1_video_frame_end(pipe, &pipe->output->video); vsp1_video_frame_end(pipe, pipe->output->entity.video);
spin_lock_irqsave(&pipe->irqlock, flags); spin_lock_irqsave(&pipe->irqlock, flags);
...@@ -1203,29 +1203,34 @@ static struct v4l2_file_operations vsp1_video_fops = { ...@@ -1203,29 +1203,34 @@ static struct v4l2_file_operations vsp1_video_fops = {
* Initialization and Cleanup * Initialization and Cleanup
*/ */
int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf) struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
struct vsp1_rwpf *rwpf)
{ {
struct vsp1_video *video;
const char *direction; const char *direction;
int ret; int ret;
switch (video->type) { video = devm_kzalloc(vsp1->dev, sizeof(*video), GFP_KERNEL);
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: if (!video)
direction = "output"; return ERR_PTR(-ENOMEM);
video->pad.flags = MEDIA_PAD_FL_SINK;
break;
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: rwpf->entity.video = video;
video->vsp1 = vsp1;
video->rwpf = rwpf;
if (rwpf->entity.type == VSP1_ENTITY_RPF) {
direction = "input"; direction = "input";
video->type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
video->pad.flags = MEDIA_PAD_FL_SOURCE; video->pad.flags = MEDIA_PAD_FL_SOURCE;
video->video.vfl_dir = VFL_DIR_TX; video->video.vfl_dir = VFL_DIR_TX;
break; } else {
direction = "output";
default: video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
return -EINVAL; video->pad.flags = MEDIA_PAD_FL_SINK;
video->video.vfl_dir = VFL_DIR_RX;
} }
video->rwpf = rwpf;
mutex_init(&video->lock); mutex_init(&video->lock);
spin_lock_init(&video->irqlock); spin_lock_init(&video->irqlock);
INIT_LIST_HEAD(&video->irqqueue); INIT_LIST_HEAD(&video->irqqueue);
...@@ -1239,7 +1244,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf) ...@@ -1239,7 +1244,7 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf)
/* Initialize the media entity... */ /* Initialize the media entity... */
ret = media_entity_pads_init(&video->video.entity, 1, &video->pad); ret = media_entity_pads_init(&video->video.entity, 1, &video->pad);
if (ret < 0) if (ret < 0)
return ret; return ERR_PTR(ret);
/* ... and the format ... */ /* ... and the format ... */
rwpf->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT); rwpf->fmtinfo = vsp1_get_format_info(VSP1_VIDEO_DEF_FORMAT);
...@@ -1294,12 +1299,12 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf) ...@@ -1294,12 +1299,12 @@ int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf)
goto error; goto error;
} }
return 0; return video;
error: error:
vb2_dma_contig_cleanup_ctx(video->alloc_ctx); vb2_dma_contig_cleanup_ctx(video->alloc_ctx);
vsp1_video_cleanup(video); vsp1_video_cleanup(video);
return ret; return ERR_PTR(ret);
} }
void vsp1_video_cleanup(struct vsp1_video *video) void vsp1_video_cleanup(struct vsp1_video *video)
......
...@@ -109,6 +109,7 @@ to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf) ...@@ -109,6 +109,7 @@ to_vsp1_vb2_buffer(struct vb2_v4l2_buffer *vbuf)
} }
struct vsp1_video { struct vsp1_video {
struct list_head list;
struct vsp1_device *vsp1; struct vsp1_device *vsp1;
struct vsp1_rwpf *rwpf; struct vsp1_rwpf *rwpf;
...@@ -133,7 +134,8 @@ static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev) ...@@ -133,7 +134,8 @@ static inline struct vsp1_video *to_vsp1_video(struct video_device *vdev)
return container_of(vdev, struct vsp1_video, video); return container_of(vdev, struct vsp1_video, video);
} }
int vsp1_video_init(struct vsp1_video *video, struct vsp1_rwpf *rwpf); struct vsp1_video *vsp1_video_create(struct vsp1_device *vsp1,
struct vsp1_rwpf *rwpf);
void vsp1_video_cleanup(struct vsp1_video *video); void vsp1_video_cleanup(struct vsp1_video *video);
void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe); void vsp1_pipeline_frame_end(struct vsp1_pipeline *pipe);
......
...@@ -215,7 +215,6 @@ static const struct vsp1_rwpf_operations wpf_vdev_ops = { ...@@ -215,7 +215,6 @@ static const struct vsp1_rwpf_operations wpf_vdev_ops = {
struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
{ {
struct v4l2_subdev *subdev; struct v4l2_subdev *subdev;
struct vsp1_video *video;
struct vsp1_rwpf *wpf; struct vsp1_rwpf *wpf;
int ret; int ret;
...@@ -262,19 +261,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -262,19 +261,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
goto error; goto error;
} }
/* Initialize the video device. */
video = &wpf->video;
video->type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
video->vsp1 = vsp1;
ret = vsp1_video_init(video, wpf);
if (ret < 0)
goto error;
wpf->entity.video = video;
wpf->entity.sink = &wpf->video.video.entity;
return wpf; return wpf;
error: error:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment