From patchwork Wed Jul 20 00:03:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Longerbeam X-Patchwork-Id: 9238529 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D82FE607DA for ; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7DF3277D9 for ; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAF6A27A98; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 42D22277D9 for ; Wed, 20 Jul 2016 00:04:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752837AbcGTAEU (ORCPT ); Tue, 19 Jul 2016 20:04:20 -0400 Received: from mail-pa0-f65.google.com ([209.85.220.65]:35518 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752689AbcGTAEQ (ORCPT ); Tue, 19 Jul 2016 20:04:16 -0400 Received: by mail-pa0-f65.google.com with SMTP id cf3so2145782pad.2; Tue, 19 Jul 2016 17:04:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/rE5RQE52jWFwfRAbm0I7L29jLRiJCjkndL5XHx3H+w=; b=phFyFcCmrxI8evjLVIjqvAOecPz0CFqtIbjdaS2nAUwur37D5eSz86mCWxhXY9YQp5 Skj5lQprO7hSkGDEa2LO2v6fKYjkbkS3ZbdLo0zb9bOC4QbaEM758K4J9B4jy4fwejor z5IaQBCaW07Wc6HbvWuSlN+qgrKlEc/xJk/jg18+ZtD7wjG3qNCXOgox3QMegSFs2h0x 6NquV8lvfX9USGUK8EktGUwie75BpVYwFp5yxdjqSZaWjxVmBZkJ45UyKkx1PBPRn+9O t/zMzw1zKjpA2ma1lfB78TcnS4ERLF7RCZdWrfzlcfMbEQnmVPy5EgXsahyGXH/vZV5d LZ2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/rE5RQE52jWFwfRAbm0I7L29jLRiJCjkndL5XHx3H+w=; b=LdkovWhQMmqGhdDauM2EXVbHZThS8yQqYMUTla/zv4e7T8i9MsDm8ztopbLf2wC9Ja WCgJvinYKEUQVyCFMTQfexNrUM1LuM5IYQs/rjHdeWQyYZbkGHJr00CLdbqtp+6dvIOu FUgXdrtJepAoqxjpDxVOItuva/vYW+fBptKeN0qARocawSaSAWkZ0W5+s7QPqZ34TLyx SD+XMYu+Mfs2ZapPZUrPLqZpBoC4pNkpI1FENOErumRPDMBG9PVwWUhoEBp77tVV4GsA /uFq7+7lEzdikTvkuYMKzGwxnNj8aLnLb7a18xUJrU8mbXLXEbKlqOpgCCLyt8F/glkM DZWQ== X-Gm-Message-State: ALyK8tLirGitBftrmQ8THdhymreFSPPwX7DOhVKYiHF9c2mZMA7l4yzeQHBOzBMVnWAXTQ== X-Received: by 10.66.101.1 with SMTP id fc1mr69270168pab.84.1468973041904; Tue, 19 Jul 2016 17:04:01 -0700 (PDT) Received: from mothership.sklembedded.com (c-73-241-2-21.hsd1.ca.comcast.net. [73.241.2.21]) by smtp.googlemail.com with ESMTPSA id ty6sm7107742pac.18.2016.07.19.17.04.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Jul 2016 17:04:01 -0700 (PDT) From: Steve Longerbeam X-Google-Original-From: Steve Longerbeam To: lars@metafoo.de Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Steve Longerbeam Subject: [PATCH v2 04/10] media: adv7180: add support for NEWAVMODE Date: Tue, 19 Jul 2016 17:03:31 -0700 Message-Id: <1468973017-17647-5-git-send-email-steve_longerbeam@mentor.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1468973017-17647-1-git-send-email-steve_longerbeam@mentor.com> References: <1467846004-12731-1-git-send-email-steve_longerbeam@mentor.com> <1468973017-17647-1-git-send-email-steve_longerbeam@mentor.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 Parse the optional v4l2 endpoint DT node. If the V4L2_MBUS_NEWAVMODE parallel bus flag is set, configure the BT.656 bus in NEWAVMODE. Signed-off-by: Steve Longerbeam --- drivers/media/i2c/adv7180.c | 47 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index cb83ebb..667931e9 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -106,6 +107,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_NEWAVMODE 0x02 #define ADV7180_REG_MANUAL_WIN_CTL_1 0x003d #define ADV7180_REG_MANUAL_WIN_CTL_2 0x003e #define ADV7180_REG_MANUAL_WIN_CTL_3 0x003f @@ -214,6 +216,7 @@ struct adv7180_state { struct mutex mutex; /* mutual excl. when accessing chip */ int irq; v4l2_std_id curr_norm; + bool newavmode; bool powered; bool streaming; u8 input; @@ -740,6 +743,8 @@ static int adv7180_g_mbus_config(struct v4l2_subdev *sd, */ cfg->flags = V4L2_MBUS_MASTER | V4L2_MBUS_PCLK_SAMPLE_RISING | V4L2_MBUS_DATA_ACTIVE_HIGH; + if (state->newavmode) + cfg->flags |= V4L2_MBUS_NEWAVMODE; cfg->type = V4L2_MBUS_BT656; } @@ -864,9 +869,15 @@ static int adv7180_init(struct adv7180_state *state) if (ret < 0) return ret; - /* Manually set V bit end position in NTSC mode */ - return adv7180_write(state, ADV7180_REG_NTSC_V_BIT_END, - ADV7180_NTSC_V_BIT_END_MANUAL_NVEND); + if (!state->newavmode) { + /* Manually set V bit end position in NTSC mode */ + ret = adv7180_write(state, ADV7180_REG_NTSC_V_BIT_END, + ADV7180_NTSC_V_BIT_END_MANUAL_NVEND); + if (ret < 0) + return ret; + } + + return 0; } static int adv7180_set_std(struct adv7180_state *state, unsigned int std) @@ -1217,6 +1228,13 @@ static int init_device(struct adv7180_state *state) if (ret) goto out_unlock; + if (state->newavmode) { + ret = adv7180_write(state, ADV7180_REG_VSYNC_FIELD_CTL_1, + ADV7180_VSYNC_FIELD_CTL_1_NEWAVMODE); + if (ret < 0) + goto out_unlock; + } + ret = adv7180_program_std(state); if (ret) goto out_unlock; @@ -1257,6 +1275,27 @@ out_unlock: return ret; } +static void adv7180_of_parse(struct adv7180_state *state) +{ + struct i2c_client *client = state->client; + struct device_node *np = client->dev.of_node; + struct device_node *endpoint; + struct v4l2_of_endpoint ep; + + endpoint = of_graph_get_next_endpoint(np, NULL); + if (!endpoint) { + v4l_warn(client, "endpoint node not found\n"); + return; + } + + v4l2_of_parse_endpoint(endpoint, &ep); + of_node_put(endpoint); + + if (ep.bus_type == V4L2_MBUS_BT656 && + ep.bus.parallel.flags & V4L2_MBUS_NEWAVMODE) + state->newavmode = true; +} + static int adv7180_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1279,6 +1318,8 @@ static int adv7180_probe(struct i2c_client *client, state->field = V4L2_FIELD_INTERLACED; state->chip_info = (struct adv7180_chip_info *)id->driver_data; + adv7180_of_parse(state); + if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) { state->csi_client = i2c_new_dummy(client->adapter, ADV7180_DEFAULT_CSI_I2C_ADDR);