From patchwork Tue Apr 16 09:30:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10902557 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 E78AB1390 for ; Tue, 16 Apr 2019 09:45:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1F7828591 for ; Tue, 16 Apr 2019 09:45:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C5F6F2893A; Tue, 16 Apr 2019 09:45:59 +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=unavailable 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 544FC28591 for ; Tue, 16 Apr 2019 09:45:59 +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=NFua6bry+6J/D8 L9sGIpzMwV6xxnVEXKibNmqTm0JHAVU2vxpdYXwjI7j4QpRDErrCmpqN1G0cyABllQY6QxWbx895p udYm+J94D6ZfnAxtnMhTL4hPPxrn21cEHV9Lj64hHNTsG6+D2Jho/TH0D7dtHpJZuNx0iEGJwEapj EhEntXDIt4Lz3wRZfh5F4W4BfU2VClhjH0F7xNFZ5jzqf7TAqU1rlqSA3ZG0DrOt56VJe7ehbkHA1 3HhGfmILrBrUNBuqQ4oHfmdtGofQ/pdKXgFD/bXtzC5maVPVL6AZye+dM27TgseWgRsKGaL1yGbAB 8w+4E4yzl3ydQXfOSxsQ==; 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 1hGKf7-0007fR-9V; Tue, 16 Apr 2019 09:45:57 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGKdV-0004CA-VE; Tue, 16 Apr 2019 09:44:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=g86r7TMg00BPPEw8QiTMIpJpmhf/A27ItQu+fI6Oq+Q=; b=ttVFaYWW8bQStOimiaP9CR31o +P9TayAFkTSmHT9hbmrtyAD/MJKr23wC61CPJesXN+M3euQ1xt0VlYGQp5gJGz5YVnEeP0OeiJ/o9 HNsfETNCoOhM66Mb1RkUonJHHGiK1qGqWi3Du3H1KufNZELc4Ukzdb0Dl85iF893boKXtcAH9/fUg tQM3F7sJqPkUS3hgL8QlzrwK3owl7fcWgi2qnWkQ4zrLLgpaE7EMy+F4zmc/OJdWf9e8R4HFNlSqx eGzJ2K6zoCX8BGJ8LgBvLr3nL8+/7YoBNfOWTMe1XCU99BplBJVZYz/wMPUl5KZfxtnTvnwL7HwwQ AoY7lZXwg==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGKQM-0002lZ-Tu; Tue, 16 Apr 2019 09:30:45 +0000 X-UUID: 2f7b6b4f53c948b3bc44cbc5f5686712-20190416 X-UUID: 2f7b6b4f53c948b3bc44cbc5f5686712-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 1617810553; Tue, 16 Apr 2019 01:30:23 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 16 Apr 2019 02:30:22 -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:30:19 +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:30:19 +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:30:14 +0800 Message-ID: <1555407015-18130-15-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1555407015-18130-1-git-send-email-stu.hsieh@mediatek.com> References: <1555407015-18130-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_103043_472177_BC801602 X-CRM114-Status: GOOD ( 24.25 ) 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, srv_heupstream@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");