From patchwork Mon Jan 20 11:01:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 858844 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 A4A59481CD for ; Mon, 20 Jan 2025 11:02:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370936; cv=none; b=MQDaFRbFezBcoByersUm+vpyxMw4M9SPipy37G4Vx73naNM99xhOAFZRxiClUPpNKUvu8tlckE2wNDQzskoX4+2RRdUHJXsykY6NCrsdZOXCAIk8pqFqhNomFciBILw9hbaa44o+0W95Zj86AnskS49tRDWAxg5j4j04PMLCrNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370936; c=relaxed/simple; bh=cSzUNR4PUt5j2gD5m4v5XCZZuTHlKFUZti2+ZXYeseQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UY/QW8osskr56qZuoEeyMyS+mEdbwIgDGlWzvICGRNPYeRnmHfcGx93fqSFxhnJAMBIRIcECG6/1SS8ewFx3qPqeY2/ih//LHyehPruC0pBNIl+kfLUzEnHDletUooN/wc7I0fISgeap+AfsTj7N2l9qAWd2Dl5/lnglQdXcKJI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=emS8xJTe; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="emS8xJTe" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737370935; x=1768906935; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cSzUNR4PUt5j2gD5m4v5XCZZuTHlKFUZti2+ZXYeseQ=; b=emS8xJTe8W7krFvC+e/F9oyA3B+4YeVWqf6cW7KxxcpDpHwPZmY0tX9g ikEfqxW5L0fsDyb39R999Q9z0hR4hfTGl/ImKSnALw2726sC0nAt65MET ArvFupukj275UagDLegO0IME/87Ad4Lz3/w6Iyfw5wDkIWCKH46sRG15j ipIfHanIAndoggH0HWfNSlUyZVKWzQHQRP0fagWbC2cRVmbWmFWR5X1vk R0WFcq4kLgesnUeMc6px4Y2Rt5CR0kkq6hJba6K776wKejK1gaLgzFsHp 3vJHQZ+66zArC+FcNxc1wywXYYpvjAwDHfc2Hy8iw9kV+8gjjOazxwOh6 g==; X-CSE-ConnectionGUID: eGvjb3yRQ367tayzjtHnGg== X-CSE-MsgGUID: OeWdsNalSCeaobaWyL4azg== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="37914510" X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="37914510" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:14 -0800 X-CSE-ConnectionGUID: V2K5efIXRy65e6Xk2FOXvg== X-CSE-MsgGUID: o46l7irGS6aZrZc60lv18A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="106491057" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:08 -0800 Received: from svinhufvud.intel.com (maa-artisokka.localdomain [192.168.240.50]) by kekkonen.fi.intel.com (Postfix) with ESMTP id B828A11FA93; Mon, 20 Jan 2025 13:02:01 +0200 (EET) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Dan Scally , Jacopo Mondi , hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, bingbu.cao@intel.com, Tianshu Qiu , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Tomi Valkeinen , Raspberry Pi Kernel Maintenance , Florian Fainelli , Broadcom internal kernel review list , Maxime Coquelin , Alexandre Torgue , Benoit Parrot , Ricardo Ribalda , "Duc-Long, Le" Subject: [PATCH v10 1/9] media: v4l: Support passing media pad argument to v4l2_get_link_freq() Date: Mon, 20 Jan 2025 13:01:49 +0200 Message-Id: <20250120110157.152732-2-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250120110157.152732-1-sakari.ailus@linux.intel.com> References: <20250120110157.152732-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 v4l2_get_link_freq() accepts a V4L2 control handler for now, but it needs to take struct media_pad argument in order to obtain the link frequency using get_mbus_config() pad op. Prepare for this by allowing struct media_pad as well. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-common.c | 21 ++++++++++++++++++--- include/media/v4l2-common.h | 19 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c index 0a2f4f0d0a07..9fe74c7e064f 100644 --- a/drivers/media/v4l2-core/v4l2-common.c +++ b/drivers/media/v4l2-core/v4l2-common.c @@ -466,8 +466,8 @@ int v4l2_fill_pixfmt(struct v4l2_pix_format *pixfmt, u32 pixelformat, } EXPORT_SYMBOL_GPL(v4l2_fill_pixfmt); -s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul, - unsigned int div) +s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler, + unsigned int mul, unsigned int div) { struct v4l2_ctrl *ctrl; s64 freq; @@ -502,7 +502,22 @@ s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul, return freq > 0 ? freq : -EINVAL; } -EXPORT_SYMBOL_GPL(v4l2_get_link_freq); +EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_ctrl); + +#ifdef CONFIG_MEDIA_CONTROLLER +s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, + unsigned int div) +{ + struct v4l2_subdev *sd; + + sd = media_entity_to_v4l2_subdev(pad->entity); + if (!sd) + return -ENODEV; + + return __v4l2_get_link_freq_ctrl(sd->ctrl_handler, mul, div); +} +EXPORT_SYMBOL_GPL(__v4l2_get_link_freq_pad); +#endif /* CONFIG_MEDIA_CONTROLLER */ /* * Simplify a fraction using a simple continued fraction decomposition. The diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h index 63ad36f04f72..fda903bb3674 100644 --- a/include/media/v4l2-common.h +++ b/include/media/v4l2-common.h @@ -525,7 +525,8 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, /** * v4l2_get_link_freq - Get link rate from transmitter * - * @handler: The transmitter's control handler + * @pad: The transmitter's media pad (or control handler for non-MC users or + * compatibility reasons, don't use in new code) * @mul: The multiplier between pixel rate and link frequency. Bits per pixel on * D-PHY, samples per clock on parallel. 0 otherwise. * @div: The divisor between pixel rate and link frequency. Number of data lanes @@ -541,8 +542,20 @@ int v4l2_fill_pixfmt_mp(struct v4l2_pix_format_mplane *pixfmt, u32 pixelformat, * * %-ENOENT: Link frequency or pixel rate control not found * * %-EINVAL: Invalid link frequency value */ -s64 v4l2_get_link_freq(struct v4l2_ctrl_handler *handler, unsigned int mul, - unsigned int div); +#ifdef CONFIG_MEDIA_CONTROLLER +#define v4l2_get_link_freq(pad, mul, div) \ + _Generic(pad, \ + struct media_pad *: __v4l2_get_link_freq_pad, \ + struct v4l2_ctrl_handler *: __v4l2_get_link_freq_ctrl) \ + (pad, mul, div) +s64 __v4l2_get_link_freq_pad(struct media_pad *pad, unsigned int mul, + unsigned int div); +#else +#define v4l2_get_link_freq(handler, mul, div) \ + __v4l2_get_link_freq_ctrl(handler, mul, div) +#endif +s64 __v4l2_get_link_freq_ctrl(struct v4l2_ctrl_handler *handler, + unsigned int mul, unsigned int div); void v4l2_simplify_fraction(u32 *numerator, u32 *denominator, unsigned int n_terms, unsigned int threshold); From patchwork Mon Jan 20 11:01:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 858843 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 977001991CD for ; Mon, 20 Jan 2025 11:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370944; cv=none; b=ZgHWIOlePIQEwTs7OWGM2Ibitn9IRlNvWi86wVR75FNHGFvi3ND8fuWDTeu3L9gjIlgdZZap+2Zt2goAfxhbsWdSdxb6OoAQVTwaXEY+Upo4Jn27z5NHajHKinRnFpNW5n2hD1mgqR6rRqdiAASHwYRL2Wok0PlC7P5s41iuWig= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370944; c=relaxed/simple; bh=Ss2le2bg2PCpLXGM/QUZlPmxsO2vDgpi7atAPfCy0ro=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YwxgQDXnWj4QjooeLSAMkLxW0EcenCZu5dQoKPYBWjDVOKGKi/aVRECw4WxBkE0D23HcrwYC4Y1G5zqU9y3vHvpi+1dO6A9xk3ssdxnQqllUzpAF5ZVmucOzLM4KjPY3a00CZMTEPvRG5xs5ciIUKpbfcyrV43/vi3c68lWbmyo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=c5J+qj/q; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="c5J+qj/q" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737370943; x=1768906943; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Ss2le2bg2PCpLXGM/QUZlPmxsO2vDgpi7atAPfCy0ro=; b=c5J+qj/qQQYiC4S/1FVO8nBACOTax4Gk9+qAO4JT5ul7kc5Eltv6cUMX zqJrL4h8J+FQ3UxdQWUYry6LWqpqN9+lk2vzTRTx0OqLJcIhlwhqCyCcP t/J3lixzTjbPf/nsv/N9BiSKYkaUmSaPR9pHXD5mF71CqT/X5KrR8Mm7q 75sarK3Z38LE+wEtSpxt+qmpW3uW8+8BPXg2UoSZmF1memfsSVZ7DqH1g T7GKu7EpIt1HdrENWV9u+scQJpRjJ66vOL7Qpql+j7b1acmb8w5HMgnM4 Yl0MZK1i1B03MHSAVMtNDz1j1914FOxX0sYnBudfdozbnI1NKlngaDlER w==; X-CSE-ConnectionGUID: J+GZRZU/RAu2NQA5A9uytg== X-CSE-MsgGUID: cyQKENpnSK6iiVvI7+gQ3g== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="37914566" X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="37914566" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:22 -0800 X-CSE-ConnectionGUID: kAXnqCquQTCD7yAwsfDslg== X-CSE-MsgGUID: Cq6C3OisRTSjd1xF0w9puw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="106491142" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:16 -0800 Received: from svinhufvud.intel.com (maa-artisokka.localdomain [192.168.240.50]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 7C6E9120289; Mon, 20 Jan 2025 13:02:09 +0200 (EET) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Dan Scally , Jacopo Mondi , hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, bingbu.cao@intel.com, Tianshu Qiu , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Tomi Valkeinen , Raspberry Pi Kernel Maintenance , Florian Fainelli , Broadcom internal kernel review list , Maxime Coquelin , Alexandre Torgue , Benoit Parrot , Ricardo Ribalda , "Duc-Long, Le" Subject: [PATCH v10 3/9] media: Documentation: Update link frequency driver documentation Date: Mon, 20 Jan 2025 13:01:51 +0200 Message-Id: <20250120110157.152732-4-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250120110157.152732-1-sakari.ailus@linux.intel.com> References: <20250120110157.152732-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 Add the get_mbus_config() as the means for conveying the link frequency towards the receiver drivers. Signed-off-by: Sakari Ailus --- Documentation/driver-api/media/tx-rx.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Documentation/driver-api/media/tx-rx.rst b/Documentation/driver-api/media/tx-rx.rst index c71003f74b1c..6f9eba189a9f 100644 --- a/Documentation/driver-api/media/tx-rx.rst +++ b/Documentation/driver-api/media/tx-rx.rst @@ -49,6 +49,10 @@ Link frequency The :ref:`V4L2_CID_LINK_FREQ ` control is used to tell the receiver the frequency of the bus (i.e. it is not the same as the symbol rate). +Drivers that do not have user-configurable link frequency should report it +through the ``.get_mbus_config()`` subdev pad operation, in the ``link_freq`` +field of struct v4l2_mbus_config, instead of through controls. + ``.enable_streams()`` and ``.disable_streams()`` callbacks ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From patchwork Mon Jan 20 11:01:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 858842 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 186DD1991CD for ; Mon, 20 Jan 2025 11:02:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370953; cv=none; b=d/jB4s8pOQFYkfv8vLNfgIHtty+ouEKx5BDc2UJ+MrLxbFidXGaf9/bEgyeEw9fNpiXGbFdj/roBt8bRd/mIqApQyfYXZuRBmK6ARELJoVCc3Awig5Vt4tD/lwq64hVcLiF85YGs0rCme9ZbRBP+RbFe0cHJblBfmqXuTWJVTIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370953; c=relaxed/simple; bh=znKITT5Hr+Rs5mEt6PfK6F5mPmB0LeLfkHLiW6maAp4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XkFP2V/H3JrbKjFtA4vOQYJ+xnCGl/i3FgnGM5+aBWROYVLR/3re/ixPT+ZI1llYT50tmPhCiC3Uk0L344ENMdpOQXQ9W6mG4E8lDU10hi9IPBiYYLS42paC9O8i/8vb4dF96W41ZlKoTMjo6bY7oZgzi9iCIFfE8FpsId8ihhk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=JkIBvvtF; arc=none smtp.client-ip=192.198.163.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="JkIBvvtF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737370952; x=1768906952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=znKITT5Hr+Rs5mEt6PfK6F5mPmB0LeLfkHLiW6maAp4=; b=JkIBvvtFRPapypfmweQq/kPlE87yYaePWVLFcNwprERS3NMj2hV1UYo9 7+4jc6H4mqgXuFB4Se1Vcs5AEwhkJ0E8x4hKOGMmtpD3ofjtRL0gu2zhy 2B/Us3y7FAAXFG+G5i3XyZx2EtC9SsEwjh31ZBAXRwGO/QQMLJJeR/dYR slD67oI52WGC950mxZRkjLIyocsC6tgjK0Ud2xNS3F5V9z7chK2OQbWAr 521zrtRJ6Hd3P8uZyGar/VEMCoPXkuQrPppOoFi1iP5yqwBglRu69J1+7 SQFVUBOd70gBqZ4rtXrUNOlyO1086L6GC1yfI+SjV/fEvZcCLijFVuq4y w==; X-CSE-ConnectionGUID: /6cvmps3Qf6yzuuWbk4A+w== X-CSE-MsgGUID: WOD6HYxESzmo+XHlxxRk2Q== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="37914636" X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="37914636" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:32 -0800 X-CSE-ConnectionGUID: u5C/eZiZRuWKU9Dt8NN5tg== X-CSE-MsgGUID: 7UYzEArZQNWeBqqNZLfiPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="106491655" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:24 -0800 Received: from svinhufvud.intel.com (maa-artisokka.localdomain [192.168.240.50]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 154F911FA93; Mon, 20 Jan 2025 13:02:17 +0200 (EET) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Dan Scally , Jacopo Mondi , hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, bingbu.cao@intel.com, Tianshu Qiu , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Tomi Valkeinen , Raspberry Pi Kernel Maintenance , Florian Fainelli , Broadcom internal kernel review list , Maxime Coquelin , Alexandre Torgue , Benoit Parrot , Ricardo Ribalda , "Duc-Long, Le" Subject: [PATCH v10 5/9] media: Documentation: Receiver drivers should call v4l2_get_link_freq() Date: Mon, 20 Jan 2025 13:01:53 +0200 Message-Id: <20250120110157.152732-6-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250120110157.152732-1-sakari.ailus@linux.intel.com> References: <20250120110157.152732-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 Document that receiver drivers should call v4l2_get_link_freq() to obtain the link frequency. Signed-off-by: Sakari Ailus Reviewed-by: Tomi Valkeinen --- Documentation/driver-api/media/tx-rx.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/driver-api/media/tx-rx.rst b/Documentation/driver-api/media/tx-rx.rst index 03768e5aa88f..0b8c9cde8ee4 100644 --- a/Documentation/driver-api/media/tx-rx.rst +++ b/Documentation/driver-api/media/tx-rx.rst @@ -53,6 +53,9 @@ Drivers that do not have user-configurable link frequency should report it through the ``.get_mbus_config()`` subdev pad operation, in the ``link_freq`` field of struct v4l2_mbus_config, instead of through controls. +Receiver drivers should use :c:func:`v4l2_get_link_freq` helper to obtain the +link frequency from the transmitter sub-device. + ``.enable_streams()`` and ``.disable_streams()`` callbacks ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ From patchwork Mon Jan 20 11:01:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 858841 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 ECABF1991CD for ; Mon, 20 Jan 2025 11:02:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370960; cv=none; b=A58klsAAIy9mPaAWssasKV0jOldqcsdEG8YyAaxLe4BDa+h6X/tbSUBN5b9wA5IPqX+XbzVtT9CtdOQPurel+24uQo1/ZOZ8+mLYtob2aOD5I7+4mm6smmvfv6KAvjW04Jk1ko9zM0TJ79xzcZ6vA7tqLireFlwUV4QvgQmaO/M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370960; c=relaxed/simple; bh=1Wo6DzJQ4R9NSy0NkAoyzj1nGHn7ooqeIImKTEXSWgQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=uSIbkGrSc7UisbjhRzMZWUXC86M0DAZhU/O/IQ7ZBvLVR1UIwWS2G8ZVDzdPVKgypZL48a+wqnW53FQmhNh+nWqywoZUhZwto0saZE8bM1qAxkr0V+YnMdp5zm86zhS1D+PGxr+fHm8dlo4T98hhaw2ZdWUEjqZmltHF9U8yBWc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=WwD32JVH; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="WwD32JVH" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737370959; x=1768906959; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1Wo6DzJQ4R9NSy0NkAoyzj1nGHn7ooqeIImKTEXSWgQ=; b=WwD32JVHlcxU2xKK8ddvttfPMwyyQCi45Rh7BMKjbTG38Xi5St5Pd3d1 DFq1qFl/lJclwCNCgIKhve8NbxE10e+ctNOVvwIFTljiY3o8qD7LtxFdN dnd/qFO31tnBYukCkgkgkKv1w1C07i2tcLRbIDRaJ8qzSq55dXTcoQWVD 8WXSvJlheZuH1vcp8HRpxigJbuTPKfyUEsKTAe+dK7ucZedcTWDN9v9TL gr1QMw7FQJUoRktIjE9Y+kMZPRVqetJu/yFkSsVyKKOy1nuU9R39t6pjV 7ulyDd9YPMaoFd7cpwZRD1991sRQbaMzbZw+ITy9nqyAr5z80LA6UFLIN w==; X-CSE-ConnectionGUID: eY7LbZSwRYGphf0B/uyj0w== X-CSE-MsgGUID: mf54lc2QRW+KcGXqctgUvg== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="41680351" X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="41680351" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:39 -0800 X-CSE-ConnectionGUID: g2uDzSInRje8rLj1I/JzFA== X-CSE-MsgGUID: ODUV8Da2QGKPqJmjFvtnKQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="106606515" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:32 -0800 Received: from svinhufvud.intel.com (maa-artisokka.localdomain [192.168.240.50]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 507E9120289; Mon, 20 Jan 2025 13:02:26 +0200 (EET) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Dan Scally , Jacopo Mondi , hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, bingbu.cao@intel.com, Tianshu Qiu , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Tomi Valkeinen , Raspberry Pi Kernel Maintenance , Florian Fainelli , Broadcom internal kernel review list , Maxime Coquelin , Alexandre Torgue , Benoit Parrot , Ricardo Ribalda , "Duc-Long, Le" Subject: [PATCH v10 7/9] media: intel/ipu6: Obtain link frequency from the remote subdev pad Date: Mon, 20 Jan 2025 13:01:55 +0200 Message-Id: <20250120110157.152732-8-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250120110157.152732-1-sakari.ailus@linux.intel.com> References: <20250120110157.152732-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 Obtain the link frequency from the sub-device's pad instead of a control handler. This allows obtaining it using the get_mbus_config() sub-device pad op which is the only method supported by the IVSC driver. Signed-off-by: Sakari Ailus --- drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c index 051898ce53f4..da8581a37e22 100644 --- a/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c +++ b/drivers/media/pci/intel/ipu6/ipu6-isys-csi2.c @@ -80,25 +80,19 @@ static const struct ipu6_csi2_error dphy_rx_errors[] = { s64 ipu6_isys_csi2_get_link_freq(struct ipu6_isys_csi2 *csi2) { struct media_pad *src_pad; - struct v4l2_subdev *ext_sd; - struct device *dev; if (!csi2) return -EINVAL; - dev = &csi2->isys->adev->auxdev.dev; src_pad = media_entity_remote_source_pad_unique(&csi2->asd.sd.entity); if (IS_ERR(src_pad)) { - dev_err(dev, "can't get source pad of %s (%ld)\n", + dev_err(&csi2->isys->adev->auxdev.dev, + "can't get source pad of %s (%ld)\n", csi2->asd.sd.name, PTR_ERR(src_pad)); return PTR_ERR(src_pad); } - ext_sd = media_entity_to_v4l2_subdev(src_pad->entity); - if (WARN(!ext_sd, "Failed to get subdev for %s\n", csi2->asd.sd.name)) - return -ENODEV; - - return v4l2_get_link_freq(ext_sd->ctrl_handler, 0, 0); + return v4l2_get_link_freq(src_pad, 0, 0); } static int csi2_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, From patchwork Mon Jan 20 11:01:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 858840 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 B3E451991CD for ; Mon, 20 Jan 2025 11:02:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370970; cv=none; b=qKDgz0wdysJI8opii+gE6NUCbEMugO+bwgIiAm31j4bGiDCrUmMFN3gOD/FD6vAdOrUu9fGhNWv7mfOhpIcrwQn2tfAhUXEmTfOace6AVh+8yfH0ww7Qi1nFyNaWb8ewY7mslHh9CUfcnrHdkn2AHx8gUIRoKTgYL3Msw5Wd67A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737370970; c=relaxed/simple; bh=gzLZu75xGxxtAjjZqpJNfiYIv2ZYJpbEvARLlKEwjkY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pw5kPFuAJtpS2oHUJDNJQrIvPzSbx3160dDuGtu8FM6BJUBx3E5X0xM2IewtsxUlmhOH7l4gAHUf4Yl45PkgtplfNzIcK1YE9r/B1NlCLvGdJKtFfHQ/XB9uOw2eWpCp/5G1px+c1rFAVde2LlO3Rj4NUXgbZNa6dUh3Il4FZaY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=BfuY0LVa; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none 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="BfuY0LVa" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1737370969; x=1768906969; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gzLZu75xGxxtAjjZqpJNfiYIv2ZYJpbEvARLlKEwjkY=; b=BfuY0LVaWUWtKMgTU1bWYd7mPHbnuOAvAclQk4/gRbGAP4sosahW2Ypc 2kZ5gU0A+Ow+nRm2kNllHHlrcdTGYPkN0f9AuTx884R0tTyclLrZpN8Bd YJP8UFk3C5UfdF1cXh3COfP1tZeu9cReMeHyq1SdIkjpEVP0un2abkq8g OEUAe186bb2aOVazX4sieA/7ehuDNKx5V7xoW6wfjJ/+qGrenwEt+KqCg ODlAMpTN65LcdtkHW841owMm27hLIsVOQsfzXuzrlHmPGdNu1HU/uoXTy 5PBGyQgewhL0qEVIN90L2gqaC69PoGKELtBDguedixc6wVfrOj8oJw1oC g==; X-CSE-ConnectionGUID: Mk7IJ0g5TR+qR9qZAErSNg== X-CSE-MsgGUID: Ikt/sYVLSyehzuuJzhz0tw== X-IronPort-AV: E=McAfee;i="6700,10204,11320"; a="41680385" X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="41680385" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:48 -0800 X-CSE-ConnectionGUID: Xul+0viDQxm/4oSjG1J+hQ== X-CSE-MsgGUID: UtVt4DLCR2qP+o7JcCULBw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.13,218,1732608000"; d="scan'208";a="106606550" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2025 03:02:40 -0800 Received: from svinhufvud.intel.com (maa-artisokka.localdomain [192.168.240.50]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 5BD7111FA93; Mon, 20 Jan 2025 13:02:34 +0200 (EET) Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Benjamin Mugnier , Sylvain Petinot , Yong Zhi , Dan Scally , Jacopo Mondi , hverkuil@xs4all.nl, laurent.pinchart@ideasonboard.com, bingbu.cao@intel.com, Tianshu Qiu , Maxime Ripard , Rui Miguel Silva , Martin Kepplinger , Purism Kernel Team , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Robert Foss , Todor Tomov , Bryan O'Donoghue , Tomi Valkeinen , Raspberry Pi Kernel Maintenance , Florian Fainelli , Broadcom internal kernel review list , Maxime Coquelin , Alexandre Torgue , Benoit Parrot , Ricardo Ribalda , "Duc-Long, Le" Subject: [PATCH v10 9/9] media: v4l: Convert the users of v4l2_get_link_freq to call it on a pad Date: Mon, 20 Jan 2025 13:01:57 +0200 Message-Id: <20250120110157.152732-10-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250120110157.152732-1-sakari.ailus@linux.intel.com> References: <20250120110157.152732-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 Call v4l2_get_link_freq() on a pad, instead of a control handler. This way we can soon convert v4l2_get_link_freq() to be callable only on a pad and remove the compatibility code. Signed-off-by: Sakari Ailus Acked-by: Naushir Patuck # rp1-cfe Acked-by: Benjamin Mugnier # st-mipid02 --- drivers/media/i2c/st-mipid02.c | 5 ++-- drivers/media/i2c/tc358746.c | 4 ++- drivers/media/pci/intel/ipu3/ipu3-cio2.c | 11 +++++--- drivers/media/platform/cadence/cdns-csi2rx.c | 4 ++- drivers/media/platform/nxp/imx-mipi-csis.c | 5 ++-- drivers/media/platform/nxp/imx8mq-mipi-csi2.c | 11 ++++++-- .../media/platform/qcom/camss/camss-vfe-17x.c | 9 ++++--- .../platform/qcom/camss/camss-vfe-gen1.c | 9 ++++--- drivers/media/platform/qcom/camss/camss.c | 27 +++++++++---------- drivers/media/platform/qcom/camss/camss.h | 2 +- .../media/platform/raspberrypi/rp1-cfe/cfe.c | 4 ++- drivers/media/platform/st/stm32/stm32-csi.c | 4 ++- drivers/media/platform/ti/cal/cal-camerarx.c | 3 ++- drivers/media/platform/ti/cal/cal.c | 4 ++- drivers/media/platform/ti/cal/cal.h | 1 + 15 files changed, 64 insertions(+), 39 deletions(-) diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c index f08db3cfe076..f4568e87f018 100644 --- a/drivers/media/i2c/st-mipid02.c +++ b/drivers/media/i2c/st-mipid02.c @@ -301,8 +301,9 @@ static int mipid02_detect(struct mipid02_dev *bridge) static int mipid02_configure_from_rx_speed(struct mipid02_dev *bridge, struct v4l2_mbus_framefmt *fmt) { + struct media_pad *remote = + &bridge->s_subdev->entity.pads[bridge->s_subdev_pad_id]; struct i2c_client *client = bridge->i2c_client; - struct v4l2_subdev *subdev = bridge->s_subdev; struct v4l2_fwnode_endpoint *ep = &bridge->rx; u32 bpp = bpp_from_code(fmt->code); /* @@ -312,7 +313,7 @@ static int mipid02_configure_from_rx_speed(struct mipid02_dev *bridge, u64 ui_4 = 2000000000; s64 link_freq; - link_freq = v4l2_get_link_freq(subdev->ctrl_handler, bpp, + link_freq = v4l2_get_link_freq(remote, bpp, 2 * ep->bus.mipi_csi2.num_data_lanes); if (link_freq < 0) { dev_err(&client->dev, "Failed to get link frequency"); diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index 389582420ba7..31586f8e4be4 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -896,6 +896,7 @@ tc358746_link_validate(struct v4l2_subdev *sd, struct media_link *link, const struct tc358746_format *fmt; unsigned int fifo_sz, tmp, n; struct v4l2_subdev *source; + struct media_pad *src_pad; s64 source_link_freq; int err; @@ -910,7 +911,8 @@ tc358746_link_validate(struct v4l2_subdev *sd, struct media_link *link, fmt = tc358746_get_format_by_code(TC358746_SINK, mbusfmt->code); source = media_entity_to_v4l2_subdev(link->source->entity); - source_link_freq = v4l2_get_link_freq(source->ctrl_handler, 0, 0); + src_pad = &source->entity.pads[source_fmt->pad]; + source_link_freq = v4l2_get_link_freq(src_pad, 0, 0); if (source_link_freq <= 0) { dev_err(tc358746->sd.dev, "Failed to query or invalid source link frequency\n"); diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c index 4e98f432ed55..7731eb70fc8e 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c @@ -309,12 +309,17 @@ static int cio2_csi2_calc_timing(struct cio2_device *cio2, struct cio2_queue *q, unsigned int bpp, unsigned int lanes) { struct device *dev = &cio2->pci_dev->dev; + struct media_pad *src_pad; s64 freq; - if (!q->sensor) - return -ENODEV; + src_pad = media_entity_remote_source_pad_unique(&q->subdev.entity); + if (IS_ERR(src_pad)) { + dev_err(dev, "can't get source pad of %s (%ld)\n", + q->subdev.name, PTR_ERR(src_pad)); + return PTR_ERR(src_pad); + } - freq = v4l2_get_link_freq(q->sensor->ctrl_handler, bpp, lanes * 2); + freq = v4l2_get_link_freq(src_pad, bpp, lanes * 2); if (freq < 0) { dev_err(dev, "error %lld, invalid link_freq\n", freq); return freq; diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c index 4d64df829e75..cebcae196eec 100644 --- a/drivers/media/platform/cadence/cdns-csi2rx.c +++ b/drivers/media/platform/cadence/cdns-csi2rx.c @@ -164,6 +164,8 @@ static void csi2rx_reset(struct csi2rx_priv *csi2rx) static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) { + struct media_pad *src_pad = + &csi2rx->source_subdev->entity.pads[csi2rx->source_pad]; union phy_configure_opts opts = { }; struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; struct v4l2_subdev_format sd_fmt = { @@ -181,7 +183,7 @@ static int csi2rx_configure_ext_dphy(struct csi2rx_priv *csi2rx) fmt = csi2rx_get_fmt_by_code(sd_fmt.format.code); - link_freq = v4l2_get_link_freq(csi2rx->source_subdev->ctrl_handler, + link_freq = v4l2_get_link_freq(src_pad, fmt->bpp, 2 * csi2rx->num_lanes); if (link_freq < 0) return link_freq; diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index 29523bb84d95..d060eadebc7a 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -597,12 +597,13 @@ static void __mipi_csis_set_format(struct mipi_csis_device *csis, static int mipi_csis_calculate_params(struct mipi_csis_device *csis, const struct csis_pix_format *csis_fmt) { + struct media_pad *src_pad = + &csis->source.sd->entity.pads[csis->source.pad->index]; s64 link_freq; u32 lane_rate; /* Calculate the line rate from the pixel rate. */ - link_freq = v4l2_get_link_freq(csis->source.sd->ctrl_handler, - csis_fmt->width, + link_freq = v4l2_get_link_freq(src_pad, csis_fmt->width, csis->bus.num_data_lanes * 2); if (link_freq < 0) { dev_err(csis->dev, "Unable to obtain link frequency: %d\n", diff --git a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c index 1f2657cf6e82..a8bcf60e2f37 100644 --- a/drivers/media/platform/nxp/imx8mq-mipi-csi2.c +++ b/drivers/media/platform/nxp/imx8mq-mipi-csi2.c @@ -287,6 +287,7 @@ static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state, struct v4l2_subdev_state *sd_state, u32 *hs_settle) { + struct media_pad *src_pad; s64 link_freq; u32 lane_rate; unsigned long esc_clk_rate; @@ -294,13 +295,19 @@ static int imx8mq_mipi_csi_calc_hs_settle(struct csi_state *state, const struct v4l2_mbus_framefmt *fmt; const struct csi2_pix_format *csi2_fmt; + src_pad = media_entity_remote_source_pad_unique(&sd_state->sd->entity); + if (IS_ERR(src_pad)) { + dev_err(state->dev, "can't get source pad of %s (%ld)\n", + sd_state->sd->name, PTR_ERR(src_pad)); + return PTR_ERR(src_pad); + } + /* Calculate the line rate from the pixel rate. */ fmt = v4l2_subdev_state_get_format(sd_state, MIPI_CSI2_PAD_SINK); csi2_fmt = find_csi2_format(fmt->code); - link_freq = v4l2_get_link_freq(state->src_sd->ctrl_handler, - csi2_fmt->width, + link_freq = v4l2_get_link_freq(src_pad, csi2_fmt->width, state->bus.num_data_lanes * 2); if (link_freq < 0) { dev_err(state->dev, "Unable to obtain link frequency: %d\n", diff --git a/drivers/media/platform/qcom/camss/camss-vfe-17x.c b/drivers/media/platform/qcom/camss/camss-vfe-17x.c index 380c99321030..b8af019f2f45 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-17x.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-17x.c @@ -443,14 +443,15 @@ static int vfe_enable_output(struct vfe_line *line) struct vfe_device *vfe = to_vfe(line); struct vfe_output *output = &line->output; const struct vfe_hw_ops *ops = vfe->res->hw_ops; - struct media_entity *sensor; + struct media_pad *sensor_pad; unsigned long flags; unsigned int frame_skip = 0; unsigned int i; - sensor = camss_find_sensor(&line->subdev.entity); - if (sensor) { - struct v4l2_subdev *subdev = media_entity_to_v4l2_subdev(sensor); + sensor_pad = camss_find_sensor_pad(&line->subdev.entity); + if (sensor_pad) { + struct v4l2_subdev *subdev = + media_entity_to_v4l2_subdev(sensor_pad->entity); v4l2_subdev_call(subdev, sensor, g_skip_frames, &frame_skip); /* Max frame skip is 29 frames */ diff --git a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c index eb33c03df27e..d84a375e3318 100644 --- a/drivers/media/platform/qcom/camss/camss-vfe-gen1.c +++ b/drivers/media/platform/qcom/camss/camss-vfe-gen1.c @@ -170,7 +170,7 @@ static int vfe_enable_output(struct vfe_line *line) struct vfe_device *vfe = to_vfe(line); struct vfe_output *output = &line->output; const struct vfe_hw_ops *ops = vfe->res->hw_ops; - struct media_entity *sensor; + struct media_pad *sensor_pad; unsigned long flags; unsigned int frame_skip = 0; unsigned int i; @@ -180,9 +180,10 @@ static int vfe_enable_output(struct vfe_line *line) if (!ub_size) return -EINVAL; - sensor = camss_find_sensor(&line->subdev.entity); - if (sensor) { - struct v4l2_subdev *subdev = media_entity_to_v4l2_subdev(sensor); + sensor_pad = camss_find_sensor_pad(&line->subdev.entity); + if (sensor_pad) { + struct v4l2_subdev *subdev = + media_entity_to_v4l2_subdev(sensor_pad->entity); v4l2_subdev_call(subdev, sensor, g_skip_frames, &frame_skip); /* Max frame skip is 29 frames */ diff --git a/drivers/media/platform/qcom/camss/camss.c b/drivers/media/platform/qcom/camss/camss.c index a85e9df0f301..9a3dff9a55ec 100644 --- a/drivers/media/platform/qcom/camss/camss.c +++ b/drivers/media/platform/qcom/camss/camss.c @@ -1996,12 +1996,12 @@ void camss_disable_clocks(int nclocks, struct camss_clock *clock) } /* - * camss_find_sensor - Find a linked media entity which represents a sensor + * camss_find_sensor_pad - Find the media pad via which the sensor is linked * @entity: Media entity to start searching from * - * Return a pointer to sensor media entity or NULL if not found + * Return a pointer to sensor media pad or NULL if not found */ -struct media_entity *camss_find_sensor(struct media_entity *entity) +struct media_pad *camss_find_sensor_pad(struct media_entity *entity) { struct media_pad *pad; @@ -2017,7 +2017,7 @@ struct media_entity *camss_find_sensor(struct media_entity *entity) entity = pad->entity; if (entity->function == MEDIA_ENT_F_CAM_SENSOR) - return entity; + return pad; } } @@ -2032,16 +2032,13 @@ struct media_entity *camss_find_sensor(struct media_entity *entity) s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp, unsigned int lanes) { - struct media_entity *sensor; - struct v4l2_subdev *subdev; + struct media_pad *sensor_pad; - sensor = camss_find_sensor(entity); - if (!sensor) + sensor_pad = camss_find_sensor_pad(entity); + if (!sensor_pad) return -ENODEV; - subdev = media_entity_to_v4l2_subdev(sensor); - - return v4l2_get_link_freq(subdev->ctrl_handler, bpp, 2 * lanes); + return v4l2_get_link_freq(sensor_pad, bpp, 2 * lanes); } /* @@ -2053,15 +2050,15 @@ s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp, */ int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock) { - struct media_entity *sensor; + struct media_pad *sensor_pad; struct v4l2_subdev *subdev; struct v4l2_ctrl *ctrl; - sensor = camss_find_sensor(entity); - if (!sensor) + sensor_pad = camss_find_sensor_pad(entity); + if (!sensor_pad) return -ENODEV; - subdev = media_entity_to_v4l2_subdev(sensor); + subdev = media_entity_to_v4l2_subdev(sensor_pad->entity); ctrl = v4l2_ctrl_find(subdev->ctrl_handler, V4L2_CID_PIXEL_RATE); diff --git a/drivers/media/platform/qcom/camss/camss.h b/drivers/media/platform/qcom/camss/camss.h index 9a046eea334f..f912a58ae070 100644 --- a/drivers/media/platform/qcom/camss/camss.h +++ b/drivers/media/platform/qcom/camss/camss.h @@ -153,7 +153,7 @@ void camss_add_clock_margin(u64 *rate); int camss_enable_clocks(int nclocks, struct camss_clock *clock, struct device *dev); void camss_disable_clocks(int nclocks, struct camss_clock *clock); -struct media_entity *camss_find_sensor(struct media_entity *entity); +struct media_pad *camss_find_sensor_pad(struct media_entity *entity); s64 camss_get_link_freq(struct media_entity *entity, unsigned int bpp, unsigned int lanes); int camss_get_pixel_clock(struct media_entity *entity, u64 *pixel_clock); diff --git a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c index 12660087b12f..ed3d18917f2d 100644 --- a/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c +++ b/drivers/media/platform/raspberrypi/rp1-cfe/cfe.c @@ -1102,6 +1102,8 @@ static void cfe_buffer_queue(struct vb2_buffer *vb) static s64 cfe_get_source_link_freq(struct cfe_device *cfe) { + struct media_pad *src_pad = + &cfe->source_sd->entity.pads[cfe->source_pad]; struct v4l2_subdev_state *state; s64 link_freq; u32 bpp; @@ -1136,7 +1138,7 @@ static s64 cfe_get_source_link_freq(struct cfe_device *cfe) bpp = 0; } - link_freq = v4l2_get_link_freq(cfe->source_sd->ctrl_handler, bpp, + link_freq = v4l2_get_link_freq(src_pad, bpp, 2 * cfe->csi2.dphy.active_lanes); if (link_freq < 0) cfe_err(cfe, "failed to get link freq for subdev '%s'\n", diff --git a/drivers/media/platform/st/stm32/stm32-csi.c b/drivers/media/platform/st/stm32/stm32-csi.c index 48941aae8c9b..b25afeee4f24 100644 --- a/drivers/media/platform/st/stm32/stm32-csi.c +++ b/drivers/media/platform/st/stm32/stm32-csi.c @@ -444,6 +444,8 @@ static void stm32_csi_phy_reg_write(struct stm32_csi_dev *csidev, static int stm32_csi_start(struct stm32_csi_dev *csidev, struct v4l2_subdev_state *state) { + struct media_pad *src_pad = + &csidev->s_subdev->entity.pads[csidev->s_subdev_pad_nb]; const struct stm32_csi_mbps_phy_reg *phy_regs; struct v4l2_mbus_framefmt *sink_fmt; const struct stm32_csi_fmts *fmt; @@ -465,7 +467,7 @@ static int stm32_csi_start(struct stm32_csi_dev *csidev, if (!csidev->s_subdev) return -EIO; - link_freq = v4l2_get_link_freq(csidev->s_subdev->ctrl_handler, + link_freq = v4l2_get_link_freq(src_pad, fmt->bpp, 2 * csidev->num_lanes); if (link_freq < 0) return link_freq; diff --git a/drivers/media/platform/ti/cal/cal-camerarx.c b/drivers/media/platform/ti/cal/cal-camerarx.c index 42dfe08b765f..9cc875665695 100644 --- a/drivers/media/platform/ti/cal/cal-camerarx.c +++ b/drivers/media/platform/ti/cal/cal-camerarx.c @@ -65,7 +65,8 @@ static s64 cal_camerarx_get_ext_link_freq(struct cal_camerarx *phy) bpp = fmtinfo->bpp; - freq = v4l2_get_link_freq(phy->source->ctrl_handler, bpp, 2 * num_lanes); + freq = v4l2_get_link_freq(&phy->source->entity.pads[phy->source_pad], + bpp, 2 * num_lanes); if (freq < 0) { phy_err(phy, "failed to get link freq for subdev '%s'\n", phy->source->name); diff --git a/drivers/media/platform/ti/cal/cal.c b/drivers/media/platform/ti/cal/cal.c index 4bd2092e0255..6cb3e5f49686 100644 --- a/drivers/media/platform/ti/cal/cal.c +++ b/drivers/media/platform/ti/cal/cal.c @@ -798,7 +798,6 @@ static int cal_async_notifier_bound(struct v4l2_async_notifier *notifier, return 0; } - phy->source = subdev; phy_dbg(1, phy, "Using source %s for capture\n", subdev->name); pad = media_entity_get_fwnode_pad(&subdev->entity, @@ -820,6 +819,9 @@ static int cal_async_notifier_bound(struct v4l2_async_notifier *notifier, return ret; } + phy->source = subdev; + phy->source_pad = pad; + return 0; } diff --git a/drivers/media/platform/ti/cal/cal.h b/drivers/media/platform/ti/cal/cal.h index 0856297adc0b..72a246a64d9e 100644 --- a/drivers/media/platform/ti/cal/cal.h +++ b/drivers/media/platform/ti/cal/cal.h @@ -174,6 +174,7 @@ struct cal_camerarx { struct device_node *source_ep_node; struct device_node *source_node; struct v4l2_subdev *source; + unsigned int source_pad; struct v4l2_subdev subdev; struct media_pad pads[CAL_CAMERARX_NUM_PADS];