diff options
author | Stefan Wahren <stefan.wahren@i2se.com> | 2020-03-29 14:44:58 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-04-13 08:55:31 +0200 |
commit | 1a59532382a6c7301bc71c4bb56efab87745aaff (patch) | |
tree | ed2f7863b353bc5b3556890a6ffe71f58a14342c /drivers | |
parent | 3c0b37483b824f6aa55236452b4e24fa92e7fe44 (diff) | |
download | linux-1a59532382a6c7301bc71c4bb56efab87745aaff.tar.bz2 |
staging: bcm2835-camera: Move video component setup in its own function
The function mmal_setup_components has to many indention levels. So move
the setup code for video component in its own function.
Reviewed-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/1585485901-10172-7-git-send-email-stefan.wahren@i2se.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index f1019189fee5..f11f1866aaf3 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -1001,6 +1001,53 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, return 0; } + +static int mmal_setup_video_component(struct bm2835_mmal_dev *dev, + struct v4l2_format *f) +{ + bool overlay_enabled = !!dev->component[COMP_PREVIEW]->enabled; + struct vchiq_mmal_port *preview_port; + int ret; + + preview_port = &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW]; + + /* Preview and encode ports need to match on resolution */ + if (overlay_enabled) { + /* Need to disable the overlay before we can update + * the resolution + */ + ret = vchiq_mmal_port_disable(dev->instance, preview_port); + if (!ret) { + ret = vchiq_mmal_port_connect_tunnel(dev->instance, + preview_port, + NULL); + } + } + preview_port->es.video.width = f->fmt.pix.width; + preview_port->es.video.height = f->fmt.pix.height; + preview_port->es.video.crop.x = 0; + preview_port->es.video.crop.y = 0; + preview_port->es.video.crop.width = f->fmt.pix.width; + preview_port->es.video.crop.height = f->fmt.pix.height; + preview_port->es.video.frame_rate.num = + dev->capture.timeperframe.denominator; + preview_port->es.video.frame_rate.den = + dev->capture.timeperframe.numerator; + ret = vchiq_mmal_port_set_format(dev->instance, preview_port); + + if (overlay_enabled) { + ret = vchiq_mmal_port_connect_tunnel(dev->instance, + preview_port, + &dev->component[COMP_PREVIEW]->input[0]); + if (ret) + return ret; + + ret = vchiq_mmal_port_enable(dev->instance, preview_port, NULL); + } + + return ret; +} + static int mmal_setup_encode_component(struct bm2835_mmal_dev *dev, struct v4l2_format *f, struct vchiq_mmal_port *port, @@ -1184,46 +1231,7 @@ static int mmal_setup_components(struct bm2835_mmal_dev *dev, if (!ret && camera_port == &dev->component[COMP_CAMERA]->output[CAM_PORT_VIDEO]) { - bool overlay_enabled = - !!dev->component[COMP_PREVIEW]->enabled; - struct vchiq_mmal_port *preview_port = - &dev->component[COMP_CAMERA]->output[CAM_PORT_PREVIEW]; - /* Preview and encode ports need to match on resolution */ - if (overlay_enabled) { - /* Need to disable the overlay before we can update - * the resolution - */ - ret = - vchiq_mmal_port_disable(dev->instance, - preview_port); - if (!ret) - ret = - vchiq_mmal_port_connect_tunnel( - dev->instance, - preview_port, - NULL); - } - preview_port->es.video.width = f->fmt.pix.width; - preview_port->es.video.height = f->fmt.pix.height; - preview_port->es.video.crop.x = 0; - preview_port->es.video.crop.y = 0; - preview_port->es.video.crop.width = f->fmt.pix.width; - preview_port->es.video.crop.height = f->fmt.pix.height; - preview_port->es.video.frame_rate.num = - dev->capture.timeperframe.denominator; - preview_port->es.video.frame_rate.den = - dev->capture.timeperframe.numerator; - ret = vchiq_mmal_port_set_format(dev->instance, preview_port); - if (overlay_enabled) { - ret = vchiq_mmal_port_connect_tunnel( - dev->instance, - preview_port, - &dev->component[COMP_PREVIEW]->input[0]); - if (!ret) - ret = vchiq_mmal_port_enable(dev->instance, - preview_port, - NULL); - } + ret = mmal_setup_video_component(dev, f); } if (ret) { |