ASoC: cs35l35: Add Boost Inductor Calculation
Subsystems (4)
PATCH 4/4 ASoC: cs35l35: Add multi-device synchronisation
In reply to Charles KeepaxThis patch adds multi-device synchronisation capabilities to the CS35L35 amp.
In stereo mode you can select to have the devices communicate certain features to each other. Add options to allow the amps to synchronise the audio group delay, the brown out protection and the over temperature warning.
--- sound/soc/codecs/cs35l35.c | 48 +++++++++++++++++++++++++++++++++++++++++++--- sound/soc/codecs/cs35l35.h | 9 +++++++++ 2 files changed, 54 insertions(+), 3 deletions(-)
sound/soc/codecs/cs35l35.c +45 -3
@@ -310,11 +310,49 @@ static const struct snd_kcontrol_new cs35l35_aud_controls[] = { amp_gain_tlv), }; -static const struct snd_kcontrol_new cs35l35_adv_controls[] = { +static int cs35l35_put_sync (struct snd_kcontrol *kcontrol, +struct snd_ctl_elem_value *ucontrol) +{ +struct snd_soc_codec *codec =snd_soc_kcontrol_codec (kcontrol); +struct snd_soc_dapm_context *dapm =snd_soc_codec_get_dapm (codec); +struct cs35l35_private *cs35l35 =snd_soc_codec_get_drvdata (codec); +unsigned int val; +int ret; + +snd_soc_dapm_mutex_lock (dapm); + + ret =regmap_read (cs35l35->regmap,CS35L35_PWRCTL1 , &val); +if (ret) { +dev_err (cs35l35->dev,"Failed to check power state: %d\n" , ret); + goto err; + } + +if (!(val &CS35L35_PDN_ALL )) { +dev_err (cs35l35->dev,"Can't change sync when active\n" ); + ret = -EBUSY ; + goto err; + } + + ret =snd_soc_put_volsw (kcontrol, ucontrol); + +err: +snd_soc_dapm_mutex_unlock (dapm); + +return ret; +} + +static const struct snd_kcontrol_new cs35l35_stereo_controls[] = {SOC_SINGLE_SX_TLV ("Digital Advisory Volume" ,CS35L35_ADV_DIG_VOL ,0 ,0x34 ,0xE4 , dig_vol_tlv),SOC_SINGLE_TLV ("Analog Advisory Volume" ,CS35L35_AMP_GAIN_ADV_CTL ,0 ,19 ,0 , amp_gain_tlv), + +SOC_SINGLE_EXT ("SYNC Audio" ,CS35L35_MULT_DEV_SYNCH2 ,1 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC VPBR" ,CS35L35_MULT_DEV_SYNCH2 ,2 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC OTW" ,CS35L35_MULT_DEV_SYNCH2 ,3 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), };static const struct snd_soc_dapm_widget cs35l35_dapm_widgets[] = {
@@ -872,8 +910,12 @@ static int cs35l35_codec_probe(struct snd_soc_codec *codec)regmap_update_bits (cs35l35->regmap,CS35L35_CLASS_H_CTL ,CS35L35_CH_STEREO_MASK ,1 <<CS35L35_CH_STEREO_SHIFT ); - ret =snd_soc_add_codec_controls (codec, cs35l35_adv_controls, -ARRAY_SIZE (cs35l35_adv_controls)); + +regmap_update_bits (cs35l35->regmap,CS35L35_MULT_DEV_SYNCH2 , +CS35L35_SYNC_EN_MASK ,1 ); + + ret =snd_soc_add_codec_controls (codec, cs35l35_stereo_controls, +ARRAY_SIZE (cs35l35_stereo_controls));if (ret)return ret; }
sound/soc/codecs/cs35l35.h +9 -0
@@ -273,6 +273,15 @@#define CS35L35_VMON_OVFL 0x08#define CS35L35_IMON_OVFL 0x04 +/* Mulit-Device Sync */ +#define CS35L35_SYNC_EN_MASK 0x01 +#define CS35L35_SYNC_MS_MASK 0x20 +#define CS35L35_SYNC_MS_SHIFT 5 +#define CS35L35_SYNC_MS_CTRL_MASK 0x10 +#define CS35L35_SYNC_MS_CTRL_SHIFT 4 +#define CS35L35_SYNC_CLK_SEL_MASK 0x02 +#define CS35L35_SYNC_CLK_SEL_SHIFT 1 +#define CS35L35_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE | \ SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE)
Signature · 1 line
2.1.4
PATCH 1/4 ASoC: cs35l35: Add Boost Inductor Calculation
From: Brian Austin <[email protected]>
Add the Boost Inductor parameters based off the size of the inductor on the HW setup
--- include/sound/cs35l35.h | 2 ++ sound/soc/codecs/cs35l35.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l35.h | 6 ++++ 3 files changed, 90 insertions(+)
include/sound/cs35l35.h +2 -0
@@ -99,6 +99,8 @@ struct cs35l35_platform_data {bool shared_bst;/* Specifies this amp is using an external boost supply */ bool ext_bst; +/* Inductor Value */ +int boost_ind;/* ClassH Algorithm */ struct classh_cfg classh_algo;/* Monitor Config */
sound/soc/codecs/cs35l35.c +82 -0
100 lines not on this page · raw message
sound/soc/codecs/cs35l35.h +6 -0
@@ -200,6 +200,12 @@#define CS35L35_SP_I2S_DRV_MASK 0x03#define CS35L35_SP_I2S_DRV_SHIFT 0 +/* Boost Converter Config */ +#define CS35L35_BST_CONV_COEFF_MASK 0xFF +#define CS35L35_BST_CONV_SLOPE_MASK 0xFF +#define CS35L35_BST_CONV_LBST_MASK 0x03 +#define CS35L35_BST_CONV_SWFREQ_MASK 0xF0 +/* Class H Algorithm Control */ #define CS35L35_CH_STEREO_MASK 0x40#define CS35L35_CH_STEREO_SHIFT 6
Signature · 1 line
2.1.4
PATCH 2/4 ASoC: cs35l35: Add DT handling for Inductor
In reply to a message not in the archiveFrom: Brian Austin <[email protected]>
Need to specify the inductor size in nH. This is a required property.
--- Documentation/devicetree/bindings/sound/cs35l35.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/cs35l35.txt +3 -0
@@ -16,6 +16,9 @@ Required properties: (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for further information relating to interrupt properties) + - cirrus,boost-ind-nanohenry: Inductor value for boost converter. The value is + in nH and they can be values of 1000nH, 1200nH, 1500nH, and 2200nH. + Optional properties: - reset-gpios : gpio used to reset the amplifier
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/4 ASoC: cs35l35: Correctly handle 0 for bst_ipk
In reply to a message not in the archiveZero is a totally valid value to specify for the bst_ipk, as such we should append CS35L35_VALID_PDATA to ensure that it actually makes it into the register value.
--- sound/soc/codecs/cs35l35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs35l35.c +1 -1
@@ -1269,7 +1269,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,return -EINVAL ; } - pdata->bst_ipk = (val32 -1680 ) /110 ; + pdata->bst_ipk = ((val32 -1680 ) /110 ) |CS35L35_VALID_PDATA ; } ret =of_property_read_u32 (np,"cirrus,boost-ind-nanohenry" , &val32);
Signature · 6 lines
2.1.4 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "ASoC: cs35l35: Correctly handle 0 for bst_ipk" to the asoc tree
In reply to a message not in the archiveThe patch
ASoC: cs35l35: Correctly handle 0 for bst_ipk
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
486fb9590302f811d44fa15401e1736679d33736Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax-yzvPICuk2AATkU/[email protected]>
Date: Thu, 18 May 2017 16:32:38 +0100
Subject: [PATCH] ASoC: cs35l35: Correctly handle 0 for bst_ipk
Zero is a totally valid value to specify for the bst_ipk, as such we should append CS35L35_VALID_PDATA to ensure that it actually makes it into the register value.
--- sound/soc/codecs/cs35l35.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/cs35l35.c +1 -1
@@ -1269,7 +1269,7 @@ static int cs35l35_handle_of_data(struct i2c_client *i2c_client,return -EINVAL ; } - pdata->bst_ipk = (val32 -1680 ) /110 ; + pdata->bst_ipk = ((val32 -1680 ) /110 ) |CS35L35_VALID_PDATA ; } ret =of_property_read_u32 (np,"cirrus,boost-ind-nanohenry" , &val32);
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "ASoC: cs35l35: Add DT handling for Inductor" to the asoc tree
In reply to a message not in the archiveThe patch
ASoC: cs35l35: Add DT handling for Inductor
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
cff7597a46454cf0ef0de7340dfb3f6bc0855777Mon Sep 17 00:00:00 2001
From: Brian Austin <[email protected]>
Date: Thu, 18 May 2017 16:32:37 +0100
Subject: [PATCH] ASoC: cs35l35: Add DT handling for Inductor
Need to specify the inductor size in nH. This is a required property.
--- Documentation/devicetree/bindings/sound/cs35l35.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/devicetree/bindings/sound/cs35l35.txt +3 -0
@@ -16,6 +16,9 @@ Required properties: (See Documentation/devicetree/bindings/interrupt-controller/interrupts.txt for further information relating to interrupt properties) + - cirrus,boost-ind-nanohenry: Inductor value for boost converter. The value is + in nH and they can be values of 1000nH, 1200nH, 1500nH, and 2200nH. + Optional properties: - reset-gpios : gpio used to reset the amplifier
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Applied "ASoC: cs35l35: Add Boost Inductor Calculation" to the asoc tree
In reply to a message not in the archiveThe patch
ASoC: cs35l35: Add Boost Inductor Calculation
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
b7c752d68aee9c066cb0bd2f24ee73aed64575e8Mon Sep 17 00:00:00 2001
From: Brian Austin <[email protected]>
Date: Thu, 18 May 2017 16:32:36 +0100
Subject: [PATCH] ASoC: cs35l35: Add Boost Inductor Calculation
Add the Boost Inductor parameters based off the size of the inductor on the HW setup
--- include/sound/cs35l35.h | 2 ++ sound/soc/codecs/cs35l35.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++ sound/soc/codecs/cs35l35.h | 6 ++++ 3 files changed, 90 insertions(+)
include/sound/cs35l35.h +2 -0
@@ -99,6 +99,8 @@ struct cs35l35_platform_data {bool shared_bst;/* Specifies this amp is using an external boost supply */ bool ext_bst; +/* Inductor Value */ +int boost_ind;/* ClassH Algorithm */ struct classh_cfg classh_algo;/* Monitor Config */
sound/soc/codecs/cs35l35.c +82 -0
100 lines not on this page · raw message
sound/soc/codecs/cs35l35.h +6 -0
@@ -200,6 +200,12 @@#define CS35L35_SP_I2S_DRV_MASK 0x03#define CS35L35_SP_I2S_DRV_SHIFT 0 +/* Boost Converter Config */ +#define CS35L35_BST_CONV_COEFF_MASK 0xFF +#define CS35L35_BST_CONV_SLOPE_MASK 0xFF +#define CS35L35_BST_CONV_LBST_MASK 0x03 +#define CS35L35_BST_CONV_SWFREQ_MASK 0xF0 +/* Class H Algorithm Control */ #define CS35L35_CH_STEREO_MASK 0x40#define CS35L35_CH_STEREO_SHIFT 6
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
DQoNCk9uIDUvMTgvMTcsIDEwOjMyIEFNLCAiQ2hhcmxlcyBLZWVwYXgiIDxja2VlcGF4QG9wZW5z b3VyY2Uud29sZnNvbm1pY3JvLmNvbT4gd3JvdGU6DQoNCiAgICBGcm9tOiBCcmlhbiBBdXN0aW4g PGJyaWFuLmF1c3RpbkBjaXJydXMuY29tPg0KICAgIA0KICAgIEFkZCB0aGUgQm9vc3QgSW5kdWN0 b3IgcGFyYW1ldGVycyBiYXNlZCBvZmYgdGhlIHNpemUgb2YgdGhlIGluZHVjdG9yDQogICAgb24g dGhlIEhXIHNldHVwDQogICAgDQogICAgU2lnbmVkLW9mZi1ieTogQnJpYW4gQXVzdGluIDxicmlh bi5hdXN0aW5AY2lycnVzLmNvbT4NCiAgICBTaWduZWQtb2ZmLWJ5OiBDaGFybGVzIEtlZXBheCA8 Y2tlZXBheEBvcGVuc291cmNlLndvbGZzb25taWNyby5jb20+DQogICAgLS0tDQpGb3IgdGhlIHNl cmllcw0KQWNrZWQtYnk6IEJyaWFuIEF1c3RpbiA8YnJpYW4uYXVzdGluQGNpcnJ1cy5jb20+IA0K DQo=
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 4/4] ASoC: cs35l35: Add multi-device synchronisation
In reply to a message not in the archivesound/soc/codecs/cs35l35.c static const struct snd_kcontrol_new cs35l35_aud_controls[] = { · line 355
Quoted 6 lines · Charles Keepax
sound/soc/codecs/cs35l35.c +6
-0+SOC_SINGLE_EXT ("SYNC Audio" ,CS35L35_MULT_DEV_SYNCH2 ,1 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC VPBR" ,CS35L35_MULT_DEV_SYNCH2 ,2 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC OTW" ,CS35L35_MULT_DEV_SYNCH2 ,3 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync),
I can't tell how this works. It feels like this shouldn't just be being controlled from userspace but rather should be handled in some more standard fashion, or possibly as part of the platform integration but right now it's just some totally undocumented application managed controls.
Re: [PATCH 4/4] ASoC: cs35l35: Add multi-device synchronisation
Quoted 14 lines · Mark Brown
sound/soc/codecs/cs35l35.c static const struct snd_kcontrol_new cs35l35_aud_controls[] = { · line 355
Quoted 6 lines · Charles Keepax
sound/soc/codecs/cs35l35.c +6
-0+SOC_SINGLE_EXT ("SYNC Audio" ,CS35L35_MULT_DEV_SYNCH2 ,1 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC VPBR" ,CS35L35_MULT_DEV_SYNCH2 ,2 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC OTW" ,CS35L35_MULT_DEV_SYNCH2 ,3 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync),I can't tell how this works. It feels like this shouldn't just be being controlled from userspace but rather should be handled in some more standard fashion, or possibly as part of the platform integration but right now it's just some totally undocumented application managed controls.
These activate the individual types of synchronisation between the two stereo amps over a proprietary single wire connection between the two amps. The audio option synchronises the group delay between the two amps. The VPBR links the brown out on the two amps and the OTW links the over temperature warning.
The issue is really one of it being use-case specific whether the amps are being used independently or in a stereo configuration. You could have only a single amp in use in which case the sync features are best turned off. Or one might even have use-cases with both amps where they are being used independently but at the same time.
I guess we could potentially do those as calls from the machine driver, although in some cases it might be hard to tell which use-case is being used. Alternatively, one could try to actually link the two amps in DAPM and control it that way although you probably still want some device tree stuff to say which things you want to sync and it might cause issues in any cases where you had both amps up but didn't want to sync.
Thanks,
Charles
Re: [PATCH 4/4] ASoC: cs35l35: Add multi-device synchronisation
Quoted 29 lines · Charles Keepax
Quoted 14 lines · Mark Brown
sound/soc/codecs/cs35l35.c static const struct snd_kcontrol_new cs35l35_aud_controls[] = { · line 355
Quoted 6 lines · Charles Keepax
sound/soc/codecs/cs35l35.c +6
-0+SOC_SINGLE_EXT ("SYNC Audio" ,CS35L35_MULT_DEV_SYNCH2 ,1 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC VPBR" ,CS35L35_MULT_DEV_SYNCH2 ,2 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync), +SOC_SINGLE_EXT ("SYNC OTW" ,CS35L35_MULT_DEV_SYNCH2 ,3 ,1 ,0 , + snd_soc_get_volsw, cs35l35_put_sync),I can't tell how this works. It feels like this shouldn't just be being controlled from userspace but rather should be handled in some more standard fashion, or possibly as part of the platform integration but right now it's just some totally undocumented application managed controls.
These activate the individual types of synchronisation between the two stereo amps over a proprietary single wire connection between the two amps. The audio option synchronises the group delay between the two amps. The VPBR links the brown out on the two amps and the OTW links the over temperature warning.
The issue is really one of it being use-case specific whether the amps are being used independently or in a stereo configuration. You could have only a single amp in use in which case the sync features are best turned off. Or one might even have use-cases with both amps where they are being used independently but at the same time.
Quoted 7 lines
I guess we could potentially do those as calls from the machine driver, although in some cases it might be hard to tell which use-case is being used. Alternatively, one could try to actually link the two amps in DAPM and control it that way although you probably still want some device tree stuff to say which things you want to sync and it might cause issues in any cases where you had both amps up but didn't want to sync.
Ok turns out there is one other corner case issue here, lets drop this patch for now and I will try to see if I can come up with better solution for it.
Thanks,
Charles
Re: [PATCH 4/4] ASoC: cs35l35: Add multi-device synchronisation
In reply to a message not in the archiveQuoted 3 lines · Charles Keepax
These activate the individual types of synchronisation between the two stereo amps over a proprietary single wire connection between the two amps. The audio option synchronises the group
So we should at least have something that represents that single wire connection in DT since it might not be there and so that the kernel can make sure that both devices agree if they're synced or not and can disable the sync if it's been enabled in error (if one of the devices is off, you seemed to be saying that might cause problems).
Quoted 2 lines
delay between the two amps. The VPBR links the brown out on the two amps and the OTW links the over temperature warning.
It's not clear to me when it'd make sense to disable these from a system integration point of view.
Quoted 6 lines
The issue is really one of it being use-case specific whether the amps are being used independently or in a stereo configuration. You could have only a single amp in use in which case the sync features are best turned off. Or one might even have use-cases with both amps where they are being used independently but at the same time.
It feels like if this is going to be user controllable the UI needs to be pulled up a level to be something like an on/off switch for the sync rather than a series of magic _EXT controls on the individual CODECs. Even if it is magic _EXT controls having them being per device feels wrong.