From nobody Wed Nov 27 20:39:52 2024 Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) (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 4BC101D618C; Tue, 8 Oct 2024 11:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.207.212.93 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388204; cv=none; b=K+/kesClMdTMWIom2Q/s2b2uBo9fa8jR+cNDp+0D9EK5PQdM6EeO6Ta0+7cERq6oKk9iToLmctW698Z2MnZpmIqFup8/e8z9IpfAFQcM3jAYR1nsP/5otjMDRxt2CFcABaQo6f/ltdg2sri7qiyi5JY1y04kYhKr4M8XL6wa+f0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388204; c=relaxed/simple; bh=aBT9XJInmCyIxEXaR/76joWX1ch3qVUvo8eMVa9f79A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=U8bERls7fYaB4HPoG7UZ093043oA35wckJk97wPz3Twvy4bz7CqQ2zbQPdmcsXXUEoUOrSKachNtHCDs2oC86q4bhnk/2bKhcYG/FWO0Payrp3JeuXRRfKvOmYbBM6KO6x6G0FyUYL4SD1k/uPnRDg/xgsXS7pYKTm85051gdR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com; spf=pass smtp.mailfrom=foss.st.com; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b=oOErOqMJ; arc=none smtp.client-ip=91.207.212.93 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=foss.st.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=foss.st.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=foss.st.com header.i=@foss.st.com header.b="oOErOqMJ" Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4987rebW032450; Tue, 8 Oct 2024 13:49:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=selector1; bh= 4t/KgWTC6P/GkukrI5HGWXPIG8jDuBJo3wAhaRLViWU=; b=oOErOqMJ0At/XZ4P lx6bdqWErTlFfpTW3XNDLpG/ULG/Y3CfVF2+msW6LYcvbjYF8X+xoQ33m9P6NhnY I7WHk1WlUisGxr12IAGS6aPoSUvtSghaqXbLJmweYRYbvFl/wtMfKhLtmJ5dovx1 V3SY0/iEAk6FfFS3jwUankduRkX/+N75aQiloZOtVQwM3BUZmn0C1tJQgGqs7tdr jimlg/250DqIBHwioS5Banwp+sD6xLNeu9N1lShI0/X+7TTC5hWmcPimvMcHk9ZI VvhX8jdaYtzyxzSYX4YI6MqZ11zupezz5lM4T/sQhiwSsD5WqRACWAt22aTmw87o /3zriQ== Received: from beta.dmz-ap.st.com (beta.dmz-ap.st.com [138.198.100.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 422xtq5ub8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 13:49:55 +0200 (MEST) Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 9A8E04004C; Tue, 8 Oct 2024 13:49:19 +0200 (CEST) Received: from Webmail-eu.st.com (shfdag1node1.st.com [10.75.129.69]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B813C263D0C; Tue, 8 Oct 2024 13:46:36 +0200 (CEST) Received: from localhost (10.129.178.213) by SHFDAG1NODE1.st.com (10.75.129.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.37; Tue, 8 Oct 2024 13:46:36 +0200 From: Alain Volmat Date: Tue, 8 Oct 2024 13:46:06 +0200 Subject: [PATCH 2/4] media: i2c: st-mipid02: use enable/disable_streams pad ops Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20241008-st-mipid02-streams-v1-2-775c2d25cef9@foss.st.com> References: <20241008-st-mipid02-streams-v1-0-775c2d25cef9@foss.st.com> In-Reply-To: <20241008-st-mipid02-streams-v1-0-775c2d25cef9@foss.st.com> To: Benjamin Mugnier , Sylvain Petinot , Mauro Carvalho Chehab CC: , , Alain Volmat X-Mailer: b4 0.14.0 X-ClientProxiedBy: SHFCAS1NODE2.st.com (10.75.129.73) To SHFDAG1NODE1.st.com (10.75.129.69) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 Add pad enable_streams and disable_streams ops in addition to v4l2_subdev_s_stream_helper. Moreover, use functions v4l2_subdev_enable_streams and v4l2_subdev_disable_streams to control the source subdev. Signed-off-by: Alain Volmat --- drivers/media/i2c/st-mipid02.c | 43 +++++++++++++++++---------------------= ---- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index bc637a651a22..1821a8fdd618 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -100,6 +100,7 @@ struct mipid02_dev { /* remote source */ struct v4l2_async_notifier notifier; struct v4l2_subdev *s_subdev; + u16 s_subdev_pad_id; /* registers */ struct { u8 clk_lane_reg1; @@ -447,15 +448,19 @@ static int mipid02_configure_from_code(struct mipid02= _dev *bridge, return 0; } =20 -static int mipid02_stream_disable(struct mipid02_dev *bridge) +static int mipid02_disable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { + struct mipid02_dev *bridge =3D to_mipid02_dev(sd); struct i2c_client *client =3D bridge->i2c_client; int ret =3D -EINVAL; =20 if (!bridge->s_subdev) goto error; =20 - ret =3D v4l2_subdev_call(bridge->s_subdev, video, s_stream, 0); + ret =3D v4l2_subdev_disable_streams(bridge->s_subdev, + bridge->s_subdev_pad_id, BIT(0)); if (ret) goto error; =20 @@ -472,10 +477,12 @@ static int mipid02_stream_disable(struct mipid02_dev = *bridge) return ret; } =20 -static int mipid02_stream_enable(struct mipid02_dev *bridge) +static int mipid02_enable_streams(struct v4l2_subdev *sd, + struct v4l2_subdev_state *state, u32 pad, + u64 streams_mask) { + struct mipid02_dev *bridge =3D to_mipid02_dev(sd); struct i2c_client *client =3D bridge->i2c_client; - struct v4l2_subdev_state *state; struct v4l2_mbus_framefmt *fmt; int ret =3D -EINVAL; =20 @@ -484,7 +491,6 @@ static int mipid02_stream_enable(struct mipid02_dev *br= idge) =20 memset(&bridge->r, 0, sizeof(bridge->r)); =20 - state =3D v4l2_subdev_lock_and_get_active_state(&bridge->sd); fmt =3D v4l2_subdev_state_get_format(state, MIPID02_SINK_0); =20 /* build registers content */ @@ -498,8 +504,6 @@ static int mipid02_stream_enable(struct mipid02_dev *br= idge) if (ret) return ret; =20 - v4l2_subdev_unlock_state(state); - /* write mipi registers */ cci_write(bridge->regmap, MIPID02_CLK_LANE_REG1, bridge->r.clk_lane_reg1, &ret); @@ -524,7 +528,8 @@ static int mipid02_stream_enable(struct mipid02_dev *br= idge) if (ret) goto error; =20 - ret =3D v4l2_subdev_call(bridge->s_subdev, video, s_stream, 1); + ret =3D v4l2_subdev_enable_streams(bridge->s_subdev, + bridge->s_subdev_pad_id, BIT(0)); if (ret) goto error; =20 @@ -539,23 +544,6 @@ static int mipid02_stream_enable(struct mipid02_dev *b= ridge) return ret; } =20 -static int mipid02_s_stream(struct v4l2_subdev *sd, int enable) -{ - struct mipid02_dev *bridge =3D to_mipid02_dev(sd); - struct i2c_client *client =3D bridge->i2c_client; - int ret =3D 0; - - dev_dbg(&client->dev, "%s : requested %d\n", __func__, enable); - - ret =3D enable ? mipid02_stream_enable(bridge) : - mipid02_stream_disable(bridge); - if (ret) - dev_err(&client->dev, "failed to stream %s (%d)\n", - enable ? "enable" : "disable", ret); - - return ret; -} - static const struct v4l2_mbus_framefmt default_fmt =3D { .code =3D MEDIA_BUS_FMT_SBGGR8_1X8, .field =3D V4L2_FIELD_NONE, @@ -642,13 +630,15 @@ static int mipid02_set_fmt(struct v4l2_subdev *sd, } =20 static const struct v4l2_subdev_video_ops mipid02_video_ops =3D { - .s_stream =3D mipid02_s_stream, + .s_stream =3D v4l2_subdev_s_stream_helper, }; =20 static const struct v4l2_subdev_pad_ops mipid02_pad_ops =3D { .enum_mbus_code =3D mipid02_enum_mbus_code, .get_fmt =3D v4l2_subdev_get_fmt, .set_fmt =3D mipid02_set_fmt, + .enable_streams =3D mipid02_enable_streams, + .disable_streams =3D mipid02_disable_streams, }; =20 static const struct v4l2_subdev_ops mipid02_subdev_ops =3D { @@ -694,6 +684,7 @@ static int mipid02_async_bound(struct v4l2_async_notifi= er *notifier, } =20 bridge->s_subdev =3D s_subdev; + bridge->s_subdev_pad_id =3D source_pad; =20 return 0; } --=20 2.25.1