Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5338253pxb; Wed, 19 Jan 2022 16:28:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJzb6fkSo0S5MkH6HkmCYeKvEMUBT2N3vwvB1qpkSe1jN4Ln0TXwhXgi9pHH2GgGZtuafRXA X-Received: by 2002:a63:2262:: with SMTP id t34mr953162pgm.341.1642638488187; Wed, 19 Jan 2022 16:28:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642638488; cv=none; d=google.com; s=arc-20160816; b=LisDch5JJit6XuQXxsR2UPvYkM/A/2Y7a7wdSlBJ+oyx2nAWSGSnXT9GxPUOxQksAg rDLtL4OsmGi4IYNXw4a1Ohe9tg1M7QeINXX25goe/2IRICOvB40aiEGlZJUJdX4i2VN2 J+urQAxUGmkZAZ3DwIJaKxanRzXAyJKk/ZX+UsG/EeYKUWM5VCI0w1CvxYfVVk/knBac ANwrOlUtyQwOz2uBEjgpaWk+N3LaD22xBgZXFn5tR45qTSX141bmw/ph/jp8f44K2+3b /EhPRAEa7ywZD7UTAHur0rhsmyN+jsaq6cL/3TisZ5nv5v10IOn+fHO/ye17nQU+uS1V Kh2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=4Tc7nnQFnAv/x3r/yYMhvZGN3p803fSMZ3UHYukD4rU=; b=qrdannlHAFTIt1J9DkSR/4pKOViLyBj6mRR3qlc7xa21e259HNPW7sUcg+6ilpD5o2 YCGf710DP5ldkDRq8fIZcS9JY+W/cLrsWxFizv0jDCkSMtxlbQK4C+L0kaVZEZsCsmsY w830+w/+wet7iWdng9TKh/0niw19Rea2/iQAWuEfFWUtYf9BKGe0ApVvFPmodpvZDuX/ 9/pAi+A58jN7uWExUQP+PoFsXGeAkU6C17LlgAXE6jQqGJnUi3yeWKg0DKlyTY/ba5JW 40u3uJlCFSM4CO2fw6T/arJOjv2oph9xmlXOmNvlOJqUUNBE8fA9QWksu8Icx1mEvDQf PFjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X+6DQO0p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a4si1742809pfv.32.2022.01.19.16.27.56; Wed, 19 Jan 2022 16:28:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X+6DQO0p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345630AbiARJUR (ORCPT + 99 others); Tue, 18 Jan 2022 04:20:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240710AbiARJUI (ORCPT ); Tue, 18 Jan 2022 04:20:08 -0500 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C6A8C06161C for ; Tue, 18 Jan 2022 01:20:08 -0800 (PST) Received: by mail-pf1-x436.google.com with SMTP id s15so12528747pfw.1 for ; Tue, 18 Jan 2022 01:20:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4Tc7nnQFnAv/x3r/yYMhvZGN3p803fSMZ3UHYukD4rU=; b=X+6DQO0pW7rjDivnpTkFLCBkdyUpXqZAgRWD5x9ScFAktHLD6IQNAq1Tnd+GjPMMGK lDSUn+jhguAw2J5zCUYI4wyhwhDS7IgX7ZHKpH8unSKa7eNktQLvVRcfZHxnlkC6H9nd 2QR17HyXWQmIb7qcUzrHWjxdx61Ip+z/mP28w= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4Tc7nnQFnAv/x3r/yYMhvZGN3p803fSMZ3UHYukD4rU=; b=t4x0vfRC8FEgXLtlE66G4U88GAkfYd3Fi5dSseMUZQRoqHWrVqAgJEMfNiNCGP5a4Z hz1KYe0/tZ2Y6bPyDHNypXxd8kJzYpBQQ77Qjx+YoeYkvMv4gVkGy0P8vaoTK6t3W6qk 7a8OOuWMnm+ksxQaFtQLXfy7EOxiuVozSSdp6Y5PUGoSBCzaOO0k/v14TxDaCTU8lbc5 3VQNp5K6VNT+XWbw2SC1a7l943pH1RUdeVxnh4T9+6ARf350lPHdepGVwa+A9Xq/A5LJ UONSq+OOemdmStzdHnLbGq7KkhItRt8YPRqCjqt74Zsu0FnrLocy1AUfLfn1ZANqApEG DBYQ== X-Gm-Message-State: AOAM531/pkrTpU5XDQd3bvsm931qwc6kQFRpvpa6Dj0rzKwWu9sY/kHI hw6rfstwl2y5D7dNQ/TsrO92qQ== X-Received: by 2002:a63:6e86:: with SMTP id j128mr22352192pgc.6.1642497607761; Tue, 18 Jan 2022 01:20:07 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:4448:8072:97f1:64dd]) by smtp.gmail.com with ESMTPSA id y1sm14691501pgs.4.2022.01.18.01.20.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jan 2022 01:20:07 -0800 (PST) From: Hsin-Yi Wang To: Robert Foss , Rob Herring , Xin Ji Cc: David Airlie , Daniel Vetter , Laurent Pinchart , dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Andrzej Hajda , Neil Armstrong , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Maxime Ripard Subject: [PATCH v4 1/4] drm/bridge: anx7625: send DPCD command to downstream Date: Tue, 18 Jan 2022 17:19:59 +0800 Message-Id: <20220118092002.4267-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.34.1.703.g22d0c6ccf7-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xin Ji Send DPCD command to downstream before anx7625 power down, let downstream monitor enter into standby mode. Signed-off-by: Xin Ji Signed-off-by: Hsin-Yi Wang --- v3->v4: Use common DP_AUX_NATIVE_READ/WRITE Previously in: https://patchwork.kernel.org/project/dri-devel/patch/1f36f8bf0a48fb2bba17bacec23700e58c1d407d.1641891874.git.xji@analogixsemi.com/ --- drivers/gpu/drm/bridge/analogix/anx7625.c | 42 +++++++++++++++++++---- drivers/gpu/drm/bridge/analogix/anx7625.h | 2 -- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c index 76662fce4ce61d..17b23940549a42 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.c +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c @@ -129,6 +129,23 @@ static int anx7625_reg_write(struct anx7625_data *ctx, return ret; } +static int anx7625_reg_block_write(struct anx7625_data *ctx, + struct i2c_client *client, + u8 reg_addr, u8 len, u8 *buf) +{ + int ret; + struct device *dev = &client->dev; + + i2c_access_workaround(ctx, client); + + ret = i2c_smbus_write_i2c_block_data(client, reg_addr, len, buf); + if (ret < 0) + dev_err(dev, "write i2c block failed id=%x\n:%x", + client->addr, reg_addr); + + return ret; +} + static int anx7625_write_or(struct anx7625_data *ctx, struct i2c_client *client, u8 offset, u8 mask) @@ -214,8 +231,8 @@ static int wait_aux_op_finish(struct anx7625_data *ctx) return 0; } -static int anx7625_aux_dpcd_read(struct anx7625_data *ctx, - u32 address, u8 len, u8 *buf) +static int anx7625_aux_dpcd_trans(struct anx7625_data *ctx, u8 op, + u32 address, u8 len, u8 *buf) { struct device *dev = &ctx->client->dev; int ret; @@ -231,8 +248,7 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx, addrm = (address >> 8) & 0xFF; addrh = (address >> 16) & 0xFF; - cmd = DPCD_CMD(len, DPCD_READ); - cmd = ((len - 1) << 4) | 0x09; + cmd = DPCD_CMD(len, op); /* Set command and length */ ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, @@ -246,6 +262,9 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx, ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client, AP_AUX_ADDR_19_16, addrh); + if (op == DP_AUX_NATIVE_WRITE) + ret |= anx7625_reg_block_write(ctx, ctx->i2c.rx_p0_client, + AP_AUX_BUFF_START, len, buf); /* Enable aux access */ ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client, AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN); @@ -255,14 +274,17 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx, return -EIO; } - usleep_range(2000, 2100); - ret = wait_aux_op_finish(ctx); if (ret) { dev_err(dev, "aux IO error: wait aux op finish.\n"); return ret; } + /* Write done */ + if (op == DP_AUX_NATIVE_WRITE) + return 0; + + /* Read done, read out dpcd data */ ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client, AP_AUX_BUFF_START, len, buf); if (ret < 0) { @@ -845,7 +867,7 @@ static int anx7625_hdcp_enable(struct anx7625_data *ctx) } /* Read downstream capability */ - anx7625_aux_dpcd_read(ctx, 0x68028, 1, &bcap); + anx7625_aux_dpcd_trans(ctx, DP_AUX_NATIVE_READ, 0x68028, 1, &bcap); if (!(bcap & 0x01)) { pr_warn("downstream not support HDCP 1.4, cap(%x).\n", bcap); return 0; @@ -918,6 +940,7 @@ static void anx7625_dp_stop(struct anx7625_data *ctx) { struct device *dev = &ctx->client->dev; int ret; + u8 data; DRM_DEV_DEBUG_DRIVER(dev, "stop dp output\n"); @@ -929,6 +952,11 @@ static void anx7625_dp_stop(struct anx7625_data *ctx) ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, 0x08, 0x7f); ret |= anx7625_video_mute_control(ctx, 1); + + dev_dbg(dev, "notify downstream enter into standby\n"); + /* Downstream monitor enter into standby mode */ + data = 2; + ret |= anx7625_aux_dpcd_trans(ctx, DP_AUX_NATIVE_WRITE, 0x000600, 1, &data); if (ret < 0) DRM_DEV_ERROR(dev, "IO error : mute video fail\n"); diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h index 56165f5b254c14..64a8ab56529404 100644 --- a/drivers/gpu/drm/bridge/analogix/anx7625.h +++ b/drivers/gpu/drm/bridge/analogix/anx7625.h @@ -242,8 +242,6 @@ #define AP_AUX_COMMAND 0x27 /* com+len */ #define LENGTH_SHIFT 4 -#define DPCD_READ 0x09 -#define DPCD_WRITE 0x08 #define DPCD_CMD(len, cmd) ((((len) - 1) << LENGTH_SHIFT) | (cmd)) /* Bit 0&1: 3D video structure */ -- 2.34.1.703.g22d0c6ccf7-goog