Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 548b512

Browse files
Xin-ANXrobertfoss
authored andcommitted
drm/bridge: anx7625: send DPCD command to downstream
Send DPCD command to downstream before anx7625 power down, let downstream monitor enter into standby mode. Signed-off-by: Xin Ji <[email protected]> Signed-off-by: Hsin-Yi Wang <[email protected]> Reviewed-by: Hsin-Yi Wang <[email protected]> Signed-off-by: Robert Foss <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 5357402 commit 548b512

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

drivers/gpu/drm/bridge/analogix/anx7625.c

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,23 @@ static int anx7625_reg_write(struct anx7625_data *ctx,
129129
return ret;
130130
}
131131

132+
static int anx7625_reg_block_write(struct anx7625_data *ctx,
133+
struct i2c_client *client,
134+
u8 reg_addr, u8 len, u8 *buf)
135+
{
136+
int ret;
137+
struct device *dev = &client->dev;
138+
139+
i2c_access_workaround(ctx, client);
140+
141+
ret = i2c_smbus_write_i2c_block_data(client, reg_addr, len, buf);
142+
if (ret < 0)
143+
dev_err(dev, "write i2c block failed id=%x\n:%x",
144+
client->addr, reg_addr);
145+
146+
return ret;
147+
}
148+
132149
static int anx7625_write_or(struct anx7625_data *ctx,
133150
struct i2c_client *client,
134151
u8 offset, u8 mask)
@@ -214,8 +231,8 @@ static int wait_aux_op_finish(struct anx7625_data *ctx)
214231
return 0;
215232
}
216233

217-
static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
218-
u32 address, u8 len, u8 *buf)
234+
static int anx7625_aux_dpcd_trans(struct anx7625_data *ctx, u8 op,
235+
u32 address, u8 len, u8 *buf)
219236
{
220237
struct device *dev = &ctx->client->dev;
221238
int ret;
@@ -231,8 +248,7 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
231248
addrm = (address >> 8) & 0xFF;
232249
addrh = (address >> 16) & 0xFF;
233250

234-
cmd = DPCD_CMD(len, DPCD_READ);
235-
cmd = ((len - 1) << 4) | 0x09;
251+
cmd = DPCD_CMD(len, op);
236252

237253
/* Set command and length */
238254
ret = anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
@@ -246,6 +262,9 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
246262
ret |= anx7625_reg_write(ctx, ctx->i2c.rx_p0_client,
247263
AP_AUX_ADDR_19_16, addrh);
248264

265+
if (op == DP_AUX_NATIVE_WRITE)
266+
ret |= anx7625_reg_block_write(ctx, ctx->i2c.rx_p0_client,
267+
AP_AUX_BUFF_START, len, buf);
249268
/* Enable aux access */
250269
ret |= anx7625_write_or(ctx, ctx->i2c.rx_p0_client,
251270
AP_AUX_CTRL_STATUS, AP_AUX_CTRL_OP_EN);
@@ -255,14 +274,17 @@ static int anx7625_aux_dpcd_read(struct anx7625_data *ctx,
255274
return -EIO;
256275
}
257276

258-
usleep_range(2000, 2100);
259-
260277
ret = wait_aux_op_finish(ctx);
261278
if (ret) {
262279
dev_err(dev, "aux IO error: wait aux op finish.\n");
263280
return ret;
264281
}
265282

283+
/* Write done */
284+
if (op == DP_AUX_NATIVE_WRITE)
285+
return 0;
286+
287+
/* Read done, read out dpcd data */
266288
ret = anx7625_reg_block_read(ctx, ctx->i2c.rx_p0_client,
267289
AP_AUX_BUFF_START, len, buf);
268290
if (ret < 0) {
@@ -845,7 +867,7 @@ static int anx7625_hdcp_enable(struct anx7625_data *ctx)
845867
}
846868

847869
/* Read downstream capability */
848-
anx7625_aux_dpcd_read(ctx, 0x68028, 1, &bcap);
870+
anx7625_aux_dpcd_trans(ctx, DP_AUX_NATIVE_READ, 0x68028, 1, &bcap);
849871
if (!(bcap & 0x01)) {
850872
pr_warn("downstream not support HDCP 1.4, cap(%x).\n", bcap);
851873
return 0;
@@ -918,6 +940,7 @@ static void anx7625_dp_stop(struct anx7625_data *ctx)
918940
{
919941
struct device *dev = &ctx->client->dev;
920942
int ret;
943+
u8 data;
921944

922945
DRM_DEV_DEBUG_DRIVER(dev, "stop dp output\n");
923946

@@ -929,6 +952,11 @@ static void anx7625_dp_stop(struct anx7625_data *ctx)
929952
ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client, 0x08, 0x7f);
930953

931954
ret |= anx7625_video_mute_control(ctx, 1);
955+
956+
dev_dbg(dev, "notify downstream enter into standby\n");
957+
/* Downstream monitor enter into standby mode */
958+
data = 2;
959+
ret |= anx7625_aux_dpcd_trans(ctx, DP_AUX_NATIVE_WRITE, 0x000600, 1, &data);
932960
if (ret < 0)
933961
DRM_DEV_ERROR(dev, "IO error : mute video fail\n");
934962

drivers/gpu/drm/bridge/analogix/anx7625.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@
242242

243243
#define AP_AUX_COMMAND 0x27 /* com+len */
244244
#define LENGTH_SHIFT 4
245-
#define DPCD_READ 0x09
246-
#define DPCD_WRITE 0x08
247245
#define DPCD_CMD(len, cmd) ((((len) - 1) << LENGTH_SHIFT) | (cmd))
248246

249247
/* Bit 0&1: 3D video structure */

0 commit comments

Comments
 (0)