From patchwork Tue Nov 22 15:53:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugues FRUCHET X-Patchwork-Id: 9441413 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2CCDD605EE for ; Tue, 22 Nov 2016 15:53:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 223F2285A1 for ; Tue, 22 Nov 2016 15:53:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 174D2285C5; Tue, 22 Nov 2016 15:53:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1208C285A1 for ; Tue, 22 Nov 2016 15:53:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755972AbcKVPxv (ORCPT ); Tue, 22 Nov 2016 10:53:51 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:28344 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755913AbcKVPxu (ORCPT ); Tue, 22 Nov 2016 10:53:50 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id uAMFolho011615; Tue, 22 Nov 2016 16:53:48 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 26tcr9ru0y-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 22 Nov 2016 16:53:47 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 42DD43D; Tue, 22 Nov 2016 15:53:46 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 17767AE67; Tue, 22 Nov 2016 15:53:46 +0000 (GMT) Received: from localhost (10.201.23.73) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Tue, 22 Nov 2016 16:53:45 +0100 From: Hugues Fruchet To: , Hans Verkuil CC: , Benjamin Gaignard , Hugues Fruchet , Jean-Christophe Trotin Subject: [PATCH v3 10/10] [media] st-delta: debug: trace stream/frame information & summary Date: Tue, 22 Nov 2016 16:53:27 +0100 Message-ID: <1479830007-29767-11-git-send-email-hugues.fruchet@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1479830007-29767-1-git-send-email-hugues.fruchet@st.com> References: <1479830007-29767-1-git-send-email-hugues.fruchet@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.23.73] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-11-22_08:, , signatures=0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds some trace points showing input compressed stream or output decoded frame information. Adds an unconditional trace point when streaming starts showing the compressed stream and the decoded frame information. Adds an unconditional trace point at instance closure summarizing into a single line the decoding process (stream information, decoded and output frames number, potential errors observed). Signed-off-by: Hugues Fruchet --- drivers/media/platform/sti/delta/Makefile | 2 +- drivers/media/platform/sti/delta/delta-debug.c | 72 ++++++++++++++++++++++++++ drivers/media/platform/sti/delta/delta-debug.h | 18 +++++++ drivers/media/platform/sti/delta/delta-v4l2.c | 29 +++++++++-- 4 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 drivers/media/platform/sti/delta/delta-debug.c create mode 100644 drivers/media/platform/sti/delta/delta-debug.h diff --git a/drivers/media/platform/sti/delta/Makefile b/drivers/media/platform/sti/delta/Makefile index 663be70..f95580e 100644 --- a/drivers/media/platform/sti/delta/Makefile +++ b/drivers/media/platform/sti/delta/Makefile @@ -1,5 +1,5 @@ obj-$(CONFIG_VIDEO_STI_DELTA) := st-delta.o -st-delta-y := delta-v4l2.o delta-mem.o delta-ipc.o +st-delta-y := delta-v4l2.o delta-mem.o delta-ipc.o delta-debug.o # MJPEG support st-delta-$(CONFIG_VIDEO_STI_DELTA_MJPEG) += delta-mjpeg-hdr.o diff --git a/drivers/media/platform/sti/delta/delta-debug.c b/drivers/media/platform/sti/delta/delta-debug.c new file mode 100644 index 0000000..f1bc64e --- /dev/null +++ b/drivers/media/platform/sti/delta/delta-debug.c @@ -0,0 +1,72 @@ +/* + * Copyright (C) STMicroelectronics SA 2015 + * Authors: Hugues Fruchet + * Fabrice Lecoultre + * for STMicroelectronics. + * License terms: GNU General Public License (GPL), version 2 + */ + +#include "delta.h" +#include "delta-debug.h" + +char *delta_streaminfo_str(struct delta_streaminfo *s, char *str, + unsigned int len) +{ + if (!s) + return NULL; + + snprintf(str, len, + "%4.4s %dx%d %s %s dpb=%d %s %s %s%dx%d@(%d,%d) %s%d/%d", + (char *)&s->streamformat, s->width, s->height, + s->profile, s->level, s->dpb, + (s->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced", + s->other, + s->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "", + s->crop.width, s->crop.height, + s->crop.left, s->crop.top, + s->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "", + s->pixelaspect.numerator, + s->pixelaspect.denominator); + + return str; +} + +char *delta_frameinfo_str(struct delta_frameinfo *f, char *str, + unsigned int len) +{ + if (!f) + return NULL; + + snprintf(str, len, + "%4.4s %dx%d aligned %dx%d %s %s%dx%d@(%d,%d) %s%d/%d", + (char *)&f->pixelformat, f->width, f->height, + f->aligned_width, f->aligned_height, + (f->field == V4L2_FIELD_NONE) ? "progressive" : "interlaced", + f->flags & DELTA_STREAMINFO_FLAG_CROP ? "crop=" : "", + f->crop.width, f->crop.height, + f->crop.left, f->crop.top, + f->flags & DELTA_STREAMINFO_FLAG_PIXELASPECT ? "par=" : "", + f->pixelaspect.numerator, + f->pixelaspect.denominator); + + return str; +} + +void delta_trace_summary(struct delta_ctx *ctx) +{ + struct delta_dev *delta = ctx->dev; + struct delta_streaminfo *s = &ctx->streaminfo; + unsigned char str[100] = ""; + + if (!(ctx->flags & DELTA_FLAG_STREAMINFO)) + return; + + dev_info(delta->dev, "%s %s, %d frames decoded, %d frames output, %d frames dropped, %d stream errors, %d decode errors", + ctx->name, + delta_streaminfo_str(s, str, sizeof(str)), + ctx->decoded_frames, + ctx->output_frames, + ctx->dropped_frames, + ctx->stream_errors, + ctx->decode_errors); +} diff --git a/drivers/media/platform/sti/delta/delta-debug.h b/drivers/media/platform/sti/delta/delta-debug.h new file mode 100644 index 0000000..955c158 --- /dev/null +++ b/drivers/media/platform/sti/delta/delta-debug.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) STMicroelectronics SA 2015 + * Authors: Hugues Fruchet + * Fabrice Lecoultre + * for STMicroelectronics. + * License terms: GNU General Public License (GPL), version 2 + */ + +#ifndef DELTA_DEBUG_H +#define DELTA_DEBUG_H + +char *delta_streaminfo_str(struct delta_streaminfo *s, char *str, + unsigned int len); +char *delta_frameinfo_str(struct delta_frameinfo *f, char *str, + unsigned int len); +void delta_trace_summary(struct delta_ctx *ctx); + +#endif /* DELTA_DEBUG_H */ diff --git a/drivers/media/platform/sti/delta/delta-v4l2.c b/drivers/media/platform/sti/delta/delta-v4l2.c index 96590da..bd17083 100644 --- a/drivers/media/platform/sti/delta/delta-v4l2.c +++ b/drivers/media/platform/sti/delta/delta-v4l2.c @@ -17,6 +17,7 @@ #include #include "delta.h" +#include "delta-debug.h" #include "delta-ipc.h" #define DELTA_NAME "st-delta" @@ -438,11 +439,13 @@ static int delta_g_fmt_stream(struct file *file, void *fh, struct delta_dev *delta = ctx->dev; struct v4l2_pix_format *pix = &f->fmt.pix; struct delta_streaminfo *streaminfo = &ctx->streaminfo; + unsigned char str[100] = ""; if (!(ctx->flags & DELTA_FLAG_STREAMINFO)) dev_dbg(delta->dev, - "%s V4L2 GET_FMT (OUTPUT): no stream information available, using default\n", - ctx->name); + "%s V4L2 GET_FMT (OUTPUT): no stream information available, default to %s\n", + ctx->name, + delta_streaminfo_str(streaminfo, str, sizeof(str))); pix->pixelformat = streaminfo->streamformat; pix->width = streaminfo->width; @@ -465,11 +468,13 @@ static int delta_g_fmt_frame(struct file *file, void *fh, struct v4l2_format *f) struct v4l2_pix_format *pix = &f->fmt.pix; struct delta_frameinfo *frameinfo = &ctx->frameinfo; struct delta_streaminfo *streaminfo = &ctx->streaminfo; + unsigned char str[100] = ""; if (!(ctx->flags & DELTA_FLAG_FRAMEINFO)) dev_dbg(delta->dev, - "%s V4L2 GET_FMT (CAPTURE): no frame information available, using default\n", - ctx->name); + "%s V4L2 GET_FMT (CAPTURE): no frame information available, default to %s\n", + ctx->name, + delta_frameinfo_str(frameinfo, str, sizeof(str))); pix->pixelformat = frameinfo->pixelformat; pix->width = frameinfo->aligned_width; @@ -652,6 +657,7 @@ static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f) const struct delta_dec *dec = ctx->dec; struct v4l2_pix_format *pix = &f->fmt.pix; struct delta_frameinfo frameinfo; + unsigned char str[100] = ""; struct vb2_queue *vq; int ret; @@ -703,6 +709,10 @@ static int delta_s_fmt_frame(struct file *file, void *fh, struct v4l2_format *f) ctx->flags |= DELTA_FLAG_FRAMEINFO; ctx->frameinfo = frameinfo; + dev_dbg(delta->dev, + "%s V4L2 SET_FMT (CAPTURE): frameinfo updated to %s\n", + ctx->name, + delta_frameinfo_str(&frameinfo, str, sizeof(str))); pix->pixelformat = frameinfo.pixelformat; pix->width = frameinfo.aligned_width; @@ -1306,6 +1316,8 @@ static int delta_vb2_au_start_streaming(struct vb2_queue *q, struct vb2_v4l2_buffer *vbuf = NULL; struct delta_streaminfo *streaminfo = &ctx->streaminfo; struct delta_frameinfo *frameinfo = &ctx->frameinfo; + unsigned char str1[100] = ""; + unsigned char str2[100] = ""; if ((ctx->state != DELTA_STATE_WF_FORMAT) && (ctx->state != DELTA_STATE_WF_STREAMINFO)) @@ -1366,6 +1378,10 @@ static int delta_vb2_au_start_streaming(struct vb2_queue *q, ctx->state = DELTA_STATE_READY; + dev_info(delta->dev, "%s %s => %s\n", ctx->name, + delta_streaminfo_str(streaminfo, str1, sizeof(str1)), + delta_frameinfo_str(frameinfo, str2, sizeof(str2))); + delta_au_done(ctx, au, ret); return 0; @@ -1689,6 +1705,11 @@ static int delta_release(struct file *file) /* close decoder */ call_dec_op(dec, close, ctx); + /* trace a summary of instance + * before closing (debug purpose) + */ + delta_trace_summary(ctx); + v4l2_m2m_ctx_release(ctx->fh.m2m_ctx); v4l2_fh_del(&ctx->fh);