From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796252615; b=yuHDBMsupqgQCRCf2qH1usn/AeanD8xH+Q4MMm3iU1W6GRZ1tA9XKUWU0zBiImEvfhNC 0XgXgWr7KMLKi04hI4xfiJh+vdmH3RsZ0Bsk3pAulwpmuKAVYF5CSZg2t9OOocMt35pXU SM+sXMKwApnMNWdzXaY4pKIs6j6Thwv58Yp92gEZq2x8oBmvFPvUfGUYeE/uBHp4ZYWvR tN96NFqzQMbr82UtaVxPVaPBlzyE/YnqzFigZp9aro6SwvWu8ZgB+wfmvFqTCGbjlljLg OB3ZvPPByC2vb8ddWp20GJRmgouxMnJmKq/SDEvFbpg+RWVZTG/xeejpONClw+Z1TJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796252615; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=OAV/cajHwcCM34gsjLtoevJ9IzPm5WQZ83GjL8TDOnE=; b=tW4C28c6oMc3BJFGs5gf00ms2L2OrbRhR5RZ7tBxh2t22ljtHnoo+IjQ0Otg7XQ6E9Bh f9HzxeMH+jRiVEHt8bCRkeqTCITGppUoVD76BFoHSS7sDRuldnkEeCpgWNBIdGTr8GnWF tFHc4D8/EvRpY76meuiu//qDzqEkmKcZIZu7dQ8AmXod9LxlRV1kgNZ06ywNN2FONCqP9 xP27lvYzFRuXIuc+gvh4cG/8mU6yPKpvM4pPrOetgb4lfWZmwTdE6YbAxdOcnfsQFPsIi KKzVxySYMLCT4Fbg+9JMjWlOpaqH4Zvn0bTngKbWfXAI9WbqhLCBh7o44VOpcl2MXeQ== 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=y3pDFqyL; arc=none smtp.remote-ip=209.85.221.50 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (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 20359606A683 for ; Wed, 2 Dec 2026 23:03:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 20359606A683 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=y3pDFqyL Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-49412eb1474so9166431f8f.3 for ; Wed, 02 Dec 2026 15:03:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796252613; x=1796857413; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=OAV/cajHwcCM34gsjLtoevJ9IzPm5WQZ83GjL8TDOnE=; b=y3pDFqyLWFjHVrK6mcthXGXBC5WpIgVZxLVlF/fSKtPhzLi5IUriNpGQuBip6wbNca cUjVG1WMOK9qbX2udGLzNyAoY9lIWIzHfLhrRS87xaDUDNnzu0wlYDngNjzNpwdMfCSm dxpqOZwA5wDEtjz/cT8bYXV3kifnb6IEwvAXTlQO0JpXfi2h05bhuA8qpN1xxASTTzku jFF5lKMpFrTplZKWjFG31joB/xRxLDgStXfO7gCNlL4Mkw6DjIQfe2IWIUm1D/F2o/XZ t2YQ6KpJfrnHBur11XzzIvQ5q7WJ9IAeRGE6Ot7XU5gngoXXkcSDiaHy29x6NlyXm6I3 yT2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796252613; x=1796857413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=OAV/cajHwcCM34gsjLtoevJ9IzPm5WQZ83GjL8TDOnE=; b=E5SmTztIXxfaR4ZKDObt8HFn3cTaxjf6VKspXb/quGakxrDzvo1MJlc4Zj18rGJf66 zXKdvFYg9iXiPTbirdda0bf95VKHf4zG07HaoRdLLgvfvKXgsV6X6ptuBuBdimDMdu7I oVd3N2TlvROw+b+K6juWTstosxmYU4Sq7gJx9jNSrsEgxn4cWc/uTBuvoW2pco7mODYA Aod/0nXGHNuluUb7XOTA9zhF1j+BklooA0KvwHQpnTBxmfxrPdTKSw9c/1KmyEEiMvKT xseOgjAVm4XbiBNIZ3il+vLIgDw4CuSkVMtH/hcFRGSErIlT2WL2HpZmirtvIapbJuTJ Gggw== X-Forwarded-Encrypted: i=1; AL+hErETBnLpMVROzJzaTpZwBiCSOsmnR4W6DsaaYqULUWaE6KbZcwUwIXX+OmXbt4q+GTG3h6Zx8EoU1Y+qcok=@vger.kernel.org X-Gm-Message-State: APuU4Z+KocJ2JE34C6xJaAqpQS6xVf0oBZ+h921ipNO/IqY9Main51Zw L7G/GGl6/+DZjQdIvdrCZa2mdwNCzg7pYwqLNhE58wrGSamn9br+PSGF X-Gm-Gg: AZFdTZcY5Qj6Thai1uvWZwIRfxZObJXKFuQwCJI6QbS+RbnF6deYV7bzWPRxLGeslm/ aGuIodiUxJ8ZPlEAmpplm7H3OA1QyIyEavJMH9JnSRKApDMxlg3IDhj+ZM//nt+HNACQR5Nhy6Y gLzi3W3BZ0U3+8j1FT580UAJSuQZPKvNsj2jiqWPEkC+mWt4e8bd4EM+pDaSJGoYaULXDUdYesr 7Z8a9veGR2BYTu0sytmbjL2FwTXYCjNnNNvT7ZqRRmPmAfSbcyT6ZoCtbfcbpMqhg6VuA2BGd0v 8NNM+0iYZ1067cr0ZpGi0w8lDq8fSGCeBNT/s4HIMCVY4DC3tPt9e4P+yDzFNDxhjgIwfikpzUd dwS7fi78+nxYEWFD0YJ1BHpIoInDocT4qRdUKvocdAg3i0qg5+NWaJjbzyHYLsGlUmoz/PKkZP7 87Ja3MmyumNE+NHk3xy05xLthxbQvNQQ89HmDpS5dsulwaIuZ1farUm5722MVFBK0MWOE8PgbEp 2nebLc9NPl8qfvUt7b7qybpIbqie9zAHo85nHFxszxLJAqtgpvz2c/T4kIpOc2O0J7qKRgBasi7 8bwN2tFGf7PY5WM1BxG81rFDIqESyYKgKUFezsFO X-Received: by 2002:a5d:64c9:0:b0:4ae:c8ff:2302 with SMTP id ffacd0b85a97d-4aec8ff24c1mr71678840f8f.49.1796252613418; Wed, 02 Dec 2026 15:03:33 -0800 (PST) Received: from unknown.m0rf30.ray ([2a02:b021:8011:256b:d13a:b0f2:c168:28e9]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4ab658e2c8csm81180838f8f.2.2026.12.02.15.03.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 15:03:32 -0800 (PST) From: Gianluca Boiano To: Bryan O'Donoghue , Vladimir Zapolskiy , Loic Poulain , Mauro Carvalho Chehab , Sakari Ailus 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 Subject: [PATCH v2 4/5] media: ccs: Make the source pad format follow the crop rectangle Date: Thu, 3 Dec 2026 00:03:01 +0100 Message-ID: <0f9570f5b67395eb24bac5cb8958a21ed4ceb482.1796251498.git.morf3089@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: References: 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-Transfer-Encoding: 8bit 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-core.c index a4af27de5..acea07d90 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 *subdev, } } +static void ccs_get_native_size(struct ccs_subdev *ssd, struct v4l2_rect *r) +{ + r->top = 0; + r->left = 0; + r->width = CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; + r->height = 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 = v4l2_subdev_state_get_compose(sd_state, ssd->sink_pad, CCS_STREAM_PIXEL); - if (sel->pad == ssd->sink_pad) { + if (ssd == sensor->pixel_array) { + ccs_get_native_size(ssd, &src_size); + } else if (sel->pad == ssd->sink_pad) { struct v4l2_mbus_framefmt *mfmt = v4l2_subdev_state_get_format(sd_state, sel->pad); @@ -2579,20 +2589,21 @@ static int ccs_set_crop(struct v4l2_subdev *subdev, *crop = sel->r; - if (ssd != sensor->pixel_array && sel->pad == CCS_PAD_SINK) + if (sel->pad == ssd->source_pad) { + struct v4l2_mbus_framefmt *fmt = + 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 = crop->width; + fmt->height = crop->height; + } else { ccs_propagate(subdev, sd_state, V4L2_SEL_TGT_CROP); + } return 0; } -static void ccs_get_native_size(struct ccs_subdev *ssd, struct v4l2_rect *r) -{ - r->top = 0; - r->left = 0; - r->width = CCS_LIM(ssd->sensor, X_ADDR_MAX) + 1; - r->height = 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, -- 2.56.1