From nobody Mon Feb 9 12:09:48 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (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 2D36430DD1F for ; Wed, 24 Dec 2025 12:31:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766579491; cv=none; b=NQyJOr/4tVkSQyA5P3i5JFA3B9Pvwd4Un9EnaWD/pkiOGuNnKAmX9DJhXeQEdPpesx0fLMt9a5xmr/bqKPVyHAMrbYBRfFL3nB+Ae2FwndSa+x3PtqtXnaefD5BZ7+4T1qdADHNXF45cTOazUZfeQB2lLu/xjTqfk0TS/YGe7K4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766579491; c=relaxed/simple; bh=ICATXnY8OUn+EYLLDMbD26cRJdbw0LYk2Tn53ySJtys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FH+gQKy6oltpcO5BtzsGiGywghV+4dPcZfcx35sJuRY+0JxdZxhCrwiPYbrd4ImHtKEmAKCOy47OCncgD+PJ9CSdHUIMcANjQzhGn5ZMe5vpk8GARwYlBzYw32g6GAAHjc7Mez75R8sAAOq7ZY1MnQ5jq8I8DbKSPhCw/58M2A8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=OO/kKzQd; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=MAQW88Wr; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="OO/kKzQd"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="MAQW88Wr" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BO9XTlm700449 for ; Wed, 24 Dec 2025 12:31:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Q67QdQGLjQghzeJzftBRQzEPwwok8C7+UkPXfDPo1U8=; b=OO/kKzQdTh8B7tb1 q0cGE5FdB3JCrznyoE2U8lgQhI6Xuj8yNYHALYtzkf2R9eQuGLilHHAxUch52Zzp q3QYwhgZfyt1UjxutYsg9WtDuoOLzRXuto7m52SpiuV3AnzW8qKw8uJXll5EflBd UBLrlc+CgDGfKXTbVezuWYmNjD5XC+u43sc/oIYTvdpy/05LqhxsQTXsZd1mScV3 Ri8en0yg9xGNWWIFS7eJkANh+bi1vrk2+boewpH12soQiL4Q+JbV/lVfGFIwvxhA 6g+K0W1aO9iPoXRosGH7JOKdzxkWPjTCmXrnTAQia0s7MEEBsceMGoutLjOQ7eCF Izi80Q== Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4b7t7jupsd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 24 Dec 2025 12:31:28 +0000 (GMT) Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-4edb6a94873so114616731cf.0 for ; Wed, 24 Dec 2025 04:31:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1766579487; x=1767184287; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Q67QdQGLjQghzeJzftBRQzEPwwok8C7+UkPXfDPo1U8=; b=MAQW88WrWVNSRBpa86ZWUCwXPnBngMDmP1s/wc23Iar1N7RBaXPYk0zR/OT8W31G9u pq4Ag5rOk91YwB2/xb6WI+PBaucq9n7MjbbO4NQM4uDZvYHoYhTUEyODjf+fR1bq69J8 C/iZYuwPko+6j/SwUUuR2diBZUsTPfHfYOqQ2yG3zHQCkbtD92hw16UcM7yI0e58i0dz mCytEb96luRmBuh3YxDNwOLZFk7ksyzoEFXatzDjmpkXiAoQ7v9jV3iEm/AzEMBY+em0 yaiwduTsEhro9dNJwgb/85jNiyixXxT2rjxvruBQk8CAb04xRKDO7WAE5L1mfXMfdnmB v6ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766579487; x=1767184287; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q67QdQGLjQghzeJzftBRQzEPwwok8C7+UkPXfDPo1U8=; b=RSCmhNyedROuqpJw9m2D+89PeuoAItbuaP1RlazrJyu+anyPP2gyf3TUJuvQbvdro+ gLc46L3n+hgT50DQ9/RExLiqAxHbfi2Ki66ayaUxlUPSC4n5nFKs96ZOo8QKCCyWwYOz Jyx5kn3sMKR7Zq40AxwWkzoB3bbXCDCfYamGwLSG4gWbVdY8iRMR6q+FF8aVXhmcjdyw whCF9UkiCOgy44SyPmnCjY62vUNiC/X4GCy2c1Ji0uK5ARnGB7LRr0gFkh1vOAl3/X12 69466OHnwq23RLfhcEJUdi/lMckx9rIv3CrrMdccWZyAgkR2m55SK1qUBRbpyy0Yc8Ta TClA== X-Forwarded-Encrypted: i=1; AJvYcCVVdqpnsXAPjfSs3oihQXIdAYTyMpXIbxHjEKZ0FhE6uZOKoZTIZl8QmZjrAeXc4U/LtI2dIz2u+7e2Gpc=@vger.kernel.org X-Gm-Message-State: AOJu0YxpmRHhaaNytWOTKH4s9RHerVeVv/xRbGEOeOpWOaHuUIKXs7Vi 06Xjid3+KhF25qmva4xMnueI2fKeQrfffZ3cnsCwJlg++QsrPipUByA2CUCu9noL/ILfsyQeRpg DhKCJPrfVEtXTPSQxOy2YXRkxmkFD+0FgpqRv7FaXofR07cE41Csvil9DAwr4ibrvSds= X-Gm-Gg: AY/fxX6CdIDz0Yyoy2nqWf2ln7L+SFP+5AN4KnSYmU4ovsEv72CuoOnU2R8ggrM7NYB 0YbHCn9DFX+F6P590fcLhoUObQc2EvVS6CVA3zMdSmOOGxaOrWI8GjNqjvXtJRoatcfH50ZwOTq qdB9m2MSiB5iH871z9dHQAgfnJh1M3evTCLbB1Bx6IFXhZ8I8snA64k3Uq0yBqP4qa0ehYCdmcH xFfqVewReafN4gSiOUOdMvascJsi+o5N6CXDMAeGckgtMV68PfebglaT9yPft6s6BeMxfOfvPOC 9K/gBKWg0mXL/WnyMqmbJf9H2r6APnFq6Y2vRV6DuIhXtdOktRRpBE/o32eCJdXjeVtIfFaRqVp 7XJ6DicDYK7oMxtovA9Q45oyEM6H2dppuefqYzJIr6BNglhgNqUW+r3u2NqTMvQ5c3mpX19i+Om lZdnZ9jy4LRbJyB/HGVWORo1AEu5ZTIxX9RM3B4t/x X-Received: by 2002:a05:622a:5a13:b0:4f0:131f:66fe with SMTP id d75a77b69052e-4f4abdb3a07mr234223531cf.59.1766579487068; Wed, 24 Dec 2025 04:31:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRT/MedxaEXpVi/eXyGCoyB4VSkFskbjX16VocUoouWVGYhnr15rPblB+vvr/Qz+yCNBWukQ== X-Received: by 2002:a05:622a:5a13:b0:4f0:131f:66fe with SMTP id d75a77b69052e-4f4abdb3a07mr234223101cf.59.1766579486591; Wed, 24 Dec 2025 04:31:26 -0800 (PST) Received: from shalem.localdomain (2001-1c00-0c32-7800-5bfa-a036-83f0-f9ec.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:5bfa:a036:83f0:f9ec]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b8037f0b12dsm1750304066b.48.2025.12.24.04.31.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Dec 2025 04:31:25 -0800 (PST) From: Hans de Goede Date: Wed, 24 Dec 2025 13:31:19 +0100 Subject: [PATCH v4 10/15] media: mt9m114: Adjust IFP selections and source format when source format changes to/from RAW10 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: <20251224-mt9m114-atomisp-v4-10-60b25da7a1bc@oss.qualcomm.com> References: <20251224-mt9m114-atomisp-v4-0-60b25da7a1bc@oss.qualcomm.com> In-Reply-To: <20251224-mt9m114-atomisp-v4-0-60b25da7a1bc@oss.qualcomm.com> To: Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Hans de Goede X-Mailer: b4 0.14.2 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjI0MDEwOSBTYWx0ZWRfX7MCoy8tkOCda LaTGduTV8hYU78s3kNdjNUXhn+JAnZYKEUwPCeIW9RU7iNwRM017lw+x+o/fGdPF6b9m8r6cOBx cyZ1onIDAVOloLumErOzjQbf/Umk+sV8lxH+r+U3D44DO0siFm8AQRXoAkl9+dOW4eSNT5hE6ub LRQBWb4qlcfPDLVyHEAHreLLl8uiWVsA678DbCGZKy2U3E0w0gE5mDZgyxnNZmerKVDAKwm5WyI tiuP72fIPHUCHAnbzDuN/kMNS9lpVSh/qM7s4oS5GSL1UnKeocxFoBaFqWOfmMihY6Htak/61L9 phgOpE9fmI92RNxA73uzrs4Skx62DrUu5tUxm0xjz1U+jb9qYuNCWz/HqPF+w4wn14A7j+HJECU XRrlsNbKgJkwfWe/EdNALnjnDtsO9/SgfD7jlKfiLo5SZqbszZejl1H424zxSHmjqUmljr4LnS1 O4XWpUovv+FkkfJiNXw== X-Authority-Analysis: v=2.4 cv=IvATsb/g c=1 sm=1 tr=0 ts=694bdd20 cx=c_pps a=mPf7EqFMSY9/WdsSgAYMbA==:117 a=xqWC_Br6kY4A:10 a=IkcTkHD0fZMA:10 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=P1BnusSwAAAA:8 a=EUspDBNiAAAA:8 a=m-OQgdKteQAIafo4PngA:9 a=QEXdDO2ut3YA:10 a=dawVfQjAaf238kedN5IG:22 a=D0XLA9XvdZm18NrgonBM:22 X-Proofpoint-GUID: xccHNVvP-a9htZ6pXjjM3AJMVa1vXbN7 X-Proofpoint-ORIG-GUID: xccHNVvP-a9htZ6pXjjM3AJMVa1vXbN7 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-24_03,2025-12-22_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 clxscore=1015 bulkscore=0 malwarescore=0 impostorscore=0 suspectscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512240109 Changing the IFP source pad format to RAW10 means disabling the scaler, which means that the crop and compose rectangles must be reset to match the sink format size with no border. And when changing the source pad format back from RAW10 to another format which require demosaicing the crop and compose rectangles must be reset to the sink format size minus a 4 pixels border all around it. Also when changing the source pad format back from RAW10 to another format the colorspace, ycbcr_enc and quantization need to be updated too. Add a new mt9m114_ifp_update_sel_and_src_fmt() helper which resets all these taking the bordersize for the new source format into account and call this helper whenever the source pad format changes to/from RAW10. Reviewed-by: Laurent Pinchart Signed-off-by: Hans de Goede --- Changes in v4: - Address comments from Laurent about commit message and comment wording - Use simpler code to test when source pad format changes to/from RAW10 Changes in v3: - This is a new patch in v3 of this patch-set, which comes from splitting up "media: mt9m114: Fix scaler bypass mode" into multiple patches --- drivers/media/i2c/mt9m114.c | 53 ++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c index c0710dbb670d4e40e13fc895cf8c84219ea43bde..a9162457bf649404ac205732879= 9f1be61558481 100644 --- a/drivers/media/i2c/mt9m114.c +++ b/drivers/media/i2c/mt9m114.c @@ -1840,6 +1840,41 @@ static int mt9m114_ifp_enum_frameintervals(struct v4= l2_subdev *sd, return 0; } =20 +/* + * Helper function to update IFP crop, compose rectangles and source format + * when the pixel border size changes, which requires resetting these. + */ +static void mt9m114_ifp_update_sel_and_src_fmt(struct v4l2_subdev_state *s= tate) +{ + struct v4l2_mbus_framefmt *src_format, *sink_format; + struct v4l2_rect *crop; + unsigned int border; + + sink_format =3D v4l2_subdev_state_get_format(state, 0); + src_format =3D v4l2_subdev_state_get_format(state, 1); + crop =3D v4l2_subdev_state_get_crop(state, 0); + border =3D mt9m114_ifp_get_border(state); + + crop->left =3D border; + crop->top =3D border; + crop->width =3D sink_format->width - 2 * border; + crop->height =3D sink_format->height - 2 * border; + *v4l2_subdev_state_get_compose(state, 0) =3D *crop; + + src_format->width =3D crop->width; + src_format->height =3D crop->height; + + if (src_format->code =3D=3D MEDIA_BUS_FMT_SGRBG10_1X10) { + src_format->colorspace =3D V4L2_COLORSPACE_RAW; + src_format->ycbcr_enc =3D V4L2_YCBCR_ENC_601; + src_format->quantization =3D V4L2_QUANTIZATION_FULL_RANGE; + } else { + src_format->colorspace =3D V4L2_COLORSPACE_SRGB; + src_format->ycbcr_enc =3D V4L2_YCBCR_ENC_DEFAULT; + src_format->quantization =3D V4L2_QUANTIZATION_DEFAULT; + } +} + static int mt9m114_ifp_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, struct v4l2_subdev_format *fmt) @@ -1863,11 +1898,19 @@ static int mt9m114_ifp_set_fmt(struct v4l2_subdev *= sd, /* Only the media bus code can be changed on the source pad. */ info =3D mt9m114_format_info(sensor, 1, fmt->format.code); =20 - format->code =3D info->code; - - /* If the output format is RAW10, bypass the scaler. */ - if (format->code =3D=3D MEDIA_BUS_FMT_SGRBG10_1X10) - *format =3D *v4l2_subdev_state_get_format(state, 0); + /* + * If the output format changes from/to RAW10 then the crop + * rectangle needs to be adjusted to add / remove the 4 pixel + * border used for demosaicing. And these changes then need to + * be propagated to the compose rectangle and source format. + */ + if ((format->code =3D=3D MEDIA_BUS_FMT_SGRBG10_1X10) !=3D + (info->code =3D=3D MEDIA_BUS_FMT_SGRBG10_1X10)) { + format->code =3D info->code; + mt9m114_ifp_update_sel_and_src_fmt(state); + } else { + format->code =3D info->code; + } } =20 fmt->format =3D *format; --=20 2.52.0