diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2015-11-17 13:10:26 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2016-04-13 18:56:14 -0300 |
commit | 7b905f0583b2e6fe1494a85303a89aa0cd30b0b3 (patch) | |
tree | a5da79d56457b44624280f2f2fb73a5e0937ab03 /drivers/media/platform/vsp1/vsp1_sru.c | |
parent | b7e5107eebb73d27affed95c20cedbf4784bf17c (diff) | |
download | linux-7b905f0583b2e6fe1494a85303a89aa0cd30b0b3.tar.gz linux-7b905f0583b2e6fe1494a85303a89aa0cd30b0b3.tar.xz |
[media] v4l: vsp1: Create a new configure operation to setup modules
The subdev s_stream operation is abused as a generic way to setup
modules at every frame. Move the code out to a new VSP1 entity configure
operation.
Most modules now have an empty s_stream operation that can be removed.
The only exception is the WPF module that needs to perform hardware
configuration when stopping the stream. The code can be simplified
accordingly as we know that that operation never fails.
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_sru.c')
-rw-r--r-- | drivers/media/platform/vsp1/vsp1_sru.c | 91 |
1 files changed, 41 insertions, 50 deletions
diff --git a/drivers/media/platform/vsp1/vsp1_sru.c b/drivers/media/platform/vsp1/vsp1_sru.c index c9a97ba5a042..e05149eabde9 100644 --- a/drivers/media/platform/vsp1/vsp1_sru.c +++ b/drivers/media/platform/vsp1/vsp1_sru.c @@ -103,47 +103,7 @@ static const struct v4l2_ctrl_config sru_intensity_control = { }; /* ----------------------------------------------------------------------------- - * V4L2 Subdevice Core Operations - */ - -static int sru_s_stream(struct v4l2_subdev *subdev, int enable) -{ - const struct vsp1_sru_param *param; - struct vsp1_sru *sru = to_sru(subdev); - struct v4l2_mbus_framefmt *input; - struct v4l2_mbus_framefmt *output; - u32 ctrl0; - - if (!enable) - return 0; - - input = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, - SRU_PAD_SINK); - output = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, - SRU_PAD_SOURCE); - - if (input->code == MEDIA_BUS_FMT_ARGB8888_1X32) - ctrl0 = VI6_SRU_CTRL0_PARAM2 | VI6_SRU_CTRL0_PARAM3 - | VI6_SRU_CTRL0_PARAM4; - else - ctrl0 = VI6_SRU_CTRL0_PARAM3; - - if (input->width != output->width) - ctrl0 |= VI6_SRU_CTRL0_MODE_UPSCALE; - - param = &vsp1_sru_params[sru->intensity - 1]; - - ctrl0 |= param->ctrl0; - - vsp1_sru_write(sru, VI6_SRU_CTRL0, ctrl0); - vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5); - vsp1_sru_write(sru, VI6_SRU_CTRL2, param->ctrl2); - - return 0; -} - -/* ----------------------------------------------------------------------------- - * V4L2 Subdevice Pad Operations + * V4L2 Subdevice Operations */ static int sru_enum_mbus_code(struct v4l2_subdev *subdev, @@ -319,14 +279,6 @@ static int sru_set_format(struct v4l2_subdev *subdev, return 0; } -/* ----------------------------------------------------------------------------- - * V4L2 Subdevice Operations - */ - -static struct v4l2_subdev_video_ops sru_video_ops = { - .s_stream = sru_s_stream, -}; - static struct v4l2_subdev_pad_ops sru_pad_ops = { .init_cfg = vsp1_entity_init_cfg, .enum_mbus_code = sru_enum_mbus_code, @@ -336,11 +288,49 @@ static struct v4l2_subdev_pad_ops sru_pad_ops = { }; static struct v4l2_subdev_ops sru_ops = { - .video = &sru_video_ops, .pad = &sru_pad_ops, }; /* ----------------------------------------------------------------------------- + * VSP1 Entity Operations + */ + +static void sru_configure(struct vsp1_entity *entity) +{ + const struct vsp1_sru_param *param; + struct vsp1_sru *sru = to_sru(&entity->subdev); + struct v4l2_mbus_framefmt *input; + struct v4l2_mbus_framefmt *output; + u32 ctrl0; + + input = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, + SRU_PAD_SINK); + output = vsp1_entity_get_pad_format(&sru->entity, sru->entity.config, + SRU_PAD_SOURCE); + + if (input->code == MEDIA_BUS_FMT_ARGB8888_1X32) + ctrl0 = VI6_SRU_CTRL0_PARAM2 | VI6_SRU_CTRL0_PARAM3 + | VI6_SRU_CTRL0_PARAM4; + else + ctrl0 = VI6_SRU_CTRL0_PARAM3; + + if (input->width != output->width) + ctrl0 |= VI6_SRU_CTRL0_MODE_UPSCALE; + + param = &vsp1_sru_params[sru->intensity - 1]; + + ctrl0 |= param->ctrl0; + + vsp1_sru_write(sru, VI6_SRU_CTRL0, ctrl0); + vsp1_sru_write(sru, VI6_SRU_CTRL1, VI6_SRU_CTRL1_PARAM5); + vsp1_sru_write(sru, VI6_SRU_CTRL2, param->ctrl2); +} + +static const struct vsp1_entity_operations sru_entity_ops = { + .configure = sru_configure, +}; + +/* ----------------------------------------------------------------------------- * Initialization and Cleanup */ @@ -353,6 +343,7 @@ struct vsp1_sru *vsp1_sru_create(struct vsp1_device *vsp1) if (sru == NULL) return ERR_PTR(-ENOMEM); + sru->entity.ops = &sru_entity_ops; sru->entity.type = VSP1_ENTITY_SRU; ret = vsp1_entity_init(vsp1, &sru->entity, "sru", 2, &sru_ops); |