From patchwork Wed Oct 17 00:00:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644427 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C43C317D4 for ; Wed, 17 Oct 2018 00:00:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B71592A46E for ; Wed, 17 Oct 2018 00:00:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B56292A5B7; Wed, 17 Oct 2018 00:00:40 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 659042A46E for ; Wed, 17 Oct 2018 00:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbeJQHxa (ORCPT ); Wed, 17 Oct 2018 03:53:30 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43715 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbeJQHxa (ORCPT ); Wed, 17 Oct 2018 03:53:30 -0400 Received: by mail-pf1-f194.google.com with SMTP id p24-v6so12230360pff.10; Tue, 16 Oct 2018 17:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2w39VPGeACVECakpqzPDeuelU4Bi3JR8Jg1vqW985jw=; b=fch5ZbLDtkRdqeCuC6PK0FaH/6+3muOuSRQ0SAYOZD6DHjRqq/nAlDE1t97Q6V1Cwx EdliQ3GvyMQa5Gz3H/jBieLgENFC0XkXL1WI/hS0RrmOyMeO/vlrsSkzxx1W21Wuo9pS Irg+W6nQYDEg71J9aKbcPJpZnFzqwafE2SMOi2uxbzJfnlzhW5fURzyZh/QwiFvIr2x0 WgQRj/gJ3JXN1tzx2DURCgh4vCOgdHLp/wXf6z8K7E0dMPt5wcHMwQRkEyg2xGz3egeS NI3kRglgmIkB8O4idDnw/IdOl28NFROCxq7m5aEt/E9XUDMKyri1UHGtS9XbYw9BJ/rU OclQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2w39VPGeACVECakpqzPDeuelU4Bi3JR8Jg1vqW985jw=; b=ue2F/oDx6oUfv/R3PXXCHjquUH8eshjA/D8+8PN9EQ1VPTcFbsjmVVOsaFlazis1Bg 5T+kno314r6e8g/VmDNpWbsntt4Jt4ft592J6eLDTaP97JNTJ96OjKuLM5aJY3ivTRNA /s1H8QPaasiKQtck4YCjUbrTxiGIvxkvpHdqn4WYSMVTR2YGBOB/xb5+OX5cZO5sUNnV 6vuJyOvZ4Sug7rj81l5iUIJBfR5OPPrt6gUtiDNfGLVnpg/G4TIgp5NPsydToLUTydlq vBd9F37mfsbTuMSg9UfOQINxyiUxnkt6PYvpGSn6zY2GKzyd2QVy5ULFnr/eFvgsnSVP 1/UA== X-Gm-Message-State: ABuFfojTJ6Rj9ClADq9Et+9RW1TCoATBwQVvVelN8k70YCzrdXtUvAJL LwMuGvMZ+sjif3yhWIB0KyYsmlh8 X-Google-Smtp-Source: ACcGV63MxODiuLg+UXUunUCWi0wBI9D2Gckah0ba2SyB1SLsXTsCFrC3gdMgDfUHAxcV7gBJe0Fl2g== X-Received: by 2002:a62:f553:: with SMTP id n80-v6mr24097025pfh.59.1539734437830; Tue, 16 Oct 2018 17:00:37 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:36 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 01/12] media: videodev2.h: Add more field helper macros Date: Tue, 16 Oct 2018 17:00:16 -0700 Message-Id: <20181017000027.23696-2-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adds two helper macros: V4L2_FIELD_IS_SEQUENTIAL: returns true if the given field type is 'sequential', that is a full frame is transmitted, or exists in memory, as all top field lines followed by all bottom field lines, or vice-versa. V4L2_FIELD_IS_INTERLACED: returns true if the given field type is 'interlaced', that is a full frame is transmitted, or exists in memory, as top field lines interlaced with bottom field lines. Signed-off-by: Steve Longerbeam --- Changes since v3: - none Changes since v2: - none Changes since v1: - add the complement macro V4L2_FIELD_IS_INTERLACED - remove V4L2_FIELD_ALTERNATE from V4L2_FIELD_IS_SEQUENTIAL macro. - moved new macros past end of existing V4L2_FIELD_HAS_* macros. --- include/uapi/linux/videodev2.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 29729d580452..f7f031736d91 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h @@ -130,6 +130,13 @@ enum v4l2_field { ((field) == V4L2_FIELD_BOTTOM ||\ (field) == V4L2_FIELD_TOP ||\ (field) == V4L2_FIELD_ALTERNATE) +#define V4L2_FIELD_IS_INTERLACED(field) \ + ((field) == V4L2_FIELD_INTERLACED ||\ + (field) == V4L2_FIELD_INTERLACED_TB ||\ + (field) == V4L2_FIELD_INTERLACED_BT) +#define V4L2_FIELD_IS_SEQUENTIAL(field) \ + ((field) == V4L2_FIELD_SEQ_TB ||\ + (field) == V4L2_FIELD_SEQ_BT) enum v4l2_buf_type { V4L2_BUF_TYPE_VIDEO_CAPTURE = 1, From patchwork Wed Oct 17 00:00:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644429 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 01A9E17D4 for ; Wed, 17 Oct 2018 00:00:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6D182A5C7 for ; Wed, 17 Oct 2018 00:00:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB4332A5AD; Wed, 17 Oct 2018 00:00:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 09C972A602 for ; Wed, 17 Oct 2018 00:00:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727498AbeJQHxd (ORCPT ); Wed, 17 Oct 2018 03:53:33 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44641 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727171AbeJQHxb (ORCPT ); Wed, 17 Oct 2018 03:53:31 -0400 Received: by mail-pf1-f193.google.com with SMTP id r9-v6so12230477pff.11; Tue, 16 Oct 2018 17:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Qm4xfTw+EXkRYWczhf78ede2S6Obp9s1X/mYBD38YOs=; b=lUZYG6X3dicbSjJrEi1ShPvNpSWhTX7pUqlfNMdcj1P2Yksa10gVRiOZHoAU+HilCk gcPJEWhz5L2dW8oDjxelLEOoC2PMYNkMDyObo3XFgdcA82eazvwD+01EffYnsUXBHmWU xv6UB/H+Vtu70P7mCbNMMHzOOLFMB1vOY4K9wgbxFbOTRcsIndCHkuJdZGeIT+o2GJ9s XJZCvP9vmfRsF2El+vcn/6/vVX0EPW8NPbFB9jYYrRtiEVuC7LDRfih4ZNSPXbm6dS5M 696fTJobj2MilUbukQIqR6RkWKJe/aD4yoTc+XHV13UxwyseVQ4kzcBvnnXVJlG26rQ5 1I6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Qm4xfTw+EXkRYWczhf78ede2S6Obp9s1X/mYBD38YOs=; b=JhtQiWkuOIrv1jaddEbeRrfBkGZ6A0D/4MKij1gKa91gn3+xxYoTpKR4zpkoFF4ghS 7hGadfCivT2h5bsAWKhRvUuN4VU85QlWBYuvCnq6Kj9QEHMPnJgxMsPnnFt0NV0/SBRJ /BfAttRDCNtopcFsXcYU1hl6WzrJLnDA2KFyWmM2FUiHiro9eiV1pdyWUBv/CBDZ6+eu dyBwHWdNxqRI0F7EmwXS3szWHi5pNcgDbEF4eJ0rYn391Z8hGWN/JYIxdZgTio+AZPvt O+FIDhyeKMhShZPhN3Q/eDn1qzFgoAGCvk7TfUJnc2hln1EyohurCxIu7Iu6XGUfjcU2 xb9w== X-Gm-Message-State: ABuFfojGa//Y47rpphD98WRonlLr39sqvL6feHG54YL3WOML54oEAjND AlhwSRt71onAdchRN9uaM9BvvMMm X-Google-Smtp-Source: ACcGV611UtF11i9YxA+MBIo20H7EKT+z2kuzgOgYei0OyytjGJjWa6jUTgKrqBTbklKtlPIdhzdbfw== X-Received: by 2002:a63:3642:: with SMTP id d63-v6mr21917268pga.404.1539734439630; Tue, 16 Oct 2018 17:00:39 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:38 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-fbdev@vger.kernel.org (open list:FRAMEBUFFER LAYER) Subject: [PATCH v5 02/12] gpu: ipu-csi: Swap fields according to input/output field types Date: Tue, 16 Oct 2018 17:00:17 -0700 Message-Id: <20181017000027.23696-3-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The function ipu_csi_init_interface() was inverting the F-bit for NTSC case, in the CCIR_CODE_1/2 registers. The result being that for NTSC bottom-top field order, the CSI would swap fields and capture in top-bottom order. Instead, base field swap on the field order of the input to the CSI, and the field order of the requested output. If the input/output fields are sequential but different, swap fields, otherwise do not swap. This requires passing both the input and output mbus frame formats to ipu_csi_init_interface(). Move this code to a new private function ipu_csi_set_bt_interlaced_codes() that programs the CCIR_CODE_1/2 registers for interlaced BT.656 (and possibly interlaced BT.1120 in the future). When detecting input video standard from the input frame width/height, make sure to double height if input field type is alternate, since in that case input height only includes lines for one field. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- Changes since v4: - Cleaned up some convoluted code in ipu_csi_init_interface(), suggested by Philipp Zabel. - Fixed a regression in csi_setup(), caught by Philipp. --- drivers/gpu/ipu-v3/ipu-csi.c | 119 +++++++++++++++------- drivers/staging/media/imx/imx-media-csi.c | 17 +--- include/video/imx-ipu-v3.h | 3 +- 3 files changed, 88 insertions(+), 51 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-csi.c b/drivers/gpu/ipu-v3/ipu-csi.c index aa0e30a2ba18..4a15e513fa05 100644 --- a/drivers/gpu/ipu-v3/ipu-csi.c +++ b/drivers/gpu/ipu-v3/ipu-csi.c @@ -325,6 +325,15 @@ static int mbus_code_to_bus_cfg(struct ipu_csi_bus_config *cfg, u32 mbus_code, return 0; } +/* translate alternate field mode based on given standard */ +static inline enum v4l2_field +ipu_csi_translate_field(enum v4l2_field field, v4l2_std_id std) +{ + return (field != V4L2_FIELD_ALTERNATE) ? field : + ((std & V4L2_STD_525_60) ? + V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB); +} + /* * Fill a CSI bus config struct from mbus_config and mbus_framefmt. */ @@ -374,22 +383,75 @@ static int fill_csi_bus_cfg(struct ipu_csi_bus_config *csicfg, return 0; } +static int ipu_csi_set_bt_interlaced_codes(struct ipu_csi *csi, + struct v4l2_mbus_framefmt *infmt, + struct v4l2_mbus_framefmt *outfmt, + v4l2_std_id std) +{ + enum v4l2_field infield, outfield; + bool swap_fields; + + /* get translated field type of input and output */ + infield = ipu_csi_translate_field(infmt->field, std); + outfield = ipu_csi_translate_field(outfmt->field, std); + + /* + * Write the H-V-F codes the CSI will match against the + * incoming data for start/end of active and blanking + * field intervals. If input and output field types are + * sequential but not the same (one is SEQ_BT and the other + * is SEQ_TB), swap the F-bit so that the CSI will capture + * field 1 lines before field 0 lines. + */ + swap_fields = (V4L2_FIELD_IS_SEQUENTIAL(infield) && + V4L2_FIELD_IS_SEQUENTIAL(outfield) && + infield != outfield); + + if (!swap_fields) { + /* + * Field0BlankEnd = 110, Field0BlankStart = 010 + * Field0ActiveEnd = 100, Field0ActiveStart = 000 + * Field1BlankEnd = 111, Field1BlankStart = 011 + * Field1ActiveEnd = 101, Field1ActiveStart = 001 + */ + ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN, + CSI_CCIR_CODE_1); + ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2); + } else { + dev_dbg(csi->ipu->dev, "capture field swap\n"); + + /* same as above but with F-bit inverted */ + ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN, + CSI_CCIR_CODE_1); + ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2); + } + + ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); + + return 0; +} + + int ipu_csi_init_interface(struct ipu_csi *csi, struct v4l2_mbus_config *mbus_cfg, - struct v4l2_mbus_framefmt *mbus_fmt) + struct v4l2_mbus_framefmt *infmt, + struct v4l2_mbus_framefmt *outfmt) { struct ipu_csi_bus_config cfg; unsigned long flags; u32 width, height, data = 0; + v4l2_std_id std; int ret; - ret = fill_csi_bus_cfg(&cfg, mbus_cfg, mbus_fmt); + ret = fill_csi_bus_cfg(&cfg, mbus_cfg, infmt); if (ret < 0) return ret; /* set default sensor frame width and height */ - width = mbus_fmt->width; - height = mbus_fmt->height; + width = infmt->width; + height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + height *= 2; /* Set the CSI_SENS_CONF register remaining fields */ data |= cfg.data_width << CSI_SENS_CONF_DATA_WIDTH_SHIFT | @@ -416,42 +478,22 @@ int ipu_csi_init_interface(struct ipu_csi *csi, ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); break; case IPU_CSI_CLK_MODE_CCIR656_INTERLACED: - if (mbus_fmt->width == 720 && mbus_fmt->height == 576) { - /* - * PAL case - * - * Field0BlankEnd = 0x6, Field0BlankStart = 0x2, - * Field0ActiveEnd = 0x4, Field0ActiveStart = 0 - * Field1BlankEnd = 0x7, Field1BlankStart = 0x3, - * Field1ActiveEnd = 0x5, Field1ActiveStart = 0x1 - */ - height = 625; /* framelines for PAL */ - - ipu_csi_write(csi, 0x40596 | CSI_CCIR_ERR_DET_EN, - CSI_CCIR_CODE_1); - ipu_csi_write(csi, 0xD07DF, CSI_CCIR_CODE_2); - ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); - } else if (mbus_fmt->width == 720 && mbus_fmt->height == 480) { - /* - * NTSC case - * - * Field0BlankEnd = 0x7, Field0BlankStart = 0x3, - * Field0ActiveEnd = 0x5, Field0ActiveStart = 0x1 - * Field1BlankEnd = 0x6, Field1BlankStart = 0x2, - * Field1ActiveEnd = 0x4, Field1ActiveStart = 0 - */ - height = 525; /* framelines for NTSC */ - - ipu_csi_write(csi, 0xD07DF | CSI_CCIR_ERR_DET_EN, - CSI_CCIR_CODE_1); - ipu_csi_write(csi, 0x40596, CSI_CCIR_CODE_2); - ipu_csi_write(csi, 0xFF0000, CSI_CCIR_CODE_3); + if (width == 720 && height == 480) { + std = V4L2_STD_NTSC; + height = 525; + } else if (width == 720 && height == 576) { + std = V4L2_STD_PAL; + height = 625; } else { dev_err(csi->ipu->dev, - "Unsupported CCIR656 interlaced video mode\n"); - spin_unlock_irqrestore(&csi->lock, flags); - return -EINVAL; + "Unsupported interlaced video mode\n"); + ret = -EINVAL; + goto out_unlock; } + + ret = ipu_csi_set_bt_interlaced_codes(csi, infmt, outfmt, std); + if (ret) + goto out_unlock; break; case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_DDR: case IPU_CSI_CLK_MODE_CCIR1120_PROGRESSIVE_SDR: @@ -476,9 +518,10 @@ int ipu_csi_init_interface(struct ipu_csi *csi, dev_dbg(csi->ipu->dev, "CSI_ACT_FRM_SIZE = 0x%08X\n", ipu_csi_read(csi, CSI_ACT_FRM_SIZE)); +out_unlock: spin_unlock_irqrestore(&csi->lock, flags); - return 0; + return ret; } EXPORT_SYMBOL_GPL(ipu_csi_init_interface); diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 4223f8d418ae..7ecbd4d76d09 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -663,15 +663,14 @@ static void csi_idmac_stop(struct csi_priv *priv) /* Update the CSI whole sensor and active windows */ static int csi_setup(struct csi_priv *priv) { - struct v4l2_mbus_framefmt *infmt, *outfmt; + struct v4l2_mbus_framefmt infmt, outfmt; const struct imx_media_pixfmt *incc; struct v4l2_mbus_config mbus_cfg; - struct v4l2_mbus_framefmt if_fmt; struct v4l2_rect crop; - infmt = &priv->format_mbus[CSI_SINK_PAD]; + infmt = priv->format_mbus[CSI_SINK_PAD]; incc = priv->cc[CSI_SINK_PAD]; - outfmt = &priv->format_mbus[priv->active_output_pad]; + outfmt = priv->format_mbus[priv->active_output_pad]; /* compose mbus_config from the upstream endpoint */ mbus_cfg.type = priv->upstream_ep.bus_type; @@ -679,12 +678,6 @@ static int csi_setup(struct csi_priv *priv) priv->upstream_ep.bus.parallel.flags : priv->upstream_ep.bus.mipi_csi2.flags; - /* - * we need to pass input frame to CSI interface, but - * with translated field type from output format - */ - if_fmt = *infmt; - if_fmt.field = outfmt->field; crop = priv->crop; /* @@ -692,7 +685,7 @@ static int csi_setup(struct csi_priv *priv) * generic/bayer data */ if (is_parallel_bus(&priv->upstream_ep) && incc->cycles) { - if_fmt.width *= incc->cycles; + infmt.width *= incc->cycles; crop.width *= incc->cycles; } @@ -702,7 +695,7 @@ static int csi_setup(struct csi_priv *priv) priv->crop.width == 2 * priv->compose.width, priv->crop.height == 2 * priv->compose.height); - ipu_csi_init_interface(priv->csi, &mbus_cfg, &if_fmt); + ipu_csi_init_interface(priv->csi, &mbus_cfg, &infmt, &outfmt); ipu_csi_set_dest(priv->csi, priv->dest); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index abbad94e14a1..f44a35192313 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -352,7 +352,8 @@ int ipu_prg_channel_configure(struct ipuv3_channel *ipu_chan, struct ipu_csi; int ipu_csi_init_interface(struct ipu_csi *csi, struct v4l2_mbus_config *mbus_cfg, - struct v4l2_mbus_framefmt *mbus_fmt); + struct v4l2_mbus_framefmt *infmt, + struct v4l2_mbus_framefmt *outfmt); bool ipu_csi_is_interlaced(struct ipu_csi *csi); void ipu_csi_get_window(struct ipu_csi *csi, struct v4l2_rect *w); void ipu_csi_set_window(struct ipu_csi *csi, struct v4l2_rect *w); From patchwork Wed Oct 17 00:00:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644451 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 655A2157A for ; Wed, 17 Oct 2018 00:01:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 573DB2A687 for ; Wed, 17 Oct 2018 00:01:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4AFD32A795; Wed, 17 Oct 2018 00:01:46 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 DD9282A687 for ; Wed, 17 Oct 2018 00:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727508AbeJQHxe (ORCPT ); Wed, 17 Oct 2018 03:53:34 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44645 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbeJQHxd (ORCPT ); Wed, 17 Oct 2018 03:53:33 -0400 Received: by mail-pf1-f195.google.com with SMTP id r9-v6so12230508pff.11; Tue, 16 Oct 2018 17:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RZspm3Qdd+CBQ5BKu9QQloYDT701vAd6GkNdc0u66mg=; b=aLTqIUx6449r0/wvt7EcMkNMbg2siGLgfyQlqkmktGsYRXRZiYZgUwMI3PO+B8GYQl JZHlkWgSgUym8fgGEl8jEr3bayJMQLSYvb9tAt0Yu1ULyyF2UB8Nhvk6W8tG/tj6ih/Q 5a8SmfFBh7cGBlnNL3RIko2XBc+skW1YfEo2LDwNt4qQXbaYgnw7EYeir912lkLX9Tbq nkyGA8vOU9PGKnIy0BgYpIF1IloOeIdc68xMzR3715OdVbJG5yphClGRhd3fGiPjGvmW Z7LDJw6ZOkRAofQnCu2en43cVghR0+EugQZ+8FHUonGuE3JolDOL/W/Egkdra/qmX69g CSvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RZspm3Qdd+CBQ5BKu9QQloYDT701vAd6GkNdc0u66mg=; b=EnZRasW9NV+6rrCJd46/Esd4G2bX7XnLgioGyFBnnfbenWvP+wlzFtsV9m0NvDR+sP eBcO+uzsp1q1UXWfo9yg0Aix6DKw+lfliqVCq+FgcSb63fEMXWnvgdW0h2zDOc+vujvX 8DOsHCkoenpRRwWApcEkdGlFC7lH90y8RL7tTc10O12nDYLgIuvpAtOaG7V7eW+t7Wsq tdqaAKBC5N5IPBAI1ksZnzNfV3ZoW2P510TIOI/8I2KmK2M6qolW6qpJrJNZGy3ziLuH cybC6gVmIgtaignbUKWTQ6hFUFJX3oBC5Ftje6dByVISx1cf61CVMJd8BMIbgs3ofoEu 4kPA== X-Gm-Message-State: ABuFfogGlWJBKtLj/5eElF36hfPCZAUFCRWy711wL/b2NBKZK1UgeKO3 NaZIr55DohEPsLLLJVo6rXazd95V X-Google-Smtp-Source: ACcGV60sU/cxyy0ycn62tD00vyjxvSFR9J7WQPm0Qi5qxp5eYiyiTah4oQWvrcW93iQPQTfmmP8Qeg== X-Received: by 2002:a62:d206:: with SMTP id c6-v6mr9862711pfg.8.1539734441334; Tue, 16 Oct 2018 17:00:41 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:40 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , Bartlomiej Zolnierkiewicz , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR FREESCALE IMX), linux-kernel@vger.kernel.org (open list), devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-fbdev@vger.kernel.org (open list:FRAMEBUFFER LAYER) Subject: [PATCH v5 03/12] gpu: ipu-v3: Add planar support to interlaced scan Date: Tue, 16 Oct 2018 17:00:18 -0700 Message-Id: <20181017000027.23696-4-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To support interlaced scan with planar formats, cpmem SLUV must be programmed with the correct chroma line stride. For full and partial planar 4:2:2 (YUV422P, NV16), chroma line stride must be doubled. For full and partial planar 4:2:0 (YUV420, YVU420, NV12), chroma line stride must _not_ be doubled, since a single chroma line is shared by two luma lines. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel Acked-by: Philipp Zabel --- drivers/gpu/ipu-v3/ipu-cpmem.c | 26 +++++++++++++++++++-- drivers/staging/media/imx/imx-ic-prpencvf.c | 3 ++- drivers/staging/media/imx/imx-media-csi.c | 3 ++- include/video/imx-ipu-v3.h | 3 ++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/ipu-v3/ipu-cpmem.c b/drivers/gpu/ipu-v3/ipu-cpmem.c index a9d2501500a1..d41df8034c5b 100644 --- a/drivers/gpu/ipu-v3/ipu-cpmem.c +++ b/drivers/gpu/ipu-v3/ipu-cpmem.c @@ -273,9 +273,10 @@ void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off) } EXPORT_SYMBOL_GPL(ipu_cpmem_set_uv_offset); -void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride) +void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride, + u32 pixelformat) { - u32 ilo, sly; + u32 ilo, sly, sluv; if (stride < 0) { stride = -stride; @@ -286,9 +287,30 @@ void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride) sly = (stride * 2) - 1; + switch (pixelformat) { + case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: + sluv = stride / 2 - 1; + break; + case V4L2_PIX_FMT_NV12: + sluv = stride - 1; + break; + case V4L2_PIX_FMT_YUV422P: + sluv = stride - 1; + break; + case V4L2_PIX_FMT_NV16: + sluv = stride * 2 - 1; + break; + default: + sluv = 0; + break; + } + ipu_ch_param_write_field(ch, IPU_FIELD_SO, 1); ipu_ch_param_write_field(ch, IPU_FIELD_ILO, ilo); ipu_ch_param_write_field(ch, IPU_FIELD_SLY, sly); + if (sluv) + ipu_ch_param_write_field(ch, IPU_FIELD_SLUV, sluv); }; EXPORT_SYMBOL_GPL(ipu_cpmem_interlaced_scan); diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 28f41caba05d..af7224846bd5 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -412,7 +412,8 @@ static int prp_setup_channel(struct prp_priv *priv, if (image.pix.field == V4L2_FIELD_NONE && V4L2_FIELD_HAS_BOTH(infmt->field) && channel == priv->out_ch) - ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline); + ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, + image.pix.pixelformat); ret = ipu_ic_task_idma_init(priv->ic, channel, image.pix.width, image.pix.height, diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 7ecbd4d76d09..4aa20ae72608 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -512,7 +512,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) if (image.pix.field == V4L2_FIELD_NONE && V4L2_FIELD_HAS_BOTH(infmt->field)) ipu_cpmem_interlaced_scan(priv->idmac_ch, - image.pix.bytesperline); + image.pix.bytesperline, + image.pix.pixelformat); ipu_idmac_set_double_buffer(priv->idmac_ch, true); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index f44a35192313..e888c66b9d9d 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -255,7 +255,8 @@ void ipu_cpmem_set_stride(struct ipuv3_channel *ch, int stride); void ipu_cpmem_set_high_priority(struct ipuv3_channel *ch); void ipu_cpmem_set_buffer(struct ipuv3_channel *ch, int bufnum, dma_addr_t buf); void ipu_cpmem_set_uv_offset(struct ipuv3_channel *ch, u32 u_off, u32 v_off); -void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride); +void ipu_cpmem_interlaced_scan(struct ipuv3_channel *ch, int stride, + u32 pixelformat); void ipu_cpmem_set_axi_id(struct ipuv3_channel *ch, u32 id); int ipu_cpmem_get_burstsize(struct ipuv3_channel *ch); void ipu_cpmem_set_burstsize(struct ipuv3_channel *ch, int burstsize); From patchwork Wed Oct 17 00:00:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E6CAB157A for ; Wed, 17 Oct 2018 00:00:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71132A5CB for ; Wed, 17 Oct 2018 00:00:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB31E2A699; Wed, 17 Oct 2018 00:00:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 ECF4C2A5CB for ; Wed, 17 Oct 2018 00:00:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727568AbeJQHxf (ORCPT ); Wed, 17 Oct 2018 03:53:35 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40666 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727471AbeJQHxf (ORCPT ); Wed, 17 Oct 2018 03:53:35 -0400 Received: by mail-pg1-f193.google.com with SMTP id n31-v6so11604572pgm.7; Tue, 16 Oct 2018 17:00:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tGupLtCrLcyDF9k/0ilGtmDXmWL8CPouV9cE/AdG6B4=; b=kjPbI2qaKW35r63115kiKXIgPDfzfjjNHlngeXi2UVwPKqUQBvXo5YiRR1HX9id1Mi mh6v4JaLvZs0wfP1VPIjtwduE3Qg8LAu3oCs0pqdnjFt3Yc7z3eWRslQLqzUxM/BYhag jVsHlDFWtTVzB4a4O4fYRRlfYcQvWYGr3WPahibtRULUZTDRPFvQYbd7z27rDoLQb9fs VntjpEajhOXk3sSX+Z1+Y+/UUPUSni0Yrp9eXOpMKAFdthxw49D3kKB8ckIeOggXYSd7 c4uxsvSvz4eShuz4ZmzSoN2njsplmvnEKUWy9brADbiI5Kny0KvJ4Lpo2drhjMapkx+X 8bWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tGupLtCrLcyDF9k/0ilGtmDXmWL8CPouV9cE/AdG6B4=; b=W9muXsax2OdtXXvykWKTmYpfNwZJJe+SosSpL6Up8AoEGluINpAoGFkKCt8b8o2KeK SjOd1peCUXBskk6YHMqXqDrmYbnfc8DtZDQSU2zlxidPbHuM4XjFpG8qyt8vikZyVQiT FvUo9sDOCBMjqNKhT1IdxVcAc6QeMuubbnfU+U3nFWyy+i/WuPw6S5CTx+RauEOPoTnm JP76Gvg0KCslc6u17xqzX46n7FS8/MAVr1n44SJkK+2Yhc5E2DCEYaxHLrgKpJ0vpuzG rqXeUEjaKGKlgZq7toAnl4a/brw6fpbWPeCKdRqOHPr+gJHDdHm34CipGSnQ0YBN4tfz +gNg== X-Gm-Message-State: ABuFfoh4njUB1b0YKb1oGqJPynbbnVB6FSlIRtHg0yLrGMijzfIA11W3 xw4Ggf5+jkpq1QcHXwe8B6pI4eDA X-Google-Smtp-Source: ACcGV611laWqjTCTn7zPu1ZmDhnPj8r9ifJDYsgCCO+U6IfaBIuUF+r+yUHkJrejzhc2VseiKdQbpQ== X-Received: by 2002:a62:fcd8:: with SMTP id e207-v6mr23752706pfh.132.1539734443032; Tue, 16 Oct 2018 17:00:43 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:42 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 04/12] media: imx: Fix field negotiation Date: Tue, 16 Oct 2018 17:00:19 -0700 Message-Id: <20181017000027.23696-5-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP IDMAC interlaced scan, a.k.a. interweave, should be enabled in the IDMAC output channels only if the IDMAC output pad field type is 'seq-bt' or 'seq-tb', and field type at the capture interface is 'interlaced*'. V4L2_FIELD_HAS_BOTH() macro should not be used on the input to determine enabling interlaced/interweave scan. That macro includes the 'interlaced' field types, and in those cases the data is already interweaved with top/bottom field lines. The CSI will capture whole frames when the source specifies alternate field mode. So the CSI also enables interweave for alternate input field type and the field type at capture interface is interlaced. Fix the logic for setting field type in try_fmt in CSI entity. The behavior should be: - No restrictions on field type at sink pad. - At the output pads, allow sequential fields in TB order, if the sink pad field type is sequential or alternate. Otherwise passthrough the field type from sink to source pad. Move this logic to new function csi_try_field(). These changes result in the following allowed field transformations from CSI sink -> source pads (all other field types at sink are passed through to source): seq-tb -> seq-tb seq-bt -> seq-tb alternate -> seq-tb In a future patch, the CSI sink -> source will allow: seq-tb -> seq-bt seq-bt -> seq-bt alternate -> seq-bt This will require supporting interweave with top/bottom line swapping. Until then seq-bt is not allowed at the CSI source pad because there is no way to swap top/bottom lines when interweaving to INTERLACED_BT -- note that despite the name, INTERLACED_BT is top-bottom order in memory. The BT in this case refers to field dominance: the bottom lines are older in time than the top lines. The capture interface device allows selecting IDMAC interweave by choosing INTERLACED_TB if the CSI/PRPENCVF source pad is seq-tb and INTERLACED_BT if the source pad is seq-bt (for future support of seq-bt). Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-ic-prpencvf.c | 21 ++++-- drivers/staging/media/imx/imx-media-capture.c | 14 ++++ drivers/staging/media/imx/imx-media-csi.c | 64 ++++++++++++++----- 3 files changed, 76 insertions(+), 23 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index af7224846bd5..1a03d4c9d7b8 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -354,12 +354,13 @@ static int prp_setup_channel(struct prp_priv *priv, { struct imx_media_video_dev *vdev = priv->vdev; const struct imx_media_pixfmt *outcc; - struct v4l2_mbus_framefmt *infmt; + struct v4l2_mbus_framefmt *outfmt; unsigned int burst_size; struct ipu_image image; + bool interweave; int ret; - infmt = &priv->format_mbus[PRPENCVF_SINK_PAD]; + outfmt = &priv->format_mbus[PRPENCVF_SRC_PAD]; outcc = vdev->cc; ipu_cpmem_zero(channel); @@ -369,6 +370,15 @@ static int prp_setup_channel(struct prp_priv *priv, image.rect.width = image.pix.width; image.rect.height = image.pix.height; + /* + * If the field type at capture interface is interlaced, and + * the output IDMAC pad is sequential, enable interweave at + * the IDMAC output channel. + */ + interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) && + channel == priv->out_ch; + if (rot_swap_width_height) { swap(image.pix.width, image.pix.height); swap(image.rect.width, image.rect.height); @@ -409,9 +419,7 @@ static int prp_setup_channel(struct prp_priv *priv, if (rot_mode) ipu_cpmem_set_rotation(channel, rot_mode); - if (image.pix.field == V4L2_FIELD_NONE && - V4L2_FIELD_HAS_BOTH(infmt->field) && - channel == priv->out_ch) + if (interweave) ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, image.pix.pixelformat); @@ -839,8 +847,7 @@ static void prp_try_fmt(struct prp_priv *priv, infmt = __prp_get_fmt(priv, cfg, PRPENCVF_SINK_PAD, sdformat->which); if (sdformat->pad == PRPENCVF_SRC_PAD) { - if (sdformat->format.field != V4L2_FIELD_NONE) - sdformat->format.field = infmt->field; + sdformat->format.field = infmt->field; prp_bound_align_output(&sdformat->format, infmt, priv->rot_mode); diff --git a/drivers/staging/media/imx/imx-media-capture.c b/drivers/staging/media/imx/imx-media-capture.c index b37e1186eb2f..01ec9443de55 100644 --- a/drivers/staging/media/imx/imx-media-capture.c +++ b/drivers/staging/media/imx/imx-media-capture.c @@ -239,6 +239,20 @@ static int capture_try_fmt_vid_cap(struct file *file, void *fh, cc = cc_src; } + /* allow IDMAC interweave but enforce field order from source */ + if (V4L2_FIELD_IS_INTERLACED(f->fmt.pix.field)) { + switch (fmt_src.format.field) { + case V4L2_FIELD_SEQ_TB: + fmt_src.format.field = V4L2_FIELD_INTERLACED_TB; + break; + case V4L2_FIELD_SEQ_BT: + fmt_src.format.field = V4L2_FIELD_INTERLACED_BT; + break; + default: + break; + } + } + imx_media_mbus_fmt_to_pix_fmt(&f->fmt.pix, &fmt_src.format, cc); return 0; diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 4aa20ae72608..176978c7dfe7 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -398,16 +398,18 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) struct imx_media_video_dev *vdev = priv->vdev; const struct imx_media_pixfmt *incc; struct v4l2_mbus_framefmt *infmt; + struct v4l2_mbus_framefmt *outfmt; + bool passthrough, interweave; struct ipu_image image; u32 passthrough_bits; u32 passthrough_cycles; dma_addr_t phys[2]; - bool passthrough; u32 burst_size; int ret; infmt = &priv->format_mbus[CSI_SINK_PAD]; incc = priv->cc[CSI_SINK_PAD]; + outfmt = &priv->format_mbus[CSI_SRC_PAD_IDMAC]; ipu_cpmem_zero(priv->idmac_ch); @@ -424,6 +426,14 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) passthrough = requires_passthrough(&priv->upstream_ep, infmt, incc); passthrough_cycles = 1; + /* + * If the field type at capture interface is interlaced, and + * the output IDMAC pad is sequential, enable interweave at + * the IDMAC output channel. + */ + interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: case V4L2_PIX_FMT_SGBRG8: @@ -509,8 +519,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ipu_smfc_set_burstsize(priv->smfc, burst_size); - if (image.pix.field == V4L2_FIELD_NONE && - V4L2_FIELD_HAS_BOTH(infmt->field)) + if (interweave) ipu_cpmem_interlaced_scan(priv->idmac_ch, image.pix.bytesperline, image.pix.pixelformat); @@ -1302,6 +1311,38 @@ static int csi_get_fmt(struct v4l2_subdev *sd, return ret; } +static void csi_try_field(struct csi_priv *priv, + struct v4l2_subdev_pad_config *cfg, + struct v4l2_subdev_format *sdformat) +{ + struct v4l2_mbus_framefmt *infmt = + __csi_get_fmt(priv, cfg, CSI_SINK_PAD, sdformat->which); + + /* no restrictions on sink pad field type */ + if (sdformat->pad == CSI_SINK_PAD) + return; + + switch (infmt->field) { + case V4L2_FIELD_SEQ_TB: + case V4L2_FIELD_SEQ_BT: + case V4L2_FIELD_ALTERNATE: + /* + * If the sink is sequential or alternating fields, + * allow only SEQ_TB at the source. + * + * This driver does not support alternate field mode, and + * the CSI captures a whole frame, so the CSI never presents + * alternate mode at its source pads. + */ + sdformat->format.field = V4L2_FIELD_SEQ_TB; + break; + default: + /* Passthrough for all other input field types */ + sdformat->format.field = infmt->field; + break; + } +} + static void csi_try_fmt(struct csi_priv *priv, struct v4l2_fwnode_endpoint *upstream_ep, struct v4l2_subdev_pad_config *cfg, @@ -1341,25 +1382,14 @@ static void csi_try_fmt(struct csi_priv *priv, } } - if (sdformat->pad == CSI_SRC_PAD_DIRECT || - sdformat->format.field != V4L2_FIELD_NONE) - sdformat->format.field = infmt->field; - - /* - * translate V4L2_FIELD_ALTERNATE to SEQ_TB or SEQ_BT - * depending on input height (assume NTSC top-bottom - * order if 480 lines, otherwise PAL bottom-top order). - */ - if (sdformat->format.field == V4L2_FIELD_ALTERNATE) { - sdformat->format.field = (infmt->height == 480) ? - V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT; - } + csi_try_field(priv, cfg, sdformat); /* propagate colorimetry from sink */ sdformat->format.colorspace = infmt->colorspace; sdformat->format.xfer_func = infmt->xfer_func; sdformat->format.quantization = infmt->quantization; sdformat->format.ycbcr_enc = infmt->ycbcr_enc; + break; case CSI_SINK_PAD: v4l_bound_align_image(&sdformat->format.width, MIN_W, MAX_W, @@ -1387,6 +1417,8 @@ static void csi_try_fmt(struct csi_priv *priv, sdformat->format.code = (*cc)->codes[0]; } + csi_try_field(priv, cfg, sdformat); + imx_media_fill_default_mbus_fields( &sdformat->format, infmt, priv->active_output_pad == CSI_SRC_PAD_DIRECT); From patchwork Wed Oct 17 00:00:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9785F17D4 for ; Wed, 17 Oct 2018 00:00:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8877A2A5AD for ; Wed, 17 Oct 2018 00:00:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 867C82A5A8; Wed, 17 Oct 2018 00:00:48 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 3B65F2A5B4 for ; Wed, 17 Oct 2018 00:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727610AbeJQHxh (ORCPT ); Wed, 17 Oct 2018 03:53:37 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:35977 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeJQHxg (ORCPT ); Wed, 17 Oct 2018 03:53:36 -0400 Received: by mail-pg1-f196.google.com with SMTP id f18-v6so11619018pgv.3; Tue, 16 Oct 2018 17:00:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vY/CbkNcqakMjMLyu1WYUkc1UoGI2QdWY8d78wR8nXo=; b=ULUF9ku70qabezhFkjAJ/jq9Tits0fErb0paKE297tD2lOag9w3JEKMuf3Vuk5s4/8 5fbHr+U9z/eMQmZvk/G97OmuRS3c8kEjOb0RGJ9121+Dso+W87hPeWT0WOx4UxrdqHHr sjHpWIW2+krUzSgE9bLp/m2pRQSqkwk5J5N2dcIeYR5veg52RqlxoeNlIpRzibsqd+t2 d0cW6r7PmEKRvMprsynpGZhYOEq/DgrTXJFvAK9lQRNt00SitgJ4k2fRlD9c68TAq+4D 25CyTByUfn5xOdks5m2aWxymfp3WHKvS3jFmpzjQU7BmToAMEDlwDzU3LJyNM9YPuS9n cCpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vY/CbkNcqakMjMLyu1WYUkc1UoGI2QdWY8d78wR8nXo=; b=JXioTZ2tXAXMj4UgYHQ7SlFAmma07gJcI4t6EJz4zcj7/BijLNsjBcQitRpsmQW6CR SQvAZlkQc2ol57VjyxhkNW0oAdoXJaRQ00iOazDhTrDAhjpIirPaNKEb7x7LecyxDzsc b+uidonmTEPIEXMKJoGnkKaDDv2Xxesje11hYbvdb5dC3bzXMUutYU//s+Y7s3omYPxp 9Oxz02RGl5y0jAdmgJv0mTJCjw5Ahj7FXNqqX/vasuVZa5Pz37E/RjGPcs4uMc1FSX4B VTcGBAELOqSlym4MOn69FNFAoJMfyP5rT0y+MNlXCE0afiiN/OiNdVJr/+nBE/8AM8CA 5qPw== X-Gm-Message-State: ABuFfoj4EQtUfNfB0vt5NriiZYG2pvf8IMdZGSzkJW6R+M4+FiQYlXnl wvHNx1eRPFjVj1rB19IuTWfAKmmu X-Google-Smtp-Source: ACcGV63W/ahGtixGNbrw5iCx9OIclPkfwcOlaiOH8s1i4nLUOy+Y4p0tFk+mPbGbEtNf4DbHmQlyhQ== X-Received: by 2002:a62:22c7:: with SMTP id p68-v6mr24283601pfj.53.1539734444616; Tue, 16 Oct 2018 17:00:44 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:43 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 05/12] media: imx-csi: Input connections to CSI should be optional Date: Tue, 16 Oct 2018 17:00:20 -0700 Message-Id: <20181017000027.23696-6-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some imx platforms do not have fwnode connections to all CSI input ports, and should not be treated as an error. This includes the imx6q SabreAuto, which has no connections to ipu1_csi1 and ipu2_csi0. Return -ENOTCONN in imx_csi_parse_endpoint() so that v4l2-fwnode endpoint parsing will not treat an unconnected endpoint as an error. Fixes: c893500a16baf ("media: imx: csi: Register a subdev notifier") Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-csi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 176978c7dfe7..8f52428d2c75 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1813,7 +1813,7 @@ static int imx_csi_parse_endpoint(struct device *dev, struct v4l2_fwnode_endpoint *vep, struct v4l2_async_subdev *asd) { - return fwnode_device_is_available(asd->match.fwnode) ? 0 : -EINVAL; + return fwnode_device_is_available(asd->match.fwnode) ? 0 : -ENOTCONN; } static int imx_csi_async_register(struct csi_priv *priv) From patchwork Wed Oct 17 00:00:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644447 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6011717D4 for ; Wed, 17 Oct 2018 00:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F1AD2A71B for ; Wed, 17 Oct 2018 00:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 435A02A6EC; Wed, 17 Oct 2018 00:01:31 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 D75A82A72A for ; Wed, 17 Oct 2018 00:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727615AbeJQHxi (ORCPT ); Wed, 17 Oct 2018 03:53:38 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:43291 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeJQHxh (ORCPT ); Wed, 17 Oct 2018 03:53:37 -0400 Received: by mail-pl1-f194.google.com with SMTP id 30-v6so11746532plb.10; Tue, 16 Oct 2018 17:00:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eZ4OiF2jjJanfn9zHTYWPJ1ac2b/b0TjaIhiN/6VybM=; b=oI0jG3xXKHdFXUwnVLC18OIDZDHPwyatNS6aDDw/+pvabNEULX3AI3VY6NOBdIsk+v +Wi1Ac2AIgGvd5XEaj7r+3fTwegyR7/C2KQAvufskfVUmiKSSLpoCXBH31BHk/2jry7m 73I+ArSlOPvPBmIRDfzOSx23yUCn/He3fZObVnE1l8uHd/I7AXPtOOLlt4UXku56Pt8E bPEOItZtHHiKPo9mnvQ/zI6SfH95QxfTaaf5PBYFee9PSGqWs8sry4KYKEqJgiroCG18 p1MTAZpcAg2gvNyQ6iJZ0DTjrLlfZNN0i1faw39JOnUTLf7xAW6a2c02Z5EvS7OyfZcb 7FFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eZ4OiF2jjJanfn9zHTYWPJ1ac2b/b0TjaIhiN/6VybM=; b=IWU/qRDj6F4dxVwvLsV0RgOIyCRgeCYpVSkTkKMHSMZQpaf0o9v9NPjXwtf6Ri0d6t oicyImPSapCYU9agRQirukrkuLSAp94xtg1wSAnQExsllVn3q0OHkwEIIkRuOkqYYt5N 4n+bhkK7vDlkqp9owboW9wz8zE2GXF/O3ylxbGv+JvSIiDG+7OBV4X400Fh9uDWJTVcB xRHQzL2HMtOO2Ci3v8dlcthGY+FCXZIm202stW6jyiKMOdfL/UjfKYI8xzecE9hiaj60 Zk/hgPGbZ0rzj0wKsEB9JT+tHjg6ejVFAG0MIfJ/zNB/1k/S1ja5T1vKSwTpTf1kjgfJ xdDQ== X-Gm-Message-State: ABuFfojG3Xv39oSsHa2D0WCv+QnOmAA5J7yfYRbkOfaA47GZGzmKJjYM +YsY9samyOTUU4yk8yjYUcnu14Ft X-Google-Smtp-Source: ACcGV63zSS2ZDjlWaU8Gq2by+bqFntU9NAcFELZlvPOTaujDMZUNYdBEm38qRHKfsQVzQijkhh7xKg== X-Received: by 2002:a17:902:101:: with SMTP id 1-v6mr23531127plb.15.1539734446417; Tue, 16 Oct 2018 17:00:46 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:45 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 06/12] media: imx-csi: Double crop height for alternate fields at sink Date: Tue, 16 Oct 2018 17:00:21 -0700 Message-Id: <20181017000027.23696-7-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the incoming sink field type is alternate, the reset crop height and crop height bounds must be set to twice the incoming height, because in alternate field mode, upstream will report only the lines for a single field, and the CSI captures the whole frame. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-media-csi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 8f52428d2c75..d5b0f8a66750 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1140,6 +1140,8 @@ static void csi_try_crop(struct csi_priv *priv, struct v4l2_mbus_framefmt *infmt, struct v4l2_fwnode_endpoint *upstream_ep) { + u32 in_height; + crop->width = min_t(__u32, infmt->width, crop->width); if (crop->left + crop->width > infmt->width) crop->left = infmt->width - crop->width; @@ -1147,6 +1149,10 @@ static void csi_try_crop(struct csi_priv *priv, crop->left &= ~0x3; crop->width &= ~0x7; + in_height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + in_height *= 2; + /* * FIXME: not sure why yet, but on interlaced bt.656, * changing the vertical cropping causes loss of vertical @@ -1156,12 +1162,12 @@ static void csi_try_crop(struct csi_priv *priv, if (upstream_ep->bus_type == V4L2_MBUS_BT656 && (V4L2_FIELD_HAS_BOTH(infmt->field) || infmt->field == V4L2_FIELD_ALTERNATE)) { - crop->height = infmt->height; - crop->top = (infmt->height == 480) ? 2 : 0; + crop->height = in_height; + crop->top = (in_height == 480) ? 2 : 0; } else { - crop->height = min_t(__u32, infmt->height, crop->height); - if (crop->top + crop->height > infmt->height) - crop->top = infmt->height - crop->height; + crop->height = min_t(__u32, in_height, crop->height); + if (crop->top + crop->height > in_height) + crop->top = in_height - crop->height; } } @@ -1401,6 +1407,8 @@ static void csi_try_fmt(struct csi_priv *priv, crop->top = 0; crop->width = sdformat->format.width; crop->height = sdformat->format.height; + if (sdformat->format.field == V4L2_FIELD_ALTERNATE) + crop->height *= 2; csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); compose->left = 0; compose->top = 0; @@ -1528,6 +1536,8 @@ static int csi_get_selection(struct v4l2_subdev *sd, sel->r.top = 0; sel->r.width = infmt->width; sel->r.height = infmt->height; + if (infmt->field == V4L2_FIELD_ALTERNATE) + sel->r.height *= 2; break; case V4L2_SEL_TGT_CROP: sel->r = *crop; From patchwork Wed Oct 17 00:00:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F26B917D4 for ; Wed, 17 Oct 2018 00:00:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E315728F80 for ; Wed, 17 Oct 2018 00:00:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D78E62A518; Wed, 17 Oct 2018 00:00:53 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 3A57A28F80 for ; Wed, 17 Oct 2018 00:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727689AbeJQHxl (ORCPT ); Wed, 17 Oct 2018 03:53:41 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:34398 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeJQHxj (ORCPT ); Wed, 17 Oct 2018 03:53:39 -0400 Received: by mail-pl1-f194.google.com with SMTP id f18-v6so11767655plr.1; Tue, 16 Oct 2018 17:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U0eBTHkSaCphcPmwZ9jVlJ6HcB3DsZnUr5R1VmafRFY=; b=bKk3VSpVvrlANGtQ0CXXAEUKnZHRBbLi25e9GeqBgRiieQnGfLp5opYGWCA7SvEI+l tGm6IxWY6SCFGD0JMCbigX4aZH4dbZZDDBiuTo9MIzkUpaqlIh20LVAs1a2pxBZ0eeYz OkCeg8FvNAb9y0EhTkdDVYVfDOTJzIwnhPBkXWWEhd/UNffdm5/baKXkXlwRd90ftC6W jAfC8/kgZTOCBDlsJHSAHeiPybsXduhyX9GzbPCZpA3+NNUaxRpbvJiGgdYMcsmjBG8u IAUX9zKTpVmnHKlOLTie8eGYOhV/+kj8sGNpBn2pOhIDXgDP1mWX5UaJOagl+YGGSjSN rhOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U0eBTHkSaCphcPmwZ9jVlJ6HcB3DsZnUr5R1VmafRFY=; b=XgKcjMzWR621jbBfMm4CnD/oYXon0bzMJqrn8yjCnGekqE/R0n/37WZdWDtZ5kag7v 8ZFi0DPwYdCjjBdqo9eBhTnkh/i4dDFxwTjSOnM6krt2XPBmzVkOBS02j7c4K/4IJSCv Q/Mp6wMyMx2Kmvjox9jOm0Ud1j8QaxtCK4w7GCxi4B5Heu+fOh4ZJ8S6aRYrAG6H20By bOCHGEOlokIwGdqh+Km5J0vV/VnEFAp7YGuSbsl+SPiAPp5d1R4ZTk3HjXPRQGxQeOUK rrq6PD6QxlCCmQONw214My3D69wCi0sfZ99b/XTbjekofABJPmQdNNTswtnJ/DnRUjFp loTA== X-Gm-Message-State: ABuFfogYQ4no+/myWOKdxYGjWZS2Y19pax5uWYEzi9k9QASeFedPcLiK KT4kXY3Y1ipIYoZgFOiea+K4D3YF X-Google-Smtp-Source: ACcGV60yhOyX69rEqScgU2+HCyIBA9TIcWXnJisJvPF7k11Xc+/qWF0/Rix05C2vnM3xVvIksQzWkA== X-Received: by 2002:a17:902:3204:: with SMTP id y4-v6mr18584456plb.135.1539734448006; Tue, 16 Oct 2018 17:00:48 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:47 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 07/12] media: imx: interweave and odd-chroma-row skip are incompatible Date: Tue, 16 Oct 2018 17:00:22 -0700 Message-Id: <20181017000027.23696-8-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If IDMAC interweaving is enabled in a write channel, the channel must write the odd chroma rows for 4:2:0 formats. Skipping writing the odd chroma rows produces corrupted captured 4:2:0 images when interweave is enabled. Reported-by: Krzysztof HaƂasa Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-ic-prpencvf.c | 9 +++++++-- drivers/staging/media/imx/imx-media-csi.c | 8 ++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index 1a03d4c9d7b8..cf76b0432371 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -391,12 +391,17 @@ static int prp_setup_channel(struct prp_priv *priv, image.phys0 = addr0; image.phys1 = addr1; - if (channel == priv->out_ch || channel == priv->rot_out_ch) { + /* + * Skip writing U and V components to odd rows in the output + * channels for planar 4:2:0 (but not when enabling IDMAC + * interweaving, they are incompatible). + */ + if (!interweave && (channel == priv->out_ch || + channel == priv->rot_out_ch)) { switch (image.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_NV12: - /* Skip writing U and V components to odd rows */ ipu_cpmem_skip_odd_chroma_rows(channel); break; } diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index d5b0f8a66750..7e648fc9626a 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -457,8 +457,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ((image.pix.width & 0x1f) ? ((image.pix.width & 0xf) ? 8 : 16) : 32) : 64; passthrough_bits = 16; - /* Skip writing U and V components to odd rows */ - ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch); + /* + * Skip writing U and V components to odd rows (but not + * when enabling IDMAC interweaving, they are incompatible). + */ + if (!interweave) + ipu_cpmem_skip_odd_chroma_rows(priv->idmac_ch); break; case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_UYVY: From patchwork Wed Oct 17 00:00:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C894157A for ; Wed, 17 Oct 2018 00:01:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D8D22A71B for ; Wed, 17 Oct 2018 00:01:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10CC32A76D; Wed, 17 Oct 2018 00:01:17 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 B440B2A71B for ; Wed, 17 Oct 2018 00:01:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbeJQHxn (ORCPT ); Wed, 17 Oct 2018 03:53:43 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37736 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeJQHxl (ORCPT ); Wed, 17 Oct 2018 03:53:41 -0400 Received: by mail-pg1-f195.google.com with SMTP id c10-v6so11607060pgq.4; Tue, 16 Oct 2018 17:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vugOjOb9bU/wU1aCXpDs/uKcyEbw9sNMwAJBqgpFIwY=; b=ZCc0qAIgHERMROzxNRSvwS//eehcsZEfM0Scg2RNKIJHP6U/+bzjzNvkBALnJHpSQv mO1H0cIJ1fhMTzB/RK9Q3nJVVhoYECEhTRgBeMUl13UBBgi3XTj1GsbOLFi9aZlFAQsB Ab4pP/5bPJwAEz3UMF5Z7RWENgCcOE1BknYpJrhsuYanyTh0typA9ii9QErtj898WwWf 08VLhGVRDhUwspcAciWPvaNfa0+3eyjgN2gootGE7TVY99g/idSw9m/EN364AXM7FguZ bOdnbboXgBOS9ju6PpniEronLelIs9UIYmgVcLR6uivza2glUwOmrmZPr2EWyH0L2SYa 6gCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vugOjOb9bU/wU1aCXpDs/uKcyEbw9sNMwAJBqgpFIwY=; b=t0HMFtotHylwAj3LDrZVzlnDFZNNQL0GwtCUlr/rdqjQa71aW6e00Qt9ughXTyVhxT RfY2JwXpUr6d/QCJvlA68K99QB1mJBwr6Y4me7z4jX5KAO8GDTixvrICHxfHLgHkds53 b6bWq3XRHe/pzBZbNRJuwVXCf/AnCgMqlqjZLopRy1t2jizLtrj1PwlYouRtWIajCB3s eSR8hUWLXhd62CgKQ7l4ZwZ9PQl2dDA//G6oPPAGe2A05Tpa23fuACklXRtwEMOCIeAx 0emMczp+qAsv4nTjGFb9uHcqS8bd+bPArlp44cpkkXQBe6ZYIZYRtYrPTO4CTminIOkJ KNmQ== X-Gm-Message-State: ABuFfojX51vEU8ZTEgLm4qXX4wk/uulzwNkOBeZD2u4TkfLBtyhHNBP0 yRP6Zg0SkVDLvPaYvTX//SJTeai3 X-Google-Smtp-Source: ACcGV63xKqO1mBLDg9+EN8yKNjppG2LgVbEV317v29TOjTxO/d7+MXD5LLmDdxzNhEemlc3a6UlOyA== X-Received: by 2002:a63:e05:: with SMTP id d5-v6mr22051194pgl.272.1539734449622; Tue, 16 Oct 2018 17:00:49 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:48 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 08/12] media: imx-csi: Allow skipping odd chroma rows for YVU420 Date: Tue, 16 Oct 2018 17:00:23 -0700 Message-Id: <20181017000027.23696-9-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Skip writing U/V components to odd rows for YVU420 in addition to YUV420 and NV12. Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-media-csi.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 7e648fc9626a..c9110dd39a49 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -452,6 +452,7 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) passthrough_bits = 16; break; case V4L2_PIX_FMT_YUV420: + case V4L2_PIX_FMT_YVU420: case V4L2_PIX_FMT_NV12: burst_size = (image.pix.width & 0x3f) ? ((image.pix.width & 0x1f) ? From patchwork Wed Oct 17 00:00:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644445 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BD963157A for ; Wed, 17 Oct 2018 00:01:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD07E2A4DF for ; Wed, 17 Oct 2018 00:01:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB60E2A778; Wed, 17 Oct 2018 00:01:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 3919B2A5AD for ; Wed, 17 Oct 2018 00:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727282AbeJQHyI (ORCPT ); Wed, 17 Oct 2018 03:54:08 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34400 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeJQHxm (ORCPT ); Wed, 17 Oct 2018 03:53:42 -0400 Received: by mail-pl1-f193.google.com with SMTP id f18-v6so11767705plr.1; Tue, 16 Oct 2018 17:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=BwIrt/QiZthUXo9qim2CsYJxYbNHfbi5cRl8NpsI+xE=; b=Fh2gJu5v4RNXS0/w2u+wwGiVQ7mxIKzT8TYObGminR3JYEHGs7921rz8TWtegu0Jlk mtQjEng4B3pNvQUQtCX7mYeS9miXcqP/CUvuMD6hKsHx66+CzxaVhFgpKD7ZYsh3/uOl LASF5u376kmkd4W5ABwOdESDWVJfsN+l9tVOzMAtXznWdVeIeHhFEbG1yzZ9GDIpnLYi 2nJkddlF8N1ezH3/+Lln6gbiP83f/rU/PBssT2WsQjpHxcjAht6LtxU6b14gFJEX23S7 7zPGqca5YxRineJGmKMZrEmtDeQUtKXb/R2eGmvOMzHWad8ZBtxOeX71XBKK3YV4T2O8 EX8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=BwIrt/QiZthUXo9qim2CsYJxYbNHfbi5cRl8NpsI+xE=; b=sy1NH6EtY8mcwxsSB+22tXjIEzfG5tlcWMcvIVsEzoQnTZeVJO98FMQlZhprTyTt1d 5Ob3vpLaXP5OduxSszz+fnzbnlgON5UWgt5scjRJZ6camB77LL6mLG6ecHXrJ81XVH+Q VWzAIIpmY+hE5dakc+J9y5eUzt8mukHx6HxxHzKVVKRsVmkyImCdWN7VaLXmyS6x6OQi xG/JPqHYSGJ1d2Ll5w4iy8I8uagi+V5rCa0xr1JzQuMS7y1X84+BtOYevgWUvAK/dwuX 6eE8ftxFUjUNycIYYnTKDwNqt5LQwCQEDqQ0H8fs5GKShA3UJonXeYVh1hRsOYJv65wO b4aA== X-Gm-Message-State: ABuFfoid/wyBqMSs5P9FYg5B9Gj9JT9fsGRli6Q9zP1jrUf+yQUTug8A l143AVj8msxqpnma7Gh2r/vh0wkz X-Google-Smtp-Source: ACcGV63sj5FZtLhqmqZlcKgFzeb1TP4UsJ5T0CXH0puqhtC6/DV/MZLISZQhmhJxriE9zsu2HBsLIA== X-Received: by 2002:a17:902:e01:: with SMTP id 1-v6mr18779150plw.207.1539734451126; Tue, 16 Oct 2018 17:00:51 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:50 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 09/12] media: imx: vdic: rely on VDIC for correct field order Date: Tue, 16 Oct 2018 17:00:24 -0700 Message-Id: <20181017000027.23696-10-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP prepare_vdi_in_buffers() was setting up the dma pointers as if the VDIC is always programmed to receive the fields in bottom-top order, i.e. as if ipu_vdi_set_field_order() only programs BT order in the VDIC. But that's not true, ipu_vdi_set_field_order() is working correctly. So fix prepare_vdi_in_buffers() to give the VDIC the fields in whatever order they were received by the video source, and rely on the VDIC to sort out which is top and which is bottom. Signed-off-by: Steve Longerbeam --- drivers/staging/media/imx/imx-media-vdic.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-vdic.c b/drivers/staging/media/imx/imx-media-vdic.c index 482250d47e7c..4a890714193e 100644 --- a/drivers/staging/media/imx/imx-media-vdic.c +++ b/drivers/staging/media/imx/imx-media-vdic.c @@ -219,26 +219,18 @@ static void __maybe_unused prepare_vdi_in_buffers(struct vdic_priv *priv, switch (priv->fieldtype) { case V4L2_FIELD_SEQ_TB: - prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0); - curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs; - next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); - break; case V4L2_FIELD_SEQ_BT: prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + fs; curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + fs; break; + case V4L2_FIELD_INTERLACED_TB: case V4L2_FIELD_INTERLACED_BT: + case V4L2_FIELD_INTERLACED: prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0) + is; curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is; break; - default: - /* assume V4L2_FIELD_INTERLACED_TB */ - prev_phys = vb2_dma_contig_plane_dma_addr(prev_vb, 0); - curr_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0) + is; - next_phys = vb2_dma_contig_plane_dma_addr(curr_vb, 0); - break; } ipu_cpmem_set_buffer(priv->vdi_in_ch_p, 0, prev_phys); From patchwork Wed Oct 17 00:00:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644441 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3E3A157A for ; Wed, 17 Oct 2018 00:01:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9675A2A5AD for ; Wed, 17 Oct 2018 00:01:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 886262A687; Wed, 17 Oct 2018 00:01:11 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 2FB392A754 for ; Wed, 17 Oct 2018 00:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727745AbeJQHxp (ORCPT ); Wed, 17 Oct 2018 03:53:45 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:32959 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeJQHxo (ORCPT ); Wed, 17 Oct 2018 03:53:44 -0400 Received: by mail-pg1-f195.google.com with SMTP id y18-v6so11620907pge.0; Tue, 16 Oct 2018 17:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v1ovWtU7rw02LvSZ+0cIdgCkrY1FUFkyMNDz8xxcZYs=; b=dxaoezr+l5VkYMw+FdNUw5gXA6unzmKDdp1PRGh0f/2Qy1mGt3ASjCIlXZUXCcMgx0 dgYsgVI7OcELiNnCyXVqOXz8G0uX5Ldkf2HWEfKAtVlOymfYI9pc74Xvy4FLYUqT7Ffn T6nMPqm9FhwCqZyEKKC2+UHlWhVtUfpWbdmOXujO1pbqGgYg2o6K2enE/tDQMjJmo8lk e/9T/pZaojhXFiO8SW0S969GqY3dPzabKAtkI4dhb2r7W6E5AMUJrtcTztdeZuzkkhbN GIx3QIMdVWSbx1qDCCvaWFntg5E2p3U/LZxpta+ot5sOssh4crR/kCV1RT5RFwoxzTRi kwsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v1ovWtU7rw02LvSZ+0cIdgCkrY1FUFkyMNDz8xxcZYs=; b=FQ8FacFktwwoPtBpUetVnX4t9pgVNbAqcwQvwJY8TRvf1vD7+31wViVV7setak7V4l jKm1nNtvucRspH/JXPhOXrgTaATW/iRVZ+9Lk4/Xfm6kmwkutdJ0XUEUtUag4cV6ug+U DxNIykS/cXBY5Y/a1HAJJfyVnd8K808VROzFgA8CCyeCxWFuepSxNEeI9IYDMP8muJi+ rfcC/bDUkSwohaajd2hLrfg+IDg9u6mdfGzyGJz+RUABWGokB6qubGTuiCOQbBK2hKqE 5dfq6JUcDsbj1uR2hh4HbiSQuUyD6cB/lw2dz4x9PPWFOm295P8723EIjCo/msUabtd8 w3Rw== X-Gm-Message-State: ABuFfogI9C20m5B5xrVyIB9Dz5vvgysprURS2FqWRSkvOQyF7soEAEkh tUpUqdaF3fz7bTVTzVMOk+igMVts X-Google-Smtp-Source: ACcGV61ijrwr7xslsp3nuKfBh+fJVH/p+zQpqTLGYDth7nlfm9y0NhSEyHaBj37d+DlehVOG+w9aCg== X-Received: by 2002:a62:5887:: with SMTP id m129-v6mr24045222pfb.254.1539734452653; Tue, 16 Oct 2018 17:00:52 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:51 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 10/12] media: imx-csi: Move crop/compose reset after filling default mbus fields Date: Tue, 16 Oct 2018 17:00:25 -0700 Message-Id: <20181017000027.23696-11-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If caller passes un-initialized field type V4L2_FIELD_ANY to CSI sink pad, the reset CSI crop window would not be correct, because the crop window depends on a valid input field type. To fix move the reset of crop and compose windows to after the call to imx_media_fill_default_mbus_fields(). Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- drivers/staging/media/imx/imx-media-csi.c | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index c9110dd39a49..0d494a7db211 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -1407,19 +1407,6 @@ static void csi_try_fmt(struct csi_priv *priv, W_ALIGN, &sdformat->format.height, MIN_H, MAX_H, H_ALIGN, S_ALIGN); - /* Reset crop and compose rectangles */ - crop->left = 0; - crop->top = 0; - crop->width = sdformat->format.width; - crop->height = sdformat->format.height; - if (sdformat->format.field == V4L2_FIELD_ALTERNATE) - crop->height *= 2; - csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); - compose->left = 0; - compose->top = 0; - compose->width = crop->width; - compose->height = crop->height; - *cc = imx_media_find_mbus_format(sdformat->format.code, CS_SEL_ANY, true); if (!*cc) { @@ -1435,6 +1422,20 @@ static void csi_try_fmt(struct csi_priv *priv, imx_media_fill_default_mbus_fields( &sdformat->format, infmt, priv->active_output_pad == CSI_SRC_PAD_DIRECT); + + /* Reset crop and compose rectangles */ + crop->left = 0; + crop->top = 0; + crop->width = sdformat->format.width; + crop->height = sdformat->format.height; + if (sdformat->format.field == V4L2_FIELD_ALTERNATE) + crop->height *= 2; + csi_try_crop(priv, crop, cfg, &sdformat->format, upstream_ep); + compose->left = 0; + compose->top = 0; + compose->width = crop->width; + compose->height = crop->height; + break; } } From patchwork Wed Oct 17 00:00:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644439 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE5AC157A for ; Wed, 17 Oct 2018 00:01:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF69F2A583 for ; Wed, 17 Oct 2018 00:01:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B38192A71B; Wed, 17 Oct 2018 00:01:10 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 0F8842A583 for ; Wed, 17 Oct 2018 00:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727765AbeJQHxr (ORCPT ); Wed, 17 Oct 2018 03:53:47 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44943 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeJQHxq (ORCPT ); Wed, 17 Oct 2018 03:53:46 -0400 Received: by mail-pg1-f193.google.com with SMTP id g2-v6so11594161pgu.11; Tue, 16 Oct 2018 17:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ud3sZ39TjMzlMzLDf6CVuDQV1gMZF2qHkeRsS7yIoLA=; b=VFGvNezl31mnXvNdIcleKAeaCqbGx+IFUBKBfm1LOF5VmSQbPIeWv/QWBBJRnlV2AZ JIjo3VvxVXsp9wBskjNDGHFMG73GD60MZNV2KNjMj6dbj+f3tbA21F4KjYSly2Gnblgu Bq+Kso8fvc136d8349X+O7GKfD+ooST6POKq6+UbH/KF02zZNx1pgUJ5TgaYy1VYvZtz hkgV7nTWrmOvqdkdwAkkrOZZF8ggkrlBFWS3qbJ4WWMo1byObZuE6MafbmAT2K2nvzjq VPITHunCQhMresD6rhe7MPk6DXrXcnV3GCJnk0XNho/HegddMl5M/SfOE4/5+eXU4kyo qpPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Ud3sZ39TjMzlMzLDf6CVuDQV1gMZF2qHkeRsS7yIoLA=; b=ZgtVoazdlPWEA8aEkIDrOlRWmzAZx3nYqcFjybrZ9FD/TPM+rgTiUB1f1ff/KQCsBI V7qU9phoE8Rzo4GQbkVMWDE2SdJIUraXWn/xCcu4yS3637ButTzQCq8I8a/F3t/rvy8G 8QtEe4r5sdMt7KhCEtSnoEWuTMqbhdl5ea+ajNFypLT/rdeDVbQNNzwnFuDwbQvoq1P0 ZwXgVJ1e//N6ySWZHTnbZu/fWhh66QiJUqFuXfS3RMANBqOUJNFwEl3Zl944boKuk4d8 s1cJsTkLKKI2k1dxpNSnDEfJDs2VUDatBAGor615DPwMw/KIrfG6bf5BgwlSLLwm4yAT 6quQ== X-Gm-Message-State: ABuFfoj5LzoV6mOFoz4dqP0mdf6eW+w+NRTmCrKovQv/JuebBIBLqP97 75LHSH+G3LF5WBvcipS2DPx5F4T+ X-Google-Smtp-Source: ACcGV636SgYdiqfQqysECxL4/O20anZNMbtRJIoSXHMbaxsUmv11An6RCtFv4/dlQdjsCRGjkIggOQ== X-Received: by 2002:a63:e116:: with SMTP id z22-v6mr21803697pgh.20.1539734454312; Tue, 16 Oct 2018 17:00:54 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:53 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , Greg Kroah-Hartman , devel@driverdev.osuosl.org (open list:STAGING SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 11/12] media: imx: Allow interweave with top/bottom lines swapped Date: Tue, 16 Oct 2018 17:00:26 -0700 Message-Id: <20181017000027.23696-12-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow sequential->interlaced interweaving but with top/bottom lines swapped to the output buffer. This can be accomplished by adding one line length to IDMAC output channel address, with a negative line length for the interlace offset. This is to allow the seq-bt -> interlaced-bt transformation, where bottom lines are still dominant (older in time) but with top lines first in the interweaved output buffer. With this support, the CSI can now allow seq-bt at its source pads, e.g. the following transformations are allowed in CSI from sink to source: seq-tb -> seq-bt seq-bt -> seq-bt alternate -> seq-bt Suggested-by: Philipp Zabel Signed-off-by: Steve Longerbeam Reviewed-by: Philipp Zabel --- Changes since v4: - Removed interweave_offset and replace with boolean interweave_swap, suggested by Philipp Zabel. --- drivers/staging/media/imx/imx-ic-prpencvf.c | 25 +++++++++---- drivers/staging/media/imx/imx-media-csi.c | 40 ++++++++++++++++++--- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/imx/imx-ic-prpencvf.c b/drivers/staging/media/imx/imx-ic-prpencvf.c index cf76b0432371..33ada6612fee 100644 --- a/drivers/staging/media/imx/imx-ic-prpencvf.c +++ b/drivers/staging/media/imx/imx-ic-prpencvf.c @@ -106,6 +106,7 @@ struct prp_priv { u32 frame_sequence; /* frame sequence counter */ bool last_eof; /* waiting for last EOF at stream off */ bool nfb4eof; /* NFB4EOF encountered during streaming */ + bool interweave_swap; /* swap top/bottom lines when interweaving */ struct completion last_eof_comp; }; @@ -235,6 +236,9 @@ static void prp_vb2_buf_done(struct prp_priv *priv, struct ipuv3_channel *ch) if (ipu_idmac_buffer_is_ready(ch, priv->ipu_buf_num)) ipu_idmac_clear_buffer(ch, priv->ipu_buf_num); + if (priv->interweave_swap && ch == priv->out_ch) + phys += vdev->fmt.fmt.pix.bytesperline; + ipu_cpmem_set_buffer(ch, priv->ipu_buf_num, phys); } @@ -376,8 +380,9 @@ static int prp_setup_channel(struct prp_priv *priv, * the IDMAC output channel. */ interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && - V4L2_FIELD_IS_SEQUENTIAL(outfmt->field) && - channel == priv->out_ch; + V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + priv->interweave_swap = interweave && + image.pix.field == V4L2_FIELD_INTERLACED_BT; if (rot_swap_width_height) { swap(image.pix.width, image.pix.height); @@ -388,6 +393,11 @@ static int prp_setup_channel(struct prp_priv *priv, (image.pix.width * outcc->bpp) >> 3; } + if (priv->interweave_swap && channel == priv->out_ch) { + /* start interweave scan at 1st top line (2nd line) */ + image.rect.top = 1; + } + image.phys0 = addr0; image.phys1 = addr1; @@ -396,8 +406,8 @@ static int prp_setup_channel(struct prp_priv *priv, * channels for planar 4:2:0 (but not when enabling IDMAC * interweaving, they are incompatible). */ - if (!interweave && (channel == priv->out_ch || - channel == priv->rot_out_ch)) { + if ((channel == priv->out_ch && !interweave) || + channel == priv->rot_out_ch) { switch (image.pix.pixelformat) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_YVU420: @@ -424,8 +434,11 @@ static int prp_setup_channel(struct prp_priv *priv, if (rot_mode) ipu_cpmem_set_rotation(channel, rot_mode); - if (interweave) - ipu_cpmem_interlaced_scan(channel, image.pix.bytesperline, + if (interweave && channel == priv->out_ch) + ipu_cpmem_interlaced_scan(channel, + priv->interweave_swap ? + -image.pix.bytesperline : + image.pix.bytesperline, image.pix.pixelformat); ret = ipu_ic_task_idma_init(priv->ic, channel, diff --git a/drivers/staging/media/imx/imx-media-csi.c b/drivers/staging/media/imx/imx-media-csi.c index 0d494a7db211..73c9f3ae4221 100644 --- a/drivers/staging/media/imx/imx-media-csi.c +++ b/drivers/staging/media/imx/imx-media-csi.c @@ -114,6 +114,7 @@ struct csi_priv { u32 frame_sequence; /* frame sequence counter */ bool last_eof; /* waiting for last EOF at stream off */ bool nfb4eof; /* NFB4EOF encountered during streaming */ + bool interweave_swap; /* swap top/bottom lines when interweaving */ struct completion last_eof_comp; }; @@ -286,6 +287,9 @@ static void csi_vb2_buf_done(struct csi_priv *priv) if (ipu_idmac_buffer_is_ready(priv->idmac_ch, priv->ipu_buf_num)) ipu_idmac_clear_buffer(priv->idmac_ch, priv->ipu_buf_num); + if (priv->interweave_swap) + phys += vdev->fmt.fmt.pix.bytesperline; + ipu_cpmem_set_buffer(priv->idmac_ch, priv->ipu_buf_num, phys); } @@ -433,6 +437,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) */ interweave = V4L2_FIELD_IS_INTERLACED(image.pix.field) && V4L2_FIELD_IS_SEQUENTIAL(outfmt->field); + priv->interweave_swap = interweave && + image.pix.field == V4L2_FIELD_INTERLACED_BT; switch (image.pix.pixelformat) { case V4L2_PIX_FMT_SBGGR8: @@ -486,6 +492,12 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) } if (passthrough) { + if (priv->interweave_swap) { + /* start interweave scan at 1st top line (2nd line) */ + image.phys0 += image.pix.bytesperline; + image.phys1 += image.pix.bytesperline; + } + ipu_cpmem_set_resolution(priv->idmac_ch, image.rect.width * passthrough_cycles, image.rect.height); @@ -495,6 +507,11 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) ipu_cpmem_set_format_passthrough(priv->idmac_ch, passthrough_bits); } else { + if (priv->interweave_swap) { + /* start interweave scan at 1st top line (2nd line) */ + image.rect.top = 1; + } + ret = ipu_cpmem_set_image(priv->idmac_ch, &image); if (ret) goto unsetup_vb2; @@ -526,6 +543,8 @@ static int csi_idmac_setup_channel(struct csi_priv *priv) if (interweave) ipu_cpmem_interlaced_scan(priv->idmac_ch, + priv->interweave_swap ? + -image.pix.bytesperline : image.pix.bytesperline, image.pix.pixelformat); @@ -1336,16 +1355,27 @@ static void csi_try_field(struct csi_priv *priv, switch (infmt->field) { case V4L2_FIELD_SEQ_TB: case V4L2_FIELD_SEQ_BT: + /* + * If the user requests sequential at the source pad, + * allow it (along with possibly inverting field order). + * Otherwise passthrough the field type. + */ + if (!V4L2_FIELD_IS_SEQUENTIAL(sdformat->format.field)) + sdformat->format.field = infmt->field; + break; case V4L2_FIELD_ALTERNATE: /* - * If the sink is sequential or alternating fields, - * allow only SEQ_TB at the source. - * * This driver does not support alternate field mode, and * the CSI captures a whole frame, so the CSI never presents - * alternate mode at its source pads. + * alternate mode at its source pads. If user has not + * already requested sequential, translate ALTERNATE at + * sink pad to SEQ_TB or SEQ_BT at the source pad depending + * on input height (assume NTSC BT order if 480 total active + * frame lines, otherwise PAL TB order). */ - sdformat->format.field = V4L2_FIELD_SEQ_TB; + if (!V4L2_FIELD_IS_SEQUENTIAL(sdformat->format.field)) + sdformat->format.field = (infmt->height == 480 / 2) ? + V4L2_FIELD_SEQ_BT : V4L2_FIELD_SEQ_TB; break; default: /* Passthrough for all other input field types */ From patchwork Wed Oct 17 00:00:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 10644437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A29517D4 for ; Wed, 17 Oct 2018 00:01:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25FB82A5CB for ; Wed, 17 Oct 2018 00:01:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15C492A6C7; Wed, 17 Oct 2018 00:01:08 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,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 22FD32A5CB for ; Wed, 17 Oct 2018 00:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727841AbeJQHxu (ORCPT ); Wed, 17 Oct 2018 03:53:50 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:46308 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727646AbeJQHxt (ORCPT ); Wed, 17 Oct 2018 03:53:49 -0400 Received: by mail-pg1-f193.google.com with SMTP id a5-v6so11591483pgv.13; Tue, 16 Oct 2018 17:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AtLoo3VIxB2BrTDYsbUW3ewCrV6NJ5u/G+P5mLFc6Dc=; b=Hy9/6y8YAECZH/Mj+87lWHqgx5Csojz3USjPie4PUQnd78MrylW3S9VoxRSVpQCyHP 9vbi3Tf2ixCFNlCOJHhE5+icFyy6Q6ApuyNbPMaaCkb3DIj7c8A9k5aC7aoLI8EjEmYK Q/zTQUanuJMZ3qtA74aLuy7QEurd7Fl8b9VLP3ZENVZmo7OuCKju5MJcFnVPv0dmyndL /QwwzfDZXqsBAI5lcs4kHbdtwfb8XqgRFLVCSHfy5PXnmuKqKbr31rOo9lqFgTO4dLs0 vwWLHeQ8SC5kTqdBJtpAi569iPszg1+PPbredWgTIfirlpmLhY1yifTfD8nF2GN4fNAz mXNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AtLoo3VIxB2BrTDYsbUW3ewCrV6NJ5u/G+P5mLFc6Dc=; b=RPHEkVAchYBl6JnB4x8TdhyjuLB/RlPew3MStAzK+iLyjhnrspVSSJVpRAkdPX1KnD pGFnRxrmEBMcvO0Ik4ZYE+hJPtywK89/DsfgFS/9+JVEB5t5YDY89EXv27F5Kd/StB9z dkgDPbqvc9U61+/v3YshcFg/xjrfUVBCh2tJDsAN1UUKCv/UmwDV+jVVlSyJ+YsKsamr AlhzObEqAk1l9nIZeuiMukmmwvyoGKJVwvBKrfvSYyiaYDR+asq2PfSLV1qNeuW6LKwg 9YNfROGilVj9C6+J9RBaraPJr98rYMxLx+B8+DtSuwOcQ4kWB3VJCgFhvoGRv43AAbpS SLYw== X-Gm-Message-State: ABuFfoi34OUfxBxXjEZ4FaqgOK+937ZzevmCEkWCdZIJ2txajkDFQcNw jP9CugY8R7GtjYTM/lOv1WK6Pwuy X-Google-Smtp-Source: ACcGV63iB9geQwG14DIHLDeiIDsUgLCDJ4FbkDCn10k3Y+oMYcqz8j6bVOwHG1Uoi9+mIDWbR/3rPw== X-Received: by 2002:a62:99cd:: with SMTP id t74-v6mr23868388pfk.179.1539734455736; Tue, 16 Oct 2018 17:00:55 -0700 (PDT) Received: from majic.sklembedded.com (c-98-210-181-167.hsd1.ca.comcast.net. [98.210.181.167]) by smtp.googlemail.com with ESMTPSA id o12-v6sm17033117pgv.7.2018.10.16.17.00.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Oct 2018 17:00:54 -0700 (PDT) From: Steve Longerbeam To: linux-media@vger.kernel.org Cc: Steve Longerbeam , Philipp Zabel , Mauro Carvalho Chehab , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v5 12/12] media: imx.rst: Update doc to reflect fixes to interlaced capture Date: Tue, 16 Oct 2018 17:00:27 -0700 Message-Id: <20181017000027.23696-13-slongerbeam@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017000027.23696-1-slongerbeam@gmail.com> References: <20181017000027.23696-1-slongerbeam@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Also add an example pipeline for unconverted capture with interweave on SabreAuto. Cleanup some language in various places in the process. Signed-off-by: Steve Longerbeam --- Changes since v4: - Make clear that it is IDMAC channel that does pixel reordering and interweave, not the CSI. Caught by Philipp Zabel. Changes since v3: - none. Changes since v2: - expand on idmac interweave behavior in CSI subdev. - switch second SabreAuto pipeline example to PAL to give both NTSC and PAL examples. - Cleanup some language in various places. --- Documentation/media/v4l-drivers/imx.rst | 103 +++++++++++++++--------- 1 file changed, 66 insertions(+), 37 deletions(-) diff --git a/Documentation/media/v4l-drivers/imx.rst b/Documentation/media/v4l-drivers/imx.rst index 65d3d15eb159..45f3b68865dd 100644 --- a/Documentation/media/v4l-drivers/imx.rst +++ b/Documentation/media/v4l-drivers/imx.rst @@ -22,8 +22,8 @@ memory. Various dedicated DMA channels exist for both video capture and display paths. During transfer, the IDMAC is also capable of vertical image flip, 8x8 block transfer (see IRT description), pixel component re-ordering (for example UYVY to YUYV) within the same colorspace, and -even packed <--> planar conversion. It can also perform a simple -de-interlacing by interleaving even and odd lines during transfer +packed <--> planar conversion. The IDMAC can also perform a simple +de-interlacing by interweaving even and odd lines during transfer (without motion compensation which requires the VDIC). The CSI is the backend capture unit that interfaces directly with @@ -173,15 +173,21 @@ via the SMFC and an IDMAC channel, bypassing IC pre-processing. This source pad is routed to a capture device node, with a node name of the format "ipuX_csiY capture". -Note that since the IDMAC source pad makes use of an IDMAC channel, it -can do pixel reordering within the same colorspace. For example, the -sink pad can take UYVY2X8, but the IDMAC source pad can output YUYV2X8. -If the sink pad is receiving YUV, the output at the capture device can -also be converted to a planar YUV format such as YUV420. - -It will also perform simple de-interlace without motion compensation, -which is activated if the sink pad's field type is an interlaced type, -and the IDMAC source pad field type is set to none. +Note that since the IDMAC source pad makes use of an IDMAC channel, +pixel reordering within the same colorspace can be carried out by the +IDMAC channel. For example, if the CSI sink pad is receiving in UYVY +order, the capture device linked to the IDMAC source pad can capture +in YUYV order. Also, if the CSI sink pad is receiving a packed YUV +format, the capture device can capture a planar YUV format such as +YUV420. + +The IDMAC channel at the IDMAC source pad also supports simple +interweave without motion compensation, which is activated if the source +pad's field type is sequential top-bottom or bottom-top, and the +requested capture interface field type is set to interlaced (t-b, b-t, +or unqualified interlaced). The capture interface will enforce the same +field order as the source pad field order (interlaced-bt if source pad +is seq-bt, interlaced-tb if source pad is seq-tb). This subdev can generate the following event when enabling the second IDMAC source pad: @@ -323,14 +329,14 @@ ipuX_vdic The VDIC carries out motion compensated de-interlacing, with three motion compensation modes: low, medium, and high motion. The mode is -specified with the menu control V4L2_CID_DEINTERLACING_MODE. It has -two sink pads and a single source pad. +specified with the menu control V4L2_CID_DEINTERLACING_MODE. The VDIC +has two sink pads and a single source pad. The direct sink pad receives from an ipuX_csiY direct pad. With this link the VDIC can only operate in high motion mode. When the IDMAC sink pad is activated, it receives from an output -or mem2mem device node. With this pipeline, it can also operate +or mem2mem device node. With this pipeline, the VDIC can also operate in low and medium modes, because these modes require receiving frames from memory buffers. Note that an output or mem2mem device is not implemented yet, so this sink pad currently has no links. @@ -343,8 +349,8 @@ ipuX_ic_prp This is the IC pre-processing entity. It acts as a router, routing data from its sink pad to one or both of its source pads. -It has a single sink pad. The sink pad can receive from the ipuX_csiY -direct pad, or from ipuX_vdic. +This entity has a single sink pad. The sink pad can receive from the +ipuX_csiY direct pad, or from ipuX_vdic. This entity has two source pads. One source pad routes to the pre-process encode task entity (ipuX_ic_prpenc), the other to the @@ -367,8 +373,8 @@ color-space conversion, resizing (downscaling and upscaling), horizontal and vertical flip, and 90/270 degree rotation. Flip and rotation are provided via standard V4L2 controls. -Like the ipuX_csiY IDMAC source, it can also perform simple de-interlace -without motion compensation, and pixel reordering. +Like the ipuX_csiY IDMAC source, this entity also supports simple +de-interlace without motion compensation, and pixel reordering. ipuX_ic_prpvf ------------- @@ -378,18 +384,18 @@ pad from ipuX_ic_prp, and a single source pad. The source pad is routed to a capture device node, with a node name of the format "ipuX_ic_prpvf capture". -It is identical in operation to ipuX_ic_prpenc, with the same resizing -and CSC operations and flip/rotation controls. It will receive and -process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is +This entity is identical in operation to ipuX_ic_prpenc, with the same +resizing and CSC operations and flip/rotation controls. It will receive +and process de-interlaced frames from the ipuX_vdic if ipuX_ic_prp is receiving from ipuX_vdic. -Like the ipuX_csiY IDMAC source, it can perform simple de-interlace -without motion compensation. However, note that if the ipuX_vdic is -included in the pipeline (ipuX_ic_prp is receiving from ipuX_vdic), -it's not possible to use simple de-interlace in ipuX_ic_prpvf, since -the ipuX_vdic has already carried out de-interlacing (with motion -compensation) and therefore the field type output from ipuX_ic_prp can -only be none. +Like the ipuX_csiY IDMAC source, this entity supports simple +interweaving without motion compensation. However, note that if the +ipuX_vdic is included in the pipeline (ipuX_ic_prp is receiving from +ipuX_vdic), it's not possible to use interweave in ipuX_ic_prpvf, +since the ipuX_vdic has already carried out de-interlacing (with +motion compensation) and therefore the field type output from +ipuX_vdic can only be none (progressive). Capture Pipelines ----------------- @@ -514,10 +520,33 @@ On the SabreAuto, an on-board ADV7180 SD decoder is connected to the parallel bus input on the internal video mux to IPU1 CSI0. The following example configures a pipeline to capture from the ADV7180 -video decoder, assuming NTSC 720x480 input signals, with Motion -Compensated de-interlacing. Pad field types assume the adv7180 outputs -"interlaced". $outputfmt can be any format supported by the ipu1_ic_prpvf -entity at its output pad: +video decoder, assuming NTSC 720x480 input signals, using simple +interweave (unconverted and without motion compensation). The adv7180 +must output sequential or alternating fields (field type 'seq-bt' for +NTSC, or 'alternate'): + +.. code-block:: none + + # Setup links + media-ctl -l "'adv7180 3-0021':0 -> 'ipu1_csi0_mux':1[1]" + media-ctl -l "'ipu1_csi0_mux':2 -> 'ipu1_csi0':0[1]" + media-ctl -l "'ipu1_csi0':2 -> 'ipu1_csi0 capture':0[1]" + # Configure pads + media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x480 field:seq-bt]" + media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480]" + media-ctl -V "'ipu1_csi0':2 [fmt:AYUV32/720x480]" + # Configure "ipu1_csi0 capture" interface (assumed at /dev/video4) + v4l2-ctl -d4 --set-fmt-video=field=interlaced_bt + +Streaming can then begin on /dev/video4. The v4l2-ctl tool can also be +used to select any supported YUV pixelformat on /dev/video4. + +This example configures a pipeline to capture from the ADV7180 +video decoder, assuming PAL 720x576 input signals, with Motion +Compensated de-interlacing. The adv7180 must output sequential or +alternating fields (field type 'seq-tb' for PAL, or 'alternate'). +$outputfmt can be any format supported by the ipu1_ic_prpvf entity +at its output pad: .. code-block:: none @@ -529,11 +558,11 @@ entity at its output pad: media-ctl -l "'ipu1_ic_prp':2 -> 'ipu1_ic_prpvf':0[1]" media-ctl -l "'ipu1_ic_prpvf':1 -> 'ipu1_ic_prpvf capture':0[1]" # Configure pads - media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x480]" - media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x480 field:interlaced]" - media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x480 field:interlaced]" - media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x480 field:none]" - media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x480 field:none]" + media-ctl -V "'adv7180 3-0021':0 [fmt:UYVY2X8/720x576 field:seq-tb]" + media-ctl -V "'ipu1_csi0_mux':2 [fmt:UYVY2X8/720x576]" + media-ctl -V "'ipu1_csi0':1 [fmt:AYUV32/720x576]" + media-ctl -V "'ipu1_vdic':2 [fmt:AYUV32/720x576 field:none]" + media-ctl -V "'ipu1_ic_prp':2 [fmt:AYUV32/720x576 field:none]" media-ctl -V "'ipu1_ic_prpvf':1 [fmt:$outputfmt field:none]" Streaming can then begin on the capture device node at