[PATCH 2/2] drm: anx7625: add I2S input stream right justified control

Xin Ji <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
The default audio data stream is left justify. When the
property "analogix,audio-right-justify-enable" is detected,
the code enables right justify.

Signed-off-by: Xin Ji <[email protected]>
---
 drivers/gpu/drm/bridge/analogix/anx7625.c | 9 +++++++++
 drivers/gpu/drm/bridge/analogix/anx7625.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/bridge/analogix/anx7625.c
index c3af88e14f8b..f4bce0000676 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.c
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.c
@@ -1883,6 +1883,9 @@ static int anx7625_parse_dt(struct device *dev,
 	if (of_property_read_bool(np, "analogix,audio-enable"))
 		pdata->audio_en = 1;
 
+	if (of_property_read_bool(np, "analogix,audio-right-justify-enable"))
+		pdata->audio_right_justify = 1;
+
 	return 0;
 }
 
@@ -2083,6 +2086,12 @@ static int anx7625_audio_hw_params(struct device *dev, void *data,
 		ret |= anx7625_write_and(ctx, ctx->i2c.tx_p2_client,
 				AUDIO_CHANNEL_STATUS_6, ~AUDIO_LAYOUT);
 
+	/* Right justified */
+	if (ctx->pdata.audio_right_justify)
+		ret |= anx7625_write_or(ctx, ctx->i2c.tx_p2_client,
+					AUDIO_CONTROL_REGISTER,
+					RIGHT_JUSTIFY_CTRL);
+
 	/* FS */
 	switch (params->sample_rate) {
 	case 32000:
diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.h b/drivers/gpu/drm/bridge/analogix/anx7625.h
index 957d234ec07c..9dd9970d2172 100644
--- a/drivers/gpu/drm/bridge/analogix/anx7625.h
+++ b/drivers/gpu/drm/bridge/analogix/anx7625.h
@@ -154,6 +154,8 @@
 #define HPD_TIME               54000
 
 #define AUDIO_CONTROL_REGISTER 0xe6
+#define RIGHT_JUSTIFY_CTRL     BIT(0)
+
 #define TDM_TIMING_MODE 0x08
 
 #define I2C_ADDR_72_DPTX              0x72
@@ -444,6 +446,7 @@ struct anx7625_platform_data {
 	int is_dpi;
 	int mipi_lanes;
 	int audio_en;
+	int audio_right_justify;
 	int dp_lane0_swing_reg_cnt;
 	u8 lane0_reg_data[DP_TX_SWING_REG_CNT];
 	int dp_lane1_swing_reg_cnt;
-- 
2.25.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.