From patchwork Fri Jun 4 21:22:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12300793 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A1DDC4743C for ; Fri, 4 Jun 2021 21:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0C457613F4 for ; Fri, 4 Jun 2021 21:22:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231183AbhFDVYS (ORCPT ); Fri, 4 Jun 2021 17:24:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhFDVYS (ORCPT ); Fri, 4 Jun 2021 17:24:18 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 513F4C061766; Fri, 4 Jun 2021 14:22:31 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id u30so10750901qke.7; Fri, 04 Jun 2021 14:22:31 -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:mime-version :content-transfer-encoding; bh=u2ehOPdLCxDGJlmzkQMD3kIcddHWnEQ5Jk2pA+91fIU=; b=k8dPMztRjjyTsNv226sWB48DA8xKH+e968NzONYGYa76lTxOyDXrh89SZ+nEwdJrn9 952+WU3vG3tQYM02ZI2vd/N66/ET7LnpPwku9eLp33U7PFNcZtWJM7t7HrZKGaieyPCh RvkvoObyfQYC2mVJLHU87pBXUgiT2HfCmjbWl+mB6WhWp6ZjXZ2ovdbxqDcff4eEbhQo RAAdD0lrpcqk6RtEJEGf72TJMmGL2UtlVXA99QOiQ6IH029CVCgaRFnJwHIafTKuabfL eVSq0mkvlP0qPTAL/vMf9tDTYdEF3Iv6MG4p9EQN7agYMAfS+Ezq91sPoneQkPwG+mUt 2TEA== 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:mime-version :content-transfer-encoding; bh=u2ehOPdLCxDGJlmzkQMD3kIcddHWnEQ5Jk2pA+91fIU=; b=MiAs6+Z1tjPRMGUYQ46HktFwZUNAMYsntKenhjUDyxqOdNdvRp5mCTEGWqm5nzbAgc on/qWWnXsRR/BG3rK+PL8ChFh1cH/ROiCTUOMrX7OBBfM4PlLlanqK4qYTglo9TBAsY6 wnMZpw5hftYbhnXs4eF1QzFectU9aKcn+dPItmGE5qx3DSN6TC0rhUNRLSZitnHb0UFs uIQ8mjs7MlWv7ssTzmgM1hT4e0MKvo5+CM81ubRHXxJzAqg8DpQmzBmxvGXSwR9ASrC+ E9sEk7IzCYsbzt6CsgKo6iBNRmpOXbQPav1CKC+zguQzlZ8g3G0OOg2/K1epdWZ4hhVv gu5A== X-Gm-Message-State: AOAM532GWwGzBy8dSPsx5EO2IZ11QEN3NvWzFGuNYq69QDDC4AX6UPBu kpjPKYD9DyqFVHLYBLwJC8Y= X-Google-Smtp-Source: ABdhPJwz/U/aqSU+Zamv8vU01Ojuv1XBaMsJE+Mr786dAVgxaTexdul9clfvIeKVMgpCiifWD9+Iyg== X-Received: by 2002:a37:6b47:: with SMTP id g68mr6268767qkc.89.1622841750443; Fri, 04 Jun 2021 14:22:30 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:5e11:28ac:75e2:dfae]) by smtp.gmail.com with ESMTPSA id h5sm4213892qtu.75.2021.06.04.14.22.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 14:22:30 -0700 (PDT) From: Fabio Estevam To: hverkuil-cisco@xs4all.nl Cc: lars@metafoo.de, matthew.michilot@gmail.com, tharvey@gateworks.com, linux-media@vger.kernel.org, niklas.soderlund@ragnatech.se, robh+dt@kernel.org, devicetree@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 1/2] dt-bindings: adv7180: Introduce 'adv,force-bt656-4' property Date: Fri, 4 Jun 2021 18:22:16 -0300 Message-Id: <20210604212217.70518-1-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Captured NTSC video would be out of sync when using the adv7280 with the BT.656-4 protocol. Certain registers (0x04, 0x31, 0xE6) need to be configured properly to ensure BT.656-4 compatibility. Introduce the 'adv,force-bt656-4' property to allow the ADV7280 behavior to be consistent with the ADV7180, where BT.656-4 timing is used by default. Signed-off-by: Fabio Estevam Acked-by: Rob Herring --- Changes since v1: - Remove the part number from the property name (Rob) Documentation/devicetree/bindings/media/i2c/adv7180.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml index bcfd93739b4f..83e47b0c9fa2 100644 --- a/Documentation/devicetree/bindings/media/i2c/adv7180.yaml +++ b/Documentation/devicetree/bindings/media/i2c/adv7180.yaml @@ -35,6 +35,11 @@ properties: powerdown-gpios: maxItems: 1 + adv,force-bt656-4: + description: + Indicates that the output is a BT.656-4 compatible stream. + type: boolean + port: $ref: /schemas/graph.yaml#/properties/port From patchwork Fri Jun 4 21:22:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 12300795 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 180E9C4743E for ; Fri, 4 Jun 2021 21:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F104B613F8 for ; Fri, 4 Jun 2021 21:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231189AbhFDVYW (ORCPT ); Fri, 4 Jun 2021 17:24:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhFDVYV (ORCPT ); Fri, 4 Jun 2021 17:24:21 -0400 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F62CC061766; Fri, 4 Jun 2021 14:22:34 -0700 (PDT) Received: by mail-qv1-xf2b.google.com with SMTP id im10so4824212qvb.3; Fri, 04 Jun 2021 14:22:34 -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=ezTV+OzOLi9CptsqU6k+KBEk+Xlfv3f///KA0MIi6U0=; b=sTlhzcqPM87ea0l8D+Wd5U3ppXJB3g9EUqPojbs8WCalJTm5mBPmndLy4VcD4Pkuem XgrzWwGFyeLuQ46R6IJ2lfXBOJnrHRNFOLD+LXw4T7uHQ1zIu3AqyRne0NMJloYPv0YC OX8+eiavUq/ylSB4P+PyDUKOH330DMES5DnjrGCfDvOf0NF4BkpuUoR853IDCFReWcAj uWxdKihlrE+y3UnCJL2AHVfXK//vgkGNVTna286Qna7thfv5ZlTdbwzpetHv8tRmJz9Q 44ysjLb74WdMjaavRL6W38uMyJwxsKvtdh9GbhaYLYhBneQloCO/+RM3WEe7QtC+eF2J emfg== 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=ezTV+OzOLi9CptsqU6k+KBEk+Xlfv3f///KA0MIi6U0=; b=f5iBoC3rRBI8z+v7yO6s+96eaOl+nlLBAcy7wXs5zaZp2N9CmjsjOPo31sapuxtrrC Wwduzv4obrkB2Nm469cNRCJPhsSu9HiGzE9GTKOHKQTtq+oxgTifuK2icakzYcFwmO8Q fAjSXLIBBK2XfMu74gW66xWy4h6ucqyuQONJ+C3LQl5XSTB7eDDBZ6Yyk/6Zqm/ROHjk QNvteXW7jOkqGD0N8YwsKVNIxJQyp0KZKNfzPpBxlZg2uQ9TAgIIi4G65auDYdLGRMtS 5Y+PJWCLFA5hnzT7TEJH2N+RSQcKNjV9JjFQx4wP6+mwCrGHhL5gVS69yGIB5gtre3Ma ZQUg== X-Gm-Message-State: AOAM531DG9B1rbXSqbwjU/TlIqnpTWTDHTeFcqHsXAr0ZmPdfdYo0IT3 OxnI8BNLh0+ZZvm+458Tkb4= X-Google-Smtp-Source: ABdhPJw+BfRFhvWnEEk2bSJ1ykOGEJ/6ToCGnng0fPtdDkxtTk0GNl2glZ/qEAChFwVIkknafSVriQ== X-Received: by 2002:a05:6214:2269:: with SMTP id gs9mr6560455qvb.57.1622841753700; Fri, 04 Jun 2021 14:22:33 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:485:504a:5e11:28ac:75e2:dfae]) by smtp.gmail.com with ESMTPSA id h5sm4213892qtu.75.2021.06.04.14.22.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 14:22:33 -0700 (PDT) From: Fabio Estevam To: hverkuil-cisco@xs4all.nl Cc: lars@metafoo.de, matthew.michilot@gmail.com, tharvey@gateworks.com, linux-media@vger.kernel.org, niklas.soderlund@ragnatech.se, robh+dt@kernel.org, devicetree@vger.kernel.org, Fabio Estevam Subject: [PATCH v2 2/2] media: i2c: adv7180: fix adv7280 BT.656-4 compatibility Date: Fri, 4 Jun 2021 18:22:17 -0300 Message-Id: <20210604212217.70518-2-festevam@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210604212217.70518-1-festevam@gmail.com> References: <20210604212217.70518-1-festevam@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org From: Matthew Michilot Captured video would be out of sync when using the adv7280 with the BT.656-4 protocol. Certain registers (0x04, 0x31, 0xE6) had to be configured properly to ensure BT.656-4 compatibility. An error in the adv7280 reference manual suggested that EAV/SAV mode was enabled by default, however upon inspecting register 0x31, it was determined to be disabled by default. Signed-off-by: Matthew Michilot Reviewed-by: Tim Harvey [fabio: Introduce "adv,force-bt656-4" to not affect the existing users] Signed-off-by: Fabio Estevam Reviewed-by: Tim Harvey Tested-by: Tim Harvey --- Changes since v1: - Remove the part number from the property name (Rob) drivers/media/i2c/adv7180.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 44bb6fe85644..a532df813d74 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -94,6 +94,7 @@ #define ADV7180_REG_SHAP_FILTER_CTL_1 0x0017 #define ADV7180_REG_CTRL_2 0x001d #define ADV7180_REG_VSYNC_FIELD_CTL_1 0x0031 +#define ADV7180_VSYNC_FIELD_CTL_1_NEWAV 0x12 #define ADV7180_REG_MANUAL_WIN_CTL_1 0x003d #define ADV7180_REG_MANUAL_WIN_CTL_2 0x003e #define ADV7180_REG_MANUAL_WIN_CTL_3 0x003f @@ -216,6 +217,7 @@ struct adv7180_state { struct i2c_client *vpp_client; const struct adv7180_chip_info *chip_info; enum v4l2_field field; + bool force_bt656_4; }; #define to_adv7180_sd(_ctrl) (&container_of(_ctrl->handler, \ struct adv7180_state, \ @@ -963,10 +965,26 @@ static int adv7182_init(struct adv7180_state *state) adv7180_write(state, ADV7180_REG_EXTENDED_OUTPUT_CONTROL, 0x57); adv7180_write(state, ADV7180_REG_CTRL_2, 0xc0); } else { - if (state->chip_info->flags & ADV7180_FLAG_V2) - adv7180_write(state, - ADV7180_REG_EXTENDED_OUTPUT_CONTROL, - 0x17); + if (state->chip_info->flags & ADV7180_FLAG_V2) { + if (state->force_bt656_4) { + /* ITU-R BT.656-4 compatible */ + adv7180_write(state, + ADV7180_REG_EXTENDED_OUTPUT_CONTROL, + ADV7180_EXTENDED_OUTPUT_CONTROL_NTSCDIS); + /* Manually set NEWAVMODE */ + adv7180_write(state, + ADV7180_REG_VSYNC_FIELD_CTL_1, + ADV7180_VSYNC_FIELD_CTL_1_NEWAV); + /* Manually set V bit end position in NTSC mode */ + adv7180_write(state, + ADV7180_REG_NTSC_V_BIT_END, + ADV7180_NTSC_V_BIT_END_MANUAL_NVEND); + } else { + adv7180_write(state, + ADV7180_REG_EXTENDED_OUTPUT_CONTROL, + 0x17); + } + } else adv7180_write(state, ADV7180_REG_EXTENDED_OUTPUT_CONTROL, @@ -1314,6 +1332,7 @@ static int init_device(struct adv7180_state *state) static int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { + struct device_node *np = client->dev.of_node; struct adv7180_state *state; struct v4l2_subdev *sd; int ret; @@ -1338,6 +1357,9 @@ static int adv7180_probe(struct i2c_client *client, return ret; } + if (of_property_read_bool(np, "adv,force-bt656-4")) + state->force_bt656_4 = true; + if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) { state->csi_client = i2c_new_dummy_device(client->adapter, ADV7180_DEFAULT_CSI_I2C_ADDR);