diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-11-16 00:42:01 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-04-13 23:51:24 +0300 |
commit | 823329dfee7224712569cc4899720bc470a2fe56 (patch) | |
tree | 36fef23f5c8cf96f1f9db7c7dd913d5744fcfa12 /drivers/media/platform/vsp1/vsp1_entity.c | |
parent | 351bbf99f245f4bada0edec3b0863146d71f06a9 (diff) | |
download | linux-823329dfee7224712569cc4899720bc470a2fe56.tar.xz |
[media] v4l: vsp1: Move subdev initialization code to vsp1_entity_init()
Don't duplicate the code in every module driver, centralize it in a
single place.
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/platform/vsp1/vsp1_entity.c')
-rw-r--r-- | drivers/media/platform/vsp1/vsp1_entity.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index 7b2301dbd584..8432c49fbd75 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c @@ -70,8 +70,8 @@ vsp1_entity_get_pad_format(struct vsp1_entity *entity, * formats are initialized on the file handle. Otherwise active formats are * initialized on the device. */ -void vsp1_entity_init_formats(struct v4l2_subdev *subdev, - struct v4l2_subdev_pad_config *cfg) +static void vsp1_entity_init_formats(struct v4l2_subdev *subdev, + struct v4l2_subdev_pad_config *cfg) { struct v4l2_subdev_format format; unsigned int pad; @@ -159,9 +159,12 @@ static const struct vsp1_route vsp1_routes[] = { }; int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, - unsigned int num_pads) + const char *name, unsigned int num_pads, + const struct v4l2_subdev_ops *ops) { + struct v4l2_subdev *subdev; unsigned int i; + int ret; for (i = 0; i < ARRAY_SIZE(vsp1_routes); ++i) { if (vsp1_routes[i].type == entity->type && @@ -196,8 +199,25 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, entity->pads[num_pads - 1].flags = MEDIA_PAD_FL_SOURCE; /* Initialize the media entity. */ - return media_entity_pads_init(&entity->subdev.entity, num_pads, - entity->pads); + ret = media_entity_pads_init(&entity->subdev.entity, num_pads, + entity->pads); + if (ret < 0) + return ret; + + /* Initialize the V4L2 subdev. */ + subdev = &entity->subdev; + v4l2_subdev_init(subdev, ops); + + subdev->entity.ops = &vsp1->media_ops; + subdev->internal_ops = &vsp1_subdev_internal_ops; + subdev->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + + snprintf(subdev->name, sizeof(subdev->name), "%s %s", + dev_name(vsp1->dev), name); + + vsp1_entity_init_formats(subdev, NULL); + + return 0; } void vsp1_entity_destroy(struct vsp1_entity *entity) |