From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (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 0458949F11D for ; Mon, 14 Sep 2026 20:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789419244; cv=none; b=A8x05KkqEHJNQ8r+hb0FFlX/OaTppg93ToB9YYHoMmocKoO4wvv2d5ty1sIeDEvDJ+DTbtGoOhc6hKXkOMD2NSEKABjPRq8ImEivBUEQnrBF4MdvpX4w7PsAgJ6/SYozni6puCdeu8qwKBSWa2h+XnSksNdBBbxWaXJqHNiu8Hs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789419244; c=relaxed/simple; bh=ZBc74N57Ra7Mdbx5Z0Noqj8xfQ2T+MfYl59qhpIWKtM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SJGtsYxW40gU5o5NKQSbbq/WpGlLLTtHDP6pDEEG8wbfYTuOSkfD97WK0fNDat+pLCi9MrIFkQ3wLUz9mzsxL3PhK9NHPF8GaijUKT7Yk79Fvz0l9jQ1htFC/qWtpScACAKnSqLT9jVm8P9fA2hh8dCmrGfGCqy1AfwEV9gpNG0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=laJujMNF; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="laJujMNF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1789419243; x=1820955243; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZBc74N57Ra7Mdbx5Z0Noqj8xfQ2T+MfYl59qhpIWKtM=; b=laJujMNFU8lZqcPY2E9lcT6ihKndGaBV7VAgQ1gN26LGDdd557MfBGm7 9wBVK2UM/R86dvWQsglDHSNgoycekYadrE8/zdsB4gcy1+OafuZpEkvbM YFQJhD5fbnw7S3UOMsxb8rwn5eDkU85mwqSYo5FAfVV0F1YiwkCEcS47w Lti3kGZJMk/Thyz9Ue6+4dan5CtPj/dh+3bQhY715QFoRTlX5Kn1pjm/E TM3NJy2G8+GmDUFjnX9q+c7STQ3/p2/R3py6r8+nCSOW5J7TY/LrhcEuK s9zNN6CJ8kNM7pxtMX8GbWg8RgXR0RFjSy7HO5vaVuJGkmE+2bMCSEVWJ Q==; X-CSE-ConnectionGUID: lftLWAKRQdyAfzTPPC0Bsg== X-CSE-MsgGUID: m9xRT6a2RRqQnqaZRRpzkw== X-IronPort-AV: E=McAfee;i="6800,10657,11905"; a="89984122" X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="89984122" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2026 13:53:59 -0700 X-CSE-ConnectionGUID: 1hBxLTjvQKm7zkOWwMG39w== X-CSE-MsgGUID: D/34+FHfT7aS/86LjwbaGw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,103,1787036400"; d="scan'208";a="297760723" Received: from pgcooper-mobl3.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.245.245.173]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2026 13:53:56 -0700 Received: from punajuuri.localdomain (unknown [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 4D1A4121BBC; Mon, 14 Sep 2026 23:53:59 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.98.2) (envelope-from ) id 1x6Dgc-000000035J1-3KAT; Mon, 14 Sep 2026 23:53:58 +0300 Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: "Yan, Dongcheng" , Mehdi Djait , "Yu, Ong Hock" , "Ng, Khai Wen" , Antti Laakso , "Bajpai, Manik" , Divyamani Tripathi Subject: [PATCH 06/21] media: ipu6: Clean up link frequency calculation Date: Mon, 14 Sep 2026 23:53:43 +0300 Message-ID: <20260914205358.735307-7-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260914205358.735307-1-sakari.ailus@linux.intel.com> References: <20260914205358.735307-1-sakari.ailus@linux.intel.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Handle link_freq <= as a special case and continue calculating the pixel rate otherwise. Signed-off-by: Sakari Ailus --- .../media/pci/intel/ipu6/ipu6-isys-video.c | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c index 781fc0e88417..3d455872f29a 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-isys-video.c +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-video.c @@ -648,12 +648,9 @@ void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av, struct ipu6_isys_csi2 *csi2 = NULL; struct isys_iwake_watermark *iwake_watermark = &isys->iwake_watermark; struct device *dev = &isys->adev->auxdev.dev; - struct v4l2_mbus_framefmt format; struct v4l2_subdev *esd; struct v4l2_control hb = { .id = V4L2_CID_HBLANK, .value = 0 }; - unsigned int bpp, lanes; - s64 link_freq = 0; - u64 pixel_rate = 0; + s64 link_freq; int ret; esd = media_entity_to_v4l2_subdev(source); @@ -671,28 +668,26 @@ void ipu6_isys_configure_stream_watermark(struct ipu6_isys_video *av, csi2 = ipu6_isys_subdev_to_csi2(av->stream->asd); link_freq = ipu6_isys_csi2_get_link_freq(csi2); - if (link_freq > 0) { - struct v4l2_subdev_state *state = - v4l2_subdev_lock_and_get_active_state(&csi2->asd.sd); - - lanes = csi2->nlanes; - format = *v4l2_subdev_state_get_format(state, 0, - av->source_stream); - bpp = ipu6_isys_mbus_code_to_bpp(format.code); - pixel_rate = mul_u64_u32_div(link_freq, lanes * 2, bpp); - - v4l2_subdev_unlock_state(state); - } - - av->watermark.pixel_rate = pixel_rate; - - if (!pixel_rate) { + if (link_freq <= 0) { mutex_lock(&iwake_watermark->mutex); iwake_watermark->force_iwake_disable = true; mutex_unlock(&iwake_watermark->mutex); - dev_warn(dev, "unexpected pixel_rate from %s, disable iwake.\n", + dev_warn(dev, "unexpected link_freq from %s, disable iwake\n", source->name); + return; } + + struct v4l2_subdev_state *state; + struct v4l2_mbus_framefmt *format; + unsigned int bpp; + + state = v4l2_subdev_lock_and_get_active_state(&csi2->asd.sd); + format = v4l2_subdev_state_get_format(state, 0, av->source_stream); + bpp = ipu6_isys_mbus_code_to_bpp(format->code); + v4l2_subdev_unlock_state(state); + + av->watermark.pixel_rate = mul_u64_u32_div(link_freq, csi2->nlanes * 2, + bpp); } static void calculate_stream_datarate(struct ipu6_isys_video *av) -- 2.47.3