All of lore.kernel.org
 help / color / mirror / Atom feed
* ASoC: nau8825: default value for property
@ 2017-06-21  6:44 John Hsu
  2017-06-21 10:56 ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: John Hsu @ 2017-06-21  6:44 UTC (permalink / raw)
  To: broonie
  Cc: alsa-devel, anatol.pomozov, YHCHuang, John Hsu, lgirdwood, benzh,
	mac.chiang, CTLIN0, mhkuo, John Hsu, yong.zhi

Assign default value for codec private data when property not given.
If without those default value and property, the codec will work
abnormally.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Signed-off-by: John Hsu <supercraig0719@gmail.com>
---
 sound/soc/codecs/nau8825.c | 62 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 50 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/nau8825.c b/sound/soc/codecs/nau8825.c
index 97fbeba..ff827bb 100644
--- a/sound/soc/codecs/nau8825.c
+++ b/sound/soc/codecs/nau8825.c
@@ -2429,37 +2429,75 @@ static void nau8825_print_device_properties(struct nau8825 *nau8825)
 
 static int nau8825_read_device_properties(struct device *dev,
 	struct nau8825 *nau8825) {
+	int ret;
 
 	nau8825->jkdet_enable = device_property_read_bool(dev,
 		"nuvoton,jkdet-enable");
+	if (nau8825->jkdet_enable != true &&
+		nau8825->jkdet_enable != false)
+		nau8825->jkdet_enable = 1;
 	nau8825->jkdet_pull_enable = device_property_read_bool(dev,
 		"nuvoton,jkdet-pull-enable");
+	if (nau8825->jkdet_pull_enable != true &&
+		nau8825->jkdet_pull_enable != false)
+		nau8825->jkdet_pull_enable = 1;
 	nau8825->jkdet_pull_up = device_property_read_bool(dev,
 		"nuvoton,jkdet-pull-up");
-	device_property_read_u32(dev, "nuvoton,jkdet-polarity",
+	if (nau8825->jkdet_pull_up != true &&
+		nau8825->jkdet_pull_up != false)
+		nau8825->jkdet_pull_up = 1;
+	ret = device_property_read_u32(dev, "nuvoton,jkdet-polarity",
 		&nau8825->jkdet_polarity);
-	device_property_read_u32(dev, "nuvoton,micbias-voltage",
+	if (ret)
+		nau8825->jkdet_polarity = 1;
+	ret = device_property_read_u32(dev, "nuvoton,micbias-voltage",
 		&nau8825->micbias_voltage);
-	device_property_read_u32(dev, "nuvoton,vref-impedance",
+	if (ret)
+		nau8825->micbias_voltage = 6;
+	ret = device_property_read_u32(dev, "nuvoton,vref-impedance",
 		&nau8825->vref_impedance);
-	device_property_read_u32(dev, "nuvoton,sar-threshold-num",
+	if (ret)
+		nau8825->vref_impedance = 2;
+	ret = device_property_read_u32(dev, "nuvoton,sar-threshold-num",
 		&nau8825->sar_threshold_num);
-	device_property_read_u32_array(dev, "nuvoton,sar-threshold",
+	if (ret)
+		nau8825->sar_threshold_num = 4;
+	ret = device_property_read_u32_array(dev, "nuvoton,sar-threshold",
 		nau8825->sar_threshold, nau8825->sar_threshold_num);
-	device_property_read_u32(dev, "nuvoton,sar-hysteresis",
+	if (ret) {
+		nau8825->sar_threshold[0] = 0x08;
+		nau8825->sar_threshold[1] = 0x12;
+		nau8825->sar_threshold[2] = 0x26;
+		nau8825->sar_threshold[3] = 0x73;
+	}
+	ret = device_property_read_u32(dev, "nuvoton,sar-hysteresis",
 		&nau8825->sar_hysteresis);
-	device_property_read_u32(dev, "nuvoton,sar-voltage",
+	if (ret)
+		nau8825->sar_hysteresis = 0;
+	ret = device_property_read_u32(dev, "nuvoton,sar-voltage",
 		&nau8825->sar_voltage);
-	device_property_read_u32(dev, "nuvoton,sar-compare-time",
+	if (ret)
+		nau8825->sar_voltage = 6;
+	ret = device_property_read_u32(dev, "nuvoton,sar-compare-time",
 		&nau8825->sar_compare_time);
-	device_property_read_u32(dev, "nuvoton,sar-sampling-time",
+	if (ret)
+		nau8825->sar_compare_time = 1;
+	ret = device_property_read_u32(dev, "nuvoton,sar-sampling-time",
 		&nau8825->sar_sampling_time);
-	device_property_read_u32(dev, "nuvoton,short-key-debounce",
+	if (ret)
+		nau8825->sar_sampling_time = 1;
+	ret = device_property_read_u32(dev, "nuvoton,short-key-debounce",
 		&nau8825->key_debounce);
-	device_property_read_u32(dev, "nuvoton,jack-insert-debounce",
+	if (ret)
+		nau8825->key_debounce = 3;
+	ret = device_property_read_u32(dev, "nuvoton,jack-insert-debounce",
 		&nau8825->jack_insert_debounce);
-	device_property_read_u32(dev, "nuvoton,jack-eject-debounce",
+	if (ret)
+		nau8825->jack_insert_debounce = 7;
+	ret = device_property_read_u32(dev, "nuvoton,jack-eject-debounce",
 		&nau8825->jack_eject_debounce);
+	if (ret)
+		nau8825->jack_eject_debounce = 0;
 
 	nau8825->mclk = devm_clk_get(dev, "mclk");
 	if (PTR_ERR(nau8825->mclk) == -EPROBE_DEFER) {
-- 
2.6.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: ASoC: nau8825: default value for property
  2017-06-21  6:44 ASoC: nau8825: default value for property John Hsu
@ 2017-06-21 10:56 ` Mark Brown
  2017-06-22  1:32   ` John Hsu
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2017-06-21 10:56 UTC (permalink / raw)
  To: John Hsu
  Cc: alsa-devel, anatol.pomozov, YHCHuang, John Hsu, lgirdwood, benzh,
	mac.chiang, CTLIN0, mhkuo, yong.zhi


[-- Attachment #1.1: Type: text/plain, Size: 441 bytes --]

On Wed, Jun 21, 2017 at 02:44:06PM +0800, John Hsu wrote:

> +	if (nau8825->jkdet_enable != true &&
> +		nau8825->jkdet_enable != false)
> +		nau8825->jkdet_enable = 1;

Won't jack detection require specific wiring on the board (if only
connection of the interupt line)?

> +	if (nau8825->jkdet_pull_enable != true &&
> +		nau8825->jkdet_pull_enable != false)
> +		nau8825->jkdet_pull_enable = 1;

Usually we'd just use the chip defaults...

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ASoC: nau8825: default value for property
  2017-06-21 10:56 ` Mark Brown
@ 2017-06-22  1:32   ` John Hsu
  0 siblings, 0 replies; 3+ messages in thread
From: John Hsu @ 2017-06-22  1:32 UTC (permalink / raw)
  To: Mark Brown
  Cc: AP MS30 Linux ALSA, anatol.pomozov, AC30 YHChuang, lgirdwood,
	benzh, mac.chiang, AC30 CTLin0, yong.zhi, John Hsu, MS40 MHKuo

On 6/21/2017 6:56 PM, Mark Brown wrote:
> On Wed, Jun 21, 2017 at 02:44:06PM +0800, John Hsu wrote:
>
>> +    if (nau8825->jkdet_enable != true &&
>> +            nau8825->jkdet_enable != false)
>> +            nau8825->jkdet_enable = 1;
>
> Won't jack detection require specific wiring on the board (if only
> connection of the interupt line)?
>
>> +    if (nau8825->jkdet_pull_enable != true &&
>> +            nau8825->jkdet_pull_enable != false)
>> +            nau8825->jkdet_pull_enable = 1;
>
> Usually we'd just use the chip defaults...

I misunderstand the device_property_read_bool.
I agree and keep it as default. Thank you.


===========================================================================================
The privileged confidential information contained in this email is intended for use only by the addressees as indicated by the original sender of this email. If you are not the addressee indicated in this email or are not responsible for delivery of the email to such a person, please kindly reply to the sender indicating this fact and delete all copies of it from your computer and network server immediately. Your cooperation is highly appreciated. It is advised that any unauthorized use of confidential information of Nuvoton is strictly prohibited; and any information in this email irrelevant to the official business of Nuvoton shall be deemed as neither given nor endorsed by Nuvoton.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-22  1:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-21  6:44 ASoC: nau8825: default value for property John Hsu
2017-06-21 10:56 ` Mark Brown
2017-06-22  1:32   ` John Hsu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.