From patchwork Wed Jun 7 02:11:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 13269915 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 CF64FC7EE29 for ; Wed, 7 Jun 2023 02:12:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240711AbjFGCMS (ORCPT ); Tue, 6 Jun 2023 22:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240679AbjFGCMR (ORCPT ); Tue, 6 Jun 2023 22:12:17 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A873819BD for ; Tue, 6 Jun 2023 19:12:14 -0700 (PDT) Received: from db550.. (node-1w7jr9st5p2esmclet71ntnwp.ipv6.telus.net [IPv6:2001:569:beb1:1500:6f9d:3a5c:4d25:e949]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2DEE06606EF4; Wed, 7 Jun 2023 03:12:11 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686103933; bh=vCBNCkojbiic9vYkJ7j+sSyAE/A+/WePmQbM1GaHCpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DBVJKKVemm4Q3MKEkC8SVr2CsCPvSTbf2Om9E2XM5tXfol9q8e3lKEgjNIEuaHAql AFVOEZCZEIEpT/OE9oUNJkO+NagDbTFCrPLtBNbTOJBYvnpw13z4aDm7bJhL0+JfQF hegxfbWcMZuT7kdcNlw3fPx1KbOkRgd1GK9OB2GtXaC3tnh+4+tuUu6DohHiA8SpNt zNPsFraZNkMCqrjki1jgYsHVkM350Fh53LiG1oG0R2XROjd6J7HxI50vGN3n72KXqX 0JJEP5QoI/vFCFnLiuoNf/rSu6dDIkE+eCFaw3qNHVNEiVnZDM1NBr8ooS+NzA++nV s+m4u5huL2gxQ== From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, Deborah Brouwer Subject: [PATCH 1/4] v4l2-tracer: add VIDIOC_ENUM_FRAMESIZES Date: Tue, 6 Jun 2023 19:11:55 -0700 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add tracing and retracing for VIDIOC_ENUM_FRAMESIZES ioctl. Signed-off-by: Deborah Brouwer --- utils/v4l2-tracer/libv4l2tracer.cpp | 1 + utils/v4l2-tracer/retrace.cpp | 15 +++++++++++++++ utils/v4l2-tracer/trace.cpp | 3 +++ utils/v4l2-tracer/v4l2-tracer-gen.pl | 11 ++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp index 63c1812e..6edec7f4 100644 --- a/utils/v4l2-tracer/libv4l2tracer.cpp +++ b/utils/v4l2-tracer/libv4l2tracer.cpp @@ -40,6 +40,7 @@ const std::list ioctls = { VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS, + VIDIOC_ENUM_FRAMESIZES, VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD, VIDIOC_CREATE_BUFS, diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp index 51c8ad37..7003ca70 100644 --- a/utils/v4l2-tracer/retrace.cpp +++ b/utils/v4l2-tracer/retrace.cpp @@ -966,6 +966,18 @@ void retrace_vidioc_s_ext_ctrls(int fd_retrace, json_object *ioctl_args) } } +void retrace_vidioc_enum_framesizes(int fd_retrace, json_object *ioctl_args) +{ + struct v4l2_frmsizeenum *ptr = retrace_v4l2_frmsizeenum_gen(ioctl_args); + + ioctl(fd_retrace, VIDIOC_ENUM_FRAMESIZES, ptr); + + if (is_verbose() || (errno != 0)) + perror("VIDIOC_ENUM_FRAMESIZES"); + + free(ptr); +} + void retrace_vidioc_try_encoder_cmd(int fd_retrace, json_object *ioctl_args) { struct v4l2_encoder_cmd *ptr = retrace_v4l2_encoder_cmd_gen(ioctl_args); @@ -1272,6 +1284,9 @@ void retrace_ioctl(json_object *syscall_obj) case VIDIOC_S_EXT_CTRLS: retrace_vidioc_s_ext_ctrls(fd_retrace, ioctl_args_user); break; + case VIDIOC_ENUM_FRAMESIZES: + retrace_vidioc_enum_framesizes(fd_retrace, ioctl_args_user); + break; case VIDIOC_TRY_ENCODER_CMD: retrace_vidioc_try_encoder_cmd(fd_retrace, ioctl_args_user); break; diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp index acf4cc98..78db2554 100644 --- a/utils/v4l2-tracer/trace.cpp +++ b/utils/v4l2-tracer/trace.cpp @@ -589,6 +589,9 @@ json_object *trace_ioctl_args(unsigned long cmd, void *arg) case VIDIOC_S_EXT_CTRLS: trace_v4l2_ext_controls(arg, ioctl_args); break; + case VIDIOC_ENUM_FRAMESIZES: + trace_v4l2_frmsizeenum_gen(arg, ioctl_args); + break; case VIDIOC_TRY_ENCODER_CMD: case VIDIOC_ENCODER_CMD: trace_v4l2_encoder_cmd_gen(arg, ioctl_args); diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl index 8c6f7cb5..aaa112c1 100755 --- a/utils/v4l2-tracer/v4l2-tracer-gen.pl +++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl @@ -193,7 +193,7 @@ sub get_val_def_name { } return "nullptr"; # will print as hex string } - if ($member =~ /pixelformat/) { + if ($member eq "pixelformat" || $member eq "pixel_format") { return "v4l2_pix_fmt_val_def"; } if ($member =~ /cmd/) { @@ -363,6 +363,15 @@ sub handle_union { printf $fh_retrace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; } + if ($struct_name eq "v4l2_frmsizeenum") { + printf $fh_trace_cpp "\tswitch (p->type) {\n"; + printf $fh_trace_cpp "\tcase V4L2_FRMSIZE_TYPE_DISCRETE:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_frmsize_discrete_gen(&p->discrete, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_FRMSIZE_TYPE_STEPWISE:\n\tcase V4L2_FRMSIZE_TYPE_CONTINUOUS:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_frmsize_stepwise_gen(&p->stepwise, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; + } + return $suppress_union; } From patchwork Wed Jun 7 02:11:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 13269916 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 E8E68C7EE37 for ; Wed, 7 Jun 2023 02:12:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240716AbjFGCMV (ORCPT ); Tue, 6 Jun 2023 22:12:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240712AbjFGCMU (ORCPT ); Tue, 6 Jun 2023 22:12:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F89B19B5 for ; Tue, 6 Jun 2023 19:12:17 -0700 (PDT) Received: from db550.. (node-1w7jr9st5p2esmclet71ntnwp.ipv6.telus.net [IPv6:2001:569:beb1:1500:6f9d:3a5c:4d25:e949]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id B63DB6606EF0; Wed, 7 Jun 2023 03:12:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686103936; bh=Pg79s4yRL5U7Mdj11vuQq9Lg4CypiyOozpE+UK6pCAA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cn6WHo7hMlSXHkb7xYBv0qXs1155sfqXnC7+Z+B8t0T1IZZFSyQHbi5QwchSWds9V 9JJBO0AljMng5nvdDuGknQx5MpCoalsxfLJ7hZejbakjY5IeqtBp2Lb26QaLZlMb7B 5nr8o310+TeJ+eaTK8ivpCRM639gyS72KXInY5ES66ejHWhqTjmlHNeFgskGOjSOAr VLJ4Q9/SwImUAv5+b/RV4cZ450Hf4Tw3h52LgjlCK+3ADCefwwReL4+8jgUskjFjE/ Y0PczVHmTW9lXDIN+vV2bOoWrxF9XRsgWiO0t+qIYevWZwnjC60kLh1qgwxMmb2B4O qNiL7Dxttg9bQ== From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, Deborah Brouwer Subject: [PATCH 2/4] v4l2-tracer: add VIDIOC_ENUM_FRAMEINTERVALS Date: Tue, 6 Jun 2023 19:11:56 -0700 Message-Id: <5f240a99d963cb7e908bc6a9bfbf3acedd595480.1686102391.git.deborah.brouwer@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add tracing and retracing for VIDIOC_ENUM_FRAMEINTERVALS ioctl. Signed-off-by: Deborah Brouwer --- utils/v4l2-tracer/libv4l2tracer.cpp | 1 + utils/v4l2-tracer/retrace.cpp | 16 ++++++++++++++++ utils/v4l2-tracer/trace.cpp | 3 +++ utils/v4l2-tracer/v4l2-tracer-gen.pl | 9 +++++++++ 4 files changed, 29 insertions(+) diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp index 6edec7f4..58a02656 100644 --- a/utils/v4l2-tracer/libv4l2tracer.cpp +++ b/utils/v4l2-tracer/libv4l2tracer.cpp @@ -41,6 +41,7 @@ const std::list ioctls = { VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS, VIDIOC_ENUM_FRAMESIZES, + VIDIOC_ENUM_FRAMEINTERVALS, VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD, VIDIOC_CREATE_BUFS, diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp index 7003ca70..28dc6afe 100644 --- a/utils/v4l2-tracer/retrace.cpp +++ b/utils/v4l2-tracer/retrace.cpp @@ -978,6 +978,19 @@ void retrace_vidioc_enum_framesizes(int fd_retrace, json_object *ioctl_args) free(ptr); } +void retrace_vidioc_enum_frameintervals(int fd_retrace, json_object *ioctl_args) +{ + struct v4l2_frmivalenum *ptr = retrace_v4l2_frmivalenum_gen(ioctl_args); + + ioctl(fd_retrace, VIDIOC_ENUM_FRAMEINTERVALS, ptr); + + if (is_verbose() || (errno != 0)) + perror("VIDIOC_ENUM_FRAMEINTERVALS"); + + free(ptr); +} + + void retrace_vidioc_try_encoder_cmd(int fd_retrace, json_object *ioctl_args) { struct v4l2_encoder_cmd *ptr = retrace_v4l2_encoder_cmd_gen(ioctl_args); @@ -1287,6 +1300,9 @@ void retrace_ioctl(json_object *syscall_obj) case VIDIOC_ENUM_FRAMESIZES: retrace_vidioc_enum_framesizes(fd_retrace, ioctl_args_user); break; + case VIDIOC_ENUM_FRAMEINTERVALS: + retrace_vidioc_enum_frameintervals(fd_retrace, ioctl_args_user); + break; case VIDIOC_TRY_ENCODER_CMD: retrace_vidioc_try_encoder_cmd(fd_retrace, ioctl_args_user); break; diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp index 78db2554..5049a996 100644 --- a/utils/v4l2-tracer/trace.cpp +++ b/utils/v4l2-tracer/trace.cpp @@ -592,6 +592,9 @@ json_object *trace_ioctl_args(unsigned long cmd, void *arg) case VIDIOC_ENUM_FRAMESIZES: trace_v4l2_frmsizeenum_gen(arg, ioctl_args); break; + case VIDIOC_ENUM_FRAMEINTERVALS: + trace_v4l2_frmivalenum_gen(arg, ioctl_args); + break; case VIDIOC_TRY_ENCODER_CMD: case VIDIOC_ENCODER_CMD: trace_v4l2_encoder_cmd_gen(arg, ioctl_args); diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl index aaa112c1..f3eb87bb 100755 --- a/utils/v4l2-tracer/v4l2-tracer-gen.pl +++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl @@ -372,6 +372,15 @@ sub handle_union { printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; } + if ($struct_name eq "v4l2_frmivalenum") { + printf $fh_trace_cpp "\tswitch (p->type) {\n"; + printf $fh_trace_cpp "\tcase V4L2_FRMIVAL_TYPE_DISCRETE:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_fract_gen(&p->discrete, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_FRMIVAL_TYPE_STEPWISE:\n\tcase V4L2_FRMIVAL_TYPE_CONTINUOUS:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_frmival_stepwise_gen(&p->stepwise, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; + } + return $suppress_union; } From patchwork Wed Jun 7 02:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 13269917 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 A0EBBC7EE29 for ; Wed, 7 Jun 2023 02:12:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240706AbjFGCMW (ORCPT ); Tue, 6 Jun 2023 22:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240710AbjFGCMV (ORCPT ); Tue, 6 Jun 2023 22:12:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9652319A4 for ; Tue, 6 Jun 2023 19:12:19 -0700 (PDT) Received: from db550.. (node-1w7jr9st5p2esmclet71ntnwp.ipv6.telus.net [IPv6:2001:569:beb1:1500:6f9d:3a5c:4d25:e949]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id 31F1F6606EF4; Wed, 7 Jun 2023 03:12:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686103938; bh=7i3xDdpR5V7CYfQEDPt1HyY5RZ3HDruT3ILH20+KXyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YXvwIC7OAMovcdB4DG2z5PBK3p+XoaWgpGRMYSnPSq0lgLSS8c3YXALnNNr6c24OK SgNOzbAQGPg02NZX4t97woltcZiLz/2Q577bXXc+ucmmyS8yrNCbTcYR+62BtpJHyV 4rGMm6Jkm+QiXEAi0azFOCBaxMrWUXiXif2DYGSDp2dqWeJJ8nC8riy90jNNbs/4hH s400kSh6lU+R2KUe+psMBYug4+SCFCkmPwG3OMF23O2x4DCvNo/Yh+6NyAVqnMMqGp kI1ybvAwYYzEN6m5FylJfhhjst27jrlb2ox3dmdtSJPq7S/tSwp2gbgzmnNrXEsRCR F+08O6eTMFMoQ== From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, Deborah Brouwer Subject: [PATCH 3/4] v4l2-tracer: stringify target in v4l2_selection Date: Tue, 6 Jun 2023 19:11:57 -0700 Message-Id: <6ba577331303022b419d58fcbfaeba7b2459a5b5.1686102391.git.deborah.brouwer@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The struct v4l2_selection has a member "target" that is currently being traced as an integer. Since the "target" values are defines, convert them to strings to make the trace easier to read. Signed-off-by: Deborah Brouwer --- utils/v4l2-tracer/v4l2-tracer-gen.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl index f3eb87bb..4db204e3 100755 --- a/utils/v4l2-tracer/v4l2-tracer-gen.pl +++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl @@ -246,7 +246,9 @@ sub get_val_def_name { if ($member eq "audmode") { return "tuner_audmode_val_def"; } - return ""; + if ($member eq "target" && $struct_name eq "v4l2_selection") { + return "selection_target_val_def"; + } } sub get_flag_def_name { @@ -974,6 +976,11 @@ while (<>) { if (grep {/^#define\s+(MEDIA_REQUEST_IOC\w*)\s*.*/} $_) { push (@ioctls, $_); } + if (grep {/^#define V4L2_SEL_TGT_CROP\s+/} $_) { + printf $fh_common_info_h "constexpr val_def selection_target_val_def[] = {\n"; + val_def_gen("V4L2_SEL_TGT_COMPOSE_PADDED"); + next; + } } printf $fh_common_info_h "constexpr val_def control_val_def[] = {\n"; From patchwork Wed Jun 7 02:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deborah Brouwer X-Patchwork-Id: 13269918 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 69145C77B7A for ; Wed, 7 Jun 2023 02:12:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240710AbjFGCMZ (ORCPT ); Tue, 6 Jun 2023 22:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240715AbjFGCMX (ORCPT ); Tue, 6 Jun 2023 22:12:23 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B21E1990 for ; Tue, 6 Jun 2023 19:12:22 -0700 (PDT) Received: from db550.. (node-1w7jr9st5p2esmclet71ntnwp.ipv6.telus.net [IPv6:2001:569:beb1:1500:6f9d:3a5c:4d25:e949]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: dbrouwer) by madras.collabora.co.uk (Postfix) with ESMTPSA id A2A306606EF6; Wed, 7 Jun 2023 03:12:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1686103940; bh=IwPSWQ1Lk9vTxCJMpMtfnR17lQ+rgg4RtgrM5SUMjMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T4bjFs+hpB0gCFGoudmcF1rQ13kAg/WP6f44PpsyF02D/R7Aq6Db5NjsWzvFRZvaO uGJNMcrx+Vcwep8z/oJoPKMrpZtwFxN+rB36dQ4+GExkEZzk1xmO5bUhhJi985oC2S jNuwrJ08X+Q19K+8sebXYHY2C6GzZ12wQcUuQVwPYhq5icvmHiw6ou7mj4Jlfifvna 7fDLz8Zn/UzKbD2+FtUVXajYY2Mnutxlw9wBJ1rra6LmwxiTH6NUUHBnOPzZF/bflg sJ01fAvAsWshYCXIG7aUBRG9XaTOIbVFGZvPFPR8BiJq61KCevSuVEsvq4Z/gQCr+I ZrNUgQO/0cRJg== From: Deborah Brouwer To: linux-media@vger.kernel.org Cc: hverkuil-cisco@xs4all.nl, nicolas.dufresne@collabora.com, Deborah Brouwer Subject: [PATCH 4/4] v4l2-tracer: add event tracing/retracing Date: Tue, 6 Jun 2023 19:11:58 -0700 Message-Id: <3494ac2254d29947897a2a4173a2ced0da725160.1686102391.git.deborah.brouwer@collabora.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add tracing and retracing for VIDIOC_DQEVENT, VIDIOC_SUBSCRIBE_EVENT, and VIDIOC_UNSUBSCRIBE_EVENT ioctls. Signed-off-by: Deborah Brouwer --- utils/v4l2-tracer/libv4l2tracer.cpp | 3 ++ utils/v4l2-tracer/retrace.cpp | 81 ++++++++++++++++++++++++++-- utils/v4l2-tracer/trace.cpp | 7 +++ utils/v4l2-tracer/v4l2-tracer-gen.pl | 45 +++++++++++++--- 4 files changed, 126 insertions(+), 10 deletions(-) diff --git a/utils/v4l2-tracer/libv4l2tracer.cpp b/utils/v4l2-tracer/libv4l2tracer.cpp index 58a02656..7286f321 100644 --- a/utils/v4l2-tracer/libv4l2tracer.cpp +++ b/utils/v4l2-tracer/libv4l2tracer.cpp @@ -44,6 +44,9 @@ const std::list ioctls = { VIDIOC_ENUM_FRAMEINTERVALS, VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD, + VIDIOC_DQEVENT, + VIDIOC_SUBSCRIBE_EVENT, + VIDIOC_UNSUBSCRIBE_EVENT, VIDIOC_CREATE_BUFS, VIDIOC_PREPARE_BUF, VIDIOC_G_SELECTION, diff --git a/utils/v4l2-tracer/retrace.cpp b/utils/v4l2-tracer/retrace.cpp index 28dc6afe..88e70ea9 100644 --- a/utils/v4l2-tracer/retrace.cpp +++ b/utils/v4l2-tracer/retrace.cpp @@ -1120,6 +1120,61 @@ void retrace_vidioc_try_decoder_cmd(int fd_retrace, json_object *ioctl_args) free (ptr); } +void retrace_vidioc_dqevent(int fd_retrace) +{ + const int poll_timeout_ms = 200; + struct pollfd *pfds = (struct pollfd *) calloc(1, sizeof(struct pollfd)); + if (pfds == nullptr) + exit(EXIT_FAILURE); + pfds[0].fd = fd_retrace; + pfds[0].events = POLLIN | POLLPRI; + int ret = poll(pfds, 1, poll_timeout_ms); + + if (ret == -1) { + line_info("\n\tPoll error."); + perror(""); + free(pfds); + exit(EXIT_FAILURE); + } + if (ret == 0) { + line_info("\n\tPoll timed out."); + free(pfds); + exit(EXIT_FAILURE); + } + + struct v4l2_event event = {}; + ioctl(fd_retrace, VIDIOC_DQEVENT, &event); + + if (is_verbose() || (errno != 0)) + perror("VIDIOC_DQEVENT"); + + free(pfds); +} + +void retrace_vidioc_subscribe_event(int fd_retrace, json_object *ioctl_args) +{ + struct v4l2_event_subscription *ptr = retrace_v4l2_event_subscription_gen(ioctl_args); + + ioctl(fd_retrace, VIDIOC_SUBSCRIBE_EVENT, ptr); + + if (is_verbose() || (errno != 0)) + perror("VIDIOC_SUBSCRIBE_EVENT"); + + free (ptr); +} + +void retrace_vidioc_unsubscribe(int fd_retrace, json_object *ioctl_args) +{ + struct v4l2_event_subscription *ptr = retrace_v4l2_event_subscription_gen(ioctl_args); + + ioctl(fd_retrace, VIDIOC_UNSUBSCRIBE_EVENT, ptr); + + if (is_verbose() || (errno != 0)) + perror("VIDIOC_UNSUBSCRIBE_EVENT"); + + free (ptr); +} + void retrace_vidioc_decoder_cmd(int fd_retrace, json_object *ioctl_args) { struct v4l2_decoder_cmd *ptr = retrace_v4l2_decoder_cmd(ioctl_args); @@ -1187,19 +1242,25 @@ void retrace_ioctl(json_object *syscall_obj) { __s64 cmd = 0; int fd_retrace = 0; + bool ioctl_error = false; json_object *fd_trace_obj; json_object_object_get_ex(syscall_obj, "fd", &fd_trace_obj); fd_retrace = get_fd_retrace_from_fd_trace(json_object_get_int(fd_trace_obj)); - if (fd_retrace < 0) { - line_info("\n\tBad file descriptor."); - return; - } json_object *cmd_obj; json_object_object_get_ex(syscall_obj, "ioctl", &cmd_obj); cmd = s2val(json_object_get_string(cmd_obj), ioctl_val_def); + json_object *errno_obj; + if (json_object_object_get_ex(syscall_obj, "errno", &errno_obj)) + ioctl_error = true; + + if (fd_retrace < 0) { + line_info("\n\tBad file descriptor on %s\n", json_object_get_string(cmd_obj)); + return; + } + json_object *ioctl_args_user; json_object_object_get_ex(syscall_obj, "from_userspace", &ioctl_args_user); @@ -1324,6 +1385,18 @@ void retrace_ioctl(json_object *syscall_obj) case VIDIOC_TRY_DECODER_CMD: retrace_vidioc_try_decoder_cmd(fd_retrace, ioctl_args_user); break; + case VIDIOC_DQEVENT: + /* Don't retrace a timed-out DQEVENT */ + if (ioctl_error) + break; + retrace_vidioc_dqevent(fd_retrace); + break; + case VIDIOC_SUBSCRIBE_EVENT: + retrace_vidioc_subscribe_event(fd_retrace, ioctl_args_user); + break; + case VIDIOC_UNSUBSCRIBE_EVENT: + retrace_vidioc_unsubscribe(fd_retrace, ioctl_args_user); + break; case VIDIOC_DECODER_CMD: retrace_vidioc_decoder_cmd(fd_retrace, ioctl_args_user); break; diff --git a/utils/v4l2-tracer/trace.cpp b/utils/v4l2-tracer/trace.cpp index 5049a996..0e8531ff 100644 --- a/utils/v4l2-tracer/trace.cpp +++ b/utils/v4l2-tracer/trace.cpp @@ -599,6 +599,13 @@ json_object *trace_ioctl_args(unsigned long cmd, void *arg) case VIDIOC_ENCODER_CMD: trace_v4l2_encoder_cmd_gen(arg, ioctl_args); break; + case VIDIOC_DQEVENT: + trace_v4l2_event_gen(arg, ioctl_args); + break; + case VIDIOC_SUBSCRIBE_EVENT: + case VIDIOC_UNSUBSCRIBE_EVENT: + trace_v4l2_event_subscription_gen(arg, ioctl_args); + break; case VIDIOC_CREATE_BUFS: trace_v4l2_create_buffers_gen(arg, ioctl_args); break; diff --git a/utils/v4l2-tracer/v4l2-tracer-gen.pl b/utils/v4l2-tracer/v4l2-tracer-gen.pl index 4db204e3..cbfdfbe0 100755 --- a/utils/v4l2-tracer/v4l2-tracer-gen.pl +++ b/utils/v4l2-tracer/v4l2-tracer-gen.pl @@ -161,7 +161,7 @@ sub get_val_def_name { @structs_that_use_v4l2_buf_type = qw(v4l2_fmtdesc v4l2_requestbuffers v4l2_buffer v4l2_crop v4l2_exportbuffer v4l2_cropcap v4l2_selection v4l2_sliced_vbi_cap v4l2_format v4l2_streamparm); - @structs_that_use_v4l2_ctrl_type = qw(v4l2_queryctrl v4l2_query_ext_ctrl); + @structs_that_use_v4l2_ctrl_type = qw(v4l2_queryctrl v4l2_query_ext_ctrl v4l2_event_ctrl); @structs_that_use_v4l2_tuner_type = qw(v4l2_tuner v4l2_frequency); if ($member eq "type") { foreach (@structs_that_use_v4l2_buf_type) { @@ -191,6 +191,9 @@ sub get_val_def_name { if ($struct_name eq "v4l2_output") { return $val_def_name = "output_type_val_def"; } + if ($struct_name eq "v4l2_event" || $struct_name eq "v4l2_event_subscription") { + return $val_def_name = "event_val_def"; + } return "nullptr"; # will print as hex string } if ($member eq "pixelformat" || $member eq "pixel_format") { @@ -270,7 +273,10 @@ sub get_flag_def_name { if ($struct_name =~ /.*selection$/) { return "v4l2_sel_flag_def"; } - return "nullptr"; + if ($struct_name eq "v4l2_event_subscription") { + return "v4l2_event_sub_flag_def"; + } + return "nullptr"; } if ($member =~ /.*cap.*/) { @@ -289,6 +295,11 @@ sub get_flag_def_name { if ($member eq "rxsubchans") { return "tuner_rxsub_flag_def"; } + if ($member eq "changes") { + if ($struct_name eq "v4l2_event_ctrl") { + return "v4l2_event_ctrl_ch_flag_def"; + } + } return ""; } @@ -383,6 +394,21 @@ sub handle_union { printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; } + if ($struct_name eq "v4l2_event") { + printf $fh_trace_cpp "\tswitch (p->type) {\n"; + printf $fh_trace_cpp "\tcase V4L2_EVENT_VSYNC:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_event_vsync_gen(&p->u, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_EVENT_CTRL:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_event_ctrl_gen(&p->u, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_EVENT_FRAME_SYNC:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_event_frame_sync_gen(&p->u, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_EVENT_SOURCE_CHANGE:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_event_src_change_gen(&p->u, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tcase V4L2_EVENT_MOTION_DET:\n"; + printf $fh_trace_cpp "\t\ttrace_v4l2_event_motion_det_gen(&p->u, %s_obj);\n\t\tbreak;\n", $struct_name; + printf $fh_trace_cpp "\tdefault:\n\t\tbreak;\n\t}\n"; + } + return $suppress_union; } @@ -854,17 +880,15 @@ while (<>) { if (grep {/#define __LINUX_VIDEODEV2_H/} $_) { $in_v4l2_controls = false; } - if (grep {/^#define.+FWHT_FL_.+/} $_) { flag_gen("fwht"); } elsif (grep {/^#define V4L2_VP8_LF.*/} $_) { flag_gen("vp8_loop_filter"); - } elsif (grep {/^#define.+_FL_.+/} $_) { #use to get media flags + } elsif (grep {/^#define.+_FL_.+/} $_) { flag_gen(); } elsif (grep {/^#define.+_FLAG_.+/} $_) { flag_gen(); } - if ($in_v4l2_controls eq true) { if (grep {/^struct/} $_) { struct_gen_ctrl(); @@ -964,7 +988,16 @@ while (<>) { val_def_gen("V4L2_DEC_CMD_FLUSH"); next; } - + if (grep {/^#define V4L2_EVENT_ALL\s+/} $_) { + printf $fh_common_info_h "constexpr val_def event_val_def[] = {\n"; + val_def_gen("V4L2_EVENT_PRIVATE_START"); + next; + } + if (grep {/^#define V4L2_EVENT_CTRL_CH_VALUE\s+/} $_) { + printf $fh_common_info_h "constexpr flag_def v4l2_event_ctrl_ch_flag_def[] = {\n"; + flag_def_gen("V4L2_EVENT_CTRL_CH_DIMENSIONS"); + next + } if (grep {/^#define\s+(VIDIOC_\w*)\s*.*/} $_) { push (@ioctls, $_); }