diff options
| author | Haynes Mathew George <hgeorge@codeaurora.org> | 2016-10-27 16:56:21 -0700 |
|---|---|---|
| committer | Haynes Mathew George <hgeorge@codeaurora.org> | 2017-02-08 18:00:28 -0800 |
| commit | 60a73c06525b74f734bd0785cfdde42e22893cd6 (patch) | |
| tree | 9b3a4efc4f9f19c5f67bc6de23136c338a6dc9c5 | |
| parent | 147b2394be6d487f75445ed84794b60c4dc8cfc8 (diff) | |
ASoC: msm: qdsp6v2: Add endianness control for USB devices
Add mixer control to set the endianness of the playback/capture
USB device.
CRs-Fixed: 2003737
Change-Id: I99102c3bb64e321fb3e5df38428e63a406f91d7e
Signed-off-by: Haynes Mathew George <hgeorge@codeaurora.org>
| -rw-r--r-- | include/sound/apr_audio-v2.h | 23 | ||||
| -rw-r--r-- | sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c | 50 | ||||
| -rw-r--r-- | sound/soc/msm/qdsp6v2/q6afe.c | 15 |
3 files changed, 86 insertions, 2 deletions
diff --git a/include/sound/apr_audio-v2.h b/include/sound/apr_audio-v2.h index 1f8bba7e9ab7..3d3a2022bc04 100644 --- a/include/sound/apr_audio-v2.h +++ b/include/sound/apr_audio-v2.h @@ -2471,6 +2471,13 @@ struct afe_param_id_slimbus_cfg { */ #define AFE_PARAM_ID_USB_AUDIO_DEV_PARAMS 0x000102A5 + +/* ID of the parameter used to set the endianness value for the + * USB audio device. It should be used with + * AFE_MODULE_AUDIO_DEV_INTERFACE + */ +#define AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT 0x000102AA + /* Minor version used for tracking USB audio configuration */ #define AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG 0x1 @@ -2486,6 +2493,15 @@ struct afe_param_id_usb_audio_dev_params { u32 dev_token; } __packed; +struct afe_param_id_usb_audio_dev_lpcm_fmt { +/* Minor version used for tracking USB audio device parameter. + * Supported values: AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG + */ + u32 cfg_minor_version; +/* Endianness of actual end USB audio device */ + u32 endian; +} __packed; + /* ID of the parameter used by AFE_PARAM_ID_USB_AUDIO_CONFIG to configure * USB audio interface. It should be used with AFE_MODULE_AUDIO_DEV_INTERFACE */ @@ -2530,13 +2546,18 @@ struct afe_param_id_usb_audio_cfg { u16 reserved; /* device token of actual end USB aduio device */ u32 dev_token; +/* endianness of this interface */ + u32 endian; } __packed; struct afe_usb_audio_dev_param_command { struct apr_hdr hdr; struct afe_port_cmd_set_param_v2 param; struct afe_port_param_data_v2 pdata; - struct afe_param_id_usb_audio_dev_params usb_dev; + union { + struct afe_param_id_usb_audio_dev_params usb_dev; + struct afe_param_id_usb_audio_dev_lpcm_fmt lpcm_fmt; + }; } __packed; /* diff --git a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c index 7b292eef02f8..f081ef066bdd 100644 --- a/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c +++ b/sound/soc/msm/qdsp6v2/msm-dai-q6-v2.c @@ -2077,6 +2077,42 @@ static int msm_dai_q6_usb_audio_cfg_get(struct snd_kcontrol *kcontrol, return 0; } +static int msm_dai_q6_usb_audio_endian_cfg_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; + u32 val = ucontrol->value.integer.value[0]; + + if (dai_data) { + dai_data->port_config.usb_audio.endian = val; + pr_debug("%s: endian = 0x%x\n", __func__, + dai_data->port_config.usb_audio.endian); + } else { + pr_err("%s: dai_data is NULL\n", __func__); + return -EINVAL; + } + + return 0; +} + +static int msm_dai_q6_usb_audio_endian_cfg_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *ucontrol) +{ + struct msm_dai_q6_dai_data *dai_data = kcontrol->private_data; + + if (dai_data) { + ucontrol->value.integer.value[0] = + dai_data->port_config.usb_audio.endian; + pr_debug("%s: endian = 0x%x\n", __func__, + dai_data->port_config.usb_audio.endian); + } else { + pr_err("%s: dai_data is NULL\n", __func__); + return -EINVAL; + } + + return 0; +} + static int msm_dai_q6_afe_enc_cfg_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) { @@ -2327,9 +2363,15 @@ static const struct snd_kcontrol_new usb_audio_cfg_controls[] = { SOC_SINGLE_EXT("USB_AUDIO_RX dev_token", 0, 0, UINT_MAX, 0, msm_dai_q6_usb_audio_cfg_get, msm_dai_q6_usb_audio_cfg_put), + SOC_SINGLE_EXT("USB_AUDIO_RX endian", 0, 0, 1, 0, + msm_dai_q6_usb_audio_endian_cfg_get, + msm_dai_q6_usb_audio_endian_cfg_put), SOC_SINGLE_EXT("USB_AUDIO_TX dev_token", 0, 0, UINT_MAX, 0, msm_dai_q6_usb_audio_cfg_get, msm_dai_q6_usb_audio_cfg_put), + SOC_SINGLE_EXT("USB_AUDIO_TX endian", 0, 0, 1, 0, + msm_dai_q6_usb_audio_endian_cfg_get, + msm_dai_q6_usb_audio_endian_cfg_put), }; static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai) @@ -2401,10 +2443,16 @@ static int msm_dai_q6_dai_probe(struct snd_soc_dai *dai) rc = snd_ctl_add(dai->component->card->snd_card, snd_ctl_new1(&usb_audio_cfg_controls[0], dai_data)); + rc = snd_ctl_add(dai->component->card->snd_card, + snd_ctl_new1(&usb_audio_cfg_controls[1], + dai_data)); break; case AFE_PORT_ID_USB_TX: rc = snd_ctl_add(dai->component->card->snd_card, - snd_ctl_new1(&usb_audio_cfg_controls[1], + snd_ctl_new1(&usb_audio_cfg_controls[2], + dai_data)); + rc = snd_ctl_add(dai->component->card->snd_card, + snd_ctl_new1(&usb_audio_cfg_controls[3], dai_data)); break; } diff --git a/sound/soc/msm/qdsp6v2/q6afe.c b/sound/soc/msm/qdsp6v2/q6afe.c index f1607b8e5d66..2001c7398bb2 100644 --- a/sound/soc/msm/qdsp6v2/q6afe.c +++ b/sound/soc/msm/qdsp6v2/q6afe.c @@ -2657,6 +2657,21 @@ int afe_port_send_usb_dev_param(u16 port_id, union afe_port_config *afe_config) ret = -EINVAL; goto exit; } + + config.pdata.param_id = AFE_PARAM_ID_USB_AUDIO_DEV_LPCM_FMT; + config.pdata.param_size = sizeof(config.lpcm_fmt); + config.lpcm_fmt.cfg_minor_version = + AFE_API_MINIOR_VERSION_USB_AUDIO_CONFIG; + config.lpcm_fmt.endian = afe_config->usb_audio.endian; + + ret = afe_apr_send_pkt(&config, &this_afe.wait[index]); + if (ret) { + pr_err("%s: AFE device param cmd LPCM_FMT failed %d\n", + __func__, ret); + ret = -EINVAL; + goto exit; + } + exit: return ret; } |
