Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5521070pxb; Mon, 14 Feb 2022 00:38:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsv6HnXjf0QxWdGscVtGAib6iVUKZUGbubt4bsWsvhYQB6kqruWQfx+75IBJ3jQf/kRbTB X-Received: by 2002:a17:906:7797:: with SMTP id s23mr6487591ejm.191.1644827884330; Mon, 14 Feb 2022 00:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644827884; cv=none; d=google.com; s=arc-20160816; b=Woxo5e1T7LgJ/Bn063tfvOIgXc42uR/VaLNzxUR7KWayWjftevFLRvPQA5l+/PB/zS +RYeWG7WZVBTg/4tOrY55JJbQxInzvQ4orW+4QGYzNhHKuZOWYBFHCk6l4peFOJwWw9/ cbupQ85//cgOa6jwX4KXUQIMFJ3OQkeCLZU2SwPoqQpXSgsjnVbbu9/gj0Jg9z2UYSrs Jf+Y2S4SYlPrxJBBsKttduSyhhiIuko2ara5tCrASywAb4znVBRg1VhqriLQLcP5EbiR SjcrJMNdu4AXz46IcSE+ytMp5ZbJG1Y2Z1JQL1Bl5VJQV4RDIzuUOCj3I2rzY0+NStJB eTdA== 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=t/hJYfcKldb+BryXl3uVpvv9WjCLYVWvsGgc4Bs5pbE=; b=jHKJMERRD9Fy/kR9DJ8LHYCW5CS6E+jyaEh7W408fqpONKBtuGsmhAiO+NraNm7WR+ k+RpWc94f90Fg53kLitxB19c+3JScPsPdiAKbvz/lTVLJ00x1m8rJC8Em0r/3W/ToABT 5t3lIRNu9/ZtJGXDwDJM13PxFF7KeerR5Ion+cvcjkeBBF0P5Pyz1NZshRWx1SPSHvzY pZ7NPZqeud+7LCX0KphJ+zsmd8ABldk9vyEUZJ2F21SAx51Of3/oF86+JpVE35/QDdUg uy/O76QotkW/CySxZKj9vV9EbJ9oBWSGNNnNGskfIT1UoWb9yheutmSYy1WqAzqpsnB+ e40A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jKVkOfAu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s2si683988edy.363.2022.02.14.00.37.41; Mon, 14 Feb 2022 00:38:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jKVkOfAu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S235046AbiBMKes (ORCPT + 99 others); Sun, 13 Feb 2022 05:34:48 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235030AbiBMKes (ORCPT ); Sun, 13 Feb 2022 05:34:48 -0500 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19C685D673 for ; Sun, 13 Feb 2022 02:34:43 -0800 (PST) Received: by mail-pj1-x102f.google.com with SMTP id m7so11948328pjk.0 for ; Sun, 13 Feb 2022 02:34:43 -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=t/hJYfcKldb+BryXl3uVpvv9WjCLYVWvsGgc4Bs5pbE=; b=jKVkOfAuMk6waiV+V6SYdNdZrHvYTISZZUZjD0isg9cKQ1q5XPAjxyusb1doY6cl3e 9RFAPCmmq4I2C7Ehwsk969Cl2dfz3J9nS6Lphx7FVGcVOdq4BI5xIpBwMJd3Kza1Z61s YZtcMRCmIMpMvOLzvIGEMP3LcdLlAxdprsNn0= 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=t/hJYfcKldb+BryXl3uVpvv9WjCLYVWvsGgc4Bs5pbE=; b=1jJlhyeAw91o8ymSRSEvgNPOXvSREh7uaEQFfpibGv8VTJdw7eUMN/4io4umXqdUBd rJtCrPr1gS3wA+SVv4LyBpYDyFqVqAofLkQneWnyAqBBo+As+JuVbGbaKbnutOFyoYZI m74pmslsMBZ/0DoXcvXfTaLlqH1CqfTAzvQwJZAhuEXZcPJAkdsCJ9Hg8kwx7K1GbuER LuOjZHudgcyvDpX8FRCp77npe3TJKap8xisXz22c/3GtBSPVhEy2Zv2rrU2I/C///Tss h0Y7tsJlK415xzJWh/Faug5FIuqza/UAOQhRlU9sONYLrKVjWc6jSZWOTFvLeDtbRVqR J8ig== X-Gm-Message-State: AOAM531UJKZ4ZuG7Die0Z9sipAn2kv/QTmkQdm/JBU0OGSnLlLPkOYko F3tpOMUbkSMeKDzZozJXTfbgDQ== X-Received: by 2002:a17:90b:1b0e:: with SMTP id nu14mr9017838pjb.44.1644748482473; Sun, 13 Feb 2022 02:34:42 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:3653:bf18:8571:5f26]) by smtp.gmail.com with ESMTPSA id n85sm1589407pfd.142.2022.02.13.02.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Feb 2022 02:34:42 -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, Neil Armstrong , Jonas Karlman , Jernej Skrabec , Sam Ravnborg , Maxime Ripard Subject: [PATCH v7 1/4] drm/bridge: anx7625: send DPCD command to downstream Date: Sun, 13 Feb 2022 18:34:34 +0800 Message-Id: <20220213103437.3363848-1-hsinyi@chromium.org> X-Mailer: git-send-email 2.35.1.265.g69c8d7142f-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 Reviewed-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.35.1.265.g69c8d7142f-goog