Commit 89de9a06 authored by Vaibhav Agarwal's avatar Vaibhav Agarwal Committed by Greg Kroah-Hartman

greybus: audio: Update device type based on widget types

Device type info shared to above HAL is currently hard coded
to SPK only. Actual device type is identifed while parsing
widget types from topology FW shared by codec module.
Signed-off-by: default avatarVaibhav Agarwal <vaibhav.agarwal@linaro.org>
Reviewed-by: default avatarMark Greer <mgreer@animalcreek.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent a9234bfd
...@@ -36,6 +36,21 @@ enum gbcodec_reg_index { ...@@ -36,6 +36,21 @@ enum gbcodec_reg_index {
GBCODEC_REG_COUNT GBCODEC_REG_COUNT
}; };
/* device_type should be same as defined in audio.h (Android media layer) */
enum {
GBAUDIO_DEVICE_NONE = 0x0,
/* reserved bits */
GBAUDIO_DEVICE_BIT_IN = 0x80000000,
GBAUDIO_DEVICE_BIT_DEFAULT = 0x40000000,
/* output devices */
GBAUDIO_DEVICE_OUT_SPEAKER = 0x2,
GBAUDIO_DEVICE_OUT_WIRED_HEADSET = 0x4,
GBAUDIO_DEVICE_OUT_WIRED_HEADPHONE = 0x8,
/* input devices */
GBAUDIO_DEVICE_IN_BUILTIN_MIC = GBAUDIO_DEVICE_BIT_IN | 0x4,
GBAUDIO_DEVICE_IN_WIRED_HEADSET = GBAUDIO_DEVICE_BIT_IN | 0x10,
};
/* bit 0-SPK, 1-HP, 2-DAC, /* bit 0-SPK, 1-HP, 2-DAC,
* 4-MIC, 5-HSMIC, 6-MIC2 * 4-MIC, 5-HSMIC, 6-MIC2
*/ */
...@@ -144,6 +159,8 @@ struct gbaudio_module_info { ...@@ -144,6 +159,8 @@ struct gbaudio_module_info {
/* need to share this info to above user space */ /* need to share this info to above user space */
int manager_id; int manager_id;
char name[NAME_SIZE]; char name[NAME_SIZE];
unsigned int ip_devices;
unsigned int op_devices;
/* jack related */ /* jack related */
char jack_name[NAME_SIZE]; char jack_name[NAME_SIZE];
......
...@@ -353,8 +353,8 @@ static int gb_audio_probe(struct gb_bundle *bundle, ...@@ -353,8 +353,8 @@ static int gb_audio_probe(struct gb_bundle *bundle,
desc.vid = 2; /* todo */ desc.vid = 2; /* todo */
desc.pid = 3; /* todo */ desc.pid = 3; /* todo */
desc.cport = gbmodule->dev_id; desc.cport = gbmodule->dev_id;
desc.op_devices = 0x2; /* todo */ desc.op_devices = gbmodule->op_devices;
desc.ip_devices = 0x0; /* todo */ desc.ip_devices = gbmodule->ip_devices;
gbmodule->manager_id = gb_audio_manager_add(&desc); gbmodule->manager_id = gb_audio_manager_add(&desc);
dev_dbg(dev, "Add GB Audio device:%s\n", gbmodule->name); dev_dbg(dev, "Add GB Audio device:%s\n", gbmodule->name);
......
...@@ -665,15 +665,20 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module, ...@@ -665,15 +665,20 @@ static int gbaudio_tplg_create_widget(struct gbaudio_module_info *module,
case snd_soc_dapm_spk: case snd_soc_dapm_spk:
*dw = (struct snd_soc_dapm_widget) *dw = (struct snd_soc_dapm_widget)
SND_SOC_DAPM_SPK(w->name, gbcodec_event_spk); SND_SOC_DAPM_SPK(w->name, gbcodec_event_spk);
module->op_devices |= GBAUDIO_DEVICE_OUT_SPEAKER;
break; break;
case snd_soc_dapm_hp: case snd_soc_dapm_hp:
*dw = (struct snd_soc_dapm_widget) *dw = (struct snd_soc_dapm_widget)
SND_SOC_DAPM_HP(w->name, gbcodec_event_hp); SND_SOC_DAPM_HP(w->name, gbcodec_event_hp);
module->num_jacks++; module->num_jacks++;
module->op_devices |= (GBAUDIO_DEVICE_OUT_WIRED_HEADSET
| GBAUDIO_DEVICE_OUT_WIRED_HEADPHONE);
module->ip_devices |= GBAUDIO_DEVICE_IN_WIRED_HEADSET;
break; break;
case snd_soc_dapm_mic: case snd_soc_dapm_mic:
*dw = (struct snd_soc_dapm_widget) *dw = (struct snd_soc_dapm_widget)
SND_SOC_DAPM_MIC(w->name, gbcodec_event_int_mic); SND_SOC_DAPM_MIC(w->name, gbcodec_event_int_mic);
module->ip_devices |= GBAUDIO_DEVICE_IN_BUILTIN_MIC;
break; break;
case snd_soc_dapm_output: case snd_soc_dapm_output:
*dw = (struct snd_soc_dapm_widget)SND_SOC_DAPM_OUTPUT(w->name); *dw = (struct snd_soc_dapm_widget)SND_SOC_DAPM_OUTPUT(w->name);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment