From patchwork Mon Jul 17 10:33:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 107890 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4342283qge; Mon, 17 Jul 2017 03:37:13 -0700 (PDT) X-Received: by 10.98.101.4 with SMTP id z4mr17993533pfb.163.1500287833751; Mon, 17 Jul 2017 03:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500287833; cv=none; d=google.com; s=arc-20160816; b=f2mP7AmqsImcxm0mz+byHY967ibxFLuP+GQ8u2FIhPm1OISKN9PuIEZvF9aJRuHApj i5SKX/UFHTBEVsVJkJ61e41D+onubTqdUIUdyKtyKHrSZuquDtj7EqpqW90aZl72MKTz EtIgVrGvIiCn001OnhDcKpZ3sJJuEjj6LnklrKvRXsg9iVIDE/d7jdvM/keOxRAh80Xy juRWh49I3Hwjc5ug5DsTD1xZFLd07Z+67ovHdzTCbsPzRL1f+gviBTO08n11ZT6sM7Sj 88CP8lfb56VXESbKNsEAsJDOcLX3KBZdxy3BWKB88dIHT0T6Yprp41iBUeO2pzb+F9Q7 xaNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=CIaFGDlJmH9uihAdMssa4Tc083cScIekfw6JBsPzao0=; b=On2HCv5ypFtcQ7Oujn0hVDbwh41QqLI9ztV3HEJokC8ZqzEORxQtfJOXP5jK48yZr3 bVHlwbTNGuG9AeJtqnDzYLRUxV4wFdS6QQ6RJKfaVWZUqCbbXF0JB1OdobTSEH/GKnHy avNvw1km2P19uicruRg4tElVsVmaUh77qCLanszAfoSgVWHhMCnCx4VArsxzQQMl7HTy 43Gthsi5bmRkAvRRIkqhclFCz2DFpvWIAuehBXj+7NTKCpeIvhrSOUdDWUeHuCux5BQM jWE0TaposzEH8WH9mHxjdzxbyYfFQIb2QIfCPqIt9mCYJ+TYr+psntJ8OE/RxQRhlVXf kooQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u23si2163569plk.406.2017.07.17.03.37.13; Mon, 17 Jul 2017 03:37:13 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751612AbdGQKg4 (ORCPT + 25 others); Mon, 17 Jul 2017 06:36:56 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:36185 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751407AbdGQKfH (ORCPT ); Mon, 17 Jul 2017 06:35:07 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 62A02CBF4; Mon, 17 Jul 2017 13:34:59 +0300 (EEST) From: Todor Tomov To: mchehab@kernel.org, hans.verkuil@cisco.com, javier@osg.samsung.com, s.nawrocki@samsung.com, sakari.ailus@iki.fi, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Todor Tomov Subject: [PATCH v3 20/23] camss: vfe: Configure crop module in VFE Date: Mon, 17 Jul 2017 13:33:46 +0300 Message-Id: <1500287629-23703-21-git-send-email-todor.tomov@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500287629-23703-1-git-send-email-todor.tomov@linaro.org> References: <1500287629-23703-1-git-send-email-todor.tomov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add crop module configuration support to be able to apply cropping. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss-8x16/camss-vfe.c | 41 +++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c index 17617c0..8fd0ed9 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c @@ -57,6 +57,7 @@ #define VFE_0_MODULE_CFG_DEMUX (1 << 2) #define VFE_0_MODULE_CFG_CHROMA_UPSAMPLE (1 << 3) #define VFE_0_MODULE_CFG_SCALE_ENC (1 << 23) +#define VFE_0_MODULE_CFG_CROP_ENC (1 << 27) #define VFE_0_CORE_CFG 0x01c #define VFE_0_CORE_CFG_PIXEL_PATTERN_YCBYCR 0x4 @@ -194,6 +195,11 @@ #define VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE 0x790 #define VFE_0_SCALE_ENC_CBCR_V_PHASE 0x794 +#define VFE_0_CROP_ENC_Y_WIDTH 0x854 +#define VFE_0_CROP_ENC_Y_HEIGHT 0x858 +#define VFE_0_CROP_ENC_CBCR_WIDTH 0x85c +#define VFE_0_CROP_ENC_CBCR_HEIGHT 0x860 + #define VFE_0_CLAMP_ENC_MAX_CFG 0x874 #define VFE_0_CLAMP_ENC_MIN_CFG 0x878 @@ -717,6 +723,37 @@ static void vfe_set_scale_cfg(struct vfe_device *vfe, struct vfe_line *line) writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PHASE); } +static void vfe_set_crop_cfg(struct vfe_device *vfe, struct vfe_line *line) +{ + u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; + u32 reg; + u16 first, last; + + first = line->crop.left; + last = line->crop.left + line->crop.width - 1; + reg = (first << 16) | last; + writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_WIDTH); + + first = line->crop.top; + last = line->crop.top + line->crop.height - 1; + reg = (first << 16) | last; + writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_Y_HEIGHT); + + first = line->crop.left / 2; + last = line->crop.left / 2 + line->crop.width / 2 - 1; + reg = (first << 16) | last; + writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_WIDTH); + + first = line->crop.top; + last = line->crop.top + line->crop.height - 1; + if (p == V4L2_PIX_FMT_NV12 || p == V4L2_PIX_FMT_NV21) { + first = line->crop.top / 2; + last = line->crop.top / 2 + line->crop.height / 2 - 1; + } + reg = (first << 16) | last; + writel_relaxed(reg, vfe->base + VFE_0_CROP_ENC_CBCR_HEIGHT); +} + static void vfe_set_clamp_cfg(struct vfe_device *vfe) { writel_relaxed(0x00ffffff, vfe->base + VFE_0_CLAMP_ENC_MAX_CFG); @@ -829,7 +866,8 @@ static void vfe_set_module_cfg(struct vfe_device *vfe, u8 enable) { u32 val = VFE_0_MODULE_CFG_DEMUX | VFE_0_MODULE_CFG_CHROMA_UPSAMPLE | - VFE_0_MODULE_CFG_SCALE_ENC; + VFE_0_MODULE_CFG_SCALE_ENC | + VFE_0_MODULE_CFG_CROP_ENC; if (enable) writel_relaxed(val, vfe->base + VFE_0_MODULE_CFG); @@ -1304,6 +1342,7 @@ static int vfe_enable_output(struct vfe_line *line) vfe_set_xbar_cfg(vfe, output, 1); vfe_set_demux_cfg(vfe, line); vfe_set_scale_cfg(vfe, line); + vfe_set_crop_cfg(vfe, line); vfe_set_clamp_cfg(vfe); vfe_set_camif_cmd(vfe, VFE_0_CAMIF_CMD_ENABLE_FRAME_BOUNDARY); }