From nobody Tue Nov 24 11:35:56 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795466051; b=Q6NkY/ROFqB27ySZA4ID7m7qSh0nNbgP8htRLDALTt0GtaCr9I3T2BZsgwRKhhiDGFfV mePFlUfkzO8v0ZAf83qUCfN3wr1BeqWbDnlC5pegJoxv5ZbjkXSNdYbkLzRyXRs22jgws tT/P+pnZvA4cG/LKHRWeMuKCKRKtHYfld41EkKs8X/2gB0KdROCvnbdVj+wkY1T+0sY82 RDhrODsCldMj7L8nYPeCAYXkBy8vKPnCUUlItAfs20F+O9DbSgOOa9UUcKMbjJo8R1yNl TabTSW3LTfrAfH0ZFSmCN+9glOcxLyjaMj3tZVpzSzLkgzOi/8c/Py/S7XV6p+kAWaA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795466051; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=aIw52i3FBNaM3JlX95PdSZS9UEeuj75BOGnG58YJQCs=; b=L/HnotMhostWuMNQYFEGODENP/vYeGB3nc869l0MgyMH+TJUcmVBFDBdbonyhGaZbyLE hdGwvLp2o0kxkqp2BNfFy6y3YJi2FbqyScnQwyOBAashe11E/JHC0GtAzXDKOWJh80kGa bsYxLkfVacARuKnYqDtEpzyoboRBY4lssSfsI4NSa31xLbI5CegQwg7PnHcY2P1InzeEW ilnpqwcqYpk36vtCaKchhCni9iE6VwuokslT/J1qrHGXK4rw5TTY+bBjYJzYIsXAqKkmP ZyvA3qqMhHSctg6IkeGCGQV1eOR8ngu0IIyWaH46Uq3lk0TcfQeilJFZ1U0O5zVPIuw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aIdd2c40; arc=none smtp.remote-ip=209.85.128.45 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A89E606A33A for ; Mon, 23 Nov 2026 20:34:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6A89E606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=aIdd2c40 Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4a3517554f7so35171395e9.2 for ; Mon, 23 Nov 2026 12:34:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795466050; x=1796070850; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=aIw52i3FBNaM3JlX95PdSZS9UEeuj75BOGnG58YJQCs=; b=aIdd2c40s7v7UqrYtMn/jdUeRjG7uf8VxYLfXRlPixAm9l4+qo6Zry/e6kW5iGuQXM 4/4QjacbUa4z6jrFzYieNIM7FCZYdR5wA0z1BdcOXepZG+ucsqAktjaO4/HLL4LowQHL pWwSA/9NXB6tx3Muc4nGbSrho2WWMRPvv7tGDpOO86m6ixO7BgKtDgcdPGcK1iTp33OF P2RLNpMUhxb9Gyng/a2C6ur7+sxnjgVZvD1s0pvNxm7fBq/XCKdduImgG0m6BNW34Rxa 7i7bTPnLoc0cuzhpnbEz4wD1Wmm6q3whg+F1cgcb2EbpIzVh16l8mf4QVQOpu306DGtM 9mWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795466050; x=1796070850; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=aIw52i3FBNaM3JlX95PdSZS9UEeuj75BOGnG58YJQCs=; b=HxT+PET8XRV1B8GwnJvGRQvulzUUDjId9dSlOxjLpuLDVBzbCgStzHlpfYqyb35Vb2 7PZ8g4QN+xRL5OA2vj1fpMfcdxvuw7TwLxDex6EjcK50yn1x6ySwmNkJ2C/OFDe6jsqE AAvon933XnLHYPQJ3E0Ji45zt6jHpVg8I+Df3euDTjap7x6cMB0+E2YL5MIwwSZOtDSy H4A5mtGmp/dKtyHAu9eaJNa8IVhs1TmUoloz33OagRLoTrp/4DshJmj70JTKKqVystHy EdgdljWKlRNk7uPaU8WUxTU+xXqLqXOFIw86PDpSDkv6EPQ+aYx5egIsSqnhJCXrpa8d E6kQ== X-Forwarded-Encrypted: i=1; AL+hErEvzfDicbCxz4RCOTqfdwVwfs+8qIL0kAPFKEsMXTqXu9nuOGr4TZokcKH6f9F+P8afb3P3deV1kWlz5w8=@vger.kernel.org X-Gm-Message-State: APuU4Z8EHhmcTMLez8H3yT/NUAFU7/y/RozRuABj+mZ0sqaTf5zUBfOS 6BO8EK6S03cHIp4Ir36IM3Es9N28ly3HPlyyPyMX+KDZkG7d77GR/dvS X-Gm-Gg: AZFdTZfhqjv9RWPoNf3Lb89lQvDbTAkTIE/OTJo4r5RsTeKpFzDsqakljkfiyPu+dPp HCU+/cHTHufToqvUB6Y+3AUFs+5xaCdb36z9uDd1B5YWRfRjqd0vFWwgssoU7DRzU26woPmckzz c8vjNc0FWKsZBuceZIvszK+jpq6S7Mxf3YZnkcyJtFoRo7iIlN0XHapYz1neCyqLvpxtItFmS98 s81HgxVVB24yEv9iv4/2XvWQIEvL6h7wG0YlipXpyds+vqoce+Jwo+LBS8A+KreDoJHtdn5BvWH G/vLRp2Jfaj/91nYlpEhiJsTxJccfwXOs+0v3G/2UOYDWlznuoLhy78+o3+fbNoA/1SCdhxKb/G wBYyWyo4gUIVkZu8EoIY0Blqxm3OlvSwrhMyDh7OGDWd34jKX97mtmmFMD6Y5ubVROq6gI/ciVf JI3sTENalyde77rFFCQIZlVKBGjmGAHKj/VEEagsP6Qvaa5TtpDhZkfy4fYSEqpCwI1Aqv/8nXO zQej8kU4ow9TtTpr3ZtX1aEjWo1sFfb5YVKPoqEADJ8rT+JbZVJMU69g5WtNKWn3FxsoU4Yv4lv mevJbFzUQWTFIxkGDnZCDEvMIx7dfEWPrfRbGfY3u1TeUw6rtws= X-Received: by 2002:a05:600c:37c9:b0:4a6:eca1:7d5c with SMTP id 5b1f17b1804b1-4bb888251b4mr232152425e9.32.1795466049774; Mon, 23 Nov 2026 12:34:09 -0800 (PST) Received: from unknown.local ([151.34.53.154]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm515946805e9.13.2026.11.23.12.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 12:34:09 -0800 (PST) From: Gianluca Boiano Date: Mon, 23 Nov 2026 21:33:53 +0100 Subject: [PATCH 1/5] media: qcom: camss: Don't stream sub-devices upstream of the sensor X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-b4-ccs-imx376-v1-1-2b26850a6f11@gmail.com> References: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> In-Reply-To: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, David Heidelberg , Gianluca Boiano X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795466045; l=3624; i=morf3089@gmail.com; s=20240402; h=from:subject:message-id; bh=0Cz0qn0VW15LMMWXLllItkJYlosLYSu3ppAkBWYN+0E=; b=TYQR3uZ0JKNjjuCaIe/VTJRQvP3xRFLWYplEX4zBGUU1wNIBU22W0RXaFbVTKX689Platxtbd SSsPUfocmrCDCd0Et1KHBXKfdNGLdxFoh+XhRydbOr2NydckOtFuRjh X-Developer-Key: i=morf3089@gmail.com; a=ed25519; pk=HsGrEQ3ia8BGGGO8/nUM2K2UX9JKvRPV+nbrVDGrYhA= video_start_streaming() and video_stop_streaming() walk the media pipeline from the video node upstream and call s_stream on every sub-device they find, including every sub-device behind the one that is linked to the CSIPHY. That is fine for a sensor that is a single sub-device, but a sensor that consists of several sub-devices gets s_stream called on each of them, not just on the one that is linked to the CSIPHY. The MIPI CCS driver is such a sensor: it exposes a pixel array, a binner and a scaler sub-device, and the scaler (or the binner when there is no scaler) is the one linked to the CSIPHY. Streaming is started by that sub-device and covers the whole sensor. Calling s_stream also on the binner and on the pixel array is at best redundant and, as the CCS enable_streams operation only accepts the sensor's source pad, makes the pixel array fail with -EINVAL, so streaming cannot be started. This is not specific to CCS. Other drivers that have a sensor on one end of a pipeline, e.g. ipu3-cio2, rkisp1, ti-cal, ipu6 and rcar-vin, start only the sub-device that is directly connected to them and leave propagating the start request upstream to that sub-device. Do the same in CAMSS: after the first sub-device that is not part of CAMSS (i.e. the one that was bound by the async notifier, which is the one whose host private data points to the CSIPHY), stop walking the pipeline. Signed-off-by: Gianluca Boiano --- drivers/media/platform/qcom/camss/camss-video.c | 28 +++++++++++++++++++++= ++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/medi= a/platform/qcom/camss/camss-video.c index 0852eb6f1315..71ca16f15dab 100644 --- a/drivers/media/platform/qcom/camss/camss-video.c +++ b/drivers/media/platform/qcom/camss/camss-video.c @@ -249,6 +249,28 @@ static int video_prepare_streaming(struct vb2_queue *q) return ret; } =20 +/* + * video_subdev_is_external - Check if a pipeline sub-device is not part o= f CAMSS + * @subdev: Sub-device in the pipeline + * + * camss_subdev_notifier_bound() sets the host private data of every exter= nal + * sub-device it binds, i.e. the one that is linked to a CSIPHY, to the CS= IPHY. + * CAMSS sub-devices never have it set. + * + * Streaming is controlled from the video node, one CAMSS sub-device at a = time. + * The external sub-device is the end of that chain: the pipeline upstream= of it + * is not CAMSS' business, and the sub-device is responsible for starting = and + * stopping whatever else it is made of. Sensors that consist of several + * sub-devices, such as MIPI CCS ones, are not expected to be controlled + * separately for each of them. + * + * Return true if @subdev is not a CAMSS sub-device. + */ +static bool video_subdev_is_external(struct v4l2_subdev *subdev) +{ + return v4l2_get_subdev_hostdata(subdev); +} + static int video_start_streaming(struct vb2_queue *q, unsigned int count) { struct camss_video *video =3D vb2_get_drv_priv(q); @@ -284,6 +306,9 @@ static int video_start_streaming(struct vb2_queue *q, u= nsigned int count) ret =3D v4l2_subdev_call(subdev, video, s_stream, 1); if (ret < 0 && ret !=3D -ENOIOCTLCMD) goto error; + + if (video_subdev_is_external(subdev)) + break; } =20 return 0; @@ -325,6 +350,9 @@ static void video_stop_streaming(struct vb2_queue *q) dev_err(video->camss->dev, "Video pipeline stop failed: %d\n", ret); return; } + + if (video_subdev_is_external(subdev)) + break; } =20 video_device_pipeline_stop(vdev); --=20 2.56.1 From nobody Tue Nov 24 11:35:56 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795466053; b=vxGQBiEpjsuCoMOkZgadApjFOUKuYkQ8eDeiLIvBaybKuwlrFWl/mk2cGbOCdyBroKZN KHcVf9EnCtmVQxa+3T0nXECCwlg/zngIB5l1zwnuWP44RSacP6ee/TAA1nwjlFUMm8EgG h5mR/jcT9oojXcB1MYfXuVvvgbdmIKtf4gbeqgbIBqVbIVK/8bJ8/zlqtLePcmrhurIf6 z9082Mn/oLdOQTrDCQ7BpRirwoMze8GRyzwFhTqf03OFBKt9Bg3Bm/upGfal83325VCg/ e8bJr+se2ry3dtdg/DVRqAbEe13qct4RDp2qdVx6aWOzmWKnbHnH1VBg2vT3OtDlsNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795466053; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=veXzAwmEVfaxeQ226TGV88z3qOLGC1lncdwhds4Uw+A=; b=L7eSloy1Iz/cdbRaZtyX2OCetBLbmnyZE5BGpegki44pwYyyIl36MzdCzx2TRdtCbbcL uk8//tUWPBi6fLFmMNlqXIv5PYlxjDZawkpBazaYCYF0sFi96D2UbVxsTz56VZxc8sioh djl3WKyJ4q/ZQvDQ9nZEqIZ8EM1l+he2fpkTVgs8dWUwPsSBbV96i8Kg5Y336zi+dAoRu o5BxhYohh3qJCVZSD9CSGbC0JXBvHA/btbYbZsshDwX0MR7kxMlnXkwUcxo8c2M8W0F+X iXIA+8mj212dlOttW5aMKBMbip8j1tSuarTXiEf86JzdURIqFbwf9te7wG6ZpVlkYUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=j9Lonnad; arc=none smtp.remote-ip=209.85.128.51 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFAAD606A69B for ; Mon, 23 Nov 2026 20:34:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DFAAD606A69B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=j9Lonnad Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-4a35d5d4a20so37039985e9.2 for ; Mon, 23 Nov 2026 12:34:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795466051; x=1796070851; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=veXzAwmEVfaxeQ226TGV88z3qOLGC1lncdwhds4Uw+A=; b=j9LonnadtBhcTf4uh0U0BZsh53ugsoPcyeMsAx4M8zEVoUIQZWgx4sd536/f4ke42W lzpj1Ltt/hVcEt2NDsDcjBsjhL6TXdtnvHQMM6vxeTXSbmsmCnrbv9f2vKNLe2soN22A xBSpTQBvE0IWZwTBwqSReay0ZHWtXtnruWfGeur0k1HgM0c5idG2KW8x5QJpC4dNUx2D nLCHdA9w2UntGxU/xuBNR/F2HFG3eohxP+9a9N1MJF6/6vo9XkTN+coK4w3WIriaiLOu pPkMuVQgWIesEeKg7fWMjPwkWRDjfxCg5grGIMotONuHmg050PYWgRr4AFL7LyhxCeFn Pc5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795466051; x=1796070851; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=veXzAwmEVfaxeQ226TGV88z3qOLGC1lncdwhds4Uw+A=; b=Iy6Zovy0W4JzRPYTS2Oxj53w3wCILirwPxUw0TdkuDtWQjHawZ9431m5FWvLYmva77 6br/q8aRrSKEZfPItfRYqW+udEcHuYNG2iskl/UrDIaPZ4AVvVsiueKpjfJzLmJZCmlQ ob/GM2An/C4Ur4MHS4OBFIdX9RLf0g2prsWjw1JSwk9l5dudSTtQWsZOrC9jXyhEP9CK lIMKsn8syLIIP0TJTE/lf5hNqqCxhuI6yFeD41lkJTfBYuQB8jNjJJaSYczvNSWxgHA1 l5dyC/CeZk9DpfW6GZDg9vl9pEZkx9087p6SjoZDcBQX9FGtSjphEGnic93GQ1HXqhtN kgKg== X-Forwarded-Encrypted: i=1; AL+hErHNlKpziZvGjVfngyoskAouEHDs1zd9p5Dp8kQKdp+lvwigNsdxmY2TAxBjDRa7IWmao9V5EdnE4+QOfL0=@vger.kernel.org X-Gm-Message-State: APuU4Z91HExwAsEHmibUtp8AadjcFJFDcoYnwDiXqjj0j0lMGTtE9g6G 7gT284A0HktidCOBU/64JKROrHXOIvIbPPycPsz7p5wpNWX0URIlNrw4 X-Gm-Gg: AZFdTZfqOd9X2+w0XIlQGDflxbKrys1FPe7Th8xi2fbSjzJg/WKSLuicTbj6LZ8EIL5 ZTGv1fW2iNTmXvjiiJ/xOW7qo5oAlvO+3C8KEU8i5mPoJ6a0QHGLsOCNaVcVKaznv7PZNmr2AUf 771TFWL0q8TmYqyTalOUY/wlFP+0/vDLt4SfqFvA+zZRY2Qd143rXi50Ul9jqIQfdz/Vm+onahp IG1m0d0G/7ArJ+hUBcqlW7iZHCKjw5Z4bGyWadsj2zts0rucV5xQt+lOsZhZcDRv6LbzwGmnFDl K3ufR9lBeY+uhyr0UJFZzW/qfWlrDhkzCCe7OkL20EXYuI9xJiEXWcwmOtlfdHCqWzWzcUYONQN yIWlRMi7pKO4jVND7MqsMBFyEa9x0OvRcVNJ17ZGFEgpI1y9ybX4oL13mI15GT+Ce2I2Y1qwPkD BcrW9rBajk7KF0zzZWkGaobvP6/edmZiws6iupurnGvRf3zxY6ooFRHz8imErZAVKip2crGnFhM VfeBjuGcGcIB0IgioXmAqth45YEWH61a8snjdLYLeCEr/8SD7pgP1n+i9FEKtn+w2qaCjNHrXHd lu0GBoVBeBXKRMhmZYDISK4ffpyE3d1vOv1GAE3E/c/io2QSBVk= X-Received: by 2002:a05:600c:1548:b0:4a3:5aea:21e5 with SMTP id 5b1f17b1804b1-4bb887fe7e0mr275033015e9.9.1795466051182; Mon, 23 Nov 2026 12:34:11 -0800 (PST) Received: from unknown.local ([151.34.53.154]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm515946805e9.13.2026.11.23.12.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 12:34:10 -0800 (PST) From: Gianluca Boiano Date: Mon, 23 Nov 2026 21:33:54 +0100 Subject: [PATCH 2/5] media: qcom: camss: Look up link frequency from the sub-device on the CSI-2 link X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-b4-ccs-imx376-v1-2-2b26850a6f11@gmail.com> References: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> In-Reply-To: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, David Heidelberg , Gianluca Boiano X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795466045; l=2505; i=morf3089@gmail.com; s=20240402; h=from:subject:message-id; bh=SE9OTwNvO9+JP6HZCDsYQZuthYLCpe7RvJgDUw4zQ8k=; b=hp2zuUZq1Czsv84vJJBNUjKi1nRxNsBpPpdGFETpRZzJgomrKPLSiFPYImHQcAeT+XcHEeqRD dUfY47p4cu+CtXJ/2yK8asGvU6efWWj6ePDXG3u1MfbzlagG0IgUUpw X-Developer-Key: i=morf3089@gmail.com; a=ed25519; pk=HsGrEQ3ia8BGGGO8/nUM2K2UX9JKvRPV+nbrVDGrYhA= camss_find_sensor_pad() returns the pad of the first sub-device found upstream of the CSIPHY that has the MEDIA_ENT_F_CAM_SENSOR function. This is the pixel array for a sensor that consists of several sub-devices, such as a MIPI CCS one, and the link frequency and the pixel rate are then looked up from the controls of the pixel array. The pixel array does not have a link frequency control, and the pixel rate it has is the rate at which pixels are read out from the array, not the one on the CSI-2 bus. The link frequency used for the CSIPHY clock and the settle count and the pixel clock used for the VFE clock rate are then derived from the wrong rate. On Sony IMX376 that is 800 MHz instead of 400 MHz at a 500 MHz link frequency, and the kernel warns: v4l2_get_link_freq_ctrl: Link frequency estimated using pixel rate: result might be inaccurate The controls describing the CSI-2 bus (V4L2_CID_LINK_FREQ and the CSI-2 V4L2_CID_PIXEL_RATE) are those of the sub-device that transmits on the bus, i.e. the one that CAMSS has bound. Return the pad of that sub-device instead, as the other CSI-2 receiver drivers do. For a sensor consisting of a single sub-device the result is the same. Signed-off-by: Gianluca Boiano --- drivers/media/platform/qcom/camss/camss.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/plat= form/qcom/camss/camss.c index c54185c93a8a..cf86bf04dfe7 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -4513,6 +4513,10 @@ void camss_disable_clocks(int nclocks, struct camss_= clock *clock) * camss_find_sensor_pad - Find the media pad via which the sensor is link= ed * @entity: Media entity to start searching from * + * The sensor pad is the source pad of the sub-device bound to CAMSS, i.e.= the + * one that transmits on the CSI-2 bus. For a sensor made of several sub-d= evices + * this is not necessarily the pad of the pixel array. + * * Return a pointer to sensor media pad or NULL if not found */ struct media_pad *camss_find_sensor_pad(struct media_entity *entity) @@ -4530,7 +4534,7 @@ struct media_pad *camss_find_sensor_pad(struct media_= entity *entity) =20 entity =3D pad->entity; =20 - if (entity->function =3D=3D MEDIA_ENT_F_CAM_SENSOR) + if (v4l2_get_subdev_hostdata(media_entity_to_v4l2_subdev(entity))) return pad; } } --=20 2.56.1 From nobody Tue Nov 24 11:35:56 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.45 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795466054; b=FqxiRLUBbLzheZPVGGZM7EQF3+s1qz6x0GM4g0Y/TrBYnVuXzhTxObl+5D8LAgImYzP7 FuwvSVIsLGkSLAZknzQuwtkoGce90ey4+QFml8BM2mGlThJcL1cm1sDmZ4XC6n2Jj9I99 NZf6j0EIL1Gzn7c96Z31340QaB1UQQ+P3vK1pTBrDdw8wOo0qBcX7P7e+njVDmUbsP4Zi y4u06vAroMfBhhj1OLGWLzPQBeqgx782BnONpxv8hRY15lV8xAhaMVnI296yNnxuCESQX Qu4n8LDdstE1+TNEcgfcBw+Dm2yrBuXDXNTbohZY9gUZ9RLicAR0K5/9vJb/kHFNS9w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795466054; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=6OR603YV4U0OwPPTqnIgdhTgPtFX3ZXpQfBjAD1u2oU=; b=nprKaCIqf2TIfMIDTOThR6F8WrUgGS7kVJZNCLHtG17aKCH4HTUFa9Yb37sEGkvqDKGT mOFDM6QcMxbbBIZLEM2Qrpgl+8flPx0HitL+PVMHYw95YiIUkvyM9X0o5GwI7r8CnofWC lq0KEJxZYNtgh1m18x/tgaiZhqsb8Rws1cbHOupZ/vkxI9gqdHqzw5EoqVwhUM6AZgaYN ik8ObI6cnf5tZY5ch91E5wRxVIbhrEP3f6sSlulr+uq1oCFv2GT85X0Tb/O1IDKeevvKU C7Cvqz8rxN9860YjJRTYVh/QdJe8XCTkIk/54ltoRcc0OtY5fpOfOBrNFDJwPhvfPNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Z8KvwE2H; arc=none smtp.remote-ip=209.85.128.45 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50A88606A6B7 for ; Mon, 23 Nov 2026 20:34:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 50A88606A6B7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Z8KvwE2H Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-4bb55cda775so24029885e9.0 for ; Mon, 23 Nov 2026 12:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795466053; x=1796070853; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=6OR603YV4U0OwPPTqnIgdhTgPtFX3ZXpQfBjAD1u2oU=; b=Z8KvwE2HmbcjiuKTw78Oy+YNYHN8GNMgYBZwyBWDc/CS0fSAzLEia6d20eoogHK0Hn vOuMZc1tGZkHl7DRiiN+t3bG2IFgC252SnyjViZZKXxG9fRFGcYKfrBO+gk8UHSk3PWe S4iem9nIFGhaqX9NQ4Js9uiYZ1+inGXClZv/XXVbBl4Y69Qr784kcrIcx08WVIOgzljm plrZjF8lPFXblMkh0/Wvq2uMJQ9p88D/hQep5TZFnT808MyazsF/ICLskauneupXUkER 9bkaRo6Qx+GEcxY/itzEn9R2ug2yuZuI5MRf0EGq41C1Fta/MjuipuTd+qCOu4na/voY H/Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795466053; x=1796070853; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=6OR603YV4U0OwPPTqnIgdhTgPtFX3ZXpQfBjAD1u2oU=; b=AckwrEOceL46qi+W8lwgKrkxN3gBtuWAEQRt5JXGPJdZGOf4C2rsCelOoJcjZO3wNA FKBh7+G6G3xRDWyWzoSN2URhUK5l/wjgFccco7TMu+75EgUaUQrBq/RlLaqwQzbxVSoY G/QSlY/nz8nwn75NZ3OGlq4oaf5p7Pr3Kr5cJWQY46BDoRhOGaTajCcEZ9VDzlgOiQLt WTwXrzYp/c0XtINASZNGWp2B7bBdyv1VhXE3qogFA/IyiwPkYGTo76bys8lY5ONNN4MH uoid1CVROcIkn7jrCw+BkFFxZamkN7ZInvafSBrEehVaR4j/q/jxHp6dk8/UecyQPfJ/ RT+g== X-Forwarded-Encrypted: i=1; AL+hErF/v4IbG1kg1i2KH/brAEzgeJmdq0nHtPvoeLRp7E1TlkJ9MQvnQUdgjbdcCa4RJ4jKN1ZLqAUjEZH6yro=@vger.kernel.org X-Gm-Message-State: APuU4Z+K88NpGSd7MGidW8985l8fkfBPNTgXPnW525kal/KAvnwxMloF kjmP7WBpWM9yZIg8dJaJ1DzWxuQmETCZdtpHfqaSLyz6lmNufc3ZpG4p X-Gm-Gg: AZFdTZfKQ/ghShahAyyq+hsNCDyNTEB/jM3WzGZBX2F3qEjbUgvsL1uYWTKDXrhMaYx cL0cPaWbIdD0kdA6A7h3//1H9yFyhah8FkmLZEWTw54KIHHYnC9MlSPzVb8TZ8CLJ5kYtLJW9Ry uu8RBCzqX+Z4NP8YdPyalRTu4bKiXQNXIRXf6wSZ3JpAhsJkjqDmOTSh6l4QMy/fVJQ5K1wV670 z9Tbq815mjxl+8ADZ80pDVpQnY9xlzopBpyokFVZNZ9ifwNSfhTPR+kK66e4K50FekAwVO6E5sr XL5TWeOUNBi8mG7rdEFirg749FoUx7bto7pNIFwouLKWIrzcoTs7Lf09UrzIA7X83pbwIXD0GT8 eqn4NFjMSwIMVQuTUOCiMuHjLOA2jD8y2A/TdSudhRQRfs4iwbh/6KhDTty1kL0BWwQ5+my7Z0o uwTSPWNsxdhEhzigWSJUacB8e1KmNuZySdbWuC7+B4Q2zur8IGLxlMYNdyCvKX+f2nlMDsEiDFz WZ2Rbd4r97m8xqciLzcWhqmQxOGY3wcwOOnllrbxYqeS9w+jN0qBSVSfy/OsGSv/TM9EyyyuYJ7 q3GrUXblqL7DewqlGzFpYqv/jmGZlA== X-Received: by 2002:a05:600c:1d09:b0:4bb:66fd:ad68 with SMTP id 5b1f17b1804b1-4bb888160cdmr275019355e9.14.1795466052668; Mon, 23 Nov 2026 12:34:12 -0800 (PST) Received: from unknown.local ([151.34.53.154]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm515946805e9.13.2026.11.23.12.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 12:34:12 -0800 (PST) From: Gianluca Boiano Date: Mon, 23 Nov 2026 21:33:55 +0100 Subject: [PATCH 3/5] media: ccs: Store the format set on a sink pad X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-b4-ccs-imx376-v1-3-2b26850a6f11@gmail.com> References: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> In-Reply-To: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, David Heidelberg , stable@vger.kernel.org, Gianluca Boiano X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795466045; l=1782; i=morf3089@gmail.com; s=20240402; h=from:subject:message-id; bh=4SRiFW3bBAJ1IlBIN9DDyNFw3BbzT3m+KdYlz1JrA0Y=; b=l6DYb4OFrWa8aj8hDAV/Ql3Ppfpp3sLbxSS9XESSX/YP2O41q74bDTNHZvj54ZnsZPqr/xJx3 rqMTCmBBAI2BQpjfkeyJakYJMMHHDCYCa1+p9Lfedm9CmP0aFocujWP X-Developer-Key: i=morf3089@gmail.com; a=ed25519; pk=HsGrEQ3ia8BGGGO8/nUM2K2UX9JKvRPV+nbrVDGrYhA= Setting the format on the sink pad of the binner or the scaler only updated the crop and compose rectangles of the sub-device and its source pad, the format itself was never stored in the sub-device state. Reading the format back returned the one set up by ccs_init_state(), i.e. the size of the pixel array, and the selection rectangles, which depend on the size of the sink pad format, were bounded by it. Link validation then fails with -EPIPE for any readout mode that does not output the full pixel array: the scaler's sink pad format is the pixel array size whereas the binner's source pad format is the binned size, and there is no way to make the two match from user space since setting the sink format has no effect. Before the sub-device active state was used, the active sink format was stored in struct ccs_subdev (sink_fmt) in ccs_set_format(). The switch to the sub-device state dropped storing it. Store it in the state again. Fixes: d8bca3ed1d70 ("media: ccs: Use sub-device active state") Cc: stable@vger.kernel.org Signed-off-by: Gianluca Boiano --- drivers/media/i2c/ccs/ccs-core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-c= ore.c index 1cc4350856fd..a4af27de5453 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2275,6 +2275,9 @@ static int ccs_set_format(struct v4l2_subdev *subdev, CCS_LIM(sensor, MIN_Y_OUTPUT_SIZE), CCS_LIM(sensor, MAX_Y_OUTPUT_SIZE)); =20 + *v4l2_subdev_state_get_format(sd_state, ssd->sink_pad, + CCS_STREAM_PIXEL) =3D fmt->format; + crop =3D v4l2_subdev_state_get_crop(sd_state, ssd->sink_pad, CCS_STREAM_PIXEL); =20 --=20 2.56.1 From nobody Tue Nov 24 11:35:56 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795466056; b=lv5qJSW1f+ar4F2JkE2p4sZvzl7d9wl6zJ7ofx2w30BRzYjGJvl1CFHpzDEJhE4X9BbA rrB9Iqf853kex6x8OOB8vk0kKVwzSYpstlI3jnw3kFVzBDBRX8msT6U87X5kkVqXM/sQ5 ZHtIGb5i8V8ZlZev8tqMHGeHIeTEH4mjL9B+7wsksnx3vp1q/swtPleCf9lhxT37ZAABV CudBG6n1Y5OHL5LOvQ6N+KKXnFuuUSGOuPUJHaT/ZM8G0i6TdQrugFb+f37zNkXyYuZOJ kD8IrxXgJYjmdsP+BX9yrDWnnmm23Fh65gAzbsCssLsoJ+bK+GLBnalrTqVyIiHwieQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795466056; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=jmJspXYhqF5Ifm6vBoYFDWnnVcY5oxgK5Qh3Vesxuh0=; b=5tDrsKIdlhHOrl6HE0bx8MVR+oiIecngjxdjIe6MO2Iy5gSbIIrJAs57MDIt1p9r/6qH KasLr8LO74mBHWXtuY1bhOM/R7/D+Lq8zFttwrUJ8eNPKRZBHB+TLuAF9yg7R1GqToxlH +IdasUG+K2EHdmLiK1IbAw0yc5GGpwn1c9Sx8FETLdSDZA/1W6wxnXO1TB7gCVuzolmiA pyOcg+YvG5dIRMycMCOwX7DEDsplbG8ywRvCBHQdTv1J/LOyJ3FWRFXqpB+CuIk5+qzxf zvHPcUXXsrQ1+tGGrT4rsBeRX00L00eJQj/+o8Nmg3P8Eeex0Msyb5TEPgfcinNpirw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eqHfWJa9; arc=none smtp.remote-ip=209.85.128.48 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A3148606A6B5 for ; Mon, 23 Nov 2026 20:34:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A3148606A6B5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=eqHfWJa9 Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4bb68c197c7so47668955e9.1 for ; Mon, 23 Nov 2026 12:34:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795466054; x=1796070854; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=jmJspXYhqF5Ifm6vBoYFDWnnVcY5oxgK5Qh3Vesxuh0=; b=eqHfWJa9Wea/Fb3/RD4KYoNZlniZ37XLDzgSuVOIwm9447N4+odJLiA9+zkUe8O7X8 pK0pzNZwfoFcU2dNJid5h6+dBt/TBAwVz5J5T6E+Boe72nNC8S/RYIm3Egeli4/IEMgA kMjdkocnsr/jvd8VxembzJJFNYf+KCwWAEdQP5wt6SiDf20JnQi1dTcd+XnXb/P19sdj mlD2MvXC8CBGvpHU3jm2kIMGANo69DZbATy6WMiPUyFHx4o6VMlPn0bU5asxKS4JoHHh SRDGprAGom/o6GTtJv7uVF3N3HmCr5Me8w2SGAictAeM4pxXxdh5NZwEa1Iqxd1MlJ5A eZ6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795466054; x=1796070854; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=jmJspXYhqF5Ifm6vBoYFDWnnVcY5oxgK5Qh3Vesxuh0=; b=VEk09YUmf9W3cACSq8O8QBtmuvGJHiKusb5dCKLZ6Rbl72TyUdB1ZzfJu1BJdnWNUs nWM1dV9UiNFhUZ8LJGoXyupWjXNP8dG4LyxfZCrlQSOLOFa0L2JhFfC7i79aE9aFP6ue 66BPdSn3t2waB+4YuP/qEYBE8QurObvyfbwD7G/YCgGPHl/IlS1dWNkRan4h0JpLUi5u 8zOhGVTeLwkbQAkmWSGxfl+p02COGgNbnH/hvEgJndbk/MKv3LlIU30xquoKVA5RDuH6 RnfR2tgg8baeIu3M0bI++/8NpYjA0FO8jOFf1tF3p7RaeBXwWqC9P7hGrUvnnbUS7vxQ nelQ== X-Forwarded-Encrypted: i=1; AL+hErGywHmxvHSdnVtUrUrmM2HdPjgFB8XvaUhaa5ecfo4t2Yw9T1Wkkyp2sOVK6VpDrhZrP0jDjOIbzXkwZPA=@vger.kernel.org X-Gm-Message-State: APuU4Z/gP9t+MetK1PItp6EiX8/QSyMGr96EoIU9l6nEbdIuOZ6FCv0/ D7DrpkImdk5fjiljd5L8WeG/Ug6lGcK60JCi6Ye1LiOwdAW/KKboCJpm X-Gm-Gg: AZFdTZeqt34Z2b35D8duMmTtcPla5D0t6R5Jtez0ENpyI0wgYM53dasI7xVtNHRMs3E jKCGF1PgbprH47DPezSAw1U9WJaFa4SR3/qMcyj0lNld8SHfRAbAayEfKI7h6ev7ZMcp/fbilYF i2e62hVKwueciS01rhlXGTvqDHRKr+9nwgxQnhfubEizYf3U8NMJBQdaq0ywZv2I0f0PTQMyEQI aeq3MGEXj4JMpeZIiIiZWprns4pZakc0KQ4ij/33XEuzWqHQ2TpyvgSNPfIhGynrUJYNUev+963 4me516u6VrYeY7zYirkbMEN4vI+YpsqJ9eK/C3iRw56vS/78sAy5AEy+IrXzVt4SaYyWmkUKeNT oIzigLjVym2FsJyK97vaCMNaBnh4q2mRZp6+kTBixefzhQTuV5s8kE1bvryEJpaQ04svGDIV1GB BGu0JAvYTMPcCu0eJFVI3QJF2rvj+ec/v0dQi4RlyXm2r1KtdiDOT+exZ9j1/ioIN8lq+R76nd5 s/yWpcmL7RNOUAVT78svOR/AybHulFmvXocia3oNZHTGn/+MkzJaN/NWT4X3yXaydegr0BmgyMR QUB64NFiA0AC/0Hlk0G5c6qVTAsTDX4= X-Received: by 2002:a05:600c:820e:b0:4ac:da92:2bd4 with SMTP id 5b1f17b1804b1-4bb887c9936mr256814445e9.1.1795466054054; Mon, 23 Nov 2026 12:34:14 -0800 (PST) Received: from unknown.local ([151.34.53.154]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm515946805e9.13.2026.11.23.12.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 12:34:13 -0800 (PST) From: Gianluca Boiano Date: Mon, 23 Nov 2026 21:33:56 +0100 Subject: [PATCH 4/5] media: ccs: Make the source pad format follow the crop rectangle X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-b4-ccs-imx376-v1-4-2b26850a6f11@gmail.com> References: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> In-Reply-To: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, David Heidelberg , stable@vger.kernel.org, Gianluca Boiano X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795466045; l=3197; i=morf3089@gmail.com; s=20240402; h=from:subject:message-id; bh=AfhBJJT/dYmW+sBV6vyFvVaWagbgV6JhE5LC9kE6/9w=; b=nA+mPZum9SfgJ6ZaFHnBsjvxZSARCOiB7wSvuXdYHv0c3WlskBv1F9e4K0z64Lp5zVi/LfWCS bsfvfP9bsrpApXIBaGZJ8QAEOn0BW8kIsqyx1hwoN5rRmPBZz/5icF1 X-Developer-Key: i=morf3089@gmail.com; a=ed25519; pk=HsGrEQ3ia8BGGGO8/nUM2K2UX9JKvRPV+nbrVDGrYhA= The size of the format on the source pad of the pixel array, and on the source pad of the sub-device that is the source of the CSI-2 bus, is that of the crop rectangle on the same pad: the analogue crop of the pixel array and the digital crop at the end of the pipeline, respectively. The format was only initialised from the pixel array size or the compose rectangle and never updated when the crop was set, so after setting such a crop the format did not match what the sensor outputs. As the format of a source pad can not be set from user space, and the format of the sink pad it is linked to has to match it, link validation fails with -EPIPE for any crop other than the full area. Update the size of the format when the crop is set. As the size of the pixel array format is then no longer its native size, use the native size as the bounds for its crop. Fixes: d8bca3ed1d70 ("media: ccs: Use sub-device active state") Cc: stable@vger.kernel.org Signed-off-by: Gianluca Boiano --- drivers/media/i2c/ccs/ccs-core.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-c= ore.c index a4af27de5453..acea07d906f3 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -2541,6 +2541,14 @@ static int ccs_sel_supported(struct v4l2_subdev *sub= dev, } } =20 +static void ccs_get_native_size(struct ccs_subdev *ssd, struct v4l2_rect *= r) +{ + r->top =3D 0; + r->left =3D 0; + r->width =3D CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; + r->height =3D CCS_LIM(ssd->sensor, Y_ADDR_MAX) + 1; +} + static int ccs_set_crop(struct v4l2_subdev *subdev, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state, @@ -2556,7 +2564,9 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, comp =3D v4l2_subdev_state_get_compose(sd_state, ssd->sink_pad, CCS_STREAM_PIXEL); =20 - if (sel->pad =3D=3D ssd->sink_pad) { + if (ssd =3D=3D sensor->pixel_array) { + ccs_get_native_size(ssd, &src_size); + } else if (sel->pad =3D=3D ssd->sink_pad) { struct v4l2_mbus_framefmt *mfmt =3D v4l2_subdev_state_get_format(sd_state, sel->pad); =20 @@ -2579,20 +2589,21 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, =20 *crop =3D sel->r; =20 - if (ssd !=3D sensor->pixel_array && sel->pad =3D=3D CCS_PAD_SINK) + if (sel->pad =3D=3D ssd->source_pad) { + struct v4l2_mbus_framefmt *fmt =3D + v4l2_subdev_state_get_format(sd_state, sel->pad, + CCS_STREAM_PIXEL); + + /* The size of the source pad format is that of the crop. */ + fmt->width =3D crop->width; + fmt->height =3D crop->height; + } else { ccs_propagate(subdev, sd_state, V4L2_SEL_TGT_CROP); + } =20 return 0; } =20 -static void ccs_get_native_size(struct ccs_subdev *ssd, struct v4l2_rect *= r) -{ - r->top =3D 0; - r->left =3D 0; - r->width =3D CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; - r->height =3D CCS_LIM(ssd->sensor, Y_ADDR_MAX) + 1; -} - static int ccs_get_selection(struct v4l2_subdev *subdev, const struct v4l2_subdev_client_info *ci, struct v4l2_subdev_state *sd_state, --=20 2.56.1 From nobody Tue Nov 24 11:35:56 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.46 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795466057; b=xXPbs84s1zE3iZzXhYJFOxkfddpSNYXEenW3Y2+pUvzwo95uy1/M4F4wD///teHBIfeg jY/tUtW68KQ/J+qtW2RTjLPjhlyTHmMt3wOdLKD7JtMPCuKTHuTLCFbwlwDUwH72crT4t BxyYclDhl+d8P0JtKOWxkxHXyg5ujZINKh9ShhvOiTZ0UcIXT2or2fE/922iup1cAw8Ly Dj1+kW26m5H7nmKoTNlmDUP380eX328m4QMrPHnJuQsCFeiu4SrNS7BrXTD7IRUgAUtO2 8IZbwy50IoIPyAWsB/uWNFjSOsWUXB0NgSdlDeCPaxig1WLEIY7xNAdna8sglgSj+HA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795466057; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:Date:Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key; bh=hPT/ypmWmLMxLtJbyhU72b/6yrEAVjSw6rFwMDxvsHg=; b=hZO970FlXxIEMFhndAdGqNeHaEVWTcQszvQKOLRTthhltSNja7/g9vRgeCgDIbJVcsUc yEMeOXRhEdabR2GRECWH/Wsfo2PxA7iEvAzY0vjm0TIpzHfaaOjq2hmn4FgWxaLxh/8QF Zpi37PTTP16uWySgfXWjkZxOZpAMPVDPocWTLzzIpjZII8YT74c3c/eAx2wkSvq4tNQS1 ClJY5vizf+cjvgW6Sp+0xjmxwPcJ5pBW/nbqnodUaEItDK/bxYdnt2kJQ/rdZC9+5oAGh EAWXUWI059Tszet3X1pcDXpOCHYGe8a/3x40IkR9u4fErqAZRthHZ49nPvHb+Q2SvYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VNYlOwFm; arc=none smtp.remote-ip=209.85.128.46 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ACBC60A262D for ; Mon, 23 Nov 2026 20:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1ACBC60A262D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=VNYlOwFm Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-4a35d5d4a20so37040545e9.2 for ; Mon, 23 Nov 2026 12:34:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795466055; x=1796070855; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=hPT/ypmWmLMxLtJbyhU72b/6yrEAVjSw6rFwMDxvsHg=; b=VNYlOwFmrm+wLhEGoOMDJnlhb33JACLnJI2PJY6WoDx/+lw/0L8iwubY+Fe1T5seGq uZOpHDJ8XNVSvY0CRcJTzls5ESPF9EJEteQRXiQCQXzG5DSRDqmPkOfoqugitUOKR8ti h88EGkLgbTcUZz5hMLVudh2rLEHCHdcx2s0zsG6oPyJk/ijyqvJBXe0CJGxMIoIKJsXv ucw/jA1j/R0pu+1/mT5GuEZdh23/cy6/Hp8C50+7ByE2ZlF3+vtEl340GDeE5NaXFKfS wCVXj4rqIfT7XGkND+GsqDdX1A8i8BuGw5pjL+cury/90Nswk4eah2cqRYyqMffqhhpi mh+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795466055; x=1796070855; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=hPT/ypmWmLMxLtJbyhU72b/6yrEAVjSw6rFwMDxvsHg=; b=F0O2N6eMWH5NjKu4UJkhqgPeBhIWPlpuuCI2HAzijElhztdcJTd+EfBdCb4pUacVjc U0pIkkb4cq0eWjrbEATXdBT0eqXHtPEjCGjWwxp4Gsiy/LoEXjUI/QsFUF+gSzowbS3q LDqGFPNTR2kzeHyPLUKeYFcEU2ClnFL6zKf9Sd7hj/OIfGQ2wCGs0kCSuGjdI4HlpyXn 8hTUU7k5hOKtBU3pvTM9KBxUJ5bNUIabx1KDjzfge0oMM6pUqwmOhgdDoec0LTGG2V2A KuHSe2jWwWS1ZFv2oH8MV8U4H56VfFNiz1FIVdvOODJilR6S3dDjrQbTXrHUmwVWkp3K X6jw== X-Forwarded-Encrypted: i=1; AL+hErGYTgIZFpA/8IZt8mXdUD0sTgcEdGEiyDzJ4HtDXzG950dzFhv5gvfaboR/9DoXlynkSMAUEls2IPu9P6c=@vger.kernel.org X-Gm-Message-State: APuU4Z+V3dg4TRdEaAmubrRUJIDJxum84yUb9JXB2BQOjRs98AM9aVjx jsdJhxXEXGHUGi4OUYxXVd2gYY97AmkPH5hKAhhMNY6xX1dQxCWv/P52 X-Gm-Gg: AZFdTZc5geEEQLJAwaS3Y9xiuy5PmjQo+MuBTEK0Yg7KV2zunYHhv3T7QLvqrdnD4dG VFrWBEvm/MkdhwDvW7FUoW8HxpW1bEFLIg73eDI0fyPFd/UFUmIunXtC3wG/wIRStwyIlQPMzZj 3F3bHeuuOwQjLbEG8nOfXB9xQYHdnCMj1FniHUCu2TUhgkTKtQdQvjaGp9HplZHoWeQ5X+JWVhW jOwvJ03zcTyqGrL0yNw8TUKgwAFDIjaa48M6icUPaLXZIDXaPqHvyY6KZj3PdoJ691XwiFhMHti 7Qq+HYOXcZTGJsn5H00Oz9dvcgIRGNGn761PsjhVk+o0cDYF0TICC++72Cu0sB3SSLs5vRpkZNl o3fw2Z3ZmFAnWEQDwcLxE8eykh9ijOgV9L/UBypnHPQWRTA6d6ky0qfJYacNiQiS5hd7n7NBVze P0iL34oumWYQ7boKqVZ0pCgp5th3nLVshIaEmSQurZJvZ/jobntQa9DPny51/ujQ3U6a5VSy6sd 5p1xLTmN5K3Detsg/UudyMWbtZ3nf2AiKO954roPvFejijRXOxxd7zbarzVg2iqT8CBNsWjoW7p l2wpAGisPjYgw+ZjbJ8fxSsIWGPBlg== X-Received: by 2002:a05:600c:4e0b:b0:49f:e772:6ddf with SMTP id 5b1f17b1804b1-4bb8881ae90mr271461095e9.32.1795466055465; Mon, 23 Nov 2026 12:34:15 -0800 (PST) Received: from unknown.local ([151.34.53.154]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4bb884b7515sm515946805e9.13.2026.11.23.12.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2026 12:34:15 -0800 (PST) From: Gianluca Boiano Date: Mon, 23 Nov 2026 21:33:57 +0100 Subject: [PATCH 5/5] media: ccs: Apply rule-based manufacturer register blocks at stream start X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261123-b4-ccs-imx376-v1-5-2b26850a6f11@gmail.com> References: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> In-Reply-To: <20261123-b4-ccs-imx376-v1-0-2b26850a6f11@gmail.com> To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, phone-devel@vger.kernel.org, David Heidelberg , Gianluca Boiano X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1795466045; l=3499; i=morf3089@gmail.com; s=20240402; h=from:subject:message-id; bh=VfDCx66Bt9Q8ssDuqyaFOOZuxp5MaGCTsBGPv8t+RG8=; b=NAftwknVuWdeZhsZgh/6X5zyWUZbkl202qCbHJEL29BwWA0IUWx/7BgmqO5i80iqHzD4qKiJ6 6mHO0e+HqvVDk176PadruzQefMIA//D4e/+mM70fA0XvtZsNzGlkz6V X-Developer-Key: i=morf3089@gmail.com; a=ed25519; pk=HsGrEQ3ia8BGGGO8/nUM2K2UX9JKvRPV+nbrVDGrYhA= The static data rule based blocks were parsed but never used. Before streaming, write the base manufacturer register set again (undoing any earlier rule) and then the manufacturer registers of each sensor and module rule whose if-rules all match the current register values, e.g. binning_mode, which is already written at that point. This lets one static file carry settings that depend on the readout mode. Tested on a Xiaomi Mi A2 (Sony IMX376) with a static file whose base set is the 2x2 binned mode and whose rule on binning_mode 0 holds the full resolution deltas: both 2592x1940 and 5184x3880 stream correctly from the same file. Without the rule application full resolution output is corrupt. Signed-off-by: Gianluca Boiano --- drivers/media/i2c/ccs/ccs-core.c | 72 ++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 72 insertions(+) diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-c= ore.c index acea07d906f3..db98590c1ed6 100644 --- a/drivers/media/i2c/ccs/ccs-core.c +++ b/drivers/media/i2c/ccs/ccs-core.c @@ -1620,6 +1620,72 @@ static int ccs_write_msr_regs(struct ccs_sensor *sen= sor) sensor->mdata.num_module_manufacturer_regs); } =20 +static int ccs_rule_matches(struct ccs_sensor *sensor, + const struct ccs_rule *rule) +{ + for (unsigned int i =3D 0; i < rule->num_if_rules; i++) { + const struct ccs_if_rule *if_rule =3D &rule->if_rules[i]; + u32 val; + int rval; + + rval =3D ccs_read_addr_8only(sensor, CCI_REG8(if_rule->addr), + &val); + if (rval) + return rval; + + if ((val & if_rule->mask) !=3D (if_rule->value & if_rule->mask)) + return 0; + } + + return 1; +} + +static int ccs_apply_rule_list(struct ccs_sensor *sensor, + const struct ccs_rule *rules, size_t num_rules) +{ + for (unsigned int i =3D 0; i < num_rules; i++) { + int rval =3D ccs_rule_matches(sensor, &rules[i]); + + if (rval < 0) + return rval; + if (!rval) + continue; + + rval =3D ccs_write_data_regs(sensor, rules[i].manufacturer_regs, + rules[i].num_manufacturer_regs); + if (rval) + return rval; + } + + return 0; +} + +/* + * Apply the manufacturer-specific registers of the matching rule based + * blocks. The conditions refer to registers that are already set for this + * stream (e.g. binning_mode). The base set is written first, undoing what= a + * previous stream's rules may have left in the sensor. + */ +static int ccs_apply_rules(struct ccs_sensor *sensor) +{ + int rval; + + if (!sensor->sdata.num_sensor_rules && !sensor->mdata.num_module_rules) + return 0; + + rval =3D ccs_write_msr_regs(sensor); + if (rval) + return rval; + + rval =3D ccs_apply_rule_list(sensor, sensor->sdata.sensor_rules, + sensor->sdata.num_sensor_rules); + if (rval) + return rval; + + return ccs_apply_rule_list(sensor, sensor->mdata.module_rules, + sensor->mdata.num_module_rules); +} + static int ccs_update_phy_ctrl(struct ccs_sensor *sensor) { struct i2c_client *client =3D v4l2_get_subdevdata(&sensor->src->sd); @@ -1993,6 +2059,12 @@ static int ccs_enable_streams(struct v4l2_subdev *su= bdev, goto err_pm_put; } =20 + rval =3D ccs_apply_rules(sensor); + if (rval) { + dev_err(&client->dev, "applying rules failed (%d)\n", rval); + goto err_pm_put; + } + rval =3D ccs_call_quirk(sensor, pre_streamon); if (rval) { dev_err(&client->dev, "pre_streamon quirks failed\n"); --=20 2.56.1