Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2791011yba; Mon, 8 Apr 2019 04:58:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqwYprRUod7UJJlpT0FMVVjcz2dOOfmGX9x6S704KyuseMITskhoXjEM/4BSRKZxrFImFHYy X-Received: by 2002:a17:902:9a95:: with SMTP id w21mr28669524plp.74.1554724724988; Mon, 08 Apr 2019 04:58:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554724724; cv=none; d=google.com; s=arc-20160816; b=xw7coYBOWXyMjPf0ubSyA2e8FAbhdIbQlbJnHBpJ3rXRm3AvcCr6iMKbm8Z34TjXoo IHSS1p6kGVy+rKCJ9Z/Of3tkC6v/FuYJdcRCzKCWsc7madI2Ph1632vfBqIxTqWJaz+D kuTlThKOV1T5Q0wgfKXEmla7Xgh8ZUllYdcyNbJc4T95qsqx+d0yAsBvdkoQtc3Hl78H 0sq+LGZr5Yrog7zNTpR3eSbTpgSb/ff/F0+LZuHJC89rY1TlsLZoE0lpZj7VRRTfkwmD HPpYKFeK4h1jSxxD3HocbEWYxnT3xuaH3VyzOiNJrsOTJR6fi7+xc9BHvBr77TQJNP0+ 4iMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=ahiT7TzjBou9k21/LQmbaG+utjnWfz9Dg8bcDz1e2MU=; b=vGqeNro0vA8jsHFy2SWzttNReHg8un+PNUX6rsbWPPexjtuyUNNW/FCih+/sS5ys9Z KXKyltKACDT7UKFopaPzjyUb7MKrZ0tdTplUWOaT2gB9JrktsXqFSxQGMGTYzMOiiV8c lvX5QnaWLVG64NM/md1hxZulomPhxLciVKoRGPnNRSp4EN938Kc+9uWFK9WVTEHycDiQ vtwabhLSMLQWH8W0leBSng2jDMCbdRxRvLu6VqPAcSFR5C/qxwWg/qZAzpCrY5lPXVIm 0ctV1uYqtsfNQLIlZslsYHg4KSGcIhUWD1879VE0/vEFK067WVKb7vctrPefz4j8cA/A qC4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h15si17438522pgv.169.2019.04.08.04.58.30; Mon, 08 Apr 2019 04:58:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726731AbfDHLzg (ORCPT + 99 others); Mon, 8 Apr 2019 07:55:36 -0400 Received: from mailgw01.mediatek.com ([210.61.82.183]:46273 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726401AbfDHLzc (ORCPT ); Mon, 8 Apr 2019 07:55:32 -0400 X-UUID: 9f66060c3e2a4549bc5113c4906cb91d-20190408 X-UUID: 9f66060c3e2a4549bc5113c4906cb91d-20190408 Received: from mtkcas09.mediatek.inc [(172.21.101.178)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1300803878; Mon, 08 Apr 2019 19:55:25 +0800 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 CC: Stu Hsieh , , , , , 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 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 | 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 -- 2.18.0