From patchwork Fri Feb 10 20:27:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9567465 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 77AD260573 for ; Fri, 10 Feb 2017 20:28:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 687552859A for ; Fri, 10 Feb 2017 20:28:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C123285C5; Fri, 10 Feb 2017 20:28:04 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F37C6285AE for ; Fri, 10 Feb 2017 20:28:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932143AbdBJU2D (ORCPT ); Fri, 10 Feb 2017 15:28:03 -0500 Received: from mail.kernel.org ([198.145.29.136]:45792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932133AbdBJU2C (ORCPT ); Fri, 10 Feb 2017 15:28:02 -0500 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 095352012D; Fri, 10 Feb 2017 20:28:01 +0000 (UTC) Received: from CookieMonster.cookiemonster.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18DD22026C; Fri, 10 Feb 2017 20:27:58 +0000 (UTC) From: Kieran Bingham To: laurent.pinchart@ideasonboard.com, linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, kieran.bingham@ideasonboard.com Cc: Kieran Bingham Subject: [PATCH 8/8] v4l: vsp1: Implement left edge partition algorithm overlap Date: Fri, 10 Feb 2017 20:27:36 +0000 Message-Id: <19c6a7d542809dc814b5dfb11ba8ab737eab56f9.1486758327.git-series.kieran.bingham+renesas@ideasonboard.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Increase the overlap on the left edge to allow a margin to provide better image scaling Signed-off-by: Kieran Bingham --- drivers/media/platform/vsp1/vsp1_rpf.c | 7 +++++- drivers/media/platform/vsp1/vsp1_uds.c | 39 ++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/vsp1/vsp1_rpf.c b/drivers/media/platform/vsp1/vsp1_rpf.c index 94541ab4ca36..d08cfd944b7b 100644 --- a/drivers/media/platform/vsp1/vsp1_rpf.c +++ b/drivers/media/platform/vsp1/vsp1_rpf.c @@ -247,6 +247,13 @@ struct vsp1_partition_rect *rpf_partition(struct vsp1_entity *entity, /* Duplicate the target configuration to the RPF */ partition->rpf = *dest; + /* + * A partition offset, is a request for more input pixels, and a + * declaration that the consumer will clip excess. + */ + partition->rpf.width += dest->offset; + partition->rpf.left -= dest->offset; + return &partition->rpf; } diff --git a/drivers/media/platform/vsp1/vsp1_uds.c b/drivers/media/platform/vsp1/vsp1_uds.c index 9c1fb7ef3c46..9ee476c8db59 100644 --- a/drivers/media/platform/vsp1/vsp1_uds.c +++ b/drivers/media/platform/vsp1/vsp1_uds.c @@ -81,6 +81,20 @@ static struct uds_phase uds_phase_calculation(int position, int start_phase, return phase; } +static int uds_left_src_pixel(int pos, int start_phase, int ratio) +{ + struct uds_phase phase; + + phase = uds_phase_calculation(pos, start_phase, ratio); + + /* Renesas guard against odd values in these scale ratios here ? */ + if ((phase.mp == 2 && (phase.residual & 0x01)) || + (phase.mp == 4 && (phase.residual & 0x03))) + WARN_ON(1); + + return phase.mp * (phase.prefilt_outpos + (phase.residual ? 1 : 0)); +} + static int uds_start_phase(int pos, int start_phase, int ratio) { struct uds_phase phase; @@ -420,6 +434,8 @@ struct vsp1_partition_rect *uds_partition(struct vsp1_entity *entity, const struct v4l2_mbus_framefmt *input; unsigned int hscale; unsigned int image_start_phase = 0; + unsigned int right_sink; + unsigned int margin; /* Initialise the partition state */ partition->uds_sink = *dest; @@ -432,10 +448,25 @@ struct vsp1_partition_rect *uds_partition(struct vsp1_entity *entity, hscale = uds_compute_ratio(input->width, output->width); - partition->uds_sink.width = dest->width * input->width - / output->width; - partition->uds_sink.left = dest->left * input->width - / output->width; + /* Handle 'left' edge of the partitions */ + if (partition_idx == 0) { + margin = 0; + } else { + margin = hscale < 0x200 ? 32 : /* 8 < scale */ + hscale < 0x400 ? 16 : /* 4 < scale <= 8 */ + hscale < 0x800 ? 8 : /* 2 < scale <= 4 */ + 4; /* 1 < scale <= 2, scale <= 1 */ + } + + partition->uds_sink.left = uds_left_src_pixel(dest->left, + image_start_phase, hscale); + + partition->uds_sink.offset = margin; + + right_sink = uds_left_src_pixel(dest->left + dest->width - 1, + image_start_phase, hscale); + + partition->uds_sink.width = right_sink - partition->uds_sink.left + 1; partition->start_phase = uds_start_phase(partition->uds_source.left, image_start_phase, hscale);