From patchwork Tue Apr 16 09:30:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10902549 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 2A9391390 for ; Tue, 16 Apr 2019 09:45:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E31F28591 for ; Tue, 16 Apr 2019 09:45:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0264C28892; Tue, 16 Apr 2019 09:45:27 +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 A8E2E28591 for ; Tue, 16 Apr 2019 09:45:27 +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=S3A1EQ27iyEcXSOOo2AR7arYPE5aGZY3e1vADgHp3cE=; b=p74nBRTsy/x8v3 uhWys+cU74I+kthryHVSUM4k/QdESJZT+bjuXTMjFtMLApoMHdyY+Q9KrOaNHYGIZrSUCDgEg2Xeq V5t+00zPLulZ+h72co+Gez7QnrkGv/Cekx6iSgS0nOxpY60u6et36VgryXlZ69H1U2gXh/eQk3I5K 7uqS45O9poVMrVk3jmNlr/flI2x76L85rdQ1ERZwkz0XGBcgOOClHg3i11OhNEdHUilyuGNrpkjbY Cc/hiDMutq8QM9WQh077GQwUb0BheQX62DyHrEk2wqsBLDQ40JHQT4oJD9GWQxBIVPjRyJjCfiyPa jh0p1JjZm9EBRKTtK0fQ==; 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 1hGKec-000732-Pe; Tue, 16 Apr 2019 09:45:26 +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 1hGKdX-0004CA-55 for linux-mediatek@bombadil.infradead.org; Tue, 16 Apr 2019 09:44:19 +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=0gPtp+gJZKIkqYek8K7UdudTtS67Vg+0T4GNPtowu8A=; b=nHfqRluZHQAVQC1Xwn/HfFtdH 2lyTw7BxhB+tQEXY544bjJ8X9KSXpqWjMijcgU2weILyVww3RjBzpjkV0qU3pjSnTNwGyIAl4aTWH MM0RXfy3mbg4mKgXhxg1NkajZuxbCQKHua1qfoaG817ydKmEGsMgB9/p9mSTabbRlw/tuIzqz95eO OG5FCbhTk/46kxLz/QUv2yiR7Klw7ybddAeEqjsAEazEgVO7U6moEVpGkVU3nmxs+WZiT0SmU66W/ grf+byFyRFv1Zfg0T/3PS8rk4J8lHXXHzRhzhRoXU2atxxY5dPg2IgFZGri3lQoiIeNZqvL8CplHI vEXmcGYxQ==; Received: from mailgw02.mediatek.com ([216.200.240.185]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hGKQJ-0002lZ-Te for linux-mediatek@lists.infradead.org; Tue, 16 Apr 2019 09:30:42 +0000 X-UUID: 381496c786034226b1f375b8f302d469-20190416 X-UUID: 381496c786034226b1f375b8f302d469-20190416 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 30651575; Tue, 16 Apr 2019 01:30:20 -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:19 -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:17 +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:17 +0800 From: Stu Hsieh To: Mauro Carvalho Chehab , Rob Herring , CK Hu Subject: [PATCH v2 05/15] [media] mtk-mipicsi: get the w/h/bytepwerline for mtk_mipicsi Date: Tue, 16 Apr 2019 17:30:05 +0800 Message-ID: <1555407015-18130-6-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_103040_263843_D09DAE9E X-CRM114-Status: GOOD ( 15.66 ) 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 get the w/h/bytepwerline to save in mtk_mipicsi. Signed-off-by: Stu Hsieh --- .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c index 16f6bc480f4e..10782fccca79 100644 --- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c @@ -99,6 +99,9 @@ struct mtk_mipicsi_dev { u32 id; int clk_num; struct clk *clk[MIPICSI_CLK]; + u32 width; + u32 height; + u32 bytesperline; }; #define MTK_MIPICSI_BUS_PARAM (V4L2_MBUS_MASTER | \ @@ -110,13 +113,36 @@ struct mtk_mipicsi_dev { V4L2_MBUS_PCLK_SAMPLE_FALLING | \ V4L2_MBUS_DATA_ACTIVE_HIGH) +static u32 get_bytesperline(const u32 fmt, const u32 width) +{ + u32 bytesperline = 0; + + switch (fmt) { + case MEDIA_BUS_FMT_UYVY8_2X8: + case MEDIA_BUS_FMT_VYUY8_2X8: + case MEDIA_BUS_FMT_YUYV8_2X8: + case MEDIA_BUS_FMT_YVYU8_2X8: + bytesperline = width * 2U; + break; + default: + break; + } + + return bytesperline; +} + static int mtk_mipicsi_add_device(struct soc_camera_device *icd) { + struct soc_camera_host *ici = to_soc_camera_host(icd->parent); + struct mtk_mipicsi_dev *mipicsi = ici->priv; struct v4l2_subdev *sd = soc_camera_to_subdev(icd); struct v4l2_subdev_format format = { .which = V4L2_SUBDEV_FORMAT_ACTIVE, }; int ret; + u32 width; + u32 height; + u32 fmt; /* Get width/height info from subdev. Then use them to set register */ ret = v4l2_subdev_call(sd, pad, get_fmt, NULL, &format); @@ -125,6 +151,19 @@ static int mtk_mipicsi_add_device(struct soc_camera_device *icd) return ret; } + width = format.format.width; + height = format.format.height; + fmt = format.format.code; + mipicsi->bytesperline = get_bytesperline(fmt, width); + if ((width == 0U) || (height == 0U) || (mipicsi->bytesperline == 0U)) { + dev_err(icd->parent, "invalid sub device width/height/bytesperline %d/%d/%d\n", + width, height, mipicsi->bytesperline); + return -EINVAL; + } + + mipicsi->width = width; + mipicsi->height = height; + /* * If power domain was closed before, it will be open. * Then clock will be open and register will be set