From patchwork Sat Dec 16 13:34:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 13495571 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 AD59FC46CA2 for ; Sat, 16 Dec 2023 13:35:02 +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=I/67j1eCuRGj1YVZMq7etJkdWyqjAVrBGe72ngFcWmY=; b=G6N75cGS1vqkGa 0W00vJaAG8gM5Ms2x9Hqk0uV56qITfcXCZU0Xe3uDFAgNYzu6h8+FBrTQRS8maYh9apPaNgz2F6LI LH+cqHkHeVf371BB6WUqiFYbVsGNpC0pQ+sVL4h1afvUdgrpuOyiS0lzVmCpeduM6w1mpj39T3adN GYrNPS/dxmBMw8ztpgCo4y460X5RtS59qAjEHxOHQ1RW9sEp5NcJOCycM43lXuOvY169Rfmd36NPN M6LgFGAJvSUcVZG1dxtPBndpKmhyEFbiCp6tyf/+AOjJTJ538lbLFxZ9/E2I4JQfHeMq0qtW2xH0J 7dSNkRq9NV514vUKwO3g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rEUoQ-0067S4-2Z; Sat, 16 Dec 2023 13:34:38 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rEUoJ-0067PT-0L for linux-arm-kernel@lists.infradead.org; Sat, 16 Dec 2023 13:34:32 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40c6736d10fso19748595e9.1 for ; Sat, 16 Dec 2023 05:34:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702733669; x=1703338469; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kYkcCRj2aDyNKfpsjAbeqa50uCwjkKY1rnjchlV8BI4=; b=c/sUN8uZXH/GOZ4EgWOrESuu/wKjtZB42C0MNISWT5BILrZ1ULuRl+VeO9f6vP1Md5 aVARhQ2jncL4rV8Bw8HVCd4m9hwTPyBph1OQuZe+4+iXE3JOMBLFbUSc+YUUYYDcQ8LT FhkfzxSUy86+FTDiWyvqKfOd6k186oNaPOeRukAUuU6WYNBPjwHMZCvnZZNAJbswmEYX /gQaGsrBD/OGEXuq3e8z1hUrt5nFEjWpVyCMZScW+LdgE5ShiOZ9ROugbtnoFkKBWrqL ooI4MVpGbUweWyPfFuZ/Xda7Zwtsp8eflFTrk9DKz3+Q3VhZQo7WwxxNWrKP9s98l8Wb 3A/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702733669; x=1703338469; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kYkcCRj2aDyNKfpsjAbeqa50uCwjkKY1rnjchlV8BI4=; b=am4pU9U96P3w0JRMykpj9zi9XHOXnjMzHUABlBPsYSCqyBV8UxBebrKo47wMFE7zYa alP+sZJOqdYo+k49ZxtZs4WPfwkJtO1BdPlOHdSi5vXcYE3SHYo/mIY2ecxhmQtkf4vV Njltvh3Y801xgsqF+SMD84td9dIJwZgKdkqc580tku48jitsb/gZlG33w3oOJe1LWBZH putI/P+PC4tPMwWyEKqf+uWsyDjQyeFxOYBHOzceFq/p6IjDiYuoD3JRVYDQSEMwbhkj ysvll0cjzTyjU0BZmS87YpcKp+Smhws2SAlnQD9l4JiqT7iKNdpxF14cx2/uo+18p7rF n20Q== X-Gm-Message-State: AOJu0Yw9LW78tpboN4SN3BtE2QX7QVyziK8yCcAkEK0JSlINEpJU4HWA plP9Ud1+TzzWIpLnU6WcYfI= X-Google-Smtp-Source: AGHT+IG911xAhwr40S4ErD5qmHRV0PNM/nWBQsYJcAqJSi58EQSzDvjWDUWnf87Wfg5I7RBAyT+tHw== X-Received: by 2002:a05:600c:3ca2:b0:40c:5112:a0b with SMTP id bg34-20020a05600c3ca200b0040c51120a0bmr4922033wmb.45.1702733668688; Sat, 16 Dec 2023 05:34:28 -0800 (PST) Received: from localhost.localdomain (82-149-12-148.dynamic.telemach.net. [82.149.12.148]) by smtp.gmail.com with ESMTPSA id l16-20020a170906415000b00a232bf6045csm423629ejk.63.2023.12.16.05.34.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 Dec 2023 05:34:28 -0800 (PST) From: Jernej Skrabec To: wens@csie.org, samuel@sholland.org Cc: mchehab@kernel.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Jernej Skrabec Subject: [PATCH 1/3] media: sun8i-di: Fix coefficient writes Date: Sat, 16 Dec 2023 14:34:20 +0100 Message-ID: <20231216133422.2534674-2-jernej.skrabec@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231216133422.2534674-1-jernej.skrabec@gmail.com> References: <20231216133422.2534674-1-jernej.skrabec@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231216_053431_142054_FF4EC21C X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently coefficients are applied only once, since they don't change. However, this is done before enable bit is set and thus it doesn't get applied properly. Fix that by applying coefficients after enable bit is set. While this means that it will be done evey time, it doesn't bring much time penalty. Fixes: a4260ea49547 ("media: sun4i: Add H3 deinterlace driver") Signed-off-by: Jernej Skrabec --- .../media/platform/sunxi/sun8i-di/sun8i-di.c | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c index 90ab1d77b6a5..34e099939284 100644 --- a/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c +++ b/drivers/media/platform/sunxi/sun8i-di/sun8i-di.c @@ -66,6 +66,7 @@ static void deinterlace_device_run(void *priv) struct vb2_v4l2_buffer *src, *dst; unsigned int hstep, vstep; dma_addr_t addr; + int i; src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -160,6 +161,26 @@ static void deinterlace_device_run(void *priv) deinterlace_write(dev, DEINTERLACE_CH1_HORZ_FACT, hstep); deinterlace_write(dev, DEINTERLACE_CH1_VERT_FACT, vstep); + /* neutral filter coefficients */ + deinterlace_set_bits(dev, DEINTERLACE_FRM_CTRL, + DEINTERLACE_FRM_CTRL_COEF_ACCESS); + readl_poll_timeout(dev->base + DEINTERLACE_STATUS, val, + val & DEINTERLACE_STATUS_COEF_STATUS, 2, 40); + + for (i = 0; i < 32; i++) { + deinterlace_write(dev, DEINTERLACE_CH0_HORZ_COEF0 + i * 4, + DEINTERLACE_IDENTITY_COEF); + deinterlace_write(dev, DEINTERLACE_CH0_VERT_COEF + i * 4, + DEINTERLACE_IDENTITY_COEF); + deinterlace_write(dev, DEINTERLACE_CH1_HORZ_COEF0 + i * 4, + DEINTERLACE_IDENTITY_COEF); + deinterlace_write(dev, DEINTERLACE_CH1_VERT_COEF + i * 4, + DEINTERLACE_IDENTITY_COEF); + } + + deinterlace_clr_set_bits(dev, DEINTERLACE_FRM_CTRL, + DEINTERLACE_FRM_CTRL_COEF_ACCESS, 0); + deinterlace_clr_set_bits(dev, DEINTERLACE_FIELD_CTRL, DEINTERLACE_FIELD_CTRL_FIELD_CNT_MSK, DEINTERLACE_FIELD_CTRL_FIELD_CNT(ctx->field)); @@ -248,7 +269,6 @@ static irqreturn_t deinterlace_irq(int irq, void *data) static void deinterlace_init(struct deinterlace_dev *dev) { u32 val; - int i; deinterlace_write(dev, DEINTERLACE_BYPASS, DEINTERLACE_BYPASS_CSC); @@ -285,26 +305,6 @@ static void deinterlace_init(struct deinterlace_dev *dev) deinterlace_clr_set_bits(dev, DEINTERLACE_CHROMA_DIFF, DEINTERLACE_CHROMA_DIFF_TH_MSK, DEINTERLACE_CHROMA_DIFF_TH(5)); - - /* neutral filter coefficients */ - deinterlace_set_bits(dev, DEINTERLACE_FRM_CTRL, - DEINTERLACE_FRM_CTRL_COEF_ACCESS); - readl_poll_timeout(dev->base + DEINTERLACE_STATUS, val, - val & DEINTERLACE_STATUS_COEF_STATUS, 2, 40); - - for (i = 0; i < 32; i++) { - deinterlace_write(dev, DEINTERLACE_CH0_HORZ_COEF0 + i * 4, - DEINTERLACE_IDENTITY_COEF); - deinterlace_write(dev, DEINTERLACE_CH0_VERT_COEF + i * 4, - DEINTERLACE_IDENTITY_COEF); - deinterlace_write(dev, DEINTERLACE_CH1_HORZ_COEF0 + i * 4, - DEINTERLACE_IDENTITY_COEF); - deinterlace_write(dev, DEINTERLACE_CH1_VERT_COEF + i * 4, - DEINTERLACE_IDENTITY_COEF); - } - - deinterlace_clr_set_bits(dev, DEINTERLACE_FRM_CTRL, - DEINTERLACE_FRM_CTRL_COEF_ACCESS, 0); } static inline struct deinterlace_ctx *deinterlace_file2ctx(struct file *file)