[{"id":31816,"web_url":"https://patchwork.libcamera.org/comment/31816/","msgid":"<172937611323.2485972.745333590183942620@ping.linuxembedded.co.uk>","date":"2024-10-19T22:15:13","subject":"Re: [PATCH] libcamera: v4l2: Support changing poller thread for\n\tV4L2VideoDevice","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Harvey Yang (2024-10-16 14:46:33)\n> From: Han-Lin Chen <hanlinchen@chromium.org>\n> \n\nCould we get something more detailed in here?\n\nWhat use case does this support ? Are there any restrictions on how/when\nyou move the thread? What's the default thread used to poll - and why\nisn't this sufficient?\n\nThis seems like the sort of thing that deserves a test in\ntest/v4l2_videodevice.cpp to make sure the devices still operate after\nthe poll thread has been moved ?\n\n\n> Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> Co-developed-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> ---\n>  include/libcamera/internal/v4l2_videodevice.h |  2 ++\n>  src/libcamera/v4l2_videodevice.cpp            | 13 +++++++++++++\n>  2 files changed, 15 insertions(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> index f021c2a01..f8d017b01 100644\n> --- a/include/libcamera/internal/v4l2_videodevice.h\n> +++ b/include/libcamera/internal/v4l2_videodevice.h\n> @@ -232,6 +232,8 @@ public:\n>  \n>         V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n>  \n> +       void changePollerThread(Thread *thread);\n> +\n>  protected:\n>         std::string logPrefix() const override;\n>  \n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 14eba0561..fc6b88ec1 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -2120,6 +2120,19 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n>         return {};\n>  }\n>  \n> +/**\n> + * \\brief Move the event notifier and timer to \\a thread\n> + * \\param[in] thread The thread to poll on\n> + */\n> +void V4L2VideoDevice::changePollerThread(Thread *thread)\n> +{\n> +       if (!isOpen())\n> +               return;\n> +\n> +       fdBufferNotifier_->moveToThread(thread);\n> +       watchdog_.moveToThread(thread);\n> +}\n> +\n>  /**\n>   * \\class V4L2M2MDevice\n>   * \\brief Memory-to-Memory video device\n> -- \n> 2.47.0.rc1.288.g06298d1525-goog\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 8F74CBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 19 Oct 2024 22:15:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9BC8C6538D;\n\tSun, 20 Oct 2024 00:15:16 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AC2F265382\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 20 Oct 2024 00:15:15 +0200 (CEST)","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 C5B36526;\n\tSun, 20 Oct 2024 00:13:30 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZL5Ch5WR\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1729376010;\n\tbh=JxMIEKpzkGWPZtS0vjb7LmFaBecFWTauVvr/2CHrC/g=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ZL5Ch5WR2pZ0No1R40KEUWr8ywE6Hm2Zvki4vk3AbYUK+YoUCOvXb8y0vZltrFG0Z\n\tKI7xa6XecCr3GNKquXeiRIeP9Yjxdgo+wribsZ98upAtvVbYcrgXH3Zg+gL1yYa0SE\n\tFEAQK/uSevBkl9gAxaTxicgkIYReW9hV0TKUzYUk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20241016134640.3648224-1-chenghaoyang@chromium.org>","References":"<20241016134640.3648224-1-chenghaoyang@chromium.org>","Subject":"Re: [PATCH] libcamera: v4l2: Support changing poller thread for\n\tV4L2VideoDevice","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Han-Lin Chen <hanlinchen@chromium.org>,\n\tYudhistira Erlandinata <yerlandinata@chromium.org>,\n\tHarvey Yang <chenghaoyang@chromium.org>","To":"Harvey Yang <chenghaoyang@chromium.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Sat, 19 Oct 2024 23:15:13 +0100","Message-ID":"<172937611323.2485972.745333590183942620@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>"}},{"id":31880,"web_url":"https://patchwork.libcamera.org/comment/31880/","msgid":"<CAEB1ahuxiz=Uk+dPtqricAf95OEAb_1EmioLBHJtwcQhsYL9gg@mail.gmail.com>","date":"2024-10-22T12:33:19","subject":"Re: [PATCH] libcamera: v4l2: Support changing poller thread for\n\tV4L2VideoDevice","submitter":{"id":117,"url":"https://patchwork.libcamera.org/api/people/117/","name":"Cheng-Hao Yang","email":"chenghaoyang@chromium.org"},"content":"Hi Kieran,\n\nOn Sun, Oct 20, 2024 at 6:15 AM Kieran Bingham\n<kieran.bingham@ideasonboard.com> wrote:\n>\n> Quoting Harvey Yang (2024-10-16 14:46:33)\n> > From: Han-Lin Chen <hanlinchen@chromium.org>\n> >\n>\n> Could we get something more detailed in here?\n>\n> What use case does this support ? Are there any restrictions on how/when\n> you move the thread? What's the default thread used to poll - and why\n> isn't this sufficient?\n\nTrue, mtkisp7 actually doesn't need to change the owner thread of\nV4L2VideoDevice. [1]\n\nLet's ignore this patch.\n\nBR,\nHarvey\n\n[1]: https://chromium-review.googlesource.com/c/chromiumos/third_party/libcamera/+/5953203\n\n\n>\n> This seems like the sort of thing that deserves a test in\n> test/v4l2_videodevice.cpp to make sure the devices still operate after\n> the poll thread has been moved ?\n>\n>\n> > Signed-off-by: Han-Lin Chen <hanlinchen@chromium.org>\n> > Co-developed-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> > Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org>\n> > Co-developed-by: Harvey Yang <chenghaoyang@chromium.org>\n> > Signed-off-by: Harvey Yang <chenghaoyang@chromium.org>\n> > ---\n> >  include/libcamera/internal/v4l2_videodevice.h |  2 ++\n> >  src/libcamera/v4l2_videodevice.cpp            | 13 +++++++++++++\n> >  2 files changed, 15 insertions(+)\n> >\n> > diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\n> > index f021c2a01..f8d017b01 100644\n> > --- a/include/libcamera/internal/v4l2_videodevice.h\n> > +++ b/include/libcamera/internal/v4l2_videodevice.h\n> > @@ -232,6 +232,8 @@ public:\n> >\n> >         V4L2PixelFormat toV4L2PixelFormat(const PixelFormat &pixelFormat) const;\n> >\n> > +       void changePollerThread(Thread *thread);\n> > +\n> >  protected:\n> >         std::string logPrefix() const override;\n> >\n> > diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> > index 14eba0561..fc6b88ec1 100644\n> > --- a/src/libcamera/v4l2_videodevice.cpp\n> > +++ b/src/libcamera/v4l2_videodevice.cpp\n> > @@ -2120,6 +2120,19 @@ V4L2PixelFormat V4L2VideoDevice::toV4L2PixelFormat(const PixelFormat &pixelForma\n> >         return {};\n> >  }\n> >\n> > +/**\n> > + * \\brief Move the event notifier and timer to \\a thread\n> > + * \\param[in] thread The thread to poll on\n> > + */\n> > +void V4L2VideoDevice::changePollerThread(Thread *thread)\n> > +{\n> > +       if (!isOpen())\n> > +               return;\n> > +\n> > +       fdBufferNotifier_->moveToThread(thread);\n> > +       watchdog_.moveToThread(thread);\n> > +}\n> > +\n> >  /**\n> >   * \\class V4L2M2MDevice\n> >   * \\brief Memory-to-Memory video device\n> > --\n> > 2.47.0.rc1.288.g06298d1525-goog\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 F2ECDC3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Oct 2024 12:33:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC88C65391;\n\tTue, 22 Oct 2024 14:33:33 +0200 (CEST)","from mail-lj1-x234.google.com (mail-lj1-x234.google.com\n\t[IPv6:2a00:1450:4864:20::234])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 636DF6053E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Oct 2024 14:33:31 +0200 (CEST)","by mail-lj1-x234.google.com with SMTP id\n\t38308e7fff4ca-2fb3c3d5513so60896981fa.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Oct 2024 05:33:31 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"S8dhp4ay\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=chromium.org; s=google; t=1729600410; x=1730205210;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=y8Nbp035RBgusku9tTRu15YwyIv50emb235OdUIPOr4=;\n\tb=S8dhp4ayVShLIkwdWdp7mmHuu12KvOqz9dD1QufXeaSQu0ng4HoyP25LI4SGiUTlgx\n\tQG0od7Ksf9YOPzI4xZPmiiREwCWQIRhT70WHidiUGeHtuCKbH32j5MPl1vq7b7PO8j6s\n\tF13JMDnMD/mB6bO6buxlqJyBPmSWh3c72pANI=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1729600410; x=1730205210;\n\th=content-transfer-encoding:cc:to:subject:message-id:date:from\n\t:in-reply-to:references:mime-version:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=y8Nbp035RBgusku9tTRu15YwyIv50emb235OdUIPOr4=;\n\tb=XUbUKkpJC2pWlbQjg5B6mM81uwA7K6QelpxgHWi95r4ozvFmDdwZqrW1+xHGEeo6RA\n\t64iO0UpEeYojP1mbJTMikfs+PRu/FzIcByvSdyy8xkrJlIG9OXK+T8lUGSnIqHeRQBsA\n\tzEsNXKVgqeyyatyDaFS/hL2iUHxQd0Fb8uABCnnTB3r1gd42rsV7RabOlXcbsZTpV+RY\n\t4jiDNoR6JzDgI6GxawmqQzKTxdMw932PzRIYX2YeleQHAHoRicaA6QTJOGYMQ5c2MdHR\n\tYOcIOwvysrsel8X2Zc0ux/E7lnTuhV+eDBQb8qRXqRJyeEw6BywFdxRFNgHHKYaiVunz\n\tttJw==","X-Gm-Message-State":"AOJu0Yx8N86A3ZTD4IH+20voJu7hxOCcbzSnzZFLB/ZPM4syNdSxfNFB\n\thfieLX+dms8fh9KlcarQ1bXiD/XpCKE2M3tFSgZzag3ujMUctXJglYF7eN8vc+xNBVHIRZQxtj/\n\tirp6Wdclcnc89+b354SktoMA9mJSMFWqGVJpn","X-Google-Smtp-Source":"AGHT+IHURHRTs/k1aPFgwV6sEx3ajX+86/OKSXt0nztKq9C54+b25NojD4oyyoHl9uOWIN8LuChNsRsQEmaJcuitSDs=","X-Received":"by 2002:a2e:f11:0:b0:2fb:5b23:edba with SMTP id\n\t38308e7fff4ca-2fc93314f55mr10381051fa.23.1729600410525;\n\tTue, 22 Oct 2024 05:33:30 -0700 (PDT)","MIME-Version":"1.0","References":"<20241016134640.3648224-1-chenghaoyang@chromium.org>\n\t<172937611323.2485972.745333590183942620@ping.linuxembedded.co.uk>","In-Reply-To":"<172937611323.2485972.745333590183942620@ping.linuxembedded.co.uk>","From":"Cheng-Hao Yang <chenghaoyang@chromium.org>","Date":"Tue, 22 Oct 2024 20:33:19 +0800","Message-ID":"<CAEB1ahuxiz=Uk+dPtqricAf95OEAb_1EmioLBHJtwcQhsYL9gg@mail.gmail.com>","Subject":"Re: [PATCH] libcamera: v4l2: Support changing poller thread for\n\tV4L2VideoDevice","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, \n\tHan-Lin Chen <hanlinchen@chromium.org>, \n\tYudhistira Erlandinata <yerlandinata@chromium.org>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","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>"}}]