From patchwork Tue Jun 28 18:00:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Rodin X-Patchwork-Id: 585738 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CDD9DCCA47E for ; Tue, 28 Jun 2022 18:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233476AbiF1SBW (ORCPT ); Tue, 28 Jun 2022 14:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbiF1SBV (ORCPT ); Tue, 28 Jun 2022 14:01:21 -0400 Received: from hi1smtp01.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EDDF13CD3; Tue, 28 Jun 2022 11:01:20 -0700 (PDT) Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hi1smtp01.de.adit-jv.com (Postfix) with ESMTPS id 0C34F520C84; Tue, 28 Jun 2022 20:01:19 +0200 (CEST) Received: from vmlxhi-182.adit-jv.com (10.72.92.119) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 28 Jun 2022 20:01:18 +0200 From: Michael Rodin To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , , , CC: Michael Rodin , , , =?utf-8?q?Niklas_S=C3=B6derlund?= Subject: [PATCH 1/3] media: videobuf2: Add a transfer error event Date: Tue, 28 Jun 2022 20:00:20 +0200 Message-ID: <20220628180024.451258-2-mrodin@de.adit-jv.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628180024.451258-1-mrodin@de.adit-jv.com> References: <20220628180024.451258-1-mrodin@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.92.119] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Niklas Söderlund Add a new V4L2_EVENT_XFER_ERROR event to signal if an error happens during video transfer. The use-case that sparked this new event is to signal to the video device driver that an error has happen on the CSI-2 bus from the CSI-2 receiver subdevice. Signed-off-by: Niklas Söderlund [mrodin@de.adit-jv.com: adapted information what to do if this new event is received] Signed-off-by: Michael Rodin --- .../userspace-api/media/v4l/vidioc-dqevent.rst | 10 ++++++++++ .../userspace-api/media/videodev2.h.rst.exceptions | 1 + include/uapi/linux/videodev2.h | 1 + 3 files changed, 12 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst b/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst index 6eb40073c906..3cf0b4859784 100644 --- a/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst +++ b/Documentation/userspace-api/media/v4l/vidioc-dqevent.rst @@ -182,6 +182,16 @@ call. the regions changes. This event has a struct :c:type:`v4l2_event_motion_det` associated with it. + * - ``V4L2_EVENT_XFER_ERROR`` + - 7 + - This event is triggered when an transfer error is detected while + streaming. For example if an error is detected on a video bus in + the pipeline. If a driver receives this event from an upstream + subdevice, it has to forward the event to userspace. The streaming + application has to check if the transfer error is unrecoverable, + i.e. no new buffers can be dequeued from the kernel after the + expected time. If the error is unrecoverable, the streaming + application should restart streaming if it wants to continue. * - ``V4L2_EVENT_PRIVATE_START`` - 0x08000000 - Base event number for driver-private events. diff --git a/Documentation/userspace-api/media/videodev2.h.rst.exceptions b/Documentation/userspace-api/media/videodev2.h.rst.exceptions index 9cbb7a0c354a..25bde61a1519 100644 --- a/Documentation/userspace-api/media/videodev2.h.rst.exceptions +++ b/Documentation/userspace-api/media/videodev2.h.rst.exceptions @@ -500,6 +500,7 @@ replace define V4L2_EVENT_CTRL event-type replace define V4L2_EVENT_FRAME_SYNC event-type replace define V4L2_EVENT_SOURCE_CHANGE event-type replace define V4L2_EVENT_MOTION_DET event-type +replace define V4L2_EVENT_XFER_ERROR event-type replace define V4L2_EVENT_PRIVATE_START event-type replace define V4L2_EVENT_CTRL_CH_VALUE ctrl-changes-flags diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 5311ac4fde35..44db724d4541 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -2385,6 +2385,7 @@ struct v4l2_streamparm { #define V4L2_EVENT_FRAME_SYNC 4 #define V4L2_EVENT_SOURCE_CHANGE 5 #define V4L2_EVENT_MOTION_DET 6 +#define V4L2_EVENT_XFER_ERROR 7 #define V4L2_EVENT_PRIVATE_START 0x08000000 /* Payload for V4L2_EVENT_VSYNC */ From patchwork Tue Jun 28 18:00:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Rodin X-Patchwork-Id: 585737 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A298C433EF for ; Tue, 28 Jun 2022 18:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233837AbiF1SBe (ORCPT ); Tue, 28 Jun 2022 14:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233740AbiF1SBb (ORCPT ); Tue, 28 Jun 2022 14:01:31 -0400 Received: from hi1smtp01.de.adit-jv.com (smtp1.de.adit-jv.com [93.241.18.167]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5AB912AF1; Tue, 28 Jun 2022 11:01:30 -0700 (PDT) Received: from hi2exch02.adit-jv.com (hi2exch02.adit-jv.com [10.72.92.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hi1smtp01.de.adit-jv.com (Postfix) with ESMTPS id 9AA65520D1E; Tue, 28 Jun 2022 20:01:29 +0200 (CEST) Received: from vmlxhi-182.adit-jv.com (10.72.92.119) by hi2exch02.adit-jv.com (10.72.92.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Tue, 28 Jun 2022 20:01:29 +0200 From: Michael Rodin To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , , , CC: Michael Rodin , , Subject: [PATCH 3/3] media: rcar-vin: Allow userspace to subscribe to V4L2_EVENT_XFER_ERROR Date: Tue, 28 Jun 2022 20:00:22 +0200 Message-ID: <20220628180024.451258-4-mrodin@de.adit-jv.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220628180024.451258-1-mrodin@de.adit-jv.com> References: <20220628180024.451258-1-mrodin@de.adit-jv.com> MIME-Version: 1.0 X-Originating-IP: [10.72.92.119] X-ClientProxiedBy: hi2exch02.adit-jv.com (10.72.92.28) To hi2exch02.adit-jv.com (10.72.92.28) Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Userspace should be able to subscribe to V4L2_EVENT_XFER_ERROR in order to implement recovery from possible transfer errors. We can set the event queue size to 1, since only the timestamp of the latest transfer error is relevant to determine if a recovery is needed for the current streaming session. Signed-off-by: Michael Rodin --- drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c index 2e2aa9d746ee..8118c8d41a66 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c @@ -648,6 +648,8 @@ static int rvin_subscribe_event(struct v4l2_fh *fh, switch (sub->type) { case V4L2_EVENT_SOURCE_CHANGE: return v4l2_event_subscribe(fh, sub, 4, NULL); + case V4L2_EVENT_XFER_ERROR: + return v4l2_event_subscribe(fh, sub, 1, NULL); } return v4l2_ctrl_subscribe_event(fh, sub); }