From patchwork Wed Jun 19 23:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 13704714 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (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 87A7015B143 for ; Wed, 19 Jun 2024 23:24:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718839497; cv=none; b=YgbFJbiY9VGgR5bqJfCjalXclOYuDyoMt/nDDtsv7eMHGkQPklbNuO1UiYe5vL5n9+Zr5IL+JeVOH+zoK6NAiyzo9jkgUsA7sO2IyIHHGhDeydqNnEzmA8KVbzpIaHdoEhFgUhH1vZMZu6BR2MepW9afuoj/m0DGBJvzdHjALQY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718839497; c=relaxed/simple; bh=hOZq0MsRJzwxCzPT8CTrS7U4UH5KCg6abdAycpr1YRc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H37w5tvQSjfGO4p8Dx0R4vepDia/wzaJnpErYF5hyHIEHJ7MM3EjmhQkvR3aqS//ezGKT1HaYokFbmzSojpY4sYJ3CMSgW4oPTArq1xKw8LBzNN3tvFLOWduxNN2vGR5YN4TkkIi1EeanKvP1Sa1cJv/woMN/9Y4R++ZPWJzZTU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=OuWxmMqY; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="OuWxmMqY" Received: from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi [81.175.209.231]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 52EFD8E1; Thu, 20 Jun 2024 01:24:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1718839475; bh=hOZq0MsRJzwxCzPT8CTrS7U4UH5KCg6abdAycpr1YRc=; h=From:To:Cc:Subject:Date:From; b=OuWxmMqYRk8tENZ/2VPDy/xwLD2UvmLzNuUd4jeyLwMwP91PycW9IVbzkhJZNXSUQ zik/OZS3kLaXnQxdPvt3IR9XLYyfOy2hAnA+LqML4K5/X8oz0sVE5hgf6pmCGq9M2O Q1TrW0enE05CUNfo7qPjXKyTDc2TUQUobofvAGtE= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Rui Miguel Silva , Martin Kepplinger , Tomi Valkeinen , imx@lists.linux.dev, Purism Kernel Team Subject: [PATCH] media: imx-mipi-csis: Use v4l2_subdev_enable_streams() Date: Thu, 20 Jun 2024 02:24:31 +0300 Message-ID: <20240619232431.5708-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.44.2 Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To support sources that implement the .enable_streams() and .disable_streams() operations, replace the manual calls to the subdev .s_stream() operation with the v4l2_subdev_enable_streams() and v4l2_subdev_disable_streams() helpers. The helpers fall back to .s_stream() if the source doesn't implement the new operations, so backward compatibility is preserved. Signed-off-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen Reviewed-by: Rui Miguel Silva --- drivers/media/platform/nxp/imx-mipi-csis.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) base-commit: 6ba59ff4227927d3a8530fc2973b80e94b54d58f diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index f49b06978f14..b9729a8883d6 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -320,7 +320,11 @@ struct mipi_csis_device { struct v4l2_subdev sd; struct media_pad pads[CSIS_PADS_NUM]; struct v4l2_async_notifier notifier; - struct v4l2_subdev *src_sd; + + struct { + struct v4l2_subdev *sd; + const struct media_pad *pad; + } source; struct v4l2_mbus_config_mipi_csi2 bus; u32 clk_frequency; @@ -597,7 +601,7 @@ static int mipi_csis_calculate_params(struct mipi_csis_device *csis, u32 lane_rate; /* Calculate the line rate from the pixel rate. */ - link_freq = v4l2_get_link_freq(csis->src_sd->ctrl_handler, + link_freq = v4l2_get_link_freq(csis->source.sd->ctrl_handler, csis_fmt->width, csis->bus.num_data_lanes * 2); if (link_freq < 0) { @@ -958,7 +962,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable) int ret; if (!enable) { - v4l2_subdev_call(csis->src_sd, video, s_stream, 0); + v4l2_subdev_disable_streams(csis->source.sd, + csis->source.pad->index, BIT(0)); mipi_csis_stop_stream(csis); if (csis->debug.enable) @@ -986,7 +991,8 @@ static int mipi_csis_s_stream(struct v4l2_subdev *sd, int enable) mipi_csis_start_stream(csis, format, csis_fmt); - ret = v4l2_subdev_call(csis->src_sd, video, s_stream, 1); + ret = v4l2_subdev_enable_streams(csis->source.sd, + csis->source.pad->index, BIT(0)); if (ret < 0) goto err_stop; @@ -1233,12 +1239,14 @@ static int mipi_csis_link_setup(struct media_entity *entity, remote_sd = media_entity_to_v4l2_subdev(remote_pad->entity); if (flags & MEDIA_LNK_FL_ENABLED) { - if (csis->src_sd) + if (csis->source.sd) return -EBUSY; - csis->src_sd = remote_sd; + csis->source.sd = remote_sd; + csis->source.pad = remote_pad; } else { - csis->src_sd = NULL; + csis->source.sd = NULL; + csis->source.pad = NULL; } return 0;