Loading sound/soc/codecs/Kconfig +3 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ config SND_SOC_I2C_AND_SPI default y if I2C=y default y if SPI_MASTER=y config SOUND_CONTROL bool "Sound control for wcd9335" menu "CODEC drivers" config SND_SOC_ALL_CODECS Loading sound/soc/codecs/msm8x16-wcd.c +66 −0 Original line number Diff line number Diff line Loading @@ -5815,6 +5815,55 @@ static void msm8x16_wcd_configure_cap(struct snd_soc_codec *codec, } } #ifdef CONFIG_SOUND_CONTROL static struct snd_soc_codec *sound_control_codec_ptr; static ssize_t headphone_gain_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE, "%d %d\n", snd_soc_read(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL), snd_soc_read(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX2_VOL_CTL_B2_CTL) ); } static ssize_t headphone_gain_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int input_l, input_r; sscanf(buf, "%d %d", &input_l, &input_r); if (input_l < -10 || input_l > 20) input_l = 0; if (input_r < -10 || input_r > 20) input_r = 0; snd_soc_write(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL, input_l); snd_soc_write(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX2_VOL_CTL_B2_CTL, input_r); return count; } static struct kobj_attribute headphone_gain_attribute = __ATTR(headphone_gain, 0664, headphone_gain_show, headphone_gain_store); static struct attribute *sound_control_attrs[] = { &headphone_gain_attribute.attr, NULL, }; static struct attribute_group sound_control_attr_group = { .attrs = sound_control_attrs, }; static struct kobject *sound_control_kobj; #endif static int msm8x16_wcd_codec_probe(struct snd_soc_codec *codec) { struct msm8x16_wcd_priv *msm8x16_wcd_priv; Loading @@ -5825,6 +5874,10 @@ static int msm8x16_wcd_codec_probe(struct snd_soc_codec *codec) dev_dbg(codec->dev, "%s()\n", __func__); #ifdef CONFIG_SOUND_CONTROL sound_control_codec_ptr = codec; #endif msm8x16_wcd_priv = kzalloc(sizeof(struct msm8x16_wcd_priv), GFP_KERNEL); if (!msm8x16_wcd_priv) return -ENOMEM; Loading Loading @@ -6364,6 +6417,19 @@ static int msm8x16_wcd_spmi_probe(struct spmi_device *spmi) } dev_set_drvdata(&spmi->dev, msm8x16); spmi_dev_registered_cnt++; #ifdef CONFIG_SOUND_CONTROL sound_control_kobj = kobject_create_and_add("sound_control", kernel_kobj); if (sound_control_kobj == NULL) { pr_warn("%s kobject create failed!\n", __func__); } ret = sysfs_create_group(sound_control_kobj, &sound_control_attr_group); if (ret) { pr_warn("%s sysfs file create failed!\n", __func__); } #endif register_codec: if ((spmi_dev_registered_cnt == MAX_MSM8X16_WCD_DEVICE) && (!ret)) { if (msm8x16_wcd_modules[0].spmi) { Loading Loading
sound/soc/codecs/Kconfig +3 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,9 @@ config SND_SOC_I2C_AND_SPI default y if I2C=y default y if SPI_MASTER=y config SOUND_CONTROL bool "Sound control for wcd9335" menu "CODEC drivers" config SND_SOC_ALL_CODECS Loading
sound/soc/codecs/msm8x16-wcd.c +66 −0 Original line number Diff line number Diff line Loading @@ -5815,6 +5815,55 @@ static void msm8x16_wcd_configure_cap(struct snd_soc_codec *codec, } } #ifdef CONFIG_SOUND_CONTROL static struct snd_soc_codec *sound_control_codec_ptr; static ssize_t headphone_gain_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { return snprintf(buf, PAGE_SIZE, "%d %d\n", snd_soc_read(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL), snd_soc_read(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX2_VOL_CTL_B2_CTL) ); } static ssize_t headphone_gain_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { int input_l, input_r; sscanf(buf, "%d %d", &input_l, &input_r); if (input_l < -10 || input_l > 20) input_l = 0; if (input_r < -10 || input_r > 20) input_r = 0; snd_soc_write(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX1_VOL_CTL_B2_CTL, input_l); snd_soc_write(sound_control_codec_ptr, MSM8X16_WCD_A_CDC_RX2_VOL_CTL_B2_CTL, input_r); return count; } static struct kobj_attribute headphone_gain_attribute = __ATTR(headphone_gain, 0664, headphone_gain_show, headphone_gain_store); static struct attribute *sound_control_attrs[] = { &headphone_gain_attribute.attr, NULL, }; static struct attribute_group sound_control_attr_group = { .attrs = sound_control_attrs, }; static struct kobject *sound_control_kobj; #endif static int msm8x16_wcd_codec_probe(struct snd_soc_codec *codec) { struct msm8x16_wcd_priv *msm8x16_wcd_priv; Loading @@ -5825,6 +5874,10 @@ static int msm8x16_wcd_codec_probe(struct snd_soc_codec *codec) dev_dbg(codec->dev, "%s()\n", __func__); #ifdef CONFIG_SOUND_CONTROL sound_control_codec_ptr = codec; #endif msm8x16_wcd_priv = kzalloc(sizeof(struct msm8x16_wcd_priv), GFP_KERNEL); if (!msm8x16_wcd_priv) return -ENOMEM; Loading Loading @@ -6364,6 +6417,19 @@ static int msm8x16_wcd_spmi_probe(struct spmi_device *spmi) } dev_set_drvdata(&spmi->dev, msm8x16); spmi_dev_registered_cnt++; #ifdef CONFIG_SOUND_CONTROL sound_control_kobj = kobject_create_and_add("sound_control", kernel_kobj); if (sound_control_kobj == NULL) { pr_warn("%s kobject create failed!\n", __func__); } ret = sysfs_create_group(sound_control_kobj, &sound_control_attr_group); if (ret) { pr_warn("%s sysfs file create failed!\n", __func__); } #endif register_codec: if ((spmi_dev_registered_cnt == MAX_MSM8X16_WCD_DEVICE) && (!ret)) { if (msm8x16_wcd_modules[0].spmi) { Loading