diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 142a21cd9f01..08a25cff77a7 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -5674,6 +5674,85 @@ done: return ret; } +/** + * afe_set_display_stream - command to update AFE dp port params + * + * @rx_port_id: AFE port id + * @stream_idx: dp controller stream index + * @ctl_idx: dp controller index + * + * Returns 0 on success, appropriate error code otherwise + */ +int afe_set_display_stream(u16 rx_port_id, u32 stream_idx, u32 ctl_idx) +{ + int ret; + struct param_hdr_v3 param_hdr; + u32 packed_param_size = 0; + u8 *packed_param_data = NULL; + struct afe_display_stream_idx stream_data; + struct afe_display_ctl_idx ctl_data; + u32 single_param_size = 0; + + memset(¶m_hdr, 0, sizeof(param_hdr)); + memset(&stream_data, 0, sizeof(stream_data)); + memset(&ctl_data, 0, sizeof(ctl_data)); + + packed_param_size = + sizeof(param_hdr) * 2 + sizeof(stream_data) + sizeof(ctl_data); + packed_param_data = kzalloc(packed_param_size, GFP_KERNEL); + if (!packed_param_data) + return -ENOMEM; + packed_param_size = 0; + + /* Set stream index */ + param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE; + param_hdr.instance_id = INSTANCE_ID_0; + param_hdr.param_id = AFE_PARAM_ID_HDMI_DP_MST_VID_IDX_CFG; + param_hdr.param_size = sizeof(struct afe_display_stream_idx); + stream_data.minor_version = 1; + stream_data.stream_idx = stream_idx; + ret = q6common_pack_pp_params(packed_param_data, ¶m_hdr, + (u8 *) &stream_data, &single_param_size); + if (ret) { + pr_err("%s: Failed to pack param data, error %d\n", __func__, + ret); + goto done; + } + packed_param_size += single_param_size; + + /* Set controller dptx index */ + param_hdr.module_id = AFE_MODULE_AUDIO_DEV_INTERFACE; + param_hdr.instance_id = INSTANCE_ID_0; + param_hdr.param_id = AFE_PARAM_ID_HDMI_DPTX_IDX_CFG; + param_hdr.param_size = sizeof(struct afe_display_ctl_idx); + ctl_data.minor_version = 1; + ctl_data.ctl_idx = ctl_idx; + ret = q6common_pack_pp_params(packed_param_data + packed_param_size, + ¶m_hdr, (u8 *) &ctl_data, + &single_param_size); + if (ret) { + pr_err("%s: Failed to pack param data, error %d\n", __func__, + ret); + goto done; + } + packed_param_size += single_param_size; + + pr_debug("%s: rx(0x%x) stream(%d) controller(%d)\n", + __func__, rx_port_id, stream_idx, ctl_idx); + + ret = q6afe_set_params(rx_port_id, q6audio_get_port_index(rx_port_id), + NULL, packed_param_data, packed_param_size); + if (ret) + pr_err("%s: AFE display stream send failed for rx_port:%d ret:%d\n", + __func__, rx_port_id, ret); + +done: + kfree(packed_param_data); + return ret; + +} +EXPORT_SYMBOL(afe_set_display_stream); + int afe_validate_port(u16 port_id) { int ret; diff --git a/include/dsp/apr_audio-v2.h b/include/dsp/apr_audio-v2.h index b32324b81788..0d454c75815a 100644 --- a/include/dsp/apr_audio-v2.h +++ b/include/dsp/apr_audio-v2.h @@ -1726,6 +1726,16 @@ struct afe_loopback_sidetone_gain { u16 gain; } __packed; +struct afe_display_stream_idx { + u32 minor_version; + u32 stream_idx; +} __packed; + +struct afe_display_ctl_idx { + u32 minor_version; + u32 ctl_idx; +} __packed; + struct loopback_cfg_data { u32 loopback_cfg_minor_version; /* Minor version used for tracking the version of the RMC module @@ -2477,7 +2487,9 @@ struct afe_param_id_digi_mic_cfg { } __packed; /* This param id is used to configure HDMI interface */ -#define AFE_PARAM_ID_HDMI_CONFIG 0x00010210 +#define AFE_PARAM_ID_HDMI_CONFIG 0x00010210 +#define AFE_PARAM_ID_HDMI_DP_MST_VID_IDX_CFG 0x000102b5 +#define AFE_PARAM_ID_HDMI_DPTX_IDX_CFG 0x000102b6 /* This version information is used to handle the new * additions to the config interface in future in backward diff --git a/include/dsp/q6afe-v2.h b/include/dsp/q6afe-v2.h index 7c849ba15595..b2bf54769259 100644 --- a/include/dsp/q6afe-v2.h +++ b/include/dsp/q6afe-v2.h @@ -286,6 +286,7 @@ int afe_open(u16 port_id, union afe_port_config *afe_config, int rate); int afe_close(int port_id); int afe_loopback(u16 enable, u16 rx_port, u16 tx_port); int afe_sidetone_enable(u16 tx_port_id, u16 rx_port_id, bool enable); +int afe_set_display_stream(u16 rx_port_id, u32 stream_idx, u32 ctl_idx); int afe_loopback_gain(u16 port_id, u16 volume); int afe_validate_port(u16 port_id); int afe_get_port_index(u16 port_id);