From patchwork Tue Jun 14 19:10:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881388 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BA24C433EF for ; Tue, 14 Jun 2022 19:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344966AbiFNTLz (ORCPT ); Tue, 14 Jun 2022 15:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233902AbiFNTLx (ORCPT ); Tue, 14 Jun 2022 15:11:53 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F9CD205CF for ; Tue, 14 Jun 2022 12:11:52 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 23DB39E5; Tue, 14 Jun 2022 21:11:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233910; bh=/A1n8h0CJ9AcyNo5dUhvyUtS5N+++2CIezT6d2+7DJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pFjHNOvbILdbCTyyqoEV1/XPDJygKqcczgBSnLsgH3e40/JKlU2PDRSWV185m7Pm3 S3KMShJkf2fdO8Za+rnzU84qZ+xL+Y63v6A2ykEHtwWKJldv4bAh8iZpl+LqySQ5BV RvSvbinzWrIpEMzYI7phGRNQmbEfxDCxFtYC+ioE= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 01/55] media: rkisp1: debug: Add dump file in debugfs for MI buffer registers Date: Wed, 15 Jun 2022 04:10:33 +0900 Message-Id: <20220614191127.3420492-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add a register dump file in debugfs for some of the buffer-related registers in MI, for the base address, the size, and the offset. Also dump the appropriate shadow registers. Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-debug.c | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c index e76dc2b164b6..1a59c00fabdd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c @@ -121,6 +121,24 @@ static int rkisp1_debug_dump_rsz_regs_show(struct seq_file *m, void *p) } DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_dump_rsz_regs); +static int rkisp1_debug_dump_mi_mp_y_offs_cnt_show(struct seq_file *m, void *p) +{ + static const struct rkisp1_debug_register registers[] = { + RKISP1_DEBUG_REG(MI_MP_Y_BASE_AD_INIT), + RKISP1_DEBUG_REG(MI_MP_Y_BASE_AD_INIT2), + RKISP1_DEBUG_REG(MI_MP_Y_BASE_AD_SHD), + RKISP1_DEBUG_REG(MI_MP_Y_SIZE_INIT), + RKISP1_DEBUG_REG(MI_MP_Y_SIZE_INIT), + RKISP1_DEBUG_REG(MI_MP_Y_SIZE_SHD), + RKISP1_DEBUG_REG(MI_MP_Y_OFFS_CNT_SHD), + { /* Sentinel */ }, + }; + struct rkisp1_device *rkisp1 = m->private; + + return rkisp1_debug_dump_regs(rkisp1, m, 0, registers); +} +DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_dump_mi_mp_y_offs_cnt); + #define RKISP1_DEBUG_DATA_COUNT_BINS 32 #define RKISP1_DEBUG_DATA_COUNT_STEP (4096 / RKISP1_DEBUG_DATA_COUNT_BINS) @@ -214,6 +232,9 @@ void rkisp1_debug_init(struct rkisp1_device *rkisp1) debugfs_create_file("srsz", 0444, regs_dir, &rkisp1->resizer_devs[RKISP1_SELFPATH], &rkisp1_debug_dump_rsz_regs_fops); + + debugfs_create_file("mi_mp_y_bufs", 0444, regs_dir, rkisp1, + &rkisp1_debug_dump_mi_mp_y_offs_cnt_fops); } void rkisp1_debug_cleanup(struct rkisp1_device *rkisp1) From patchwork Tue Jun 14 19:10:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881389 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D70CC43334 for ; Tue, 14 Jun 2022 19:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344995AbiFNTL6 (ORCPT ); Tue, 14 Jun 2022 15:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344974AbiFNTL5 (ORCPT ); Tue, 14 Jun 2022 15:11:57 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6085620BE3 for ; Tue, 14 Jun 2022 12:11:56 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 99047D96; Tue, 14 Jun 2022 21:11:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233915; bh=8Hn75V1y68nA6PNjFyCUT/vHLq089MhAP7Ng3rcz9GA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+LNyxOyTQmXenvtvb6txcxZWdDiv0RfDhvaULhowwRffUDMMZbLaP1MNczsJsPY0 dIU+pspfCe3x4vPN0tGCvLQjtMfoE6Fh/ypHPsUXE+ea6fDcYSkyCtm5JhzdSEMgSO RgyxBMIdHymU9qw/ODDi6qtn6cwMTO7qXWBh6N3w= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 02/55] media: rkisp1: Enable compilation on ARCH_MXC Date: Wed, 15 Jun 2022 04:10:34 +0900 Message-Id: <20220614191127.3420492-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ISP used by the Rockchip RK3399 is also found in the NXP i.MX8MP. Enable compilation of the driver for the MXC architecture in addition to ARCH_ROCKCHIP. Signed-off-by: Laurent Pinchart Reviewed-by: Dafna Hirschfeld --- drivers/media/platform/rockchip/rkisp1/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/Kconfig b/drivers/media/platform/rockchip/rkisp1/Kconfig index dabd7e42c193..731c9acbf6ef 100644 --- a/drivers/media/platform/rockchip/rkisp1/Kconfig +++ b/drivers/media/platform/rockchip/rkisp1/Kconfig @@ -3,7 +3,7 @@ config VIDEO_ROCKCHIP_ISP1 tristate "Rockchip Image Signal Processing v1 Unit driver" depends on V4L_PLATFORM_DRIVERS depends on VIDEO_DEV && OF - depends on ARCH_ROCKCHIP || COMPILE_TEST + depends on ARCH_ROCKCHIP || ARCH_MXC || COMPILE_TEST select MEDIA_CONTROLLER select VIDEO_V4L2_SUBDEV_API select VIDEOBUF2_DMA_CONTIG From patchwork Tue Jun 14 19:10:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881391 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C251DCCA47A for ; Tue, 14 Jun 2022 19:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345170AbiFNTMH (ORCPT ); Tue, 14 Jun 2022 15:12:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245174AbiFNTMG (ORCPT ); Tue, 14 Jun 2022 15:12:06 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 287C320BC5 for ; Tue, 14 Jun 2022 12:12:01 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C036AF95; Tue, 14 Jun 2022 21:11:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233919; bh=kFkq9EYQIYVYHtcJ4C11CNQqT3UkvhgAxURDV/zltyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tb9ZhQwoW6KiLThS8fkam+w+mRotLEPZ0SszpXIfNe0D27QAYBarRr9fnLHEALkC6 OtzDab+vvXYa9ojnF6XzFiMEEqixPz/YrSRUWVsYsB7H+Cv9OYJTe2MHIPbwsne60N UG5w/0Ji5GVMHOQZBYLJQCTCLj2f3VoFq1nY4SMY= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 03/55] media: rkisp1: debug: Add debugfs files to monitor MI and ISP interrupts Date: Wed, 15 Jun 2022 04:10:35 +0900 Message-Id: <20220614191127.3420492-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add files in debugfs to monitor some of the interrupts of the MI and ISP. Add the appropriate holder variables in the rkisp1_debug struct as well. Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-common.h | 9 +++++++++ .../platform/rockchip/rkisp1/rkisp1-debug.c | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 4243ff5e2197..a67fe7b1dfa1 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -364,6 +364,15 @@ struct rkisp1_debug { unsigned long stats_error; unsigned long stop_timeout[2]; unsigned long frame_drop[2]; + unsigned long mi_irq_mblk_line_count; + unsigned long mi_irq_fill_mp_y_count; + unsigned long mi_irq_frame_count; + unsigned long mi_irq_wrap_mp_y_count; + unsigned long mi_irq_wrap_mp_cb_count; + unsigned long mi_irq_wrap_mp_cr_count; + unsigned long isp_irq_v_start_count; + unsigned long isp_irq_frame_count; + unsigned long isp_irq_frame_in_count; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c index 1a59c00fabdd..02854e8ea1a4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c @@ -220,6 +220,26 @@ void rkisp1_debug_init(struct rkisp1_device *rkisp1) debugfs_create_file("input_status", 0444, debug->debugfs_dir, rkisp1, &rkisp1_debug_input_status_fops); + debugfs_create_ulong("mi_irq_mblk_line_count", 0444, debug->debugfs_dir, + &debug->mi_irq_mblk_line_count); + debugfs_create_ulong("mi_irq_fill_mp_y_count", 0444, debug->debugfs_dir, + &debug->mi_irq_fill_mp_y_count); + debugfs_create_ulong("mi_irq_frame_count", 0444, debug->debugfs_dir, + &debug->mi_irq_frame_count); + debugfs_create_ulong("mi_irq_wrap_mp_y_count", 0444, debug->debugfs_dir, + &debug->mi_irq_wrap_mp_y_count); + debugfs_create_ulong("mi_irq_wrap_mp_cb_count", 0444, debug->debugfs_dir, + &debug->mi_irq_wrap_mp_cb_count); + debugfs_create_ulong("mi_irq_wrap_mp_cr_count", 0444, debug->debugfs_dir, + &debug->mi_irq_wrap_mp_cr_count); + + debugfs_create_ulong("isp_irq_v_start_count", 0444, debug->debugfs_dir, + &debug->isp_irq_v_start_count); + debugfs_create_ulong("isp_irq_frame_count", 0444, debug->debugfs_dir, + &debug->isp_irq_frame_count); + debugfs_create_ulong("isp_irq_frame_in_count", 0444, debug->debugfs_dir, + &debug->isp_irq_frame_in_count); + regs_dir = debugfs_create_dir("regs", debug->debugfs_dir); debugfs_create_file("core", 0444, regs_dir, rkisp1, From patchwork Tue Jun 14 19:10:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881390 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49BF7C433EF for ; Tue, 14 Jun 2022 19:12:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345110AbiFNTMG (ORCPT ); Tue, 14 Jun 2022 15:12:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344974AbiFNTMF (ORCPT ); Tue, 14 Jun 2022 15:12:05 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EDA7205E8 for ; Tue, 14 Jun 2022 12:12:05 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3D828825; Tue, 14 Jun 2022 21:11:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233923; bh=tJJflPFb86Dv38xnb6QyNuWk1nEBEVkZYbxSu526cQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlPqyOkqL0uEU1FiFjRFqYfaKXWDtbAHR2N8NpgZq/IjdjY6isSvC2+vvrZsI2LCF LzmPk0e4bOgEKMtybMuJRtZ/2jM8DqYYclgcEL/JpEyfQ2llIhC3LiU8e8qqLgOWnJ sm8SFuFixeE3t0ZiK8MPBCrh3T9v2AHceisIloyA= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 04/55] media: rkisp1: Disable runtime PM in probe error path Date: Wed, 15 Jun 2022 04:10:36 +0900 Message-Id: <20220614191127.3420492-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart If the v4l2_device_register() call fails, runtime PM is left enabled. Fix it. Signed-off-by: Laurent Pinchart Reviewed-by: Dafna Hirschfeld --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 97d569968285..248f0172ca62 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -523,7 +523,7 @@ static int rkisp1_probe(struct platform_device *pdev) ret = v4l2_device_register(rkisp1->dev, &rkisp1->v4l2_dev); if (ret) - return ret; + goto err_pm_runtime_disable; ret = media_device_register(&rkisp1->media_dev); if (ret) { @@ -543,6 +543,7 @@ static int rkisp1_probe(struct platform_device *pdev) media_device_unregister(&rkisp1->media_dev); err_unreg_v4l2_dev: v4l2_device_unregister(&rkisp1->v4l2_dev); +err_pm_runtime_disable: pm_runtime_disable(&pdev->dev); return ret; } From patchwork Tue Jun 14 19:10:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881392 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996BACCA47A for ; Tue, 14 Jun 2022 19:12:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345187AbiFNTML (ORCPT ); Tue, 14 Jun 2022 15:12:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245174AbiFNTMK (ORCPT ); Tue, 14 Jun 2022 15:12:10 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E833205CF for ; Tue, 14 Jun 2022 12:12:09 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 697FF9E5; Tue, 14 Jun 2022 21:12:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233927; bh=MN+k+386HwfC89iXMHL522rxnVO8f8e0jWiEPtZXKlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oL09Tb7mRFKMOrMiHIzBgkQnQjP2jQciWy6gmtnoJNDVXOWV5G9c8DiM+p4N6e7nO CpI7HCu92KAEQYQpZfRL1TC4Lgu/LDgtknVIFuiYOf/DA0ShYssLg/30CI1pOUFiwu /YlXessdkT6w9ajLpqGTQNo+hN/sMo8+0TEAQe24= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 05/55] media: rkisp1: Read the ID register at probe time instead of streamon Date: Wed, 15 Jun 2022 04:10:37 +0900 Message-Id: <20220614191127.3420492-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart There's no need to read the ID register every time streaming is started. Do it once, at probe time. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 10 ++++++++++ drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 4 ---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 248f0172ca62..ba773c0784fb 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -467,6 +467,7 @@ static int rkisp1_probe(struct platform_device *pdev) struct v4l2_device *v4l2_dev; unsigned int i; int ret, irq; + u32 cif_id; match_data = of_device_get_match_data(&pdev->dev); if (!match_data) @@ -509,6 +510,15 @@ static int rkisp1_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); + if (ret) + goto err_pm_runtime_disable; + + cif_id = rkisp1_read(rkisp1, RKISP1_CIF_VI_ID); + dev_dbg(rkisp1->dev, "CIF_ID 0x%08x\n", cif_id); + + pm_runtime_put(&pdev->dev); + rkisp1->media_dev.hw_revision = match_data->isp_ver; strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME, sizeof(rkisp1->media_dev.model)); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 187d78075acb..02968656f3c0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -473,12 +473,8 @@ static int rkisp1_config_path(struct rkisp1_device *rkisp1) /* Hardware configure Entry */ static int rkisp1_config_cif(struct rkisp1_device *rkisp1) { - u32 cif_id; int ret; - cif_id = rkisp1_read(rkisp1, RKISP1_CIF_VI_ID); - dev_dbg(rkisp1->dev, "CIF_ID 0x%08x\n", cif_id); - ret = rkisp1_config_isp(rkisp1); if (ret) return ret; From patchwork Tue Jun 14 19:10:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881393 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE452C43334 for ; Tue, 14 Jun 2022 19:12:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346562AbiFNTMO (ORCPT ); Tue, 14 Jun 2022 15:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345217AbiFNTMO (ORCPT ); Tue, 14 Jun 2022 15:12:14 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52397205E8 for ; Tue, 14 Jun 2022 12:12:13 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F488D96; Tue, 14 Jun 2022 21:12:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233932; bh=Yfn1DCE8BQiJyEWvIA9Gs2CWs3elUgygGqaP9Io968k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BhviWCjMEO7zHi3p1eXtv2Oa+PGFeBDk27NPcdHYe47E7oQTIwYfoqdtCF9OhCWHa UFPMpODoL+s5PaFLmk5XlosOCq6VbI+8KSikveKmHzGVoMaOBhKovyVCa16vQr6UI7 OjYYm6pN53K6DvvqPqyk1CfBFG7+YUbG0m2Jbig8= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 06/55] media: rkisp1: Rename rkisp1_match_data to rkisp1_info Date: Wed, 15 Jun 2022 04:10:38 +0900 Message-Id: <20220614191127.3420492-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The rkisp1_match_data structure contains device model-specific information. It it referenced from OF match data, but that's an implementation detail. Rename it to rkisp1_info to reflect its main purpose. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-dev.c | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index ba773c0784fb..258980ef4783 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -105,7 +105,7 @@ struct rkisp1_isr_data { irqreturn_t (*isr)(int irq, void *ctx); }; -struct rkisp1_match_data { +struct rkisp1_info { const char * const *clks; unsigned int clk_size; const struct rkisp1_isr_data *isrs; @@ -420,7 +420,7 @@ static const struct rkisp1_isr_data px30_isp_isrs[] = { { "mipi", rkisp1_mipi_isr }, }; -static const struct rkisp1_match_data px30_isp_match_data = { +static const struct rkisp1_info px30_isp_info = { .clks = px30_isp_clks, .clk_size = ARRAY_SIZE(px30_isp_clks), .isrs = px30_isp_isrs, @@ -438,7 +438,7 @@ static const struct rkisp1_isr_data rk3399_isp_isrs[] = { { NULL, rkisp1_isr }, }; -static const struct rkisp1_match_data rk3399_isp_match_data = { +static const struct rkisp1_info rk3399_isp_info = { .clks = rk3399_isp_clks, .clk_size = ARRAY_SIZE(rk3399_isp_clks), .isrs = rk3399_isp_isrs, @@ -449,11 +449,11 @@ static const struct rkisp1_match_data rk3399_isp_match_data = { static const struct of_device_id rkisp1_of_match[] = { { .compatible = "rockchip,px30-cif-isp", - .data = &px30_isp_match_data, + .data = &px30_isp_info, }, { .compatible = "rockchip,rk3399-cif-isp", - .data = &rk3399_isp_match_data, + .data = &rk3399_isp_info, }, {}, }; @@ -461,7 +461,7 @@ MODULE_DEVICE_TABLE(of, rkisp1_of_match); static int rkisp1_probe(struct platform_device *pdev) { - const struct rkisp1_match_data *match_data; + const struct rkisp1_info *info; struct device *dev = &pdev->dev; struct rkisp1_device *rkisp1; struct v4l2_device *v4l2_dev; @@ -469,8 +469,8 @@ static int rkisp1_probe(struct platform_device *pdev) int ret, irq; u32 cif_id; - match_data = of_device_get_match_data(&pdev->dev); - if (!match_data) + info = of_device_get_match_data(&pdev->dev); + if (!info) return -ENODEV; rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL); @@ -486,14 +486,14 @@ static int rkisp1_probe(struct platform_device *pdev) if (IS_ERR(rkisp1->base_addr)) return PTR_ERR(rkisp1->base_addr); - for (i = 0; i < match_data->isr_size; i++) { - irq = match_data->isrs[i].name - ? platform_get_irq_byname(pdev, match_data->isrs[i].name) + for (i = 0; i < info->isr_size; i++) { + irq = info->isrs[i].name + ? platform_get_irq_byname(pdev, info->isrs[i].name) : platform_get_irq(pdev, i); if (irq < 0) return irq; - ret = devm_request_irq(dev, irq, match_data->isrs[i].isr, IRQF_SHARED, + ret = devm_request_irq(dev, irq, info->isrs[i].isr, IRQF_SHARED, dev_driver_string(dev), dev); if (ret) { dev_err(dev, "request irq failed: %d\n", ret); @@ -501,12 +501,12 @@ static int rkisp1_probe(struct platform_device *pdev) } } - for (i = 0; i < match_data->clk_size; i++) - rkisp1->clks[i].id = match_data->clks[i]; - ret = devm_clk_bulk_get(dev, match_data->clk_size, rkisp1->clks); + for (i = 0; i < info->clk_size; i++) + rkisp1->clks[i].id = info->clks[i]; + ret = devm_clk_bulk_get(dev, info->clk_size, rkisp1->clks); if (ret) return ret; - rkisp1->clk_size = match_data->clk_size; + rkisp1->clk_size = info->clk_size; pm_runtime_enable(&pdev->dev); @@ -519,7 +519,7 @@ static int rkisp1_probe(struct platform_device *pdev) pm_runtime_put(&pdev->dev); - rkisp1->media_dev.hw_revision = match_data->isp_ver; + rkisp1->media_dev.hw_revision = info->isp_ver; strscpy(rkisp1->media_dev.model, RKISP1_DRIVER_NAME, sizeof(rkisp1->media_dev.model)); rkisp1->media_dev.dev = &pdev->dev; From patchwork Tue Jun 14 19:10:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881394 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DD33CCA47A for ; Tue, 14 Jun 2022 19:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347448AbiFNTMT (ORCPT ); Tue, 14 Jun 2022 15:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346934AbiFNTMS (ORCPT ); Tue, 14 Jun 2022 15:12:18 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7419248DE for ; Tue, 14 Jun 2022 12:12:17 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B2AE2825; Tue, 14 Jun 2022 21:12:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233936; bh=ezpdH0sDENe4SC2kcyfXXr7hHWjEHr22xpbzcdQQXP0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a952uRO9gdq1xudsMOe6fnPxLFcK6th8DGx1bzWtx5TAwErv9tcIzl+1q6lWGG/SC fbLGwf5HQiphz3edG5oRK7/rNCZiX500wo4Svz+S/3UBq/q645xgAUYBLqGlBLY65L 84gEDJcuD+C2pd2Nbqm533bqt8of6YdnCsqkT7So= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 07/55] media: rkisp1: Save info pointer in rkisp1_device Date: Wed, 15 Jun 2022 04:10:39 +0900 Message-Id: <20220614191127.3420492-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org To make it possible to use the rkisp1_info after probe time (for instance to make code conditional on the ISP version), save it in the main rkisp1_device structure. To achieve this, also move the info structure into the common header, and document it. While at it, drop a NULL check in rkisp1_probe() for the match data as it can't happen. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart Reviewed-by: Dafna Hirschfeld --- .../platform/rockchip/rkisp1/rkisp1-common.h | 22 +++++++++++++++++++ .../platform/rockchip/rkisp1/rkisp1-dev.c | 15 +++---------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index a67fe7b1dfa1..50d31a254b03 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -91,6 +91,26 @@ enum rkisp1_isp_pad { RKISP1_ISP_PAD_MAX }; +/* + * struct rkisp1_info - Model-specific ISP Information + * + * @clks: array of ISP clock names + * @clk_size: number of entries in the @clks array + * @isrs: array of ISP interrupt descriptors + * @isr_size: number of entires in the @isrs array + * @isp_ver: ISP version + * + * This structure contains information about the ISP specific to a particular + * ISP model, version, or integration in a particular SoC. + */ +struct rkisp1_info { + const char * const *clks; + unsigned int clk_size; + const struct rkisp1_isr_data *isrs; + unsigned int isr_size; + enum rkisp1_cif_isp_version isp_ver; +}; + /* * struct rkisp1_sensor_async - A container for the v4l2_async_subdev to add to the notifier * of the v4l2-async API @@ -395,6 +415,7 @@ struct rkisp1_debug { * @pipe: media pipeline * @stream_lock: serializes {start/stop}_streaming callbacks between the capture devices. * @debug: debug params to be exposed on debugfs + * @info: version-specific ISP information */ struct rkisp1_device { void __iomem *base_addr; @@ -413,6 +434,7 @@ struct rkisp1_device { struct media_pipeline pipe; struct mutex stream_lock; /* serialize {start/stop}_streaming cb between capture devices */ struct rkisp1_debug debug; + const struct rkisp1_info *info; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 258980ef4783..39ae35074062 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -105,14 +105,6 @@ struct rkisp1_isr_data { irqreturn_t (*isr)(int irq, void *ctx); }; -struct rkisp1_info { - const char * const *clks; - unsigned int clk_size; - const struct rkisp1_isr_data *isrs; - unsigned int isr_size; - enum rkisp1_cif_isp_version isp_ver; -}; - /* ---------------------------------------------------------------------------- * Sensor DT bindings */ @@ -469,14 +461,13 @@ static int rkisp1_probe(struct platform_device *pdev) int ret, irq; u32 cif_id; - info = of_device_get_match_data(&pdev->dev); - if (!info) - return -ENODEV; - rkisp1 = devm_kzalloc(dev, sizeof(*rkisp1), GFP_KERNEL); if (!rkisp1) return -ENOMEM; + info = of_device_get_match_data(dev); + rkisp1->info = info; + dev_set_drvdata(dev, rkisp1); rkisp1->dev = dev; From patchwork Tue Jun 14 19:10:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881395 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C608FC433EF for ; Tue, 14 Jun 2022 19:12:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351017AbiFNTMY (ORCPT ); Tue, 14 Jun 2022 15:12:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346934AbiFNTMX (ORCPT ); Tue, 14 Jun 2022 15:12:23 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA03BD0 for ; Tue, 14 Jun 2022 12:12:21 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 105FB9E5; Tue, 14 Jun 2022 21:12:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233940; bh=A2fdDC+egWutaMVHi6UlHyyI7g9A33l3ZSwSZNsp5Dw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pEtldVyXBtUV4tMMd4zv/kxxt6L3zZNeaGpUYKprXWtOWTEhmVAl4o4x5A+BRWrT4 Y6Vsq/SSeu0BijDJFw9exVFHjiqDBOrPELq1ElzxNGIqXrYA49+Oz8J4ntnGCE7M60 59PY8iO1Lw9hY+n6juaXzgW07/RbF/zFWFXvONGo= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 08/55] media: rkisp1: Access ISP version from info pointer Date: Wed, 15 Jun 2022 04:10:40 +0900 Message-Id: <20220614191127.3420492-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ISP version is stored in the media_device hw_revision field and access from there in the driver. Now that we store a pointer to the match data in the rkisp1_device structure, access the ISP version from there to make the code clearer and avoid depending on the media_device. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 4 ++-- drivers/media/platform/rockchip/rkisp1/rkisp1-params.c | 2 +- drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 02968656f3c0..328e8fec14e9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -417,7 +417,7 @@ static int rkisp1_config_mipi(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, mipi_ctrl); /* V12 could also use a newer csi2-host, but we don't want that yet */ - if (rkisp1->media_dev.hw_revision == RKISP1_V12) + if (rkisp1->info->isp_ver == RKISP1_V12) rkisp1_write(rkisp1, RKISP1_CIF_ISP_CSI0_CTRL0, 0); /* Configure Data Type and Virtual Channel */ @@ -535,7 +535,7 @@ static void rkisp1_config_clk(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, RKISP1_CIF_VI_ICCL, val); /* ensure sp and mp can run at the same time in V12 */ - if (rkisp1->media_dev.hw_revision == RKISP1_V12) { + if (rkisp1->info->isp_ver == RKISP1_V12) { val = RKISP1_CIF_CLK_CTRL_MI_Y12 | RKISP1_CIF_CLK_CTRL_MI_SP | RKISP1_CIF_CLK_CTRL_MI_RAW0 | RKISP1_CIF_CLK_CTRL_MI_RAW1 | RKISP1_CIF_CLK_CTRL_MI_READ | RKISP1_CIF_CLK_CTRL_MI_RAWRD | diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c index c88a9c0fa86e..9da7dc1bc690 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c @@ -1801,7 +1801,7 @@ static void rkisp1_init_params(struct rkisp1_params *params) params->vdev_fmt.fmt.meta.buffersize = sizeof(struct rkisp1_params_cfg); - if (params->rkisp1->media_dev.hw_revision == RKISP1_V12) + if (params->rkisp1->info->isp_ver == RKISP1_V12) params->ops = &rkisp1_v12_params_ops; else params->ops = &rkisp1_v10_params_ops; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c index b7ae9166c52f..7d82356b5345 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c @@ -427,7 +427,7 @@ static void rkisp1_init_stats(struct rkisp1_stats *stats) stats->vdev_fmt.fmt.meta.buffersize = sizeof(struct rkisp1_stat_buffer); - if (stats->rkisp1->media_dev.hw_revision == RKISP1_V12) + if (stats->rkisp1->info->isp_ver == RKISP1_V12) stats->ops = &rkisp1_v12_stats_ops; else stats->ops = &rkisp1_v10_stats_ops; From patchwork Tue Jun 14 19:10:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881396 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AA5BC433EF for ; Tue, 14 Jun 2022 19:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357414AbiFNTMs (ORCPT ); Tue, 14 Jun 2022 15:12:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357210AbiFNTM3 (ORCPT ); Tue, 14 Jun 2022 15:12:29 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B8A3A46C for ; Tue, 14 Jun 2022 12:12:26 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 37613825; Tue, 14 Jun 2022 21:12:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233945; bh=ziuJlGEi/sBEJXY/zL7duNXdiLAR8BKLwIcdu8TNidw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L32QNvCAqIM4mx7p95QVK9ny/+dVNBOMcqin/7J4bwqvsabrarTvSz19HYePaCXt8 /DzEILJGV0pJ/b/QTjQQq40/0j6oJezvaiQlNoRfxupDLnShUd/TZbPJus7x5ErUs1 HgLzD5rtcW55aQJjpU8z2M0irwQLErpD5E8r8b+U= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 09/55] media: rkisp1: Make rkisp1_isp_mbus_info common Date: Wed, 15 Jun 2022 04:10:41 +0900 Message-Id: <20220614191127.3420492-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The upcoming CSI receiver split from the ISP to a separate source file will need to be able to access the list of formats supported by the driver. Move it out of the ISP's header and into the common header, and add helper functions for accessing it so that the format list doesn't need to be stored in the header. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.c | 148 +++++++++++++++ .../platform/rockchip/rkisp1/rkisp1-common.h | 28 ++- .../platform/rockchip/rkisp1/rkisp1-isp.c | 168 ++---------------- .../platform/rockchip/rkisp1/rkisp1-resizer.c | 14 +- .../platform/rockchip/rkisp1/rkisp1-stats.c | 2 +- 5 files changed, 193 insertions(+), 167 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.c index cf889666e166..bb0ea20118e1 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.c @@ -5,10 +5,158 @@ * Copyright (C) 2019 Collabora, Ltd. */ +#include #include #include "rkisp1-common.h" +static const struct rkisp1_mbus_info rkisp1_formats[] = { + { + .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, + .pixel_enc = V4L2_PIXEL_ENC_YUV, + .direction = RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW10, + .bayer_pat = RKISP1_RAW_RGGB, + .bus_width = 10, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW10, + .bayer_pat = RKISP1_RAW_BGGR, + .bus_width = 10, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW10, + .bayer_pat = RKISP1_RAW_GBRG, + .bus_width = 10, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW10, + .bayer_pat = RKISP1_RAW_GRBG, + .bus_width = 10, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW12, + .bayer_pat = RKISP1_RAW_RGGB, + .bus_width = 12, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW12, + .bayer_pat = RKISP1_RAW_BGGR, + .bus_width = 12, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW12, + .bayer_pat = RKISP1_RAW_GBRG, + .bus_width = 12, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW12, + .bayer_pat = RKISP1_RAW_GRBG, + .bus_width = 12, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW8, + .bayer_pat = RKISP1_RAW_RGGB, + .bus_width = 8, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW8, + .bayer_pat = RKISP1_RAW_BGGR, + .bus_width = 8, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW8, + .bayer_pat = RKISP1_RAW_GBRG, + .bus_width = 8, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, + .pixel_enc = V4L2_PIXEL_ENC_BAYER, + .mipi_dt = MIPI_CSI2_DT_RAW8, + .bayer_pat = RKISP1_RAW_GRBG, + .bus_width = 8, + .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, + }, { + .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, + .pixel_enc = V4L2_PIXEL_ENC_YUV, + .mipi_dt = MIPI_CSI2_DT_YUV422_8B, + .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_YCBYCR, + .bus_width = 16, + .direction = RKISP1_ISP_SD_SINK, + }, { + .mbus_code = MEDIA_BUS_FMT_YVYU8_1X16, + .pixel_enc = V4L2_PIXEL_ENC_YUV, + .mipi_dt = MIPI_CSI2_DT_YUV422_8B, + .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_YCRYCB, + .bus_width = 16, + .direction = RKISP1_ISP_SD_SINK, + }, { + .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, + .pixel_enc = V4L2_PIXEL_ENC_YUV, + .mipi_dt = MIPI_CSI2_DT_YUV422_8B, + .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_CBYCRY, + .bus_width = 16, + .direction = RKISP1_ISP_SD_SINK, + }, { + .mbus_code = MEDIA_BUS_FMT_VYUY8_1X16, + .pixel_enc = V4L2_PIXEL_ENC_YUV, + .mipi_dt = MIPI_CSI2_DT_YUV422_8B, + .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_CRYCBY, + .bus_width = 16, + .direction = RKISP1_ISP_SD_SINK, + }, +}; + +unsigned int rkisp1_mbus_info_length(void) +{ + return ARRAY_SIZE(rkisp1_formats); +} + +const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index) +{ + if (index >= rkisp1_mbus_info_length()) + return NULL; + + return &rkisp1_formats[index]; +} + +const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(rkisp1_formats); i++) { + const struct rkisp1_mbus_info *fmt = &rkisp1_formats[i]; + + if (fmt->mbus_code == mbus_code) + return fmt; + } + + return NULL; +} + static const struct v4l2_rect rkisp1_sd_min_crop = { .width = RKISP1_ISP_MIN_WIDTH, .height = RKISP1_ISP_MIN_HEIGHT, diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 50d31a254b03..c7d5c57607bd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -26,7 +26,7 @@ struct dentry; /* - * flags on the 'direction' field in struct 'rkisp1_isp_mbus_info' that indicate + * flags on the 'direction' field in struct rkisp1_mbus_info' that indicate * on which pad the media bus format is supported */ #define RKISP1_ISP_SD_SRC BIT(0) @@ -150,8 +150,8 @@ struct rkisp1_isp { struct v4l2_subdev sd; struct media_pad pads[RKISP1_ISP_PAD_MAX]; struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX]; - const struct rkisp1_isp_mbus_info *sink_fmt; - const struct rkisp1_isp_mbus_info *src_fmt; + const struct rkisp1_mbus_info *sink_fmt; + const struct rkisp1_mbus_info *src_fmt; struct mutex ops_lock; /* serialize the subdevice ops */ bool is_dphy_errctrl_disabled; __u32 frame_sequence; @@ -438,8 +438,8 @@ struct rkisp1_device { }; /* - * struct rkisp1_isp_mbus_info - ISP media bus info, Translates media bus code to hardware - * format values + * struct rkisp1_mbus_info - ISP media bus info, Translates media bus code to hardware + * format values * * @mbus_code: media bus code * @pixel_enc: pixel encoding @@ -449,7 +449,7 @@ struct rkisp1_device { * @bayer_pat: bayer pattern * @direction: a bitmask of the flags indicating on which pad the format is supported on */ -struct rkisp1_isp_mbus_info { +struct rkisp1_mbus_info { u32 mbus_code; enum v4l2_pixel_encoding pixel_enc; u32 mipi_dt; @@ -481,6 +481,18 @@ static inline u32 rkisp1_read(struct rkisp1_device *rkisp1, unsigned int addr) int rkisp1_cap_enum_mbus_codes(struct rkisp1_capture *cap, struct v4l2_subdev_mbus_code_enum *code); +/* + * rkisp1_mbus_info_length - Return the number of supported mbus codes + */ +unsigned int rkisp1_mbus_info_length(void); + +/* + * rkisp1_mbus_info_get_by_index - Retrieve the ith supported mbus info + * + * @index: index of the mbus info to fetch + */ +const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_index(unsigned int index); + /* * rkisp1_sd_adjust_crop_rect - adjust a rectangle to fit into another rectangle. * @@ -500,11 +512,11 @@ void rkisp1_sd_adjust_crop(struct v4l2_rect *crop, const struct v4l2_mbus_framefmt *bounds); /* - * rkisp1_isp_mbus_info - get the isp info of the media bus code + * rkisp1_mbus_info_get_by_code - get the isp info of the media bus code * * @mbus_code: the media bus code */ -const struct rkisp1_isp_mbus_info *rkisp1_isp_mbus_info_get(u32 mbus_code); +const struct rkisp1_mbus_info *rkisp1_mbus_info_get_by_code(u32 mbus_code); /* rkisp1_params_configure - configure the params when stream starts. * This function is called by the isp entity upon stream starts. diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 328e8fec14e9..89577119b571 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -15,7 +15,6 @@ #include #include -#include #include #include "rkisp1-common.h" @@ -56,144 +55,10 @@ * +---------------------------------------------------------+ */ -static const struct rkisp1_isp_mbus_info rkisp1_isp_formats[] = { - { - .mbus_code = MEDIA_BUS_FMT_YUYV8_2X8, - .pixel_enc = V4L2_PIXEL_ENC_YUV, - .direction = RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SRGGB10_1X10, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW10, - .bayer_pat = RKISP1_RAW_RGGB, - .bus_width = 10, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SBGGR10_1X10, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW10, - .bayer_pat = RKISP1_RAW_BGGR, - .bus_width = 10, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGBRG10_1X10, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW10, - .bayer_pat = RKISP1_RAW_GBRG, - .bus_width = 10, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGRBG10_1X10, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW10, - .bayer_pat = RKISP1_RAW_GRBG, - .bus_width = 10, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SRGGB12_1X12, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW12, - .bayer_pat = RKISP1_RAW_RGGB, - .bus_width = 12, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SBGGR12_1X12, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW12, - .bayer_pat = RKISP1_RAW_BGGR, - .bus_width = 12, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGBRG12_1X12, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW12, - .bayer_pat = RKISP1_RAW_GBRG, - .bus_width = 12, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGRBG12_1X12, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW12, - .bayer_pat = RKISP1_RAW_GRBG, - .bus_width = 12, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SRGGB8_1X8, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW8, - .bayer_pat = RKISP1_RAW_RGGB, - .bus_width = 8, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SBGGR8_1X8, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW8, - .bayer_pat = RKISP1_RAW_BGGR, - .bus_width = 8, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGBRG8_1X8, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW8, - .bayer_pat = RKISP1_RAW_GBRG, - .bus_width = 8, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_SGRBG8_1X8, - .pixel_enc = V4L2_PIXEL_ENC_BAYER, - .mipi_dt = MIPI_CSI2_DT_RAW8, - .bayer_pat = RKISP1_RAW_GRBG, - .bus_width = 8, - .direction = RKISP1_ISP_SD_SINK | RKISP1_ISP_SD_SRC, - }, { - .mbus_code = MEDIA_BUS_FMT_YUYV8_1X16, - .pixel_enc = V4L2_PIXEL_ENC_YUV, - .mipi_dt = MIPI_CSI2_DT_YUV422_8B, - .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_YCBYCR, - .bus_width = 16, - .direction = RKISP1_ISP_SD_SINK, - }, { - .mbus_code = MEDIA_BUS_FMT_YVYU8_1X16, - .pixel_enc = V4L2_PIXEL_ENC_YUV, - .mipi_dt = MIPI_CSI2_DT_YUV422_8B, - .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_YCRYCB, - .bus_width = 16, - .direction = RKISP1_ISP_SD_SINK, - }, { - .mbus_code = MEDIA_BUS_FMT_UYVY8_1X16, - .pixel_enc = V4L2_PIXEL_ENC_YUV, - .mipi_dt = MIPI_CSI2_DT_YUV422_8B, - .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_CBYCRY, - .bus_width = 16, - .direction = RKISP1_ISP_SD_SINK, - }, { - .mbus_code = MEDIA_BUS_FMT_VYUY8_1X16, - .pixel_enc = V4L2_PIXEL_ENC_YUV, - .mipi_dt = MIPI_CSI2_DT_YUV422_8B, - .yuv_seq = RKISP1_CIF_ISP_ACQ_PROP_CRYCBY, - .bus_width = 16, - .direction = RKISP1_ISP_SD_SINK, - }, -}; - /* ---------------------------------------------------------------------------- * Helpers */ -const struct rkisp1_isp_mbus_info *rkisp1_isp_mbus_info_get(u32 mbus_code) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(rkisp1_isp_formats); i++) { - const struct rkisp1_isp_mbus_info *fmt = &rkisp1_isp_formats[i]; - - if (fmt->mbus_code == mbus_code) - return fmt; - } - - return NULL; -} - static struct v4l2_subdev *rkisp1_get_remote_sensor(struct v4l2_subdev *sd) { struct media_pad *local, *remote; @@ -275,7 +140,7 @@ static void rkisp1_config_ism(struct rkisp1_device *rkisp1) static int rkisp1_config_isp(struct rkisp1_device *rkisp1) { u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0; - const struct rkisp1_isp_mbus_info *src_fmt, *sink_fmt; + const struct rkisp1_mbus_info *src_fmt, *sink_fmt; struct rkisp1_sensor_async *sensor; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; @@ -376,7 +241,7 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) { - const struct rkisp1_isp_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; + const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; u32 val, input_sel; switch (sink_fmt->bus_width) { @@ -402,7 +267,7 @@ static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) static int rkisp1_config_mipi(struct rkisp1_device *rkisp1) { - const struct rkisp1_isp_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; + const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; unsigned int lanes = rkisp1->active_sensor->lanes; u32 mipi_ctrl; @@ -593,11 +458,12 @@ static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd, return 0; } - if (code->index >= ARRAY_SIZE(rkisp1_isp_formats)) + if (code->index >= rkisp1_mbus_info_length()) return -EINVAL; - for (i = 0; i < ARRAY_SIZE(rkisp1_isp_formats); i++) { - const struct rkisp1_isp_mbus_info *fmt = &rkisp1_isp_formats[i]; + for (i = 0; i < rkisp1_mbus_info_length(); i++) { + const struct rkisp1_mbus_info *fmt = + rkisp1_mbus_info_get_by_index(i); if (fmt->direction & dir) pos++; @@ -619,7 +485,7 @@ static int rkisp1_isp_enum_frame_size(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_frame_size_enum *fse) { - const struct rkisp1_isp_mbus_info *mbus_info; + const struct rkisp1_mbus_info *mbus_info; if (fse->pad == RKISP1_ISP_PAD_SINK_PARAMS || fse->pad == RKISP1_ISP_PAD_SOURCE_STATS) @@ -628,7 +494,7 @@ static int rkisp1_isp_enum_frame_size(struct v4l2_subdev *sd, if (fse->index > 0) return -EINVAL; - mbus_info = rkisp1_isp_mbus_info_get(fse->code); + mbus_info = rkisp1_mbus_info_get_by_code(fse->code); if (!mbus_info) return -EINVAL; @@ -695,7 +561,7 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp, struct v4l2_mbus_framefmt *format, unsigned int which) { - const struct rkisp1_isp_mbus_info *mbus_info; + const struct rkisp1_mbus_info *mbus_info; struct v4l2_mbus_framefmt *src_fmt; const struct v4l2_rect *src_crop; @@ -705,10 +571,10 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp, RKISP1_ISP_PAD_SOURCE_VIDEO, which); src_fmt->code = format->code; - mbus_info = rkisp1_isp_mbus_info_get(src_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(src_fmt->code); if (!mbus_info || !(mbus_info->direction & RKISP1_ISP_SD_SRC)) { src_fmt->code = RKISP1_DEF_SRC_PAD_FMT; - mbus_info = rkisp1_isp_mbus_info_get(src_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(src_fmt->code); } if (which == V4L2_SUBDEV_FORMAT_ACTIVE) isp->src_fmt = mbus_info; @@ -793,7 +659,7 @@ static void rkisp1_isp_set_sink_fmt(struct rkisp1_isp *isp, struct v4l2_mbus_framefmt *format, unsigned int which) { - const struct rkisp1_isp_mbus_info *mbus_info; + const struct rkisp1_mbus_info *mbus_info; struct v4l2_mbus_framefmt *sink_fmt; struct v4l2_rect *sink_crop; @@ -801,10 +667,10 @@ static void rkisp1_isp_set_sink_fmt(struct rkisp1_isp *isp, RKISP1_ISP_PAD_SINK_VIDEO, which); sink_fmt->code = format->code; - mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); if (!mbus_info || !(mbus_info->direction & RKISP1_ISP_SD_SINK)) { sink_fmt->code = RKISP1_DEF_SINK_PAD_FMT; - mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); } if (which == V4L2_SUBDEV_FORMAT_ACTIVE) isp->sink_fmt = mbus_info; @@ -1080,8 +946,8 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1) pads[RKISP1_ISP_PAD_SOURCE_VIDEO].flags = MEDIA_PAD_FL_SOURCE; pads[RKISP1_ISP_PAD_SOURCE_STATS].flags = MEDIA_PAD_FL_SOURCE; - isp->sink_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SINK_PAD_FMT); - isp->src_fmt = rkisp1_isp_mbus_info_get(RKISP1_DEF_SRC_PAD_FMT); + isp->sink_fmt = rkisp1_mbus_info_get_by_code(RKISP1_DEF_SINK_PAD_FMT); + isp->src_fmt = rkisp1_mbus_info_get_by_code(RKISP1_DEF_SRC_PAD_FMT); mutex_init(&isp->ops_lock); ret = media_entity_pads_init(&sd->entity, RKISP1_ISP_PAD_MAX, pads); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c index 1c07985c810d..f4caa8f684aa 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c @@ -433,14 +433,14 @@ static void rkisp1_rsz_set_src_fmt(struct rkisp1_resizer *rsz, struct v4l2_mbus_framefmt *format, unsigned int which) { - const struct rkisp1_isp_mbus_info *sink_mbus_info; + const struct rkisp1_mbus_info *sink_mbus_info; struct v4l2_mbus_framefmt *src_fmt, *sink_fmt; sink_fmt = rkisp1_rsz_get_pad_fmt(rsz, sd_state, RKISP1_RSZ_PAD_SINK, which); src_fmt = rkisp1_rsz_get_pad_fmt(rsz, sd_state, RKISP1_RSZ_PAD_SRC, which); - sink_mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + sink_mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); /* for YUV formats, userspace can change the mbus code on the src pad if it is supported */ if (sink_mbus_info->pixel_enc == V4L2_PIXEL_ENC_YUV && @@ -462,7 +462,7 @@ static void rkisp1_rsz_set_sink_crop(struct rkisp1_resizer *rsz, struct v4l2_rect *r, unsigned int which) { - const struct rkisp1_isp_mbus_info *mbus_info; + const struct rkisp1_mbus_info *mbus_info; struct v4l2_mbus_framefmt *sink_fmt; struct v4l2_rect *sink_crop; @@ -473,7 +473,7 @@ static void rkisp1_rsz_set_sink_crop(struct rkisp1_resizer *rsz, which); /* Not crop for MP bayer raw data */ - mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); if (rsz->id == RKISP1_MAINPATH && mbus_info->pixel_enc == V4L2_PIXEL_ENC_BAYER) { @@ -500,7 +500,7 @@ static void rkisp1_rsz_set_sink_fmt(struct rkisp1_resizer *rsz, struct v4l2_mbus_framefmt *format, unsigned int which) { - const struct rkisp1_isp_mbus_info *mbus_info; + const struct rkisp1_mbus_info *mbus_info; struct v4l2_mbus_framefmt *sink_fmt, *src_fmt; struct v4l2_rect *sink_crop; @@ -516,10 +516,10 @@ static void rkisp1_rsz_set_sink_fmt(struct rkisp1_resizer *rsz, else sink_fmt->code = format->code; - mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); if (!mbus_info || !(mbus_info->direction & RKISP1_ISP_SD_SRC)) { sink_fmt->code = RKISP1_DEF_FMT; - mbus_info = rkisp1_isp_mbus_info_get(sink_fmt->code); + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); } if (which == V4L2_SUBDEV_FORMAT_ACTIVE) rsz->pixel_enc = mbus_info->pixel_enc; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c index 7d82356b5345..2795eef91bdd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c @@ -305,7 +305,7 @@ static void rkisp1_stats_get_bls_meas(struct rkisp1_stats *stats, struct rkisp1_stat_buffer *pbuf) { struct rkisp1_device *rkisp1 = stats->rkisp1; - const struct rkisp1_isp_mbus_info *in_fmt = rkisp1->isp.sink_fmt; + const struct rkisp1_mbus_info *in_fmt = rkisp1->isp.sink_fmt; struct rkisp1_cif_isp_bls_meas_val *bls_val; bls_val = &pbuf->params.ae.bls_val; From patchwork Tue Jun 14 19:10:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53204C433EF for ; Tue, 14 Jun 2022 19:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350483AbiFNTMy (ORCPT ); Tue, 14 Jun 2022 15:12:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357202AbiFNTMg (ORCPT ); Tue, 14 Jun 2022 15:12:36 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 752D111C0F for ; Tue, 14 Jun 2022 12:12:30 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A92509E5; Tue, 14 Jun 2022 21:12:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233949; bh=kS4iBC6vAv+3oQJU2XUDDkNuo7oUHbBdOv75NuIxKAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vAuu+aNPHbyxzD9hyWJtPI0zoWH58cU49DaufbtQEivPS5VDcgSkze53UNO6uwEjj c3oVVNcw/jIWR3O74ksQpTHapu9tnQWI1u9Slro75aGb668lYuY7ULUpVxshVVBBiI Bed4YSIfmEPSIQ/A3KrOjpO0AfNcB2V7fBzpiChA= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 10/55] media: rkisp1: cap: Print debug message on failed link validation Date: Wed, 15 Jun 2022 04:10:42 +0900 Message-Id: <20220614191127.3420492-11-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart When a link validation failure occurs, print a debug message to help diagnosing the cause. Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/rkisp1-capture.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 94819e6c23e2..94a0d787a312 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -1294,8 +1294,16 @@ static int rkisp1_capture_link_validate(struct media_link *link) if (sd_fmt.format.height != cap->pix.fmt.height || sd_fmt.format.width != cap->pix.fmt.width || - sd_fmt.format.code != fmt->mbus) + sd_fmt.format.code != fmt->mbus) { + dev_dbg(cap->rkisp1->dev, + "link '%s':%u -> '%s':%u not valid: 0x%04x/%ux%u != 0x%04x/%ux%u", + link->source->entity->name, link->source->index, + link->sink->entity->name, link->sink->index, + sd_fmt.format.code, sd_fmt.format.width, + sd_fmt.format.height, fmt->mbus, cap->pix.fmt.width, + cap->pix.fmt.height); return -EPIPE; + } return 0; } From patchwork Tue Jun 14 19:10:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF5C0C43334 for ; Tue, 14 Jun 2022 19:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344022AbiFNTMz (ORCPT ); Tue, 14 Jun 2022 15:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357370AbiFNTMl (ORCPT ); Tue, 14 Jun 2022 15:12:41 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7691813CF7 for ; Tue, 14 Jun 2022 12:12:34 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D3985D96; Tue, 14 Jun 2022 21:12:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233953; bh=k8FRBbwpvIHe8zOUzbxn54nhYIrUq6aIGOgT/YnXUxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TXd/O2C3MN/Un/SQgTfm55tjOsb36YLeoWVMOXhyyNk/Ym/QLhQRd3ovUmObvxM8e 0uXe2CC0QjTS+eCnBMyb3qj5Xzlv8XC8h4mr3Z0tlBbcA681nZdAzGxZ6PFF24zdx8 CZbSaxnyb09UgFemrzlz0xOiL0h+ksG0C9dTb8Nc= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 11/55] media: rkisp1: Move sensor .s_stream() call to ISP Date: Wed, 15 Jun 2022 04:10:43 +0900 Message-Id: <20220614191127.3420492-12-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Move the calls to the active sensor's .s_stream() operation to the ISP subdev's .s_stream(). This groups all handling of the active sensor in one place, preparing for a rework of that code. Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/rkisp1-capture.c | 12 +----------- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 11 +++++++++++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 94a0d787a312..9edaa95fa44c 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -926,11 +926,8 @@ static void rkisp1_pipeline_stream_disable(struct rkisp1_capture *cap) * If the other capture is streaming, isp and sensor nodes shouldn't * be disabled, skip them. */ - if (rkisp1->pipe.streaming_count < 2) { - v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, - false); + if (rkisp1->pipe.streaming_count < 2) v4l2_subdev_call(&rkisp1->isp.sd, video, s_stream, false); - } v4l2_subdev_call(&rkisp1->resizer_devs[cap->id].sd, video, s_stream, false); @@ -966,15 +963,8 @@ static int rkisp1_pipeline_stream_enable(struct rkisp1_capture *cap) if (ret) goto err_disable_rsz; - ret = v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, - true); - if (ret) - goto err_disable_isp; - return 0; -err_disable_isp: - v4l2_subdev_call(&rkisp1->isp.sd, video, s_stream, false); err_disable_rsz: v4l2_subdev_call(&rkisp1->resizer_devs[cap->id].sd, video, s_stream, false); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 89577119b571..58cf6d21f1eb 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -857,6 +857,9 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) int ret = 0; if (!enable) { + v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, + false); + rkisp1_isp_stop(rkisp1); rkisp1_mipi_csi2_stop(rkisp1->active_sensor); return 0; @@ -886,6 +889,14 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) rkisp1_isp_start(rkisp1); + ret = v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, + true); + if (ret) { + rkisp1_isp_stop(rkisp1); + rkisp1_mipi_csi2_stop(rkisp1->active_sensor); + goto mutex_unlock; + } + mutex_unlock: mutex_unlock(&isp->ops_lock); return ret; From patchwork Tue Jun 14 19:10:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881399 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11635C43334 for ; Tue, 14 Jun 2022 19:12:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352461AbiFNTM4 (ORCPT ); Tue, 14 Jun 2022 15:12:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357403AbiFNTMr (ORCPT ); Tue, 14 Jun 2022 15:12:47 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C99815708 for ; Tue, 14 Jun 2022 12:12:40 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 06A29825; Tue, 14 Jun 2022 21:12:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233957; bh=rIl2U/uSQ4qjK1oJdx1HUIdq6XV0PrNBBMDId1R+hqI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oEbAtAeFuR6hQJPaF8PDn+1P0B8v3LHhIz1jraiTq0pDAvx0uxpm9EUWUMgFvwGaG qC7jw0Chyqit0UG3HvJp5Ei/V5mPlEPBr6rUyeV15QrGyTvRQhzfrDsADqsQ9eLzTX pHXfkHBBXiatQYYCYlkGfFZKi5QCv64AIOxBk84o= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 12/55] media: rkisp1: Reject sensors without pixel rate control at bound time Date: Wed, 15 Jun 2022 04:10:44 +0900 Message-Id: <20220614191127.3420492-13-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The rkisp1 driver requires the sensor to implement the pixel rate control. Trying to operate without it will cause an error when starting streaming. Catch the issue earlier, at bound time. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 6 ++++++ drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 39ae35074062..7fc617d51f44 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -190,6 +190,12 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, s_asd->pixel_rate_ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE); + if (!s_asd->pixel_rate_ctrl) { + dev_err(rkisp1->dev, "No pixel rate control in subdev %s\n", + sd->name); + return -EINVAL; + } + s_asd->sd = sd; s_asd->dphy = devm_phy_get(rkisp1->dev, "dphy"); if (IS_ERR(s_asd->dphy)) { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 58cf6d21f1eb..81138c676ac0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -823,11 +823,6 @@ static int rkisp1_mipi_csi2_start(struct rkisp1_isp *isp, struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; s64 pixel_clock; - if (!sensor->pixel_rate_ctrl) { - dev_warn(rkisp1->dev, "No pixel rate control in sensor subdev\n"); - return -EPIPE; - } - pixel_clock = v4l2_ctrl_g_ctrl_int64(sensor->pixel_rate_ctrl); if (!pixel_clock) { dev_err(rkisp1->dev, "Invalid pixel rate value\n"); From patchwork Tue Jun 14 19:10:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881400 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 004BFC433EF for ; Tue, 14 Jun 2022 19:12:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232105AbiFNTM6 (ORCPT ); Tue, 14 Jun 2022 15:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245423AbiFNTMs (ORCPT ); Tue, 14 Jun 2022 15:12:48 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82705630C for ; Tue, 14 Jun 2022 12:12:42 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0583DEF1; Tue, 14 Jun 2022 21:12:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233961; bh=fCDJB0TqsmD2OS4rT6TXU6SyBYYpwaytCRpPvzdgB6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XpLCIkR7EwsNtxU7R/2BExbvEkeuQRk8t6Eg+NCJgWdxiSafMtElot+j5XYeg82uq 2DlH4/Lt+8kfClm6d8SJkp4GRKUY5qM1xUdJgeuGIUksqNY7XpsqZrBnZSzu3Ov0y+ WOI+tI0LHPUCybzutmgv5gN6r7C9VrqPdFcA56Zc= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 13/55] media: rkisp1: Create link from sensor to ISP at notifier bound time Date: Wed, 15 Jun 2022 04:10:45 +0900 Message-Id: <20220614191127.3420492-14-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Links from sensors to the ISP can be created as sensors are bound. Move the link creation from rkisp1_create_links() to the bound notifier, and clean up the rkisp1_create_links() function while at it. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 + .../platform/rockchip/rkisp1/rkisp1-dev.c | 87 ++++++++----------- 2 files changed, 40 insertions(+), 49 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index c7d5c57607bd..ba11baf75fa9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -116,6 +116,7 @@ struct rkisp1_info { * of the v4l2-async API * * @asd: async_subdev variable for the sensor + * @index: index of the sensor (counting sensor found in DT) * @lanes: number of lanes * @mbus_type: type of bus (currently only CSI2 is supported) * @mbus_flags: media bus (V4L2_MBUS_*) flags @@ -125,6 +126,7 @@ struct rkisp1_info { */ struct rkisp1_sensor_async { struct v4l2_async_subdev asd; + unsigned int index; unsigned int lanes; enum v4l2_mbus_type mbus_type; unsigned int mbus_flags; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 7fc617d51f44..4501aea265cb 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -111,72 +111,46 @@ struct rkisp1_isr_data { static int rkisp1_create_links(struct rkisp1_device *rkisp1) { - struct media_entity *source, *sink; - unsigned int flags, source_pad; - struct v4l2_subdev *sd; unsigned int i; int ret; - /* sensor links */ - flags = MEDIA_LNK_FL_ENABLED; - list_for_each_entry(sd, &rkisp1->v4l2_dev.subdevs, list) { - if (sd == &rkisp1->isp.sd || - sd == &rkisp1->resizer_devs[RKISP1_MAINPATH].sd || - sd == &rkisp1->resizer_devs[RKISP1_SELFPATH].sd) - continue; - - ret = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode, - MEDIA_PAD_FL_SOURCE); - if (ret < 0) { - dev_err(rkisp1->dev, "failed to find src pad for %s\n", - sd->name); - return ret; - } - source_pad = ret; - - ret = media_create_pad_link(&sd->entity, source_pad, - &rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SINK_VIDEO, - flags); - if (ret) - return ret; - - flags = 0; - } - - flags = MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE; - /* create ISP->RSZ->CAP links */ for (i = 0; i < 2; i++) { - source = &rkisp1->isp.sd.entity; - sink = &rkisp1->resizer_devs[i].sd.entity; - ret = media_create_pad_link(source, RKISP1_ISP_PAD_SOURCE_VIDEO, - sink, RKISP1_RSZ_PAD_SINK, + struct media_entity *resizer = + &rkisp1->resizer_devs[i].sd.entity; + struct media_entity *capture = + &rkisp1->capture_devs[i].vnode.vdev.entity;; + + ret = media_create_pad_link(&rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SOURCE_VIDEO, + resizer, RKISP1_RSZ_PAD_SINK, MEDIA_LNK_FL_ENABLED); if (ret) return ret; - source = sink; - sink = &rkisp1->capture_devs[i].vnode.vdev.entity; - ret = media_create_pad_link(source, RKISP1_RSZ_PAD_SRC, - sink, 0, flags); + ret = media_create_pad_link(resizer, RKISP1_RSZ_PAD_SRC, + capture, 0, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); if (ret) return ret; } /* params links */ - source = &rkisp1->params.vnode.vdev.entity; - sink = &rkisp1->isp.sd.entity; - ret = media_create_pad_link(source, 0, sink, - RKISP1_ISP_PAD_SINK_PARAMS, flags); + ret = media_create_pad_link(&rkisp1->params.vnode.vdev.entity, 0, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_PARAMS, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); if (ret) return ret; /* 3A stats links */ - source = &rkisp1->isp.sd.entity; - sink = &rkisp1->stats.vnode.vdev.entity; - return media_create_pad_link(source, RKISP1_ISP_PAD_SOURCE_STATS, - sink, 0, flags); + return media_create_pad_link(&rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SOURCE_STATS, + &rkisp1->stats.vnode.vdev.entity, 0, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); } static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, @@ -187,6 +161,7 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, container_of(notifier, struct rkisp1_device, notifier); struct rkisp1_sensor_async *s_asd = container_of(asd, struct rkisp1_sensor_async, asd); + int source_pad; s_asd->pixel_rate_ctrl = v4l2_ctrl_find(sd->ctrl_handler, V4L2_CID_PIXEL_RATE); @@ -206,7 +181,19 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, phy_init(s_asd->dphy); - return 0; + /* Create the link to the sensor. */ + source_pad = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode, + MEDIA_PAD_FL_SOURCE); + if (source_pad < 0) { + dev_err(rkisp1->dev, "failed to find source pad for %s\n", + sd->name); + return source_pad; + } + + return media_create_pad_link(&sd->entity, source_pad, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_VIDEO, + !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); } static void rkisp1_subdev_notifier_unbind(struct v4l2_async_notifier *notifier, @@ -248,6 +235,7 @@ static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1) { struct v4l2_async_notifier *ntf = &rkisp1->notifier; unsigned int next_id = 0; + unsigned int index = 0; int ret; v4l2_async_nf_init(ntf); @@ -277,6 +265,7 @@ static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1) goto err_parse; } + rk_asd->index = index++; rk_asd->mbus_type = vep.bus_type; rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; From patchwork Tue Jun 14 19:10:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881401 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1749C43334 for ; Tue, 14 Jun 2022 19:13:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351461AbiFNTM6 (ORCPT ); Tue, 14 Jun 2022 15:12:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347305AbiFNTMu (ORCPT ); Tue, 14 Jun 2022 15:12:50 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57C79AE5F for ; Tue, 14 Jun 2022 12:12:46 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 068AA825; Tue, 14 Jun 2022 21:12:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233965; bh=JZYZDIgU+Gckh67qts/TBvqvAJZkut3JlM+0PM/Pgo0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NHwHkPRKW3sgYSC+3woTshC56JAcUFX2y7GMWVkSMH/sh1DkO3j/IZTCGdRm4kTVs GM2nfCV88U5aXEETZrGfG5gWpbjOpsoptbWQnQP72KnPyw1Q7bTQCqBeK0J/9r+X62 ayJXJdTrixaKk/hxplvZBAVUMK7hr8AoeFXJAUD0= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 14/55] media: rkisp1: Create internal links at probe time Date: Wed, 15 Jun 2022 04:10:46 +0900 Message-Id: <20220614191127.3420492-15-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart There's no need to wait until all async subdevs are bound before creating internal links. Create them at probe time. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-dev.c | 105 ++++++++---------- 1 file changed, 49 insertions(+), 56 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 4501aea265cb..7bb1235cddea 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -109,50 +109,6 @@ struct rkisp1_isr_data { * Sensor DT bindings */ -static int rkisp1_create_links(struct rkisp1_device *rkisp1) -{ - unsigned int i; - int ret; - - /* create ISP->RSZ->CAP links */ - for (i = 0; i < 2; i++) { - struct media_entity *resizer = - &rkisp1->resizer_devs[i].sd.entity; - struct media_entity *capture = - &rkisp1->capture_devs[i].vnode.vdev.entity;; - - ret = media_create_pad_link(&rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SOURCE_VIDEO, - resizer, RKISP1_RSZ_PAD_SINK, - MEDIA_LNK_FL_ENABLED); - if (ret) - return ret; - - ret = media_create_pad_link(resizer, RKISP1_RSZ_PAD_SRC, - capture, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret) - return ret; - } - - /* params links */ - ret = media_create_pad_link(&rkisp1->params.vnode.vdev.entity, 0, - &rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SINK_PARAMS, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); - if (ret) - return ret; - - /* 3A stats links */ - return media_create_pad_link(&rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SOURCE_STATS, - &rkisp1->stats.vnode.vdev.entity, 0, - MEDIA_LNK_FL_ENABLED | - MEDIA_LNK_FL_IMMUTABLE); -} - static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) @@ -210,19 +166,8 @@ static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) { struct rkisp1_device *rkisp1 = container_of(notifier, struct rkisp1_device, notifier); - int ret; - - ret = rkisp1_create_links(rkisp1); - if (ret) - return ret; - - ret = v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev); - if (ret) - return ret; - - dev_dbg(rkisp1->dev, "Async subdev notifier completed\n"); - return 0; + return v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev); } static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = { @@ -332,6 +277,50 @@ static const struct dev_pm_ops rkisp1_pm_ops = { * Core */ +static int rkisp1_create_links(struct rkisp1_device *rkisp1) +{ + unsigned int i; + int ret; + + /* create ISP->RSZ->CAP links */ + for (i = 0; i < 2; i++) { + struct media_entity *resizer = + &rkisp1->resizer_devs[i].sd.entity; + struct media_entity *capture = + &rkisp1->capture_devs[i].vnode.vdev.entity;; + + ret = media_create_pad_link(&rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SOURCE_VIDEO, + resizer, RKISP1_RSZ_PAD_SINK, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + + ret = media_create_pad_link(resizer, RKISP1_RSZ_PAD_SRC, + capture, 0, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; + } + + /* params links */ + ret = media_create_pad_link(&rkisp1->params.vnode.vdev.entity, 0, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_PARAMS, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); + if (ret) + return ret; + + /* 3A stats links */ + return media_create_pad_link(&rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SOURCE_STATS, + &rkisp1->stats.vnode.vdev.entity, 0, + MEDIA_LNK_FL_ENABLED | + MEDIA_LNK_FL_IMMUTABLE); +} + static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1) { rkisp1_params_unregister(rkisp1); @@ -365,6 +354,10 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) if (ret) goto error; + ret = rkisp1_create_links(rkisp1); + if (ret) + goto error; + ret = rkisp1_subdev_notifier(rkisp1); if (ret) { dev_err(rkisp1->dev, From patchwork Tue Jun 14 19:10:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881403 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8A66C433EF for ; Tue, 14 Jun 2022 19:13:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357202AbiFNTNB (ORCPT ); Tue, 14 Jun 2022 15:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243622AbiFNTMv (ORCPT ); Tue, 14 Jun 2022 15:12:51 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAFC4D0 for ; Tue, 14 Jun 2022 12:12:50 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C8AF79E5; Tue, 14 Jun 2022 21:12:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233969; bh=KtK5dwW377NvXzCNP1bIxdNyOb6odWD4AMbMsOvO2T0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F086lYTvRWB6k/opHq61tQXg7462fUbFxUwgm6DYGzMcrgFR8OLYx6Y5+O0GEv8A3 F2rkRClcVK12GQoPl8jyvOaDYNrjuyY9TckZERO5Jn6EQ+EypbGqUhuHSmjuvG2gvo i5e0AI/bUY1CcNXNvIYsUwGkakHxAJUkZQFrOUqw= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 15/55] media: rkisp1: Rename rkisp1_subdev_notifier() to rkisp1_subdev_notifier_register() Date: Wed, 15 Jun 2022 04:10:47 +0900 Message-Id: <20220614191127.3420492-16-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The function name isn't very clear, rename it to rkisp1_subdev_notifier_register(). Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 7bb1235cddea..386c1c17aec2 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -176,7 +176,7 @@ static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = .complete = rkisp1_subdev_notifier_complete, }; -static int rkisp1_subdev_notifier(struct rkisp1_device *rkisp1) +static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) { struct v4l2_async_notifier *ntf = &rkisp1->notifier; unsigned int next_id = 0; @@ -358,7 +358,7 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) if (ret) goto error; - ret = rkisp1_subdev_notifier(rkisp1); + ret = rkisp1_subdev_notifier_register(rkisp1); if (ret) { dev_err(rkisp1->dev, "Failed to register subdev notifier(%d)\n", ret); From patchwork Tue Jun 14 19:10:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86C91CCA47A for ; Tue, 14 Jun 2022 19:13:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353089AbiFNTNA (ORCPT ); Tue, 14 Jun 2022 15:13:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348261AbiFNTMz (ORCPT ); Tue, 14 Jun 2022 15:12:55 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E2E11C0F for ; Tue, 14 Jun 2022 12:12:54 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D39CC825; Tue, 14 Jun 2022 21:12:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233973; bh=OTnYQuvlSCEpGxJsQky+B7kiN2Ypy9jL3LZYyc2briI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CK5oen+KeOy3ybrgXRPXrGAYOZNbIo4OvJCLFOlXJeXppllcvk/57qnx8mKWaThna Pqy/51ShQoN07wIWX3YzwwbWPMETB9C8LHIxQJ4wNy1HcIM/LlGlym/tMuG8n4eDFm CPqG0la1MEYpkl9HFv3NGnxp4n8X4K+cqL4Y8nJY= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 16/55] media: v4l2-async: Add notifier operation to destroy asd instances Date: Wed, 15 Jun 2022 04:10:48 +0900 Message-Id: <20220614191127.3420492-17-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Drivers typically extend the v4l2_async_subdev structure by embedding it in a driver-specific structure, to store per-subdev custom data. The v4l2_async_subdev instances are freed by the v4l2-async framework, which makes this mechanism cumbersome to use safely when custom data needs special treatment to be destroyed (such as freeing additional memory, or releasing references to kernel objects). To ease this, add a .destroy() operation to the v4l2_async_notifier_operations structure. The operation is called right before the v4l2_async_subdev is freed, giving drivers a chance to destroy data if needed. Signed-off-by: Laurent Pinchart Reviewed-by: Hans Verkuil --- Documentation/driver-api/media/v4l2-subdev.rst | 6 ++++++ drivers/media/v4l2-core/v4l2-async.c | 10 ++++++++++ include/media/v4l2-async.h | 2 ++ 3 files changed, 18 insertions(+) diff --git a/Documentation/driver-api/media/v4l2-subdev.rst b/Documentation/driver-api/media/v4l2-subdev.rst index cf3b52bdbfb9..6f8d79926aa5 100644 --- a/Documentation/driver-api/media/v4l2-subdev.rst +++ b/Documentation/driver-api/media/v4l2-subdev.rst @@ -243,6 +243,12 @@ notifier callback is called. After all subdevices have been located the .complete() callback is called. When a subdevice is removed from the system the .unbind() method is called. All three callbacks are optional. +Drivers can store any type of custom data in their driver-specific +:c:type:`v4l2_async_subdev` wrapper. If any of that data requires special +handling when the structure is freed, drivers must implement the ``.destroy()`` +notifier callback. The framework will call it right before freeing the +:c:type:`v4l2_async_subdev`. + Calling subdev operations ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index c6995718237a..735dede624b8 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -52,6 +52,15 @@ static int v4l2_async_nf_call_complete(struct v4l2_async_notifier *n) return n->ops->complete(n); } +static void v4l2_async_nf_call_destroy(struct v4l2_async_notifier *n, + struct v4l2_async_subdev *asd) +{ + if (!n->ops || !n->ops->destroy) + return; + + n->ops->destroy(asd); +} + static bool match_i2c(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) { @@ -626,6 +635,7 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) } list_del(&asd->asd_list); + v4l2_async_nf_call_destroy(notifier, asd); kfree(asd); } } diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 13ff3ad948f4..25eb1d138c06 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -81,6 +81,7 @@ struct v4l2_async_subdev { * @complete: All subdevices have been probed successfully. The complete * callback is only executed for the root notifier. * @unbind: a subdevice is leaving + * @destroy: the asd is about to be freed */ struct v4l2_async_notifier_operations { int (*bound)(struct v4l2_async_notifier *notifier, @@ -90,6 +91,7 @@ struct v4l2_async_notifier_operations { void (*unbind)(struct v4l2_async_notifier *notifier, struct v4l2_subdev *subdev, struct v4l2_async_subdev *asd); + void (*destroy)(struct v4l2_async_subdev *asd); }; /** From patchwork Tue Jun 14 19:10:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881404 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80113C43334 for ; Tue, 14 Jun 2022 19:13:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357359AbiFNTNC (ORCPT ); Tue, 14 Jun 2022 15:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357107AbiFNTNB (ORCPT ); Tue, 14 Jun 2022 15:13:01 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10361D0 for ; Tue, 14 Jun 2022 12:12:58 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B18579E5; Tue, 14 Jun 2022 21:12:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233977; bh=K9npBCq+tHJrYT4GNEeLnPI3pCxXPv+JI547oDpsamY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKDaouJbKplgOKz8/hB24IfgiSly1LULYsV3fMoFj1zA9g0yNJqudYBXHs88XBlFo cgo+aiyQOW38oQ8R5BLNPXI41WdZfAYwa4HvI5/ffVwmqSoO9UFg/Qv0TvznPx5YhW cZbFDKtW3Zx2b0lnE9GJgZEd80Ztpspgo9aoQBz4= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 17/55] media: rkisp1: Fix sensor source pad retrieval at bound time Date: Wed, 15 Jun 2022 04:10:49 +0900 Message-Id: <20220614191127.3420492-18-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart When a sensor is bound, its source pad is retrieved in the .bound() operation with a call to media_entity_get_fwnode_pad(). The function should be called with the source endpoint fwnode of the sensor, but is instead called with the sensor's device fwnode. Fix this, which involves storing a reference to the source endpoint fwnode in the rkisp1_sensor_async structure, and thus implementing the subdev notifier .destroy() operation to release the reference. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 ++ .../platform/rockchip/rkisp1/rkisp1-dev.c | 28 ++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index ba11baf75fa9..60c5462e1746 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -117,6 +117,7 @@ struct rkisp1_info { * * @asd: async_subdev variable for the sensor * @index: index of the sensor (counting sensor found in DT) + * @source_ep: fwnode for the sensor source endpoint * @lanes: number of lanes * @mbus_type: type of bus (currently only CSI2 is supported) * @mbus_flags: media bus (V4L2_MBUS_*) flags @@ -127,6 +128,7 @@ struct rkisp1_info { struct rkisp1_sensor_async { struct v4l2_async_subdev asd; unsigned int index; + struct fwnode_handle *source_ep; unsigned int lanes; enum v4l2_mbus_type mbus_type; unsigned int mbus_flags; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 386c1c17aec2..0f3e45cdbf2a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -138,7 +138,7 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, phy_init(s_asd->dphy); /* Create the link to the sensor. */ - source_pad = media_entity_get_fwnode_pad(&sd->entity, sd->fwnode, + source_pad = media_entity_get_fwnode_pad(&sd->entity, s_asd->source_ep, MEDIA_PAD_FL_SOURCE); if (source_pad < 0) { dev_err(rkisp1->dev, "failed to find source pad for %s\n", @@ -170,10 +170,19 @@ static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) return v4l2_device_register_subdev_nodes(&rkisp1->v4l2_dev); } +static void rkisp1_subdev_notifier_destroy(struct v4l2_async_subdev *asd) +{ + struct rkisp1_sensor_async *rk_asd = + container_of(asd, struct rkisp1_sensor_async, asd); + + fwnode_handle_put(rk_asd->source_ep); +} + static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = { .bound = rkisp1_subdev_notifier_bound, .unbind = rkisp1_subdev_notifier_unbind, .complete = rkisp1_subdev_notifier_complete, + .destroy = rkisp1_subdev_notifier_destroy, }; static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) @@ -190,6 +199,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) .bus_type = V4L2_MBUS_CSI2_DPHY }; struct rkisp1_sensor_async *rk_asd; + struct fwnode_handle *source = NULL; struct fwnode_handle *ep; ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(rkisp1->dev), @@ -202,15 +212,24 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) if (ret) goto err_parse; - rk_asd = v4l2_async_nf_add_fwnode_remote(ntf, ep, - struct - rkisp1_sensor_async); + source = fwnode_graph_get_remote_endpoint(ep); + if (!source) { + dev_err(rkisp1->dev, + "endpoint %pfw has no remote endpoint\n", + ep); + ret = -ENODEV; + goto err_parse; + } + + rk_asd = v4l2_async_nf_add_fwnode(ntf, source, + struct rkisp1_sensor_async); if (IS_ERR(rk_asd)) { ret = PTR_ERR(rk_asd); goto err_parse; } rk_asd->index = index++; + rk_asd->source_ep = source; rk_asd->mbus_type = vep.bus_type; rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; @@ -225,6 +244,7 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) continue; err_parse: fwnode_handle_put(ep); + fwnode_handle_put(source); v4l2_async_nf_cleanup(ntf); return ret; } From patchwork Tue Jun 14 19:10:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881405 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A615DC43334 for ; Tue, 14 Jun 2022 19:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357137AbiFNTNH (ORCPT ); Tue, 14 Jun 2022 15:13:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357271AbiFNTNF (ORCPT ); Tue, 14 Jun 2022 15:13:05 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A0911C0F for ; Tue, 14 Jun 2022 12:13:03 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D39D0D96; Tue, 14 Jun 2022 21:12:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233982; bh=BR3wnKS0KZOPzZGpf+A8iOqDqP+2yYqmab3lSNs2MKU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W+V3/tvhatXeh5lmGfVFnsVx/t7ZzIDfPZnSdneuP+3VOrpjIC6McQ8PSxfhCGUiq +CAoT6L8FhXymbqjd1gZmAFUE+Gk1AalXJ1ObcuUI7tPH5z0kM/Kh62jugpU8u6b1Y ceVzq+SQafRAZsd9SGRXMS0tGAuHC3O5ks77D6A8= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 18/55] media: rkisp1: Split CSI handling to separate file Date: Wed, 15 Jun 2022 04:10:50 +0900 Message-Id: <20220614191127.3420492-19-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Not all ISP instances include a MIPI CSI-2 receiver. To prepare for making it optional, move code related to the CSI-2 receiver to a separate file. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/Makefile | 1 + .../platform/rockchip/rkisp1/rkisp1-common.h | 17 +- .../platform/rockchip/rkisp1/rkisp1-csi.c | 193 ++++++++++++++++++ .../platform/rockchip/rkisp1/rkisp1-csi.h | 28 +++ .../platform/rockchip/rkisp1/rkisp1-dev.c | 32 +-- .../platform/rockchip/rkisp1/rkisp1-isp.c | 153 +------------- 6 files changed, 257 insertions(+), 167 deletions(-) create mode 100644 drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c create mode 100644 drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h diff --git a/drivers/media/platform/rockchip/rkisp1/Makefile b/drivers/media/platform/rockchip/rkisp1/Makefile index f7543a82aa10..b3844c4f7623 100644 --- a/drivers/media/platform/rockchip/rkisp1/Makefile +++ b/drivers/media/platform/rockchip/rkisp1/Makefile @@ -2,6 +2,7 @@ rockchip-isp1-y := rkisp1-capture.o \ rkisp1-common.o \ + rkisp1-csi.o \ rkisp1-dev.o \ rkisp1-isp.o \ rkisp1-resizer.o \ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 60c5462e1746..a52fa9e0dd66 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -123,7 +123,6 @@ struct rkisp1_info { * @mbus_flags: media bus (V4L2_MBUS_*) flags * @sd: a pointer to v4l2_subdev struct of the sensor * @pixel_rate_ctrl: pixel rate of the sensor, used to initialize the phy - * @dphy: a pointer to the phy */ struct rkisp1_sensor_async { struct v4l2_async_subdev asd; @@ -134,7 +133,19 @@ struct rkisp1_sensor_async { unsigned int mbus_flags; struct v4l2_subdev *sd; struct v4l2_ctrl *pixel_rate_ctrl; +}; + +/* + * struct rkisp1_csi - CSI receiver subdev + * + * @rkisp1: pointer to the rkisp1 device + * @dphy: a pointer to the phy + * @is_dphy_errctrl_disabled: if dphy errctrl is disabled (avoid endless interrupt) + */ +struct rkisp1_csi { + struct rkisp1_device *rkisp1; struct phy *dphy; + bool is_dphy_errctrl_disabled; }; /* @@ -147,7 +158,6 @@ struct rkisp1_sensor_async { * @sink_fmt: input format * @src_fmt: output format * @ops_lock: ops serialization - * @is_dphy_errctrl_disabled: if dphy errctrl is disabled (avoid endless interrupt) * @frame_sequence: used to synchronize frame_id between video devices. */ struct rkisp1_isp { @@ -157,7 +167,6 @@ struct rkisp1_isp { const struct rkisp1_mbus_info *sink_fmt; const struct rkisp1_mbus_info *src_fmt; struct mutex ops_lock; /* serialize the subdevice ops */ - bool is_dphy_errctrl_disabled; __u32 frame_sequence; }; @@ -411,6 +420,7 @@ struct rkisp1_debug { * @media_dev: media_device variable * @notifier: a notifier to register on the v4l2-async API to be notified on the sensor * @active_sensor: sensor in-use, set when streaming on + * @csi: internal CSI-2 receiver * @isp: ISP sub-device * @resizer_devs: resizer sub-devices * @capture_devs: capture devices @@ -430,6 +440,7 @@ struct rkisp1_device { struct media_device media_dev; struct v4l2_async_notifier notifier; struct rkisp1_sensor_async *active_sensor; + struct rkisp1_csi csi; struct rkisp1_isp isp; struct rkisp1_resizer resizer_devs[2]; struct rkisp1_capture capture_devs[2]; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c new file mode 100644 index 000000000000..4af04296b625 --- /dev/null +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -0,0 +1,193 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Rockchip ISP1 Driver - CSI-2 Receiver + * + * Copyright (C) 2019 Collabora, Ltd. + * Copyright (C) 2022 Ideas on Board + * + * Based on Rockchip ISP1 driver by Rockchip Electronics Co., Ltd. + * Copyright (C) 2017 Rockchip Electronics Co., Ltd. + */ + +#include +#include +#include + +#include + +#include "rkisp1-common.h" +#include "rkisp1-csi.h" + +int rkisp1_config_mipi(struct rkisp1_csi *csi) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; + unsigned int lanes = rkisp1->active_sensor->lanes; + u32 mipi_ctrl; + + if (lanes < 1 || lanes > 4) + return -EINVAL; + + mipi_ctrl = RKISP1_CIF_MIPI_CTRL_NUM_LANES(lanes - 1) | + RKISP1_CIF_MIPI_CTRL_SHUTDOWNLANES(0xf) | + RKISP1_CIF_MIPI_CTRL_ERR_SOT_SYNC_HS_SKIP | + RKISP1_CIF_MIPI_CTRL_CLOCKLANE_ENA; + + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, mipi_ctrl); + + /* V12 could also use a newer csi2-host, but we don't want that yet */ + if (rkisp1->info->isp_ver == RKISP1_V12) + rkisp1_write(rkisp1, RKISP1_CIF_ISP_CSI0_CTRL0, 0); + + /* Configure Data Type and Virtual Channel */ + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMG_DATA_SEL, + RKISP1_CIF_MIPI_DATA_SEL_DT(sink_fmt->mipi_dt) | + RKISP1_CIF_MIPI_DATA_SEL_VC(0)); + + /* Clear MIPI interrupts */ + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); + /* + * Disable RKISP1_CIF_MIPI_ERR_DPHY interrupt here temporary for + * isp bus may be dead when switch isp. + */ + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, + RKISP1_CIF_MIPI_FRAME_END | RKISP1_CIF_MIPI_ERR_CSI | + RKISP1_CIF_MIPI_ERR_DPHY | + RKISP1_CIF_MIPI_SYNC_FIFO_OVFLW(0x03) | + RKISP1_CIF_MIPI_ADD_DATA_OVFLW); + + dev_dbg(rkisp1->dev, "\n MIPI_CTRL 0x%08x\n" + " MIPI_IMG_DATA_SEL 0x%08x\n" + " MIPI_STATUS 0x%08x\n" + " MIPI_IMSC 0x%08x\n", + rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL), + rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMG_DATA_SEL), + rkisp1_read(rkisp1, RKISP1_CIF_MIPI_STATUS), + rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC)); + + return 0; +} + +int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, + struct rkisp1_sensor_async *sensor) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + union phy_configure_opts opts; + struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; + s64 pixel_clock; + + pixel_clock = v4l2_ctrl_g_ctrl_int64(sensor->pixel_rate_ctrl); + if (!pixel_clock) { + dev_err(rkisp1->dev, "Invalid pixel rate value\n"); + return -EINVAL; + } + + phy_mipi_dphy_get_default_config(pixel_clock, + rkisp1->isp.sink_fmt->bus_width, + sensor->lanes, cfg); + phy_set_mode(csi->dphy, PHY_MODE_MIPI_DPHY); + phy_configure(csi->dphy, &opts); + phy_power_on(csi->dphy); + + return 0; +} + +void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi) +{ + phy_power_off(csi->dphy); +} + +void rkisp1_mipi_start(struct rkisp1_csi *csi) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + u32 val; + + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, + val | RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA); +} + +void rkisp1_mipi_stop(struct rkisp1_csi *csi) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + u32 val; + + /* Mask and clear interrupts. */ + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, 0); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); + + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, + val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); +} + +irqreturn_t rkisp1_mipi_isr(int irq, void *ctx) +{ + struct device *dev = ctx; + struct rkisp1_device *rkisp1 = dev_get_drvdata(dev); + u32 val, status; + + status = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_MIS); + if (!status) + return IRQ_NONE; + + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, status); + + /* + * Disable DPHY errctrl interrupt, because this dphy + * erctrl signal is asserted until the next changes + * of line state. This time is may be too long and cpu + * is hold in this interrupt. + */ + if (status & RKISP1_CIF_MIPI_ERR_CTRL(0x0f)) { + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, + val & ~RKISP1_CIF_MIPI_ERR_CTRL(0x0f)); + rkisp1->csi.is_dphy_errctrl_disabled = true; + } + + /* + * Enable DPHY errctrl interrupt again, if mipi have receive + * the whole frame without any error. + */ + if (status == RKISP1_CIF_MIPI_FRAME_END) { + /* + * Enable DPHY errctrl interrupt again, if mipi have receive + * the whole frame without any error. + */ + if (rkisp1->csi.is_dphy_errctrl_disabled) { + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC); + val |= RKISP1_CIF_MIPI_ERR_CTRL(0x0f); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, val); + rkisp1->csi.is_dphy_errctrl_disabled = false; + } + } else { + rkisp1->debug.mipi_error++; + } + + return IRQ_HANDLED; +} + +int rkisp1_csi_init(struct rkisp1_device *rkisp1) +{ + struct rkisp1_csi *csi = &rkisp1->csi; + + csi->dphy = devm_phy_get(rkisp1->dev, "dphy"); + if (IS_ERR(csi->dphy)) { + if (PTR_ERR(csi->dphy) != -EPROBE_DEFER) + dev_err_probe(rkisp1->dev, PTR_ERR(csi->dphy), + "Couldn't get the MIPI D-PHY\n"); + return PTR_ERR(csi->dphy); + } + + phy_init(csi->dphy); + + return 0; +} + +void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1) +{ + struct rkisp1_csi *csi = &rkisp1->csi; + + phy_exit(csi->dphy); +} diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h new file mode 100644 index 000000000000..d97a4ee5c002 --- /dev/null +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */ +/* + * Rockchip ISP1 Driver - CSI-2 Receiver + * + * Copyright (C) 2019 Collabora, Ltd. + * Copyright (C) 2022 Ideas on Board + * + * Based on Rockchip ISP1 driver by Rockchip Electronics Co., Ltd. + * Copyright (C) 2017 Rockchip Electronics Co., Ltd. + */ +#ifndef _RKISP1_CSI_H +#define _RKISP1_CSI_H + +struct rkisp1_device; +struct rkisp1_sensor_async; + +int rkisp1_csi_init(struct rkisp1_device *rkisp1); +void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); + +int rkisp1_config_mipi(struct rkisp1_csi *csi); + +int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, + struct rkisp1_sensor_async *sensor); +void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi); +void rkisp1_mipi_start(struct rkisp1_csi *csi); +void rkisp1_mipi_stop(struct rkisp1_csi *csi); + +#endif /* _RKISP1_CSI_H */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 0f3e45cdbf2a..373a1f00c10a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -15,11 +15,11 @@ #include #include #include -#include -#include +#include #include #include "rkisp1-common.h" +#include "rkisp1-csi.h" /* * ISP Details @@ -128,14 +128,6 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, } s_asd->sd = sd; - s_asd->dphy = devm_phy_get(rkisp1->dev, "dphy"); - if (IS_ERR(s_asd->dphy)) { - if (PTR_ERR(s_asd->dphy) != -EPROBE_DEFER) - dev_err(rkisp1->dev, "Couldn't get the MIPI D-PHY\n"); - return PTR_ERR(s_asd->dphy); - } - - phy_init(s_asd->dphy); /* Create the link to the sensor. */ source_pad = media_entity_get_fwnode_pad(&sd->entity, s_asd->source_ep, @@ -152,16 +144,6 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); } -static void rkisp1_subdev_notifier_unbind(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *sd, - struct v4l2_async_subdev *asd) -{ - struct rkisp1_sensor_async *s_asd = - container_of(asd, struct rkisp1_sensor_async, asd); - - phy_exit(s_asd->dphy); -} - static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) { struct rkisp1_device *rkisp1 = @@ -180,7 +162,6 @@ static void rkisp1_subdev_notifier_destroy(struct v4l2_async_subdev *asd) static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = { .bound = rkisp1_subdev_notifier_bound, - .unbind = rkisp1_subdev_notifier_unbind, .complete = rkisp1_subdev_notifier_complete, .destroy = rkisp1_subdev_notifier_destroy, }; @@ -540,14 +521,20 @@ static int rkisp1_probe(struct platform_device *pdev) goto err_unreg_v4l2_dev; } - ret = rkisp1_entities_register(rkisp1); + ret = rkisp1_csi_init(rkisp1); if (ret) goto err_unreg_media_dev; + ret = rkisp1_entities_register(rkisp1); + if (ret) + goto err_cleanup_csi; + rkisp1_debug_init(rkisp1); return 0; +err_cleanup_csi: + rkisp1_csi_cleanup(rkisp1); err_unreg_media_dev: media_device_unregister(&rkisp1->media_dev); err_unreg_v4l2_dev: @@ -565,6 +552,7 @@ static int rkisp1_remove(struct platform_device *pdev) v4l2_async_nf_cleanup(&rkisp1->notifier); rkisp1_entities_unregister(rkisp1); + rkisp1_csi_cleanup(rkisp1); rkisp1_debug_cleanup(rkisp1); media_device_unregister(&rkisp1->media_dev); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 81138c676ac0..5eabb321e320 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -9,8 +9,6 @@ */ #include -#include -#include #include #include #include @@ -18,6 +16,7 @@ #include #include "rkisp1-common.h" +#include "rkisp1-csi.h" #define RKISP1_DEF_SINK_PAD_FMT MEDIA_BUS_FMT_SRGGB10_1X10 #define RKISP1_DEF_SRC_PAD_FMT MEDIA_BUS_FMT_YUYV8_2X8 @@ -265,55 +264,6 @@ static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) return 0; } -static int rkisp1_config_mipi(struct rkisp1_device *rkisp1) -{ - const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; - unsigned int lanes = rkisp1->active_sensor->lanes; - u32 mipi_ctrl; - - if (lanes < 1 || lanes > 4) - return -EINVAL; - - mipi_ctrl = RKISP1_CIF_MIPI_CTRL_NUM_LANES(lanes - 1) | - RKISP1_CIF_MIPI_CTRL_SHUTDOWNLANES(0xf) | - RKISP1_CIF_MIPI_CTRL_ERR_SOT_SYNC_HS_SKIP | - RKISP1_CIF_MIPI_CTRL_CLOCKLANE_ENA; - - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, mipi_ctrl); - - /* V12 could also use a newer csi2-host, but we don't want that yet */ - if (rkisp1->info->isp_ver == RKISP1_V12) - rkisp1_write(rkisp1, RKISP1_CIF_ISP_CSI0_CTRL0, 0); - - /* Configure Data Type and Virtual Channel */ - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMG_DATA_SEL, - RKISP1_CIF_MIPI_DATA_SEL_DT(sink_fmt->mipi_dt) | - RKISP1_CIF_MIPI_DATA_SEL_VC(0)); - - /* Clear MIPI interrupts */ - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); - /* - * Disable RKISP1_CIF_MIPI_ERR_DPHY interrupt here temporary for - * isp bus may be dead when switch isp. - */ - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, - RKISP1_CIF_MIPI_FRAME_END | RKISP1_CIF_MIPI_ERR_CSI | - RKISP1_CIF_MIPI_ERR_DPHY | - RKISP1_CIF_MIPI_SYNC_FIFO_OVFLW(0x03) | - RKISP1_CIF_MIPI_ADD_DATA_OVFLW); - - dev_dbg(rkisp1->dev, "\n MIPI_CTRL 0x%08x\n" - " MIPI_IMG_DATA_SEL 0x%08x\n" - " MIPI_STATUS 0x%08x\n" - " MIPI_IMSC 0x%08x\n", - rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL), - rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMG_DATA_SEL), - rkisp1_read(rkisp1, RKISP1_CIF_MIPI_STATUS), - rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC)); - - return 0; -} - /* Configure MUX */ static int rkisp1_config_path(struct rkisp1_device *rkisp1) { @@ -326,7 +276,7 @@ static int rkisp1_config_path(struct rkisp1_device *rkisp1) ret = rkisp1_config_dvp(rkisp1); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_PARALLEL; } else if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) { - ret = rkisp1_config_mipi(rkisp1); + ret = rkisp1_config_mipi(&rkisp1->csi); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_MIPI; } @@ -360,17 +310,14 @@ static void rkisp1_isp_stop(struct rkisp1_device *rkisp1) * Stop ISP(isp) ->wait for ISP isp off */ /* stop and clear MI, MIPI, and ISP interrupts */ - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, 0); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); - rkisp1_write(rkisp1, RKISP1_CIF_ISP_IMSC, 0); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ICR, ~0); rkisp1_write(rkisp1, RKISP1_CIF_MI_IMSC, 0); rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, ~0); - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, - val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); + + rkisp1_mipi_stop(&rkisp1->csi); + /* stop ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); val &= ~(RKISP1_CIF_ISP_CTRL_ISP_INFORM_ENABLE | @@ -417,11 +364,9 @@ static void rkisp1_isp_start(struct rkisp1_device *rkisp1) rkisp1_config_clk(rkisp1); /* Activate MIPI */ - if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) { - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, - val | RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA); - } + if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) + rkisp1_mipi_start(&rkisp1->csi); + /* Activate ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); val |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD | @@ -814,35 +759,6 @@ static const struct v4l2_subdev_pad_ops rkisp1_isp_pad_ops = { * Stream operations */ -static int rkisp1_mipi_csi2_start(struct rkisp1_isp *isp, - struct rkisp1_sensor_async *sensor) -{ - struct rkisp1_device *rkisp1 = - container_of(isp->sd.v4l2_dev, struct rkisp1_device, v4l2_dev); - union phy_configure_opts opts; - struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; - s64 pixel_clock; - - pixel_clock = v4l2_ctrl_g_ctrl_int64(sensor->pixel_rate_ctrl); - if (!pixel_clock) { - dev_err(rkisp1->dev, "Invalid pixel rate value\n"); - return -EINVAL; - } - - phy_mipi_dphy_get_default_config(pixel_clock, isp->sink_fmt->bus_width, - sensor->lanes, cfg); - phy_set_mode(sensor->dphy, PHY_MODE_MIPI_DPHY); - phy_configure(sensor->dphy, &opts); - phy_power_on(sensor->dphy); - - return 0; -} - -static void rkisp1_mipi_csi2_stop(struct rkisp1_sensor_async *sensor) -{ - phy_power_off(sensor->dphy); -} - static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) { struct rkisp1_device *rkisp1 = @@ -856,7 +772,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) false); rkisp1_isp_stop(rkisp1); - rkisp1_mipi_csi2_stop(rkisp1->active_sensor); + rkisp1_mipi_csi2_stop(&rkisp1->csi); return 0; } @@ -878,7 +794,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) if (ret) goto mutex_unlock; - ret = rkisp1_mipi_csi2_start(&rkisp1->isp, rkisp1->active_sensor); + ret = rkisp1_mipi_csi2_start(&rkisp1->csi, rkisp1->active_sensor); if (ret) goto mutex_unlock; @@ -888,7 +804,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) true); if (ret) { rkisp1_isp_stop(rkisp1); - rkisp1_mipi_csi2_stop(rkisp1->active_sensor); + rkisp1_mipi_csi2_stop(&rkisp1->csi); goto mutex_unlock; } @@ -993,53 +909,6 @@ void rkisp1_isp_unregister(struct rkisp1_device *rkisp1) * Interrupt handlers */ -irqreturn_t rkisp1_mipi_isr(int irq, void *ctx) -{ - struct device *dev = ctx; - struct rkisp1_device *rkisp1 = dev_get_drvdata(dev); - u32 val, status; - - status = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_MIS); - if (!status) - return IRQ_NONE; - - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, status); - - /* - * Disable DPHY errctrl interrupt, because this dphy - * erctrl signal is asserted until the next changes - * of line state. This time is may be too long and cpu - * is hold in this interrupt. - */ - if (status & RKISP1_CIF_MIPI_ERR_CTRL(0x0f)) { - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, - val & ~RKISP1_CIF_MIPI_ERR_CTRL(0x0f)); - rkisp1->isp.is_dphy_errctrl_disabled = true; - } - - /* - * Enable DPHY errctrl interrupt again, if mipi have receive - * the whole frame without any error. - */ - if (status == RKISP1_CIF_MIPI_FRAME_END) { - /* - * Enable DPHY errctrl interrupt again, if mipi have receive - * the whole frame without any error. - */ - if (rkisp1->isp.is_dphy_errctrl_disabled) { - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_IMSC); - val |= RKISP1_CIF_MIPI_ERR_CTRL(0x0f); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, val); - rkisp1->isp.is_dphy_errctrl_disabled = false; - } - } else { - rkisp1->debug.mipi_error++; - } - - return IRQ_HANDLED; -} - static void rkisp1_isp_queue_event_sof(struct rkisp1_isp *isp) { struct v4l2_event event = { From patchwork Tue Jun 14 19:10:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881406 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2394C433EF for ; Tue, 14 Jun 2022 19:13:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345473AbiFNTNK (ORCPT ); Tue, 14 Jun 2022 15:13:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357228AbiFNTNH (ORCPT ); Tue, 14 Jun 2022 15:13:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45435167E1 for ; Tue, 14 Jun 2022 12:13:07 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2D22825; Tue, 14 Jun 2022 21:13:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233986; bh=eSmCMdUtxHqbgRDuGNxkbYgoA5HVwiupuRMK0U0lEW4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AAKigp01AQ9Qpy0H5Afbl6B52sZ2askUtzATYvZSvTsKya/a/e3UVnEAHqTg+9Vmw U60DaSpK5cws2Bv8bhuCQYAEKoMzf2pqCCHEH+Na/o1ZfCLkcQtyGMG01WZCvz5eOh 5nNXIw46JEZYzotaLddFhNIBAvYhmOui4q95IL2A= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 19/55] media: rkisp1: isp: Start CSI-2 receiver before ISP Date: Wed, 15 Jun 2022 04:10:51 +0900 Message-Id: <20220614191127.3420492-20-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Make sure the ISP is ready to receive data before starting the CSI-2 receiver by starting it first. Similarly, stop the CSI-2 receiver before the ISP when stopping streaming. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 5eabb321e320..0e68c8d53404 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -771,8 +771,9 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, false); - rkisp1_isp_stop(rkisp1); rkisp1_mipi_csi2_stop(&rkisp1->csi); + rkisp1_isp_stop(rkisp1); + return 0; } @@ -794,11 +795,13 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) if (ret) goto mutex_unlock; + rkisp1_isp_start(rkisp1); + ret = rkisp1_mipi_csi2_start(&rkisp1->csi, rkisp1->active_sensor); - if (ret) + if (ret) { + rkisp1_isp_stop(rkisp1); goto mutex_unlock; - - rkisp1_isp_start(rkisp1); + } ret = v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, true); From patchwork Tue Jun 14 19:10:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881407 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 625DEC433EF for ; Tue, 14 Jun 2022 19:13:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357228AbiFNTNN (ORCPT ); Tue, 14 Jun 2022 15:13:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356266AbiFNTNM (ORCPT ); Tue, 14 Jun 2022 15:13:12 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5918F764E for ; Tue, 14 Jun 2022 12:13:11 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2ECB9E5; Tue, 14 Jun 2022 21:13:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233990; bh=yLehz9iX9xX3s4cg3uv51RrHUohI2wgfVSeQoP8kya0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ssMB2VbC4/cXBPbwGSf35glWDiDZn5gdCGK5J66dmRS0v+A/s8tp/R35DZFbjAv2M HacO1vz3Z21PVJ+R7nvVWZ/K9BKrRl0ZdlSCnGOqO3iQAYoOXRh2waiZ+EAAdm6Aau vJdKsR6dr755cJid7Hq95IsFIeOk9NBdd5U3J7UY= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 20/55] media: rkisp1: csi: Handle CSI-2 RX configuration fully in rkisp1-csi.c Date: Wed, 15 Jun 2022 04:10:52 +0900 Message-Id: <20220614191127.3420492-21-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ISP layer now calls multiple functions of the CSI-2 RX layer to configure, start and stop it, with the steps for the last two operations. Move those calls to rkisp1_mipi_csi2_start() and rkisp1_mipi_csi2_stop() to simplify the ISP code and the API exposed by the CSI-2 receiver component. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-csi.c | 59 +++++++++++-------- .../platform/rockchip/rkisp1/rkisp1-csi.h | 4 -- .../platform/rockchip/rkisp1/rkisp1-isp.c | 10 +--- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index 4af04296b625..f19513a601e8 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -18,7 +18,7 @@ #include "rkisp1-common.h" #include "rkisp1-csi.h" -int rkisp1_config_mipi(struct rkisp1_csi *csi) +static int rkisp1_config_mipi(struct rkisp1_csi *csi) { struct rkisp1_device *rkisp1 = csi->rkisp1; const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; @@ -68,6 +68,30 @@ int rkisp1_config_mipi(struct rkisp1_csi *csi) return 0; } +void rkisp1_mipi_start(struct rkisp1_csi *csi) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + u32 val; + + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, + val | RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA); +} + +void rkisp1_mipi_stop(struct rkisp1_csi *csi) +{ + struct rkisp1_device *rkisp1 = csi->rkisp1; + u32 val; + + /* Mask and clear interrupts. */ + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, 0); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); + + val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); + rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, + val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); +} + int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, struct rkisp1_sensor_async *sensor) { @@ -75,6 +99,11 @@ int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, union phy_configure_opts opts; struct phy_configure_opts_mipi_dphy *cfg = &opts.mipi_dphy; s64 pixel_clock; + int ret; + + ret = rkisp1_config_mipi(csi); + if (ret) + return ret; pixel_clock = v4l2_ctrl_g_ctrl_int64(sensor->pixel_rate_ctrl); if (!pixel_clock) { @@ -89,36 +118,16 @@ int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, phy_configure(csi->dphy, &opts); phy_power_on(csi->dphy); + rkisp1_mipi_start(csi); + return 0; } void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi) { - phy_power_off(csi->dphy); -} - -void rkisp1_mipi_start(struct rkisp1_csi *csi) -{ - struct rkisp1_device *rkisp1 = csi->rkisp1; - u32 val; + rkisp1_mipi_stop(csi); - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, - val | RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA); -} - -void rkisp1_mipi_stop(struct rkisp1_csi *csi) -{ - struct rkisp1_device *rkisp1 = csi->rkisp1; - u32 val; - - /* Mask and clear interrupts. */ - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_IMSC, 0); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_ICR, ~0); - - val = rkisp1_read(rkisp1, RKISP1_CIF_MIPI_CTRL); - rkisp1_write(rkisp1, RKISP1_CIF_MIPI_CTRL, - val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); + phy_power_off(csi->dphy); } irqreturn_t rkisp1_mipi_isr(int irq, void *ctx) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h index d97a4ee5c002..1f921d534865 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -17,12 +17,8 @@ struct rkisp1_sensor_async; int rkisp1_csi_init(struct rkisp1_device *rkisp1); void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); -int rkisp1_config_mipi(struct rkisp1_csi *csi); - int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, struct rkisp1_sensor_async *sensor); void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi); -void rkisp1_mipi_start(struct rkisp1_csi *csi); -void rkisp1_mipi_stop(struct rkisp1_csi *csi); #endif /* _RKISP1_CSI_H */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 0e68c8d53404..208c68aa52ea 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -276,7 +276,6 @@ static int rkisp1_config_path(struct rkisp1_device *rkisp1) ret = rkisp1_config_dvp(rkisp1); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_PARALLEL; } else if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) { - ret = rkisp1_config_mipi(&rkisp1->csi); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_MIPI; } @@ -309,15 +308,13 @@ static void rkisp1_isp_stop(struct rkisp1_device *rkisp1) * ISP(mi) stop in mi frame end -> Stop ISP(mipi) -> * Stop ISP(isp) ->wait for ISP isp off */ - /* stop and clear MI, MIPI, and ISP interrupts */ + /* stop and clear MI and ISP interrupts */ rkisp1_write(rkisp1, RKISP1_CIF_ISP_IMSC, 0); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ICR, ~0); rkisp1_write(rkisp1, RKISP1_CIF_MI_IMSC, 0); rkisp1_write(rkisp1, RKISP1_CIF_MI_ICR, ~0); - rkisp1_mipi_stop(&rkisp1->csi); - /* stop ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); val &= ~(RKISP1_CIF_ISP_CTRL_ISP_INFORM_ENABLE | @@ -358,15 +355,10 @@ static void rkisp1_config_clk(struct rkisp1_device *rkisp1) static void rkisp1_isp_start(struct rkisp1_device *rkisp1) { - struct rkisp1_sensor_async *sensor = rkisp1->active_sensor; u32 val; rkisp1_config_clk(rkisp1); - /* Activate MIPI */ - if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) - rkisp1_mipi_start(&rkisp1->csi); - /* Activate ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); val |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD | From patchwork Tue Jun 14 19:10:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881408 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE24DC43334 for ; Tue, 14 Jun 2022 19:13:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357370AbiFNTNR (ORCPT ); Tue, 14 Jun 2022 15:13:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243622AbiFNTNQ (ORCPT ); Tue, 14 Jun 2022 15:13:16 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BD41C2 for ; Tue, 14 Jun 2022 12:13:15 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C9DB1D96; Tue, 14 Jun 2022 21:13:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233994; bh=Dj3w8Yy6C+KPFthDULRS9YCi+MtkmY+sGf1KnXve3io=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K9GVPI2dJJo528hN6KtSqfFP9wIk5AMwmu/1m6gi/BQAutcRPrekdMNqBaEtT1N2f D7poQohWjtjPUhM2lAlq6E80WRbW1JT8GeR02FEcdgb/OnvDjNOxpLhwlCx0sW4yYA 14o78uE2pPslGuilCFpbr8drqPARbcvK0zFfhxv8= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 21/55] media: rkisp1: csi: Rename CSI functions with a common rkisp1_csi prefix Date: Wed, 15 Jun 2022 04:10:53 +0900 Message-Id: <20220614191127.3420492-22-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The CSI-related functions are not named consistently. Fix it by using a common rkisp1_csi prefix. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 +- .../platform/rockchip/rkisp1/rkisp1-csi.c | 20 +++++++++---------- .../platform/rockchip/rkisp1/rkisp1-csi.h | 6 +++--- .../platform/rockchip/rkisp1/rkisp1-dev.c | 4 ++-- .../platform/rockchip/rkisp1/rkisp1-isp.c | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index a52fa9e0dd66..dbf1baca623a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -555,7 +555,7 @@ void rkisp1_params_disable(struct rkisp1_params *params); /* irq handlers */ irqreturn_t rkisp1_isp_isr(int irq, void *ctx); -irqreturn_t rkisp1_mipi_isr(int irq, void *ctx); +irqreturn_t rkisp1_csi_isr(int irq, void *ctx); irqreturn_t rkisp1_capture_isr(int irq, void *ctx); void rkisp1_stats_isr(struct rkisp1_stats *stats, u32 isp_ris); void rkisp1_params_isr(struct rkisp1_device *rkisp1); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index f19513a601e8..c1bb8c05543d 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -18,7 +18,7 @@ #include "rkisp1-common.h" #include "rkisp1-csi.h" -static int rkisp1_config_mipi(struct rkisp1_csi *csi) +static int rkisp1_csi_config(struct rkisp1_csi *csi) { struct rkisp1_device *rkisp1 = csi->rkisp1; const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; @@ -68,7 +68,7 @@ static int rkisp1_config_mipi(struct rkisp1_csi *csi) return 0; } -void rkisp1_mipi_start(struct rkisp1_csi *csi) +static void rkisp1_csi_enable(struct rkisp1_csi *csi) { struct rkisp1_device *rkisp1 = csi->rkisp1; u32 val; @@ -78,7 +78,7 @@ void rkisp1_mipi_start(struct rkisp1_csi *csi) val | RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA); } -void rkisp1_mipi_stop(struct rkisp1_csi *csi) +static void rkisp1_csi_disable(struct rkisp1_csi *csi) { struct rkisp1_device *rkisp1 = csi->rkisp1; u32 val; @@ -92,8 +92,8 @@ void rkisp1_mipi_stop(struct rkisp1_csi *csi) val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); } -int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, - struct rkisp1_sensor_async *sensor) +int rkisp1_csi_start(struct rkisp1_csi *csi, + struct rkisp1_sensor_async *sensor) { struct rkisp1_device *rkisp1 = csi->rkisp1; union phy_configure_opts opts; @@ -101,7 +101,7 @@ int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, s64 pixel_clock; int ret; - ret = rkisp1_config_mipi(csi); + ret = rkisp1_csi_config(csi); if (ret) return ret; @@ -118,19 +118,19 @@ int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, phy_configure(csi->dphy, &opts); phy_power_on(csi->dphy); - rkisp1_mipi_start(csi); + rkisp1_csi_enable(csi); return 0; } -void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi) +void rkisp1_csi_stop(struct rkisp1_csi *csi) { - rkisp1_mipi_stop(csi); + rkisp1_csi_disable(csi); phy_power_off(csi->dphy); } -irqreturn_t rkisp1_mipi_isr(int irq, void *ctx) +irqreturn_t rkisp1_csi_isr(int irq, void *ctx) { struct device *dev = ctx; struct rkisp1_device *rkisp1 = dev_get_drvdata(dev); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h index 1f921d534865..7d3f01cfb49f 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -17,8 +17,8 @@ struct rkisp1_sensor_async; int rkisp1_csi_init(struct rkisp1_device *rkisp1); void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); -int rkisp1_mipi_csi2_start(struct rkisp1_csi *csi, - struct rkisp1_sensor_async *sensor); -void rkisp1_mipi_csi2_stop(struct rkisp1_csi *csi); +int rkisp1_csi_start(struct rkisp1_csi *csi, + struct rkisp1_sensor_async *sensor); +void rkisp1_csi_stop(struct rkisp1_csi *csi); #endif /* _RKISP1_CSI_H */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 373a1f00c10a..253220188abd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -383,7 +383,7 @@ static irqreturn_t rkisp1_isr(int irq, void *ctx) */ rkisp1_capture_isr(irq, ctx); rkisp1_isp_isr(irq, ctx); - rkisp1_mipi_isr(irq, ctx); + rkisp1_csi_isr(irq, ctx); return IRQ_HANDLED; } @@ -398,7 +398,7 @@ static const char * const px30_isp_clks[] = { static const struct rkisp1_isr_data px30_isp_isrs[] = { { "isp", rkisp1_isp_isr }, { "mi", rkisp1_capture_isr }, - { "mipi", rkisp1_mipi_isr }, + { "mipi", rkisp1_csi_isr }, }; static const struct rkisp1_info px30_isp_info = { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 208c68aa52ea..ecb8ca0ad670 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -763,7 +763,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, false); - rkisp1_mipi_csi2_stop(&rkisp1->csi); + rkisp1_csi_stop(&rkisp1->csi); rkisp1_isp_stop(rkisp1); return 0; @@ -789,7 +789,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) rkisp1_isp_start(rkisp1); - ret = rkisp1_mipi_csi2_start(&rkisp1->csi, rkisp1->active_sensor); + ret = rkisp1_csi_start(&rkisp1->csi, rkisp1->active_sensor); if (ret) { rkisp1_isp_stop(rkisp1); goto mutex_unlock; @@ -799,7 +799,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) true); if (ret) { rkisp1_isp_stop(rkisp1); - rkisp1_mipi_csi2_stop(&rkisp1->csi); + rkisp1_csi_stop(&rkisp1->csi); goto mutex_unlock; } From patchwork Tue Jun 14 19:10:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881456 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDE8FC43334 for ; Tue, 14 Jun 2022 19:13:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243622AbiFNTNf (ORCPT ); Tue, 14 Jun 2022 15:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235369AbiFNTNT (ORCPT ); Tue, 14 Jun 2022 15:13:19 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4088111C0F for ; Tue, 14 Jun 2022 12:13:19 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A311B825; Tue, 14 Jun 2022 21:13:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655233998; bh=ej2B32tUERRKgixONq9ekw2odpbfaviOoKuWtBeOUfM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hHnEHCFEDVGpBuPuxhDZwIjWIkCJzJyviV/rmkj8Jm4mgRDpwuyjunJxPJF5SvdMp LxVq3ac5JWXR5UMw1ioWxip28itSeMXVP3fKBWblumlq7A+49qv5c9OzFExpOOtry7 YpHYUaevxOIb0x4ReeoxvTWkg/atVgjfs3hiu3dI= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 22/55] media: rkisp1: csi: Move start delay to rkisp1_csi_start() Date: Wed, 15 Jun 2022 04:10:54 +0900 Message-Id: <20220614191127.3420492-23-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The delay in rkisp1_isp_start() is related to to the CSI-2 receiver and the camera sensor. Move it where it belongs, to rkisp1_csi_start(). Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c | 7 +++++++ drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 6 ------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index c1bb8c05543d..fcaffffd371b 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -9,6 +9,7 @@ * Copyright (C) 2017 Rockchip Electronics Co., Ltd. */ +#include #include #include #include @@ -120,6 +121,12 @@ int rkisp1_csi_start(struct rkisp1_csi *csi, rkisp1_csi_enable(csi); + /* + * CIF spec says to wait for sufficient time after enabling + * the MIPI interface and before starting the sensor output. + */ + usleep_range(1000, 1200); + return 0; } diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index ecb8ca0ad670..3ea0deb6b792 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -365,12 +365,6 @@ static void rkisp1_isp_start(struct rkisp1_device *rkisp1) RKISP1_CIF_ISP_CTRL_ISP_ENABLE | RKISP1_CIF_ISP_CTRL_ISP_INFORM_ENABLE; rkisp1_write(rkisp1, RKISP1_CIF_ISP_CTRL, val); - - /* - * CIF spec says to wait for sufficient time after enabling - * the MIPI interface and before starting the sensor output. - */ - usleep_range(1000, 1200); } /* ---------------------------------------------------------------------------- From patchwork Tue Jun 14 19:10:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 260EDCCA47B for ; Tue, 14 Jun 2022 19:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245301AbiFNTNf (ORCPT ); Tue, 14 Jun 2022 15:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357407AbiFNTNY (ORCPT ); Tue, 14 Jun 2022 15:13:24 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5533228705 for ; Tue, 14 Jun 2022 12:13:23 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2DB79E5; Tue, 14 Jun 2022 21:13:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234002; bh=kU4BvR4gtyLqWIj3HHrrQsSfcQk7hfRJpaJgG5KXHIQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JjLOFLnu+q3ZwerYd7hdC5eqHgRPJGBwOY8rfiubCo2Se3Ctmx1vhDUq4RQdKB2qb ZMpesyGQWTv7ic19+IT/myL9wb64LdKH/j4bDk6hkdTFO0OthdKsaxhkQwB4eEem5S VDBO1Th7sUG0p1tbsctWXnaqaGy/7irWMOrducmU= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 23/55] media: rkisp1: csi: Pass sensor pointer to rkisp1_csi_config() Date: Wed, 15 Jun 2022 04:10:55 +0900 Message-Id: <20220614191127.3420492-24-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart To prepare for the removal of the active_sensor field from the rkisp1_device structure, pass the sensor pointer to the rkisp1_csi_config() function instead of accessing it through active_sensor. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index fcaffffd371b..925274b9a3c4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -19,11 +19,12 @@ #include "rkisp1-common.h" #include "rkisp1-csi.h" -static int rkisp1_csi_config(struct rkisp1_csi *csi) +static int rkisp1_csi_config(struct rkisp1_csi *csi, + struct rkisp1_sensor_async *sensor) { struct rkisp1_device *rkisp1 = csi->rkisp1; const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; - unsigned int lanes = rkisp1->active_sensor->lanes; + unsigned int lanes = sensor->lanes; u32 mipi_ctrl; if (lanes < 1 || lanes > 4) @@ -102,7 +103,7 @@ int rkisp1_csi_start(struct rkisp1_csi *csi, s64 pixel_clock; int ret; - ret = rkisp1_csi_config(csi); + ret = rkisp1_csi_config(csi, sensor); if (ret) return ret; From patchwork Tue Jun 14 19:10:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881458 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A79E2CCA480 for ; Tue, 14 Jun 2022 19:13:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236059AbiFNTNh (ORCPT ); Tue, 14 Jun 2022 15:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357483AbiFNTN1 (ORCPT ); Tue, 14 Jun 2022 15:13:27 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1CDD61260D for ; Tue, 14 Jun 2022 12:13:27 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A2F08825; Tue, 14 Jun 2022 21:13:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234005; bh=iIHXQZ2sOYbmnNJklnn0bmABq2AvSYS02MD7fTAEsbg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMGQsHMOJKveopyLfGGAGqEdJxVmwa5Q10g7yBuzLQz+tV/m3iDZX5xsV8VZNbPm2 upB/XuNlAscSDciGZq2/EiGYCHqq2g9+su2kynPWXeC1L5wv7SVkU/uY7WovT/beXt 8EiHGkLrR43BQtbUzUtNRJFrGhZsLJSofaW1JC28= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 24/55] media: rkisp1: csi: Constify argument to rkisp1_csi_start() Date: Wed, 15 Jun 2022 04:10:56 +0900 Message-Id: <20220614191127.3420492-25-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The sensor argument to rkisp1_csi_start() isn't meant to be modified by the function. Make it const. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c | 4 ++-- drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index 925274b9a3c4..425a3b014089 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -20,7 +20,7 @@ #include "rkisp1-csi.h" static int rkisp1_csi_config(struct rkisp1_csi *csi, - struct rkisp1_sensor_async *sensor) + const struct rkisp1_sensor_async *sensor) { struct rkisp1_device *rkisp1 = csi->rkisp1; const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; @@ -95,7 +95,7 @@ static void rkisp1_csi_disable(struct rkisp1_csi *csi) } int rkisp1_csi_start(struct rkisp1_csi *csi, - struct rkisp1_sensor_async *sensor) + const struct rkisp1_sensor_async *sensor) { struct rkisp1_device *rkisp1 = csi->rkisp1; union phy_configure_opts opts; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h index 7d3f01cfb49f..97ce7e7959ab 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -18,7 +18,7 @@ int rkisp1_csi_init(struct rkisp1_device *rkisp1); void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); int rkisp1_csi_start(struct rkisp1_csi *csi, - struct rkisp1_sensor_async *sensor); + const struct rkisp1_sensor_async *sensor); void rkisp1_csi_stop(struct rkisp1_csi *csi); #endif /* _RKISP1_CSI_H */ From patchwork Tue Jun 14 19:10:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881460 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C18FC43334 for ; Tue, 14 Jun 2022 19:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350914AbiFNTNh (ORCPT ); Tue, 14 Jun 2022 15:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357599AbiFNTNb (ORCPT ); Tue, 14 Jun 2022 15:13:31 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F00F2764E for ; Tue, 14 Jun 2022 12:13:30 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 75B89D96; Tue, 14 Jun 2022 21:13:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234009; bh=35br+PBGDYimxknyVI8XqRWDD0b9S/DSRrn5qKiWY6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t4myaVjzWPrvYpED+Ffsu43wnK6LlYemIw80A22B2XQ+G0SrlCNWPnJKCukoCcEXt +SGDSUOiHpDwXxySn+gsOsVjWFDEZQtgM6yWWXAe55oCehF9DoH4A2SHeuMm5RA0K1 1aUbgZjO07mrRPXBuxeAZ8Kxhwf+A56bpf4kViXQ= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 25/55] media: rkisp1: isp: Don't initialize ret to 0 in rkisp1_isp_s_stream() Date: Wed, 15 Jun 2022 04:10:57 +0900 Message-Id: <20220614191127.3420492-26-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ret variable doesn't need to be initialized in rkisp1_isp_s_stream(). Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 3ea0deb6b792..a234cf29ec67 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -751,7 +751,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); struct rkisp1_isp *isp = &rkisp1->isp; struct v4l2_subdev *sensor_sd; - int ret = 0; + int ret; if (!enable) { v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, From patchwork Tue Jun 14 19:10:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881459 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BE9CCA483 for ; Tue, 14 Jun 2022 19:13:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357271AbiFNTNi (ORCPT ); Tue, 14 Jun 2022 15:13:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344359AbiFNTNg (ORCPT ); Tue, 14 Jun 2022 15:13:36 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2656A11C0F for ; Tue, 14 Jun 2022 12:13:35 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54A8D825; Tue, 14 Jun 2022 21:13:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234013; bh=tZdsTEOzZ0A5HJGR1F3OoUPE4i5dFnHw09rTYGtqYNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H3o3JQ6onfS3TdxMjM53jlS9xIRc2tJEMvBYdiAsB86sVSvE8Rl6DUBM6ba1Ifu3r YzrzMK7aXr8v9+k0InuJmFEJ9VDBgGlqFKHAfJ6R2cXOn8ZvWiYeD5yLd6eua02IyB 8ruz/fc7n2x/F0a/Dj5dqw1uu4LRi6GqQun9TiBY= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 26/55] media: rkisp1: isp: Pass mbus type and flags to rkisp1_config_cif() Date: Wed, 15 Jun 2022 04:10:58 +0900 Message-Id: <20220614191127.3420492-27-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart To prepare for the removal of the active_sensor field from the rkisp1_device structure, pass the media bus type of flag to the rkisp1_config_cif() function instead of accessing them through active_sensor. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index a234cf29ec67..f6d1c93dd99d 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -136,15 +136,14 @@ static void rkisp1_config_ism(struct rkisp1_device *rkisp1) /* * configure ISP blocks with input format, size...... */ -static int rkisp1_config_isp(struct rkisp1_device *rkisp1) +static int rkisp1_config_isp(struct rkisp1_device *rkisp1, + enum v4l2_mbus_type mbus_type, u32 mbus_flags) { u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0; const struct rkisp1_mbus_info *src_fmt, *sink_fmt; - struct rkisp1_sensor_async *sensor; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; - sensor = rkisp1->active_sensor; sink_fmt = rkisp1->isp.sink_fmt; src_fmt = rkisp1->isp.src_fmt; sink_frm = rkisp1_isp_get_pad_fmt(&rkisp1->isp, NULL, @@ -157,7 +156,7 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) if (sink_fmt->pixel_enc == V4L2_PIXEL_ENC_BAYER) { acq_mult = 1; if (src_fmt->pixel_enc == V4L2_PIXEL_ENC_BAYER) { - if (sensor->mbus_type == V4L2_MBUS_BT656) + if (mbus_type == V4L2_MBUS_BT656) isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_RAW_PICT_ITU656; else isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_RAW_PICT; @@ -165,17 +164,17 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, RKISP1_CIF_ISP_DEMOSAIC, RKISP1_CIF_ISP_DEMOSAIC_TH(0xc)); - if (sensor->mbus_type == V4L2_MBUS_BT656) + if (mbus_type == V4L2_MBUS_BT656) isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_BAYER_ITU656; else isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_BAYER_ITU601; } } else if (sink_fmt->pixel_enc == V4L2_PIXEL_ENC_YUV) { acq_mult = 2; - if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) { + if (mbus_type == V4L2_MBUS_CSI2_DPHY) { isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_ITU601; } else { - if (sensor->mbus_type == V4L2_MBUS_BT656) + if (mbus_type == V4L2_MBUS_BT656) isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_ITU656; else isp_ctrl = RKISP1_CIF_ISP_CTRL_ISP_MODE_ITU601; @@ -185,17 +184,16 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1) } /* Set up input acquisition properties */ - if (sensor->mbus_type == V4L2_MBUS_BT656 || - sensor->mbus_type == V4L2_MBUS_PARALLEL) { - if (sensor->mbus_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) + if (mbus_type == V4L2_MBUS_BT656 || mbus_type == V4L2_MBUS_PARALLEL) { + if (mbus_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) signal = RKISP1_CIF_ISP_ACQ_PROP_POS_EDGE; } - if (sensor->mbus_type == V4L2_MBUS_PARALLEL) { - if (sensor->mbus_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) + if (mbus_type == V4L2_MBUS_PARALLEL) { + if (mbus_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) signal |= RKISP1_CIF_ISP_ACQ_PROP_VSYNC_LOW; - if (sensor->mbus_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) + if (mbus_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) signal |= RKISP1_CIF_ISP_ACQ_PROP_HSYNC_LOW; } @@ -265,17 +263,17 @@ static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) } /* Configure MUX */ -static int rkisp1_config_path(struct rkisp1_device *rkisp1) +static int rkisp1_config_path(struct rkisp1_device *rkisp1, + enum v4l2_mbus_type mbus_type) { - struct rkisp1_sensor_async *sensor = rkisp1->active_sensor; u32 dpcl = rkisp1_read(rkisp1, RKISP1_CIF_VI_DPCL); int ret = 0; - if (sensor->mbus_type == V4L2_MBUS_BT656 || - sensor->mbus_type == V4L2_MBUS_PARALLEL) { + if (mbus_type == V4L2_MBUS_BT656 || + mbus_type == V4L2_MBUS_PARALLEL) { ret = rkisp1_config_dvp(rkisp1); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_PARALLEL; - } else if (sensor->mbus_type == V4L2_MBUS_CSI2_DPHY) { + } else if (mbus_type == V4L2_MBUS_CSI2_DPHY) { dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_MIPI; } @@ -285,14 +283,15 @@ static int rkisp1_config_path(struct rkisp1_device *rkisp1) } /* Hardware configure Entry */ -static int rkisp1_config_cif(struct rkisp1_device *rkisp1) +static int rkisp1_config_cif(struct rkisp1_device *rkisp1, + enum v4l2_mbus_type mbus_type, u32 mbus_flags) { int ret; - ret = rkisp1_config_isp(rkisp1); + ret = rkisp1_config_isp(rkisp1, mbus_type, mbus_flags); if (ret) return ret; - ret = rkisp1_config_path(rkisp1); + ret = rkisp1_config_path(rkisp1, mbus_type); if (ret) return ret; rkisp1_config_ism(rkisp1); @@ -777,7 +776,8 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) rkisp1->isp.frame_sequence = -1; mutex_lock(&isp->ops_lock); - ret = rkisp1_config_cif(rkisp1); + ret = rkisp1_config_cif(rkisp1, rkisp1->active_sensor->mbus_type, + rkisp1->active_sensor->mbus_flags); if (ret) goto mutex_unlock; From patchwork Tue Jun 14 19:10:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881461 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C6FCCA47B for ; Tue, 14 Jun 2022 19:13:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238748AbiFNTNk (ORCPT ); Tue, 14 Jun 2022 15:13:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233205AbiFNTNj (ORCPT ); Tue, 14 Jun 2022 15:13:39 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3135764E for ; Tue, 14 Jun 2022 12:13:38 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 76E259E5; Tue, 14 Jun 2022 21:13:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234017; bh=Eecg3Ahmdygu1oP8pI41z4Bd/FJGnoaSXWK5oiZILZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fjvsn82AbVPduS3k8p+Au1d7hLmlLtfD3AfJ70oWRJXwUajZ6yy+lBpqC3kD1hBw0 FyXoLsJ5DVagd3r0NBBZWd6Qb/PAtaBrFQ0k6tTEcx3I9yW7qQlNaKChJPt4jmpTjP XtkzHGaJhK9EiRVqA+pDQTDsklRIT8SBkiY7Jh8c= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 27/55] media: rkisp1: isp: Rename rkisp1_device.active_sensor to source Date: Wed, 15 Jun 2022 04:10:59 +0900 Message-Id: <20220614191127.3420492-28-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The active_sensor field of the rkisp1_device structure points to the ASD data for the active source. The source may however not be a sensor, so the naming is a bit confusing. Furthermore, the driver doesn't need to access the full ASD from the active_sensor field, only the subdev pointer is needed, when stopping streaming. Rename the field to source, and turn it into a v4l2_subdev pointer. Signed-off-by: Laurent Pinchart Reviewed-by: Dafna Hirschfeld Reviewed-by: Dafna Hirschfeld --- .../platform/rockchip/rkisp1/rkisp1-common.h | 4 +-- .../platform/rockchip/rkisp1/rkisp1-isp.c | 27 +++++++++---------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index dbf1baca623a..7a6f55a31bb0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -419,7 +419,7 @@ struct rkisp1_debug { * @v4l2_dev: v4l2_device variable * @media_dev: media_device variable * @notifier: a notifier to register on the v4l2-async API to be notified on the sensor - * @active_sensor: sensor in-use, set when streaming on + * @source: source subdev in-use, set when starting streaming * @csi: internal CSI-2 receiver * @isp: ISP sub-device * @resizer_devs: resizer sub-devices @@ -439,7 +439,7 @@ struct rkisp1_device { struct v4l2_device v4l2_dev; struct media_device media_dev; struct v4l2_async_notifier notifier; - struct rkisp1_sensor_async *active_sensor; + struct v4l2_subdev *source; struct rkisp1_csi csi; struct rkisp1_isp isp; struct rkisp1_resizer resizer_devs[2]; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index f6d1c93dd99d..4f12fc0b7694 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -58,7 +58,7 @@ * Helpers */ -static struct v4l2_subdev *rkisp1_get_remote_sensor(struct v4l2_subdev *sd) +static struct v4l2_subdev *rkisp1_get_remote_source(struct v4l2_subdev *sd) { struct media_pad *local, *remote; struct media_entity *sensor_me; @@ -749,12 +749,11 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) struct rkisp1_device *rkisp1 = container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); struct rkisp1_isp *isp = &rkisp1->isp; - struct v4l2_subdev *sensor_sd; + struct rkisp1_sensor_async *asd; int ret; if (!enable) { - v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, - false); + v4l2_subdev_call(rkisp1->source, video, s_stream, false); rkisp1_csi_stop(&rkisp1->csi); rkisp1_isp_stop(rkisp1); @@ -762,35 +761,33 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) return 0; } - sensor_sd = rkisp1_get_remote_sensor(sd); - if (!sensor_sd) { - dev_warn(rkisp1->dev, "No link between isp and sensor\n"); + rkisp1->source = rkisp1_get_remote_source(sd); + if (!rkisp1->source) { + dev_warn(rkisp1->dev, "No link between isp and source\n"); return -ENODEV; } - rkisp1->active_sensor = container_of(sensor_sd->asd, - struct rkisp1_sensor_async, asd); + asd = container_of(rkisp1->source->asd, struct rkisp1_sensor_async, + asd); - if (rkisp1->active_sensor->mbus_type != V4L2_MBUS_CSI2_DPHY) + if (asd->mbus_type != V4L2_MBUS_CSI2_DPHY) return -EINVAL; rkisp1->isp.frame_sequence = -1; mutex_lock(&isp->ops_lock); - ret = rkisp1_config_cif(rkisp1, rkisp1->active_sensor->mbus_type, - rkisp1->active_sensor->mbus_flags); + ret = rkisp1_config_cif(rkisp1, asd->mbus_type, asd->mbus_flags); if (ret) goto mutex_unlock; rkisp1_isp_start(rkisp1); - ret = rkisp1_csi_start(&rkisp1->csi, rkisp1->active_sensor); + ret = rkisp1_csi_start(&rkisp1->csi, asd); if (ret) { rkisp1_isp_stop(rkisp1); goto mutex_unlock; } - ret = v4l2_subdev_call(rkisp1->active_sensor->sd, video, s_stream, - true); + ret = v4l2_subdev_call(rkisp1->source, video, s_stream, true); if (ret) { rkisp1_isp_stop(rkisp1); rkisp1_csi_stop(&rkisp1->csi); From patchwork Tue Jun 14 19:11:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDD12C43334 for ; Tue, 14 Jun 2022 19:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344359AbiFNTNo (ORCPT ); Tue, 14 Jun 2022 15:13:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233205AbiFNTNn (ORCPT ); Tue, 14 Jun 2022 15:13:43 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C811F28984 for ; Tue, 14 Jun 2022 12:13:42 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 39C13FA0; Tue, 14 Jun 2022 21:13:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234021; bh=nen/2bN6BiLU0SoY7+g9X9Z3wLthtBU3eonu0OwOdH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JhwdEfNjVrPpzOt2chrJDy9lwg1jLnGNIW76W4PTQ9ks2DxRXEtl9mwnbun98S2cE u4V0+UBNHpXyGtu5ev7gimBMlIUZLNLrf3HT5KNO80QVjek1IwR92R8o0mX7Kc6Qzo OCSMS7Br5Brgpe/YYr4tIpXtKHET7WbxMvUVWwqs= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 28/55] media: rkisp1: isp: Add container_of wrapper to cast subdev to rkisp1_isp Date: Wed, 15 Jun 2022 04:11:00 +0900 Message-Id: <20220614191127.3420492-29-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Replace manual container_of() calls with a static inline wrapper to increase readability. Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/rkisp1-isp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 4f12fc0b7694..812fb2ea5323 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -370,6 +370,11 @@ static void rkisp1_isp_start(struct rkisp1_device *rkisp1) * Subdev pad operations */ +static inline struct rkisp1_isp *to_rkisp1_isp(struct v4l2_subdev *sd) +{ + return container_of(sd, struct rkisp1_isp, sd); +} + static int rkisp1_isp_enum_mbus_code(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_mbus_code_enum *code) @@ -625,7 +630,7 @@ static int rkisp1_isp_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) { - struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); + struct rkisp1_isp *isp = to_rkisp1_isp(sd); mutex_lock(&isp->ops_lock); fmt->format = *rkisp1_isp_get_pad_fmt(isp, sd_state, fmt->pad, @@ -638,7 +643,7 @@ static int rkisp1_isp_set_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_format *fmt) { - struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); + struct rkisp1_isp *isp = to_rkisp1_isp(sd); mutex_lock(&isp->ops_lock); if (fmt->pad == RKISP1_ISP_PAD_SINK_VIDEO) @@ -659,7 +664,7 @@ static int rkisp1_isp_get_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) { - struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); + struct rkisp1_isp *isp = to_rkisp1_isp(sd); int ret = 0; if (sel->pad != RKISP1_ISP_PAD_SOURCE_VIDEO && @@ -701,7 +706,7 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd, { struct rkisp1_device *rkisp1 = container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); - struct rkisp1_isp *isp = container_of(sd, struct rkisp1_isp, sd); + struct rkisp1_isp *isp = to_rkisp1_isp(sd); int ret = 0; if (sel->target != V4L2_SEL_TGT_CROP) @@ -748,7 +753,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) { struct rkisp1_device *rkisp1 = container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); - struct rkisp1_isp *isp = &rkisp1->isp; + struct rkisp1_isp *isp = to_rkisp1_isp(sd); struct rkisp1_sensor_async *asd; int ret; From patchwork Tue Jun 14 19:11:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 171E9C43334 for ; Tue, 14 Jun 2022 19:13:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357407AbiFNTNt (ORCPT ); Tue, 14 Jun 2022 15:13:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233205AbiFNTNr (ORCPT ); Tue, 14 Jun 2022 15:13:47 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBDAB764E for ; Tue, 14 Jun 2022 12:13:46 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2DC40EF1; Tue, 14 Jun 2022 21:13:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234025; bh=B4d0dJOR6yxu00HHYzsuZC8jCLhA/Y8JmyFLeN3g3+I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y4sY0C6GObKQ8RxuI4Yo2PlJmW9wr9D26P8oV2yMtMAk/UXXhgop8ZXBvFu56Z0yo iNVvg3WX5GJJ1xfy3oX6wFxovGBOkzIRc3+gDKL6+6+iTkAs6QbfdLpkjRftAfi9cP p0QkwLLhlhOZC8iwRqSYRgx89OoiJxX4UujIi6Mw= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 29/55] media: rkisp1: isp: Add rkisp1_device backpointer to rkisp1_isp Date: Wed, 15 Jun 2022 04:11:01 +0900 Message-Id: <20220614191127.3420492-30-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The rkisp1_isp structure documentation mentions a backpointer field to rkisp1_device, but the field is missing. Add it, and use it to replace more complicated constructs using container_of() on the v4l2_device. Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/rkisp1-common.h | 1 + drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 7a6f55a31bb0..3c55e922346e 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -162,6 +162,7 @@ struct rkisp1_csi { */ struct rkisp1_isp { struct v4l2_subdev sd; + struct rkisp1_device *rkisp1; struct media_pad pads[RKISP1_ISP_PAD_MAX]; struct v4l2_subdev_pad_config pad_cfg[RKISP1_ISP_PAD_MAX]; const struct rkisp1_mbus_info *sink_fmt; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 812fb2ea5323..f8ab1d9cc8cd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -704,15 +704,13 @@ static int rkisp1_isp_set_selection(struct v4l2_subdev *sd, struct v4l2_subdev_state *sd_state, struct v4l2_subdev_selection *sel) { - struct rkisp1_device *rkisp1 = - container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); struct rkisp1_isp *isp = to_rkisp1_isp(sd); int ret = 0; if (sel->target != V4L2_SEL_TGT_CROP) return -EINVAL; - dev_dbg(rkisp1->dev, "%s: pad: %d sel(%d,%d)/%dx%d\n", __func__, + dev_dbg(isp->rkisp1->dev, "%s: pad: %d sel(%d,%d)/%dx%d\n", __func__, sel->pad, sel->r.left, sel->r.top, sel->r.width, sel->r.height); mutex_lock(&isp->ops_lock); if (sel->pad == RKISP1_ISP_PAD_SINK_VIDEO) @@ -751,9 +749,8 @@ static const struct v4l2_subdev_pad_ops rkisp1_isp_pad_ops = { static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) { - struct rkisp1_device *rkisp1 = - container_of(sd->v4l2_dev, struct rkisp1_device, v4l2_dev); struct rkisp1_isp *isp = to_rkisp1_isp(sd); + struct rkisp1_device *rkisp1 = isp->rkisp1; struct rkisp1_sensor_async *asd; int ret; @@ -840,12 +837,14 @@ int rkisp1_isp_register(struct rkisp1_device *rkisp1) { struct v4l2_subdev_state state = { .pads = rkisp1->isp.pad_cfg - }; + }; struct rkisp1_isp *isp = &rkisp1->isp; struct media_pad *pads = isp->pads; struct v4l2_subdev *sd = &isp->sd; int ret; + isp->rkisp1 = rkisp1; + v4l2_subdev_init(sd, &rkisp1_isp_ops); sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; sd->entity.ops = &rkisp1_isp_media_ops; From patchwork Tue Jun 14 19:11:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881464 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5B49C433EF for ; Tue, 14 Jun 2022 19:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233205AbiFNTNw (ORCPT ); Tue, 14 Jun 2022 15:13:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbiFNTNv (ORCPT ); Tue, 14 Jun 2022 15:13:51 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6120611C0F for ; Tue, 14 Jun 2022 12:13:50 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1EF2ED96; Tue, 14 Jun 2022 21:13:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234029; bh=CTsRNe95zDqSugl7jPkVw0novTlOC80JNbr53/mVQwI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sh2JxadNZ+t8wMFIUGsBzn9yikMaK+E3lxXtQPKxf+OB2QxsyaAY1pd/DbTyu4+wb lmws4h1HAtDXgPIyRMqkEOvMtzarJVz3y18e6wTzfMp3xIcsf68IJo8Z65DDKwBcAJ scPGPy6UojN7MBdmm554u0UhpB916wNHrqeHRUSo= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 30/55] media: rkisp1: isp: Pass rkisp1_isp pointer to internal ISP functions Date: Wed, 15 Jun 2022 04:11:02 +0900 Message-Id: <20220614191127.3420492-31-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Replace the rkisp1_device pointer argument to the internal functions of the ISP implementation with a rkisp1_isp object. This makes the code flow more logical, as the functions operate on the ISP object. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 60 +++++++++++-------- 1 file changed, 34 insertions(+), 26 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index f8ab1d9cc8cd..e27137b5c33e 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -109,12 +109,13 @@ rkisp1_isp_get_pad_crop(struct rkisp1_isp *isp, * This should only be called when configuring CIF * or at the frame end interrupt */ -static void rkisp1_config_ism(struct rkisp1_device *rkisp1) +static void rkisp1_config_ism(struct rkisp1_isp *isp) { struct v4l2_rect *src_crop = - rkisp1_isp_get_pad_crop(&rkisp1->isp, NULL, + rkisp1_isp_get_pad_crop(isp, NULL, RKISP1_ISP_PAD_SOURCE_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); + struct rkisp1_device *rkisp1 = isp->rkisp1; u32 val; rkisp1_write(rkisp1, RKISP1_CIF_ISP_IS_RECENTER, 0); @@ -136,20 +137,21 @@ static void rkisp1_config_ism(struct rkisp1_device *rkisp1) /* * configure ISP blocks with input format, size...... */ -static int rkisp1_config_isp(struct rkisp1_device *rkisp1, +static int rkisp1_config_isp(struct rkisp1_isp *isp, enum v4l2_mbus_type mbus_type, u32 mbus_flags) { + struct rkisp1_device *rkisp1 = isp->rkisp1; u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0; const struct rkisp1_mbus_info *src_fmt, *sink_fmt; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; - sink_fmt = rkisp1->isp.sink_fmt; - src_fmt = rkisp1->isp.src_fmt; - sink_frm = rkisp1_isp_get_pad_fmt(&rkisp1->isp, NULL, + sink_fmt = isp->sink_fmt; + src_fmt = isp->src_fmt; + sink_frm = rkisp1_isp_get_pad_fmt(isp, NULL, RKISP1_ISP_PAD_SINK_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); - sink_crop = rkisp1_isp_get_pad_crop(&rkisp1->isp, NULL, + sink_crop = rkisp1_isp_get_pad_crop(isp, NULL, RKISP1_ISP_PAD_SINK_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); @@ -226,7 +228,7 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1, } else { struct v4l2_mbus_framefmt *src_frm; - src_frm = rkisp1_isp_get_pad_fmt(&rkisp1->isp, NULL, + src_frm = rkisp1_isp_get_pad_fmt(isp, NULL, RKISP1_ISP_PAD_SINK_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); rkisp1_params_configure(&rkisp1->params, sink_fmt->bayer_pat, @@ -236,9 +238,10 @@ static int rkisp1_config_isp(struct rkisp1_device *rkisp1, return 0; } -static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) +static int rkisp1_config_dvp(struct rkisp1_isp *isp) { - const struct rkisp1_mbus_info *sink_fmt = rkisp1->isp.sink_fmt; + struct rkisp1_device *rkisp1 = isp->rkisp1; + const struct rkisp1_mbus_info *sink_fmt = isp->sink_fmt; u32 val, input_sel; switch (sink_fmt->bus_width) { @@ -263,15 +266,16 @@ static int rkisp1_config_dvp(struct rkisp1_device *rkisp1) } /* Configure MUX */ -static int rkisp1_config_path(struct rkisp1_device *rkisp1, +static int rkisp1_config_path(struct rkisp1_isp *isp, enum v4l2_mbus_type mbus_type) { + struct rkisp1_device *rkisp1 = isp->rkisp1; u32 dpcl = rkisp1_read(rkisp1, RKISP1_CIF_VI_DPCL); int ret = 0; if (mbus_type == V4L2_MBUS_BT656 || mbus_type == V4L2_MBUS_PARALLEL) { - ret = rkisp1_config_dvp(rkisp1); + ret = rkisp1_config_dvp(isp); dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_PARALLEL; } else if (mbus_type == V4L2_MBUS_CSI2_DPHY) { dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_MIPI; @@ -283,24 +287,25 @@ static int rkisp1_config_path(struct rkisp1_device *rkisp1, } /* Hardware configure Entry */ -static int rkisp1_config_cif(struct rkisp1_device *rkisp1, +static int rkisp1_config_cif(struct rkisp1_isp *isp, enum v4l2_mbus_type mbus_type, u32 mbus_flags) { int ret; - ret = rkisp1_config_isp(rkisp1, mbus_type, mbus_flags); + ret = rkisp1_config_isp(isp, mbus_type, mbus_flags); if (ret) return ret; - ret = rkisp1_config_path(rkisp1, mbus_type); + ret = rkisp1_config_path(isp, mbus_type); if (ret) return ret; - rkisp1_config_ism(rkisp1); + rkisp1_config_ism(isp); return 0; } -static void rkisp1_isp_stop(struct rkisp1_device *rkisp1) +static void rkisp1_isp_stop(struct rkisp1_isp *isp) { + struct rkisp1_device *rkisp1 = isp->rkisp1; u32 val; /* @@ -332,8 +337,10 @@ static void rkisp1_isp_stop(struct rkisp1_device *rkisp1) rkisp1_write(rkisp1, RKISP1_CIF_VI_IRCL, 0x0); } -static void rkisp1_config_clk(struct rkisp1_device *rkisp1) +static void rkisp1_config_clk(struct rkisp1_isp *isp) { + struct rkisp1_device *rkisp1 = isp->rkisp1; + u32 val = RKISP1_CIF_VI_ICCL_ISP_CLK | RKISP1_CIF_VI_ICCL_CP_CLK | RKISP1_CIF_VI_ICCL_MRSZ_CLK | RKISP1_CIF_VI_ICCL_SRSZ_CLK | RKISP1_CIF_VI_ICCL_JPEG_CLK | RKISP1_CIF_VI_ICCL_MI_CLK | @@ -352,11 +359,12 @@ static void rkisp1_config_clk(struct rkisp1_device *rkisp1) } } -static void rkisp1_isp_start(struct rkisp1_device *rkisp1) +static void rkisp1_isp_start(struct rkisp1_isp *isp) { + struct rkisp1_device *rkisp1 = isp->rkisp1; u32 val; - rkisp1_config_clk(rkisp1); + rkisp1_config_clk(isp); /* Activate ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); @@ -758,7 +766,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) v4l2_subdev_call(rkisp1->source, video, s_stream, false); rkisp1_csi_stop(&rkisp1->csi); - rkisp1_isp_stop(rkisp1); + rkisp1_isp_stop(isp); return 0; } @@ -775,23 +783,23 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) if (asd->mbus_type != V4L2_MBUS_CSI2_DPHY) return -EINVAL; - rkisp1->isp.frame_sequence = -1; + isp->frame_sequence = -1; mutex_lock(&isp->ops_lock); - ret = rkisp1_config_cif(rkisp1, asd->mbus_type, asd->mbus_flags); + ret = rkisp1_config_cif(isp, asd->mbus_type, asd->mbus_flags); if (ret) goto mutex_unlock; - rkisp1_isp_start(rkisp1); + rkisp1_isp_start(isp); ret = rkisp1_csi_start(&rkisp1->csi, asd); if (ret) { - rkisp1_isp_stop(rkisp1); + rkisp1_isp_stop(isp); goto mutex_unlock; } ret = v4l2_subdev_call(rkisp1->source, video, s_stream, true); if (ret) { - rkisp1_isp_stop(rkisp1); + rkisp1_isp_stop(isp); rkisp1_csi_stop(&rkisp1->csi); goto mutex_unlock; } From patchwork Tue Jun 14 19:11:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41398C43334 for ; Tue, 14 Jun 2022 19:13:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344634AbiFNTN4 (ORCPT ); Tue, 14 Jun 2022 15:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357475AbiFNTNz (ORCPT ); Tue, 14 Jun 2022 15:13:55 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388E911C0F for ; Tue, 14 Jun 2022 12:13:54 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C021E825; Tue, 14 Jun 2022 21:13:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234032; bh=/zY9FmG+cX5zgDSYHx1u5t6KmYKY5RDU86JnqNycTj4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ew0j3SExQ8b9xcbmzIFgawsVruJ8NLnJAMaodnCjV6ntHK4zPo+ZpXrtOI8PU/Dip gqDfGra8RI8pZoZmU/Z07ue7X8ecVZ6uLnWXg9RmSFNGYEw21XPxcFPV9lO96LYyTn 1YR+jFvei25IB+A6s6hG7OZsKl8bm9eI/vI2kbGM= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 31/55] media: rkisp1: isp: Move input configuration to rkisp1_config_isp() Date: Wed, 15 Jun 2022 04:11:03 +0900 Message-Id: <20220614191127.3420492-32-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ISP_ACQ_PROP register is set twice, once in rkisp1_config_isp() for most of its fields, and once in rkisp1_config_dvp() (called from rkisp1_config_path()) to configure the input selection field. Move the latter to rkisp1_config_isp() to write the register once only, and drop the now empty rkisp1_config_dvp() function. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 62 +++++++------------ 1 file changed, 22 insertions(+), 40 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index e27137b5c33e..f5b8a2e31936 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -141,7 +141,7 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, enum v4l2_mbus_type mbus_type, u32 mbus_flags) { struct rkisp1_device *rkisp1 = isp->rkisp1; - u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0; + u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0, input_sel = 0; const struct rkisp1_mbus_info *src_fmt, *sink_fmt; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; @@ -189,6 +189,21 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, if (mbus_type == V4L2_MBUS_BT656 || mbus_type == V4L2_MBUS_PARALLEL) { if (mbus_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) signal = RKISP1_CIF_ISP_ACQ_PROP_POS_EDGE; + + switch (sink_fmt->bus_width) { + case 8: + input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_8B_ZERO; + break; + case 10: + input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_10B_ZERO; + break; + case 12: + input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_12B; + break; + default: + dev_err(rkisp1->dev, "Invalid bus width\n"); + return -EINVAL; + } } if (mbus_type == V4L2_MBUS_PARALLEL) { @@ -201,7 +216,7 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, rkisp1_write(rkisp1, RKISP1_CIF_ISP_CTRL, isp_ctrl); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ACQ_PROP, - signal | sink_fmt->yuv_seq | + signal | sink_fmt->yuv_seq | input_sel | RKISP1_CIF_ISP_ACQ_PROP_BAYER_PAT(sink_fmt->bayer_pat) | RKISP1_CIF_ISP_ACQ_PROP_FIELD_SEL_ALL); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ACQ_NR_FRAMES, 0); @@ -238,52 +253,20 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, return 0; } -static int rkisp1_config_dvp(struct rkisp1_isp *isp) -{ - struct rkisp1_device *rkisp1 = isp->rkisp1; - const struct rkisp1_mbus_info *sink_fmt = isp->sink_fmt; - u32 val, input_sel; - - switch (sink_fmt->bus_width) { - case 8: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_8B_ZERO; - break; - case 10: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_10B_ZERO; - break; - case 12: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_12B; - break; - default: - dev_err(rkisp1->dev, "Invalid bus width\n"); - return -EINVAL; - } - - val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_ACQ_PROP); - rkisp1_write(rkisp1, RKISP1_CIF_ISP_ACQ_PROP, val | input_sel); - - return 0; -} - /* Configure MUX */ -static int rkisp1_config_path(struct rkisp1_isp *isp, - enum v4l2_mbus_type mbus_type) +static void rkisp1_config_path(struct rkisp1_isp *isp, + enum v4l2_mbus_type mbus_type) { struct rkisp1_device *rkisp1 = isp->rkisp1; u32 dpcl = rkisp1_read(rkisp1, RKISP1_CIF_VI_DPCL); - int ret = 0; - if (mbus_type == V4L2_MBUS_BT656 || - mbus_type == V4L2_MBUS_PARALLEL) { - ret = rkisp1_config_dvp(isp); + if (mbus_type == V4L2_MBUS_BT656 || mbus_type == V4L2_MBUS_PARALLEL) { dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_PARALLEL; } else if (mbus_type == V4L2_MBUS_CSI2_DPHY) { dpcl |= RKISP1_CIF_VI_DPCL_IF_SEL_MIPI; } rkisp1_write(rkisp1, RKISP1_CIF_VI_DPCL, dpcl); - - return ret; } /* Hardware configure Entry */ @@ -295,9 +278,8 @@ static int rkisp1_config_cif(struct rkisp1_isp *isp, ret = rkisp1_config_isp(isp, mbus_type, mbus_flags); if (ret) return ret; - ret = rkisp1_config_path(isp, mbus_type); - if (ret) - return ret; + + rkisp1_config_path(isp, mbus_type); rkisp1_config_ism(isp); return 0; From patchwork Tue Jun 14 19:11:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881466 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D55AC433EF for ; Tue, 14 Jun 2022 19:14:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357479AbiFNTOA (ORCPT ); Tue, 14 Jun 2022 15:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357493AbiFNTN7 (ORCPT ); Tue, 14 Jun 2022 15:13:59 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F8F28995 for ; Tue, 14 Jun 2022 12:13:58 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AC898D96; Tue, 14 Jun 2022 21:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234037; bh=35+hA7UDvD2qw6jCdPcIbuPN8UA7aIOG3BVxM+CvBR8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XIGPIpoPrOZX7ILPWr9PyEU34w3DL9PeFEHSWsxqn63Bgq/ZUyMjZGE8T0dLIo6oK bHNz5A2eiUodiox8nmIFJYqMORsTTJbQ/EllJPTrqEvIVyyxdzLH4JBP8YS4EG21pM N5pL2XkAV5glO/FxzBX44DEyTUV0hd4pGoDfXMFo= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 32/55] media: rkisp1: isp: Merge ISP_ACQ_PROP configuration in single variable Date: Wed, 15 Jun 2022 04:11:04 +0900 Message-Id: <20220614191127.3420492-33-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The rkisp1_config_isp() function stores the value of the input selection and polarity configuration in two different local variables, OR'ed together when writing the register. Merge them into a single acq_prop variable. Signed-off-by: Laurent Pinchart --- .../media/platform/rockchip/rkisp1/rkisp1-isp.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index f5b8a2e31936..4496af991c82 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -141,7 +141,7 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, enum v4l2_mbus_type mbus_type, u32 mbus_flags) { struct rkisp1_device *rkisp1 = isp->rkisp1; - u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, signal = 0, input_sel = 0; + u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, acq_prop = 0; const struct rkisp1_mbus_info *src_fmt, *sink_fmt; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; @@ -188,17 +188,17 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, /* Set up input acquisition properties */ if (mbus_type == V4L2_MBUS_BT656 || mbus_type == V4L2_MBUS_PARALLEL) { if (mbus_flags & V4L2_MBUS_PCLK_SAMPLE_RISING) - signal = RKISP1_CIF_ISP_ACQ_PROP_POS_EDGE; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_POS_EDGE; switch (sink_fmt->bus_width) { case 8: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_8B_ZERO; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_8B_ZERO; break; case 10: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_10B_ZERO; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_10B_ZERO; break; case 12: - input_sel = RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_12B; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_IN_SEL_12B; break; default: dev_err(rkisp1->dev, "Invalid bus width\n"); @@ -208,15 +208,15 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, if (mbus_type == V4L2_MBUS_PARALLEL) { if (mbus_flags & V4L2_MBUS_VSYNC_ACTIVE_LOW) - signal |= RKISP1_CIF_ISP_ACQ_PROP_VSYNC_LOW; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_VSYNC_LOW; if (mbus_flags & V4L2_MBUS_HSYNC_ACTIVE_LOW) - signal |= RKISP1_CIF_ISP_ACQ_PROP_HSYNC_LOW; + acq_prop |= RKISP1_CIF_ISP_ACQ_PROP_HSYNC_LOW; } rkisp1_write(rkisp1, RKISP1_CIF_ISP_CTRL, isp_ctrl); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ACQ_PROP, - signal | sink_fmt->yuv_seq | input_sel | + acq_prop | sink_fmt->yuv_seq | RKISP1_CIF_ISP_ACQ_PROP_BAYER_PAT(sink_fmt->bayer_pat) | RKISP1_CIF_ISP_ACQ_PROP_FIELD_SEL_ALL); rkisp1_write(rkisp1, RKISP1_CIF_ISP_ACQ_NR_FRAMES, 0); From patchwork Tue Jun 14 19:11:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881467 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31439CCA47A for ; Tue, 14 Jun 2022 19:14:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245199AbiFNTOE (ORCPT ); Tue, 14 Jun 2022 15:14:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244548AbiFNTOD (ORCPT ); Tue, 14 Jun 2022 15:14:03 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D36B28995 for ; Tue, 14 Jun 2022 12:14:02 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CEE6E825; Tue, 14 Jun 2022 21:13:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234041; bh=wr50jMmPTcrTYRpC1bC0bf83xxKPsRG6ZsJ7EZ3lTdQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bcexBvJWPuSJI6jlSOTSnEn0NFxh/mS1vX5nI9A2Alvn0ly3ZNE4Faoy29g9eIu2M OgOpiAkLKIvfYDbNn/M5I2oh7gdehEp0r/+hYKKX1Jwy31ncLVEYYmJ/tJ5xnJTZ31 vlCmegAGPs24p9ULV/U8yUb7A6jOBlq0Y914Rayk= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 33/55] media: rkisp1: isp: Initialize some variables at declaration time Date: Wed, 15 Jun 2022 04:11:05 +0900 Message-Id: <20220614191127.3420492-34-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Intialize the src_fmt and sink_fmt variable when declaring them in rkisp1_config_isp(). Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 4496af991c82..bf44f10200f5 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -142,12 +142,11 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, { struct rkisp1_device *rkisp1 = isp->rkisp1; u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, acq_prop = 0; - const struct rkisp1_mbus_info *src_fmt, *sink_fmt; + const struct rkisp1_mbus_info *sink_fmt = isp->sink_fmt; + const struct rkisp1_mbus_info *src_fmt = isp->src_fmt; struct v4l2_mbus_framefmt *sink_frm; struct v4l2_rect *sink_crop; - sink_fmt = isp->sink_fmt; - src_fmt = isp->src_fmt; sink_frm = rkisp1_isp_get_pad_fmt(isp, NULL, RKISP1_ISP_PAD_SINK_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); From patchwork Tue Jun 14 19:11:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5704EC43334 for ; Tue, 14 Jun 2022 19:14:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357493AbiFNTOL (ORCPT ); Tue, 14 Jun 2022 15:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344724AbiFNTOH (ORCPT ); Tue, 14 Jun 2022 15:14:07 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B17A4764E for ; Tue, 14 Jun 2022 12:14:06 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 068969E5; Tue, 14 Jun 2022 21:14:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234045; bh=5TfCdx16tPdAtupupd+gmBosQHk0m9Yd9ndPuGyPEkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UCrSYj3NIAmr5o9VVjM4d/62ZJybY8xsIOy535cbAB2yGiVhaPbZATsNxPdh9exAf EGcoWTMLSA+svexpD70wTH9F3vYL0/exw1KzitB6ohCz7eHCZQ2fOcZiIMHJ5VPwBu lrX0lmfQAoDDr9EAQVy2Pt8+kysa4GPkU0z4jcJ8= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 34/55] media: rkisp1: isp: Fix whitespace issues Date: Wed, 15 Jun 2022 04:11:06 +0900 Message-Id: <20220614191127.3420492-35-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Add missing blank lines after variable declaration blocks, and fix indentation issues. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index bf44f10200f5..86d496855374 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -79,7 +79,8 @@ rkisp1_isp_get_pad_fmt(struct rkisp1_isp *isp, { struct v4l2_subdev_state state = { .pads = isp->pad_cfg - }; + }; + if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_format(&isp->sd, sd_state, pad); else @@ -93,7 +94,8 @@ rkisp1_isp_get_pad_crop(struct rkisp1_isp *isp, { struct v4l2_subdev_state state = { .pads = isp->pad_cfg - }; + }; + if (which == V4L2_SUBDEV_FORMAT_TRY) return v4l2_subdev_get_try_crop(&isp->sd, sd_state, pad); else @@ -893,8 +895,8 @@ static void rkisp1_isp_queue_event_sof(struct rkisp1_isp *isp) struct v4l2_event event = { .type = V4L2_EVENT_FRAME_SYNC, }; - event.u.frame_sync.frame_sequence = isp->frame_sequence; + event.u.frame_sync.frame_sequence = isp->frame_sequence; v4l2_event_queue(isp->sd.devnode, &event); } From patchwork Tue Jun 14 19:11:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A218C43334 for ; Tue, 14 Jun 2022 19:14:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344724AbiFNTOQ (ORCPT ); Tue, 14 Jun 2022 15:14:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357500AbiFNTOL (ORCPT ); Tue, 14 Jun 2022 15:14:11 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E539E167E1 for ; Tue, 14 Jun 2022 12:14:10 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 26666D96; Tue, 14 Jun 2022 21:14:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234049; bh=RtSAScxUk0/fbQ2CmcZYEaFy40LrLwy8r9dzgWI2z2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O4wZyXbeUAI0woo1zZumyaAQoGJVm9qC5G7B/X8Tq4QROjmVjKnE5/508F/jj+FSo nVSIIwxaMs2Y2pZFSvjlRLVdM8fDVa/Wi9u9YSqILSF8fq9TmNwaOZQr/Fk8O3Ome0 4nfazw9x3R3Fds/rCzOpN+tru6v6MPlGvHhdEpNE= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 35/55] media: rkisp1: isp: Constify various local variables Date: Wed, 15 Jun 2022 04:11:07 +0900 Message-Id: <20220614191127.3420492-36-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart A set of local variables point to structure that are not meant to be modified. Constify them. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 86d496855374..91b37f2dca91 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -113,7 +113,7 @@ rkisp1_isp_get_pad_crop(struct rkisp1_isp *isp, */ static void rkisp1_config_ism(struct rkisp1_isp *isp) { - struct v4l2_rect *src_crop = + const struct v4l2_rect *src_crop = rkisp1_isp_get_pad_crop(isp, NULL, RKISP1_ISP_PAD_SOURCE_VIDEO, V4L2_SUBDEV_FORMAT_ACTIVE); @@ -146,8 +146,8 @@ static int rkisp1_config_isp(struct rkisp1_isp *isp, u32 isp_ctrl = 0, irq_mask = 0, acq_mult = 0, acq_prop = 0; const struct rkisp1_mbus_info *sink_fmt = isp->sink_fmt; const struct rkisp1_mbus_info *src_fmt = isp->src_fmt; - struct v4l2_mbus_framefmt *sink_frm; - struct v4l2_rect *sink_crop; + const struct v4l2_mbus_framefmt *sink_frm; + const struct v4l2_rect *sink_crop; sink_frm = rkisp1_isp_get_pad_fmt(isp, NULL, RKISP1_ISP_PAD_SINK_VIDEO, @@ -557,7 +557,7 @@ static void rkisp1_isp_set_sink_crop(struct rkisp1_isp *isp, struct v4l2_rect *r, unsigned int which) { struct v4l2_rect *sink_crop, *src_crop; - struct v4l2_mbus_framefmt *sink_fmt; + const struct v4l2_mbus_framefmt *sink_fmt; sink_crop = rkisp1_isp_get_pad_crop(isp, sd_state, RKISP1_ISP_PAD_SINK_VIDEO, @@ -742,7 +742,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) { struct rkisp1_isp *isp = to_rkisp1_isp(sd); struct rkisp1_device *rkisp1 = isp->rkisp1; - struct rkisp1_sensor_async *asd; + const struct rkisp1_sensor_async *asd; int ret; if (!enable) { From patchwork Tue Jun 14 19:11:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1CB9C433EF for ; Tue, 14 Jun 2022 19:14:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357483AbiFNTOR (ORCPT ); Tue, 14 Jun 2022 15:14:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244803AbiFNTOQ (ORCPT ); Tue, 14 Jun 2022 15:14:16 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9CD5764E for ; Tue, 14 Jun 2022 12:14:14 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54BA3825; Tue, 14 Jun 2022 21:14:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234053; bh=Ysq+xCMW5F6/ZUgZYbcVb3DpW87wB9+TyL8iuISrRNI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TKX6lsoN/VZQgJyl9fvW91dGzCBsBZLF4I5y0iNgpaPibvBMpwvoptPH4Ic5stoWY J5cStUPGFbeOGqGN/sUSK7+aUWuFIhmntwisz+ySxUXe7YCZyHB0vZEeGRVYtsrit9 b/fV8rCC24G4FRY+0R38FrvSoib4CxELnseGZreE= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 36/55] media: rkisp1: isp: Rename rkisp1_get_remote_source() Date: Wed, 15 Jun 2022 04:11:08 +0900 Message-Id: <20220614191127.3420492-37-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Rename the rkisp1_get_remote_source() function to rkisp1_isp_get_source() to use a consistent rkisp1_isp_* prefix for all ISP functions, and drop the "remote" as the source can't be local. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 91b37f2dca91..627b1ad3bf26 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -58,7 +58,7 @@ * Helpers */ -static struct v4l2_subdev *rkisp1_get_remote_source(struct v4l2_subdev *sd) +static struct v4l2_subdev *rkisp1_isp_get_source(struct v4l2_subdev *sd) { struct media_pad *local, *remote; struct media_entity *sensor_me; @@ -754,7 +754,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) return 0; } - rkisp1->source = rkisp1_get_remote_source(sd); + rkisp1->source = rkisp1_isp_get_source(sd); if (!rkisp1->source) { dev_warn(rkisp1->dev, "No link between isp and source\n"); return -ENODEV; From patchwork Tue Jun 14 19:11:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21CF8C43334 for ; Tue, 14 Jun 2022 19:14:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357516AbiFNTOU (ORCPT ); Tue, 14 Jun 2022 15:14:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244803AbiFNTOT (ORCPT ); Tue, 14 Jun 2022 15:14:19 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D710F11C0F for ; Tue, 14 Jun 2022 12:14:18 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3C4779E5; Tue, 14 Jun 2022 21:14:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234057; bh=qUlczx9eYLE47F3Qcq/gfcPI1Bs/0f5w9kN1BfDl3yE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W8rAKYI3UqiIzwP5ODD4ciUAfNA2MzTb2TaJ+fAxhdMca87UUVOhFmypNX02nfJ2B 7NBqOJKWscun+WRhOqxoeSFaFxMSVoGdvy+16fdd3HvJJattdtJpUI1Ea0dz7gijNL 4dzD68CNTTmpzzXeyEp5y0eqRSzep3+G3u6fax/Q= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 37/55] media: mc-entity: Add a new helper function to get a remote pad Date: Wed, 15 Jun 2022 04:11:09 +0900 Message-Id: <20220614191127.3420492-38-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The media_entity_remote_pad() helper function returns the first remote pad it find connected to a given pad. Beside being possibly ill-named (as it operates on a pad, not an entity) and non-deterministic (as it stops at the first enabled link), the fact that it returns the first match makes it unsuitable for drivers that need to guarantee that a single link is enabled, for instance when an entity can process data from one of multiple sources at a time. For those use cases, add a new helper function, media_entity_remote_pad_unique(), that operates on an entity and returns a remote pad, with a guarantee that only one link is enabled. To ease its use in drivers, also add an inline wrapper that locates source pads specifically. A wrapper that locates sink pads can easily be added when needed. Signed-off-by: Laurent Pinchart Acked-by: Hans Verkuil --- Documentation/driver-api/media/mc-core.rst | 4 +- drivers/media/mc/mc-entity.c | 38 ++++++++++++++++++ include/media/media-entity.h | 45 ++++++++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/media/mc-core.rst b/Documentation/driver-api/media/mc-core.rst index 02481a2513b9..a2d1e32e3abb 100644 --- a/Documentation/driver-api/media/mc-core.rst +++ b/Documentation/driver-api/media/mc-core.rst @@ -186,8 +186,8 @@ is required and the graph structure can be freed normally. Helper functions can be used to find a link between two given pads, or a pad connected to another pad through an enabled link -:c:func:`media_entity_find_link()` and -:c:func:`media_entity_remote_pad()`. +(:c:func:`media_entity_find_link()`, :c:func:`media_entity_remote_pad()` and +:c:func:`media_entity_remote_source_pad()`). Use count and power handling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 11f5207f73aa..1febf5a86be6 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -920,6 +921,43 @@ struct media_pad *media_entity_remote_pad(const struct media_pad *pad) } EXPORT_SYMBOL_GPL(media_entity_remote_pad); +struct media_pad * +media_entity_remote_pad_unique(const struct media_entity *entity, + unsigned int type) +{ + struct media_pad *pad = NULL; + struct media_link *link; + + list_for_each_entry(link, &entity->links, list) { + struct media_pad *local_pad; + struct media_pad *remote_pad; + + if (!(link->flags & MEDIA_LNK_FL_ENABLED)) + continue; + + if (type == MEDIA_PAD_FL_SOURCE) { + local_pad = link->sink; + remote_pad = link->source; + } else { + local_pad = link->source; + remote_pad = link->sink; + } + + if (local_pad->entity == entity) { + if (pad) + return ERR_PTR(-ENOTUNIQ); + + pad = remote_pad; + } + } + + if (!pad) + return ERR_PTR(-ENOLINK); + + return pad; +} +EXPORT_SYMBOL_GPL(media_entity_remote_pad_unique); + static void media_interface_init(struct media_device *mdev, struct media_interface *intf, u32 gobj_type, diff --git a/include/media/media-entity.h b/include/media/media-entity.h index a9a1c0ec5d1c..33d5f52719a0 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -859,6 +859,51 @@ struct media_link *media_entity_find_link(struct media_pad *source, */ struct media_pad *media_entity_remote_pad(const struct media_pad *pad); +/** + * media_entity_remote_pad_unique - Find a remote pad connected to an entity + * @entity: The entity + * @type: The type of pad to find (MEDIA_PAD_FL_SINK or MEDIA_PAD_FL_SOURCE) + * + * Search for and return a remote pad of @type connected to @entity through an + * enabled link. If multiple (or no) remote pads match these criteria, an error + * is returned. + * + * The uniqueness constraint makes this helper function suitable for entities + * that support a single active source or sink at a time. + * + * Return: A pointer to the remote pad, or one of the following error pointers + * if an error occurs: + * + * * -ENOTUNIQ - Multiple links are enabled + * * -ENOLINK - No connected pad found + */ +struct media_pad * +media_entity_remote_pad_unique(const struct media_entity *entity, + unsigned int type); + +/** + * media_entity_remote_source_pad - Find a remote source pad connected to an entity + * @entity: The entity + * + * Search for and return a remote source pad connected to @entity through an + * enabled link. If multiple (or no) remote pads match these criteria, an error + * is returned. + * + * The uniqueness constraint makes this helper function suitable for entities + * that support a single active source at a time. + * + * Return: A pointer to the remote pad, or one of the following error pointers + * if an error occurs: + * + * * -ENOTUNIQ - Multiple links are enabled + * * -ENOLINK - No connected pad found + */ +static inline struct media_pad * +media_entity_remote_source_pad(const struct media_entity *entity) +{ + return media_entity_remote_pad_unique(entity, MEDIA_PAD_FL_SOURCE); +} + /** * media_entity_is_streaming - Test if an entity is part of a streaming pipeline * @entity: The entity From patchwork Tue Jun 14 19:11:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CDD2C433EF for ; Tue, 14 Jun 2022 19:14:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357517AbiFNTOY (ORCPT ); Tue, 14 Jun 2022 15:14:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357611AbiFNTOX (ORCPT ); Tue, 14 Jun 2022 15:14:23 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB61111C0F for ; Tue, 14 Jun 2022 12:14:22 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 34FF7EF1; Tue, 14 Jun 2022 21:14:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234061; bh=GIhvJxxbVqRLcGeLL6GwJpK7d1zU0sA9adbgCCbIZhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WTlRkEcQmW6qIbNKJqv/Dmifftm/pXUbiAn3xBWjck2hsFIdCokVM+B5+ots8+LW3 FdAdslsFhhEYYnu9g1O7EwhQVjnQhP0zWzSrJ2BZcIlrEL4z971KBs/RmK0Va4sO0k P0J5fmM6QI20HUnfABdR5sPPfpH2/78dfDJcxGzg= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 38/55] media: mc-entity: Add a new helper function to get a remote pad for a pad Date: Wed, 15 Jun 2022 04:11:10 +0900 Message-Id: <20220614191127.3420492-39-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The newly added media_entity_remote_source_pad() helper function handles use cases where the entity has a link enabled uniqueness constraint covering all pads. There are use cases where the constraint covers a specific pad only. Add a new media_pad_remote_pad() function to handle this. It operates as media_entity_remote_source_pad(), but on a given pad instead of on the entity. Signed-off-by: Laurent Pinchart Acked-by: Hans Verkuil --- Documentation/driver-api/media/mc-core.rst | 4 +-- drivers/media/mc/mc-entity.c | 31 ++++++++++++++++++++++ include/media/media-entity.h | 18 +++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Documentation/driver-api/media/mc-core.rst b/Documentation/driver-api/media/mc-core.rst index a2d1e32e3abb..83c3bdbf67be 100644 --- a/Documentation/driver-api/media/mc-core.rst +++ b/Documentation/driver-api/media/mc-core.rst @@ -186,8 +186,8 @@ is required and the graph structure can be freed normally. Helper functions can be used to find a link between two given pads, or a pad connected to another pad through an enabled link -(:c:func:`media_entity_find_link()`, :c:func:`media_entity_remote_pad()` and -:c:func:`media_entity_remote_source_pad()`). +(:c:func:`media_entity_find_link()`, :c:func:`media_entity_remote_pad()`, +:c:func:`media_entity_remote_source_pad()` and :c:func:`media_pad_remote_pad()`). Use count and power handling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c index 1febf5a86be6..6429b0510bfb 100644 --- a/drivers/media/mc/mc-entity.c +++ b/drivers/media/mc/mc-entity.c @@ -958,6 +958,37 @@ media_entity_remote_pad_unique(const struct media_entity *entity, } EXPORT_SYMBOL_GPL(media_entity_remote_pad_unique); +struct media_pad *media_pad_remote_pad(const struct media_pad *pad) +{ + struct media_pad *found_pad = NULL; + struct media_link *link; + + list_for_each_entry(link, &pad->entity->links, list) { + struct media_pad *remote_pad; + + if (!(link->flags & MEDIA_LNK_FL_ENABLED)) + continue; + + if (link->sink == pad) + remote_pad = link->source; + else if (link->source == pad) + remote_pad = link->sink; + else + continue; + + if (found_pad) + return ERR_PTR(-ENOTUNIQ); + + found_pad = remote_pad; + } + + if (!found_pad) + return ERR_PTR(-ENOLINK); + + return found_pad; +} +EXPORT_SYMBOL_GPL(media_pad_remote_pad); + static void media_interface_init(struct media_device *mdev, struct media_interface *intf, u32 gobj_type, diff --git a/include/media/media-entity.h b/include/media/media-entity.h index 33d5f52719a0..bfe6a7b10a68 100644 --- a/include/media/media-entity.h +++ b/include/media/media-entity.h @@ -904,6 +904,24 @@ media_entity_remote_source_pad(const struct media_entity *entity) return media_entity_remote_pad_unique(entity, MEDIA_PAD_FL_SOURCE); } +/** + * media_pad_remote_pad - Find a remote pad connected to a pad + * @pad: The pad + * + * Search for and return a remote pad connected to @pad through an enabled + * link. If multiple (or no) remote pads are found, an error is returned. + * + * The uniqueness constraint makes this helper function suitable for entities + * that support a single active source at a time on a given pad. + * + * Return: A pointer to the remote pad, or one of the following error pointers + * if an error occurs: + * + * * -ENOTUNIQ - Multiple links are enabled + * * -ENOLINK - No connected pad found + */ +struct media_pad *media_pad_remote_pad(const struct media_pad *pad); + /** * media_entity_is_streaming - Test if an entity is part of a streaming pipeline * @entity: The entity From patchwork Tue Jun 14 19:11:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5E4DC43334 for ; Tue, 14 Jun 2022 19:14:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357554AbiFNTO2 (ORCPT ); Tue, 14 Jun 2022 15:14:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245409AbiFNTO2 (ORCPT ); Tue, 14 Jun 2022 15:14:28 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED8F0167E1 for ; Tue, 14 Jun 2022 12:14:26 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54DAA825; Tue, 14 Jun 2022 21:14:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234065; bh=EjpFD5LtcGNQ0Nr3GRZflMgD+UClVA3ZnxbDe9i0nuk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k4b9Tph4+C7tcUWqTlktTtm3IZDVMgLO3F+uX7CYt4uXhCBhIChHZ6hhiyKVSBJVi JFo19fy3fo2RO0hqOVX/kRwTAMUeDPgzyycSDKYKssNrFP0m1hfqvzckQq+q1ecpCg LHBO8iJyHrcrSTGRfU6uqA70fyQnpPelS0KNsUxI= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 39/55] media: rkisp1: isp: Disallow multiple active sources Date: Wed, 15 Jun 2022 04:11:11 +0900 Message-Id: <20220614191127.3420492-40-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The ISP supports multiple source subdevs, but can only capture from a single one at a time. The source is selected through link setup. The driver finds the active source in its .s_stream() handler using the media_entity_remote_pad() function. This fails to reject invalid configurations with multiple active sources. Fix it by using the media_entity_remote_source_pad() helper instead, and inline rkisp1_isp_get_source() in rkisp1_isp_s_stream() as the function is small and has a single caller. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 627b1ad3bf26..5afb8be311c7 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -58,20 +58,6 @@ * Helpers */ -static struct v4l2_subdev *rkisp1_isp_get_source(struct v4l2_subdev *sd) -{ - struct media_pad *local, *remote; - struct media_entity *sensor_me; - - local = &sd->entity.pads[RKISP1_ISP_PAD_SINK_VIDEO]; - remote = media_entity_remote_pad(local); - if (!remote) - return NULL; - - sensor_me = remote->entity; - return media_entity_to_v4l2_subdev(sensor_me); -} - static struct v4l2_mbus_framefmt * rkisp1_isp_get_pad_fmt(struct rkisp1_isp *isp, struct v4l2_subdev_state *sd_state, @@ -743,6 +729,7 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) struct rkisp1_isp *isp = to_rkisp1_isp(sd); struct rkisp1_device *rkisp1 = isp->rkisp1; const struct rkisp1_sensor_async *asd; + struct media_pad *source_pad; int ret; if (!enable) { @@ -754,10 +741,17 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) return 0; } - rkisp1->source = rkisp1_isp_get_source(sd); + source_pad = media_pad_remote_pad(&isp->pads[RKISP1_ISP_PAD_SINK_VIDEO]); + if (IS_ERR(source_pad)) { + dev_dbg(rkisp1->dev, "Failed to get source for ISP: %ld\n", + PTR_ERR(source_pad)); + return -EPIPE; + } + + rkisp1->source = media_entity_to_v4l2_subdev(source_pad->entity); if (!rkisp1->source) { - dev_warn(rkisp1->dev, "No link between isp and source\n"); - return -ENODEV; + /* This should really not happen, so is not worth a message. */ + return -EPIPE; } asd = container_of(rkisp1->source->asd, struct rkisp1_sensor_async, From patchwork Tue Jun 14 19:11:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC717C43334 for ; Tue, 14 Jun 2022 19:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357686AbiFNTOe (ORCPT ); Tue, 14 Jun 2022 15:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245409AbiFNTOc (ORCPT ); Tue, 14 Jun 2022 15:14:32 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69E5F167E1 for ; Tue, 14 Jun 2022 12:14:31 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 526B8D96; Tue, 14 Jun 2022 21:14:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234070; bh=jbvJX7i+C9k1JYEVwzj6u7FtLpm2xQDOpc3cY6tnv+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WTQtaA7ou46YgDy+YL6jXY2MKsyZztW4FIup7PdyOnqOC7zbmb1yxS+wFXAevcrdj uX9Xd0oYNFzD40Ng6JVmuk6U3S1M2Lz0WBRqSKWqbTqMjJLy5f+sqVYBJTR60xw9+/ U1T9hicyPqEA1iBSWc1FEebz6jvBEfBt/+2PCe6w= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 40/55] media: rkisp1: csi: Implement a V4L2 subdev for the CSI receiver Date: Wed, 15 Jun 2022 04:11:12 +0900 Message-Id: <20220614191127.3420492-41-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The CSI receiver is a component separate from the ISP or the resizers. It is actually optional, not all device model include a CSI receiver. On some SoCs CSI-2 support can be provided through an external CSI-2 receiver, connected to the ISP's parallel input. To support those use cases, create a V4L2 subdev to model the CSI receiver. It will allow the driver to handle both internal and external CSI receivers the same way. The next commit will plumb the CSI subdev to the rest of the driver, replacing direct function calls. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 17 ++ .../platform/rockchip/rkisp1/rkisp1-csi.c | 287 ++++++++++++++++++ .../platform/rockchip/rkisp1/rkisp1-csi.h | 4 + .../platform/rockchip/rkisp1/rkisp1-dev.c | 5 + 4 files changed, 313 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 3c55e922346e..0ab49d1feb55 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -68,6 +68,13 @@ enum rkisp1_rsz_pad { RKISP1_RSZ_PAD_MAX }; +/* enum for the csi receiver pads */ +enum rkisp1_csi_pad { + RKISP1_CSI_PAD_SINK, + RKISP1_CSI_PAD_SRC, + RKISP1_CSI_PAD_MAX +}; + /* enum for the capture id */ enum rkisp1_stream_id { RKISP1_MAINPATH, @@ -141,11 +148,21 @@ struct rkisp1_sensor_async { * @rkisp1: pointer to the rkisp1 device * @dphy: a pointer to the phy * @is_dphy_errctrl_disabled: if dphy errctrl is disabled (avoid endless interrupt) + * @sd: v4l2_subdev variable + * @pads: media pads + * @pad_cfg: configurations for the pads + * @ops_lock: a lock for the subdev ops + * @source: source in-use, set when starting streaming */ struct rkisp1_csi { struct rkisp1_device *rkisp1; struct phy *dphy; bool is_dphy_errctrl_disabled; + struct v4l2_subdev sd; + struct media_pad pads[RKISP1_CSI_PAD_MAX]; + struct v4l2_subdev_pad_config pad_cfg[RKISP1_CSI_PAD_MAX]; + struct mutex ops_lock; /* serialize the subdevice ops */ + struct rkisp1_sensor_async *source; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index 425a3b014089..8182694a6fe0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -15,10 +15,34 @@ #include #include +#include #include "rkisp1-common.h" #include "rkisp1-csi.h" +#define RKISP1_CSI_DEV_NAME RKISP1_DRIVER_NAME "_csi" + +#define RKISP1_CSI_DEF_FMT MEDIA_BUS_FMT_SRGGB10_1X10 + +static inline struct rkisp1_csi *to_rkisp1_csi(struct v4l2_subdev *sd) +{ + return container_of(sd, struct rkisp1_csi, sd); +} + +static struct v4l2_mbus_framefmt * +rkisp1_csi_get_pad_fmt(struct rkisp1_csi *csi, + struct v4l2_subdev_state *sd_state, + unsigned int pad, u32 which) +{ + struct v4l2_subdev_state state = { + .pads = csi->pad_cfg + }; + if (which == V4L2_SUBDEV_FORMAT_TRY) + return v4l2_subdev_get_try_format(&csi->sd, sd_state, pad); + else + return v4l2_subdev_get_try_format(&csi->sd, &state, pad); +} + static int rkisp1_csi_config(struct rkisp1_csi *csi, const struct rkisp1_sensor_async *sensor) { @@ -185,6 +209,269 @@ irqreturn_t rkisp1_csi_isr(int irq, void *ctx) return IRQ_HANDLED; } +/* ---------------------------------------------------------------------------- + * Subdev pad operations + */ + +static void rkisp1_csi_set_src_fmt(struct rkisp1_csi *csi, + struct v4l2_subdev_state *sd_state, + struct v4l2_mbus_framefmt *format, + unsigned int which) +{ + struct v4l2_mbus_framefmt *sink_fmt; + + /* We don't set the src format directly; take it from the sink format */ + sink_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, RKISP1_CSI_PAD_SINK, + which); + + *format = *sink_fmt; +} + +static void rkisp1_csi_set_sink_fmt(struct rkisp1_csi *csi, + struct v4l2_subdev_state *sd_state, + struct v4l2_mbus_framefmt *format, + unsigned int which) +{ + const struct rkisp1_mbus_info *mbus_info; + struct v4l2_mbus_framefmt *sink_fmt, *src_fmt; + + sink_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, RKISP1_CSI_PAD_SINK, + which); + src_fmt = rkisp1_csi_get_pad_fmt(csi, sd_state, RKISP1_CSI_PAD_SRC, + which); + + sink_fmt->code = format->code; + + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); + if (!mbus_info || !(mbus_info->direction & RKISP1_ISP_SD_SINK)) { + sink_fmt->code = RKISP1_CSI_DEF_FMT; + mbus_info = rkisp1_mbus_info_get_by_code(sink_fmt->code); + } + + sink_fmt->width = clamp_t(u32, format->width, + RKISP1_ISP_MIN_WIDTH, + RKISP1_ISP_MAX_WIDTH); + sink_fmt->height = clamp_t(u32, format->height, + RKISP1_ISP_MIN_HEIGHT, + RKISP1_ISP_MAX_HEIGHT); + + /* Propagate to source pad */ + src_fmt->code = sink_fmt->code; + src_fmt->width = sink_fmt->width; + src_fmt->height = sink_fmt->height; + + *format = *sink_fmt; +} + +static int rkisp1_csi_enum_mbus_code(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_mbus_code_enum *code) +{ + unsigned int i; + int pos = 0; + + if (code->index >= rkisp1_mbus_info_length()) + return -EINVAL; + + for (i = 0; i < rkisp1_mbus_info_length(); i++) { + const struct rkisp1_mbus_info *fmt = + rkisp1_mbus_info_get_by_index(i); + + if (fmt->direction & RKISP1_ISP_SD_SINK) + pos++; + + if (code->index == pos - 1) { + code->code = fmt->mbus_code; + return 0; + } + } + + return -EINVAL; +} + +static int rkisp1_csi_init_config(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state) +{ + struct v4l2_mbus_framefmt *sink_fmt, *src_fmt; + + sink_fmt = v4l2_subdev_get_try_format(sd, sd_state, + RKISP1_CSI_PAD_SRC); + sink_fmt->width = RKISP1_DEFAULT_WIDTH; + sink_fmt->height = RKISP1_DEFAULT_HEIGHT; + sink_fmt->field = V4L2_FIELD_NONE; + sink_fmt->code = RKISP1_CSI_DEF_FMT; + + src_fmt = v4l2_subdev_get_try_format(sd, sd_state, + RKISP1_CSI_PAD_SINK); + *src_fmt = *sink_fmt; + + return 0; +} + +static int rkisp1_csi_get_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct rkisp1_csi *csi = to_rkisp1_csi(sd); + + mutex_lock(&csi->ops_lock); + fmt->format = *rkisp1_csi_get_pad_fmt(csi, sd_state, fmt->pad, + fmt->which); + mutex_unlock(&csi->ops_lock); + return 0; +} + +static int rkisp1_csi_set_fmt(struct v4l2_subdev *sd, + struct v4l2_subdev_state *sd_state, + struct v4l2_subdev_format *fmt) +{ + struct rkisp1_csi *csi = to_rkisp1_csi(sd); + + mutex_lock(&csi->ops_lock); + if (fmt->pad == RKISP1_CSI_PAD_SINK) + rkisp1_csi_set_sink_fmt(csi, sd_state, &fmt->format, + fmt->which); + else + rkisp1_csi_set_src_fmt(csi, sd_state, &fmt->format, + fmt->which); + + mutex_unlock(&csi->ops_lock); + return 0; +} + +/* ---------------------------------------------------------------------------- + * Subdev video operations + */ + +static int rkisp1_csi_s_stream(struct v4l2_subdev *sd, int enable) +{ + struct rkisp1_csi *csi = to_rkisp1_csi(sd); + struct rkisp1_device *rkisp1 = csi->rkisp1; + struct media_pad *source_pad; + struct v4l2_subdev *source; + int ret; + + if (!enable) { + v4l2_subdev_call(csi->source->sd, video, s_stream, + false); + + rkisp1_csi_stop(csi); + + return ret; + } + + source_pad = media_entity_remote_source_pad(&sd->entity); + if (IS_ERR(source_pad)) { + dev_dbg(rkisp1->dev, "Failed to get source for CSI: %d\n", ret); + return -EPIPE; + } + + source = media_entity_to_v4l2_subdev(source_pad->entity); + if (!source) { + /* This should really not happen, so is not worth a message. */ + return -EPIPE; + } + + csi->source = container_of(source->asd, struct rkisp1_sensor_async, + asd); + + if (csi->source->mbus_type != V4L2_MBUS_CSI2_DPHY) + return -EINVAL; + + mutex_lock(&csi->ops_lock); + ret = rkisp1_csi_start(csi, csi->source); + mutex_unlock(&csi->ops_lock); + if (ret) + return ret; + + v4l2_subdev_call(csi->source->sd, video, s_stream, true); + + return 0; +} + +/* ---------------------------------------------------------------------------- + * Registration + */ + +static const struct media_entity_operations rkisp1_csi_media_ops = { + .link_validate = v4l2_subdev_link_validate, +}; + +static const struct v4l2_subdev_video_ops rkisp1_csi_video_ops = { + .s_stream = rkisp1_csi_s_stream, +}; + +static const struct v4l2_subdev_pad_ops rkisp1_csi_pad_ops = { + .enum_mbus_code = rkisp1_csi_enum_mbus_code, + .init_cfg = rkisp1_csi_init_config, + .get_fmt = rkisp1_csi_get_fmt, + .set_fmt = rkisp1_csi_set_fmt, +}; + +static const struct v4l2_subdev_ops rkisp1_csi_ops = { + .video = &rkisp1_csi_video_ops, + .pad = &rkisp1_csi_pad_ops, +}; + +int rkisp1_csi_register(struct rkisp1_device *rkisp1) +{ + struct rkisp1_csi *csi = &rkisp1->csi; + struct v4l2_subdev_state state = {}; + struct media_pad *pads; + struct v4l2_subdev *sd; + int ret; + + csi->rkisp1 = rkisp1; + mutex_init(&csi->ops_lock); + + sd = &csi->sd; + v4l2_subdev_init(sd, &rkisp1_csi_ops); + sd->flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; + sd->entity.ops = &rkisp1_csi_media_ops; + sd->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + sd->owner = THIS_MODULE; + strscpy(sd->name, RKISP1_CSI_DEV_NAME, sizeof(sd->name)); + + pads = csi->pads; + pads[RKISP1_CSI_PAD_SINK].flags = MEDIA_PAD_FL_SINK | + MEDIA_PAD_FL_MUST_CONNECT; + pads[RKISP1_CSI_PAD_SRC].flags = MEDIA_PAD_FL_SOURCE | + MEDIA_PAD_FL_MUST_CONNECT; + + ret = media_entity_pads_init(&sd->entity, RKISP1_CSI_PAD_MAX, pads); + if (ret) + goto error; + + state.pads = csi->pad_cfg; + rkisp1_csi_init_config(sd, &state); + + ret = v4l2_device_register_subdev(&csi->rkisp1->v4l2_dev, sd); + if (ret) { + dev_err(sd->dev, "Failed to register csi receiver subdev\n"); + goto error; + } + + return 0; + +error: + media_entity_cleanup(&sd->entity); + mutex_destroy(&csi->ops_lock); + csi->rkisp1 = NULL; + return ret; +} + +void rkisp1_csi_unregister(struct rkisp1_device *rkisp1) +{ + struct rkisp1_csi *csi = &rkisp1->csi; + + if (!csi->rkisp1) + return; + + v4l2_device_unregister_subdev(&csi->sd); + media_entity_cleanup(&csi->sd.entity); + mutex_destroy(&csi->ops_lock); +} + int rkisp1_csi_init(struct rkisp1_device *rkisp1) { struct rkisp1_csi *csi = &rkisp1->csi; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h index 97ce7e7959ab..ddf8e5e08f55 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -13,10 +13,14 @@ struct rkisp1_device; struct rkisp1_sensor_async; +struct v4l2_subdev; int rkisp1_csi_init(struct rkisp1_device *rkisp1); void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); +int rkisp1_csi_register(struct rkisp1_device *rkisp1); +void rkisp1_csi_unregister(struct rkisp1_device *rkisp1); + int rkisp1_csi_start(struct rkisp1_csi *csi, const struct rkisp1_sensor_async *sensor); void rkisp1_csi_stop(struct rkisp1_csi *csi); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 253220188abd..faf2cd4c8149 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -324,6 +324,7 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1) { + rkisp1_csi_unregister(rkisp1); rkisp1_params_unregister(rkisp1); rkisp1_stats_unregister(rkisp1); rkisp1_capture_devs_unregister(rkisp1); @@ -355,6 +356,10 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) if (ret) goto error; + ret = rkisp1_csi_register(rkisp1); + if (ret) + goto error; + ret = rkisp1_create_links(rkisp1); if (ret) goto error; From patchwork Tue Jun 14 19:11:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05C58C43334 for ; Tue, 14 Jun 2022 19:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357611AbiFNTOh (ORCPT ); Tue, 14 Jun 2022 15:14:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245409AbiFNTOg (ORCPT ); Tue, 14 Jun 2022 15:14:36 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1AFF764E for ; Tue, 14 Jun 2022 12:14:35 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C9E9F825; Tue, 14 Jun 2022 21:14:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234074; bh=qbUKKlAVPblPV/pI5UUGyESkZeMPGJdVzC0EImNhNCQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOeCrhf0+lGnb+Or7Y6tnvAbkPOSELAhg4TW05S13XYzWxqUdpLQBd2oH2oHqISbz BxPjUNYAz4hAdDynZt6BDC7qD3qJKDBRwtntykf0okFfriW8kUtAnmuVm5XdSxrPoV 942ZqpKJ1DXt6d+Kpxe7/6/vPTwCtD3Mfvy+vHNo= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org, Paul Elder Subject: [PATCH 41/55] media: rkisp1: csi: Plumb the CSI RX subdev Date: Wed, 15 Jun 2022 04:11:13 +0900 Message-Id: <20220614191127.3420492-42-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Connect the CSI receiver subdevice into the rest of the driver. This includes: - calling the subdevice via the v4l2 subdev API - moving the async notifier for the sensor from the ISP to the CSI receiver - in the ISP, create a media link to the CSI receiver, and remove the media link creation to the sensor - in the CSI receiver, create a media link to the sensor Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-csi.c | 34 ++++++++++++++++-- .../platform/rockchip/rkisp1/rkisp1-csi.h | 6 ++-- .../platform/rockchip/rkisp1/rkisp1-dev.c | 36 +++++++++---------- .../platform/rockchip/rkisp1/rkisp1-isp.c | 21 ++--------- 4 files changed, 53 insertions(+), 44 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c index 8182694a6fe0..96712b467dde 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.c @@ -43,6 +43,34 @@ rkisp1_csi_get_pad_fmt(struct rkisp1_csi *csi, return v4l2_subdev_get_try_format(&csi->sd, &state, pad); } +int rkisp1_csi_link_sensor(struct rkisp1_device *rkisp1, struct v4l2_subdev *sd, + struct rkisp1_sensor_async *s_asd, + unsigned int source_pad) +{ + struct rkisp1_csi *csi = &rkisp1->csi; + int ret; + + s_asd->pixel_rate_ctrl = v4l2_ctrl_find(sd->ctrl_handler, + V4L2_CID_PIXEL_RATE); + if (!s_asd->pixel_rate_ctrl) { + dev_err(rkisp1->dev, "No pixel rate control in subdev %s\n", + sd->name); + return -EINVAL; + } + + /* Create the link from the sensor to the CSI receiver. */ + ret = media_create_pad_link(&sd->entity, source_pad, + &csi->sd.entity, RKISP1_CSI_PAD_SINK, + !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); + if (ret) { + dev_err(csi->rkisp1->dev, "failed to link src pad of %s\n", + sd->name); + return ret; + } + + return 0; +} + static int rkisp1_csi_config(struct rkisp1_csi *csi, const struct rkisp1_sensor_async *sensor) { @@ -118,8 +146,8 @@ static void rkisp1_csi_disable(struct rkisp1_csi *csi) val & (~RKISP1_CIF_MIPI_CTRL_OUTPUT_ENA)); } -int rkisp1_csi_start(struct rkisp1_csi *csi, - const struct rkisp1_sensor_async *sensor) +static int rkisp1_csi_start(struct rkisp1_csi *csi, + const struct rkisp1_sensor_async *sensor) { struct rkisp1_device *rkisp1 = csi->rkisp1; union phy_configure_opts opts; @@ -155,7 +183,7 @@ int rkisp1_csi_start(struct rkisp1_csi *csi, return 0; } -void rkisp1_csi_stop(struct rkisp1_csi *csi) +static void rkisp1_csi_stop(struct rkisp1_csi *csi) { rkisp1_csi_disable(csi); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h index ddf8e5e08f55..eadcd24f65fb 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-csi.h @@ -21,8 +21,8 @@ void rkisp1_csi_cleanup(struct rkisp1_device *rkisp1); int rkisp1_csi_register(struct rkisp1_device *rkisp1); void rkisp1_csi_unregister(struct rkisp1_device *rkisp1); -int rkisp1_csi_start(struct rkisp1_csi *csi, - const struct rkisp1_sensor_async *sensor); -void rkisp1_csi_stop(struct rkisp1_csi *csi); +int rkisp1_csi_link_sensor(struct rkisp1_device *rkisp1, struct v4l2_subdev *sd, + struct rkisp1_sensor_async *s_asd, + unsigned int source_pad); #endif /* _RKISP1_CSI_H */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index faf2cd4c8149..a3e182c86bdd 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -17,6 +17,7 @@ #include #include #include +#include #include "rkisp1-common.h" #include "rkisp1-csi.h" @@ -119,17 +120,8 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, container_of(asd, struct rkisp1_sensor_async, asd); int source_pad; - s_asd->pixel_rate_ctrl = v4l2_ctrl_find(sd->ctrl_handler, - V4L2_CID_PIXEL_RATE); - if (!s_asd->pixel_rate_ctrl) { - dev_err(rkisp1->dev, "No pixel rate control in subdev %s\n", - sd->name); - return -EINVAL; - } - s_asd->sd = sd; - /* Create the link to the sensor. */ source_pad = media_entity_get_fwnode_pad(&sd->entity, s_asd->source_ep, MEDIA_PAD_FL_SOURCE); if (source_pad < 0) { @@ -138,10 +130,7 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, return source_pad; } - return media_create_pad_link(&sd->entity, source_pad, - &rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SINK_VIDEO, - !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); + return rkisp1_csi_link_sensor(rkisp1, sd, s_asd, source_pad); } static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) @@ -283,6 +272,14 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) unsigned int i; int ret; + /* Link the CSI receiver to the ISP. */ + ret = media_create_pad_link(&rkisp1->csi.sd.entity, RKISP1_CSI_PAD_SRC, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_VIDEO, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + /* create ISP->RSZ->CAP links */ for (i = 0; i < 2; i++) { struct media_entity *resizer = @@ -364,13 +361,6 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) if (ret) goto error; - ret = rkisp1_subdev_notifier_register(rkisp1); - if (ret) { - dev_err(rkisp1->dev, - "Failed to register subdev notifier(%d)\n", ret); - goto error; - } - return 0; error: @@ -534,10 +524,16 @@ static int rkisp1_probe(struct platform_device *pdev) if (ret) goto err_cleanup_csi; + ret = rkisp1_subdev_notifier_register(rkisp1); + if (ret) + goto err_unreg_entities; + rkisp1_debug_init(rkisp1); return 0; +err_unreg_entities: + rkisp1_entities_unregister(rkisp1); err_cleanup_csi: rkisp1_csi_cleanup(rkisp1); err_unreg_media_dev: diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 5afb8be311c7..260c9ce0dca4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -16,7 +16,6 @@ #include #include "rkisp1-common.h" -#include "rkisp1-csi.h" #define RKISP1_DEF_SINK_PAD_FMT MEDIA_BUS_FMT_SRGGB10_1X10 #define RKISP1_DEF_SRC_PAD_FMT MEDIA_BUS_FMT_YUYV8_2X8 @@ -728,16 +727,12 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) { struct rkisp1_isp *isp = to_rkisp1_isp(sd); struct rkisp1_device *rkisp1 = isp->rkisp1; - const struct rkisp1_sensor_async *asd; struct media_pad *source_pad; int ret; if (!enable) { v4l2_subdev_call(rkisp1->source, video, s_stream, false); - - rkisp1_csi_stop(&rkisp1->csi); rkisp1_isp_stop(isp); - return 0; } @@ -754,30 +749,20 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) return -EPIPE; } - asd = container_of(rkisp1->source->asd, struct rkisp1_sensor_async, - asd); - - if (asd->mbus_type != V4L2_MBUS_CSI2_DPHY) - return -EINVAL; + if (rkisp1->source != &rkisp1->csi.sd) + return -EPIPE; isp->frame_sequence = -1; mutex_lock(&isp->ops_lock); - ret = rkisp1_config_cif(isp, asd->mbus_type, asd->mbus_flags); + ret = rkisp1_config_cif(isp, V4L2_MBUS_CSI2_DPHY, 0); if (ret) goto mutex_unlock; rkisp1_isp_start(isp); - ret = rkisp1_csi_start(&rkisp1->csi, asd); - if (ret) { - rkisp1_isp_stop(isp); - goto mutex_unlock; - } - ret = v4l2_subdev_call(rkisp1->source, video, s_stream, true); if (ret) { rkisp1_isp_stop(isp); - rkisp1_csi_stop(&rkisp1->csi); goto mutex_unlock; } From patchwork Tue Jun 14 19:11:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881476 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91028C433EF for ; Tue, 14 Jun 2022 19:14:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357798AbiFNTOn (ORCPT ); Tue, 14 Jun 2022 15:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345388AbiFNTOm (ORCPT ); Tue, 14 Jun 2022 15:14:42 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ACB9764E for ; Tue, 14 Jun 2022 12:14:40 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B32AD96; Tue, 14 Jun 2022 21:14:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234078; bh=KDwDrnorXMslawjormLxIyDw9bPVJZXe9XsdxnbPr/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PpL4s2SDYMgXlHEZ97eD37Buy9iav1AECyETYFBjKdI/RmWrZUA4WyJidJUu8L/Cn 3C58NC+QpUeOlOvJYPQa0KwFVgrarQS5auQ5uXETjFUAZ2C+bzqYkkPMXyIA+9OSoO x/i2iZeKOkrO8LmeOM/flAX6xOnUyax+r/AQh9TE= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 42/55] media: rkisp1: Use fwnode_graph_for_each_endpoint Date: Wed, 15 Jun 2022 04:11:14 +0900 Message-Id: <20220614191127.3420492-43-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When registering the notifier, replace the manual while loop with fwnode_graph_for_each_endpoint. This simplifies error handling. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-dev.c | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index a3e182c86bdd..00ace8224575 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -158,29 +158,28 @@ static const struct v4l2_async_notifier_operations rkisp1_subdev_notifier_ops = static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) { struct v4l2_async_notifier *ntf = &rkisp1->notifier; - unsigned int next_id = 0; + struct fwnode_handle *fwnode = dev_fwnode(rkisp1->dev); + struct fwnode_handle *ep; unsigned int index = 0; - int ret; + int ret = 0; v4l2_async_nf_init(ntf); - while (1) { + ntf->ops = &rkisp1_subdev_notifier_ops; + + fwnode_graph_for_each_endpoint(fwnode, ep) { struct v4l2_fwnode_endpoint vep = { .bus_type = V4L2_MBUS_CSI2_DPHY }; struct rkisp1_sensor_async *rk_asd; - struct fwnode_handle *source = NULL; - struct fwnode_handle *ep; - - ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(rkisp1->dev), - 0, next_id, - FWNODE_GRAPH_ENDPOINT_NEXT); - if (!ep) - break; + struct fwnode_handle *source; ret = v4l2_fwnode_endpoint_parse(ep, &vep); - if (ret) - goto err_parse; + if (ret) { + dev_err(rkisp1->dev, "failed to parse endpoint %pfw\n", + ep); + break; + } source = fwnode_graph_get_remote_endpoint(ep); if (!source) { @@ -188,14 +187,15 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) "endpoint %pfw has no remote endpoint\n", ep); ret = -ENODEV; - goto err_parse; + break; } rk_asd = v4l2_async_nf_add_fwnode(ntf, source, struct rkisp1_sensor_async); if (IS_ERR(rk_asd)) { + fwnode_handle_put(source); ret = PTR_ERR(rk_asd); - goto err_parse; + break; } rk_asd->index = index++; @@ -206,27 +206,23 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) dev_dbg(rkisp1->dev, "registered ep id %d with %d lanes\n", vep.base.id, rk_asd->lanes); + } - next_id = vep.base.id + 1; - - fwnode_handle_put(ep); - - continue; -err_parse: + if (ret) { fwnode_handle_put(ep); - fwnode_handle_put(source); v4l2_async_nf_cleanup(ntf); return ret; } - if (next_id == 0) + if (!index) dev_dbg(rkisp1->dev, "no remote subdevice found\n"); - ntf->ops = &rkisp1_subdev_notifier_ops; + ret = v4l2_async_nf_register(&rkisp1->v4l2_dev, ntf); if (ret) { v4l2_async_nf_cleanup(ntf); return ret; } + return 0; } From patchwork Tue Jun 14 19:11:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 12E64C433EF for ; Tue, 14 Jun 2022 19:14:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345388AbiFNTOp (ORCPT ); Tue, 14 Jun 2022 15:14:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231270AbiFNTOo (ORCPT ); Tue, 14 Jun 2022 15:14:44 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CCA8764E for ; Tue, 14 Jun 2022 12:14:44 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 72062825; Tue, 14 Jun 2022 21:14:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234083; bh=JDrE3gIcwPaRi+Dxag5RlGTDmHsSPmdXGAsnpx6V2jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PjrcfKeIVyitcdhYkFH+otTmFavz1xBeTjQYoG2QJNYl31WuGpU9+k8KfAEIx7skj qliY6WY3MZO31W1ujN7VBuypKM5mFzKitaWcBUFHdjd2TOHxlRrTWfcgH0Rs1rGB7Q JDmyAE1gafSJnVS7kYlyCcvRfHT1sMfV0pS/sAaU= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 43/55] dt-bindings: media: rkisp1: Add port for parallel interface Date: Wed, 15 Jun 2022 04:11:15 +0900 Message-Id: <20220614191127.3420492-44-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The rkisp1 can take an input on the parallel interface. Add a port for it, and update the required field. At least one port is required, and both may be specified. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- .../bindings/media/rockchip-isp1.yaml | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/media/rockchip-isp1.yaml b/Documentation/devicetree/bindings/media/rockchip-isp1.yaml index d1489b177331..b3661d7d4357 100644 --- a/Documentation/devicetree/bindings/media/rockchip-isp1.yaml +++ b/Documentation/devicetree/bindings/media/rockchip-isp1.yaml @@ -84,8 +84,27 @@ properties: minItems: 1 maxItems: 4 - required: - - port@0 + port@1: + $ref: /schemas/graph.yaml#/$defs/port-base + unevaluatedProperties: false + description: connection point for input on the parallel interface + + properties: + bus-type: + enum: [5, 6] + + endpoint: + $ref: video-interfaces.yaml# + unevaluatedProperties: false + + required: + - bus-type + + anyOf: + - required: + - port@0 + - required: + - port@1 required: - compatible From patchwork Tue Jun 14 19:11:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881478 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 833C2C433EF for ; Tue, 14 Jun 2022 19:14:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357842AbiFNTOu (ORCPT ); Tue, 14 Jun 2022 15:14:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357829AbiFNTOt (ORCPT ); Tue, 14 Jun 2022 15:14:49 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F8B28995 for ; Tue, 14 Jun 2022 12:14:48 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9DFA89E5; Tue, 14 Jun 2022 21:14:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234086; bh=t1VabHiEpQeS0YnlCZfzPji/iFZumcWdUddy7jMzrJ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oa+K588xL+/fDx5Ee1b/sD6T2vSeHvbk+7SVMvWKZrg2VXJj+ughtzj15Jab/Xra4 HLopO1dFmA0QpgxITSzpKPJPPEkqufmLPlDbbN0CYRwzJblVWBneT8J38ravRyNOOk nUUDPblt5fNlKtxRfyyzMkMbc4P809uX7j/mpDng= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 44/55] media: rkisp1: Support the ISP parallel input Date: Wed, 15 Jun 2022 04:11:16 +0900 Message-Id: <20220614191127.3420492-45-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ISP has a parallel input, exposed through port 1 in the device tree node. While the driver supports configuring the ISP for the parallel and BT.656 input modes, the DT parsing code, the subdev bound handler and the ISP stream start handler only support the CSI input. Extend them to support the parallel input. Signed-off-by: Paul Elder Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 + .../platform/rockchip/rkisp1/rkisp1-dev.c | 68 ++++++++++++++++--- .../platform/rockchip/rkisp1/rkisp1-isp.c | 18 ++++- 3 files changed, 77 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 0ab49d1feb55..f926ca8248f8 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -130,6 +130,7 @@ struct rkisp1_info { * @mbus_flags: media bus (V4L2_MBUS_*) flags * @sd: a pointer to v4l2_subdev struct of the sensor * @pixel_rate_ctrl: pixel rate of the sensor, used to initialize the phy + * @port: port number (0: MIPI, 1: Parallel) */ struct rkisp1_sensor_async { struct v4l2_async_subdev asd; @@ -140,6 +141,7 @@ struct rkisp1_sensor_async { unsigned int mbus_flags; struct v4l2_subdev *sd; struct v4l2_ctrl *pixel_rate_ctrl; + unsigned int port; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 00ace8224575..e85cf0d79af9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -119,6 +119,7 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, struct rkisp1_sensor_async *s_asd = container_of(asd, struct rkisp1_sensor_async, asd); int source_pad; + int ret; s_asd->sd = sd; @@ -130,7 +131,20 @@ static int rkisp1_subdev_notifier_bound(struct v4l2_async_notifier *notifier, return source_pad; } - return rkisp1_csi_link_sensor(rkisp1, sd, s_asd, source_pad); + if (s_asd->port == 0) + return rkisp1_csi_link_sensor(rkisp1, sd, s_asd, source_pad); + + ret = media_create_pad_link(&sd->entity, source_pad, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_VIDEO, + !s_asd->index ? MEDIA_LNK_FL_ENABLED : 0); + if (ret) { + dev_err(rkisp1->dev, "failed to link source pad of %s\n", + sd->name); + return ret; + } + + return 0; } static int rkisp1_subdev_notifier_complete(struct v4l2_async_notifier *notifier) @@ -168,12 +182,33 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) ntf->ops = &rkisp1_subdev_notifier_ops; fwnode_graph_for_each_endpoint(fwnode, ep) { - struct v4l2_fwnode_endpoint vep = { - .bus_type = V4L2_MBUS_CSI2_DPHY - }; + struct fwnode_handle *port; + struct v4l2_fwnode_endpoint vep = { }; struct rkisp1_sensor_async *rk_asd; struct fwnode_handle *source; + u32 reg = 0; + /* Select the bus type based on the port. */ + port = fwnode_get_parent(ep); + fwnode_property_read_u32(port, "reg", ®); + fwnode_handle_put(port); + + switch (reg) { + case 0: + vep.bus_type = V4L2_MBUS_CSI2_DPHY; + break; + + case 1: + /* + * Parallel port. The bus-type property in DT is + * mandatory for port 1, it will be used to determine if + * it's PARALLEL or BT656. + */ + vep.bus_type = V4L2_MBUS_UNKNOWN; + break; + } + + /* Parse the endpoint and validate the bus type. */ ret = v4l2_fwnode_endpoint_parse(ep, &vep); if (ret) { dev_err(rkisp1->dev, "failed to parse endpoint %pfw\n", @@ -181,6 +216,17 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) break; } + if (vep.base.port == 1) { + if (vep.bus_type != V4L2_MBUS_PARALLEL && + vep.bus_type != V4L2_MBUS_BT656) { + dev_err(rkisp1->dev, + "port 1 must be parallel or BT656\n"); + ret = -EINVAL; + break; + } + } + + /* Add the async subdev to the notifier. */ source = fwnode_graph_get_remote_endpoint(ep); if (!source) { dev_err(rkisp1->dev, @@ -201,11 +247,17 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) rk_asd->index = index++; rk_asd->source_ep = source; rk_asd->mbus_type = vep.bus_type; - rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; - rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; + rk_asd->port = vep.base.port; + + if (vep.bus_type == V4L2_MBUS_CSI2_DPHY) { + rk_asd->mbus_flags = vep.bus.mipi_csi2.flags; + rk_asd->lanes = vep.bus.mipi_csi2.num_data_lanes; + } else { + rk_asd->mbus_flags = vep.bus.parallel.flags; + } - dev_dbg(rkisp1->dev, "registered ep id %d with %d lanes\n", - vep.base.id, rk_asd->lanes); + dev_dbg(rkisp1->dev, "registered ep id %d, bus type %u, %u lanes\n", + vep.base.id, rk_asd->mbus_type, rk_asd->lanes); } if (ret) { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 260c9ce0dca4..8268331faca9 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -728,6 +728,8 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) struct rkisp1_isp *isp = to_rkisp1_isp(sd); struct rkisp1_device *rkisp1 = isp->rkisp1; struct media_pad *source_pad; + enum v4l2_mbus_type mbus_type; + u32 mbus_flags; int ret; if (!enable) { @@ -749,12 +751,22 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) return -EPIPE; } - if (rkisp1->source != &rkisp1->csi.sd) - return -EPIPE; + if (rkisp1->source == &rkisp1->csi.sd) { + mbus_type = V4L2_MBUS_CSI2_DPHY; + mbus_flags = 0; + } else { + const struct rkisp1_sensor_async *asd; + + asd = container_of(rkisp1->source->asd, + struct rkisp1_sensor_async, asd); + + mbus_type = asd->mbus_type; + mbus_flags = asd->mbus_flags; + } isp->frame_sequence = -1; mutex_lock(&isp->ops_lock); - ret = rkisp1_config_cif(isp, V4L2_MBUS_CSI2_DPHY, 0); + ret = rkisp1_config_cif(isp, mbus_type, mbus_flags); if (ret) goto mutex_unlock; From patchwork Tue Jun 14 19:11:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0C8DC433EF for ; Tue, 14 Jun 2022 19:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357815AbiFNTOx (ORCPT ); Tue, 14 Jun 2022 15:14:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357853AbiFNTOw (ORCPT ); Tue, 14 Jun 2022 15:14:52 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1624167E1 for ; Tue, 14 Jun 2022 12:14:51 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8E019D96; Tue, 14 Jun 2022 21:14:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234090; bh=Bhft2ql1CSfmPHJxfGOvZIq7jzGcGv9JEwoGwE8igyI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uVkpy072o89BR0n10QWcZ6dBCRoenK46mXj1Oq0Ygzbh3P/R25wl+OFtY4CdwWR61 M3/eExIQs+fhmTFMzBQq1DgcLY5g/+AxU+zf06A98G5fIF1t/5+RLlLqijQWL63qE9 BHCyaLzlRxLWODdX4YL5wE4MoURGZ7le6ekI2TuQ= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 45/55] media: rkisp1: Add infrastructure to support ISP features Date: Wed, 15 Jun 2022 04:11:17 +0900 Message-Id: <20220614191127.3420492-46-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Different ISP versions implement different sets of features. The driver already takes the version into account in several places, but this approach won't scale well for features that are found in different versions. Introduce a new mechanism using a features bitmask in the rkisp1_info structure to indicate which features the ISP support. The first feature bit tells if the ISP has an internal CSI-2 receiver, which is not available in all ISP versions. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 15 +++++++++++++++ .../media/platform/rockchip/rkisp1/rkisp1-dev.c | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index f926ca8248f8..eccdd3f9bc89 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -98,6 +98,19 @@ enum rkisp1_isp_pad { RKISP1_ISP_PAD_MAX }; +/* + * enum rkisp1_feature - ISP features + * + * @RKISP1_FEATURE_MIPI_CSI2: The ISP has an internal MIPI CSI-2 receiver + * + * The ISP features are stored in a bitmask in &rkisp1_info.features and allow + * the driver to implement support for features present in some ISP versions + * only. + */ +enum rkisp1_feature { + RKISP1_FEATURE_MIPI_CSI2 = BIT(0), +}; + /* * struct rkisp1_info - Model-specific ISP Information * @@ -106,6 +119,7 @@ enum rkisp1_isp_pad { * @isrs: array of ISP interrupt descriptors * @isr_size: number of entires in the @isrs array * @isp_ver: ISP version + * @features: bitmatk of rkisp1_feature features implemented by the ISP * * This structure contains information about the ISP specific to a particular * ISP model, version, or integration in a particular SoC. @@ -116,6 +130,7 @@ struct rkisp1_info { const struct rkisp1_isr_data *isrs; unsigned int isr_size; enum rkisp1_cif_isp_version isp_ver; + unsigned int features; }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index e85cf0d79af9..8ccd4042f3f3 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -450,6 +450,7 @@ static const struct rkisp1_info px30_isp_info = { .isrs = px30_isp_isrs, .isr_size = ARRAY_SIZE(px30_isp_isrs), .isp_ver = RKISP1_V12, + .features = RKISP1_FEATURE_MIPI_CSI2, }; static const char * const rk3399_isp_clks[] = { @@ -468,6 +469,7 @@ static const struct rkisp1_info rk3399_isp_info = { .isrs = rk3399_isp_isrs, .isr_size = ARRAY_SIZE(rk3399_isp_isrs), .isp_ver = RKISP1_V10, + .features = RKISP1_FEATURE_MIPI_CSI2, }; static const struct of_device_id rkisp1_of_match[] = { From patchwork Tue Jun 14 19:11:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881480 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF934C43334 for ; Tue, 14 Jun 2022 19:14:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357853AbiFNTO5 (ORCPT ); Tue, 14 Jun 2022 15:14:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357829AbiFNTO4 (ORCPT ); Tue, 14 Jun 2022 15:14:56 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4F65764E for ; Tue, 14 Jun 2022 12:14:55 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 43A4B825; Tue, 14 Jun 2022 21:14:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234094; bh=EG0U4nHqxwGlJmaOm9q7pgjmOJ4qGSCMRWmGBWC+C8E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q86Xja8JKk2RFys5yEk+mzSSX1efewrDVQThh8bG/sO0zFE6ACbSfMU5E9wO0N9ZV VvqNCfBpTNGyBtsXdzWjTpTtG35+bQC8WHex2Uw1tP8/DCGGu7KQgiEa7uf1eJvCpm NecY0+H1wdgesO8NO2cHo5yl9iDjQzPyuYpCPiew= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 46/55] media: rkisp1: Make the internal CSI-2 receiver optional Date: Wed, 15 Jun 2022 04:11:18 +0900 Message-Id: <20220614191127.3420492-47-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart Not all ISP versions integrate a MIPI CSI-2 receiver. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-dev.c | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 8ccd4042f3f3..62fa2bd275fe 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -195,6 +195,14 @@ static int rkisp1_subdev_notifier_register(struct rkisp1_device *rkisp1) switch (reg) { case 0: + /* MIPI CSI-2 port */ + if (!(rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2)) { + dev_err(rkisp1->dev, + "internal CSI must be available for port 0\n"); + ret = -EINVAL; + break; + } + vep.bus_type = V4L2_MBUS_CSI2_DPHY; break; @@ -320,13 +328,16 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) unsigned int i; int ret; - /* Link the CSI receiver to the ISP. */ - ret = media_create_pad_link(&rkisp1->csi.sd.entity, RKISP1_CSI_PAD_SRC, - &rkisp1->isp.sd.entity, - RKISP1_ISP_PAD_SINK_VIDEO, - MEDIA_LNK_FL_ENABLED); - if (ret) - return ret; + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) { + /* Link the CSI receiver to the ISP. */ + ret = media_create_pad_link(&rkisp1->csi.sd.entity, + RKISP1_CSI_PAD_SRC, + &rkisp1->isp.sd.entity, + RKISP1_ISP_PAD_SINK_VIDEO, + MEDIA_LNK_FL_ENABLED); + if (ret) + return ret; + } /* create ISP->RSZ->CAP links */ for (i = 0; i < 2; i++) { @@ -369,7 +380,8 @@ static int rkisp1_create_links(struct rkisp1_device *rkisp1) static void rkisp1_entities_unregister(struct rkisp1_device *rkisp1) { - rkisp1_csi_unregister(rkisp1); + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) + rkisp1_csi_unregister(rkisp1); rkisp1_params_unregister(rkisp1); rkisp1_stats_unregister(rkisp1); rkisp1_capture_devs_unregister(rkisp1); @@ -401,9 +413,11 @@ static int rkisp1_entities_register(struct rkisp1_device *rkisp1) if (ret) goto error; - ret = rkisp1_csi_register(rkisp1); - if (ret) - goto error; + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) { + ret = rkisp1_csi_register(rkisp1); + if (ret) + goto error; + } ret = rkisp1_create_links(rkisp1); if (ret) @@ -566,9 +580,11 @@ static int rkisp1_probe(struct platform_device *pdev) goto err_unreg_v4l2_dev; } - ret = rkisp1_csi_init(rkisp1); - if (ret) - goto err_unreg_media_dev; + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) { + ret = rkisp1_csi_init(rkisp1); + if (ret) + goto err_unreg_media_dev; + } ret = rkisp1_entities_register(rkisp1); if (ret) @@ -585,7 +601,8 @@ static int rkisp1_probe(struct platform_device *pdev) err_unreg_entities: rkisp1_entities_unregister(rkisp1); err_cleanup_csi: - rkisp1_csi_cleanup(rkisp1); + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) + rkisp1_csi_cleanup(rkisp1); err_unreg_media_dev: media_device_unregister(&rkisp1->media_dev); err_unreg_v4l2_dev: @@ -603,7 +620,8 @@ static int rkisp1_remove(struct platform_device *pdev) v4l2_async_nf_cleanup(&rkisp1->notifier); rkisp1_entities_unregister(rkisp1); - rkisp1_csi_cleanup(rkisp1); + if (rkisp1->info->features & RKISP1_FEATURE_MIPI_CSI2) + rkisp1_csi_cleanup(rkisp1); rkisp1_debug_cleanup(rkisp1); media_device_unregister(&rkisp1->media_dev); From patchwork Tue Jun 14 19:11:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DBE13C433EF for ; Tue, 14 Jun 2022 19:15:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245239AbiFNTPB (ORCPT ); Tue, 14 Jun 2022 15:15:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbiFNTPA (ORCPT ); Tue, 14 Jun 2022 15:15:00 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1569F11C0F for ; Tue, 14 Jun 2022 12:15:00 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 23F449E5; Tue, 14 Jun 2022 21:14:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234098; bh=baLg4ESdTFTdfXTHb8sK66nWlixJdHENVXjvY+MGTRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o1lvvf+lHmn5+AGAMBjfEhOQyN669YcK9CznC1BAfAfHs3fsOOR6IgelUSanUvum8 3J4H3iZ7m2cgwGVvvwKeD0PL9+mRctBGiork6r/Fh+swNxuXKhEx1p8xSwYmFIoFcA 3fXu7M2DwfcMRbNcJPsX/AGFCEixmHWewR3AdQlw= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 47/55] dt-bindings: media: rkisp1: Add i.MX8MP ISP to compatible Date: Wed, 15 Jun 2022 04:11:19 +0900 Message-Id: <20220614191127.3420492-48-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The i.MX8MP ISP is compatbile with the rkisp1 driver. Add it to the list of compatible strings. While at it, expand on the description of the clocks to make it clear which clock in the i.MX8MP ISP they map to, based on the names from the datasheet (which are confusing). Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Documentation/devicetree/bindings/media/rockchip-isp1.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/media/rockchip-isp1.yaml b/Documentation/devicetree/bindings/media/rockchip-isp1.yaml index b3661d7d4357..95cf945f7ac5 100644 --- a/Documentation/devicetree/bindings/media/rockchip-isp1.yaml +++ b/Documentation/devicetree/bindings/media/rockchip-isp1.yaml @@ -16,6 +16,7 @@ description: | properties: compatible: enum: + - fsl,imx8mp-isp - rockchip,px30-cif-isp - rockchip,rk3399-cif-isp @@ -36,9 +37,9 @@ properties: minItems: 3 items: # isp0 and isp1 - - description: ISP clock - - description: ISP AXI clock - - description: ISP AHB clock + - description: ISP clock (for imx8mp, clk) + - description: ISP AXI clock (for imx8mp, m_hclk) + - description: ISP AHB clock (for imx8mp, hclk) # only for isp1 - description: ISP Pixel clock From patchwork Tue Jun 14 19:11:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EEABC433EF for ; Tue, 14 Jun 2022 19:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357880AbiFNTPG (ORCPT ); Tue, 14 Jun 2022 15:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352403AbiFNTPF (ORCPT ); Tue, 14 Jun 2022 15:15:05 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E071764E for ; Tue, 14 Jun 2022 12:15:04 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 72128D96; Tue, 14 Jun 2022 21:14:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234103; bh=h3v3qWRipH1zNKbuAdnfoVFADmknQ5uyeAOGcsWH2i4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O/sDDhqGHqZOebnPjeGgsIidJdAyX9JjaGihyBtMNKI3HOUnjOi0p5U6ElgjmhsTX kyKjSmEAWlJp2lR81zkao1Y3ZJDKwbEs/BAsfklZaorNqnd6ymtly4dGBrA3s+eMcO qVMF2OBhbpquDBUXZ02puPt+RUqvvgumu3hhwUlc= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 48/55] media: rkisp1: Add match data for i.MX8MP ISP Date: Wed, 15 Jun 2022 04:11:20 +0900 Message-Id: <20220614191127.3420492-49-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add match data to the rkisp1 driver to match the i.MX8MP ISP. Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-dev.c | 22 +++++++++++++++++++ include/uapi/linux/rkisp1-config.h | 3 +++ 2 files changed, 25 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 62fa2bd275fe..3a0115bdcee5 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -486,6 +486,24 @@ static const struct rkisp1_info rk3399_isp_info = { .features = RKISP1_FEATURE_MIPI_CSI2, }; +static const char * const imx8mp_isp_clks[] = { + "isp", + "hclk", + "aclk", +}; + +static const struct rkisp1_isr_data imx8mp_isp_isrs[] = { + { NULL, rkisp1_isr }, +}; + +static const struct rkisp1_info imx8mp_isp_info = { + .clks = imx8mp_isp_clks, + .clk_size = ARRAY_SIZE(imx8mp_isp_clks), + .isrs = imx8mp_isp_isrs, + .isr_size = ARRAY_SIZE(imx8mp_isp_isrs), + .isp_ver = IMX8MP_V10, +}; + static const struct of_device_id rkisp1_of_match[] = { { .compatible = "rockchip,px30-cif-isp", @@ -495,6 +513,10 @@ static const struct of_device_id rkisp1_of_match[] = { .compatible = "rockchip,rk3399-cif-isp", .data = &rk3399_isp_info, }, + { + .compatible = "fsl,imx8mp-isp", + .data = &imx8mp_isp_info, + }, {}, }; MODULE_DEVICE_TABLE(of, rkisp1_of_match); diff --git a/include/uapi/linux/rkisp1-config.h b/include/uapi/linux/rkisp1-config.h index 583ca0d9a79d..40677d47825c 100644 --- a/include/uapi/linux/rkisp1-config.h +++ b/include/uapi/linux/rkisp1-config.h @@ -140,12 +140,15 @@ * @RKISP1_V11: declared in the original vendor code, but not used * @RKISP1_V12: used at least in rk3326 and px30 * @RKISP1_V13: used at least in rk1808 + * @IMX8MP_V10: used in at least imx8mp */ enum rkisp1_cif_isp_version { RKISP1_V10 = 10, RKISP1_V11, RKISP1_V12, RKISP1_V13, + /* TODO Choose a better version for this */ + IMX8MP_V10, }; enum rkisp1_cif_isp_histogram_mode { From patchwork Tue Jun 14 19:11:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 834CDCCA47A for ; Tue, 14 Jun 2022 19:15:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357891AbiFNTPK (ORCPT ); Tue, 14 Jun 2022 15:15:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352403AbiFNTPJ (ORCPT ); Tue, 14 Jun 2022 15:15:09 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6298228995 for ; Tue, 14 Jun 2022 12:15:08 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C022D9E5; Tue, 14 Jun 2022 21:15:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234107; bh=1iqfhx8zGRDSs2euNuBOSF9s402ZhZkH0ceimyzhUEQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZbfU4K/V9vO4I5Xp60m1l28ODImX8rQmiVZYOllHr5rQZLgB5ogikRA1z4ZL6sIB Mwshxre3cxJdUUZedVyzr/U6dwK9qUsERz5ZcY0gvD0u0haEX/NVivf2LMgOcgwAhF AyQCrb1YsVdFA07NlqyvAzPcwZcq0f5YljaXBRWQ= From: Paul Elder To: linux-media@vger.kernel.org Cc: Laurent Pinchart , dafna@fastmail.com, heiko@sntech.de, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 49/55] media: rkisp1: Configure gasket on i.MX8MP Date: Wed, 15 Jun 2022 04:11:21 +0900 Message-Id: <20220614191127.3420492-50-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Laurent Pinchart The i.MX8MP has a gasket between the CSI-2 receiver and the ISP. Configure and enable it when starting the ISP, and disable it when stopping. Signed-off-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-common.h | 5 + .../platform/rockchip/rkisp1/rkisp1-dev.c | 16 +++ .../platform/rockchip/rkisp1/rkisp1-isp.c | 128 +++++++++++++++++- 3 files changed, 147 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index eccdd3f9bc89..667fca0fef95 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -24,6 +24,7 @@ #include "rkisp1-regs.h" struct dentry; +struct regmap; /* * flags on the 'direction' field in struct rkisp1_mbus_info' that indicate @@ -451,6 +452,8 @@ struct rkisp1_debug { * @dev: a pointer to the struct device * @clk_size: number of clocks * @clks: array of clocks + * @gasket: the gasket - i.MX8MP only + * @gasket_id: the gasket ID (0 or 1) - i.MX8MP only * @v4l2_dev: v4l2_device variable * @media_dev: media_device variable * @notifier: a notifier to register on the v4l2-async API to be notified on the sensor @@ -471,6 +474,8 @@ struct rkisp1_device { struct device *dev; unsigned int clk_size; struct clk_bulk_data clks[RKISP1_MAX_BUS_CLK]; + struct regmap *gasket; + unsigned int gasket_id; struct v4l2_device v4l2_dev; struct media_device media_dev; struct v4l2_async_notifier notifier; diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 3a0115bdcee5..a4496ee2e9b4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -569,6 +570,21 @@ static int rkisp1_probe(struct platform_device *pdev) return ret; rkisp1->clk_size = info->clk_size; + if (info->isp_ver == IMX8MP_V10) { + unsigned int id; + + rkisp1->gasket = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "fsl,blk-ctrl", + 1, &id); + if (IS_ERR(rkisp1->gasket)) { + ret = PTR_ERR(rkisp1->gasket); + dev_err(dev, "failed to get gasket: %d\n", ret); + return ret; + } + + rkisp1->gasket_id = id; + } + pm_runtime_enable(&pdev->dev); ret = pm_runtime_resume_and_get(&pdev->dev); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 8268331faca9..ddad36ab4389 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -87,6 +88,115 @@ rkisp1_isp_get_pad_crop(struct rkisp1_isp *isp, return v4l2_subdev_get_try_crop(&isp->sd, &state, pad); } +/* ----------------------------------------------------------------------------- + * Media block control (i.MX8MP only) + */ + +#define ISP_DEWARP_CONTROL 0x0138 + +#define ISP_DEWARP_CONTROL_MIPI_CSI2_HS_POLARITY BIT(22) +#define ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_RISING (0 << 20) +#define ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_NEGATIVE (1 << 20) +#define ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_POSITIVE (2 << 20) +#define ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_FALLING (3 << 20) +#define ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_MASK GENMASK(21, 20) +#define ISP_DEWARP_CONTROL_MIPI_ISP2_LEFT_JUST_MODE BIT(19) +#define ISP_DEWARP_CONTROL_MIPI_ISP2_DATA_TYPE(dt) ((dt) << 13) +#define ISP_DEWARP_CONTROL_MIPI_ISP2_DATA_TYPE_MASK GENMASK(18, 13) + +#define ISP_DEWARP_CONTROL_MIPI_CSI1_HS_POLARITY BIT(12) +#define ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_RISING (0 << 10) +#define ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_NEGATIVE (1 << 10) +#define ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_POSITIVE (2 << 10) +#define ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_FALLING (3 << 10) +#define ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_MASK GENMASK(11, 10) +#define ISP_DEWARP_CONTROL_MIPI_ISP1_LEFT_JUST_MODE BIT(9) +#define ISP_DEWARP_CONTROL_MIPI_ISP1_DATA_TYPE(dt) ((dt) << 3) +#define ISP_DEWARP_CONTROL_MIPI_ISP1_DATA_TYPE_MASK GENMASK(8, 3) + +#define ISP_DEWARP_CONTROL_GPR_ISP_1_DISABLE BIT(1) +#define ISP_DEWARP_CONTROL_GPR_ISP_0_DISABLE BIT(0) + +static int rkisp1_gasket_enable(struct rkisp1_device *rkisp1, + struct media_pad *source) +{ + struct v4l2_subdev *source_sd; + struct v4l2_mbus_frame_desc fd; + unsigned int dt; + u32 mask; + u32 val; + int ret; + + /* + * Configure and enable the gasket with the CSI-2 data type. Set the + * vsync polarity as active high, as that is what the ISP is configured + * to expect in ISP_ACQ_PROP. Enable left justification, as the i.MX8MP + * ISP has a 16-bit wide input and expects data to be left-aligned. + */ + + source_sd = media_entity_to_v4l2_subdev(source->entity); + ret = v4l2_subdev_call(source_sd, pad, get_frame_desc, + source->index, &fd); + if (ret) { + dev_err(rkisp1->dev, + "failed to get frame descriptor from '%s':%u: %d\n", + source_sd->name, 0, ret); + return ret; + } + + if (fd.num_entries != 1) { + dev_err(rkisp1->dev, "invalid frame descriptor for '%s':%u\n", + source_sd->name, 0); + return -EINVAL; + } + + dt = fd.entry[0].bus.csi2.dt; + + if (rkisp1->gasket_id == 0) { + mask = ISP_DEWARP_CONTROL_MIPI_CSI1_HS_POLARITY + | ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_MASK + | ISP_DEWARP_CONTROL_MIPI_ISP1_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP1_DATA_TYPE_MASK + | ISP_DEWARP_CONTROL_GPR_ISP_0_DISABLE; + val = ISP_DEWARP_CONTROL_MIPI_CSI1_VS_SEL_POSITIVE + | ISP_DEWARP_CONTROL_MIPI_ISP1_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP1_DATA_TYPE(dt); + } else { + mask = ISP_DEWARP_CONTROL_MIPI_CSI2_HS_POLARITY + | ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_MASK + | ISP_DEWARP_CONTROL_MIPI_ISP2_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP2_DATA_TYPE_MASK + | ISP_DEWARP_CONTROL_GPR_ISP_1_DISABLE; + val = ISP_DEWARP_CONTROL_MIPI_CSI2_VS_SEL_POSITIVE + | ISP_DEWARP_CONTROL_MIPI_ISP2_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP2_DATA_TYPE(dt); + } + + regmap_update_bits(rkisp1->gasket, ISP_DEWARP_CONTROL, mask, val); + + return 0; +} + +static void rkisp1_gasket_disable(struct rkisp1_device *rkisp1) +{ + u32 mask; + u32 val; + + if (rkisp1->gasket_id == 1) { + mask = ISP_DEWARP_CONTROL_MIPI_ISP2_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP2_DATA_TYPE_MASK + | ISP_DEWARP_CONTROL_GPR_ISP_1_DISABLE; + val = ISP_DEWARP_CONTROL_GPR_ISP_1_DISABLE; + } else { + mask = ISP_DEWARP_CONTROL_MIPI_ISP1_LEFT_JUST_MODE + | ISP_DEWARP_CONTROL_MIPI_ISP1_DATA_TYPE_MASK + | ISP_DEWARP_CONTROL_GPR_ISP_0_DISABLE; + val = ISP_DEWARP_CONTROL_GPR_ISP_0_DISABLE; + } + + regmap_update_bits(rkisp1->gasket, ISP_DEWARP_CONTROL, mask, val); +} + /* ---------------------------------------------------------------------------- * Camera Interface registers configurations */ @@ -303,6 +413,9 @@ static void rkisp1_isp_stop(struct rkisp1_isp *isp) RKISP1_CIF_VI_IRCL_MIPI_SW_RST | RKISP1_CIF_VI_IRCL_ISP_SW_RST); rkisp1_write(rkisp1, RKISP1_CIF_VI_IRCL, 0x0); + + if (rkisp1->info->isp_ver == IMX8MP_V10) + rkisp1_gasket_disable(rkisp1); } static void rkisp1_config_clk(struct rkisp1_isp *isp) @@ -327,19 +440,28 @@ static void rkisp1_config_clk(struct rkisp1_isp *isp) } } -static void rkisp1_isp_start(struct rkisp1_isp *isp) +static int rkisp1_isp_start(struct rkisp1_isp *isp, struct media_pad *source) { struct rkisp1_device *rkisp1 = isp->rkisp1; u32 val; + int ret; rkisp1_config_clk(isp); + if (rkisp1->info->isp_ver == IMX8MP_V10) { + ret = rkisp1_gasket_enable(rkisp1, source); + if (ret) + return ret; + } + /* Activate ISP */ val = rkisp1_read(rkisp1, RKISP1_CIF_ISP_CTRL); val |= RKISP1_CIF_ISP_CTRL_ISP_CFG_UPD | RKISP1_CIF_ISP_CTRL_ISP_ENABLE | RKISP1_CIF_ISP_CTRL_ISP_INFORM_ENABLE; rkisp1_write(rkisp1, RKISP1_CIF_ISP_CTRL, val); + + return 0; } /* ---------------------------------------------------------------------------- @@ -770,7 +892,9 @@ static int rkisp1_isp_s_stream(struct v4l2_subdev *sd, int enable) if (ret) goto mutex_unlock; - rkisp1_isp_start(isp); + ret = rkisp1_isp_start(isp, source_pad); + if (ret) + goto mutex_unlock; ret = v4l2_subdev_call(rkisp1->source, video, s_stream, true); if (ret) { From patchwork Tue Jun 14 19:11:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881484 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A28A6C43334 for ; Tue, 14 Jun 2022 19:15:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243228AbiFNTPP (ORCPT ); Tue, 14 Jun 2022 15:15:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357900AbiFNTPO (ORCPT ); Tue, 14 Jun 2022 15:15:14 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D338228705 for ; Tue, 14 Jun 2022 12:15:12 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C0291825; Tue, 14 Jun 2022 21:15:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234111; bh=oK+rU4Lkk88AlP7PONSvWsmoI8W3t86TP+7Am/+lmTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QYmyA+k3xNKsJvunh03jM2iuV4DA5xhACPV0MVVTaJpX5IuzIFWUjy4NpfZ7c3uTM iDK+8V7gq3HJIu2sfty6+2y5R+pjpagM1zZJjUJFMP9/rsR8jyhS7JEMJd1uR6mN2P VBHoQVt402kIHx7yMqlXBFdKGJs1zwfcDCsozmT0= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 50/55] media: rkisp1: Add and set registers for crop for i.MX8MP Date: Wed, 15 Jun 2022 04:11:22 +0900 Message-Id: <20220614191127.3420492-51-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ISP version in the i.MX8MP has a separate set of registers for crop that is currently not handled. Add a feature flag to determine which type of crop the ISP supports and set the crop registers based on that. Signed-off-by: Laurent Pinchart Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-common.h | 2 ++ .../platform/rockchip/rkisp1/rkisp1-debug.c | 14 +++++++++++++- .../platform/rockchip/rkisp1/rkisp1-dev.c | 7 +++++-- .../platform/rockchip/rkisp1/rkisp1-regs.h | 9 +++++++++ .../platform/rockchip/rkisp1/rkisp1-resizer.c | 19 +++++++++++++++++-- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 667fca0fef95..e4f422bed09a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -110,6 +110,8 @@ enum rkisp1_isp_pad { */ enum rkisp1_feature { RKISP1_FEATURE_MIPI_CSI2 = BIT(0), + RKISP1_FEATURE_DUAL_CROP = BIT(1), + RKISP1_FEATURE_RSZ_CROP = BIT(2), }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c index 02854e8ea1a4..753abd024ce7 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-debug.c @@ -115,9 +115,21 @@ static int rkisp1_debug_dump_rsz_regs_show(struct seq_file *m, void *p) RKISP1_DEBUG_SHD_REG(RSZ_PHASE_VC), { /* Sentinel */ }, }; + static const struct rkisp1_debug_register crop_registers[] = { + RKISP1_DEBUG_SHD_REG(RSZ_CROP_X_DIR), + RKISP1_DEBUG_SHD_REG(RSZ_CROP_Y_DIR), + RKISP1_DEBUG_REG(RSZ_FRAME_RATE), + RKISP1_DEBUG_REG(RSZ_FORMAT_CONV_CTRL), + { /* Sentinel */ }, + }; struct rkisp1_resizer *rsz = m->private; - return rkisp1_debug_dump_regs(rsz->rkisp1, m, rsz->regs_base, registers); + rkisp1_debug_dump_regs(rsz->rkisp1, m, rsz->regs_base, registers); + if (rsz->rkisp1->info->features & RKISP1_FEATURE_RSZ_CROP) + rkisp1_debug_dump_regs(rsz->rkisp1, m, rsz->regs_base, + crop_registers); + + return 0; } DEFINE_SHOW_ATTRIBUTE(rkisp1_debug_dump_rsz_regs); diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index a4496ee2e9b4..5abe33f5fed4 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -465,7 +465,8 @@ static const struct rkisp1_info px30_isp_info = { .isrs = px30_isp_isrs, .isr_size = ARRAY_SIZE(px30_isp_isrs), .isp_ver = RKISP1_V12, - .features = RKISP1_FEATURE_MIPI_CSI2, + .features = RKISP1_FEATURE_MIPI_CSI2 + | RKISP1_FEATURE_DUAL_CROP, }; static const char * const rk3399_isp_clks[] = { @@ -484,7 +485,8 @@ static const struct rkisp1_info rk3399_isp_info = { .isrs = rk3399_isp_isrs, .isr_size = ARRAY_SIZE(rk3399_isp_isrs), .isp_ver = RKISP1_V10, - .features = RKISP1_FEATURE_MIPI_CSI2, + .features = RKISP1_FEATURE_MIPI_CSI2 + | RKISP1_FEATURE_DUAL_CROP, }; static const char * const imx8mp_isp_clks[] = { @@ -503,6 +505,7 @@ static const struct rkisp1_info imx8mp_isp_info = { .isrs = imx8mp_isp_isrs, .isr_size = ARRAY_SIZE(imx8mp_isp_isrs), .isp_ver = IMX8MP_V10, + .features = RKISP1_FEATURE_RSZ_CROP, }; static const struct of_device_id rkisp1_of_match[] = { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index dd3e6c38be67..1fc54ab22b6d 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -168,6 +168,9 @@ #define RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO BIT(9) #define RKISP1_CIF_RSZ_SCALER_FACTOR BIT(16) +/* RSZ_CROP_[XY]_DIR */ +#define RKISP1_CIF_RSZ_CROP_XY_DIR(start, end) ((end) << 16 | (start) << 0) + /* MI_IMSC - MI_MIS - MI_RIS - MI_ICR - MI_ISR */ #define RKISP1_CIF_MI_FRAME(stream) BIT((stream)->id) #define RKISP1_CIF_MI_MBLK_LINE BIT(2) @@ -926,6 +929,12 @@ #define RKISP1_CIF_RSZ_PHASE_HC_SHD 0x004C #define RKISP1_CIF_RSZ_PHASE_VY_SHD 0x0050 #define RKISP1_CIF_RSZ_PHASE_VC_SHD 0x0054 +#define RKISP1_CIF_RSZ_CROP_X_DIR 0x0058 +#define RKISP1_CIF_RSZ_CROP_Y_DIR 0x005C +#define RKISP1_CIF_RSZ_CROP_X_DIR_SHD 0x0060 +#define RKISP1_CIF_RSZ_CROP_Y_DIR_SHD 0x0064 +#define RKISP1_CIF_RSZ_FRAME_RATE 0x0068 +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL 0x006C #define RKISP1_CIF_MI_BASE 0x00001400 #define RKISP1_CIF_MI_CTRL (RKISP1_CIF_MI_BASE + 0x00000000) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c index f4caa8f684aa..08bf3aa8088f 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c @@ -244,6 +244,7 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz, { u32 ratio, rsz_ctrl = 0; unsigned int i; + u32 val; /* No phase offset */ rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_PHASE_HY, 0); @@ -292,6 +293,18 @@ static void rkisp1_rsz_config_regs(struct rkisp1_resizer *rsz, rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_CTRL, rsz_ctrl); + if (rsz->rkisp1->info->features & RKISP1_FEATURE_RSZ_CROP) { + val = RKISP1_CIF_RSZ_CROP_XY_DIR(src_y->left, src_y->left + src_y->width - 1); + rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_CROP_X_DIR, val); + val = RKISP1_CIF_RSZ_CROP_XY_DIR(src_y->top, src_y->top + src_y->height - 1); + rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_CROP_Y_DIR, val); + + val = RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_INPUT_FORMAT_YCBCR_422 + | RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_OUTPUT_FORMAT_YCBCR_420 + | RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_PACK_FORMAT_SEMI_PLANAR; + rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_FORMAT_CONV_CTRL, val); + } + rkisp1_rsz_update_shadow(rsz, when); } @@ -656,7 +669,8 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable) enum rkisp1_shadow_regs_when when = RKISP1_SHADOW_REGS_SYNC; if (!enable) { - rkisp1_dcrop_disable(rsz, RKISP1_SHADOW_REGS_ASYNC); + if (rkisp1->info->features & RKISP1_FEATURE_DUAL_CROP) + rkisp1_dcrop_disable(rsz, RKISP1_SHADOW_REGS_ASYNC); rkisp1_rsz_disable(rsz, RKISP1_SHADOW_REGS_ASYNC); return 0; } @@ -666,7 +680,8 @@ static int rkisp1_rsz_s_stream(struct v4l2_subdev *sd, int enable) mutex_lock(&rsz->ops_lock); rkisp1_rsz_config(rsz, when); - rkisp1_dcrop_config(rsz); + if (rkisp1->info->features & RKISP1_FEATURE_DUAL_CROP) + rkisp1_dcrop_config(rsz); mutex_unlock(&rsz->ops_lock); return 0; From patchwork Tue Jun 14 19:11:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E822CC43334 for ; Tue, 14 Jun 2022 19:15:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357900AbiFNTPU (ORCPT ); Tue, 14 Jun 2022 15:15:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357894AbiFNTPS (ORCPT ); Tue, 14 Jun 2022 15:15:18 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5717828705 for ; Tue, 14 Jun 2022 12:15:17 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 412B6D96; Tue, 14 Jun 2022 21:15:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234116; bh=5pNr9/pV+cMYN9Su0BLdIhQqcBSnGWJJy0qdYwzRJnM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=udfMvX+5NEAwziY2aZDRaAwplJgvuRaz+Qfm1t3EZa8+8PZx8QH82dvGruMNwD9jk 2kh1ESYq3ycFHiNWwtW5CtRp8iteKIvUK43wwZglPnZaTN/fNPQ+huqmlPzSk6XHkG SGhADWgbKlPIKr9XDhUSlkFAT1+swHiN/LdCA2gE= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 51/55] media: rkisp1: Add and set registers for output size config on i.MX8MP Date: Wed, 15 Jun 2022 04:11:23 +0900 Message-Id: <20220614191127.3420492-52-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ISP version in the i.MX8MP has a set of registers currently not handled by the driver for output size configuration. Add a feature flag to determine if the ISP requires this, and set the registers based on that. Signed-off-by: Laurent Pinchart Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c | 8 ++++++++ drivers/media/platform/rockchip/rkisp1/rkisp1-common.h | 1 + drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c | 3 ++- drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 9edaa95fa44c..35cec263c563 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -420,6 +420,14 @@ static void rkisp1_mp_config(struct rkisp1_capture *cap) rkisp1_write(rkisp1, cap->config->mi.cr_size_init, rkisp1_pixfmt_comp_size(pixm, RKISP1_PLANE_CR)); + if (rkisp1->info->features & RKISP1_FEATURE_MAIN_STRIDE) { + rkisp1_write(rkisp1, RKISP1_CIF_MI_MP_Y_LLENGTH, pixm->width); + rkisp1_write(rkisp1, RKISP1_CIF_MI_MP_Y_PIC_WIDTH, pixm->width); + rkisp1_write(rkisp1, RKISP1_CIF_MI_MP_Y_PIC_HEIGHT, pixm->height); + rkisp1_write(rkisp1, RKISP1_CIF_MI_MP_Y_PIC_SIZE, + pixm->width * pixm->height); + } + rkisp1_irq_frame_end_enable(cap); /* set uv swapping for semiplanar formats */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index e4f422bed09a..96657e55a5b0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -112,6 +112,7 @@ enum rkisp1_feature { RKISP1_FEATURE_MIPI_CSI2 = BIT(0), RKISP1_FEATURE_DUAL_CROP = BIT(1), RKISP1_FEATURE_RSZ_CROP = BIT(2), + RKISP1_FEATURE_MAIN_STRIDE = BIT(3), }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index 5abe33f5fed4..d68a805e8b6b 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -505,7 +505,8 @@ static const struct rkisp1_info imx8mp_isp_info = { .isrs = imx8mp_isp_isrs, .isr_size = ARRAY_SIZE(imx8mp_isp_isrs), .isp_ver = IMX8MP_V10, - .features = RKISP1_FEATURE_RSZ_CROP, + .features = RKISP1_FEATURE_RSZ_CROP + | RKISP1_FEATURE_MAIN_STRIDE, }; static const struct of_device_id rkisp1_of_match[] = { diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index 1fc54ab22b6d..5c2195019723 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -1013,6 +1013,15 @@ #define RKISP1_CIF_MI_SP_CB_BASE_AD_INIT2 (RKISP1_CIF_MI_BASE + 0x00000140) #define RKISP1_CIF_MI_SP_CR_BASE_AD_INIT2 (RKISP1_CIF_MI_BASE + 0x00000144) #define RKISP1_CIF_MI_XTD_FORMAT_CTRL (RKISP1_CIF_MI_BASE + 0x00000148) +#define RKISP1_CIF_MI_MP_HANDSHAKE_0 (RKISP1_CIF_MI_BASE + 0x0000014C) +#define RKISP1_CIF_MI_MP_Y_LLENGTH (RKISP1_CIF_MI_BASE + 0x00000150) +#define RKISP1_CIF_MI_MP_Y_SLICE_OFFSET (RKISP1_CIF_MI_BASE + 0x00000154) +#define RKISP1_CIF_MI_MP_C_SLICE_OFFSET (RKISP1_CIF_MI_BASE + 0x00000158) +#define RKISP1_CIF_MI_OUTPUT_ALIGN_FORMAT (RKISP1_CIF_MI_BASE + 0x0000015C) +#define RKISP1_CIF_MI_MP_OUTPUT_FIFO_SIZE (RKISP1_CIF_MI_BASE + 0x00000160) +#define RKISP1_CIF_MI_MP_Y_PIC_WIDTH (RKISP1_CIF_MI_BASE + 0x00000164) +#define RKISP1_CIF_MI_MP_Y_PIC_HEIGHT (RKISP1_CIF_MI_BASE + 0x00000168) +#define RKISP1_CIF_MI_MP_Y_PIC_SIZE (RKISP1_CIF_MI_BASE + 0x0000016C) #define RKISP1_CIF_SMIA_BASE 0x00001A00 #define RKISP1_CIF_SMIA_CTRL (RKISP1_CIF_SMIA_BASE + 0x00000000) From patchwork Tue Jun 14 19:11:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881486 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37135C433EF for ; Tue, 14 Jun 2022 19:15:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357931AbiFNTPa (ORCPT ); Tue, 14 Jun 2022 15:15:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357903AbiFNTPY (ORCPT ); Tue, 14 Jun 2022 15:15:24 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0ADD167E1 for ; Tue, 14 Jun 2022 12:15:21 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B660B9E5; Tue, 14 Jun 2022 21:15:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234120; bh=Ol8ROY2bg9Y0528MwuNfAdTwhTIluFw4lunzEUd7gvI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mD7AmA4JhsreyI3ME50ReppWnzKv8dJtfx7OFLr4Q6TzXPtkV1HVWoLeuC6xZ06PD Lsei1h+C98rAUY8ySQeyFz/T+JiOKdpWzlkc7Q1ZiO+dmmokBz2LYuMJ69Y+wYi8yn Cnd8gj0WfNvGMv8fSj06Q8aUoTBfNunPneNkjWnM= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 52/55] media: rkisp1: Add i.MX8MP-specific registers for MI and resizer Date: Wed, 15 Jun 2022 04:11:24 +0900 Message-Id: <20220614191127.3420492-53-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add register definitions for resizer format conversion control and for the memory interface output that are specific to the ISP version in the i.MX8MP. Signed-off-by: Laurent Pinchart Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-regs.h | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index 5c2195019723..dd63ae13e603 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -171,6 +171,23 @@ /* RSZ_CROP_[XY]_DIR */ #define RKISP1_CIF_RSZ_CROP_XY_DIR(start, end) ((end) << 16 | (start) << 0) +/* RSZ_FORMAT_CONV_CTRL */ +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_INPUT_FORMAT_YCBCR_400 (0 << 0) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_INPUT_FORMAT_YCBCR_420 (1 << 0) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_INPUT_FORMAT_YCBCR_422 (2 << 0) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_INPUT_FORMAT_YCBCR_444 (3 << 0) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_OUTPUT_FORMAT_YCBCR_400 (0 << 2) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_OUTPUT_FORMAT_YCBCR_420 (1 << 2) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_OUTPUT_FORMAT_YCBCR_422 (2 << 2) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_OUTPUT_FORMAT_YCBCR_444 (3 << 2) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_CFG_Y_FULL BIT(5) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_CFG_CBCR_FULL BIT(6) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_CFG_422NOCOSITED BIT(7) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_DATA_WIDTH_10_BIT_ENABLE BIT(8) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_DATA_WIDTH_10_BIT_METHOD BIT(9) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_PACK_FORMAT_PLANAR (0 << 10) +#define RKISP1_CIF_RSZ_FORMAT_CONV_CTRL_RSZ_PACK_FORMAT_SEMI_PLANAR (1 << 10) + /* MI_IMSC - MI_MIS - MI_RIS - MI_ICR - MI_ISR */ #define RKISP1_CIF_MI_FRAME(stream) BIT((stream)->id) #define RKISP1_CIF_MI_MBLK_LINE BIT(2) @@ -212,6 +229,22 @@ #define RKISP1_CIF_MI_XTD_FMT_CTRL_MP_CB_CR_SWAP BIT(0) #define RKISP1_CIF_MI_XTD_FMT_CTRL_SP_CB_CR_SWAP BIT(1) #define RKISP1_CIF_MI_XTD_FMT_CTRL_DMA_CB_CR_SWAP BIT(2) +/* MI_OUTPUT_ALIGN_FORMAT */ +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_LSB_ALIGNMENT BIT(0) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_BYTES BIT(1) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_WORDS BIT(2) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_MP_BYTE_SWAP_DWORDS BIT(3) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_BYTES BIT(4) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_WORDS BIT(5) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_SP_BYTE_SWAP_DWORDS BIT(6) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_DMA_BYTE_SWAP_BYTES BIT(7) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_DMA_BYTE_SWAP_WORDS BIT(8) +#define RKISP1_CIF_OUTPUT_ALIGN_FORMAT_DMA_BYTE_SWAP_DWORDS BIT(9) +/* MI_MP_OUTPUT_FIFO_SIZE */ +#define RKISP1_CIF_MI_MP_OUTPUT_FIFO_SIZE_OUTPUT_FIFO_DEPTH_FULL (0 << 0) +#define RKISP1_CIF_MI_MP_OUTPUT_FIFO_SIZE_OUTPUT_FIFO_DEPTH_HALF (1 << 0) +#define RKISP1_CIF_MI_MP_OUTPUT_FIFO_SIZE_OUTPUT_FIFO_DEPTH_QUARTER (2 << 0) +#define RKISP1_CIF_MI_MP_OUTPUT_FIFO_SIZE_OUTPUT_FIFO_DEPTH_EIGHT (3 << 0) /* VI_CCL */ #define RKISP1_CIF_CCL_CIF_CLK_DIS BIT(2) From patchwork Tue Jun 14 19:11:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D6DCFCCA47B for ; Tue, 14 Jun 2022 19:15:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241360AbiFNTPd (ORCPT ); Tue, 14 Jun 2022 15:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357913AbiFNTP3 (ORCPT ); Tue, 14 Jun 2022 15:15:29 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D8AB28995 for ; Tue, 14 Jun 2022 12:15:26 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 376DB825; Tue, 14 Jun 2022 21:15:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234125; bh=4KxktOBIz+UgpeD0pYr7qe9l+jhMzIbCTkVwvpMlX0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r4KrlLcYemeWMfX3JG4vwOgsPU1NQtQxCg2A2e6XTJTHcdj+S9Gy5kzXV8B4WYzZA ZeuxWGw3b/S4IgexsLdVKgNtiusC6Os/p3pbEUpjg35uNL/+IK7B/4WtJcDDw45IWc /OXwAuiF8rV8bq+4Y+NtWRy2vxpt/8c6DTEXNapo= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 53/55] media: rkisp1: Shift DMA buffer addresses on i.MX8MP Date: Wed, 15 Jun 2022 04:11:25 +0900 Message-Id: <20220614191127.3420492-54-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On the ISP that is integrated in the i.MX8MP, the DMA base addresses are encoded in 34-bit. Shift them to the left by 2 bits so that they can be contained in 32 bits. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- .../platform/rockchip/rkisp1/rkisp1-capture.c | 19 +++++++++++-------- .../platform/rockchip/rkisp1/rkisp1-common.h | 1 + .../platform/rockchip/rkisp1/rkisp1-dev.c | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c index 35cec263c563..234b1f8488cb 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-capture.c @@ -624,6 +624,9 @@ static void rkisp1_dummy_buf_destroy(struct rkisp1_capture *cap) static void rkisp1_set_next_buf(struct rkisp1_capture *cap) { + u8 shift = cap->rkisp1->info->features & RKISP1_FEATURE_DMA_34BIT ? + 2 : 0; + cap->buf.curr = cap->buf.next; cap->buf.next = NULL; @@ -636,7 +639,7 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap) buff_addr = cap->buf.next->buff_addr; rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init, - buff_addr[RKISP1_PLANE_Y]); + buff_addr[RKISP1_PLANE_Y] >> shift); /* * In order to support grey format we capture * YUV422 planar format from the camera and @@ -645,17 +648,17 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap) if (cap->pix.cfg->fourcc == V4L2_PIX_FMT_GREY) { rkisp1_write(cap->rkisp1, cap->config->mi.cb_base_ad_init, - cap->buf.dummy.dma_addr); + cap->buf.dummy.dma_addr >> shift); rkisp1_write(cap->rkisp1, cap->config->mi.cr_base_ad_init, - cap->buf.dummy.dma_addr); + cap->buf.dummy.dma_addr >> shift); } else { rkisp1_write(cap->rkisp1, cap->config->mi.cb_base_ad_init, - buff_addr[RKISP1_PLANE_CB]); + buff_addr[RKISP1_PLANE_CB] >> shift); rkisp1_write(cap->rkisp1, cap->config->mi.cr_base_ad_init, - buff_addr[RKISP1_PLANE_CR]); + buff_addr[RKISP1_PLANE_CR] >> shift); } } else { /* @@ -663,11 +666,11 @@ static void rkisp1_set_next_buf(struct rkisp1_capture *cap) * throw data if there is no available buffer. */ rkisp1_write(cap->rkisp1, cap->config->mi.y_base_ad_init, - cap->buf.dummy.dma_addr); + cap->buf.dummy.dma_addr >> shift); rkisp1_write(cap->rkisp1, cap->config->mi.cb_base_ad_init, - cap->buf.dummy.dma_addr); + cap->buf.dummy.dma_addr >> shift); rkisp1_write(cap->rkisp1, cap->config->mi.cr_base_ad_init, - cap->buf.dummy.dma_addr); + cap->buf.dummy.dma_addr >> shift); } /* Set plane offsets */ diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h index 96657e55a5b0..0b834579d08c 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-common.h @@ -113,6 +113,7 @@ enum rkisp1_feature { RKISP1_FEATURE_DUAL_CROP = BIT(1), RKISP1_FEATURE_RSZ_CROP = BIT(2), RKISP1_FEATURE_MAIN_STRIDE = BIT(3), + RKISP1_FEATURE_DMA_34BIT = BIT(4), }; /* diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c index d68a805e8b6b..4c77aa2bc50a 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-dev.c @@ -506,7 +506,8 @@ static const struct rkisp1_info imx8mp_isp_info = { .isr_size = ARRAY_SIZE(imx8mp_isp_isrs), .isp_ver = IMX8MP_V10, .features = RKISP1_FEATURE_RSZ_CROP - | RKISP1_FEATURE_MAIN_STRIDE, + | RKISP1_FEATURE_MAIN_STRIDE + | RKISP1_FEATURE_DMA_34BIT, }; static const struct of_device_id rkisp1_of_match[] = { From patchwork Tue Jun 14 19:11:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881488 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AF70C433EF for ; Tue, 14 Jun 2022 19:15:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345029AbiFNTPe (ORCPT ); Tue, 14 Jun 2022 15:15:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357934AbiFNTPb (ORCPT ); Tue, 14 Jun 2022 15:15:31 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 755FE764E for ; Tue, 14 Jun 2022 12:15:30 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id AB80B9E5; Tue, 14 Jun 2022 21:15:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234129; bh=InAoFYTpv2IR4VgCX+XR+7V60n9zC0NurDrDkBszFNs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=To9UAGv4xtLOhYvgXaRz7LOmW0tGgm6kTycU3gdOZcGC2TAdkdGU5Q8608V1CX+xI nA4SderMP4y2DBrYW5HdmKImKeki2PSxsFfk0EJ+KK8+XBkVd0wvR66FIo0qZtOU8j 1cqmXh+2omD5UNRSRp58ZSVCpfFuE/uJkVpG/9NQ= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 54/55] media: rkisp1: Add register definitions for the test pattern generator Date: Wed, 15 Jun 2022 04:11:26 +0900 Message-Id: <20220614191127.3420492-55-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add register definitions and value macros for the test pattern generator block in the ISP. Signed-off-by: Paul Elder --- .../platform/rockchip/rkisp1/rkisp1-regs.h | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index dd63ae13e603..34f4fe09c88d 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -717,6 +717,27 @@ #define RKISP1_CIF_ISP_DPF_SPATIAL_COEFF_MAX 0x1F #define RKISP1_CIF_ISP_DPF_NLL_COEFF_N_MAX 0x3FF +/* TPG */ +#define RKISP1_CIF_ISP_TPG_CTRL_ENA BIT(0) +#define RKISP1_CIF_ISP_TPG_CTRL_IMG_3X3_COLOR_BLOCK (0 << 1) +#define RKISP1_CIF_ISP_TPG_CTRL_IMG_COLOR_BAR (1 << 1) +#define RKISP1_CIF_ISP_TPG_CTRL_IMG_GRAY_BAR (2 << 1) +#define RKISP1_CIF_ISP_TPG_CTRL_IMG_HIGHLIGHT_GRID (3 << 1) +#define RKISP1_CIF_ISP_TPG_CTRL_IMG_RAND (4 << 1) +#define RKISP1_CIF_ISP_TPG_CTRL_CFA_RGGB (0 << 4) +#define RKISP1_CIF_ISP_TPG_CTRL_CFA_GRBG (1 << 4) +#define RKISP1_CIF_ISP_TPG_CTRL_CFA_GBRB (2 << 4) +#define RKISP1_CIF_ISP_TPG_CTRL_CFA_BGGR (3 << 4) +#define RKISP1_CIF_ISP_TPG_CTRL_DEPTH_8 (0 << 6) +#define RKISP1_CIF_ISP_TPG_CTRL_DEPTH_10 (1 << 6) +#define RKISP1_CIF_ISP_TPG_CTRL_DEPTH_12 (2 << 6) +#define RKISP1_CIF_ISP_TPG_CTRL_DEF_SYNC BIT(8) +#define RKISP1_CIF_ISP_TPG_CTRL_MAX_SYNC BIT(9) +#define RKISP1_CIF_ISP_TPG_CTRL_SOL_1080P (0 << 10) +#define RKISP1_CIF_ISP_TPG_CTRL_SOL_720P (1 << 10) +#define RKISP1_CIF_ISP_TPG_CTRL_SOL_4K (2 << 10) +#define RKISP1_CIF_ISP_TPG_CTRL_SOL_USER_DEFINED (3 << 10) + /* =================================================================== */ /* CIF Registers */ /* =================================================================== */ @@ -912,6 +933,17 @@ #define RKISP1_CIF_ISP_SH_DELAY (RKISP1_CIF_ISP_SH_BASE + 0x00000008) #define RKISP1_CIF_ISP_SH_TIME (RKISP1_CIF_ISP_SH_BASE + 0x0000000C) +#define RKISP1_CIF_ISP_TPG_BASE 0x00000700 +#define RKISP1_CIF_ISP_TPG_CTRL (RKISP1_CIF_ISP_TPG_BASE + 0x00000000) +#define RKISP1_CIF_ISP_TPG_TOTAL_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000004) +#define RKISP1_CIF_ISP_TPG_ACT_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000008) +#define RKISP1_CIF_ISP_TPG_FP_IN (RKISP1_CIF_ISP_TPG_BASE + 0x0000000C) +#define RKISP1_CIF_ISP_TPG_BP_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000010) +#define RKISP1_CIF_ISP_TPG_W_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000014) +#define RKISP1_CIF_ISP_TPG_GAP_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000018) +#define RKISP1_CIF_ISP_TPG_GAP_STD_IN (RKISP1_CIF_ISP_TPG_BASE + 0x0000001C) +#define RKISP1_CIF_ISP_TPG_RANDOM_SEED_IN (RKISP1_CIF_ISP_TPG_BASE + 0x00000020) + #define RKISP1_CIF_C_PROC_BASE 0x00000800 #define RKISP1_CIF_C_PROC_CTRL (RKISP1_CIF_C_PROC_BASE + 0x00000000) #define RKISP1_CIF_C_PROC_CONTRAST (RKISP1_CIF_C_PROC_BASE + 0x00000004) From patchwork Tue Jun 14 19:11:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 12881489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D22BC43334 for ; Tue, 14 Jun 2022 19:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357903AbiFNTPg (ORCPT ); Tue, 14 Jun 2022 15:15:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357441AbiFNTPf (ORCPT ); Tue, 14 Jun 2022 15:15:35 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F17711C0F for ; Tue, 14 Jun 2022 12:15:34 -0700 (PDT) Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D1760825; Tue, 14 Jun 2022 21:15:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1655234133; bh=4FRx9cLD3vaUJ9hfLIwWu8iF+r754iIQFJ+3X5OaMOo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wjJ8SudfI+ziGWowJWw+jCqHSfQlcx7tHIy9klQcKh1zoQGlFb2arNiApN8/e3xmR 9emOqYeN33YBiGrDtTNtR6o0nlJ4cyGP3x7tO5QnN1/rEUMt4I6iVTW+Bea4jbu+FL HbRTeM7GG4Tiv7OIKXSUgkzGUNSAEW0h4bCcNXy4= From: Paul Elder To: linux-media@vger.kernel.org Cc: Paul Elder , dafna@fastmail.com, heiko@sntech.de, laurent.pinchart@ideasonboard.com, jeanmichel.hautbois@ideasonboard.com, jacopo@jmondi.org, djrscally@gmail.com, helen.koike@collabora.com, linux-rockchip@lists.infradead.org Subject: [PATCH 55/55] media: rkisp1: Fix RSZ_CTRL bits for i.MX8MP Date: Wed, 15 Jun 2022 04:11:27 +0900 Message-Id: <20220614191127.3420492-56-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220614191127.3420492-1-paul.elder@ideasonboard.com> References: <20220614191127.3420492-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The ISP that is integrated in the i.MX8MP uses different bits in the MRSZ_CTRL and SRSZ_CTRL registers for updating the configuration compared to the on in the RK3399. In addition, it adds a new bit for enabling crop. Add new definitions for these bits for i.MX8MP devices, and update where they are set. Signed-off-by: Paul Elder --- drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h | 4 ++++ .../media/platform/rockchip/rkisp1/rkisp1-resizer.c | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h index 34f4fe09c88d..24ad2ccec2a3 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-regs.h @@ -168,6 +168,10 @@ #define RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO BIT(9) #define RKISP1_CIF_RSZ_SCALER_FACTOR BIT(16) +#define RKISP1_CIF_RSZ_CTRL_CROP_ENABLE_IMX BIT(8) +#define RKISP1_CIF_RSZ_CTRL_CFG_UPD_IMX BIT(9) +#define RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO_IMX BIT(10) + /* RSZ_CROP_[XY]_DIR */ #define RKISP1_CIF_RSZ_CROP_XY_DIR(start, end) ((end) << 16 | (start) << 0) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c index 08bf3aa8088f..29a31b18a082 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-resizer.c @@ -209,9 +209,15 @@ static void rkisp1_rsz_update_shadow(struct rkisp1_resizer *rsz, u32 ctrl_cfg = rkisp1_rsz_read(rsz, RKISP1_CIF_RSZ_CTRL); if (when == RKISP1_SHADOW_REGS_ASYNC) - ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO; + if (rsz->rkisp1->info->isp_ver == IMX8MP_V10) + ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO_IMX; + else + ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD_AUTO; else - ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD; + if (rsz->rkisp1->info->isp_ver == IMX8MP_V10) + ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD_IMX; + else + ctrl_cfg |= RKISP1_CIF_RSZ_CTRL_CFG_UPD; rkisp1_rsz_write(rsz, RKISP1_CIF_RSZ_CTRL, ctrl_cfg); }