All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: linux-media@vger.kernel.org
Cc: Steve Longerbeam <slongerbeam@gmail.com>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Rui Miguel Silva <rmfrfs@gmail.com>
Subject: [PATCH 14/14] media: imx: imx7-mipi-csis: Implement the .enum_mbus_code() operation
Date: Fri, 13 Mar 2020 01:47:22 +0200	[thread overview]
Message-ID: <20200312234722.23483-15-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <20200312234722.23483-1-laurent.pinchart@ideasonboard.com>

Implement the subdev pad .enum_mbus_code() operation to enumerate media
bus codes on the sink and source pads.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/staging/media/imx/imx7-mipi-csis.c | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/staging/media/imx/imx7-mipi-csis.c b/drivers/staging/media/imx/imx7-mipi-csis.c
index 66ff73919371..38f465256879 100644
--- a/drivers/staging/media/imx/imx7-mipi-csis.c
+++ b/drivers/staging/media/imx/imx7-mipi-csis.c
@@ -752,6 +752,38 @@ static int mipi_csis_get_fmt(struct v4l2_subdev *mipi_sd,
 	return 0;
 }
 
+static int mipi_csis_enum_mbus_code(struct v4l2_subdev *mipi_sd,
+				    struct v4l2_subdev_pad_config *cfg,
+				    struct v4l2_subdev_mbus_code_enum *code)
+{
+	struct csi_state *state = mipi_sd_to_csis_state(mipi_sd);
+
+	/*
+	 * The CSIS can't transcode in any way, the source format is identical
+	 * to the sink format.
+	 */
+	if (code->pad == CSIS_PAD_SOURCE) {
+		struct v4l2_mbus_framefmt *fmt;
+
+		if (code->index > 0)
+			return -EINVAL;
+
+		fmt = mipi_csis_get_format(state, cfg, code->which, code->pad);
+		code->code = fmt->code;
+		return 0;
+	}
+
+	if (code->pad != CSIS_PAD_SINK)
+		return -EINVAL;
+
+	if (code->index >= ARRAY_SIZE(mipi_csis_formats))
+		return -EINVAL;
+
+	code->code = mipi_csis_formats[code->index].code;
+
+	return 0;
+}
+
 static int mipi_csis_set_fmt(struct v4l2_subdev *mipi_sd,
 			     struct v4l2_subdev_pad_config *cfg,
 			     struct v4l2_subdev_format *sdformat)
@@ -881,6 +913,7 @@ static const struct v4l2_subdev_video_ops mipi_csis_video_ops = {
 
 static const struct v4l2_subdev_pad_ops mipi_csis_pad_ops = {
 	.init_cfg		= mipi_csis_init_cfg,
+	.enum_mbus_code		= mipi_csis_enum_mbus_code,
 	.get_fmt		= mipi_csis_get_fmt,
 	.set_fmt		= mipi_csis_set_fmt,
 };
-- 
Regards,

Laurent Pinchart


  parent reply	other threads:[~2020-03-12 23:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-12 23:47 [PATCH 00/14] media: imx: Miscellaneous fixes for i.MX7 CSI-2 receiver Laurent Pinchart
2020-03-12 23:47 ` [PATCH 01/14] media: imx: imx7-mipi-csis: Cleanup and fix subdev pad format handling Laurent Pinchart
2020-03-12 23:47 ` [PATCH 02/14] media: imx: imx7-mipi-csis: Centralize initialization of pad formats Laurent Pinchart
2020-03-12 23:47 ` [PATCH 03/14] media: imx: imx7-mipi-csis: Add missing RAW formats Laurent Pinchart
2020-03-12 23:47 ` [PATCH 04/14] media: imx: imx7-mipi-csis: Expose correct YUV formats Laurent Pinchart
2020-03-12 23:47 ` [PATCH 05/14] media: imx: imx7-mipi-csis: Fix MEDIA_BUS_FMT_UYVY8_2X8 data alignment Laurent Pinchart
2020-03-12 23:47 ` [PATCH 06/14] media: imx: imx7-mipi-csis: Add MEDIA_BUS_FMT_UYVY10_2X10 support Laurent Pinchart
2020-03-12 23:47 ` [PATCH 07/14] media: imx: imx7-mipi-csis: Rename data_alignment field to width Laurent Pinchart
2020-03-12 23:47 ` [PATCH 08/14] media: imx: imx7-mipi-csis: Align image width based on format Laurent Pinchart
2020-03-12 23:47 ` [PATCH 09/14] media: imx: imx7-mipi-csis: Never set MIPI_CSIS_ISPCFG_ALIGN_32BIT Laurent Pinchart
2020-03-12 23:47 ` [PATCH 10/14] media: imx: imx7-mipi-csis: Align macro definitions Laurent Pinchart
2020-03-12 23:47 ` [PATCH 11/14] media: imx: imx7-mipi-csis: Remove link setup on source pad Laurent Pinchart
2020-03-12 23:47 ` [PATCH 12/14] media: imx: imx7-mipi-csis: Cleanup includes Laurent Pinchart
2020-03-12 23:47 ` [PATCH 13/14] media: imx: imx7-mipi-csis: Don't use imx-media-utils helpers Laurent Pinchart
2020-03-25  9:13   ` Hans Verkuil
2020-03-25  9:17     ` Laurent Pinchart
2020-03-25 17:08     ` Steve Longerbeam
2020-03-12 23:47 ` Laurent Pinchart [this message]
2020-03-16 10:47 ` [PATCH 00/14] media: imx: Miscellaneous fixes for i.MX7 CSI-2 receiver Rui Miguel Silva

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=20200312234722.23483-15-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=rmfrfs@gmail.com \
    --cc=slongerbeam@gmail.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.