Skip to contentSkip to conversation

ASoC: add RT5640 CODEC driver

PATCH Bard 2 participants 2 messages Apr 22, 2013 2 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Bard

author
#2 lore raw

Dear Mark,

Please see my reply below.

Thanks.

-----Original Message-----
From: Mark Brown [mailto:[email protected]]
Sent: Tuesday, April 16, 2013 10:38 PM
To: Bard
Cc: Flove; Oder Chiou; [email protected]; bard
Subject: Re: [PATCH] ASoC: add RT5640 CODEC driver

On Tue, Apr 16, 2013 at 10:10:37PM +0800, [email protected] wrote:

Please remember to post things to the list... just a quick scan through here:

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int rt5640_reg_init(struct snd_soc_codec *codec) {
+	int i;
+	for (i = 0; i < RT5640_INIT_REG_LEN; i++)
+		snd_soc_write(codec, init_list[i].reg, init_list[i].val);
+	return 0;
+}

This should be converted over to regmap. There's support for paging in the core, look at regmap_range.

Bard: I will use regmap_register_patch to do that.

Review

Quoted 11 lines
(quoted diff) +11 -0
+/* IN1/IN2 Input Type */
+static const char * const rt5640_input_mode[] = {
+	"Single ended", "Differential"};
+
+static const SOC_ENUM_SINGLE_DECL(
+	rt5640_in1_mode_enum, RT5640_IN1_IN2,
+	RT5640_IN_SFT1, rt5640_input_mode);
+
+static const SOC_ENUM_SINGLE_DECL(
+	rt5640_in2_mode_enum, RT5640_IN3_IN4,
+	RT5640_IN_SFT2, rt5640_input_mode);

Platform data...

Bard: Can I export a function that machine can configure it by this function?

Review

Quoted 11 lines
(quoted diff) +11 -0
+static int rt5640_vol_rescale_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+	unsigned int val, val2;
+
+	val = VOL_RESCALE_MAX_VOL - ucontrol->value.integer.value[0];
+	val2 = VOL_RESCALE_MAX_VOL - ucontrol->value.integer.value[1];
+	return snd_soc_update_bits_locked(codec, mc->reg, RT5640_L_VOL_MASK |
+			RT5640_R_VOL_MASK, val << mc->shift | val2); }

This looks like a variant on the _RANGE controls?

Bard: Yes, we want to limit the max value of volume.
If it is not good, I will change it.

Quoted 4 lines
(quoted diff) +4 -0
+static int hp_event(struct snd_soc_dapm_widget *w,
+	struct snd_kcontrol *kcontrol, int event) {
+	switch (event) {
+	case SND_SOC_DAPM_POST_PMU:

Review

Quoted 10 lines
(quoted diff) +10 -0
+		break;
+
+	case SND_SOC_DAPM_PRE_PMD:
+		break;
+
+	default:
+		return 0;
+	}
+	return 0;
+}

Remove this, it doesn't actually do anything any more.

Bard: I will remove it.

------Please consider the environment before printing this e-mail.

#3 lore raw
Quoted 1 line · Bard

Please see my reply below.

As you've been told several times now please fix your mailer to quote the text you're replying to. You shouldn't need to point out that you're replying inline, this is how we do things...

Quoted 7 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+static const SOC_ENUM_SINGLE_DECL(
+	rt5640_in2_mode_enum, RT5640_IN3_IN4,
+	RT5640_IN_SFT2, rt5640_input_mode);

Platform data...

Bard: Can I export a function that machine can configure it by this function?

Why on earth would you want to do that?

Quoted 14 lines

Review

Quoted 11 lines
(quoted diff) +10 -0
+static int rt5640_vol_rescale_put(struct snd_kcontrol *kcontrol,
+		struct snd_ctl_elem_value *ucontrol) {
+	struct soc_mixer_control *mc =
+		(struct soc_mixer_control *)kcontrol->private_value;
+	struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
+	unsigned int val, val2;
 
+	val = VOL_RESCALE_MAX_VOL - ucontrol->value.integer.value[0];
+	val2 = VOL_RESCALE_MAX_VOL - ucontrol->value.integer.value[1];
+	return snd_soc_update_bits_locked(codec, mc->reg, RT5640_L_VOL_MASK |
+			RT5640_R_VOL_MASK, val << mc->shift | val2); }

This looks like a variant on the _RANGE controls?

Quoted 2 lines

Bard: Yes, we want to limit the max value of volume.
If it is not good, I will change it.

This shouldn't be open coded in the driver, the functions should be generic. Code wise it's fine.