Commit c7621b30 authored by Javier Martinez Canillas's avatar Javier Martinez Canillas Committed by Mauro Carvalho Chehab

[media] v4l: vsp1: separate links creation from entities init

The vsp1 driver initializes the entities and creates the pads links
before the entities are registered with the media device. This doesn't
work now that object IDs are used to create links so the media_device
has to be set.

Split out the pads links creation from the entity initialization so are
made after the entities registration.
Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Acked-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 7213fe7e
...@@ -260,9 +260,19 @@ static int vsp1_create_entities(struct vsp1_device *vsp1) ...@@ -260,9 +260,19 @@ static int vsp1_create_entities(struct vsp1_device *vsp1)
/* Create links. */ /* Create links. */
list_for_each_entry(entity, &vsp1->entities, list_dev) { list_for_each_entry(entity, &vsp1->entities, list_dev) {
if (entity->type == VSP1_ENTITY_LIF || if (entity->type == VSP1_ENTITY_LIF) {
entity->type == VSP1_ENTITY_RPF) ret = vsp1_wpf_create_pads_links(vsp1, entity);
if (ret < 0)
goto done;
continue;
}
if (entity->type == VSP1_ENTITY_RPF) {
ret = vsp1_rpf_create_pads_links(vsp1, entity);
if (ret < 0)
goto done;
continue; continue;
}
ret = vsp1_create_links(vsp1, entity); ret = vsp1_create_links(vsp1, entity);
if (ret < 0) if (ret < 0)
......
...@@ -277,18 +277,29 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -277,18 +277,29 @@ struct vsp1_rwpf *vsp1_rpf_create(struct vsp1_device *vsp1, unsigned int index)
rpf->entity.video = video; rpf->entity.video = video;
/* Connect the video device to the RPF. */
ret = media_create_pad_link(&rpf->video.video.entity, 0,
&rpf->entity.subdev.entity,
RWPF_PAD_SINK,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
if (ret < 0)
goto error;
return rpf; return rpf;
error: error:
vsp1_entity_destroy(&rpf->entity); vsp1_entity_destroy(&rpf->entity);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
/*
* vsp1_rpf_create_pads_links_create_pads_links() - RPF pads links creation
* @vsp1: Pointer to VSP1 device
* @entity: Pointer to VSP1 entity
*
* return negative error code or zero on success
*/
int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1,
struct vsp1_entity *entity)
{
struct vsp1_rwpf *rpf = to_rwpf(&entity->subdev);
/* Connect the video device to the RPF. */
return media_create_pad_link(&rpf->video.video.entity, 0,
&rpf->entity.subdev.entity,
RWPF_PAD_SINK,
MEDIA_LNK_FL_ENABLED |
MEDIA_LNK_FL_IMMUTABLE);
}
...@@ -50,6 +50,11 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev) ...@@ -50,6 +50,11 @@ static inline struct vsp1_rwpf *to_rwpf(struct v4l2_subdev *subdev)
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 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);
int vsp1_rpf_create_pads_links(struct vsp1_device *vsp1,
struct vsp1_entity *entity);
int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1,
struct vsp1_entity *entity);
int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev, int vsp1_rwpf_enum_mbus_code(struct v4l2_subdev *subdev,
struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_pad_config *cfg,
struct v4l2_subdev_mbus_code_enum *code); struct v4l2_subdev_mbus_code_enum *code);
......
...@@ -220,7 +220,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -220,7 +220,6 @@ 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_video *video;
struct vsp1_rwpf *wpf; struct vsp1_rwpf *wpf;
unsigned int flags;
int ret; int ret;
wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL); wpf = devm_kzalloc(vsp1->dev, sizeof(*wpf), GFP_KERNEL);
...@@ -276,20 +275,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -276,20 +275,6 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
goto error; goto error;
wpf->entity.video = video; wpf->entity.video = video;
/* Connect the video device to the WPF. All connections are immutable
* except for the WPF0 source link if a LIF is present.
*/
flags = MEDIA_LNK_FL_ENABLED;
if (!(vsp1->pdata.features & VSP1_HAS_LIF) || index != 0)
flags |= MEDIA_LNK_FL_IMMUTABLE;
ret = media_create_pad_link(&wpf->entity.subdev.entity,
RWPF_PAD_SOURCE,
&wpf->video.video.entity, 0, flags);
if (ret < 0)
goto error;
wpf->entity.sink = &wpf->video.video.entity; wpf->entity.sink = &wpf->video.video.entity;
return wpf; return wpf;
...@@ -298,3 +283,28 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index) ...@@ -298,3 +283,28 @@ struct vsp1_rwpf *vsp1_wpf_create(struct vsp1_device *vsp1, unsigned int index)
vsp1_entity_destroy(&wpf->entity); vsp1_entity_destroy(&wpf->entity);
return ERR_PTR(ret); return ERR_PTR(ret);
} }
/*
* vsp1_wpf_create_pads_links_create_pads_links() - RPF pads links creation
* @vsp1: Pointer to VSP1 device
* @entity: Pointer to VSP1 entity
*
* return negative error code or zero on success
*/
int vsp1_wpf_create_pads_links(struct vsp1_device *vsp1,
struct vsp1_entity *entity)
{
struct vsp1_rwpf *wpf = to_rwpf(&entity->subdev);
unsigned int flags;
/* Connect the video device to the WPF. All connections are immutable
* except for the WPF0 source link if a LIF is present.
*/
flags = MEDIA_LNK_FL_ENABLED;
if (!(vsp1->pdata.features & VSP1_HAS_LIF) || entity->index != 0)
flags |= MEDIA_LNK_FL_IMMUTABLE;
return media_create_pad_link(&wpf->entity.subdev.entity,
RWPF_PAD_SOURCE,
&wpf->video.video.entity, 0, flags);
}
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