From patchwork Thu Aug 13 11:36:50 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Towle X-Patchwork-Id: 7007841 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A35F7C05AC for ; Thu, 13 Aug 2015 11:37:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B034520747 for ; Thu, 13 Aug 2015 11:37:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B41B02074E for ; Thu, 13 Aug 2015 11:37:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753034AbbHMLhw (ORCPT ); Thu, 13 Aug 2015 07:37:52 -0400 Received: from 82-70-136-246.dsl.in-addr.zen.co.uk ([82.70.136.246]:53657 "EHLO xk120.dyn.ducie.codethink.co.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752573AbbHMLg6 (ORCPT ); Thu, 13 Aug 2015 07:36:58 -0400 Received: from william by xk120.dyn.ducie.codethink.co.uk with local (Exim 4.80) (envelope-from ) id 1ZPqoX-0000dB-65; Thu, 13 Aug 2015 12:36:53 +0100 From: William Towle To: linux-media@vger.kernel.org, linux-kernel@lists.codethink.co.uk Cc: linux-sh@vger.kernel.org, Guennadi Liakhovetski , Sergei Shtylyov , Laurent Pinchart , Hans Verkuil Subject: [PATCH 2/3] media: adv7604: automatic "default-input" selection Date: Thu, 13 Aug 2015 12:36:50 +0100 Message-Id: <1439465811-936-3-git-send-email-william.towle@codethink.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1439465811-936-1-git-send-email-william.towle@codethink.co.uk> References: <1439465811-936-1-git-send-email-william.towle@codethink.co.uk> Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add logic such that the "default-input" property becomes unnecessary for chips that only have one suitable input (ADV7611 by design, and ADV7612 due to commit 7111cddd "[media] media: adv7604: reduce support to first (digital) input"). Additionally, Ian's documentation in commit bf9c8227 ("[media] media: adv7604: ability to read default input port from DT") states that the "default-input" property should reside directly in the node for adv7612. Hence, also adjust the parsing to make the implementation consistent with this. Signed-off-by: William Towle --- drivers/media/i2c/adv7604.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 5631ec0..5bd81bd 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -2799,7 +2799,7 @@ static int adv76xx_parse_dt(struct adv76xx_state *state) struct device_node *endpoint; struct device_node *np; unsigned int flags; - u32 v; + u32 v= -1; np = state->i2c_clients[ADV76XX_PAGE_IO]->dev.of_node; @@ -2809,14 +2809,25 @@ static int adv76xx_parse_dt(struct adv76xx_state *state) return -EINVAL; v4l2_of_parse_endpoint(endpoint, &bus_cfg); - - if (!of_property_read_u32(endpoint, "default-input", &v)) - state->pdata.default_input = v; - else - state->pdata.default_input = -1; - of_node_put(endpoint); + if (of_property_read_u32(np, "default-input", &v)) { + /* not specified ... can we choose automatically? */ + switch (state->info->type) { + case ADV7611: + v = 0; + break; + case ADV7612: + if (state->info->max_port + == ADV76XX_PAD_HDMI_PORT_A) + v = 0; + /* else is unhobbled, leave unspecified */ + default: + break; + } + } + state->pdata.default_input = v; + flags = bus_cfg.bus.parallel.flags; if (flags & V4L2_MBUS_HSYNC_ACTIVE_HIGH)