From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
tomi.valkeinen@ideasonboard.com, bingbu.cao@intel.com,
hongju.wang@intel.com, hverkuil@xs4all.nl,
Andrey Konovalov <andrey.konovalov@linaro.org>,
Jacopo Mondi <jacopo.mondi@ideasonboard.com>,
Dmitry Perchanov <dmitry.perchanov@intel.com>,
"Ng, Khai Wen" <khai.wen.ng@intel.com>
Subject: [PATCH v6 25/28] media: ccs: Support frame descriptors
Date: Tue, 3 Oct 2023 15:08:10 +0300 [thread overview]
Message-ID: <20231003120813.77726-16-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20231003115237.76828-1-sakari.ailus@linux.intel.com>
Provide information on the frame layout using frame descriptors.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ccs/ccs-core.c | 60 +++++++++++++++++++++++++++++++
drivers/media/i2c/ccs/ccs-quirk.h | 7 ++++
drivers/media/i2c/ccs/ccs.h | 4 +++
3 files changed, 71 insertions(+)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 4924ec460d81..75abb18ae847 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -25,6 +25,7 @@
#include <linux/slab.h>
#include <linux/smiapp.h>
#include <linux/v4l2-mediabus.h>
+#include <media/mipi-csi2.h>
#include <media/v4l2-fwnode.h>
#include <media/v4l2-device.h>
#include <uapi/linux/ccs.h>
@@ -235,6 +236,33 @@ static int ccs_read_all_limits(struct ccs_sensor *sensor)
return ret;
}
+static u8 ccs_mipi_csi2_data_type(unsigned int bpp)
+{
+ switch (bpp) {
+ case 6:
+ return MIPI_CSI2_DT_RAW6;
+ case 7:
+ return MIPI_CSI2_DT_RAW7;
+ case 8:
+ return MIPI_CSI2_DT_RAW8;
+ case 10:
+ return MIPI_CSI2_DT_RAW10;
+ case 12:
+ return MIPI_CSI2_DT_RAW12;
+ case 14:
+ return MIPI_CSI2_DT_RAW14;
+ case 16:
+ return MIPI_CSI2_DT_RAW16;
+ case 20:
+ return MIPI_CSI2_DT_RAW20;
+ case 24:
+ return MIPI_CSI2_DT_RAW24;
+ default:
+ WARN_ON(1);
+ return 0;
+ }
+}
+
static int ccs_read_frame_fmt(struct ccs_sensor *sensor)
{
struct i2c_client *client = v4l2_get_subdevdata(&sensor->src->sd);
@@ -2616,6 +2644,37 @@ static int ccs_set_selection(struct v4l2_subdev *subdev,
return ret;
}
+static int ccs_get_frame_desc(struct v4l2_subdev *subdev, unsigned int pad,
+ struct v4l2_mbus_frame_desc *desc)
+{
+ struct ccs_sensor *sensor = to_ccs_sensor(subdev);
+ struct v4l2_mbus_frame_desc_entry *entry = desc->entry;
+
+ if (ccs_has_quirk(sensor, frame_desc))
+ return ccs_call_quirk(sensor, frame_desc, desc);
+
+ switch (sensor->hwcfg.csi_signalling_mode) {
+ case CCS_CSI_SIGNALING_MODE_CSI_2_DPHY:
+ case CCS_CSI_SIGNALING_MODE_CSI_2_CPHY:
+ desc->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2;
+ break;
+ default:
+ /* FIXME: CCP2 support */
+ return -EINVAL;
+ }
+
+ entry->pixelcode = sensor->csi_format->code;
+ entry->stream = CCS_STREAM_PIXEL;
+ entry->bus.csi2.dt =
+ sensor->csi_format->width == sensor->csi_format->compressed ?
+ ccs_mipi_csi2_data_type(sensor->csi_format->compressed) :
+ CCS_DEFAULT_COMPRESSED_DT;
+ entry++;
+ desc->num_entries++;
+
+ return 0;
+}
+
static int ccs_get_skip_frames(struct v4l2_subdev *subdev, u32 *frames)
{
struct ccs_sensor *sensor = to_ccs_sensor(subdev);
@@ -3042,6 +3101,7 @@ static const struct v4l2_subdev_pad_ops ccs_pad_ops = {
.set_selection = ccs_set_selection,
.enable_streams = ccs_enable_streams,
.disable_streams = ccs_disable_streams,
+ .get_frame_desc = ccs_get_frame_desc,
};
static const struct v4l2_subdev_sensor_ops ccs_sensor_ops = {
diff --git a/drivers/media/i2c/ccs/ccs-quirk.h b/drivers/media/i2c/ccs/ccs-quirk.h
index 0b1a64958d71..13f334fe0ac8 100644
--- a/drivers/media/i2c/ccs/ccs-quirk.h
+++ b/drivers/media/i2c/ccs/ccs-quirk.h
@@ -36,6 +36,7 @@ struct ccs_sensor;
* access may be done by the caller (default read
* value is zero), else negative error code on error
* @flags: Quirk flags
+ * @frame_desc: Obtain the frame descriptor
*/
struct ccs_quirk {
int (*limits)(struct ccs_sensor *sensor);
@@ -46,6 +47,8 @@ struct ccs_quirk {
int (*init)(struct ccs_sensor *sensor);
int (*reg_access)(struct ccs_sensor *sensor, bool write, u32 *reg,
u32 *val);
+ int (*frame_desc)(struct ccs_sensor *sensor,
+ struct v4l2_mbus_frame_desc *desc);
unsigned long flags;
};
@@ -62,6 +65,10 @@ struct ccs_reg_8 {
.val = _val, \
}
+#define ccs_has_quirk(sensor, _quirk) \
+ ((sensor)->minfo.quirk && \
+ (sensor)->minfo.quirk->_quirk)
+
#define ccs_call_quirk(sensor, _quirk, ...) \
((sensor)->minfo.quirk && \
(sensor)->minfo.quirk->_quirk ? \
diff --git a/drivers/media/i2c/ccs/ccs.h b/drivers/media/i2c/ccs/ccs.h
index 043a679e115c..7fd9b6493d2b 100644
--- a/drivers/media/i2c/ccs/ccs.h
+++ b/drivers/media/i2c/ccs/ccs.h
@@ -45,6 +45,8 @@
#define CCS_COLOUR_COMPONENTS 4
+#define CCS_DEFAULT_COMPRESSED_DT 0x30
+
#define SMIAPP_NAME "smiapp"
#define CCS_NAME "ccs"
@@ -174,6 +176,8 @@ struct ccs_csi_data_format {
#define CCS_PAD_SRC 1
#define CCS_PADS 2
+#define CCS_STREAM_PIXEL 0
+
struct ccs_binning_subtype {
u8 horizontal:4;
u8 vertical:4;
--
2.39.2
next prev parent reply other threads:[~2023-10-03 12:08 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-03 11:52 [PATCH v6 00/28] Generic line based metadata support, internal pads Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 01/28] media: mc: Add INTERNAL pad flag Sakari Ailus
2023-10-05 9:52 ` Hans Verkuil
2023-10-05 10:22 ` Sakari Ailus
2023-10-05 11:16 ` Hans Verkuil
2023-10-25 21:17 ` Sakari Ailus
2023-10-11 19:22 ` Sakari Ailus
2023-10-05 11:04 ` Tomi Valkeinen
2023-10-11 19:35 ` Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 02/28] media: uapi: Add generic serial metadata mbus formats Sakari Ailus
[not found] ` <20231027144742.GC19539@pendragon.ideasonboard.com>
2023-10-27 20:43 ` Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 03/28] media: uapi: Document which mbus format fields are valid for metadata Sakari Ailus
2023-10-05 11:28 ` Tomi Valkeinen
2023-10-11 19:41 ` Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 04/28] media: uapi: Add generic 8-bit metadata format definitions Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 05/28] media: v4l: Support line-based metadata capture Sakari Ailus
2023-10-05 10:00 ` Hans Verkuil
2023-10-03 11:52 ` [PATCH v6 06/28] media: uapi: ccs: Add media bus code for MIPI CCS embedded data Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 07/28] media: Documentation: ccs: Document routing Sakari Ailus
2023-10-03 11:52 ` [PATCH v6 08/28] media: Documentation: Additional streams generally don't harm capture Sakari Ailus
2023-10-05 11:40 ` Tomi Valkeinen
2023-10-03 11:52 ` [PATCH v6 09/28] media: Documentation: Document embedded data guidelines for camera sensors Sakari Ailus
2023-10-05 10:10 ` Hans Verkuil
2023-10-05 11:53 ` Tomi Valkeinen
2023-10-05 14:13 ` Sakari Ailus
2023-10-05 14:11 ` Sakari Ailus
2023-10-05 10:14 ` Hans Verkuil
2023-10-05 14:35 ` Sakari Ailus
2023-10-03 12:07 ` [PATCH v6 10/28] media: Documentation: v4l: Document source routes Sakari Ailus
2023-10-05 10:26 ` Hans Verkuil
2023-10-09 17:31 ` Sakari Ailus
2023-10-05 12:37 ` Tomi Valkeinen
2023-10-09 17:26 ` Sakari Ailus
2023-10-03 12:07 ` [PATCH v6 11/28] media: Documentation: Document S_ROUTING behaviour Sakari Ailus
2023-10-05 12:59 ` Tomi Valkeinen
2023-10-12 20:00 ` Sakari Ailus
2023-10-03 12:07 ` [PATCH v6 12/28] media: v4l: subdev: Add helpers for format, crop and compose pointers Sakari Ailus
2023-10-05 13:12 ` Tomi Valkeinen
2023-10-13 6:05 ` Sakari Ailus
2023-10-03 12:07 ` [PATCH v6 13/28] media: v4l: subdev: Add a function to lock two sub-device states, use it Sakari Ailus
2023-10-09 10:34 ` Tomi Valkeinen
2023-10-25 21:11 ` Sakari Ailus
2023-10-03 12:07 ` [PATCH v6 14/28] media: v4l: subdev: Move G_ROUTING handling below S_ROUTING Sakari Ailus
2023-10-09 10:36 ` Tomi Valkeinen
2023-10-25 21:05 ` Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 15/28] media: v4l: subdev: Copy argument back to user also for S_ROUTING Sakari Ailus
2023-10-05 10:37 ` Hans Verkuil
2023-10-12 20:09 ` Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 16/28] media: v4l: subdev: Add len_routes field to struct v4l2_subdev_routing Sakari Ailus
2023-10-05 11:00 ` Hans Verkuil
2023-11-28 13:30 ` Sakari Ailus
2023-12-04 13:36 ` Hans Verkuil
2023-10-03 12:08 ` [PATCH v6 17/28] media: v4l: subdev: Return routes set using S_ROUTING Sakari Ailus
2023-10-05 11:05 ` Hans Verkuil
2023-10-25 20:12 ` Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 18/28] media: uapi: Allow a larger number of routes than there's room for Sakari Ailus
2023-10-05 11:08 ` Hans Verkuil
2023-10-25 21:00 ` Sakari Ailus
2023-10-09 10:56 ` Tomi Valkeinen
2023-10-25 21:07 ` Laurent Pinchart
[not found] ` <adaadd6e-c163-4c3a-b851-b2de184b5b5e@xs4all.nl>
2023-10-30 7:57 ` Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 19/28] media: v4l: subdev: Add trivial set_routing support Sakari Ailus
2023-10-09 11:09 ` Tomi Valkeinen
2023-10-03 12:08 ` [PATCH v6 20/28] media: uapi: v4l: subdev: Enable streams API Sakari Ailus
2023-10-09 12:52 ` Tomi Valkeinen
2023-10-25 21:13 ` Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 21/28] media: ccs: No need to set streaming to false in power off Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 22/28] media: ccs: Use {enable,disable}_streams operations Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 23/28] media: ccs: Track streaming state Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 24/28] media: ccs: Move ccs_validate_csi_data_format up Sakari Ailus
2023-10-03 12:08 ` Sakari Ailus [this message]
2023-10-03 12:08 ` [PATCH v6 26/28] media: ccs: Add support for embedded data stream Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 27/28] media: ccs: Remove ccs_get_crop_compose helper Sakari Ailus
2023-10-03 12:08 ` [PATCH v6 28/28] media: ccs: Rely on sub-device state locking Sakari Ailus
2023-10-05 8:05 ` [PATCH v6 00/28] Generic line based metadata support, internal pads Tomi Valkeinen
2023-10-05 9:04 ` Sakari Ailus
2023-10-05 11:17 ` Tomi Valkeinen
2023-10-09 12:16 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231003120813.77726-16-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=andrey.konovalov@linaro.org \
--cc=bingbu.cao@intel.com \
--cc=dmitry.perchanov@intel.com \
--cc=hongju.wang@intel.com \
--cc=hverkuil@xs4all.nl \
--cc=jacopo.mondi@ideasonboard.com \
--cc=khai.wen.ng@intel.com \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=tomi.valkeinen@ideasonboard.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.