From patchwork Mon Jul 17 10:33:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Todor Tomov X-Patchwork-Id: 107893 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4343466qge; Mon, 17 Jul 2017 03:38:35 -0700 (PDT) X-Received: by 10.84.217.132 with SMTP id p4mr2607717pli.217.1500287914928; Mon, 17 Jul 2017 03:38:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500287914; cv=none; d=google.com; s=arc-20160816; b=WEnTR5WEaIzKNHFDh/o+abOdy9mJyT73CLBj8lEU+GSukvsPmkPZapbY2Do6jWF/UM YDWZxUFbGRqPstBbtzVVszboRu48DTxfpmWseq8aGlNNHrahSdhjk0PmOVuUrnyXu+4W qfJVykv4Fmx83fTT0zzPvlB6Meu6fIdEmTyxXDw9oXBxHjwS6hTQOEMwiQ8entg0VdCC epyyXaFtFVP6SasnSj7Z0nli94imEB+pvOzZKZ6hjvXdFNWkxX8NaLJisEQ3EakNywgO n/IP3w/A4Gd7rnafuJ8k1h0MFZBAHAo0PQYMnSh/yiYVKEwcJl7kLM7s4PcVCWfe7G2W tVig== 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=zzgy6D/VgW00zwYKLFz3EDCmLCSBifkWXjEMM9RjnN0=; b=TCqWhCGVXL7EQ9msgQ/p2oxSidTV9akEFWQBkq4z1XJV2dQ9ni+K3ACHlPD7QfJU8I hbXfVDNNMj3iPNpw0PtfIlrzu3hnWq0AQL+Roq1ZBVQ2JxNkAV6tJtvLBZKxNq6sRVFB jKCb6JCMI724Rrunf9oVOAnRquG84i8E01W40/MzhOEHxnRheoEHxuCAKxI18OhJpqWR X5dNDAk1m+4Wu8BN8NWpngkaMB8gE65PAN142VON+PJF0vfZQBVfphapWLB5+vQk+QSD a7/U6O2nZwxa2qR/eqhp2sNwANFf2/NkDtQ12NlAFzHSjXCatXbGy/7qA7vrVr4u3rKA nRnA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 r1si8580355pge.84.2017.07.17.03.38.34; Mon, 17 Jul 2017 03:38:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-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 S1751430AbdGQKib (ORCPT + 4 others); Mon, 17 Jul 2017 06:38:31 -0400 Received: from ns.mm-sol.com ([37.157.136.199]:36170 "EHLO extserv.mm-sol.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751405AbdGQKfG (ORCPT ); Mon, 17 Jul 2017 06:35:06 -0400 Received: from mms-0439.qualcomm.mm-sol.com (unknown [37.157.136.206]) by extserv.mm-sol.com (Postfix) with ESMTPSA id 418B5CBF2; 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 18/23] camss: vfe: Configure scaler module in VFE Date: Mon, 17 Jul 2017 13:33:44 +0300 Message-Id: <1500287629-23703-19-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-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add scaler module configuration support to be able to apply scaling. Signed-off-by: Todor Tomov --- drivers/media/platform/qcom/camss-8x16/camss-vfe.c | 59 +++++++++++++++++----- 1 file changed, 46 insertions(+), 13 deletions(-) -- 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 8ec6ce7..f994b35 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c @@ -183,13 +183,16 @@ #define VFE_0_DEMUX_EVEN_CFG 0x438 #define VFE_0_DEMUX_ODD_CFG 0x43c +#define VFE_0_SCALE_ENC_Y_CFG 0x75c +#define VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE 0x760 +#define VFE_0_SCALE_ENC_Y_H_PHASE 0x764 +#define VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE 0x76c +#define VFE_0_SCALE_ENC_Y_V_PHASE 0x770 #define VFE_0_SCALE_ENC_CBCR_CFG 0x778 #define VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE 0x77c #define VFE_0_SCALE_ENC_CBCR_H_PHASE 0x780 -#define VFE_0_SCALE_ENC_CBCR_H_PAD 0x78c #define VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE 0x790 #define VFE_0_SCALE_ENC_CBCR_V_PHASE 0x794 -#define VFE_0_SCALE_ENC_CBCR_V_PAD 0x7a0 #define VFE_0_CLAMP_ENC_MAX_CFG 0x874 #define VFE_0_CLAMP_ENC_MIN_CFG 0x878 @@ -645,6 +648,20 @@ static void vfe_set_demux_cfg(struct vfe_device *vfe, struct vfe_line *line) writel_relaxed(odd_cfg, vfe->base + VFE_0_DEMUX_ODD_CFG); } +static inline u8 vfe_calc_interp_reso(u16 input, u16 output) +{ + if (input / output >= 16) + return 0; + + if (input / output >= 8) + return 1; + + if (input / output >= 4) + return 2; + + return 3; +} + static void vfe_set_scale_cfg(struct vfe_device *vfe, struct vfe_line *line) { u32 p = line->video_out.active_fmt.fmt.pix_mp.pixelformat; @@ -653,35 +670,51 @@ static void vfe_set_scale_cfg(struct vfe_device *vfe, struct vfe_line *line) u8 interp_reso; u32 phase_mult; + writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_Y_CFG); + + input = line->fmt[MSM_VFE_PAD_SINK].width; + output = line->compose.width; + reg = (output << 16) | input; + writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_IMAGE_SIZE); + + interp_reso = vfe_calc_interp_reso(input, output); + phase_mult = input * (1 << (13 + interp_reso)) / output; + reg = (interp_reso << 20) | phase_mult; + writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_H_PHASE); + + input = line->fmt[MSM_VFE_PAD_SINK].height; + output = line->compose.height; + reg = (output << 16) | input; + writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_IMAGE_SIZE); + + interp_reso = vfe_calc_interp_reso(input, output); + phase_mult = input * (1 << (13 + interp_reso)) / output; + reg = (interp_reso << 20) | phase_mult; + writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_Y_V_PHASE); + writel_relaxed(0x3, vfe->base + VFE_0_SCALE_ENC_CBCR_CFG); input = line->fmt[MSM_VFE_PAD_SINK].width; - output = line->fmt[MSM_VFE_PAD_SRC].width / 2; + output = line->compose.width / 2; reg = (output << 16) | input; writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_IMAGE_SIZE); - interp_reso = 3; + interp_reso = vfe_calc_interp_reso(input, output); phase_mult = input * (1 << (13 + interp_reso)) / output; reg = (interp_reso << 20) | phase_mult; writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_PHASE); - reg = input; - writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_H_PAD); - input = line->fmt[MSM_VFE_PAD_SINK].height; - output = line->fmt[MSM_VFE_PAD_SRC].height; + output = line->compose.height; if (p == V4L2_PIX_FMT_NV12 || p == V4L2_PIX_FMT_NV21) - output = line->fmt[MSM_VFE_PAD_SRC].height / 2; + output = line->compose.height / 2; reg = (output << 16) | input; writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_IMAGE_SIZE); - interp_reso = 3; + interp_reso = vfe_calc_interp_reso(input, output); phase_mult = input * (1 << (13 + interp_reso)) / output; reg = (interp_reso << 20) | phase_mult; writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PHASE); - - reg = input; - writel_relaxed(reg, vfe->base + VFE_0_SCALE_ENC_CBCR_V_PAD); } static void vfe_set_clamp_cfg(struct vfe_device *vfe)