From patchwork Tue Apr 16 09:27:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10902309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA4E91515 for ; Tue, 16 Apr 2019 09:28:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 841C5284C0 for ; Tue, 16 Apr 2019 09:28:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 785C3288E2; Tue, 16 Apr 2019 09:28:52 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04249284C0 for ; Tue, 16 Apr 2019 09:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=dp8yegWxbuR0v2DY3t6Zz0G6OW4L6gmbh1pUZkCYn6A=; b=BCQEAqefrZp2xc cXhAZpmYwgtITV0qm2ZVdkJmq8/b3taYnEW3uSDSLvfrJiLGu+pFo7KVA2V44CC5Y4797Ju3LWA6R B/MlEdXAA+reh9Zcba639LYDDZicq3k5x9BGnsQKMYJ5kg619yFnHw5/zNZnYuIx9T03WMjD9U2xr VM+vrcH6qlgMsaqFJHluh4LzDjYXowsubX0LFmP6WyHH9J+PINe7EKSybzFr3VlxYYQFsMQxQIRTZ Ary1rttwrsY4ng3N5zm8AN9XDbI1oZmVSMHD/Be6cUBt4Wf26mt96xtFu40W6Cmai3cWLl8pOX3X5 EcV3QxiThyilpCJYAh2A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGKOY-000251-QH; Tue, 16 Apr 2019 09:28:50 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGKNj-0000w9-1l; Tue, 16 Apr 2019 09:28:01 +0000 X-UUID: d095a69d84564bd28ae7a7c12ab7e304-20190416 X-UUID: d095a69d84564bd28ae7a7c12ab7e304-20190416 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 128176245; Tue, 16 Apr 2019 01:27:56 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 16 Apr 2019 02:27:55 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 16 Apr 2019 17:27:48 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Tue, 16 Apr 2019 17:27:48 +0800 From: Stu Hsieh To: Mauro Carvalho Chehab , Rob Herring , CK Hu Subject: [PATCH v2 14/15] [media] mtk-mipicsi: add debug message for mipicsi driver Date: Tue, 16 Apr 2019 17:27:42 +0800 Message-ID: <1555406863-18069-15-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1555406863-18069-1-git-send-email-stu.hsieh@mediatek.com> References: <1555406863-18069-1-git-send-email-stu.hsieh@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190416_022759_982530_534B3F3A X-CRM114-Status: GOOD ( 18.53 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Stu Hsieh , Matthias Brugger , linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add debug message for mipicsi driver. Signed-off-by: Stu Hsieh --- .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c index 5db9c68b0da9..321bb4c88027 100644 --- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -117,6 +118,15 @@ #define SerDes_support 1 +static int mtk_mipicsi_dbg_level; +#define mtk_mipicsi_dbg(level, fmt, args...) \ + do { \ + if (mtk_mipicsi_dbg_level >= level) \ + pr_info("[MTK_MIPICSI%d] L%d %s %d: " fmt "\n", \ + mipicsi->id, level, __func__, __LINE__, \ + ##args); \ + } while (0) + /* buffer for one video frame */ struct mtk_mipicsi_buf { struct list_head queue; @@ -154,6 +164,8 @@ struct mtk_mipicsi_dev { unsigned long enqueue_cnt; unsigned long dequeue_cnt; struct v4l2_ctrl_handler ctrl_hdl; + struct timespec64 fps_time_cur; + struct timespec64 fps_time_pre; char drv_name[16]; u32 id; int clk_num; @@ -429,6 +441,8 @@ static int mtk_mipicsi_add_device(struct soc_camera_device *icd) mipicsi->width = width; mipicsi->height = height; + mtk_mipicsi_dbg(1, "sub device width/height/bytesperline %d/%d/%d", + width, height, mipicsi->bytesperline); /* * If power domain was closed before, it will be open. @@ -565,6 +579,9 @@ static int mtk_mipicsi_set_fmt(struct soc_camera_device *icd, if (pix->pixelformat == V4L2_PIX_FMT_YUYV) pix->sizeimage = pix->width * pix->height * 2U; + mtk_mipicsi_dbg(0, "width/height/sizeimage %u/%u/%u", + pix->width, pix->height, pix->sizeimage); + if (mf->code != xlate->code) return -EINVAL; @@ -690,6 +707,9 @@ static int mtk_mipicsi_vb2_prepare(struct vb2_buffer *vb) vb2_dma_contig_plane_dma_addr(vb, 0); #endif va = vb2_plane_vaddr(vb, 0); + mtk_mipicsi_dbg(1, "va=%p vb_dma_addr_phy=%lx size=%d", + va, (unsigned long)buf->vb_dma_addr_phy, + vb->planes[0].bytesused); buf->vb = vb; } @@ -735,6 +755,8 @@ static void mtk_mipicsi_vb2_queue(struct vb2_buffer *vb) } ++(mipicsi->enqueue_cnt); + mtk_mipicsi_dbg(2, "enqueue NO.%d buffer(%p). Total %lu buffer", + vb->index, vb, mipicsi->enqueue_cnt); } static int mtk_mipicsi_vb2_start_streaming(struct vb2_queue *vq, @@ -1119,8 +1141,10 @@ static int mtk_mipicsi_pm_resume(struct device *dev) if (mipicsi->larb_pdev != NULL) { ret = mtk_smi_larb_get(mipicsi->larb_pdev); - if (ret != 0) + if (ret != 0) { + mtk_mipicsi_dbg(0, "failed to get larb, err %d", ret); return ret; + } } mtk_mipicsi_ana_clk_enable(mipicsi->ana, true); @@ -1170,6 +1194,7 @@ static void mtk_mipicsi_irq_buf_process(struct mtk_mipicsi_dev *mipicsi) unsigned int next = 0U; u64 offset = 0ULL; u8 link_index = 0U; + long time_interval; void __iomem *base = NULL; dma_addr_t pa; @@ -1179,8 +1204,10 @@ static void mtk_mipicsi_irq_buf_process(struct mtk_mipicsi_dev *mipicsi) i = 0; /* only one buffer left */ - if ((&(mipicsi->fb_list))->next->next == &(mipicsi->fb_list)) + if ((&(mipicsi->fb_list))->next->next == &(mipicsi->fb_list)) { + mtk_mipicsi_dbg(1, "only 1 buffer left, drop frame"); return; + } /*for each fb_lst 2 times to get the top 2 buffer.*/ list_for_each_entry_safe(new_cam_buf, tmp, @@ -1213,6 +1240,27 @@ static void mtk_mipicsi_irq_buf_process(struct mtk_mipicsi_dev *mipicsi) ++(mipicsi->dequeue_cnt); list_del_init(&(mipicsi->cam_buf[index].queue)); + + if (mtk_mipicsi_dbg_level >= 2) { + ktime_get_real_ts64(&(mipicsi->fps_time_cur)); + if (mipicsi->dequeue_cnt == 1) { + mipicsi->fps_time_pre.tv_sec = + mipicsi->fps_time_cur.tv_sec; + mipicsi->fps_time_pre.tv_nsec = + mipicsi->fps_time_cur.tv_nsec; + } else { + time_interval = (mipicsi->fps_time_cur.tv_sec + - mipicsi->fps_time_pre.tv_sec) * 1000000000 + + (mipicsi->fps_time_cur.tv_nsec + - mipicsi->fps_time_pre.tv_nsec); + mtk_mipicsi_dbg(0, "time interval is %ld\n", + time_interval); + mipicsi->fps_time_pre.tv_sec = + mipicsi->fps_time_cur.tv_sec; + mipicsi->fps_time_pre.tv_nsec = + mipicsi->fps_time_cur.tv_nsec; + } + } } static irqreturn_t mtk_mipicsi_isr(int irq, void *data) @@ -1227,6 +1275,7 @@ static irqreturn_t mtk_mipicsi_isr(int irq, void *data) isr_ch = get_irq_channel(mipicsi); if (isr_ch < 0) { + mtk_mipicsi_dbg(0, "no interrupt occur"); spin_unlock_irqrestore(&mipicsi->lock, flags); return IRQ_HANDLED; } @@ -1567,5 +1616,6 @@ static struct platform_driver mtk_mipicsi_driver = { }; module_platform_driver(mtk_mipicsi_driver); +module_param(mtk_mipicsi_dbg_level, int, 0644); MODULE_DESCRIPTION("MediaTek SoC Camera Host driver"); MODULE_LICENSE("GPL v2");