From patchwork Wed Mar 24 07:56:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Verkuil X-Patchwork-Id: 408506 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 02B77C433E1 for ; Wed, 24 Mar 2021 07:57:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEF87619FF for ; Wed, 24 Mar 2021 07:57:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236037AbhCXH5S (ORCPT ); Wed, 24 Mar 2021 03:57:18 -0400 Received: from lb2-smtp-cloud8.xs4all.net ([194.109.24.25]:53243 "EHLO lb2-smtp-cloud8.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235901AbhCXH4r (ORCPT ); Wed, 24 Mar 2021 03:56:47 -0400 Received: from cust-b5b5937f ([IPv6:fc0c:c16d:66b8:757f:c639:739b:9d66:799d]) by smtp-cloud8.xs4all.net with ESMTPA id OyNelvrLxCAEGOyNhlYquz; Wed, 24 Mar 2021 08:56:45 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=s2; t=1616572605; bh=fZ79A/xTJZ3PqF4fkdUC6OWqKO2m1C1YvsZWEkldU/s=; h=To:From:Subject:Message-ID:Date:MIME-Version:Content-Type:From: Subject; b=Ca67zsS+HbgQlD3UqjXubuytG65YZEUu+r0o5EMgFtk9HZDJzuP1iB+tnhhTUTLOk eInv/lLTgwMv7HC05Pv41vQTMVm3rGnL3vQEOKrTJN92+uuM3l0utRXJ+S/Yo+0euj 9s1FFyRhe4T6K4lSHeUa5ij3BUp7czVC+kBI9KABXurGdmDymWfF/brtLuPs0KywKa pUE6wARJtU/sFFLRVs9Pmj7DXBagcOpU2UxbaGlCxaWyTvN60fBT8ZlLamKFlAiiVu KzD1QYMJ8hD8fejzsPzKRRdVs5LlVdDnClstrKJwaKQPdS7xF4/F+/sHUaR5rbr1LI ITutfA5DGY3Uw== To: Linux Media Mailing List Cc: =?utf-8?q?Niklas_S=C3=B6derlund?= From: Hans Verkuil Subject: [PATCH] adv7604: fix HPD support for adv7611/12 Message-ID: Date: Wed, 24 Mar 2021 08:56:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.1 MIME-Version: 1.0 Content-Language: en-US X-CMAE-Envelope: MS4xfMMEc6Jxr+z2qIghm6YbPYhxEQSiejPnYmE9YgjUzxxYbn1KAbPyn8X7Uvn104nQdsfjBKfGEdrxW1TvA0EKfvErVw0furQzVXNRhAgZTQOI1K7UkilP 1v4QBDTu+TRIDnaWTQRE+tKav0R/tYjbnPDH/EliX0w7OxAs+auH7EOXYckYCfhDAfCYQ5VYqqPgoUNj3Dv3TC0mwIkrHqB4ImX3206kJCSmrVimay00gbeP US9g7d0bRjca5Og/1RTiGQ== Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org For the adv7604 the hotplug detect pin is controlled through gpio pins from the SoC, but the adv7611 and adv7612 control the hotplug detect pin themselves. But the driver had no support for this, so the HPD was always high, even when changing the EDID. Add proper support for this to the driver. Tested with an adv7612. Signed-off-by: Hans Verkuil Reviewed-by: Niklas Söderlund diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c index 7547afc85eb1..15bcb88ca2e3 100644 --- a/drivers/media/i2c/adv7604.c +++ b/drivers/media/i2c/adv7604.c @@ -519,10 +519,17 @@ static inline int edid_write_block(struct v4l2_subdev *sd, static void adv76xx_set_hpd(struct adv76xx_state *state, unsigned int hpd) { + const struct adv76xx_chip_info *info = state->info; unsigned int i; - for (i = 0; i < state->info->num_dv_ports; ++i) - gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i)); + if (info->type == ADV7604) { + for (i = 0; i < state->info->num_dv_ports; ++i) + gpiod_set_value_cansleep(state->hpd_gpio[i], hpd & BIT(i)); + } else { + for (i = 0; i < state->info->num_dv_ports; ++i) + io_write_clr_set(&state->sd, 0x20, 0x80 >> i, + (!!(hpd & BIT(i))) << (7 - i)); + } v4l2_subdev_notify(&state->sd, ADV76XX_HOTPLUG, &hpd); } @@ -2826,6 +2833,18 @@ static int adv76xx_core_init(struct v4l2_subdev *sd) io_write(sd, 0x0b, 0x44); /* Power down ESDP block */ cp_write(sd, 0xcf, 0x01); /* Power down macrovision */ + /* HPD */ + if (info->type != ADV7604) { + /* Set manual HPD values to 0 */ + io_write_clr_set(sd, 0x20, 0xc0, 0); + /* + * Set HPA_DELAY to 200 ms and set automatic HPD control + * to: internal EDID is active AND a cable is detected + * AND the manual HPD control is set to 1. + */ + hdmi_write_clr_set(sd, 0x6c, 0xf6, 0x26); + } + /* video format */ io_write_clr_set(sd, 0x02, 0x0f, pdata->alt_gamma << 3); io_write_clr_set(sd, 0x05, 0x0e, pdata->blank_data << 3 |