[{"id":37021,"web_url":"https://patchwork.libcamera.org/comment/37021/","msgid":"<176398190111.567526.10252878249087076822@ping.linuxembedded.co.uk>","date":"2025-11-24T10:58:21","subject":"Re: [[PATCH v1]] media: rkisp1: Fix filter mode register\n\tconfiguration to handle enable and DNR bits separately","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Rui,\n\n\nThis patch should be sent to the linux-media maililng list.\n\nPlease read\n https://www.kernel.org/doc/html/latest/process/submitting-patches.html\n\nQuoting Rui Wang (2025-11-23 20:32:28)\n\n> The current implementation in rkisp1_flt_config()\n> treats the arg->mode field as a boolean for enabling DNR mode,\n> which doesn't properly separate the filter\n> enable bit from the DNR mode bit\n> in the RKISP1_CIF_ISP_FILT_MODE register.\n\nThis looks like it could be wrapped to at least 72 characters per line\nfor commit messages please:\n\nThe current implementation in rkisp1_flt_config() treats the arg->mode\nfield as a boolean for enabling DNR mode, which doesn't properly\nseparate the filter enable bit from the DNR mode bit in the\nRKISP1_CIF_ISP_FILT_MODE register.\n\n> Update the register write to explicitly check individual bits:\n> \n> Bit 0 of arg->mode controls the filter enable (RKISP1_CIF_ISP_FLT_ENA)\n> Bit 1 of arg->mode controls the DNR mode (RKISP1_CIF_ISP_FLT_MODE_DNR)\n> This ensures that the filter enable and DNR mode\n> can be configured independently through the mode field,\n> \n> Signed-off-by: Rui Wang <rui.wang@ideasonboard.com>\n> ---\n>  drivers/media/platform/rockchip/rkisp1/rkisp1-params.c | 3 ++-\n>  1 file changed, 2 insertions(+), 1 deletion(-)\n> \n> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c\n> index b28f4140c8a3..077269848058 100644\n> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c\n> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-params.c\n> @@ -408,7 +408,8 @@ static void rkisp1_flt_config(struct rkisp1_params *params,\n>                      arg->lum_weight);\n>  \n>         rkisp1_write(params->rkisp1, RKISP1_CIF_ISP_FILT_MODE,\n> -                    (arg->mode ? RKISP1_CIF_ISP_FLT_MODE_DNR : 0) |\n> +                    ((arg->mode & (1 << 1)) ? RKISP1_CIF_ISP_FLT_MODE_DNR : 0) |\n> +                    ((arg->mode & (1 << 0)) ? RKISP1_CIF_ISP_FLT_ENA : 0) |\n\nIn the Linux kernel we have a macro called BIT() for tis, so we should\nreplace 1<<1 and 1<<0 with BIT(1) and BIT(0).\n\nBut the usual practise is to give the bits names as well to improve\nreadbility so it should be more like\n\n#define RKISP1_FILT_MODE_ENABLE\tBIT(0)\n#define RKISP1_FILT_MODE_DNR\tBIT(1)\n\nsomewhere appropriate to then use here.\n\nI wonder if this register value should be split out from the\nrkisp1_write() call too if it would make it more readable... I think\nit's getting long and complex...\n\n--\nRegards\n\nKieran\n\n>                      RKISP1_CIF_ISP_FLT_CHROMA_V_MODE(arg->chr_v_mode) |\n>                      RKISP1_CIF_ISP_FLT_CHROMA_H_MODE(arg->chr_h_mode) |\n>                      RKISP1_CIF_ISP_FLT_GREEN_STAGE1(arg->grn_stage1));\n> -- \n> 2.43.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 832DFC32EF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 24 Nov 2025 10:58:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9784960A80;\n\tMon, 24 Nov 2025 11:58:25 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C53DF606D5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 24 Nov 2025 11:58:23 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AB56189A;\n\tMon, 24 Nov 2025 11:56:15 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TOBYdFD5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1763981775;\n\tbh=JY+nmHjM5D+WJRzNZnTNTLExL1qRmHt1g2PHQ4pRWco=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=TOBYdFD5wxE9HAIB8QTyyvKjyfT5OKlXBN+HlgYHKGixNcaj5L+xVkhFpAFoW+aAo\n\tNYuB31ypccr6OFrOfdvftEiqpq2GffaVGtYoEcd2SDFc2WionOrd2CilrAVqLuqswY\n\trlakbLeW44ovYzeKpB8Pu5PIY4coyqoKcn0Hug1s=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251123203228.3462026-1-rui.wang@ideasonboard.com>","References":"<20251123203228.3462026-1-rui.wang@ideasonboard.com>","Subject":"Re: [[PATCH v1]] media: rkisp1: Fix filter mode register\n\tconfiguration to handle enable and DNR bits separately","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Rui Wang <rui.wang@ideasonboard.com>","To":"Rui Wang <rui.wang@ideasonboard.com>, libcamera-devel@lists.libcamera.org","Date":"Mon, 24 Nov 2025 10:58:21 +0000","Message-ID":"<176398190111.567526.10252878249087076822@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]