msm8916-openwrt/target/linux/bcm27xx/patches-6.6/950-0282-media-i2c-add-ov9281-driver.patch
Álvaro Fernández Rojas 8c405cdccc bcm27xx: add 6.6 kernel patches
The patches were generated from the RPi repo with the following command:
git format-patch v6.6.34..rpi-6.1.y

Some patches needed rebasing and, as usual, the applied and reverted, wireless
drivers, Github workflows, READMEs and defconfigs patches were removed.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
2024-06-18 18:52:49 +02:00

392 lines
13 KiB
Diff

From 9c7302f485c701900af7902af10d8a111e0a6192 Mon Sep 17 00:00:00 2001
From: Zefa Chen <zefa.chen@rock-chips.com>
Date: Fri, 17 May 2019 18:23:03 +0800
Subject: [PATCH 0282/1085] media: i2c: add ov9281 driver.
Change-Id: I7b77250bbc56d2f861450cf77271ad15f9b88ab1
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: fix mclk issue when probe multiple camera.
Takes the ov9281 part only from the Rockchip's patch.
Change-Id: I30e833baf2c1bb07d6d87ddb3b00759ab45a90e4
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: add enum_frame_interval function for iq tool 2.2 and hal3
Adds the ov9281 parts of the Rockchip patch adding enum_frame_interval to
a large number of drivers.
Change-Id: I03344cd6cf278dd7c18fce8e97479089ef185a5c
Signed-off-by: Zefa Chen <zefa.chen@rock-chips.com>
media: i2c: ov9281: Fixup for recent kernel releases, and remove custom code
The Rockchip driver was based on a 4.4 kernel, and had several custom
Rockchip parts.
Update to 5.4 kernel APIs, with the relevant controls required by
libcamera, and remove custom Rockchip parts.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Read chip ID via 2 reads
Vision Components have made an OV9281 module which blocks reading
back the majority of registers to comply with NDAs, and in doing
so doesn't allow auto-increment register reading as used when
reading the chip ID.
Use two reads and manually combine the results.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Add support for 8 bit readout
The sensor supports 8 bit mode as well as 10bit, so add the
relevant code to allow selection of this.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: ov9281: Add 1280x720 and 640x480 modes
Breaks out common register set and adds the different registers
for 1280x720 (cropped) and 640x480 (skipped) modes
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Fixed picture line bug in all ov9281 modes
Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
Added hflip and vflip controls to ov9281
Signed-off-by: Mathias Anhalt <mathiasanhalt@web.de>
media: i2c: ov9281: Remove override of subdev name
From the original Rockchip driver, the subdev was renamed
from the default to being "mov9281 <dev_name>" whereas the
default would have been "ov9281 <dev_name>".
Remove the override to drop back to the default rather than
a vendor custom string.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: v4l2-subdev: add subdev-wide state struct
Signed-off-by: Dom Cobley <popcornmix@gmail.com>
media: i2c: ov9281: Add fwnode properties controls
Add call to v4l2_ctrl_new_fwnode_properties to read and
create the fwnode based controls.
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
media: i2c: ov9281: Sensor should report RAW color space
Tested on Raspberry Pi running libcamera.
Signed-off-by: David Plowman <david.plowman@raspberrypi.com>
Partial revert "media: i2c: add ov9281 driver."
This partially reverts commit 84e98e3a4f3eecb168ceb80231c3e8252929892e.
The commit had merged some changes to other drivers with adding the ov9281
driver. Only the ov9281 parts have been reverted.
---
drivers/media/i2c/imx477.c | 32 ++++++++++---------
drivers/media/i2c/irs1125.c | 15 ++++-----
.../media/platform/bcm2835/bcm2835-unicam.c | 20 ++++++------
.../bcm2835-isp/bcm2835-v4l2-isp.c | 4 +--
4 files changed, 36 insertions(+), 35 deletions(-)
--- a/drivers/media/i2c/imx477.c
+++ b/drivers/media/i2c/imx477.c
@@ -1272,9 +1272,9 @@ static int imx477_open(struct v4l2_subde
{
struct imx477 *imx477 = to_imx477(sd);
struct v4l2_mbus_framefmt *try_fmt_img =
- v4l2_subdev_get_try_format(sd, fh->pad, IMAGE_PAD);
+ v4l2_subdev_get_try_format(sd, fh->state, IMAGE_PAD);
struct v4l2_mbus_framefmt *try_fmt_meta =
- v4l2_subdev_get_try_format(sd, fh->pad, METADATA_PAD);
+ v4l2_subdev_get_try_format(sd, fh->state, METADATA_PAD);
struct v4l2_rect *try_crop;
mutex_lock(&imx477->mutex);
@@ -1293,7 +1293,7 @@ static int imx477_open(struct v4l2_subde
try_fmt_meta->field = V4L2_FIELD_NONE;
/* Initialize try_crop */
- try_crop = v4l2_subdev_get_try_crop(sd, fh->pad, IMAGE_PAD);
+ try_crop = v4l2_subdev_get_try_crop(sd, fh->state, IMAGE_PAD);
try_crop->left = IMX477_PIXEL_ARRAY_LEFT;
try_crop->top = IMX477_PIXEL_ARRAY_TOP;
try_crop->width = IMX477_PIXEL_ARRAY_WIDTH;
@@ -1425,7 +1425,7 @@ static const struct v4l2_ctrl_ops imx477
};
static int imx477_enum_mbus_code(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
{
struct imx477 *imx477 = to_imx477(sd);
@@ -1450,7 +1450,7 @@ static int imx477_enum_mbus_code(struct
}
static int imx477_enum_frame_size(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_frame_size_enum *fse)
{
struct imx477 *imx477 = to_imx477(sd);
@@ -1516,7 +1516,7 @@ static void imx477_update_metadata_pad_f
}
static int imx477_get_pad_format(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
struct imx477 *imx477 = to_imx477(sd);
@@ -1528,7 +1528,8 @@ static int imx477_get_pad_format(struct
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
struct v4l2_mbus_framefmt *try_fmt =
- v4l2_subdev_get_try_format(&imx477->sd, cfg, fmt->pad);
+ v4l2_subdev_get_try_format(&imx477->sd, sd_state,
+ fmt->pad);
/* update the code which could change due to vflip or hflip: */
try_fmt->code = fmt->pad == IMAGE_PAD ?
imx477_get_format_code(imx477, try_fmt->code) :
@@ -1593,7 +1594,7 @@ static void imx477_set_framing_limits(st
}
static int imx477_set_pad_format(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *fmt)
{
struct v4l2_mbus_framefmt *framefmt;
@@ -1622,7 +1623,7 @@ static int imx477_set_pad_format(struct
fmt->format.height);
imx477_update_image_pad_format(imx477, mode, fmt);
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
- framefmt = v4l2_subdev_get_try_format(sd, cfg,
+ framefmt = v4l2_subdev_get_try_format(sd, sd_state,
fmt->pad);
*framefmt = fmt->format;
} else if (imx477->mode != mode) {
@@ -1632,7 +1633,7 @@ static int imx477_set_pad_format(struct
}
} else {
if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
- framefmt = v4l2_subdev_get_try_format(sd, cfg,
+ framefmt = v4l2_subdev_get_try_format(sd, sd_state,
fmt->pad);
*framefmt = fmt->format;
} else {
@@ -1647,12 +1648,13 @@ static int imx477_set_pad_format(struct
}
static const struct v4l2_rect *
-__imx477_get_pad_crop(struct imx477 *imx477, struct v4l2_subdev_pad_config *cfg,
+__imx477_get_pad_crop(struct imx477 *imx477,
+ struct v4l2_subdev_state *sd_state,
unsigned int pad, enum v4l2_subdev_format_whence which)
{
switch (which) {
case V4L2_SUBDEV_FORMAT_TRY:
- return v4l2_subdev_get_try_crop(&imx477->sd, cfg, pad);
+ return v4l2_subdev_get_try_crop(&imx477->sd, sd_state, pad);
case V4L2_SUBDEV_FORMAT_ACTIVE:
return &imx477->mode->crop;
}
@@ -1661,7 +1663,7 @@ __imx477_get_pad_crop(struct imx477 *imx
}
static int imx477_get_selection(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_selection *sel)
{
switch (sel->target) {
@@ -1669,7 +1671,7 @@ static int imx477_get_selection(struct v
struct imx477 *imx477 = to_imx477(sd);
mutex_lock(&imx477->mutex);
- sel->r = *__imx477_get_pad_crop(imx477, cfg, sel->pad,
+ sel->r = *__imx477_get_pad_crop(imx477, sd_state, sel->pad,
sel->which);
mutex_unlock(&imx477->mutex);
@@ -2297,7 +2299,7 @@ static struct i2c_driver imx477_i2c_driv
.of_match_table = imx477_dt_ids,
.pm = &imx477_pm_ops,
},
- .probe_new = imx477_probe,
+ .probe = imx477_probe,
.remove = imx477_remove,
};
--- a/drivers/media/i2c/irs1125.c
+++ b/drivers/media/i2c/irs1125.c
@@ -562,8 +562,8 @@ static const struct v4l2_subdev_video_op
};
static int irs1125_enum_mbus_code(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
- struct v4l2_subdev_mbus_code_enum *code)
+ struct v4l2_subdev_state *sd_state,
+ struct v4l2_subdev_mbus_code_enum *code)
{
if (code->index > 0)
return -EINVAL;
@@ -574,7 +574,7 @@ static int irs1125_enum_mbus_code(struct
}
static int irs1125_set_get_fmt(struct v4l2_subdev *sd,
- struct v4l2_subdev_pad_config *cfg,
+ struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_format *format)
{
struct v4l2_mbus_framefmt *fmt = &format->format;
@@ -930,7 +930,7 @@ static int irs1125_detect(struct v4l2_su
static int irs1125_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
{
struct v4l2_mbus_framefmt *format =
- v4l2_subdev_get_try_format(sd, fh->pad, 0);
+ v4l2_subdev_get_try_format(sd, fh->state, 0);
format->code = MEDIA_BUS_FMT_Y12_1X12;
format->width = IRS1125_WINDOW_WIDTH_DEF;
@@ -1061,8 +1061,7 @@ static int irs1125_ident_setup(struct ir
return 0;
}
-static int irs1125_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+static int irs1125_probe(struct i2c_client *client)
{
struct device *dev = &client->dev;
struct irs1125 *sensor;
@@ -1161,7 +1160,7 @@ mutex_remove:
return ret;
}
-static int irs1125_remove(struct i2c_client *client)
+static void irs1125_remove(struct i2c_client *client)
{
struct v4l2_subdev *sd = i2c_get_clientdata(client);
struct irs1125 *irs1125 = to_state(sd);
@@ -1171,8 +1170,6 @@ static int irs1125_remove(struct i2c_cli
v4l2_device_unregister_subdev(sd);
mutex_destroy(&irs1125->lock);
v4l2_ctrl_handler_free(&irs1125->ctrl_handler);
-
- return 0;
}
#if IS_ENABLED(CONFIG_OF)
--- a/drivers/media/platform/bcm2835/bcm2835-unicam.c
+++ b/drivers/media/platform/bcm2835/bcm2835-unicam.c
@@ -443,7 +443,7 @@ struct unicam_device {
/* ptr to sub device */
struct v4l2_subdev *sensor;
/* Pad config for the sensor */
- struct v4l2_subdev_pad_config *sensor_config;
+ struct v4l2_subdev_state *sensor_state;
enum v4l2_mbus_type bus_type;
/*
@@ -594,7 +594,7 @@ static int __subdev_get_format(struct un
};
int ret;
- ret = v4l2_subdev_call(dev->sensor, pad, get_fmt, dev->sensor_config,
+ ret = v4l2_subdev_call(dev->sensor, pad, get_fmt, dev->sensor_state,
&sd_fmt);
if (ret < 0)
return ret;
@@ -618,7 +618,7 @@ static int __subdev_set_format(struct un
sd_fmt.format = *fmt;
- ret = v4l2_subdev_call(dev->sensor, pad, set_fmt, dev->sensor_config,
+ ret = v4l2_subdev_call(dev->sensor, pad, set_fmt, dev->sensor_state,
&sd_fmt);
if (ret < 0)
return ret;
@@ -1094,7 +1094,7 @@ static int unicam_try_fmt_vid_cap(struct
*/
mbus_fmt->field = V4L2_FIELD_NONE;
- ret = v4l2_subdev_call(dev->sensor, pad, set_fmt, dev->sensor_config,
+ ret = v4l2_subdev_call(dev->sensor, pad, set_fmt, dev->sensor_state,
&sd_fmt);
if (ret && ret != -ENOIOCTLCMD && ret != -ENODEV)
return ret;
@@ -1116,7 +1116,7 @@ static int unicam_try_fmt_vid_cap(struct
mbus_fmt->code = fmt->code;
ret = v4l2_subdev_call(dev->sensor, pad, set_fmt,
- dev->sensor_config, &sd_fmt);
+ dev->sensor_state, &sd_fmt);
if (ret && ret != -ENOIOCTLCMD && ret != -ENODEV)
return ret;
@@ -2320,8 +2320,8 @@ static void unicam_release(struct kref *
v4l2_ctrl_handler_free(&unicam->ctrl_handler);
media_device_cleanup(&unicam->mdev);
- if (unicam->sensor_config)
- v4l2_subdev_free_pad_config(unicam->sensor_config);
+ if (unicam->sensor_state)
+ __v4l2_subdev_state_free(unicam->sensor_state);
kfree(unicam);
}
@@ -2579,12 +2579,14 @@ static void unregister_nodes(struct unic
static int unicam_probe_complete(struct unicam_device *unicam)
{
+ static struct lock_class_key key;
int ret;
unicam->v4l2_dev.notify = unicam_notify;
- unicam->sensor_config = v4l2_subdev_alloc_pad_config(unicam->sensor);
- if (!unicam->sensor_config)
+ unicam->sensor_state = __v4l2_subdev_state_alloc(unicam->sensor,
+ "unicam:async->lock", &key);
+ if (!unicam->sensor_state)
return -ENOMEM;
unicam->sensor_embedded_data = (unicam->sensor->entity.num_pads >= 2);
--- a/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
+++ b/drivers/staging/vc04_services/bcm2835-isp/bcm2835-v4l2-isp.c
@@ -1465,7 +1465,7 @@ queue_cleanup:
}
/* Unregister one of the /dev/video<N> nodes associated with the ISP. */
-static void unregister_node(struct bcm2835_isp_node *node)
+static void bcm2835_unregister_node(struct bcm2835_isp_node *node)
{
struct bcm2835_isp_dev *dev = node_get_dev(node);
@@ -1668,7 +1668,7 @@ static int bcm2835_isp_remove(struct pla
media_controller_unregister(dev);
for (i = 0; i < BCM2835_ISP_NUM_NODES; i++)
- unregister_node(&dev->node[i]);
+ bcm2835_unregister_node(&dev->node[i]);
v4l2_device_unregister(&dev->v4l2_dev);