aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRishikesh Donadkar <r-donadkar@ti.com>2024-11-21 19:27:53 +0530
committerXulin Sun <xulin.sun@windriver.com>2025-03-11 16:59:46 +0800
commit2e2c9a25140690d0c7f14ff3affad115a4183d4e (patch)
treea14fbb2ed177ef3fa928d971395f8cae71b1b972
parentf417c5c9a806073b8af854f2684a1ca9db8b83ed (diff)
downloadlinux-yocto-2e2c9a25140690d0c7f14ff3affad115a4183d4e.tar.gz
media: ov5640: Add hook to pass frame descriptor
commit 7e9ef6bcb65df25576a049b58dcd206626874e2a from git://git.ti.com/ti-linux-kernel/ti-linux-kernel.git The .get_frame_desc hook is called to propagate information to the downstream element in the camera pipeline. Support it for OV5640. Signed-off-by: Rishikesh Donadkar <r-donadkar@ti.com> Signed-off-by: Xulin Sun <xulin.sun@windriver.com>
-rw-r--r--drivers/media/i2c/ov5640.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 9b56fc1cd3d7..2251bbc7cccd 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -25,6 +25,7 @@
#include <media/v4l2-event.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-subdev.h>
+#include <media/mipi-csi2.h>
/* min/typical/max system clock (xclk) frequencies */
#define OV5640_XCLK_MIN 6000000
@@ -3765,6 +3766,45 @@ static int ov5640_init_cfg(struct v4l2_subdev *sd,
return 0;
}
+static int ov5640_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
+ struct v4l2_mbus_frame_desc *fd)
+{
+ struct ov5640_dev *sensor = to_ov5640_dev(sd);
+ u32 bpp;
+ int ret = 0;
+
+ if (pad != 0)
+ return -EINVAL;
+
+ mutex_lock(&sensor->lock);
+
+ memset(fd, 0, sizeof(*fd));
+
+ fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+
+ /* pixel stream */
+
+ bpp = ov5640_code_to_bpp(sensor, sensor->fmt.code);
+
+ fd->entry[fd->num_entries].stream = 0;
+
+ fd->entry[fd->num_entries].flags = V4L2_MBUS_FRAME_DESC_FL_LEN_MAX;
+ fd->entry[fd->num_entries].length =
+ (sensor->current_mode->width
+ * sensor->current_mode->height * bpp) / 8;
+ fd->entry[fd->num_entries].pixelcode = sensor->fmt.code;
+ fd->entry[fd->num_entries].bus.csi2.vc = 0;
+ if (sensor->fmt.code == MEDIA_BUS_FMT_SRGGB8_1X8)
+ fd->entry[fd->num_entries].bus.csi2.dt = 0x2a; /* SRGGB8 */
+ else
+ fd->entry[fd->num_entries].bus.csi2.dt = MIPI_CSI2_DT_YUV422_8B;
+ fd->num_entries++;
+
+ mutex_unlock(&sensor->lock);
+
+ return ret;
+}
+
static const struct v4l2_subdev_core_ops ov5640_core_ops = {
.log_status = v4l2_ctrl_subdev_log_status,
.subscribe_event = v4l2_ctrl_subdev_subscribe_event,
@@ -3785,6 +3825,7 @@ static const struct v4l2_subdev_pad_ops ov5640_pad_ops = {
.get_selection = ov5640_get_selection,
.enum_frame_size = ov5640_enum_frame_size,
.enum_frame_interval = ov5640_enum_frame_interval,
+ .get_frame_desc = ov5640_get_frame_desc,
};
static const struct v4l2_subdev_ops ov5640_subdev_ops = {