From patchwork Mon Jul 11 12:42:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12913733 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2F0AC43334 for ; Mon, 11 Jul 2022 12:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+GlBQHxBRk46YgUV6FtSlPdVWMd3jh0M9BEGxvrhWNA=; b=cf4+Y8v1+viTnX c4iH8qpzmHQde5fLkex+Pf/OH7yeSOVqhPrs0lYtvrXojD6IgIK5wBEDJrNyPJ95s4F8iMldJHBpK +8og3jdvUA5rNBmxkrV1r5v8OIwHLBqyFMc9n8WZAu11o1nhQBVdi/Aj1nsKyc8vbsdbPYucTuFlO EMzgNULxReEf3gV5LEB7gKqTE/LJDIVF1igr5B9UOkWaYCu+3x+a1Lv6qLnqhRYKtk/dH3i79f5sF EkP9GPQ2hrMcwjd80QyKXwjLT1Z3LqjZZ4E7N1G3XdlAUX7L8Gk9uGHnchQsdjMPxvrawmXEpNPAW uj3s/kXCxa/UEGrufYVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAszR-001gqW-K6; Mon, 11 Jul 2022 12:58:17 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oAslI-001YGY-MW for linux-rockchip@lists.infradead.org; Mon, 11 Jul 2022 12:43:43 +0000 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B0801248B; Mon, 11 Jul 2022 14:43:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1657543419; bh=YRIkRIHx5fjCmt6w+s89P+Fh2RDmgqmtBmqRwMeMf6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FY2gnc63t82ssdwhLHUyiymtEENXDenaqREEASZc0rOjKkBS0XpHM6D9lPIJ8zOHP /yH1XXMif8PiWN14zwgWVCKnFrj0fyQg4X+mqVoQZqMaQs/s3epG2ZGy3lhCNLUD7Z 5t2kCNXbRaRFieJX1bYb1vvP+p0/PqWcSboCo89k= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: linux-rockchip@lists.infradead.org, Dafna Hirschfeld , Heiko Stuebner , Helen Koike , Paul Elder Subject: [PATCH v3 32/46] media: rkisp1: isp: Move input configuration to rkisp1_config_isp() Date: Mon, 11 Jul 2022 15:42:34 +0300 Message-Id: <20220711124248.2683-33-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220711124248.2683-1-laurent.pinchart@ideasonboard.com> References: <20220711124248.2683-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220711_054341_072629_C6E132CD X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: Paul Elder Reviewed-by: Dafna Hirschfeld --- Changes since v1: - Print the value of unsupported bus width - Remove unneeded curly braces --- .../platform/rockchip/rkisp1/rkisp1-isp.c | 66 +++++++------------ 1 file changed, 24 insertions(+), 42 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c index 9b32ae585de8..85c1995bb5c2 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,22 @@ 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 %u\n", + sink_fmt->bus_width); + return -EINVAL; + } } if (mbus_type == V4L2_MBUS_PARALLEL) { @@ -201,7 +217,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 +254,19 @@ 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) { + 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;