| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * NAU88L24 ALSA SoC audio driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright 2016 Nuvoton Technology Corp. |
|---|
| 5 | 6 | * Author: John Hsu <KCHSU0@nuvoton.com> |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 9 | | - * published by the Free Software Foundation. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 814 | 811 | static bool nau8824_is_jack_inserted(struct nau8824 *nau8824) |
|---|
| 815 | 812 | { |
|---|
| 816 | 813 | struct snd_soc_jack *jack = nau8824->jack; |
|---|
| 817 | | - bool insert = FALSE; |
|---|
| 814 | + bool insert = false; |
|---|
| 818 | 815 | |
|---|
| 819 | 816 | if (nau8824->irq && jack) |
|---|
| 820 | 817 | insert = jack->status & SND_JACK_HEADPHONE; |
|---|
| .. | .. |
|---|
| 1075 | 1072 | struct snd_soc_component *component = dai->component; |
|---|
| 1076 | 1073 | struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); |
|---|
| 1077 | 1074 | unsigned int val_len = 0, osr, ctrl_val, bclk_fs, bclk_div; |
|---|
| 1075 | + int err = -EINVAL; |
|---|
| 1078 | 1076 | |
|---|
| 1079 | 1077 | nau8824_sema_acquire(nau8824, HZ); |
|---|
| 1080 | 1078 | |
|---|
| .. | .. |
|---|
| 1091 | 1089 | osr &= NAU8824_DAC_OVERSAMPLE_MASK; |
|---|
| 1092 | 1090 | if (nau8824_clock_check(nau8824, substream->stream, |
|---|
| 1093 | 1091 | nau8824->fs, osr)) |
|---|
| 1094 | | - return -EINVAL; |
|---|
| 1092 | + goto error; |
|---|
| 1095 | 1093 | regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER, |
|---|
| 1096 | 1094 | NAU8824_CLK_DAC_SRC_MASK, |
|---|
| 1097 | 1095 | osr_dac_sel[osr].clk_src << NAU8824_CLK_DAC_SRC_SFT); |
|---|
| .. | .. |
|---|
| 1101 | 1099 | osr &= NAU8824_ADC_SYNC_DOWN_MASK; |
|---|
| 1102 | 1100 | if (nau8824_clock_check(nau8824, substream->stream, |
|---|
| 1103 | 1101 | nau8824->fs, osr)) |
|---|
| 1104 | | - return -EINVAL; |
|---|
| 1102 | + goto error; |
|---|
| 1105 | 1103 | regmap_update_bits(nau8824->regmap, NAU8824_REG_CLK_DIVIDER, |
|---|
| 1106 | 1104 | NAU8824_CLK_ADC_SRC_MASK, |
|---|
| 1107 | 1105 | osr_adc_sel[osr].clk_src << NAU8824_CLK_ADC_SRC_SFT); |
|---|
| .. | .. |
|---|
| 1122 | 1120 | else if (bclk_fs <= 256) |
|---|
| 1123 | 1121 | bclk_div = 0; |
|---|
| 1124 | 1122 | else |
|---|
| 1125 | | - return -EINVAL; |
|---|
| 1123 | + goto error; |
|---|
| 1126 | 1124 | regmap_update_bits(nau8824->regmap, |
|---|
| 1127 | 1125 | NAU8824_REG_PORT0_I2S_PCM_CTRL_2, |
|---|
| 1128 | 1126 | NAU8824_I2S_LRC_DIV_MASK | NAU8824_I2S_BLK_DIV_MASK, |
|---|
| .. | .. |
|---|
| 1143 | 1141 | val_len |= NAU8824_I2S_DL_32; |
|---|
| 1144 | 1142 | break; |
|---|
| 1145 | 1143 | default: |
|---|
| 1146 | | - return -EINVAL; |
|---|
| 1144 | + goto error; |
|---|
| 1147 | 1145 | } |
|---|
| 1148 | 1146 | |
|---|
| 1149 | 1147 | regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1, |
|---|
| 1150 | 1148 | NAU8824_I2S_DL_MASK, val_len); |
|---|
| 1149 | + err = 0; |
|---|
| 1151 | 1150 | |
|---|
| 1151 | + error: |
|---|
| 1152 | 1152 | nau8824_sema_release(nau8824); |
|---|
| 1153 | 1153 | |
|---|
| 1154 | | - return 0; |
|---|
| 1154 | + return err; |
|---|
| 1155 | 1155 | } |
|---|
| 1156 | 1156 | |
|---|
| 1157 | 1157 | static int nau8824_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) |
|---|
| .. | .. |
|---|
| 1159 | 1159 | struct snd_soc_component *component = dai->component; |
|---|
| 1160 | 1160 | struct nau8824 *nau8824 = snd_soc_component_get_drvdata(component); |
|---|
| 1161 | 1161 | unsigned int ctrl1_val = 0, ctrl2_val = 0; |
|---|
| 1162 | | - |
|---|
| 1163 | | - nau8824_sema_acquire(nau8824, HZ); |
|---|
| 1164 | 1162 | |
|---|
| 1165 | 1163 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
|---|
| 1166 | 1164 | case SND_SOC_DAIFMT_CBM_CFM: |
|---|
| .. | .. |
|---|
| 1203 | 1201 | return -EINVAL; |
|---|
| 1204 | 1202 | } |
|---|
| 1205 | 1203 | |
|---|
| 1204 | + nau8824_sema_acquire(nau8824, HZ); |
|---|
| 1205 | + |
|---|
| 1206 | 1206 | regmap_update_bits(nau8824->regmap, NAU8824_REG_PORT0_I2S_PCM_CTRL_1, |
|---|
| 1207 | 1207 | NAU8824_I2S_DF_MASK | NAU8824_I2S_BP_MASK | |
|---|
| 1208 | 1208 | NAU8824_I2S_PCMB_EN, ctrl1_val); |
|---|