Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1050058rdb; Mon, 4 Sep 2023 00:59:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzlU3Qk2fI41L3fjKroNiTqxBuvxazLmjtd4kRfEP8z65j16xo4UlyayC6/XuvNOZOcC/G X-Received: by 2002:a05:6870:797:b0:1c0:131b:2bb8 with SMTP id en23-20020a056870079700b001c0131b2bb8mr12684647oab.58.1693814385064; Mon, 04 Sep 2023 00:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693814385; cv=none; d=google.com; s=arc-20160816; b=u83lXbIB1BF/e3eXXxkl7yEpBGENS53iyFN5bMxNzT6LzpxNMH1Yl8+BSXN+tDFC3h w4I2/MtbsJ4RngGPmaR2trelUyIqUFg/CIRxcZau+VGfjyyu20tk3/kLiIC8jwN5fyWM cmXx7v8+YtGzsmjcnULmbNf42bM68f2BPm+vZuymoqC8KP0g4uLBHJt81uklCSMiDzF1 cTzhwhHQRw5dQEV4LkSHkKQONLUD0VasS9ZtE3F00OlshkSOp/Zs+j/c3DJ9oiE0heb3 4eEvzzYZ9rmGaBR9jBuNWyQPt71JvTobrqD4qLSKH17MwB06Z4KkJOlvThULXV7qMKbi AFdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=iacGK+V2SyI7u62NbaMeNw3cu42K5/MOVGdVpsBcQr4=; fh=UU71DBBjCJucxaBrDK66unW5KFHkl3JLjolnqhLE1Oc=; b=Asojwcx4Gc/DBUTDevqh0ByTRywACCxy/GALz1quLDpQsGGicxt7NAk4RubmkL/05L gtByAC8UJJxfS8uaLpV9mw5VOpA25p6eBZ7QwCb14OmA3SSmNLQnenMro1YbzjRGXY71 cRA5eKhdOxkj/cnn3c4ufs1IRXQpybNibtjvxAOclWt1zVz88MzJC4+L363SF8n8vNdz m8TkOss0Ro6VSldePo8CxkR7yjl9DXaxf941gf+Zq0HTVyxzwAF17ySQv39LYeAhNU+5 2poDZ9TwtOOgDJQjIzkmooSS6bht1ijr6CviVoaMwH5vSg+HfEkVQvZiqrXZvgMXq7ej 942A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eaQIkP+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k10-20020a6568ca000000b0056a670ebd6fsi7276217pgt.669.2023.09.04.00.59.32; Mon, 04 Sep 2023 00:59:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=eaQIkP+B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351879AbjIDEuC (ORCPT + 99 others); Mon, 4 Sep 2023 00:50:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242273AbjIDEuB (ORCPT ); Mon, 4 Sep 2023 00:50:01 -0400 Received: from mail-ua1-x92f.google.com (mail-ua1-x92f.google.com [IPv6:2607:f8b0:4864:20::92f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71A459B; Sun, 3 Sep 2023 21:49:58 -0700 (PDT) Received: by mail-ua1-x92f.google.com with SMTP id a1e0cc1a2514c-7a0254de2fdso298536241.1; Sun, 03 Sep 2023 21:49:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693802997; x=1694407797; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=iacGK+V2SyI7u62NbaMeNw3cu42K5/MOVGdVpsBcQr4=; b=eaQIkP+Bj8DKeudOBnZM4rWwWYme9HVcqV8qEzos/0FQKovM7u3fBGeAwS1zwyoa6s 4J4Why4DmfFKCK/Pn4OWw/J4Xm9anhOOcHNIQJQ3Axv5qjtP1qZV/4t/C16uYqPiuAR3 TPjXH9OzwLZouhleTBPWfKkaxny1gnRMVdhBf2V2s6wN+JdmKCRTOHIi+jM/WDBfHyQn hLFddyrkegHWOdHJqRdNrBIL6HareTfFPZclk0IDUnAiKGgGVP1bONzuFex0ntRuxFtR DwiHYWWQgWCGaE2nZ31Yq8mu6Tzgz5q94JFU8+ZIcd1CL+FW/3eog3XFazNcDqIH2fBm ikDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693802997; x=1694407797; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iacGK+V2SyI7u62NbaMeNw3cu42K5/MOVGdVpsBcQr4=; b=PR4m0m6cKA3Ao5sLqJLkptohwBEnVTa4bgeztk1rh447PkUhiyp+73Tum1Q5PU+v3u ITuPWXGezdVsYzVixwRgNM+cWQXIYuh26Vbit9V85z3TC4BQn+Qyj2I70sks6rtITONT dygdAd+8IUAwwWfxF+PYHuOQdrJt+l8Sb2tiFrW793XAXWZx67Bp5TEc61L3xGdMPhvT qalPz//GSiAfkJx1/V89QbRtQ+pVeNPV76YaAVkg5U3m4o9y/VXGXwCzp81+CuEv+LPU qwtRS+wSN8ukW03gaYCcZA1sjyZSVXBkOATH4f7ElcM+Pb0qooIFoL3P9+5xMQLNqwrw SoWg== X-Gm-Message-State: AOJu0Yz9h3BhsjqQV4kZDA0SweZsozjYI21IdPHoIuCOx4Eu0Rb5guHj dbEKm5AQ+R1jVc1M1WV4zklwK66KrnMdeGB8nlBreq89 X-Received: by 2002:a05:6102:3a56:b0:44e:b30a:c0da with SMTP id c22-20020a0561023a5600b0044eb30ac0damr7596914vsu.26.1693802997437; Sun, 03 Sep 2023 21:49:57 -0700 (PDT) MIME-Version: 1.0 References: <20230828091859.3889817-1-milkfafa@gmail.com> <20230828091859.3889817-8-milkfafa@gmail.com> <0c91f68d-d172-bd14-9115-b6977ad2d01f@xs4all.nl> In-Reply-To: From: Kun-Fa Lin Date: Mon, 4 Sep 2023 12:49:46 +0800 Message-ID: Subject: Re: [PATCH v14 7/7] media: nuvoton: Add driver for NPCM video capture and encode engine To: Hans Verkuil Cc: mchehab@kernel.org, avifishman70@gmail.com, tmaimon77@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, andrzej.p@collabora.com, devicetree@vger.kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, kwliu@nuvoton.com, kflin@nuvoton.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Hans, Thanks for the reply. > > When userspace dequeues the 1st buffer (video->list[0]), it needs to > > know the count of HEXTILE rectangles in the buffer, > > so after dequeuing the buffer it will call this control to get the > > rect count (video->rect[0]). And when a buffer is dequeued, > > npcm_video_buf_finish() will be called, in which the buffer index (in > > this example, buffer index = 0) will be stored to video->vb_index. > > Then when userspace calls this control, npcm_video_get_volatile_ctrl() > > will return the rect count of vb_index = 0. > > In this way, I think userspace is always reading the correct control's > > value even if userspace is slow. > > Does it make sense to you or is there anything I missed? > > Ah, I don't think I have ever seen anyone use buf_finish in that way! > > Very inventive, and perfectly legal. Actually a very nice idea! > > So, with that in mind there are still some things that need to change. > > First of all, you can drop the 'VOLATILE' flag from the control, instead > just call v4l2_ctrl_s_ctrl() from buf_finish() to update the control. > And in stop_streaming the control value should probably be set to 0. > > The use of volatile for a control is a last resort, and in this case it > is not volatile at all. > > Secondly, this behavior has to be documented: in buf_finish add a comment > along the lines of: "This callback is called when the buffer is dequeued, > so update this control with the number of rectangles." > > And where the control is defined, refer to buf_finish to explain where it > is set. > > Finally the user-facing documentation has to be updated (npcm-video.rst) > to explain this behavior. OK. Will drop the VOLATILE flag and update comment/document in the next version. Regards, Marvin