From patchwork Mon May 18 10:24:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2292 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 69BDF1C07A5 for ; Mon, 18 May 2026 12:26:01 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-23452-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-23452-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 4CCBF30022D8 for ; Mon, 18 May 2026 10:25:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26D0D3E023E; Mon, 18 May 2026 10:25:57 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F31321FF25; Mon, 18 May 2026 10:25:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779099957; cv=none; b=Sp+1nLgbpFATek3dR6RUTzt/WBmbHaaYCxEKpS/WiuPCuNvwwjpvfBStmHFoKBPVXvySquY41yIBs//zjf8VkQOH8Twjw7T9ALixxI1KZVYGRNozWupxfWF/257PsX+NQGc3vaQ1cVnO3OmZl6FgSdkg6RDLHTswG8NXGSd+CAQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779099957; c=relaxed/simple; bh=+rA7zRMyBIseG+w6aT0DbMLWFLONB8COOVqZA+GGd4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pkg2kgaMIAcT9dfrcVKjN3Yr77sM3WNJsNjb4JvQasmZUcqFzSjVV1zj0taSdKKM8Eqv1ucVO6ZsHq39bPrxKun4E1R/wOh1sNVudMxDZqk4UqnO6rLpFxZPdOwqQ4CnfCVafUl8AA0QeilJtAygoyBm2t+exQXDUPAdsSEGQB4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 58CFA1F80041; Mon, 18 May 2026 10:25:53 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id C8ADEB407FA; Mon, 18 May 2026 10:25:52 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id D38ECB407ED; Mon, 18 May 2026 10:24:52 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 01/16] media: sun6i-csi: bridge: Use V4L2 subdev active state Date: Mon, 18 May 2026 12:24:36 +0200 Message-ID: <20260518102451.417971-2-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Arash Golgol Use the V4L2 subdev active state API to store the active format. This simplifies the driver not only by dropping the bridge mbus_format field, but it also allows dropping the bridge lock, replaced with the state lock. Previously, capture accessed bridge private state directly. After moving to framework-managed state, resolve the format through the subdev pad API. The sun6i-csi-bridge hardware does not perform any format conversion. Enforce identical formats on the sink and source pads in the set_fmt() and init_state() callbacks. Signed-off-by: Arash Golgol Reviewed-by: Paul Kocialkowski Tested-by: Paul Kocialkowski Reviewed-by: Laurent Pinchart --- .../sunxi/sun6i-csi/sun6i_csi_bridge.c | 155 ++++++++---------- .../sunxi/sun6i-csi/sun6i_csi_bridge.h | 9 - .../sunxi/sun6i-csi/sun6i_csi_capture.c | 27 ++- 3 files changed, 86 insertions(+), 105 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c index d006d9dd0170..43a85bcc2ba2 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c @@ -13,26 +13,6 @@ #include "sun6i_csi_bridge.h" #include "sun6i_csi_reg.h" -/* Helpers */ - -void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev, - unsigned int *width, unsigned int *height) -{ - if (width) - *width = csi_dev->bridge.mbus_format.width; - if (height) - *height = csi_dev->bridge.mbus_format.height; -} - -void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev, - u32 *mbus_code, u32 *field) -{ - if (mbus_code) - *mbus_code = csi_dev->bridge.mbus_format.code; - if (field) - *field = csi_dev->bridge.mbus_format.field; -} - /* Format */ static const struct sun6i_csi_bridge_format sun6i_csi_bridge_formats[] = { @@ -226,7 +206,8 @@ static void sun6i_csi_bridge_disable(struct sun6i_csi_device *csi_dev) } static void -sun6i_csi_bridge_configure_parallel(struct sun6i_csi_device *csi_dev) +sun6i_csi_bridge_configure_parallel(struct sun6i_csi_device *csi_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct device *dev = csi_dev->dev; struct regmap *regmap = csi_dev->regmap; @@ -234,11 +215,9 @@ sun6i_csi_bridge_configure_parallel(struct sun6i_csi_device *csi_dev) &csi_dev->bridge.source_parallel.endpoint; unsigned char bus_width = endpoint->bus.parallel.bus_width; unsigned int flags = endpoint->bus.parallel.flags; - u32 field; + u32 field = mbus_format->field; u32 value = SUN6I_CSI_IF_CFG_IF_CSI; - sun6i_csi_bridge_format(csi_dev, NULL, &field); - if (field == V4L2_FIELD_INTERLACED || field == V4L2_FIELD_INTERLACED_TB || field == V4L2_FIELD_INTERLACED_BT) @@ -317,13 +296,12 @@ sun6i_csi_bridge_configure_parallel(struct sun6i_csi_device *csi_dev) } static void -sun6i_csi_bridge_configure_mipi_csi2(struct sun6i_csi_device *csi_dev) +sun6i_csi_bridge_configure_mipi_csi2(struct sun6i_csi_device *csi_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct regmap *regmap = csi_dev->regmap; u32 value = SUN6I_CSI_IF_CFG_IF_MIPI; - u32 field; - - sun6i_csi_bridge_format(csi_dev, NULL, &field); + u32 field = mbus_format->field; if (field == V4L2_FIELD_INTERLACED || field == V4L2_FIELD_INTERLACED_TB || @@ -335,19 +313,20 @@ sun6i_csi_bridge_configure_mipi_csi2(struct sun6i_csi_device *csi_dev) regmap_write(regmap, SUN6I_CSI_IF_CFG_REG, value); } -static void sun6i_csi_bridge_configure_format(struct sun6i_csi_device *csi_dev) +static void +sun6i_csi_bridge_configure_format(struct sun6i_csi_device *csi_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct regmap *regmap = csi_dev->regmap; bool capture_streaming = csi_dev->capture.state.streaming; const struct sun6i_csi_bridge_format *bridge_format; const struct sun6i_csi_capture_format *capture_format; - u32 mbus_code, field, pixelformat; + u32 pixelformat; + u32 field = mbus_format->field; u8 input_format, input_yuv_seq, output_format; u32 value = 0; - sun6i_csi_bridge_format(csi_dev, &mbus_code, &field); - - bridge_format = sun6i_csi_bridge_format_find(mbus_code); + bridge_format = sun6i_csi_bridge_format_find(mbus_format->code); if (WARN_ON(!bridge_format)) return; @@ -391,16 +370,17 @@ static void sun6i_csi_bridge_configure_format(struct sun6i_csi_device *csi_dev) } static void sun6i_csi_bridge_configure(struct sun6i_csi_device *csi_dev, - struct sun6i_csi_bridge_source *source) + struct sun6i_csi_bridge_source *source, + const struct v4l2_mbus_framefmt *mbus_format) { struct sun6i_csi_bridge *bridge = &csi_dev->bridge; if (source == &bridge->source_parallel) - sun6i_csi_bridge_configure_parallel(csi_dev); + sun6i_csi_bridge_configure_parallel(csi_dev, mbus_format); else - sun6i_csi_bridge_configure_mipi_csi2(csi_dev); + sun6i_csi_bridge_configure_mipi_csi2(csi_dev, mbus_format); - sun6i_csi_bridge_configure_format(csi_dev); + sun6i_csi_bridge_configure_format(csi_dev, mbus_format); } /* V4L2 Subdev */ @@ -415,6 +395,8 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) struct sun6i_csi_bridge_source *source; struct v4l2_subdev *source_subdev; struct media_pad *remote_pad; + struct v4l2_subdev_state *state; + const struct v4l2_mbus_framefmt *mbus_format; int ret; /* Source */ @@ -433,6 +415,10 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) else source = &bridge->source_mipi_csi2; + /* Active State */ + + state = v4l2_subdev_lock_and_get_active_state(subdev); + if (!on) { v4l2_subdev_call(source_subdev, video, s_stream, 0); ret = 0; @@ -443,7 +429,7 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) ret = pm_runtime_resume_and_get(dev); if (ret < 0) - return ret; + goto unlock; /* Clear */ @@ -451,7 +437,9 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) /* Configure */ - sun6i_csi_bridge_configure(csi_dev, source); + mbus_format = v4l2_subdev_state_get_format(state, + SUN6I_CSI_BRIDGE_PAD_SINK); + sun6i_csi_bridge_configure(csi_dev, source, mbus_format); if (capture_streaming) sun6i_csi_capture_configure(csi_dev); @@ -472,7 +460,8 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) if (ret && ret != -ENOIOCTLCMD) goto disable; - return 0; + ret = 0; + goto unlock; disable: if (capture_streaming) @@ -482,6 +471,8 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) pm_runtime_put(dev); +unlock: + v4l2_subdev_unlock_state(state); return ret; } @@ -504,21 +495,23 @@ sun6i_csi_bridge_mbus_format_prepare(struct v4l2_mbus_framefmt *mbus_format) static int sun6i_csi_bridge_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct sun6i_csi_device *csi_dev = v4l2_get_subdevdata(subdev); - unsigned int pad = SUN6I_CSI_BRIDGE_PAD_SINK; - struct v4l2_mbus_framefmt *mbus_format = - v4l2_subdev_state_get_format(state, pad); - struct mutex *lock = &csi_dev->bridge.lock; + unsigned int pad; - mutex_lock(lock); + /* + * This subdev does not perform format conversion, + * initialize both pads identically. + */ + for (pad = 0; pad < subdev->entity.num_pads; pad++) { + struct v4l2_mbus_framefmt *mbus_format; - mbus_format->code = sun6i_csi_bridge_formats[0].mbus_code; - mbus_format->width = 1280; - mbus_format->height = 720; + mbus_format = v4l2_subdev_state_get_format(state, pad); - sun6i_csi_bridge_mbus_format_prepare(mbus_format); + mbus_format->code = sun6i_csi_bridge_formats[0].mbus_code; + mbus_format->width = 1280; + mbus_format->height = 720; - mutex_unlock(lock); + sun6i_csi_bridge_mbus_format_prepare(mbus_format); + } return 0; } @@ -536,53 +529,32 @@ sun6i_csi_bridge_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } -static int sun6i_csi_bridge_get_fmt(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *state, - struct v4l2_subdev_format *format) -{ - struct sun6i_csi_device *csi_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi_dev->bridge.lock; - - mutex_lock(lock); - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *mbus_format = *v4l2_subdev_state_get_format(state, - format->pad); - else - *mbus_format = csi_dev->bridge.mbus_format; - - mutex_unlock(lock); - - return 0; -} - static int sun6i_csi_bridge_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct sun6i_csi_device *csi_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi_dev->bridge.lock; + struct v4l2_mbus_framefmt *fmt; - mutex_lock(lock); + /* The format on the source pad always matches the sink pad. */ + if (format->pad != SUN6I_CSI_BRIDGE_PAD_SINK) + return v4l2_subdev_get_fmt(subdev, state, format); - sun6i_csi_bridge_mbus_format_prepare(mbus_format); + sun6i_csi_bridge_mbus_format_prepare(&format->format); - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *v4l2_subdev_state_get_format(state, format->pad) = - *mbus_format; - else - csi_dev->bridge.mbus_format = *mbus_format; + /* Set the format on the sink pad. */ + fmt = v4l2_subdev_state_get_format(state, format->pad); + *fmt = format->format; - mutex_unlock(lock); + /* Propagate the format to the source pad. */ + fmt = v4l2_subdev_state_get_format(state, SUN6I_CSI_BRIDGE_PAD_SOURCE); + *fmt = format->format; return 0; } static const struct v4l2_subdev_pad_ops sun6i_csi_bridge_pad_ops = { .enum_mbus_code = sun6i_csi_bridge_enum_mbus_code, - .get_fmt = sun6i_csi_bridge_get_fmt, + .get_fmt = v4l2_subdev_get_fmt, .set_fmt = sun6i_csi_bridge_set_fmt, }; @@ -780,8 +752,6 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev) }; int ret; - mutex_init(&bridge->lock); - /* V4L2 Subdev */ v4l2_subdev_init(subdev, &sun6i_csi_bridge_subdev_ops); @@ -809,6 +779,12 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev) if (ret < 0) return ret; + /* V4L2 Subdev finalize */ + + ret = v4l2_subdev_init_finalize(subdev); + if (ret < 0) + goto error_media_entity; + /* V4L2 Subdev */ if (csi_dev->isp_available) @@ -818,7 +794,7 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev) if (ret) { dev_err(dev, "failed to register v4l2 subdev: %d\n", ret); - goto error_media_entity; + goto error_subdev_finalize; } /* V4L2 Async */ @@ -852,6 +828,9 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev) else v4l2_device_unregister_subdev(subdev); +error_subdev_finalize: + v4l2_subdev_cleanup(subdev); + error_media_entity: media_entity_cleanup(&subdev->entity); @@ -868,5 +847,7 @@ void sun6i_csi_bridge_cleanup(struct sun6i_csi_device *csi_dev) v4l2_device_unregister_subdev(subdev); + v4l2_subdev_cleanup(subdev); + media_entity_cleanup(&subdev->entity); } diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h index 44653b38f722..a5b0a6f064dd 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.h @@ -42,20 +42,11 @@ struct sun6i_csi_bridge { struct v4l2_subdev subdev; struct v4l2_async_notifier notifier; struct media_pad pads[2]; - struct v4l2_mbus_framefmt mbus_format; - struct mutex lock; /* Mbus format lock. */ struct sun6i_csi_bridge_source source_parallel; struct sun6i_csi_bridge_source source_mipi_csi2; }; -/* Helpers */ - -void sun6i_csi_bridge_dimensions(struct sun6i_csi_device *csi_dev, - unsigned int *width, unsigned int *height); -void sun6i_csi_bridge_format(struct sun6i_csi_device *csi_dev, - u32 *mbus_code, u32 *field); - /* Format */ const struct sun6i_csi_bridge_format * diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 65879f4802c0..d90abba21309 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -888,14 +888,19 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) media_entity_to_video_device(link->sink->entity); struct sun6i_csi_device *csi_dev = video_get_drvdata(video_dev); struct v4l2_device *v4l2_dev = csi_dev->v4l2_dev; + struct v4l2_subdev *src_subdev = + media_entity_to_v4l2_subdev(link->source->entity); const struct sun6i_csi_capture_format *capture_format; const struct sun6i_csi_bridge_format *bridge_format; unsigned int capture_width, capture_height; - unsigned int bridge_width, bridge_height; const struct v4l2_format_info *format_info; + struct v4l2_subdev_format src_fmt = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = link->source->index + }; u32 pixelformat, capture_field; - u32 mbus_code, bridge_field; bool match; + int ret; sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height); @@ -904,19 +909,22 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) if (WARN_ON(!capture_format)) return -EINVAL; - sun6i_csi_bridge_dimensions(csi_dev, &bridge_width, &bridge_height); + /* Resolve csi bridge format. */ + ret = v4l2_subdev_call(src_subdev, pad, get_fmt, NULL, &src_fmt); + if (ret) + return ret; - sun6i_csi_bridge_format(csi_dev, &mbus_code, &bridge_field); - bridge_format = sun6i_csi_bridge_format_find(mbus_code); + bridge_format = sun6i_csi_bridge_format_find(src_fmt.format.code); if (WARN_ON(!bridge_format)) return -EINVAL; /* No cropping/scaling is supported. */ - if (capture_width != bridge_width || capture_height != bridge_height) { + if (capture_width != src_fmt.format.width || + capture_height != src_fmt.format.height) { v4l2_err(v4l2_dev, "invalid input/output dimensions: %ux%u/%ux%u\n", - bridge_width, bridge_height, capture_width, - capture_height); + src_fmt.format.width, src_fmt.format.height, + capture_width, capture_height); return -EINVAL; } @@ -947,7 +955,8 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) /* With raw input mode, we need a 1:1 match between input and output. */ if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW || capture_format->input_format_raw) { - match = sun6i_csi_capture_format_match(pixelformat, mbus_code); + match = sun6i_csi_capture_format_match(pixelformat, + src_fmt.format.code); if (!match) goto invalid; } From patchwork Mon May 18 10:24:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2293 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id DD5BF1C07A5 for ; Mon, 18 May 2026 12:26:36 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-23453-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-23453-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id DB14030068ED for ; Mon, 18 May 2026 10:26:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 44F9C318B9C; Mon, 18 May 2026 10:26:22 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5AA530568E; Mon, 18 May 2026 10:26:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779099982; cv=none; b=qfpobhDoy4ZcrYaI/zP8XZcUerdP1berx34gc+7VYoy/y/E1NL4n/cK47rFpMJS70S/pxfDUTuprWo60RwWBMn9VqONNypavoUBx8bCJaE8MEWJT6r++OgjBJOxEctxhiUaLPrqId2bAKrtI8p0/ySPonh1sAnSFVfs2V7LNEsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779099982; c=relaxed/simple; bh=vXy7wGbCoWon8e0bM6D24f1MQwlaCnUDtj8yulvwCl0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WOwKtIA6a5GZrRhlrL2Zd3nfeWQVJRf1BkVYI9RFTYlfYUx69iRYqh/0rCP0cEIIjy5UHbrOKuMQh2swBL/uN4B15TjX6cNbIP5DhD0xs4+CZb99w09195stKVBMEL/+2WDqDVbooRqCHh+nY0tooY2P5+eIHldgXOXaIlYu+dc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 1DE571F80044; Mon, 18 May 2026 10:26:19 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 76B5CB40800; Mon, 18 May 2026 10:26:18 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id C362EB407F0; Mon, 18 May 2026 10:24:53 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 02/16] media: sun6i-csi: capture: Implement vidioc_enum_framesizes Date: Mon, 18 May 2026 12:24:37 +0200 Message-ID: <20260518102451.417971-3-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[99.99%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; DMARC_NA(0.00)[sys-base.io]; DBL_BLOCKED_OPENRESOLVER(0.00)[ideasonboard.com:email,tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo,sys-base.io:email]; RCPT_COUNT_TWELVE(0.00)[14]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23453-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: DD5BF1C07A5 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Arash Golgol Report the stepwise frame size range supported by the CSI capture hardware for the pixel formats exposed by the driver. The hardware does not perform scaling and accepts any even width and height within the reported limits. Signed-off-by: Arash Golgol Reviewed-by: Paul Kocialkowski Tested-by: Paul Kocialkowski Reviewed-by: Laurent Pinchart --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index d90abba21309..f788b4234673 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -738,6 +738,27 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv, return 0; } +static int sun6i_csi_capture_enum_framesize(struct file *file, void *fh, + struct v4l2_frmsizeenum *fsize) +{ + if (fsize->index) + return -EINVAL; + + /* Only accept format in map table. */ + if (!sun6i_csi_capture_format_find(fsize->pixel_format)) + return -EINVAL; + + fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + fsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN; + fsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX; + fsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN; + fsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX; + fsize->stepwise.step_width = 2; + fsize->stepwise.step_height = 2; + + return 0; +} + static int sun6i_csi_capture_g_fmt(struct file *file, void *priv, struct v4l2_format *format) { @@ -805,6 +826,7 @@ static const struct v4l2_ioctl_ops sun6i_csi_capture_ioctl_ops = { .vidioc_querycap = sun6i_csi_capture_querycap, .vidioc_enum_fmt_vid_cap = sun6i_csi_capture_enum_fmt, + .vidioc_enum_framesizes = sun6i_csi_capture_enum_framesize, .vidioc_g_fmt_vid_cap = sun6i_csi_capture_g_fmt, .vidioc_s_fmt_vid_cap = sun6i_csi_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_csi_capture_try_fmt, From patchwork Mon May 18 10:24:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2295 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id F2D291C07A8 for ; Mon, 18 May 2026 12:29:08 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23454-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23454-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 3B9113005D3B for ; Mon, 18 May 2026 10:26:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9AA473E5EF7; Mon, 18 May 2026 10:26:53 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B32D33815F3; Mon, 18 May 2026 10:26:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100013; cv=none; b=HiK8rVdXH2MsEAEaPyhTf/qh3vf5U+njiaVHUHRX6Nt1KCycW/P0bF/P1pJV3MURM0pCFukvgI8IlYFAfSRv5FiraTGLYKoTcCFUyUwOt5bHeDv5gXWsiotSEbF9B+ExTNqz3Du9gI92Nuy+wz8kA3AA57Icjh/+5Hfd7/OGGg0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100013; c=relaxed/simple; bh=Tbz0Fq2B2eUEXo8eCeEVL3h9wLwJpFw6jFs2iijEFBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QHfd5m6z3EcDPT9t8LROjQ2ClzhO/GVm76P+r4PRjkvMdN2QHCDXWn8uZdHgZTR9G+tzGMBiw0s6CbkdatsCHWrx3PNcDEkzmMoPfFmVP3JdccllO4o85BUUkXN07k0TqibP9iNYHA6FWkPX/dnsr99C1QZtde1M+2OEa92uq34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id D734E1F8004A; Mon, 18 May 2026 10:26:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 43117B40805; Mon, 18 May 2026 10:26:44 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 18CA6B407EF; Mon, 18 May 2026 10:24:54 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 03/16] media: sun6i-mipi-csi2: Use V4L2 subdev active state Date: Mon, 18 May 2026 12:24:38 +0200 Message-ID: <20260518102451.417971-4-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Arash Golgol Use the V4L2 subdev active state API to store the active format. This simplifies the driver not only by dropping the bridge mbus_format field, but it also allows dropping the bridge lock, replaced with the state lock. The sun6i-mipi-csi2 hardware does not perform any format conversion. Enforce identical formats on the sink and source pads in the set_fmt() and init_state() callbacks. Signed-off-by: Arash Golgol Reviewed-by: Laurent Pinchart --- .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 107 +++++++++--------- .../sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h | 2 - 2 files changed, 53 insertions(+), 56 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c index b06cb73015cd..682bdd82098c 100644 --- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c @@ -95,12 +95,12 @@ static void sun6i_mipi_csi2_disable(struct sun6i_mipi_csi2_device *csi2_dev) SUN6I_MIPI_CSI2_CTL_EN, 0); } -static void sun6i_mipi_csi2_configure(struct sun6i_mipi_csi2_device *csi2_dev) +static void sun6i_mipi_csi2_configure(struct sun6i_mipi_csi2_device *csi2_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct regmap *regmap = csi2_dev->regmap; unsigned int lanes_count = csi2_dev->bridge.endpoint.bus.mipi_csi2.num_data_lanes; - struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; const struct sun6i_mipi_csi2_format *format; struct device *dev = csi2_dev->dev; u32 version = 0; @@ -173,7 +173,8 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) struct v4l2_subdev *source_subdev = csi2_dev->bridge.source_subdev; union phy_configure_opts dphy_opts = { 0 }; struct phy_configure_opts_mipi_dphy *dphy_cfg = &dphy_opts.mipi_dphy; - struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; + struct v4l2_subdev_state *state; + const struct v4l2_mbus_framefmt *mbus_format; const struct sun6i_mipi_csi2_format *format; struct phy *dphy = csi2_dev->dphy; struct device *dev = csi2_dev->dev; @@ -183,8 +184,12 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) unsigned long pixel_rate; int ret; - if (!source_subdev) - return -ENODEV; + state = v4l2_subdev_lock_and_get_active_state(subdev); + + if (!source_subdev) { + ret = -ENODEV; + goto unlock; + } if (!on) { v4l2_subdev_call(source_subdev, video, s_stream, 0); @@ -196,7 +201,7 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) ret = pm_runtime_resume_and_get(dev); if (ret < 0) - return ret; + goto unlock; /* Sensor Pixel Rate */ @@ -222,6 +227,8 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) goto error_pm; } + mbus_format = v4l2_subdev_state_get_format(state, + SUN6I_MIPI_CSI2_PAD_SINK); format = sun6i_mipi_csi2_format_find(mbus_format->code); if (WARN_ON(!format)) { ret = -ENODEV; @@ -260,7 +267,7 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) /* Controller */ - sun6i_mipi_csi2_configure(csi2_dev); + sun6i_mipi_csi2_configure(csi2_dev, mbus_format); sun6i_mipi_csi2_enable(csi2_dev); /* D-PHY */ @@ -277,7 +284,8 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) if (ret && ret != -ENOIOCTLCMD) goto disable; - return 0; + ret = 0; + goto unlock; disable: phy_power_off(dphy); @@ -286,6 +294,8 @@ static int sun6i_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) error_pm: pm_runtime_put(dev); +unlock: + v4l2_subdev_unlock_state(state); return ret; } @@ -308,21 +318,23 @@ sun6i_mipi_csi2_mbus_format_prepare(struct v4l2_mbus_framefmt *mbus_format) static int sun6i_mipi_csi2_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct sun6i_mipi_csi2_device *csi2_dev = v4l2_get_subdevdata(subdev); - unsigned int pad = SUN6I_MIPI_CSI2_PAD_SINK; - struct v4l2_mbus_framefmt *mbus_format = - v4l2_subdev_state_get_format(state, pad); - struct mutex *lock = &csi2_dev->bridge.lock; + unsigned int pad; - mutex_lock(lock); + /* + * This subdev does not perform format conversion, + * initialize both pads identically. + */ + for (pad = 0; pad < subdev->entity.num_pads; pad++) { + struct v4l2_mbus_framefmt *mbus_format; - mbus_format->code = sun6i_mipi_csi2_formats[0].mbus_code; - mbus_format->width = 640; - mbus_format->height = 480; + mbus_format = v4l2_subdev_state_get_format(state, pad); - sun6i_mipi_csi2_mbus_format_prepare(mbus_format); + mbus_format->code = sun6i_mipi_csi2_formats[0].mbus_code; + mbus_format->width = 640; + mbus_format->height = 480; - mutex_unlock(lock); + sun6i_mipi_csi2_mbus_format_prepare(mbus_format); + } return 0; } @@ -340,53 +352,32 @@ sun6i_mipi_csi2_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } -static int sun6i_mipi_csi2_get_fmt(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *state, - struct v4l2_subdev_format *format) -{ - struct sun6i_mipi_csi2_device *csi2_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi2_dev->bridge.lock; - - mutex_lock(lock); - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *mbus_format = *v4l2_subdev_state_get_format(state, - format->pad); - else - *mbus_format = csi2_dev->bridge.mbus_format; - - mutex_unlock(lock); - - return 0; -} - static int sun6i_mipi_csi2_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct sun6i_mipi_csi2_device *csi2_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi2_dev->bridge.lock; + struct v4l2_mbus_framefmt *fmt; - mutex_lock(lock); + /* The format on the source pad always matches the sink pad. */ + if (format->pad != SUN6I_MIPI_CSI2_PAD_SINK) + return v4l2_subdev_get_fmt(subdev, state, format); - sun6i_mipi_csi2_mbus_format_prepare(mbus_format); + sun6i_mipi_csi2_mbus_format_prepare(&format->format); - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *v4l2_subdev_state_get_format(state, format->pad) = - *mbus_format; - else - csi2_dev->bridge.mbus_format = *mbus_format; + /* Set the format on the sink pad. */ + fmt = v4l2_subdev_state_get_format(state, format->pad); + *fmt = format->format; - mutex_unlock(lock); + /* Propagate the format to the source pad. */ + fmt = v4l2_subdev_state_get_format(state, SUN6I_MIPI_CSI2_PAD_SOURCE); + *fmt = format->format; return 0; } static const struct v4l2_subdev_pad_ops sun6i_mipi_csi2_pad_ops = { .enum_mbus_code = sun6i_mipi_csi2_enum_mbus_code, - .get_fmt = sun6i_mipi_csi2_get_fmt, + .get_fmt = v4l2_subdev_get_fmt, .set_fmt = sun6i_mipi_csi2_set_fmt, }; @@ -502,8 +493,6 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev) bool notifier_registered = false; int ret; - mutex_init(&bridge->lock); - /* V4L2 Subdev */ v4l2_subdev_init(subdev, &sun6i_mipi_csi2_subdev_ops); @@ -532,6 +521,12 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev) if (ret) return ret; + /* V4L2 Subdev finalize */ + + ret = v4l2_subdev_init_finalize(subdev); + if (ret < 0) + goto error_media_entity_cleanup; + /* V4L2 Async */ v4l2_async_subdev_nf_init(notifier, subdev); @@ -565,6 +560,9 @@ static int sun6i_mipi_csi2_bridge_setup(struct sun6i_mipi_csi2_device *csi2_dev) error_v4l2_notifier_cleanup: v4l2_async_nf_cleanup(notifier); + v4l2_subdev_cleanup(subdev); + +error_media_entity_cleanup: media_entity_cleanup(&subdev->entity); return ret; @@ -579,6 +577,7 @@ sun6i_mipi_csi2_bridge_cleanup(struct sun6i_mipi_csi2_device *csi2_dev) v4l2_async_unregister_subdev(subdev); v4l2_async_nf_unregister(notifier); v4l2_async_nf_cleanup(notifier); + v4l2_subdev_cleanup(subdev); media_entity_cleanup(&subdev->entity); } diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h index 24b15e34b5e8..d72dfbd6a993 100644 --- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h +++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.h @@ -32,8 +32,6 @@ struct sun6i_mipi_csi2_bridge { struct media_pad pads[SUN6I_MIPI_CSI2_PAD_COUNT]; struct v4l2_fwnode_endpoint endpoint; struct v4l2_async_notifier notifier; - struct v4l2_mbus_framefmt mbus_format; - struct mutex lock; /* Mbus format lock. */ struct v4l2_subdev *source_subdev; }; From patchwork Mon May 18 10:24:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2297 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id C6A011C07A5 for ; Mon, 18 May 2026 12:30:27 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23455-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23455-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 63B833048DF5 for ; Mon, 18 May 2026 10:27:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38A443E7BA0; Mon, 18 May 2026 10:27:31 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09BC63E5EF8; Mon, 18 May 2026 10:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100050; cv=none; b=huoLeTN1s+ncTj6cd9ZwpOtSvD5M/kHBWRp2cxb1EsZ/dewRAPloH1WvBDuYVTM0HbSnA+ZDJTM9eQx3s3TWpmWizLFMTNFOaUj8cHD6r2nLJyMZ/FjytHRPFNja7tBs4Pihqs0f8E8Kir+XlPpXgA0fjPf3GnKvroS/TldGCMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100050; c=relaxed/simple; bh=v9/oHB00j+2MpFeubgCrn6YeImJ75HNm2yALCtXVeeA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U7ttaF55BOtkZLKsIhqdN9ir/ATZ9dLHzjKvA0D+O8MWk/VbrpL5Q078+4AEbUEW9Gj0XqKxV8I3WkeyCjWREC4ZCHgcswfHfAOvTZLEZHacQIst40LpckNwTQpFsDrXn7zewY8lOL0ithY595QepVSeKMUo7W5Z2s//XP/HcBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 399FC1F80044; Mon, 18 May 2026 10:27:19 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id A3A9BB4080A; Mon, 18 May 2026 10:27:18 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 5F82AB407F1; Mon, 18 May 2026 10:24:54 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 04/16] media: sun8i-a83t-mipi-csi2: Use V4L2 subdev active state Date: Mon, 18 May 2026 12:24:39 +0200 Message-ID: <20260518102451.417971-5-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= From: Arash Golgol Use the V4L2 subdev active state API to store the active format. This simplifies the driver not only by dropping the bridge mbus_format field, but it also allows dropping the bridge lock, replaced with the state lock. The sun8i-a83t-mipi-csi2 hardware does not perform any format conversion. Enforce identical formats on the sink and source pads in the set_fmt() and init_state() callbacks. Signed-off-by: Arash Golgol Reviewed-by: Paul Kocialkowski Tested-by: Paul Kocialkowski --- .../sun8i_a83t_mipi_csi2.c | 113 +++++++++--------- .../sun8i_a83t_mipi_csi2.h | 2 - 2 files changed, 56 insertions(+), 59 deletions(-) diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c index dbc51daa4fe3..2b7635f3952d 100644 --- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c +++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.c @@ -144,12 +144,12 @@ sun8i_a83t_mipi_csi2_disable(struct sun8i_a83t_mipi_csi2_device *csi2_dev) } static void -sun8i_a83t_mipi_csi2_configure(struct sun8i_a83t_mipi_csi2_device *csi2_dev) +sun8i_a83t_mipi_csi2_configure(struct sun8i_a83t_mipi_csi2_device *csi2_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct regmap *regmap = csi2_dev->regmap; unsigned int lanes_count = csi2_dev->bridge.endpoint.bus.mipi_csi2.num_data_lanes; - struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; const struct sun8i_a83t_mipi_csi2_format *format; struct device *dev = csi2_dev->dev; u32 version = 0; @@ -205,7 +205,8 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) struct v4l2_subdev *source_subdev = csi2_dev->bridge.source_subdev; union phy_configure_opts dphy_opts = { 0 }; struct phy_configure_opts_mipi_dphy *dphy_cfg = &dphy_opts.mipi_dphy; - struct v4l2_mbus_framefmt *mbus_format = &csi2_dev->bridge.mbus_format; + struct v4l2_subdev_state *state; + const struct v4l2_mbus_framefmt *mbus_format; const struct sun8i_a83t_mipi_csi2_format *format; struct phy *dphy = csi2_dev->dphy; struct device *dev = csi2_dev->dev; @@ -215,8 +216,12 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) unsigned long pixel_rate; int ret; - if (!source_subdev) - return -ENODEV; + state = v4l2_subdev_lock_and_get_active_state(subdev); + + if (!source_subdev) { + ret = -ENODEV; + goto unlock; + } if (!on) { v4l2_subdev_call(source_subdev, video, s_stream, 0); @@ -228,7 +233,7 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) ret = pm_runtime_resume_and_get(dev); if (ret < 0) - return ret; + goto unlock; /* Sensor pixel rate */ @@ -254,6 +259,9 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) goto error_pm; } + mbus_format = + v4l2_subdev_state_get_format(state, + SUN8I_A83T_MIPI_CSI2_PAD_SINK); format = sun8i_a83t_mipi_csi2_format_find(mbus_format->code); if (WARN_ON(!format)) { ret = -ENODEV; @@ -292,7 +300,7 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) /* Controller */ - sun8i_a83t_mipi_csi2_configure(csi2_dev); + sun8i_a83t_mipi_csi2_configure(csi2_dev, mbus_format); sun8i_a83t_mipi_csi2_enable(csi2_dev); /* D-PHY */ @@ -309,7 +317,8 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) if (ret && ret != -ENOIOCTLCMD) goto disable; - return 0; + ret = 0; + goto unlock; disable: phy_power_off(dphy); @@ -318,6 +327,8 @@ static int sun8i_a83t_mipi_csi2_s_stream(struct v4l2_subdev *subdev, int on) error_pm: pm_runtime_put(dev); +unlock: + v4l2_subdev_unlock_state(state); return ret; } @@ -341,22 +352,24 @@ sun8i_a83t_mipi_csi2_mbus_format_prepare(struct v4l2_mbus_framefmt *mbus_format) static int sun8i_a83t_mipi_csi2_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct sun8i_a83t_mipi_csi2_device *csi2_dev = - v4l2_get_subdevdata(subdev); - unsigned int pad = SUN8I_A83T_MIPI_CSI2_PAD_SINK; - struct v4l2_mbus_framefmt *mbus_format = - v4l2_subdev_state_get_format(state, pad); - struct mutex *lock = &csi2_dev->bridge.lock; + unsigned int pad; - mutex_lock(lock); + /* + * This subdev does not perform format conversion, + * initialize both pads identically. + */ + for (pad = 0; pad < subdev->entity.num_pads; pad++) { + struct v4l2_mbus_framefmt *mbus_format; - mbus_format->code = sun8i_a83t_mipi_csi2_formats[0].mbus_code; - mbus_format->width = 640; - mbus_format->height = 480; + mbus_format = v4l2_subdev_state_get_format(state, pad); + + mbus_format->code = sun8i_a83t_mipi_csi2_formats[0].mbus_code; + mbus_format->width = 640; + mbus_format->height = 480; - sun8i_a83t_mipi_csi2_mbus_format_prepare(mbus_format); + sun8i_a83t_mipi_csi2_mbus_format_prepare(mbus_format); + } - mutex_unlock(lock); return 0; } @@ -375,55 +388,33 @@ sun8i_a83t_mipi_csi2_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } -static int sun8i_a83t_mipi_csi2_get_fmt(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *state, - struct v4l2_subdev_format *format) -{ - struct sun8i_a83t_mipi_csi2_device *csi2_dev = - v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi2_dev->bridge.lock; - - mutex_lock(lock); - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *mbus_format = *v4l2_subdev_state_get_format(state, - format->pad); - else - *mbus_format = csi2_dev->bridge.mbus_format; - - mutex_unlock(lock); - - return 0; -} - static int sun8i_a83t_mipi_csi2_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct sun8i_a83t_mipi_csi2_device *csi2_dev = - v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &csi2_dev->bridge.lock; + struct v4l2_mbus_framefmt *fmt; - mutex_lock(lock); + /* The format on the source pad always matches the sink pad. */ + if (format->pad != SUN8I_A83T_MIPI_CSI2_PAD_SINK) + return v4l2_subdev_get_fmt(subdev, state, format); - sun8i_a83t_mipi_csi2_mbus_format_prepare(mbus_format); + sun8i_a83t_mipi_csi2_mbus_format_prepare(&format->format); - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *v4l2_subdev_state_get_format(state, format->pad) = - *mbus_format; - else - csi2_dev->bridge.mbus_format = *mbus_format; + /* Set the format on the sink pad. */ + fmt = v4l2_subdev_state_get_format(state, format->pad); + *fmt = format->format; - mutex_unlock(lock); + /* Propagate the format to the source pad. */ + fmt = v4l2_subdev_state_get_format(state, + SUN8I_A83T_MIPI_CSI2_PAD_SOURCE); + *fmt = format->format; return 0; } static const struct v4l2_subdev_pad_ops sun8i_a83t_mipi_csi2_pad_ops = { .enum_mbus_code = sun8i_a83t_mipi_csi2_enum_mbus_code, - .get_fmt = sun8i_a83t_mipi_csi2_get_fmt, + .get_fmt = v4l2_subdev_get_fmt, .set_fmt = sun8i_a83t_mipi_csi2_set_fmt, }; @@ -540,8 +531,6 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev) bool notifier_registered = false; int ret; - mutex_init(&bridge->lock); - /* V4L2 Subdev */ v4l2_subdev_init(subdev, &sun8i_a83t_mipi_csi2_subdev_ops); @@ -570,6 +559,12 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev) if (ret) return ret; + /* V4L2 Subdev finalize */ + + ret = v4l2_subdev_init_finalize(subdev); + if (ret < 0) + goto error_media_entity_cleanup; + /* V4L2 Async */ v4l2_async_subdev_nf_init(notifier, subdev); @@ -603,6 +598,9 @@ sun8i_a83t_mipi_csi2_bridge_setup(struct sun8i_a83t_mipi_csi2_device *csi2_dev) error_v4l2_notifier_cleanup: v4l2_async_nf_cleanup(notifier); + v4l2_subdev_cleanup(subdev); + +error_media_entity_cleanup: media_entity_cleanup(&subdev->entity); return ret; @@ -617,6 +615,7 @@ sun8i_a83t_mipi_csi2_bridge_cleanup(struct sun8i_a83t_mipi_csi2_device *csi2_dev v4l2_async_unregister_subdev(subdev); v4l2_async_nf_unregister(notifier); v4l2_async_nf_cleanup(notifier); + v4l2_subdev_cleanup(subdev); media_entity_cleanup(&subdev->entity); } diff --git a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h index f1e64c53434c..819527bcd64d 100644 --- a/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h +++ b/drivers/media/platform/sunxi/sun8i-a83t-mipi-csi2/sun8i_a83t_mipi_csi2.h @@ -33,8 +33,6 @@ struct sun8i_a83t_mipi_csi2_bridge { struct media_pad pads[SUN8I_A83T_MIPI_CSI2_PAD_COUNT]; struct v4l2_fwnode_endpoint endpoint; struct v4l2_async_notifier notifier; - struct v4l2_mbus_framefmt mbus_format; - struct mutex lock; /* Mbus format lock. */ struct v4l2_subdev *source_subdev; }; From patchwork Mon May 18 10:24:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2294 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 8E6B31C07A5 for ; Mon, 18 May 2026 12:28:36 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-23456-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-23456-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 7734D3025A58 for ; Mon, 18 May 2026 10:28:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D9A63E9C12; Mon, 18 May 2026 10:28:00 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82B123E8C79; Mon, 18 May 2026 10:27:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100079; cv=none; b=Ahg3Ma/E4C/71EgMcDaQhBZ//6JSiiSu9xPnbuaQRf/rPCjSsaCuEwYw9SypKvWxYRpdBpk/m2b8fscPP4m8gttIDy7bACrWSC2dZz6Xcnn/yrbEGVM95uw3YGvBygUgOVPr4V5ebDZ30T2D1hwx+/aYZIOatLtVXX+a9yFpbvg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100079; c=relaxed/simple; bh=rOPLs8ziQTXtf4yGzefCGTBcEtcsiUtr3cFFKYF7g8A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U9YjgYCaVbLrpfiBF46qdw8uHlK+19wFWpYHWKxlOTxl4gRmhZN4hUYkGMmX/XutoQoxlZzze872Q6pQcG8KjaxxpsAkWoC14eiZlsTS0N0DrVK0K9fKZLXwoPFqr4z9ljoV//6sgshwg4nIdQNLcxbW/pHsuXS9dpQ6T4K7OKk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id BD1D31F80044; Mon, 18 May 2026 10:27:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 20F4DB4080B; Mon, 18 May 2026 10:27:44 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id A3E79B407F2; Mon, 18 May 2026 10:24:54 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 05/16] media: v4l2-common: Fix NV15_4L4 format info block height Date: Mon, 18 May 2026 12:24:40 +0200 Message-ID: <20260518102451.417971-6-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; DMARC_NA(0.00)[sys-base.io]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo,sys-base.io:email]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23456-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: 8E6B31C07A5 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The NV15_4L4 format is specified as a 4x4 format, not 4x1. In addition the block size should not take subsampling in account, so specify it as 4x4 for both luma and chroma. Signed-off-by: Paul Kocialkowski --- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 554c591e1113..77a0daa92c2b 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -309,7 +309,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) /* Tiled YUV formats */ { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, { .format = V4L2_PIX_FMT_NV15_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2, - .block_w = { 4, 2, 0, 0 }, .block_h = { 1, 1, 0, 0 }}, + .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, /* YUV planar formats, non contiguous variant */ From patchwork Mon May 18 10:24:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2296 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id EC51E1C07A5 for ; Mon, 18 May 2026 12:30:20 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-23457-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-23457-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id B2C5D303E6CC for ; Mon, 18 May 2026 10:28:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0DFEE3EAC71; Mon, 18 May 2026 10:28:37 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E90A3E5A13; Mon, 18 May 2026 10:28:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100111; cv=none; b=oWo24zscGa5O12KTg57MFN4daNqKtBuWBBwX+tBFyRnLGic3Hc12BsSlazFoAMlo9mbtQrx1GIdrQ4CTkFvmd2b/azvyHXtx7CfNqfXCKfo3aol6gqPyBmdX94CeWR+RUq5OcuFvHXGQXoXY5T3c6pnS1HuGLu9ncHFSL7/GrrE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100111; c=relaxed/simple; bh=RJtv2gx1tUEfFVw7z5+P1pqG0yHksAvNV2U0eiZ7RLk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mwW15xMfcL3RDDM9tiSdObBxbgiGDBAbWi4SKiXNSWlntaFlzoUqF7ThT9dmpbLX+RecnfLvX1HDQa1bvb6+Es5pHwrSizcpyG52QzktWmeAmEUq7/dWlI/AFi0KbcwzkdJZig2rQ2dL8b3FYbVfYkAJ7xOWyuIiy1s+8Lrc29c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 59C1C1F80041; Mon, 18 May 2026 10:28:19 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id C09E3B40810; Mon, 18 May 2026 10:28:18 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 082B1B407F3; Mon, 18 May 2026 10:24:55 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 06/16] media: v4l2-common: Add missing tiled format info block sizes Date: Mon, 18 May 2026 12:24:41 +0200 Message-ID: <20260518102451.417971-7-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.105.105.114:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; RCPT_COUNT_TWELVE(0.00)[14]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; DMARC_NA(0.00)[sys-base.io]; DBL_BLOCKED_OPENRESOLVER(0.00)[tor.lore.kernel.org:rdns,tor.lore.kernel.org:helo,sys-base.io:email]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.105.105.114:c]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23457-noreply=patchwork.local]; MIME_TRACE(0.00)[0:+]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ASN(0.00)[asn:63949, ipnet:172.105.96.0/20, country:SG]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: EC51E1C07A5 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Some YUV420 tiled format info definitions are missing block sizes. Add the missing block sizes (they are all 4x4). Signed-off-by: Paul Kocialkowski --- drivers/media/v4l2-core/v4l2-common.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 77a0daa92c2b..e142d40c71b9 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -307,10 +307,12 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_GREY, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 1, .bpp = { 1, 0, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 1, .vdiv = 1 }, /* Tiled YUV formats */ - { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, + { .format = V4L2_PIX_FMT_NV12_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, { .format = V4L2_PIX_FMT_NV15_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 5, 10, 0, 0 }, .bpp_div = { 4, 4, 1, 1 }, .hdiv = 2, .vdiv = 2, .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, - { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, + { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, /* YUV planar formats, non contiguous variant */ { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, From patchwork Mon May 18 10:24:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2298 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id 37EED1C07A5 for ; Mon, 18 May 2026 12:30:48 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-23458-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-23458-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id D68E2302D301 for ; Mon, 18 May 2026 10:28:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F8783E9F8B; Mon, 18 May 2026 10:28:59 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83B143E8C61; Mon, 18 May 2026 10:28:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100137; cv=none; b=W/k32NExvNwzmsfzCPTh1QkHjoDiHxKW1fy3e/tlMB5LbvFzyMueulV3BhOpMrpWwFD2r4fr9gG061WPNnhfhTmWbpXyYIn6PdrDiz7fMth/Y/Cq2XQxUfE5jTO0xGW5tn99sa/g3Nn50dnWcuBg4nLgdH2wK3TC17ICFMpEhtU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100137; c=relaxed/simple; bh=ERMR5eeWA11hRqZdNI29e1YB2rlq2P5j6QMS8CIQNgM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VOME3pEzQd2z56df2wnxplpddkNOEZSRPM6PMPste9ZXir0Yr7FH1EmXMsGqM6Ni3dcIHoTnWq8f6pB19rHmQKWgF2xUOSF7TzP8CcFPkqNEfkr66Z2+93UDT8QpUM56Tw3Ugm7VWZW5hPJ0ulGmTq1AqW5RhMpWym7Ilz/Kx6g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id ACC921F80044; Mon, 18 May 2026 10:28:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 29A27B40814; Mon, 18 May 2026 10:28:44 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 4CE81B407F4; Mon, 18 May 2026 10:24:55 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 07/16] media: v4l2-common: Add NV12_16L16 pixel format to v4l2 format info Date: Mon, 18 May 2026 12:24:42 +0200 Message-ID: <20260518102451.417971-8-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Represent the NV12_16L16 pixel format in the v4l2 format info table. This is a 16x16 tiled version of NV12. Signed-off-by: Paul Kocialkowski --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index e142d40c71b9..6194d6eb9c56 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -313,6 +313,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, { .format = V4L2_PIX_FMT_P010_4L4, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, + { .format = V4L2_PIX_FMT_NV12_16L16, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 16, 16, 0, 0 }, .block_h = { 16, 16, 0, 0 }}, /* YUV planar formats, non contiguous variant */ { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, From patchwork Mon May 18 10:24:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2299 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id BA9161C07A5 for ; Mon, 18 May 2026 12:32:49 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23459-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23459-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id C04E430578DA for ; Mon, 18 May 2026 10:29:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 593432DEA93; Mon, 18 May 2026 10:29:31 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 180C33E3DB6; Mon, 18 May 2026 10:29:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100170; cv=none; b=HehU5WVnNzKGegWVxDzjKAbLE1QeP8QlYqS2D6n2fu1moyYb2JnGhHPK0JeYygdl84RGBlf6gVYYM8ubIMhP/jO1neZ6VUwYKiUvI26kIjDZfC+2GQbK+d/7mm3XWOa3BLHr1hLDBMUGyXxttmQk9+DKEDU97H6J/GevMOLtOiI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100170; c=relaxed/simple; bh=eCvQTJjp2h8EORPuvx4oGznSj4EQT6vruXMeoKz4qjs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vku/tBNztq5+3Si1Aj3BIl90oSOLzko8iUJRFNQsTijMs8dDuKDs+NKPuUmqHnRzd5UaE3gtmA/Z5czcV/lakTycurks54tgyjaHENx7pvnn7Lxz+a8icHE+II4LbnY9vwCBfbQETIi+lHkquszyyKcGpMhndRdkKhjZBntDzLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id E84571F80044; Mon, 18 May 2026 10:29:18 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 757EFB40818; Mon, 18 May 2026 10:29:18 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id A0656B407F5; Mon, 18 May 2026 10:24:55 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 08/16] media: v4l2-common: Add NV12_32L32 pixel format to v4l2 format info Date: Mon, 18 May 2026 12:24:43 +0200 Message-ID: <20260518102451.417971-9-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; DMARC_NA(0.00)[sys-base.io]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; TAGGED_RCPT(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; PRECEDENCE_BULK(0.00)[]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23459-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: BA9161C07A5 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Represent the NV12_32L32 pixel format in the v4l2 format info table. This is a 32x32 tiled version of NV12. Signed-off-by: Paul Kocialkowski --- drivers/media/v4l2-core/v4l2-common.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 6194d6eb9c56..fe7141883ec5 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -315,6 +315,8 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) .block_w = { 4, 4, 0, 0 }, .block_h = { 4, 4, 0, 0 }}, { .format = V4L2_PIX_FMT_NV12_16L16, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, .block_w = { 16, 16, 0, 0 }, .block_h = { 16, 16, 0, 0 }}, + { .format = V4L2_PIX_FMT_NV12_32L32, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2, + .block_w = { 32, 32, 0, 0 }, .block_h = { 32, 32, 0, 0 }}, /* YUV planar formats, non contiguous variant */ { .format = V4L2_PIX_FMT_YUV420M, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 3, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .bpp_div = { 1, 1, 1, 1 }, .hdiv = 2, .vdiv = 2 }, From patchwork Mon May 18 10:24:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2300 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id 1C9F51C07A5 for ; Mon, 18 May 2026 12:34:57 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-23460-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-23460-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id E7F9F3020BE1 for ; Mon, 18 May 2026 10:30:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 79B683ECBFD; Mon, 18 May 2026 10:30:00 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 460833EBF33; Mon, 18 May 2026 10:29:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100198; cv=none; b=h675zoKe2d24pYLtv91kfEcpq2ScWRyQg8fVP2ZIiJAh837R8qSNvYrZzbbVtM9VfffHC6WeHq8R+dggpHwbmHLfcUWAvyMOI5gF9tuHbte8bybwFzw80uZodGQvnqL5z405Rs94jTxSx7Re+XvI9tc0gDBYTGSg4wa02ZHXlPU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100198; c=relaxed/simple; bh=N6jBm7mjftN6RyzhLYEDB/ctTHQIpMFcWgaVKSlq3IY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=APbiX4W55FT8kevvQhxGLpIRJjULMmxkp67fuCdWrgyan1jWpO6Rvys2ExOaoxjsWxQ98RfwFUbHh2ellJOM2tf5MzMK6SyS2NpAT74vSn0b8KhcNv6XEaw+q/PzLxdbpJy6DEBoN+ixmEZ3Xu6B3Lbjz3zYeRPMYdp39zPLTE0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 8F9251F80044; Mon, 18 May 2026 10:29:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 10E15B40818; Mon, 18 May 2026 10:29:43 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 0C8EBB407F6; Mon, 18 May 2026 10:24:56 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 09/16] media: sun6i-csi: Split format validation to a dedicated helper Date: Mon, 18 May 2026 12:24:44 +0200 Message-ID: <20260518102451.417971-10-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Introduce a new sun6i_csi_capture_format_check helper based on the link_validate code, which will be reused to implement MC-style pixelformat enumeration. Formats not listed in v4l2_format_info are now checked via sun6i_csi_capture_format_check (which only concerns raw formats) instead of blindly allowing them. Also fix a comment in the raw format table. Signed-off-by: Paul Kocialkowski --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 87 +++++++++++-------- 1 file changed, 49 insertions(+), 38 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index f788b4234673..a836fa7f081a 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -213,7 +213,7 @@ struct sun6i_csi_capture_format *sun6i_csi_capture_format_find(u32 pixelformat) /* RAW formats need an exact match between pixel and mbus formats. */ static const struct sun6i_csi_capture_format_match sun6i_csi_capture_format_matches[] = { - /* YUV420 */ + /* YUV422 */ { .pixelformat = V4L2_PIX_FMT_YUYV, .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, @@ -327,6 +327,51 @@ static bool sun6i_csi_capture_format_match(u32 pixelformat, u32 mbus_code) return false; } +static bool +sun6i_csi_capture_format_check(const struct sun6i_csi_capture_format *capture_format, + const struct sun6i_csi_bridge_format *bridge_format) +{ + const struct v4l2_format_info *format_info; + u32 pixelformat = capture_format->pixelformat; + u32 mbus_code = bridge_format->mbus_code; + bool match; + + format_info = v4l2_format_info(pixelformat); + + /* Some raw formats like JPEG are not listed: try a direct match. */ + if (!format_info) + return sun6i_csi_capture_format_match(pixelformat, mbus_code); + + if (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER && + bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) + return false; + + if (format_info->pixel_enc == V4L2_PIXEL_ENC_RGB && + bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) + return false; + + if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) { + if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 && + bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422) + return false; + + /* YUV420 input can't produce YUV422 output. */ + if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 && + format_info->vdiv == 1) + return false; + } + + /* With raw input mode, we need a 1:1 match between input and output. */ + if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW || + capture_format->input_format_raw) { + match = sun6i_csi_capture_format_match(pixelformat, mbus_code); + if (!match) + return false; + } + + return true; +} + /* Capture */ static void @@ -915,13 +960,11 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) const struct sun6i_csi_capture_format *capture_format; const struct sun6i_csi_bridge_format *bridge_format; unsigned int capture_width, capture_height; - const struct v4l2_format_info *format_info; struct v4l2_subdev_format src_fmt = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, .pad = link->source->index }; u32 pixelformat, capture_field; - bool match; int ret; sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height); @@ -950,44 +993,12 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) return -EINVAL; } - format_info = v4l2_format_info(pixelformat); - /* Some formats are not listed. */ - if (!format_info) - return 0; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_BAYER && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) - goto invalid; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_RGB && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_RAW) - goto invalid; - - if (format_info->pixel_enc == V4L2_PIXEL_ENC_YUV) { - if (bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV420 && - bridge_format->input_format != SUN6I_CSI_INPUT_FMT_YUV422) - goto invalid; - - /* YUV420 input can't produce YUV422 output. */ - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_YUV420 && - format_info->vdiv == 1) - goto invalid; - } - - /* With raw input mode, we need a 1:1 match between input and output. */ - if (bridge_format->input_format == SUN6I_CSI_INPUT_FMT_RAW || - capture_format->input_format_raw) { - match = sun6i_csi_capture_format_match(pixelformat, - src_fmt.format.code); - if (!match) - goto invalid; + if (!sun6i_csi_capture_format_check(capture_format, bridge_format)) { + v4l2_err(v4l2_dev, "invalid input/output format combination\n"); + return -EINVAL; } return 0; - -invalid: - v4l2_err(v4l2_dev, "invalid input/output format combination\n"); - return -EINVAL; } static const struct media_entity_operations sun6i_csi_capture_media_ops = { From patchwork Mon May 18 10:24:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2301 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 86C621C00A5 for ; Mon, 18 May 2026 12:38:21 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23461-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23461-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id DD2F5305592B for ; Mon, 18 May 2026 10:30:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 868B53ED124; Mon, 18 May 2026 10:30:55 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 738243E866F; Mon, 18 May 2026 10:30:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100250; cv=none; b=qVtpkd5MrOlk1RUKmwwO4PS/59nLZ3SEZl2h8rwUEnvt0kVYTdV7UTVsIMVWKY9slmzF+70Bfj0Ytd1PLwvXBzyai3+fQXIfXgX4ug7Y0YEBFrNfPfziVSbQiuwJxnnB9hQdQhx7Jn4zFOhpr+PtNE8nors99OEJLo6YbkAmYLA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100250; c=relaxed/simple; bh=a94F18r5g+FvBqZBmEeOdOnNuIqh/W6Oyf8UGJe6Jgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B/AeY9UDBocX+OUT3id3pnzmji2es0PZ8E3pRTuo9WvpKzQIfqx3emrqxcaW4ZGXHVbHDPkSY+jdhpLa5DY5HS/F8eQC0mNq+SZKSyTQNc8NhDtT8UDtKxq5zgJE+051KjubE1aZnXTcxSgLnLsoF+HXYoNTcgtvOFJb2SCVlXw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 9E0A91F80041; Mon, 18 May 2026 10:30:18 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 0D92FB40818; Mon, 18 May 2026 10:30:17 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 5C629B407F7; Mon, 18 May 2026 10:25:00 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 10/16] media: sun6i-csi: Add support for MC-centric format enumeration Date: Mon, 18 May 2026 12:24:45 +0200 Message-ID: <20260518102451.417971-11-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Use the dedicated helper to check possible pixelformats against the provided mbus code in order to support MC-centric format enumeration. Note that multiple pixelformats may be returned for a given mbus code. Signed-off-by: Paul Kocialkowski Tested-by: Arash Golgol --- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index a836fa7f081a..409c28621093 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -773,14 +773,43 @@ static int sun6i_csi_capture_querycap(struct file *file, void *priv, static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *fmtdesc) { + const struct sun6i_csi_capture_format *capture_format; + const struct sun6i_csi_bridge_format *bridge_format; + u32 mbus_code = fmtdesc->mbus_code; u32 index = fmtdesc->index; + unsigned int index_valid = 0; + unsigned int i; + + /* Video-node-centric enumeration. */ + if (!mbus_code) { + if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) + return -EINVAL; + + fmtdesc->pixelformat = + sun6i_csi_capture_formats[index].pixelformat; + return 0; + } - if (index >= ARRAY_SIZE(sun6i_csi_capture_formats)) + bridge_format = sun6i_csi_bridge_format_find(mbus_code); + if (!bridge_format) return -EINVAL; - fmtdesc->pixelformat = sun6i_csi_capture_formats[index].pixelformat; + for (i = 0; i < ARRAY_SIZE(sun6i_csi_capture_formats); i++) { + capture_format = &sun6i_csi_capture_formats[i]; - return 0; + if (!sun6i_csi_capture_format_check(capture_format, + bridge_format)) + continue; + + if (index_valid == index) { + fmtdesc->pixelformat = capture_format->pixelformat; + return 0; + } + + index_valid++; + } + + return -EINVAL; } static int sun6i_csi_capture_enum_framesize(struct file *file, void *fh, @@ -1076,7 +1105,8 @@ int sun6i_csi_capture_setup(struct sun6i_csi_device *csi_dev) strscpy(video_dev->name, SUN6I_CSI_CAPTURE_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_RX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_csi_capture_fops; From patchwork Mon May 18 10:24:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2302 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id C43EF1C00A5 for ; Mon, 18 May 2026 12:40:05 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23462-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23462-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 3AFC9304BE77 for ; Mon, 18 May 2026 10:32:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4724F3EEAEB; Mon, 18 May 2026 10:31:21 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 522743EDAA1; Mon, 18 May 2026 10:30:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100277; cv=none; b=uDdAol8FehVwNk/Cm0timg2FOAy1HBhULHuvadbXwUI1dO6bHRJsk+ql/6CtsNkSapPPXLqJadCQ8NKWP1JiEhFK1IONALd8+nUhlQoKaiinVBphjcy+Yo+jKWyky8UIKAl4fcYCL0yKLbOMocvshRKiboqCW2vdJ5Ja6v2q1A8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100277; c=relaxed/simple; bh=pGb0topKOndkQgyiZuK5FBJvTqlPd3JBn9MwPx7o0Wc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZULjMz4HGLaPGVM4WSWrLTUarv6jlChHD5BdSpPTVxnG3blF+lefyE89rSKsFRSt7RyxyK1dQfMTNBdTl9gvdEYIxFUpzsOTNNpLftMWXZZy7TfxH6X7kprZy55GTGYWZv5VyR45eu8k+ilEhL0SpEbA/4nmWn1fD/vPG8LnP6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 1919D1F8004F; Mon, 18 May 2026 10:30:45 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 89E1CB40822; Mon, 18 May 2026 10:30:44 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id A5E0BB407F8; Mon, 18 May 2026 10:25:00 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 11/16] media: sun6i-csi: Tidy up and unify coding style Date: Mon, 18 May 2026 12:24:46 +0200 Message-ID: <20260518102451.417971-12-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; DMARC_NA(0.00)[sys-base.io]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[sys-base.io:email,sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23462-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: C43EF1C00A5 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Bring recent changes to the same coding style as the rest of the driver. This is purely cosmetic and no functional change is intended. Signed-off-by: Paul Kocialkowski --- .../sunxi/sun6i-csi/sun6i_csi_bridge.c | 16 ++--- .../sunxi/sun6i-csi/sun6i_csi_capture.c | 72 ++++++++++--------- 2 files changed, 46 insertions(+), 42 deletions(-) diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c index 43a85bcc2ba2..18f79075d3ad 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_bridge.c @@ -473,6 +473,7 @@ static int sun6i_csi_bridge_s_stream(struct v4l2_subdev *subdev, int on) unlock: v4l2_subdev_unlock_state(state); + return ret; } @@ -533,7 +534,7 @@ static int sun6i_csi_bridge_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct v4l2_mbus_framefmt *fmt; + struct v4l2_mbus_framefmt *mbus_format; /* The format on the source pad always matches the sink pad. */ if (format->pad != SUN6I_CSI_BRIDGE_PAD_SINK) @@ -542,12 +543,12 @@ static int sun6i_csi_bridge_set_fmt(struct v4l2_subdev *subdev, sun6i_csi_bridge_mbus_format_prepare(&format->format); /* Set the format on the sink pad. */ - fmt = v4l2_subdev_state_get_format(state, format->pad); - *fmt = format->format; + mbus_format = v4l2_subdev_state_get_format(state, format->pad); + *mbus_format = format->format; /* Propagate the format to the source pad. */ - fmt = v4l2_subdev_state_get_format(state, SUN6I_CSI_BRIDGE_PAD_SOURCE); - *fmt = format->format; + mbus_format = v4l2_subdev_state_get_format(state, SUN6I_CSI_BRIDGE_PAD_SOURCE); + *mbus_format = format->format; return 0; } @@ -779,14 +780,12 @@ int sun6i_csi_bridge_setup(struct sun6i_csi_device *csi_dev) if (ret < 0) return ret; - /* V4L2 Subdev finalize */ + /* V4L2 Subdev */ ret = v4l2_subdev_init_finalize(subdev); if (ret < 0) goto error_media_entity; - /* V4L2 Subdev */ - if (csi_dev->isp_available) ret = v4l2_async_register_subdev(subdev); else @@ -846,7 +845,6 @@ void sun6i_csi_bridge_cleanup(struct sun6i_csi_device *csi_dev) v4l2_async_nf_cleanup(notifier); v4l2_device_unregister_subdev(subdev); - v4l2_subdev_cleanup(subdev); media_entity_cleanup(&subdev->entity); diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c index 409c28621093..eea682f47eea 100644 --- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c +++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi_capture.c @@ -812,27 +812,6 @@ static int sun6i_csi_capture_enum_fmt(struct file *file, void *priv, return -EINVAL; } -static int sun6i_csi_capture_enum_framesize(struct file *file, void *fh, - struct v4l2_frmsizeenum *fsize) -{ - if (fsize->index) - return -EINVAL; - - /* Only accept format in map table. */ - if (!sun6i_csi_capture_format_find(fsize->pixel_format)) - return -EINVAL; - - fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; - fsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN; - fsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX; - fsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN; - fsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX; - fsize->stepwise.step_width = 2; - fsize->stepwise.step_height = 2; - - return 0; -} - static int sun6i_csi_capture_g_fmt(struct file *file, void *priv, struct v4l2_format *format) { @@ -867,6 +846,27 @@ static int sun6i_csi_capture_try_fmt(struct file *file, void *priv, return 0; } +static int sun6i_csi_capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *frmsize) +{ + if (frmsize->index) + return -EINVAL; + + /* Only accept format in map table. */ + if (!sun6i_csi_capture_format_find(frmsize->pixel_format)) + return -EINVAL; + + frmsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + frmsize->stepwise.min_width = SUN6I_CSI_CAPTURE_WIDTH_MIN; + frmsize->stepwise.max_width = SUN6I_CSI_CAPTURE_WIDTH_MAX; + frmsize->stepwise.min_height = SUN6I_CSI_CAPTURE_HEIGHT_MIN; + frmsize->stepwise.max_height = SUN6I_CSI_CAPTURE_HEIGHT_MAX; + frmsize->stepwise.step_width = 2; + frmsize->stepwise.step_height = 2; + + return 0; +} + static int sun6i_csi_capture_enum_input(struct file *file, void *priv, struct v4l2_input *input) { @@ -900,11 +900,12 @@ static const struct v4l2_ioctl_ops sun6i_csi_capture_ioctl_ops = { .vidioc_querycap = sun6i_csi_capture_querycap, .vidioc_enum_fmt_vid_cap = sun6i_csi_capture_enum_fmt, - .vidioc_enum_framesizes = sun6i_csi_capture_enum_framesize, .vidioc_g_fmt_vid_cap = sun6i_csi_capture_g_fmt, .vidioc_s_fmt_vid_cap = sun6i_csi_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_csi_capture_try_fmt, + .vidioc_enum_framesizes = sun6i_csi_capture_enum_framesizes, + .vidioc_enum_input = sun6i_csi_capture_enum_input, .vidioc_g_input = sun6i_csi_capture_g_input, .vidioc_s_input = sun6i_csi_capture_s_input, @@ -984,16 +985,17 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) media_entity_to_video_device(link->sink->entity); struct sun6i_csi_device *csi_dev = video_get_drvdata(video_dev); struct v4l2_device *v4l2_dev = csi_dev->v4l2_dev; - struct v4l2_subdev *src_subdev = + struct v4l2_subdev *bridge_subdev = media_entity_to_v4l2_subdev(link->source->entity); const struct sun6i_csi_capture_format *capture_format; const struct sun6i_csi_bridge_format *bridge_format; unsigned int capture_width, capture_height; - struct v4l2_subdev_format src_fmt = { - .which = V4L2_SUBDEV_FORMAT_ACTIVE, - .pad = link->source->index + unsigned int bridge_width, bridge_height; + struct v4l2_subdev_format bridge_subdev_format = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = link->source->index, }; - u32 pixelformat, capture_field; + u32 pixelformat, capture_field, mbus_code; int ret; sun6i_csi_capture_dimensions(csi_dev, &capture_width, &capture_height); @@ -1004,21 +1006,25 @@ static int sun6i_csi_capture_link_validate(struct media_link *link) return -EINVAL; /* Resolve csi bridge format. */ - ret = v4l2_subdev_call(src_subdev, pad, get_fmt, NULL, &src_fmt); + ret = v4l2_subdev_call(bridge_subdev, pad, get_fmt, NULL, + &bridge_subdev_format); if (ret) return ret; - bridge_format = sun6i_csi_bridge_format_find(src_fmt.format.code); + bridge_width = bridge_subdev_format.format.width; + bridge_height = bridge_subdev_format.format.height; + mbus_code = bridge_subdev_format.format.code; + + bridge_format = sun6i_csi_bridge_format_find(mbus_code); if (WARN_ON(!bridge_format)) return -EINVAL; /* No cropping/scaling is supported. */ - if (capture_width != src_fmt.format.width || - capture_height != src_fmt.format.height) { + if (capture_width != bridge_width || capture_height != bridge_height) { v4l2_err(v4l2_dev, "invalid input/output dimensions: %ux%u/%ux%u\n", - src_fmt.format.width, src_fmt.format.height, - capture_width, capture_height); + bridge_width, bridge_height, capture_width, + capture_height); return -EINVAL; } From patchwork Mon May 18 10:24:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2303 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id 616A71C07E9 for ; Mon, 18 May 2026 12:47:22 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-23463-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-23463-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 9951F3018157 for ; Mon, 18 May 2026 10:32:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9A8B3E8C46; Mon, 18 May 2026 10:31:30 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 692203EAC86; Mon, 18 May 2026 10:31:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100289; cv=none; b=Z2c0l7hhWvPluhg/WSDxB0MNTlwR5wp1OUGCvVnhzOL1V4ccUrzycSBoFbO9N8XaU2gnAFceQimutmapcccMYgcOrmwxmzMy/LM8d+v3AOS6YRQ+L9sLrNvQukpqKBiWxzQsfgNEKIRyhNdrK5bHvLCeJJcJVDxrAo8Fgs0YkpM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100289; c=relaxed/simple; bh=3KX5OyYkwJhiTbzQdQdOc5p3BV7xGqdUpy50KYOtY0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VwI9aSwDmwXQhoZhMqn00vDQPUdbiaIs3B/+UI5GedNZM4ipZKQqS88/bHtOMM7YeIDs41yt4694V3MEWhr/B2cSpkxqqnIkZY/a/vkEqCFu0i/7vSWgktx0zt75UdMd5uzsWi5SY8LdKa/dZO1smtF5Q+9itChFclzYNyUFD68= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id B2F4A1F80041; Mon, 18 May 2026 10:31:18 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 3C1A7B40824; Mon, 18 May 2026 10:31:18 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id ECF89B407F9; Mon, 18 May 2026 10:25:00 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 12/16] media: sun6i-mipi-csi2: Fix parenthesis alignment Date: Mon, 18 May 2026 12:24:47 +0200 Message-ID: <20260518102451.417971-13-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= This is purely cosmetic, no functional change intended. Signed-off-by: Paul Kocialkowski --- drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c index 682bdd82098c..17a9a215a98a 100644 --- a/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c +++ b/drivers/media/platform/sunxi/sun6i-mipi-csi2/sun6i_mipi_csi2.c @@ -96,7 +96,7 @@ static void sun6i_mipi_csi2_disable(struct sun6i_mipi_csi2_device *csi2_dev) } static void sun6i_mipi_csi2_configure(struct sun6i_mipi_csi2_device *csi2_dev, - const struct v4l2_mbus_framefmt *mbus_format) + const struct v4l2_mbus_framefmt *mbus_format) { struct regmap *regmap = csi2_dev->regmap; unsigned int lanes_count = From patchwork Mon May 18 10:24:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2305 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id BE27B1C05D7 for ; Mon, 18 May 2026 12:54:37 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23464-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23464-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 2AA873187257 for ; Mon, 18 May 2026 10:33:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3D2F3EF0DA; Mon, 18 May 2026 10:32:24 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7005C3ED114; Mon, 18 May 2026 10:31:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100342; cv=none; b=NCBpQ/lYrKV9o7iOEq3NKAvQVLC2nppLbbdlhH0NvcoCwiKl+0W5Kzm58fDsrbaENNy59eTgm7KsHIqg6Cn59Ta96hnZccqH4MzhW+UkE/Z3ZVXVXOTPP8KPCJ/fWUV9J+I1nHlQvI4Y28ANBU2RzfC0C+2gO6ee3ZzAOztsE9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100342; c=relaxed/simple; bh=y79apGl6OKDANYCmmE5+PZLLyf9iwNGUT3KnWbPd0gQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MGfgCr//MEj48E2y1XZgi4lMXwx5zcdTpdSuywR8OT42YXXdil92XstlcAAmKEsv9JGsnLo/MQl8hvJbrmqcVqgs3rCen/pUQX6nxzoCUNLwnenJLgd0JL32qm6xfxk+B5pPcNM7jstjI5UDqpzh9Wqt9vJDwDo/GWVKBdezoYM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 4CB791F80041; Mon, 18 May 2026 10:31:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id D0DC9B40828; Mon, 18 May 2026 10:31:43 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 6F206B407FB; Mon, 18 May 2026 10:25:01 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 13/16] media: sun6i-isp: Add dummy params link_validate implementation Date: Mon, 18 May 2026 12:24:48 +0200 Message-ID: <20260518102451.417971-14-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[99.99%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; DMARC_NA(0.00)[sys-base.io]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[sys-base.io:email,sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23464-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: BE27B1C05D7 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= There isn't anything configurable about the params video device link, but the v4l2 core complains that no op is provided so implement a dummy one to make it happy. Signed-off-by: Paul Kocialkowski Tested-by: Arash Golgol --- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c index 77c2d06c0436..b7ef33fa2b13 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c @@ -450,6 +450,18 @@ static const struct v4l2_file_operations sun6i_isp_params_fops = { .poll = vb2_fop_poll, }; +/* Media Entity */ + +static int sun6i_isp_params_link_validate(struct media_link *link) +{ + /* Nothing to validate here. */ + return 0; +} + +static const struct media_entity_operations sun6i_isp_params_entity_ops = { + .link_validate = sun6i_isp_params_link_validate, +}; + /* Params */ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev) @@ -470,6 +482,10 @@ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev) INIT_LIST_HEAD(&state->queue); spin_lock_init(&state->lock); + /* Media Entity */ + + video_dev->entity.ops = &sun6i_isp_params_entity_ops; + /* Media Pads */ pad->flags = MEDIA_PAD_FL_SOURCE | MEDIA_PAD_FL_MUST_CONNECT; From patchwork Mon May 18 10:24:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2307 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id 4D3F21C05D7 for ; Mon, 18 May 2026 13:03:16 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-23465-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-23465-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id 4807E30569AE for ; Mon, 18 May 2026 10:33:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E94E3EF651; Mon, 18 May 2026 10:32:25 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD5143ED110; Mon, 18 May 2026 10:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100342; cv=none; b=ZB067vDQU/TycevX84+LVLFppGvNU/0GVVOs+N37n9xTi1SKZXsLUz+uAq66N20eo2a3bJi7uEenmJZZ5lBl1ogAj1Zvga4ITB20hamTbWci7ZHLhCTg62rg1XJcKVv7oSf4rzMfsR9pUhpA4fMYie79wWCm2fL3O2ECiSywX/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100342; c=relaxed/simple; bh=fmifNF4wHadqQlP/a3pXW+27pHqSFgjDfb4aMBlUX9c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V2bujZvgJbnb8pqL7qCd3AmONl+67Oa2Fc0q5Fg7C2YBvMJTbrPWw1wDcOj6u3mDb0N0UCbY2crhHmXPp+JwY2UToRAV3q17Iuwxz8GmOec8ttXJpMhksWImvUofgYPxJ4fOrYNAnZc4d9f7INBXkY6+tPQfy4UsWJJ5ZAtcs34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 49E2C1F80044; Mon, 18 May 2026 10:32:11 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id BDF3DB40828; Mon, 18 May 2026 10:32:10 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id B68C1B407FD; Mon, 18 May 2026 10:25:01 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 14/16] media: sun6i-isp: Use V4L2 subdev active state Date: Mon, 18 May 2026 12:24:49 +0200 Message-ID: <20260518102451.417971-15-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[104.64.211.4:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; FREEMAIL_CC(0.00)[sys-base.io,kernel.org,gmail.com,sholland.org,linuxfoundation.org,ideasonboard.com,collabora.com]; DMARC_NA(0.00)[sys-base.io]; MIME_TRACE(0.00)[0:+]; DBL_BLOCKED_OPENRESOLVER(0.00)[sin.lore.kernel.org:rdns,sin.lore.kernel.org:helo,sys-base.io:email]; RCPT_COUNT_TWELVE(0.00)[14]; FUZZY_BLOCKED(0.00)[rspamd.com]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; FROM_HAS_DN(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_TLS_LAST(0.00)[]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; TO_DN_SOME(0.00)[]; RCVD_COUNT_SEVEN(0.00)[7]; R_DKIM_NA(0.00)[]; TAGGED_FROM(0.00)[bounces-23465-noreply=patchwork.local]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; FROM_NEQ_ENVFROM(0.00)[paulk@sys-base.io,linux-sunxi@lists.linux.dev]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; FORGED_SENDER_MAILLIST(0.00)[] X-Rspamd-Queue-Id: 4D3F21C05D7 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Store the active format using the common V4L2 subdev active state instead of our local copy of it. Signed-off-by: Paul Kocialkowski Tested-by: Arash Golgol Reviewed-by: Arash Golgol --- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 16 ++- .../media/sunxi/sun6i-isp/sun6i_isp_params.c | 18 ++- .../media/sunxi/sun6i-isp/sun6i_isp_params.h | 4 +- .../media/sunxi/sun6i-isp/sun6i_isp_proc.c | 117 ++++++++---------- .../media/sunxi/sun6i-isp/sun6i_isp_proc.h | 7 -- 5 files changed, 82 insertions(+), 80 deletions(-) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c index e7b99cee63d6..24e731bcabe9 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c @@ -595,11 +595,25 @@ static int sun6i_isp_capture_link_validate(struct media_link *link) media_entity_to_video_device(link->sink->entity); struct sun6i_isp_device *isp_dev = video_get_drvdata(video_dev); struct v4l2_device *v4l2_dev = &isp_dev->v4l2.v4l2_dev; + struct v4l2_subdev *proc_subdev = + media_entity_to_v4l2_subdev(link->source->entity); unsigned int capture_width, capture_height; unsigned int proc_width, proc_height; + struct v4l2_subdev_format proc_subdev_format = { + .which = V4L2_SUBDEV_FORMAT_ACTIVE, + .pad = link->source->index, + }; + int ret; sun6i_isp_capture_dimensions(isp_dev, &capture_width, &capture_height); - sun6i_isp_proc_dimensions(isp_dev, &proc_width, &proc_height); + + ret = v4l2_subdev_call(proc_subdev, pad, get_fmt, NULL, + &proc_subdev_format); + if (ret) + return ret; + + proc_width = proc_subdev_format.format.width; + proc_height = proc_subdev_format.format.height; /* No cropping/scaling is supported (yet). */ if (capture_width != proc_width || capture_height != proc_height) { diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c index b7ef33fa2b13..0cc48e2bc8c6 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c @@ -43,11 +43,14 @@ static const struct sun6i_isp_params_config sun6i_isp_params_config_default = { }, }; -static void sun6i_isp_params_configure_ob(struct sun6i_isp_device *isp_dev) +static void +sun6i_isp_params_configure_ob(struct sun6i_isp_device *isp_dev, + const struct v4l2_mbus_framefmt *mbus_format) { unsigned int width, height; - sun6i_isp_proc_dimensions(isp_dev, &width, &height); + width = mbus_format->width; + height = mbus_format->height; sun6i_isp_load_write(isp_dev, SUN6I_ISP_OB_SIZE_REG, SUN6I_ISP_OB_SIZE_WIDTH(width) | @@ -112,10 +115,12 @@ static void sun6i_isp_params_configure_wb(struct sun6i_isp_device *isp_dev) SUN6I_ISP_WB_CFG_CLIP(0xfff)); } -static void sun6i_isp_params_configure_base(struct sun6i_isp_device *isp_dev) +static void +sun6i_isp_params_configure_base(struct sun6i_isp_device *isp_dev, + const struct v4l2_mbus_framefmt *mbus_format) { sun6i_isp_params_configure_ae(isp_dev); - sun6i_isp_params_configure_ob(isp_dev); + sun6i_isp_params_configure_ob(isp_dev, mbus_format); sun6i_isp_params_configure_wb(isp_dev); } @@ -170,14 +175,15 @@ sun6i_isp_params_configure_modules(struct sun6i_isp_device *isp_dev, sun6i_isp_load_write(isp_dev, SUN6I_ISP_MODULE_EN_REG, value); } -void sun6i_isp_params_configure(struct sun6i_isp_device *isp_dev) +void sun6i_isp_params_configure(struct sun6i_isp_device *isp_dev, + const struct v4l2_mbus_framefmt *mbus_format) { struct sun6i_isp_params_state *state = &isp_dev->params.state; unsigned long flags; spin_lock_irqsave(&state->lock, flags); - sun6i_isp_params_configure_base(isp_dev); + sun6i_isp_params_configure_base(isp_dev, mbus_format); /* Default config is only applied at the very first stream start. */ if (state->configured) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.h b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.h index 50f10f879c42..c0d6cff95d54 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.h +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.h @@ -36,8 +36,8 @@ struct sun6i_isp_params { /* Params */ -void sun6i_isp_params_configure(struct sun6i_isp_device *isp_dev); - +void sun6i_isp_params_configure(struct sun6i_isp_device *isp_dev, + const struct v4l2_mbus_framefmt *mbus_format); /* State */ void sun6i_isp_params_state_update(struct sun6i_isp_device *isp_dev, diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c index 46a334b602f1..9073a7f3f8c8 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.c @@ -15,17 +15,6 @@ #include "sun6i_isp_proc.h" #include "sun6i_isp_reg.h" -/* Helpers */ - -void sun6i_isp_proc_dimensions(struct sun6i_isp_device *isp_dev, - unsigned int *width, unsigned int *height) -{ - if (width) - *width = isp_dev->proc.mbus_format.width; - if (height) - *height = isp_dev->proc.mbus_format.height; -} - /* Format */ static const struct sun6i_isp_proc_format sun6i_isp_proc_formats[] = { @@ -137,9 +126,10 @@ static void sun6i_isp_proc_disable(struct sun6i_isp_device *isp_dev) regmap_write(regmap, SUN6I_ISP_FE_CFG_REG, 0); } -static void sun6i_isp_proc_configure(struct sun6i_isp_device *isp_dev) +static void +sun6i_isp_proc_configure(struct sun6i_isp_device *isp_dev, + const struct v4l2_mbus_framefmt *mbus_format) { - struct v4l2_mbus_framefmt *mbus_format = &isp_dev->proc.mbus_format; const struct sun6i_isp_proc_format *format; u32 value; @@ -173,6 +163,8 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on) struct sun6i_isp_proc_source *source; struct v4l2_subdev *source_subdev; struct media_pad *remote_pad; + struct v4l2_subdev_state *state; + const struct v4l2_mbus_framefmt *mbus_format; int ret; /* Source */ @@ -191,6 +183,10 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on) else source = &proc->source_csi1; + /* Active State */ + + state = v4l2_subdev_lock_and_get_active_state(subdev); + if (!on) { sun6i_isp_proc_irq_disable(isp_dev); v4l2_subdev_call(source_subdev, video, s_stream, 0); @@ -202,7 +198,7 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on) ret = pm_runtime_resume_and_get(dev); if (ret < 0) - return ret; + goto unlock; /* Clear */ @@ -210,9 +206,12 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on) /* Configure */ + mbus_format = v4l2_subdev_state_get_format(state, + SUN6I_ISP_PROC_PAD_SINK_CSI); + sun6i_isp_tables_configure(isp_dev); - sun6i_isp_params_configure(isp_dev); - sun6i_isp_proc_configure(isp_dev); + sun6i_isp_params_configure(isp_dev, mbus_format); + sun6i_isp_proc_configure(isp_dev, mbus_format); sun6i_isp_capture_configure(isp_dev); /* State Update */ @@ -230,13 +229,17 @@ static int sun6i_isp_proc_s_stream(struct v4l2_subdev *subdev, int on) goto disable; } - return 0; + ret = 0; + goto unlock; disable: sun6i_isp_proc_disable(isp_dev); pm_runtime_put(dev); +unlock: + v4l2_subdev_unlock_state(state); + return ret; } @@ -259,21 +262,22 @@ sun6i_isp_proc_mbus_format_prepare(struct v4l2_mbus_framefmt *mbus_format) static int sun6i_isp_proc_init_state(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state) { - struct sun6i_isp_device *isp_dev = v4l2_get_subdevdata(subdev); - unsigned int pad = SUN6I_ISP_PROC_PAD_SINK_CSI; - struct v4l2_mbus_framefmt *mbus_format = - v4l2_subdev_state_get_format(state, pad); - struct mutex *lock = &isp_dev->proc.lock; + unsigned int pad; - mutex_lock(lock); + for (pad = 0; pad < subdev->entity.num_pads; pad++) { + struct v4l2_mbus_framefmt *mbus_format; - mbus_format->code = sun6i_isp_proc_formats[0].mbus_code; - mbus_format->width = 1280; - mbus_format->height = 720; + if (pad == SUN6I_ISP_PROC_PAD_SINK_PARAMS) + continue; - sun6i_isp_proc_mbus_format_prepare(mbus_format); + mbus_format = v4l2_subdev_state_get_format(state, pad); - mutex_unlock(lock); + mbus_format->code = sun6i_isp_proc_formats[0].mbus_code; + mbus_format->width = 1280; + mbus_format->height = 720; + + sun6i_isp_proc_mbus_format_prepare(mbus_format); + } return 0; } @@ -291,53 +295,31 @@ sun6i_isp_proc_enum_mbus_code(struct v4l2_subdev *subdev, return 0; } -static int sun6i_isp_proc_get_fmt(struct v4l2_subdev *subdev, - struct v4l2_subdev_state *state, - struct v4l2_subdev_format *format) -{ - struct sun6i_isp_device *isp_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &isp_dev->proc.lock; - - mutex_lock(lock); - - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *mbus_format = *v4l2_subdev_state_get_format(state, - format->pad); - else - *mbus_format = isp_dev->proc.mbus_format; - - mutex_unlock(lock); - - return 0; -} - static int sun6i_isp_proc_set_fmt(struct v4l2_subdev *subdev, struct v4l2_subdev_state *state, struct v4l2_subdev_format *format) { - struct sun6i_isp_device *isp_dev = v4l2_get_subdevdata(subdev); - struct v4l2_mbus_framefmt *mbus_format = &format->format; - struct mutex *lock = &isp_dev->proc.lock; + struct v4l2_mbus_framefmt *mbus_format; - mutex_lock(lock); + if (format->pad != SUN6I_ISP_PROC_PAD_SINK_CSI) + return v4l2_subdev_get_fmt(subdev, state, format); - sun6i_isp_proc_mbus_format_prepare(mbus_format); + sun6i_isp_proc_mbus_format_prepare(&format->format); - if (format->which == V4L2_SUBDEV_FORMAT_TRY) - *v4l2_subdev_state_get_format(state, format->pad) = - *mbus_format; - else - isp_dev->proc.mbus_format = *mbus_format; + mbus_format = v4l2_subdev_state_get_format(state, format->pad); + *mbus_format = format->format; - mutex_unlock(lock); + /* Propagate the format to the source pad. */ + mbus_format = v4l2_subdev_state_get_format(state, + SUN6I_ISP_PROC_PAD_SOURCE); + *mbus_format = format->format; return 0; } static const struct v4l2_subdev_pad_ops sun6i_isp_proc_pad_ops = { .enum_mbus_code = sun6i_isp_proc_enum_mbus_code, - .get_fmt = sun6i_isp_proc_get_fmt, + .get_fmt = v4l2_subdev_get_fmt, .set_fmt = sun6i_isp_proc_set_fmt, }; @@ -499,8 +481,6 @@ int sun6i_isp_proc_setup(struct sun6i_isp_device *isp_dev) struct media_pad *pads = proc->pads; int ret; - mutex_init(&proc->lock); - /* V4L2 Subdev */ v4l2_subdev_init(subdev, &sun6i_isp_proc_subdev_ops); @@ -532,10 +512,14 @@ int sun6i_isp_proc_setup(struct sun6i_isp_device *isp_dev) /* V4L2 Subdev */ + ret = v4l2_subdev_init_finalize(subdev); + if (ret < 0) + goto error_media_entity; + ret = v4l2_device_register_subdev(v4l2_dev, subdev); if (ret < 0) { v4l2_err(v4l2_dev, "failed to register v4l2 subdev: %d\n", ret); - goto error_media_entity; + goto error_subdev_finalize; } /* V4L2 Async */ @@ -562,6 +546,9 @@ int sun6i_isp_proc_setup(struct sun6i_isp_device *isp_dev) v4l2_device_unregister_subdev(subdev); +error_subdev_finalize: + v4l2_subdev_cleanup(subdev); + error_media_entity: media_entity_cleanup(&subdev->entity); @@ -577,5 +564,7 @@ void sun6i_isp_proc_cleanup(struct sun6i_isp_device *isp_dev) v4l2_async_nf_cleanup(notifier); v4l2_device_unregister_subdev(subdev); + v4l2_subdev_cleanup(subdev); + media_entity_cleanup(&subdev->entity); } diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.h b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.h index db6738a39147..26c4327c5ed7 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.h +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_proc.h @@ -42,18 +42,11 @@ struct sun6i_isp_proc { struct v4l2_subdev subdev; struct media_pad pads[3]; struct v4l2_async_notifier notifier; - struct v4l2_mbus_framefmt mbus_format; - struct mutex lock; /* Mbus format lock. */ struct sun6i_isp_proc_source source_csi0; struct sun6i_isp_proc_source source_csi1; }; -/* Helpers */ - -void sun6i_isp_proc_dimensions(struct sun6i_isp_device *isp_dev, - unsigned int *width, unsigned int *height); - /* Format */ const struct sun6i_isp_proc_format *sun6i_isp_proc_format_find(u32 mbus_code); From patchwork Mon May 18 10:24:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2304 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id D46481C00A5 for ; Mon, 18 May 2026 12:51:41 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-23466-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-23466-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id E602130118F9 for ; Mon, 18 May 2026 10:34:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD2DD3EFFC9; Mon, 18 May 2026 10:32:58 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E20F3EEACB; Mon, 18 May 2026 10:32:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100377; cv=none; b=FLToJ0pXh+jUcgxAz/PL3HfA9d1u8i3S0Z/5/2GZGuu1oaxc+0QZuFtO95xcboBKz9xfjWJKz1sNm7XbIgC/YB3bb8FkLpkhwCZkVyTpRUhc29lKD29mkGb+wxG7WtOy3vsRiFL/jldB8VYMYjQIhTyV4VYKLI6vfZ8+uf0atSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100377; c=relaxed/simple; bh=2ryYcYdMDv3PHd8raqE/i1so2/ppAY539lB4WGhZSA4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n9XqwROr292T8HMx32ZmoQbBM70Ouw9XYnQyh/bvbbOHnGbBhKjYSP0l0fPLmG5PSRchjXFYxCbZHPhmQHKYdgwy+SSALyRs5vB/JLQLRbtZrpx4Gaz7eleDN5wr5v9YNIduUfr1ZgczqXf64BLZbT6Gar6mKbI6tdfh7mpqDyw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id 5B19F1F80044; Mon, 18 May 2026 10:32:44 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id D123EB4082D; Mon, 18 May 2026 10:32:43 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 0912DB407FE; Mon, 18 May 2026 10:25:02 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 15/16] media: sun6i-isp: Add support for MC-centric format enumeration Date: Mon, 18 May 2026 12:24:50 +0200 Message-ID: <20260518102451.417971-16-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Just make sure the provided mbus code is supported and carry on with the existing implementation since the pixelformat is independent from the mbus code. The params video node only supports a single format and does not care about the mbus format, but we can still report MC-centric support. Signed-off-by: Paul Kocialkowski Tested-by: Arash Golgol --- .../staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c | 9 ++++++++- drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c index 24e731bcabe9..372b9331bd6d 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c @@ -436,8 +436,14 @@ static int sun6i_isp_capture_querycap(struct file *file, void *priv, static int sun6i_isp_capture_enum_fmt(struct file *file, void *priv, struct v4l2_fmtdesc *fmtdesc) { + u32 mbus_code = fmtdesc->mbus_code; u32 index = fmtdesc->index; + if (mbus_code && !sun6i_isp_proc_format_find(mbus_code)) + return -EINVAL; + + /* Capture format is independent from proc format. */ + if (index >= ARRAY_SIZE(sun6i_isp_capture_formats)) return -EINVAL; @@ -697,7 +703,8 @@ int sun6i_isp_capture_setup(struct sun6i_isp_device *isp_dev) strscpy(video_dev->name, SUN6I_ISP_CAPTURE_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_RX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_isp_capture_fops; diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c index 0cc48e2bc8c6..2622e5a07817 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_params.c @@ -531,7 +531,8 @@ int sun6i_isp_params_setup(struct sun6i_isp_device *isp_dev) strscpy(video_dev->name, SUN6I_ISP_PARAMS_NAME, sizeof(video_dev->name)); - video_dev->device_caps = V4L2_CAP_META_OUTPUT | V4L2_CAP_STREAMING; + video_dev->device_caps = V4L2_CAP_META_OUTPUT | V4L2_CAP_STREAMING | + V4L2_CAP_IO_MC; video_dev->vfl_dir = VFL_DIR_TX; video_dev->release = video_device_release_empty; video_dev->fops = &sun6i_isp_params_fops; From patchwork Mon May 18 10:24:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Kocialkowski X-Patchwork-Id: 2306 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id C8CA11C05D7 for ; Mon, 18 May 2026 12:58:21 +0200 (CEST) Authentication-Results: mxe881; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-23467-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-23467-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id 8651F30B5873 for ; Mon, 18 May 2026 10:37:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B73A3F4112; Mon, 18 May 2026 10:33:30 +0000 (UTC) X-Original-To: linux-sunxi@lists.linux.dev Received: from leonov.paulk.fr (leonov.paulk.fr [185.233.101.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 625F33F075C; Mon, 18 May 2026 10:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.233.101.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100409; cv=none; b=K56gNoe6xXotkWWi7ykcfgMvUtI2nV/z7IOMht6xHBBOn7UJb2FRtzulqCbI4nIvus6oZRQuqawzVrjp7H9sUpgGiejjpimTpXWIyb8hQ0RSS8LxuVa43ntVbAMZm2dSYxEVMrU7szqtkk7F2vtvMhoGExA74Mg8RSlPixVimtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779100409; c=relaxed/simple; bh=SgJOt2lJqQBSvcUOjOlop7PuiMEzx9YAgYU411aMNBA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kFXzNzLYdUp3rhzWhafJdO2SKZZna1h/v+iCkR5pTbvo3SzGBbBU8q2gbG9u4ShZdMMTSDxUTS18TM3MRXZ+8/+eJhQRSduSCMgkWPaF5o3ewGEmj1i5Gs0yG5Qbong/mfwutP4TOgq2JLsdNXZvxH1Ds4ELONHOwr+BtUTtsoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io; spf=pass smtp.mailfrom=sys-base.io; arc=none smtp.client-ip=185.233.101.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sys-base.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sys-base.io Received: from laika.paulk.fr (12.234.24.109.rev.sfr.net [109.24.234.12]) by leonov.paulk.fr (Postfix) with ESMTPS id E7BB11F80041; Mon, 18 May 2026 10:33:09 +0000 (UTC) Received: by laika.paulk.fr (Postfix, from userid 65534) id 6F611B4082E; Mon, 18 May 2026 10:33:09 +0000 (UTC) X-Spam-Level: * Received: from collins (unknown [192.168.1.64]) by laika.paulk.fr (Postfix) with ESMTP id 52A59B407FF; Mon, 18 May 2026 10:25:02 +0000 (UTC) From: Paul Kocialkowski To: linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Cc: Paul Kocialkowski , Mauro Carvalho Chehab , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Greg Kroah-Hartman , Arash Golgol , Laurent Pinchart , Nicolas Dufresne Subject: [PATCH 16/16] media: sun6i-isp: Add support for frame size enumeration Date: Mon, 18 May 2026 12:24:51 +0200 Message-ID: <20260518102451.417971-17-paulk@sys-base.io> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518102451.417971-1-paulk@sys-base.io> References: <20260518102451.417971-1-paulk@sys-base.io> Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= This implements the enum_framesizes operation, which reports support for even sizes. Signed-off-by: Paul Kocialkowski Tested-by: Arash Golgol Reviewed-by: Arash Golgol --- .../media/sunxi/sun6i-isp/sun6i_isp_capture.c | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c index 372b9331bd6d..e638ec32c7cd 100644 --- a/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c +++ b/drivers/staging/media/sunxi/sun6i-isp/sun6i_isp_capture.c @@ -452,6 +452,26 @@ static int sun6i_isp_capture_enum_fmt(struct file *file, void *priv, return 0; } +static int sun6i_isp_capture_enum_framesizes(struct file *file, void *fh, + struct v4l2_frmsizeenum *frmsize) +{ + if (frmsize->index) + return -EINVAL; + + if (!sun6i_isp_capture_format_find(frmsize->pixel_format)) + return -EINVAL; + + frmsize->type = V4L2_FRMSIZE_TYPE_STEPWISE; + frmsize->stepwise.min_width = SUN6I_ISP_CAPTURE_WIDTH_MIN; + frmsize->stepwise.max_width = SUN6I_ISP_CAPTURE_WIDTH_MAX; + frmsize->stepwise.min_height = SUN6I_ISP_CAPTURE_HEIGHT_MIN; + frmsize->stepwise.max_height = SUN6I_ISP_CAPTURE_HEIGHT_MAX; + frmsize->stepwise.step_width = 2; + frmsize->stepwise.step_height = 2; + + return 0; +} + static int sun6i_isp_capture_g_fmt(struct file *file, void *priv, struct v4l2_format *format) { @@ -522,6 +542,8 @@ static const struct v4l2_ioctl_ops sun6i_isp_capture_ioctl_ops = { .vidioc_s_fmt_vid_cap = sun6i_isp_capture_s_fmt, .vidioc_try_fmt_vid_cap = sun6i_isp_capture_try_fmt, + .vidioc_enum_framesizes = sun6i_isp_capture_enum_framesizes, + .vidioc_enum_input = sun6i_isp_capture_enum_input, .vidioc_g_input = sun6i_isp_capture_g_input, .vidioc_s_input = sun6i_isp_capture_s_input,