From nobody Wed Nov 27 18:50:41 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 6D3731DEFF1; Tue, 8 Oct 2024 11:50:05 +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=1728388207; cv=none; b=Go/rILCVpMd6A/Mug4IPKWpOPtAiP2ZyflBmlRGPJndRVSpBIi1TdiiKcWEOS9qzcE0UkHfV8TKyZKuSxcMRXlwniV1gyJVlqL5kOcznNB/utNQpJD8e+U/GdbsM8e7vKuglyHRTB1LruDTQYkJpyIH0ZejoDL4Y0gVPdhEG9wc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388207; c=relaxed/simple; bh=uHCcsnQARIuwiUEcq+L18xIRwNPj1IHXtEZslZlqpP0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=QAX0ga17MPzyn6CZ1hZwqQi4qomtFV5zZQ8C7YDHGGorNLIBCAUd66rYo1E3dt708RQohAGS1oL/h4WNHIsXtDH66WPqPfOkCO+OMqeuszXQyHIgy1LYPm0YMrgIt5f1d8hvQLEPEG06LtljzCwvjK5t8qTgUhjKrtusLILlIdQ= 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=XD8Lo72y; 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="XD8Lo72y" Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 498B85O5010486; Tue, 8 Oct 2024 13:50:00 +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= ezNjJ416FrgMLBGxqqXBcKBs7f7037S7P18JphZTJM0=; b=XD8Lo72yvjBXQ7pJ 2PEcajwlVEM2xuEhvJy8/0ky9MZzSkJFuHoF2ubxVhzmm0jH4QJMrODdcg64dbeP g17dk0WF9OWoBy9XVuaWVSEBLAoqGCM8cCQsSFUnuwmCO2priVIv2WF2EkMLlduL YeuK2xE3L/V1UhqTBphp3oEoOJ4odrpdg2z0uedSCEsNupdGbPq7vqaaNcL61vz5 uVOu4NcL8nphbm6LDpZ9QCVT/oXSdx2NiEgXrXc9Q+eHnfh9lgqHeIMwbCFOZd5G 1TRGoutUty3S+KPk7iA/PJKEh1i2uQQHSb8juJZ6OLQSZAsmy8B8gCKmER3YelN1 TlGFQg== 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 422xs55ubq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 08 Oct 2024 13:50:00 +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 9515A4004B; 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 23DF426357F; 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:35 +0200 From: Alain Volmat Date: Tue, 8 Oct 2024 13:46:05 +0200 Subject: [PATCH 1/4] media: i2c: st-mipid02: fix mipid02_stream_enable error handling 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-1-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 Following addition of cascaded s_stream call within mipid02_stream_enable and mipid02_stream_disable, the mipid02_stream_enable error handling must be fixed to simply disable the clocks & data lanes without also calling again the s_stream of the source subdev. Moreover, main control registers are reset to 0 for all cases of error within the mipid02_stream_enable even if they haven't yet been written. Correct this behavior by simply returning an error when register clear are not necessary. Signed-off-by: Alain Volmat Reviewed-by: Benjamin Mugnier --- drivers/media/i2c/st-mipid02.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index b947a55281f0..bc637a651a22 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -480,7 +480,7 @@ static int mipid02_stream_enable(struct mipid02_dev *br= idge) int ret =3D -EINVAL; =20 if (!bridge->s_subdev) - goto error; + return ret; =20 memset(&bridge->r, 0, sizeof(bridge->r)); =20 @@ -490,13 +490,13 @@ static int mipid02_stream_enable(struct mipid02_dev *= bridge) /* build registers content */ ret =3D mipid02_configure_from_rx(bridge, fmt); if (ret) - goto error; + return ret; ret =3D mipid02_configure_from_tx(bridge); if (ret) - goto error; + return ret; ret =3D mipid02_configure_from_code(bridge, fmt); if (ret) - goto error; + return ret; =20 v4l2_subdev_unlock_state(state); =20 @@ -531,8 +531,10 @@ static int mipid02_stream_enable(struct mipid02_dev *b= ridge) return 0; =20 error: + cci_write(bridge->regmap, MIPID02_CLK_LANE_REG1, 0, &ret); + cci_write(bridge->regmap, MIPID02_DATA_LANE0_REG1, 0, &ret); + cci_write(bridge->regmap, MIPID02_DATA_LANE1_REG1, 0, &ret); dev_err(&client->dev, "failed to stream on %d", ret); - mipid02_stream_disable(bridge); =20 return ret; } --=20 2.25.1 From nobody Wed Nov 27 18:50:41 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 Reviewed-by: Benjamin Mugnier --- 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 From nobody Wed Nov 27 18:50:41 2024 Received: from mx08-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 BC22F1DE3C1; Tue, 8 Oct 2024 11:50:00 +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=1728388202; cv=none; b=UFCL9UyZt5+S97kbywpZuzQte4kSUWstVzkJ6gWIDlQ0feUMyemCj3DFTPYlobq5bbhGam9aOgx2q7A6ZpPDgRc4irkZoNKrbv7KdTjOKbAuj2qg7lhmcMAZ265rQpdMUMnX8pcABP2xEa2KkVZLuPgfiR6gn9XfjH3fR+XGjc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388202; c=relaxed/simple; bh=1CqIry95tyv+kn3op8ngGR3vg8HBawuT8sY+KxfDEoM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Vd8DigIpWkbQ0hF4bn853U9IuLc90hqjAU6FFAJO3dxzPgTtds1O6aydseVbLhxr0N+IeobMZBmcnU9ejVbgl3icS3+nigeXoVYcIxpWBvAMeL/q1Cj5ZcP7AqtNGT6/yxE0/5y/Vc1kAVRhoC/nXDOlQnduQl/VvU1qHKprZTc= 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=Z10/lSqO; 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="Z10/lSqO" Received: from pps.filterd (m0369457.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4987vp5D014980; 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= WTSg2agHV3N14FzR8O+U/92oSmSIzVerhwhnLxMBkrw=; b=Z10/lSqOA1St0BM9 FNxd/jLP/ZfXjKlelKBBC4td8Iw2lLNyR1S/3oTEfIp9hOHSygZkOshU2OnpppYU +yfSVLv6gX6vVVvMe/u6PCaEUxlee6HEW0uTS9D9NBdu6nnMlj2b2Ejj3UaCGoDZ VFjlY2UGT0hKTMQb+lM+wnXQY3Ct/GZNvLTiOwVPAi/pO5tzy66U3vfXO1+KiII3 Hm+Qi8qYJjbaIlk1Ady6LrRppJe9W6sF9Fdf04XVY69uj7Up6W0hNDK8DU3AiSFY cRxouLzon3Xk6QoAGLcGNkd8QWaeN/VBFwPnVNagCDuM87Palbwpw9sLPtRdrN5j kbZ7xg== 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 423gdmk1jr-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 9CBB54004D; 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 57C6626450B; Tue, 8 Oct 2024 13:46:37 +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:37 +0200 From: Alain Volmat Date: Tue, 8 Oct 2024 13:46:07 +0200 Subject: [PATCH 3/4] media: i2c: st-mipid02: add pm_runtime handling 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-3-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 handling of pm_runtime in order to control the supplies and clocks of the bridge. Signed-off-by: Alain Volmat Reviewed-by: Benjamin Mugnier --- drivers/media/i2c/st-mipid02.c | 49 ++++++++++++++++++++++++++++++++++++--= ---- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index 1821a8fdd618..635b8a433d63 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -249,8 +250,10 @@ static void mipid02_apply_reset(struct mipid02_dev *br= idge) usleep_range(5000, 10000); } =20 -static int mipid02_set_power_on(struct mipid02_dev *bridge) +static int mipid02_set_power_on(struct device *dev) { + struct v4l2_subdev *sd =3D dev_get_drvdata(dev); + struct mipid02_dev *bridge =3D to_mipid02_dev(sd); struct i2c_client *client =3D bridge->i2c_client; int ret; =20 @@ -283,10 +286,15 @@ static int mipid02_set_power_on(struct mipid02_dev *b= ridge) return ret; } =20 -static void mipid02_set_power_off(struct mipid02_dev *bridge) +static int mipid02_set_power_off(struct device *dev) { + struct v4l2_subdev *sd =3D dev_get_drvdata(dev); + struct mipid02_dev *bridge =3D to_mipid02_dev(sd); + regulator_bulk_disable(MIPID02_NUM_SUPPLIES, bridge->supplies); clk_disable_unprepare(bridge->xclk); + + return 0; } =20 static int mipid02_detect(struct mipid02_dev *bridge) @@ -470,6 +478,10 @@ static int mipid02_disable_streams(struct v4l2_subdev = *sd, cci_write(bridge->regmap, MIPID02_DATA_LANE1_REG1, 0, &ret); if (ret) goto error; + + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); + error: if (ret) dev_err(&client->dev, "failed to stream off %d", ret); @@ -504,6 +516,10 @@ static int mipid02_enable_streams(struct v4l2_subdev *= sd, if (ret) return ret; =20 + ret =3D pm_runtime_resume_and_get(&client->dev); + if (ret < 0) + return ret; + /* write mipi registers */ cci_write(bridge->regmap, MIPID02_CLK_LANE_REG1, bridge->r.clk_lane_reg1, &ret); @@ -539,8 +555,9 @@ static int mipid02_enable_streams(struct v4l2_subdev *s= d, cci_write(bridge->regmap, MIPID02_CLK_LANE_REG1, 0, &ret); cci_write(bridge->regmap, MIPID02_DATA_LANE0_REG1, 0, &ret); cci_write(bridge->regmap, MIPID02_DATA_LANE1_REG1, 0, &ret); - dev_err(&client->dev, "failed to stream on %d", ret); =20 + pm_runtime_mark_last_busy(&client->dev); + pm_runtime_put_autosuspend(&client->dev); return ret; } =20 @@ -868,7 +885,7 @@ static int mipid02_probe(struct i2c_client *client) } =20 /* enable clock, power and reset device if available */ - ret =3D mipid02_set_power_on(bridge); + ret =3D mipid02_set_power_on(&client->dev); if (ret) goto entity_cleanup; =20 @@ -890,6 +907,15 @@ static int mipid02_probe(struct i2c_client *client) goto power_off; } =20 + /* Enable runtime PM and turn off the device */ + pm_runtime_set_active(dev); + pm_runtime_get_noresume(&client->dev); + pm_runtime_enable(dev); + + pm_runtime_set_autosuspend_delay(&client->dev, 1000); + pm_runtime_use_autosuspend(&client->dev); + pm_runtime_put_autosuspend(&client->dev); + ret =3D v4l2_async_register_subdev(&bridge->sd); if (ret < 0) { dev_err(&client->dev, "v4l2_async_register_subdev failed %d", @@ -904,8 +930,10 @@ static int mipid02_probe(struct i2c_client *client) unregister_notifier: v4l2_async_nf_unregister(&bridge->notifier); v4l2_async_nf_cleanup(&bridge->notifier); + pm_runtime_disable(&client->dev); + pm_runtime_set_suspended(&client->dev); power_off: - mipid02_set_power_off(bridge); + mipid02_set_power_off(&client->dev); entity_cleanup: media_entity_cleanup(&bridge->sd.entity); =20 @@ -920,7 +948,11 @@ static void mipid02_remove(struct i2c_client *client) v4l2_async_nf_unregister(&bridge->notifier); v4l2_async_nf_cleanup(&bridge->notifier); v4l2_async_unregister_subdev(&bridge->sd); - mipid02_set_power_off(bridge); + + pm_runtime_disable(&client->dev); + if (!pm_runtime_status_suspended(&client->dev)) + mipid02_set_power_off(&client->dev); + pm_runtime_set_suspended(&client->dev); media_entity_cleanup(&bridge->sd.entity); } =20 @@ -930,10 +962,15 @@ static const struct of_device_id mipid02_dt_ids[] =3D= { }; MODULE_DEVICE_TABLE(of, mipid02_dt_ids); =20 +static const struct dev_pm_ops mipid02_pm_ops =3D { + RUNTIME_PM_OPS(mipid02_set_power_off, mipid02_set_power_on, NULL) +}; + static struct i2c_driver mipid02_i2c_driver =3D { .driver =3D { .name =3D "st-mipid02", .of_match_table =3D mipid02_dt_ids, + .pm =3D pm_ptr(&mipid02_pm_ops), }, .probe =3D mipid02_probe, .remove =3D mipid02_remove, --=20 2.25.1 From nobody Wed Nov 27 18:50:41 2024 Received: from mx07-00178001.pphosted.com (mx07-00178001.pphosted.com [185.132.182.106]) (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 790A61DE885; Tue, 8 Oct 2024 11:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.182.106 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388203; cv=none; b=kipxpbBclrxqLt4oMChpz2sFwt6TXtnHZ2aKpOOBjekyEltfp3fCBgaOoAeAn9ut0hH+2ggTRbowv0qaBd1fSmAJPy6blfGW/oEEvaDdyGx3p+oSJOOhU/cDMuTb7fkoGSbRx4iYmH8j1fWLvlDrExvMbBk7jlFXCQSK0XfUFzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728388203; c=relaxed/simple; bh=pZcmBcG9FLKU1llHOrmXLZfBhX2yPux5vJpR9zTp4E4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=HdVAMWUYOPPwptk6NSrLcimh9CvUSXixNxLQ9OwKRP2h60IJZbz0aCkAuUDu7kWSJzORiQIU2yCPUTt7Wzb9th55ygnRWxrAM2LmZExbVbpl2zWj5/MOl8T/e3MPeIFRvndAv5VexO6DIhV4NThjJkVuPi222NNsJPOYrWJN1v0= 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=ppaYkq35; arc=none smtp.client-ip=185.132.182.106 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="ppaYkq35" Received: from pps.filterd (m0288072.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4989AUt9017178; Tue, 8 Oct 2024 13:49:56 +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= Mnz/aGX3LHgwwUDqxrcB+OMCoex8kw2JOndT63O5sNk=; b=ppaYkq35pSVCCZOO ZX70CPTh+ekXk0cfAtiS5mxvyIsA8GOFSiYribiB+H1/5o7UGh+RuFfleUFljQ1h Q0BfGYJ5rgXjEV0NYRZocHzrrM2UneS3Xd0ZjH6ntuUas79awc5VeCIXADx7ne7m vzJd90ROddaj66ba72bMexPLeEtzauPkpug3Tf7FHH3vK4r+DYAiaHPCqCR6CAhu l7ZUH5qyFGyWnAiZ2GSD5MjEyFMGPnUmsGb83Gr1u2lYXuHnr4ucoCz9xfH3z6UR 3gAUQMezlzvf/wqtl77AKxGbYJGm/3EErneUBoGWFasEOF+b8PuXooeiWYQtRpBE PHphbw== 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 422xv7658w-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 A7D734004F; 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 EEED52649E9; Tue, 8 Oct 2024 13:46:37 +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:37 +0200 From: Alain Volmat Date: Tue, 8 Oct 2024 13:46:08 +0200 Subject: [PATCH 4/4] media: i2c: st-mipid02: remove parallel mbus format on sink pad 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-4-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 2X.. mbus formats are related to parallel interface and as such should not be acceptable on the sink pad of the bridge. Only keep their csi counterpart in 1X.. Signed-off-by: Alain Volmat Reviewed-by: Benjamin Mugnier --- drivers/media/i2c/st-mipid02.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index 635b8a433d63..f08db3cfe076 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -68,9 +68,6 @@ static const u32 mipid02_supported_fmt_codes[] =3D { MEDIA_BUS_FMT_YUYV8_1X16, MEDIA_BUS_FMT_YVYU8_1X16, MEDIA_BUS_FMT_UYVY8_1X16, MEDIA_BUS_FMT_VYUY8_1X16, MEDIA_BUS_FMT_RGB565_1X16, MEDIA_BUS_FMT_BGR888_1X24, - MEDIA_BUS_FMT_RGB565_2X8_LE, MEDIA_BUS_FMT_RGB565_2X8_BE, - MEDIA_BUS_FMT_YUYV8_2X8, MEDIA_BUS_FMT_YVYU8_2X8, - MEDIA_BUS_FMT_UYVY8_2X8, MEDIA_BUS_FMT_VYUY8_2X8, MEDIA_BUS_FMT_Y8_1X8, MEDIA_BUS_FMT_JPEG_1X8 }; =20 @@ -140,12 +137,6 @@ static int bpp_from_code(__u32 code) case MEDIA_BUS_FMT_UYVY8_1X16: case MEDIA_BUS_FMT_VYUY8_1X16: case MEDIA_BUS_FMT_RGB565_1X16: - case MEDIA_BUS_FMT_YUYV8_2X8: - case MEDIA_BUS_FMT_YVYU8_2X8: - case MEDIA_BUS_FMT_UYVY8_2X8: - case MEDIA_BUS_FMT_VYUY8_2X8: - case MEDIA_BUS_FMT_RGB565_2X8_LE: - case MEDIA_BUS_FMT_RGB565_2X8_BE: return 16; case MEDIA_BUS_FMT_BGR888_1X24: return 24; @@ -177,16 +168,10 @@ static u8 data_type_from_code(__u32 code) case MEDIA_BUS_FMT_YVYU8_1X16: case MEDIA_BUS_FMT_UYVY8_1X16: case MEDIA_BUS_FMT_VYUY8_1X16: - case MEDIA_BUS_FMT_YUYV8_2X8: - case MEDIA_BUS_FMT_YVYU8_2X8: - case MEDIA_BUS_FMT_UYVY8_2X8: - case MEDIA_BUS_FMT_VYUY8_2X8: return MIPI_CSI2_DT_YUV422_8B; case MEDIA_BUS_FMT_BGR888_1X24: return MIPI_CSI2_DT_RGB888; case MEDIA_BUS_FMT_RGB565_1X16: - case MEDIA_BUS_FMT_RGB565_2X8_LE: - case MEDIA_BUS_FMT_RGB565_2X8_BE: return MIPI_CSI2_DT_RGB565; default: return 0; --=20 2.25.1