From: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
To: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-staging@lists.linux.dev
Subject: [RFC 08/12] staging: media: max96712: allow enumerating MBUS codes
Date: Fri, 31 Jan 2025 18:34:02 +0200 [thread overview]
Message-ID: <20250131163408.2019144-9-laurentiu.palcu@oss.nxp.com> (raw)
In-Reply-To: <20250131163408.2019144-1-laurentiu.palcu@oss.nxp.com>
This would allow apps to enumerate the supported MBUS formats available
on a certain pad.
Signed-off-by: Laurentiu Palcu <laurentiu.palcu@oss.nxp.com>
---
drivers/staging/media/max96712/max96712.c | 142 ++++++++++++++++++++++
1 file changed, 142 insertions(+)
diff --git a/drivers/staging/media/max96712/max96712.c b/drivers/staging/media/max96712/max96712.c
index a078e4c67c360..d735798effa5c 100644
--- a/drivers/staging/media/max96712/max96712.c
+++ b/drivers/staging/media/max96712/max96712.c
@@ -199,6 +199,107 @@ struct max96712_priv {
enum max96712_pattern pattern;
};
+struct max96712_format_info {
+ u32 code;
+ u8 data_type;
+};
+
+static const struct max96712_format_info max96712_formats[] = {
+ /* YUV formats */
+ {
+ .code = MEDIA_BUS_FMT_UYVY8_1X16,
+ .data_type = MIPI_CSI2_DT_YUV422_8B,
+ }, {
+ .code = MEDIA_BUS_FMT_VYUY8_1X16,
+ .data_type = MIPI_CSI2_DT_YUV422_8B,
+ }, {
+ .code = MEDIA_BUS_FMT_YUYV8_1X16,
+ .data_type = MIPI_CSI2_DT_YUV422_8B,
+ }, {
+ .code = MEDIA_BUS_FMT_YVYU8_1X16,
+ .data_type = MIPI_CSI2_DT_YUV422_8B,
+ }, {
+ .code = MEDIA_BUS_FMT_UYVY10_1X20,
+ .data_type = MIPI_CSI2_DT_YUV422_10B,
+ }, {
+ .code = MEDIA_BUS_FMT_VYUY10_1X20,
+ .data_type = MIPI_CSI2_DT_YUV422_10B,
+ }, {
+ .code = MEDIA_BUS_FMT_YUYV10_1X20,
+ .data_type = MIPI_CSI2_DT_YUV422_10B,
+ }, {
+ .code = MEDIA_BUS_FMT_YVYU10_1X20,
+ .data_type = MIPI_CSI2_DT_YUV422_10B,
+ },
+ /* RGB formats */
+ {
+ .code = MEDIA_BUS_FMT_RGB565_1X16,
+ .data_type = MIPI_CSI2_DT_RGB565,
+ }, {
+ .code = MEDIA_BUS_FMT_BGR888_1X24,
+ .data_type = MIPI_CSI2_DT_RGB888,
+ }, {
+ .code = MEDIA_BUS_FMT_RGB888_1X24,
+ .data_type = MIPI_CSI2_DT_RGB888,
+ }, {
+ .code = MEDIA_BUS_FMT_RBG888_1X24,
+ .data_type = MIPI_CSI2_DT_RGB888,
+ }, {
+ .code = MEDIA_BUS_FMT_GBR888_1X24,
+ .data_type = MIPI_CSI2_DT_RGB888,
+ },
+ /* RAW formats */
+ {
+ .code = MEDIA_BUS_FMT_SBGGR8_1X8,
+ .data_type = MIPI_CSI2_DT_RAW8,
+ }, {
+ .code = MEDIA_BUS_FMT_SGBRG8_1X8,
+ .data_type = MIPI_CSI2_DT_RAW8,
+ }, {
+ .code = MEDIA_BUS_FMT_SGRBG8_1X8,
+ .data_type = MIPI_CSI2_DT_RAW8,
+ }, {
+ .code = MEDIA_BUS_FMT_SRGGB8_1X8,
+ .data_type = MIPI_CSI2_DT_RAW8,
+ }, {
+ .code = MEDIA_BUS_FMT_SBGGR12_1X12,
+ .data_type = MIPI_CSI2_DT_RAW12,
+ }, {
+ .code = MEDIA_BUS_FMT_SGBRG12_1X12,
+ .data_type = MIPI_CSI2_DT_RAW12,
+ }, {
+ .code = MEDIA_BUS_FMT_SGRBG12_1X12,
+ .data_type = MIPI_CSI2_DT_RAW12,
+ }, {
+ .code = MEDIA_BUS_FMT_SRGGB12_1X12,
+ .data_type = MIPI_CSI2_DT_RAW12,
+ }, {
+ .code = MEDIA_BUS_FMT_SBGGR14_1X14,
+ .data_type = MIPI_CSI2_DT_RAW14,
+ }, {
+ .code = MEDIA_BUS_FMT_SGBRG14_1X14,
+ .data_type = MIPI_CSI2_DT_RAW14,
+ }, {
+ .code = MEDIA_BUS_FMT_SGRBG14_1X14,
+ .data_type = MIPI_CSI2_DT_RAW14,
+ }, {
+ .code = MEDIA_BUS_FMT_SRGGB14_1X14,
+ .data_type = MIPI_CSI2_DT_RAW14,
+ }, {
+ .code = MEDIA_BUS_FMT_SBGGR16_1X16,
+ .data_type = MIPI_CSI2_DT_RAW16,
+ }, {
+ .code = MEDIA_BUS_FMT_SGBRG16_1X16,
+ .data_type = MIPI_CSI2_DT_RAW16,
+ }, {
+ .code = MEDIA_BUS_FMT_SGRBG16_1X16,
+ .data_type = MIPI_CSI2_DT_RAW16,
+ }, {
+ .code = MEDIA_BUS_FMT_SRGGB16_1X16,
+ .data_type = MIPI_CSI2_DT_RAW16,
+ },
+};
+
static inline bool max96712_pad_is_sink(u32 pad)
{
return pad < MAX96712_FIRST_SOURCE_PAD || pad == MAX96712_VPG_PAD;
@@ -379,6 +480,46 @@ static void max96712_pattern_enable(struct max96712_priv *priv, bool enable)
}
}
+static int max96712_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state,
+ struct v4l2_subdev_mbus_code_enum *code)
+{
+ if (code->pad > MAX96712_VPG_PAD)
+ return -EINVAL;
+
+ if (max96712_pad_is_source(code->pad)) {
+ struct v4l2_mbus_framefmt *fmt;
+
+ if (code->index > 0)
+ return -EINVAL;
+
+ fmt = v4l2_subdev_state_get_opposite_stream_format(sd_state, code->pad,
+ code->stream);
+ if (!fmt)
+ return -EINVAL;
+
+ code->code = fmt->code;
+
+ return 0;
+ }
+
+ /* Internal VPG pad only supprts RGB888 */
+ if (code->pad == MAX96712_VPG_PAD) {
+ if (code->index > 0)
+ return -EINVAL;
+
+ code->code = MEDIA_BUS_FMT_RGB888_1X24;
+
+ return 0;
+ }
+
+ if (code->index >= ARRAY_SIZE(max96712_formats))
+ return -EINVAL;
+
+ code->code = max96712_formats[code->index].code;
+
+ return 0;
+}
+
static int max96712_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
struct v4l2_mbus_frame_desc *fd)
{
@@ -547,6 +688,7 @@ static const struct v4l2_subdev_internal_ops max96712_internal_ops = {
};
static const struct v4l2_subdev_pad_ops max96712_pad_ops = {
+ .enum_mbus_code = max96712_enum_mbus_code,
.get_fmt = v4l2_subdev_get_fmt,
.set_fmt = v4l2_subdev_get_fmt,
.enable_streams = max96712_enable_streams,
--
2.44.1
next prev parent reply other threads:[~2025-01-31 16:34 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 16:33 [RFC 00/12] staging: media: max96712: Add support for streams and multiple sensors Laurentiu Palcu
2025-01-31 16:33 ` [RFC 01/12] media: mc: Add INTERNAL pad flag Laurentiu Palcu
2025-01-31 16:33 ` [RFC 02/12] dt-bindings: i2c: maxim,max96712: add a couple of new properties Laurentiu Palcu
2025-02-03 22:00 ` Rob Herring
2025-01-31 16:33 ` [RFC 03/12] staging: media: max96712: convert to using CCI register access helpers Laurentiu Palcu
2025-01-31 16:33 ` [RFC 04/12] staging: media: max96712: change DT parsing routine Laurentiu Palcu
2025-02-01 10:30 ` Dan Carpenter
2025-01-31 16:33 ` [RFC 05/12] staging: media: max96712: add link frequency V4L2 control Laurentiu Palcu
2025-01-31 16:34 ` [RFC 06/12] staging: media: max96712: add I2C mux support Laurentiu Palcu
2025-01-31 16:34 ` [RFC 07/12] staging: media: max96712: add support for streams Laurentiu Palcu
2025-01-31 16:34 ` Laurentiu Palcu [this message]
2025-01-31 16:34 ` [RFC 09/12] staging: media: max96712: add set_fmt routine Laurentiu Palcu
2025-01-31 16:34 ` [RFC 10/12] staging: media: max96712: add gpiochip functionality Laurentiu Palcu
2025-02-06 18:40 ` Linus Walleij
2025-01-31 16:34 ` [RFC 11/12] staging: media: max96712: add fsync support Laurentiu Palcu
2025-01-31 16:34 ` [RFC 12/12] staging: media: max96712: allow streaming from connected sensors Laurentiu Palcu
2025-02-04 12:39 ` [RFC 00/12] staging: media: max96712: Add support for streams and multiple sensors Niklas Söderlund
2025-02-04 13:37 ` Laurentiu Palcu
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=20250131163408.2019144-9-laurentiu.palcu@oss.nxp.com \
--to=laurentiu.palcu@oss.nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mchehab@kernel.org \
--cc=niklas.soderlund@ragnatech.se \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®