diff options
Diffstat (limited to 'drivers/media/i2c')
-rw-r--r-- | drivers/media/i2c/adv748x/adv748x-afe.c | 3 | ||||
-rw-r--r-- | drivers/media/i2c/dw9714.c | 14 | ||||
-rw-r--r-- | drivers/media/i2c/imx274.c | 2 | ||||
-rw-r--r-- | drivers/media/i2c/ov13858.c | 19 | ||||
-rw-r--r-- | drivers/media/i2c/ov2685.c | 1 | ||||
-rw-r--r-- | drivers/media/i2c/ov5640.c | 38 | ||||
-rw-r--r-- | drivers/media/i2c/ov5645.c | 29 | ||||
-rw-r--r-- | drivers/media/i2c/ov5670.c | 19 |
8 files changed, 52 insertions, 73 deletions
diff --git a/drivers/media/i2c/adv748x/adv748x-afe.c b/drivers/media/i2c/adv748x/adv748x-afe.c index 5188178588c9..61514bae7e5c 100644 --- a/drivers/media/i2c/adv748x/adv748x-afe.c +++ b/drivers/media/i2c/adv748x/adv748x-afe.c @@ -275,7 +275,8 @@ static int adv748x_afe_s_stream(struct v4l2_subdev *sd, int enable) { struct adv748x_afe *afe = adv748x_sd_to_afe(sd); struct adv748x_state *state = adv748x_afe_to_state(afe); - int ret, signal = V4L2_IN_ST_NO_SIGNAL; + u32 signal = V4L2_IN_ST_NO_SIGNAL; + int ret; mutex_lock(&state->mutex); diff --git a/drivers/media/i2c/dw9714.c b/drivers/media/i2c/dw9714.c index 8dbbf0f917df..91fae01d052b 100644 --- a/drivers/media/i2c/dw9714.c +++ b/drivers/media/i2c/dw9714.c @@ -1,15 +1,5 @@ -/* - * Copyright (c) 2015--2017 Intel Corporation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - */ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2015--2017 Intel Corporation. #include <linux/delay.h> #include <linux/i2c.h> diff --git a/drivers/media/i2c/imx274.c b/drivers/media/i2c/imx274.c index 664e8acdf2a0..daec33f4196a 100644 --- a/drivers/media/i2c/imx274.c +++ b/drivers/media/i2c/imx274.c @@ -1426,7 +1426,7 @@ static int imx274_set_vflip(struct stimx274 *priv, int val) err = imx274_write_reg(priv, IMX274_VFLIP_REG, val); if (err) { - dev_err(&priv->client->dev, "VFILP control error\n"); + dev_err(&priv->client->dev, "VFLIP control error\n"); return err; } diff --git a/drivers/media/i2c/ov13858.c b/drivers/media/i2c/ov13858.c index 30ee9f71bf0d..3dbcae257164 100644 --- a/drivers/media/i2c/ov13858.c +++ b/drivers/media/i2c/ov13858.c @@ -1,16 +1,5 @@ -/* - * Copyright (c) 2017 Intel Corporation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Intel Corporation. #include <linux/acpi.h> #include <linux/i2c.h> @@ -1375,7 +1364,9 @@ ov13858_set_pad_format(struct v4l2_subdev *sd, if (fmt->format.code != MEDIA_BUS_FMT_SGRBG10_1X10) fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; - mode = v4l2_find_nearest_size(supported_modes, width, height, + mode = v4l2_find_nearest_size(supported_modes, + ARRAY_SIZE(supported_modes), + width, height, fmt->format.width, fmt->format.height); ov13858_update_pad_format(mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c index 83c55e8288e7..385c1886a947 100644 --- a/drivers/media/i2c/ov2685.c +++ b/drivers/media/i2c/ov2685.c @@ -832,7 +832,6 @@ MODULE_DEVICE_TABLE(of, ov2685_of_match); static struct i2c_driver ov2685_i2c_driver = { .driver = { .name = "ov2685", - .owner = THIS_MODULE, .pm = &ov2685_pm_ops, .of_match_table = of_match_ptr(ov2685_of_match), }, diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c index 03940f0cdfa6..852026baa2e7 100644 --- a/drivers/media/i2c/ov5640.c +++ b/drivers/media/i2c/ov5640.c @@ -1641,6 +1641,9 @@ static int ov5640_set_mode(struct ov5640_dev *sensor, return 0; } +static int ov5640_set_framefmt(struct ov5640_dev *sensor, + struct v4l2_mbus_framefmt *format); + /* restore the last set video mode after chip power-on */ static int ov5640_restore_mode(struct ov5640_dev *sensor) { @@ -1652,7 +1655,11 @@ static int ov5640_restore_mode(struct ov5640_dev *sensor) return ret; /* now restore the last capture mode */ - return ov5640_set_mode(sensor, &ov5640_mode_init_data); + ret = ov5640_set_mode(sensor, &ov5640_mode_init_data); + if (ret < 0) + return ret; + + return ov5640_set_framefmt(sensor, &sensor->fmt); } static void ov5640_power(struct ov5640_dev *sensor, bool enable) @@ -1874,7 +1881,13 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd, if (ov5640_formats[i].code == fmt->code) break; if (i >= ARRAY_SIZE(ov5640_formats)) - fmt->code = ov5640_formats[0].code; + i = 0; + + fmt->code = ov5640_formats[i].code; + fmt->colorspace = ov5640_formats[i].colorspace; + fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); + fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE; + fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace); return 0; } @@ -1885,6 +1898,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, { struct ov5640_dev *sensor = to_ov5640_dev(sd); const struct ov5640_mode_info *new_mode; + struct v4l2_mbus_framefmt *mbus_fmt = &format->format; int ret; if (format->pad != 0) @@ -1897,7 +1911,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, goto out; } - ret = ov5640_try_fmt_internal(sd, &format->format, + ret = ov5640_try_fmt_internal(sd, mbus_fmt, sensor->current_fr, &new_mode); if (ret) goto out; @@ -1906,12 +1920,12 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, struct v4l2_mbus_framefmt *fmt = v4l2_subdev_get_try_format(sd, cfg, 0); - *fmt = format->format; + *fmt = *mbus_fmt; goto out; } sensor->current_mode = new_mode; - sensor->fmt = format->format; + sensor->fmt = *mbus_fmt; sensor->pending_mode_change = true; out: mutex_unlock(&sensor->lock); @@ -2496,6 +2510,7 @@ static int ov5640_probe(struct i2c_client *client, struct device *dev = &client->dev; struct fwnode_handle *endpoint; struct ov5640_dev *sensor; + struct v4l2_mbus_framefmt *fmt; int ret; sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); @@ -2503,10 +2518,15 @@ static int ov5640_probe(struct i2c_client *client, return -ENOMEM; sensor->i2c_client = client; - sensor->fmt.code = MEDIA_BUS_FMT_UYVY8_2X8; - sensor->fmt.width = 640; - sensor->fmt.height = 480; - sensor->fmt.field = V4L2_FIELD_NONE; + fmt = &sensor->fmt; + fmt->code = ov5640_formats[0].code; + fmt->colorspace = ov5640_formats[0].colorspace; + fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace); + fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE; + fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace); + fmt->width = 640; + fmt->height = 480; + fmt->field = V4L2_FIELD_NONE; sensor->frame_interval.numerator = 1; sensor->frame_interval.denominator = ov5640_framerates[OV5640_30_FPS]; sensor->current_fr = OV5640_30_FPS; diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c index d28845f7356f..4e3142a7e5a7 100644 --- a/drivers/media/i2c/ov5645.c +++ b/drivers/media/i2c/ov5645.c @@ -959,23 +959,6 @@ __ov5645_get_pad_crop(struct ov5645 *ov5645, struct v4l2_subdev_pad_config *cfg, } } -static const struct ov5645_mode_info * -ov5645_find_nearest_mode(unsigned int width, unsigned int height) -{ - int i; - - for (i = ARRAY_SIZE(ov5645_mode_info_data) - 1; i >= 0; i--) { - if (ov5645_mode_info_data[i].width <= width && - ov5645_mode_info_data[i].height <= height) - break; - } - - if (i < 0) - i = 0; - - return &ov5645_mode_info_data[i]; -} - static int ov5645_set_format(struct v4l2_subdev *sd, struct v4l2_subdev_pad_config *cfg, struct v4l2_subdev_format *format) @@ -989,8 +972,11 @@ static int ov5645_set_format(struct v4l2_subdev *sd, __crop = __ov5645_get_pad_crop(ov5645, cfg, format->pad, format->which); - new_mode = ov5645_find_nearest_mode(format->format.width, - format->format.height); + new_mode = v4l2_find_nearest_size(ov5645_mode_info_data, + ARRAY_SIZE(ov5645_mode_info_data), + width, height, + format->format.width, format->format.height); + __crop->width = new_mode->width; __crop->height = new_mode->height; @@ -1131,13 +1117,14 @@ static int ov5645_probe(struct i2c_client *client, ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), &ov5645->ep); + + of_node_put(endpoint); + if (ret < 0) { dev_err(dev, "parsing endpoint node failed\n"); return ret; } - of_node_put(endpoint); - if (ov5645->ep.bus_type != V4L2_MBUS_CSI2) { dev_err(dev, "invalid bus type, must be CSI2\n"); return -EINVAL; diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c index d2db480da1b9..7b7c74d77370 100644 --- a/drivers/media/i2c/ov5670.c +++ b/drivers/media/i2c/ov5670.c @@ -1,16 +1,5 @@ -/* - * Copyright (c) 2017 Intel Corporation. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License version - * 2 as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Intel Corporation. #include <linux/acpi.h> #include <linux/i2c.h> @@ -2230,7 +2219,9 @@ static int ov5670_set_pad_format(struct v4l2_subdev *sd, fmt->format.code = MEDIA_BUS_FMT_SGRBG10_1X10; - mode = v4l2_find_nearest_size(supported_modes, width, height, + mode = v4l2_find_nearest_size(supported_modes, + ARRAY_SIZE(supported_modes), + width, height, fmt->format.width, fmt->format.height); ov5670_update_pad_format(mode, fmt); if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) { |