From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9913C04AB4 for ; Tue, 14 May 2019 06:16:39 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D7CE2086A for ; Tue, 14 May 2019 06:16:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tpfc/Wyj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D7CE2086A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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=08Dmq/GcSO9P8G6jeFTI1GWLYCIErxJWzM94V/5c2vA=; b=tpfc/WyjqJ9dOb qfO4GjdiMGYsSUF1i438uZ6KW3VIqi0+JNW8DmNJ4ZWie0R5G15kCOq5MHxoBoNhz9IMMoTTGz0dh VtORkNoy9PgcoNCfBPVvyNyAbFxHeK+f720Z+9SWoGB0X1BOKrASpPD2wsLgvOMA91F0iDKByM3Y+ y7cu2/bzJcP885CVBACzFPpC4QDqYHFuGwfr9vT2oSt5haxolKVfXig2PqX8DUoUEOX1tgyMn7MsN 4MErZNT8tnOtUVFUHcm3N/Wswj64qCGhlfF3poqWwty1t6F+qgYQ2pISp2C1esinGQSq5xMOlLPR9 y46QKtdXxZkYBP2MjtRw==; 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 1hQQjr-0003KD-41; Tue, 14 May 2019 06:16:35 +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 1hQQhY-0007ZG-Ho; Tue, 14 May 2019 06:14:18 +0000 X-UUID: 576fda712ce14e60a46596b2b0a389a7-20190513 X-UUID: 576fda712ce14e60a46596b2b0a389a7-20190513 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLS) with ESMTP id 251968824; Mon, 13 May 2019 22:14:04 -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, 13 May 2019 23:14:03 -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, 14 May 2019 14:13:54 +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, 14 May 2019 14:13:54 +0800 From: Stu Hsieh To: Mauro Carvalho Chehab , Rob Herring , CK Hu Subject: [PATCH v3 05/13] [media] mtk-mipicsi: get the w/h/bytepwerline for mtk_mipicsi Date: Tue, 14 May 2019 14:13:42 +0800 Message-ID: <1557814430-9675-6-git-send-email-stu.hsieh@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557814430-9675-1-git-send-email-stu.hsieh@mediatek.com> References: <1557814430-9675-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-20190513_231412_943612_B581DB4B X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patch get the w/h/bytepwerline to save in mtk_mipicsi. Signed-off-by: Stu Hsieh --- .../media/platform/mtk-mipicsi/mtk_mipicsi.c | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c index 9c65b96456c4..920848e965e3 100644 --- a/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c +++ b/drivers/media/platform/mtk-mipicsi/mtk_mipicsi.c @@ -132,6 +132,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 | \ @@ -143,13 +146,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); @@ -158,6 +184,21 @@ 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) || (width > MAX_SUPPORT_WIDTH) || + (height == 0U) || (height > MAX_SUPPORT_HEIGHT) || + (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 -- 2.18.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel