From patchwork Mon Apr 8 11:54:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stu Hsieh X-Patchwork-Id: 10889429 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 DC1AD922 for ; Mon, 8 Apr 2019 12:06:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFC4528426 for ; Mon, 8 Apr 2019 12:06:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B400D283A5; Mon, 8 Apr 2019 12:06:29 +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 6D6AA28426 for ; Mon, 8 Apr 2019 12:06:29 +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=BsghLw+Ddl6tGzapVsUjn6YDFBmtgB3k8smc+RnWgQo=; b=WKm6nk69Gv6TYM bUb+1Wte/Zk2t/1KsHAkaZn1Hx8E7Du4lZEzCWZZlpYDu8zhPxORbkHweMvqFN9waeJMFKyHAbySr YFX+AhhMTWh43DQRdJUXLpeHzZ9LhEvOGs6Q/u3w1MSF2lENEqgkhr6Jq6whMznGFUC3JehXiSH2U cNkWwGfmwAssSKmNlysgMYyWut5oerc8ReBvC4sFIlF5FykG4aSswR0wOJdjfuCICLR94/i9uxdAs NpGCTsSDj7gMxVGtsYyOqY/CdMrGLV3SLtE0tAbF+YCVmp4ML09O6YheY8NB5YMM0wgrf59dSP9vR cGX0Own05s9hFuKeu4fw==; 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 1hDT2d-0002EL-L1; Mon, 08 Apr 2019 12:06:23 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hDSsC-0001mH-LS; Mon, 08 Apr 2019 11:55:39 +0000 X-UUID: 428396b484cf401f9d140abdbba6bc34-20190408 X-UUID: 428396b484cf401f9d140abdbba6bc34-20190408 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 624587781; Mon, 08 Apr 2019 03:55:29 -0800 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Apr 2019 04:55:28 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 8 Apr 2019 19:55:23 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Mon, 8 Apr 2019 19:55:24 +0800 From: Stu Hsieh To: Mauro Carvalho Chehab , Matthias Brugger Subject: [PATCH 04/14] [media] mtk-mipicsi: get the w/h/bytepwerline for mtk_mipicsi Date: Mon, 8 Apr 2019 19:54:55 +0800 Message-ID: <1554724505-19882-5-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1554724505-19882-1-git-send-email-stu.hsieh@mediatek.com> References: <1554724505-19882-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-20190408_045536_724121_A8A731A0 X-CRM114-Status: GOOD ( 11.65 ) 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: srv_heupstream@mediatek.com, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, Stu Hsieh , 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 ccf2d18a3e74..f9deff1e5a9f 100644 --- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c @@ -100,6 +100,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 | \ @@ -111,13 +114,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); @@ -126,6 +152,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