From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=68.232.153.233 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796195795; b=lnEVpzviSuIQEZ81K+yWa9mEe74pfHyyypuCqJi9nsvrQ4aetqGmqqoPkWCNIZZNhUQ/ QHkpc8whaFTQUc4sBK2/4sqsdqqJwCs4G04V9vINANKXR1SjjwnjorWwVIOJDH7Upnam6 YAdtAh7gNvWMzsd8lrqMcCo5n++6aVsyBBLfx6t1WZ1jpT4LhbL7axIxN9d4ZicKp5Xoq LgbEsPfKyrj5wH+2fy1g0+jGo65RyKyzCS4RmWUjTBW798F7ZLYJGN2U0h6vlYkO3narJ TnvjuNT4K8DtdK8xv4E7bO5cdcGAS4tiMgsrc4X+6poOj8t1eCq/TgZPswKJxPnOVcg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796195795; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-Amp-Result:Received:Received:Received:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-ID:References:In-Reply-To:To:CC:X-Mailer; bh=yjNfh4lMSvW8AgEm5xJTBa1T2L6SMIBG9XsxCyMdetU=; b=Y8hTDhCG7H04wOuthIZeZJyMT1Uc0zV9i834+Vzpq07HMeasj4+gwfd46JjcixUNrEu/ Fz6kGSyEH4V19VsDvRRysjetayOJGJgVRF/yGXoecdCpcSBVhHaQhxWYbEM25iOzKg9CC uahOqRpbiM0MjmpVt2dxSenZqbui2IcUXKScLUOr/nj0gWEuZg3HsZIBbUO5Pm3WWm86Q CfARC6MxFJhsflsKVMMXvXGSWBY9r6VWvwcombm9z5glTxFuM5XrnVimbGn0nbjfnB/EE fEx8i08QW/VtPo0bfABp3bt4P+MByL5s4bIhW/4XPI0ec23jAdGzcOqjjlKMPLe6MLQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=microchip.com; spf=pass smtp.mailfrom=microchip.com; dkim=pass header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=jVVUst5K; arc=none smtp.remote-ip=68.232.153.233 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60FDE606A6B5 for ; Wed, 2 Dec 2026 07:16:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 60FDE606A6B5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=microchip.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=microchip.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=microchip.com header.i=@microchip.com header.a=rsa-sha256 header.s=mchp header.b=jVVUst5K DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1796195795; x=1827731795; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=flpJSkSL8WkguqliRaVAA13Tt0UQUweghDmjOSZ+9ck=; b=jVVUst5KoyLyp6UjHipfM8Jqgz9aBIg1/wA+Bokml9RgccgJPs4AcZot Lf9hayKs0j8dcKF9BZDiYSUz6qElgAZF1SjoE3bizjNuLDSnZ4rbzaL/I I+p2AGnnNgOP6ZLrbTm2wGER/fbKie2ng5/7Q0iithcgBb/WkaY1UKgKa 4l4cCcKKiIACuTpMAsq8u200YbJrEVbPVdlcScdAqp55pdW1YxeZMCoZP ZTJle/QdNvVxUOD+VhW3xgfjf9X0lXopyzHveRs9rILGn2hHnrg06vwYm yuyfc8El2xz18Rqly3BZRuXGoyFyLIX7NMlhWEKXoY/ADUPRIckm/oMIo g==; X-CSE-ConnectionGUID: gRqb0TyuTJK5DZyw0xNKKg== X-CSE-MsgGUID: 8p8LXfp6TG+Blvi0TTgRjg== X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="67334015" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa3.microchip.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 00:16:34 -0700 Received: from chn-vm-ex01.mchp-main.com (10.10.87.71) by chn-vm-ex3.mchp-main.com (10.10.87.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.57; Wed, 2 Dec 2026 00:16:34 -0700 Received: from [127.0.0.1] (10.10.85.11) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server id 15.1.2507.58 via Frontend Transport; Wed, 2 Dec 2026 00:16:32 -0700 From: Balakrishnan Sambath Date: Wed, 2 Dec 2026 12:46:18 +0530 Subject: [PATCH 12/15] media: microchip-isc: do the AWB gain product in 64 bits 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: 7bit Message-ID: <20261202-isc-series-v1-v1-12-4e2f17c0271c@microchip.com> References: <20261202-isc-series-v1-v1-0-4e2f17c0271c@microchip.com> In-Reply-To: <20261202-isc-series-v1-v1-0-4e2f17c0271c@microchip.com> To: CC: , Balakrishnan Sambath X-Mailer: b4 0.14.3 s_gain and gw_gain are Q9, so their product is Q18 and can wrap a u32 on a strong stretch with a large grey world gain. Multiply in u64 and clamp the Q9 result to GENMASK(12, 0), the width of the gain field. Signed-off-by: Balakrishnan Sambath --- drivers/media/platform/microchip/microchip-isc-base.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/microchip/microchip-isc-base.c b/drivers/media/platform/microchip/microchip-isc-base.c index 491f710fe08d..a767dfc719f3 100644 --- a/drivers/media/platform/microchip/microchip-isc-base.c +++ b/drivers/media/platform/microchip/microchip-isc-base.c @@ -1428,11 +1428,9 @@ static void isc_wb_update(struct isc_ctrls *ctrls) "isc wb: component %d, s_gain %u, gw_gain %u\n", c, s_gain[c], gw_gain[c]); /* multiply both gains and adjust for decimals */ - ctrls->gain[c] = s_gain[c] * gw_gain[c]; - ctrls->gain[c] >>= 9; - - /* make sure we are not out of range */ - ctrls->gain[c] = clamp_val(ctrls->gain[c], 0, GENMASK(12, 0)); + /* the product of two Q9 gains can exceed 32 bits */ + ctrls->gain[c] = min_t(u64, ((u64)s_gain[c] * gw_gain[c]) >> 9, + GENMASK(12, 0)); dev_dbg(isc->dev, "isc wb: component %d, final gain %u\n", c, ctrls->gain[c]); -- 2.34.1