Skip to content

Instantly share code, notes, and snippets.

@junk-labs
Last active November 4, 2016 05:06
Show Gist options
  • Save junk-labs/b552e4b7fbdb8e621b585211ba8e50cf to your computer and use it in GitHub Desktop.
Save junk-labs/b552e4b7fbdb8e621b585211ba8e50cf to your computer and use it in GitHub Desktop.
dlxj向けのcm13orRRでゲーム等の音量調整に関する互換性を向上させるパッチ類。(完全に治るとは言っていない)
diff --git sound/soc/msm/apq8064.c sound/soc/msm/apq8064.c
index e8603a6..72288e5 100644
--- sound/soc/msm/apq8064.c
+++ sound/soc/msm/apq8064.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2012, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -101,6 +101,7 @@ enum {
};
static int msm_spk_control;
+static int msm_spk9887mute_control = 0;
static int msm_ext_bottom_spk_pamp;
static int msm_ext_top_spk_pamp;
static int msm_slim_0_rx_ch = 1;
@@ -148,6 +149,30 @@ static struct tabla_mbhc_config mbhc_cfg = {
.gpio_level_insert = 1,
};
+static inline int param_is_mask(int p)
+{
+ return ((p >= SNDRV_PCM_HW_PARAM_FIRST_MASK) &&
+ (p <= SNDRV_PCM_HW_PARAM_LAST_MASK));
+}
+
+static inline struct snd_mask *param_to_mask(struct snd_pcm_hw_params *p, int n)
+{
+ return &(p->masks[n - SNDRV_PCM_HW_PARAM_FIRST_MASK]);
+}
+
+static void param_set_mask(struct snd_pcm_hw_params *p, int n, unsigned bit)
+{
+ if (bit >= SNDRV_MASK_MAX)
+ return;
+ if (param_is_mask(n)) {
+ struct snd_mask *m = param_to_mask(p, n);
+ m->bits[0] = 0;
+ m->bits[1] = 0;
+ m->bits[bit >> 5] |= (1 << (bit & 31));
+ }
+}
+
+
static struct mutex cdc_mclk_mutex;
static struct mutex aux_pcm_mutex;
@@ -180,7 +205,7 @@ static int msm8960_mi2s_hw_params(struct snd_pcm_substream *substream,
int bit_clk_set = 0;
if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
- bit_clk_set = 12288000/(rate * 2 * 16);
+ bit_clk_set = 18432000/(rate * 2 * 24);
clk_set_rate(mi2s_rx_bit_clk, bit_clk_set);
}
return 1;
@@ -254,7 +279,8 @@ static int msm8960_mi2s_startup(struct snd_pcm_substream *substream)
configure_mi2s_rx_gpio();
mi2s_rx_osr_clk = clk_get(cpu_dai->dev, "osr_clk");
if (mi2s_rx_osr_clk) {
- clk_set_rate(mi2s_rx_osr_clk, 12288000);
+
+ clk_set_rate(mi2s_rx_osr_clk, 18432000);
clk_prepare_enable(mi2s_rx_osr_clk);
}
mi2s_rx_bit_clk = clk_get(cpu_dai->dev, "bit_clk");
@@ -673,6 +699,32 @@ static int msm_set_spk(struct snd_kcontrol *kcontrol,
msm_ext_control(codec);
return 1;
}
+
+static int msm_get_spk9887mute(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol) {
+ pr_debug("%s: msm_spk9887_control = %d", __func__, msm_spk9887mute_control);
+ ucontrol->value.integer.value[0] = msm_spk9887mute_control;
+ return 0;
+}
+static int msm_set_spk9887mute(struct snd_kcontrol *kcontrol,
+ struct snd_ctl_elem_value *ucontrol) {
+
+
+
+
+ msm_spk9887mute_control = ucontrol->value.integer.value[0];
+ pr_info("@@## %s() %d\n", __func__,msm_spk9887mute_control);
+ if (msm_spk9887mute_control)
+ {
+ msleep(200);
+ set_tfa9887_spkamp(0, 0);
+ }
+ else
+ set_tfa9887_spkamp(1, 0);
+
+ return 1;
+}
+
static int msm_spkramp_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
@@ -1048,6 +1100,8 @@ static const struct snd_kcontrol_new tabla_msm_controls[] = {
msm_set_hac),
SOC_ENUM_EXT("RCV AMP EN", msm_enum[0], msm_get_rcv_amp,
msm_set_rcv_amp),
+ SOC_ENUM_EXT("Mute9887 Function", msm_enum[0],msm_get_spk9887mute,
+ msm_set_spk9887mute),
};
@@ -1387,7 +1441,31 @@ static int msm_slim_0_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_interval *channels = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS);
+ pr_debug("%s() Fixing the BE DAI format to 24bit\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S24_LE);
+
+ rate->min = rate->max = 48000;
+ channels->min = channels->max = msm_slim_0_rx_ch;
+
+ return 0;
+}
+
+static int msm_slim_0_stub_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_interval *rate = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_RATE);
+
+ struct snd_interval *channels = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_CHANNELS);
+
pr_debug("%s()\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S16_LE);
+
rate->min = rate->max = 48000;
channels->min = channels->max = msm_slim_0_rx_ch;
@@ -1420,6 +1498,10 @@ static int msm_slim_3_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
SNDRV_PCM_HW_PARAM_CHANNELS);
pr_debug("%s()\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S16_LE);
+
rate->min = rate->max = 48000;
channels->min = channels->max = msm_slim_3_rx_ch;
@@ -1455,6 +1537,10 @@ static int msm_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
SNDRV_PCM_HW_PARAM_RATE);
pr_debug("%s()\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S16_LE);
+
rate->min = rate->max = 48000;
return 0;
@@ -1471,6 +1557,8 @@ static int msm_hdmi_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
pr_debug("%s channels->min %u channels->max %u ()\n", __func__,
channels->min, channels->max);
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S16_LE);
rate->min = rate->max = 48000;
@@ -1501,6 +1589,11 @@ static int msm_mi2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_interval *channels = hw_param_interval(params,
SNDRV_PCM_HW_PARAM_CHANNELS);
+ pr_debug("%s() Fixing the BE DAI format to 24bit\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S24_LE);
+
rate->min = rate->max = 48000;
channels->min = channels->max = 1;
#ifdef CONFIG_AMP_TFA9887L
@@ -1510,6 +1603,22 @@ static int msm_mi2s_rx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
return 0;
}
+static int msm_mi2s_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
+ struct snd_pcm_hw_params *params)
+{
+ struct snd_interval *rate = hw_param_interval(params,
+ SNDRV_PCM_HW_PARAM_RATE);
+
+ pr_debug("%s()\n", __func__);
+
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S24_LE);
+
+ rate->min = rate->max = 48000;
+
+ return 0;
+}
+
static int msm_slim_1_tx_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
struct snd_pcm_hw_params *params)
{
@@ -1550,7 +1659,11 @@ static int msm_auxpcm_be_params_fixup(struct snd_soc_pcm_runtime *rtd,
SNDRV_PCM_HW_PARAM_CHANNELS);
+#ifdef CONFIG_BT_WBS_BRCM
+ rate->min = rate->max = 16000;
+#else
rate->min = rate->max = 8000;
+#endif
channels->min = channels->max = 1;
return 0;
@@ -1563,6 +1676,9 @@ static int msm_proxy_be_hw_params_fixup(struct snd_soc_pcm_runtime *rtd,
SNDRV_PCM_HW_PARAM_RATE);
pr_debug("%s()\n", __func__);
+ param_set_mask(params, SNDRV_PCM_HW_PARAM_FORMAT,
+ SNDRV_PCM_FORMAT_S16_LE);
+
rate->min = rate->max = 48000;
return 0;
@@ -2022,7 +2138,7 @@ static struct snd_soc_dai_link msm_dai[] = {
.codec_name = "msm-stub-codec.1",
.codec_dai_name = "msm-stub-tx",
.no_pcm = 1,
- .be_hw_params_fixup = msm_be_hw_params_fixup,
+ .be_hw_params_fixup = msm_mi2s_tx_be_hw_params_fixup,
.be_id = MSM_BACKEND_DAI_MI2S_TX,
.ops = &msm8960_mi2s_be_ops,
},
@@ -2085,7 +2201,7 @@ static struct snd_soc_dai_link msm_dai[] = {
.codec_dai_name = "tabla_rx2",
.no_pcm = 1,
.be_id = MSM_BACKEND_DAI_EXTPROC_RX,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
+ .be_hw_params_fixup = msm_slim_0_stub_rx_be_hw_params_fixup,
.init = &msm_stubrx_init,
.ops = &msm_be_ops,
.ignore_pmdown_time = 1,
@@ -2177,7 +2293,7 @@ static struct snd_soc_dai_link msm_dai[] = {
.codec_dai_name = "tabla_tx3",
.no_pcm = 1,
.be_id = MSM_BACKEND_DAI_EXTPROC_EC_TX,
- .be_hw_params_fixup = msm_slim_0_rx_be_hw_params_fixup,
+ .be_hw_params_fixup = msm_slim_0_stub_rx_be_hw_params_fixup,
.ops = &msm_be_ops,
},
{
@@ -2278,6 +2394,19 @@ static struct snd_soc_dai_link msm_dai[] = {
.ignore_pmdown_time = 1,
.be_id = MSM_FRONTEND_DAI_MULTIMEDIA8,
},
+ {
+ .name = "Compress Stub",
+ .stream_name = "Compress Stub",
+ .cpu_dai_name = "MM_STUB",
+ .platform_name = "msm-pcm-hostless",
+ .dynamic = 1,
+ .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST},
+ .no_host_mode = SND_SOC_DAI_LINK_NO_HOST,
+ .ignore_suspend = 1,
+ .ignore_pmdown_time = 1,
+ .codec_dai_name = "snd-soc-dummy-dai",
+ .codec_name = "snd-soc-dummy",
+ },
};
@@ -2316,7 +2445,8 @@ static int __init msm_audio_init(void)
GPIO_CFG(42, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
};
- if (!cpu_is_apq8064()) {
+ if (!(cpu_is_apq8064() || cpu_is_apq8064ab()) ||
+ (socinfo_get_id() == 130)) {
pr_err("%s: Not the right machine type\n", __func__);
return -ENODEV;
}
@@ -2370,7 +2500,8 @@ module_init(msm_audio_init);
static void __exit msm_audio_exit(void)
{
- if (!cpu_is_apq8064() || (socinfo_get_id() == 130)) {
+ if (!(cpu_is_apq8064() || cpu_is_apq8064ab()) ||
+ (socinfo_get_id() == 130)) {
pr_err("%s: Not the right machine type\n", __func__);
return ;
}
diff --git arch/arm/mach-msm/include/mach/tfa9887.h arch/arm/mach-msm/include/mach/tfa9887.h
index 68012d5..8190cb8 100644
--- arch/arm/mach-msm/include/mach/tfa9887.h
+++ arch/arm/mach-msm/include/mach/tfa9887.h
@@ -10,6 +10,9 @@ struct tfa9887_platform_data {
};
+extern int tfa9887l_step;
+extern int tfa9887l_step_en;
+
void set_tfa9887_spkamp(int en, int dsp_mode);
void set_tfa9887l_spkamp(int en, int dsp_mode);
int tfa9887_l_write(char *txData, int length);
diff --git drivers/i2c/chips/tfa9887.c drivers/i2c/chips/tfa9887.c
index c644405..81eb482 100644
--- drivers/i2c/chips/tfa9887.c
+++ drivers/i2c/chips/tfa9887.c
@@ -52,6 +52,10 @@ struct mutex spk_amp_lock;
static int tfa9887_opened;
static int last_spkamp_state;
static int dsp_enabled;
+
+static int tfa9887_step = -1;
+static int tfa9887_step_en = 0;
+
static int tfa9887_i2c_write(char *txData, int length);
static int tfa9887_i2c_read(char *rxData, int length);
#ifdef CONFIG_DEBUG_FS
@@ -180,6 +184,12 @@ static int tfa9887_i2c_write(char *txData, int length)
.buf = txData,
},
};
+
+ if (tfa9887_step_en)
+ tfa9887_step ++;
+#if DEBUG
+ pr_err("%s: tfa9887_step %d\n", __func__, tfa9887_step);
+#endif
rc = i2c_transfer(this_client->adapter, msg, 1);
if (rc < 0) {
@@ -187,7 +197,11 @@ static int tfa9887_i2c_write(char *txData, int length)
return rc;
}
+
+ if (tfa9887_step_en)
+ tfa9887_step ++;
#if DEBUG
+ pr_err("%s: tfa9887_step %d\n", __func__, tfa9887_step);
{
int i = 0;
for (i = 0; i < length; i++)
@@ -211,13 +225,25 @@ static int tfa9887_i2c_read(char *rxData, int length)
},
};
+
+ if (tfa9887_step_en)
+ tfa9887_step ++;
+#if DEBUG
+ pr_err("%s: tfa9887_step %d\n", __func__, tfa9887_step);
+#endif
+
rc = i2c_transfer(this_client->adapter, msgs, 1);
if (rc < 0) {
pr_err("%s: transfer error %d\n", __func__, rc);
return rc;
}
+
+ if (tfa9887_step_en)
+ tfa9887_step ++;
+
#if DEBUG
+ pr_err("%s: tfa9887_step %d\n", __func__, tfa9887_step);
{
int i = 0;
for (i = 0; i < length; i++)
@@ -261,6 +287,9 @@ void set_tfa9887_spkamp(int en, int dsp_mode)
pr_info("%s: en = %d dsp_enabled = %d\n", __func__, en, dsp_enabled);
mutex_lock(&spk_amp_lock);
+
+ tfa9887_step = 0;
+ tfa9887_step_en = 1;
if (en && !last_spkamp_state) {
last_spkamp_state = 1;
@@ -316,6 +345,10 @@ void set_tfa9887_spkamp(int en, int dsp_mode)
tfa9887_i2c_write(power_data, 3);
}
}
+
+ tfa9887_step_en = 0;
+ tfa9887_step = -1;
+
mutex_unlock(&spk_amp_lock);
}
@@ -327,6 +360,7 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
unsigned int len = 0;
char *addr;
void __user *argp = (void __user *)arg;
+ char *buf;
switch (cmd) {
case TPA9887_WRITE_CONFIG:
@@ -340,7 +374,29 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_i2c_write(addr+1, len -1);
+
+ if (tfa9887_step_en)
+ pr_info("%s TPA9887_WRITE_CONFIG tfa9887_step_en = %d, tfa9887_step = %d\n",
+ __func__, tfa9887_step_en, tfa9887_step);
+ tfa9887_step = 0;
+ tfa9887_step_en = 2;
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+ if (copy_from_user(buf, addr, len)) {
+ kfree(buf);
+ pr_err("%s addr %x error\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+
+ tfa9887_i2c_write(buf+1, len -1);
+ kfree(buf);
+
+ tfa9887_step_en = 0;
+ tfa9887_step = -1;
break;
case TPA9887_READ_CONFIG:
@@ -353,7 +409,30 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_i2c_read(addr, len);
+
+
+ if (tfa9887_step_en)
+ pr_info("%s TPA9887_READ_CONFIG tfa9887_step_en = %d, tfa9887_step = %d\n",
+ __func__, tfa9887_step_en, tfa9887_step);
+ tfa9887_step = 0;
+ tfa9887_step_en = 2;
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+
+ tfa9887_i2c_read(buf, len);
+ if (copy_to_user(addr, buf, len)) {
+ kfree(buf);
+ pr_err("%s addr %x error\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+ kfree(buf);
+
+ tfa9887_step_en = 0;
+ tfa9887_step = -1;
rc = copy_to_user(argp, reg_value, sizeof(reg_value));
if (rc) {
@@ -372,7 +451,29 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_l_write(addr+1, len -1);
+
+ if (tfa9887l_step_en)
+ pr_info("%s TPA9887_WRITE_L_CONFIG tfa9887l_step_en = %d, tfa9887l_step = %d\n",
+ __func__, tfa9887l_step_en, tfa9887l_step);
+ tfa9887l_step = 0;
+ tfa9887l_step_en = 2;
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+ if (copy_from_user(buf, addr, len)) {
+ kfree(buf);
+ pr_err("%s addr %x error\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+
+ tfa9887_l_write(buf+1, len -1);
+ kfree(buf);
+
+ tfa9887l_step_en = 0;
+ tfa9887l_step = -1;
break;
case TPA9887_READ_L_CONFIG:
pr_debug("%s: TPA9887_READ_CONFIG_L\n", __func__);
@@ -384,7 +485,30 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_l_read(addr, len);
+
+ if (tfa9887l_step_en)
+ pr_info("%s TPA9887_READ_L_CONFIG tfa9887l_step_en = %d, tfa9887l_step = %d\n",
+ __func__, tfa9887l_step_en, tfa9887l_step);
+ tfa9887l_step = 0;
+ tfa9887l_step_en = 2;
+
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+
+ tfa9887_l_read(buf, len);
+ if (copy_to_user(addr, buf, len)) {
+ kfree(buf);
+ pr_err("%s addr %x NO mem\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+ kfree(buf);
+
+ tfa9887l_step_en = 0;
+ tfa9887l_step = -1;
rc = copy_to_user(argp, reg_value, sizeof(reg_value));
if (rc) {
@@ -394,7 +518,6 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
break;
#endif
case TPA9887_ENABLE_DSP:
- pr_info("%s: TPA9887_ENABLE_DSP\n", __func__);
rc = copy_from_user(reg_value, argp, sizeof(reg_value));;
if (rc) {
pr_err("%s: copy from user failed.\n", __func__);
@@ -403,6 +526,7 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
dsp_enabled = reg_value[1];
+ pr_info("%s: TPA9887_ENABLE_DSP (%d)\n", __func__, dsp_enabled);
break;
case TPA9887_KERNEL_LOCK:
rc = copy_from_user(reg_value, argp, sizeof(reg_value));;
@@ -413,11 +537,13 @@ static long tfa9887_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
- pr_debug("TPA9887_KLOCK1 %d\n", reg_value[1]);
- if (reg_value[1])
+ if (reg_value[1]) {
mutex_lock(&spk_amp_lock);
- else
+ pr_info("TPA9887_KLOCK1 ++\n");
+ } else {
+ pr_info("TPA9887_KLOCK1 --\n");
mutex_unlock(&spk_amp_lock);
+ }
break;
}
err:
diff --git drivers/i2c/chips/tfa9887l.c drivers/i2c/chips/tfa9887l.c
index 9ee7a9a..4ff55e7 100644
--- drivers/i2c/chips/tfa9887l.c
+++ drivers/i2c/chips/tfa9887l.c
@@ -50,6 +50,11 @@ struct mutex spk_ampl_lock;
static int tfa9887l_opened;
static int last_spkampl_state;
static int dspl_enabled;
+int tfa9887l_step = -1;
+EXPORT_SYMBOL(tfa9887l_step);
+int tfa9887l_step_en = 0;
+EXPORT_SYMBOL(tfa9887l_step_en);
+
static int tfa9887_i2c_write(char *txData, int length);
static int tfa9887_i2c_read(char *rxData, int length);
#ifdef CONFIG_DEBUG_FS
@@ -172,6 +177,12 @@ static int tfa9887_i2c_write(char *txData, int length)
.buf = txData,
},
};
+
+ if (tfa9887l_step_en)
+ tfa9887l_step ++;
+#if DEBUG
+ pr_err("%s: tfa9887l_step %d\n", __func__, tfa9887l_step);
+#endif
rc = i2c_transfer(this_client->adapter, msg, 1);
if (rc < 0) {
@@ -179,7 +190,12 @@ static int tfa9887_i2c_write(char *txData, int length)
return rc;
}
+
+ if (tfa9887l_step_en)
+ tfa9887l_step ++;
+
#if DEBUG
+ pr_err("%s: tfa9887l_step %d\n", __func__, tfa9887l_step);
{
int i = 0;
for (i = 0; i < length; i++)
@@ -203,13 +219,25 @@ static int tfa9887_i2c_read(char *rxData, int length)
},
};
+
+ if (tfa9887l_step_en)
+ tfa9887l_step ++;
+#if DEBUG
+ pr_err("%s: tfa9887l_step %d\n", __func__, tfa9887l_step);
+#endif
+
rc = i2c_transfer(this_client->adapter, msgs, 1);
if (rc < 0) {
pr_err("%s: transfer error %d\n", __func__, rc);
return rc;
}
+
+ if (tfa9887l_step_en)
+ tfa9887l_step ++;
+
#if DEBUG
+ pr_err("%s: tfa9887l_step %d\n", __func__, tfa9887l_step);
{
int i = 0;
for (i = 0; i < length; i++)
@@ -262,6 +290,9 @@ void set_tfa9887l_spkamp(int en, int dsp_mode)
pr_info("%s: en = %d dsp_enabled = %d\n", __func__, en, dspl_enabled);
mutex_lock(&spk_ampl_lock);
+
+ tfa9887l_step = 0;
+ tfa9887l_step_en = 1;
if (en && !last_spkampl_state) {
last_spkampl_state = 1;
@@ -317,6 +348,10 @@ void set_tfa9887l_spkamp(int en, int dsp_mode)
tfa9887_i2c_write(power_data, 3);
}
}
+
+ tfa9887l_step_en = 0;
+ tfa9887l_step = -1;
+
mutex_unlock(&spk_ampl_lock);
}
@@ -328,6 +363,7 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
unsigned int len = 0;
char *addr;
void __user *argp = (void __user *)arg;
+ char *buf;
switch (cmd) {
case TPA9887_WRITE_CONFIG:
@@ -341,7 +377,26 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_i2c_write(addr+1, len -1);
+
+ tfa9887l_step = 0;
+ tfa9887l_step_en = 2;
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+ if (copy_from_user(buf, addr, len)) {
+ kfree(buf);
+ pr_err("%s addr %x error\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+
+ tfa9887_i2c_write(buf+1, len -1);
+ kfree(buf);
+
+ tfa9887l_step_en = 0;
+ tfa9887l_step = -1;
break;
case TPA9887_READ_CONFIG:
@@ -354,7 +409,27 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
addr = (char *)reg_value[1];
- tfa9887_i2c_read(addr, len);
+
+
+ tfa9887l_step = 0;
+ tfa9887l_step_en = 2;
+
+ buf = kmalloc(len, GFP_KERNEL);
+ if (!buf) {
+ pr_err("%s len %u NO mem\n", __func__, len);
+ return -ENOMEM;
+ }
+
+ tfa9887_i2c_read(buf, len);
+ if (copy_to_user(addr, buf, len)) {
+ kfree(buf);
+ pr_err("%s addr %x NO mem\n", __func__, (unsigned int)addr);
+ return -EFAULT;
+ }
+ kfree(buf);
+
+ tfa9887l_step_en = 0;
+ tfa9887l_step = -1;
rc = copy_to_user(argp, reg_value, sizeof(reg_value));
if (rc) {
@@ -363,7 +438,6 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
}
break;
case TPA9887_ENABLE_DSP:
- pr_info("%s: TPA9887_ENABLE_DSP\n", __func__);
rc = copy_from_user(reg_value, argp, sizeof(reg_value));;
if (rc) {
pr_err("%s: copy from user failed.\n", __func__);
@@ -372,6 +446,7 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
dspl_enabled = reg_value[1];
+ pr_info("%s: TPA9887_ENABLE_DSP(%d)\n", __func__, dspl_enabled);
break;
case TPA9887_KERNEL_LOCK:
rc = copy_from_user(reg_value, argp, sizeof(reg_value));;
@@ -382,11 +457,13 @@ static long tfa9887l_ioctl(struct file *file, unsigned int cmd,
len = reg_value[0];
- pr_debug("TPA9887_KLOCK2 %d\n", reg_value[1]);
- if (reg_value[1])
+ if (reg_value[1]) {
mutex_lock(&spk_ampl_lock);
- else
+ pr_info("TPA9887_KLOCK2 ++\n");
+ } else {
+ pr_info("TPA9887_KLOCK2 --\n");
mutex_unlock(&spk_ampl_lock);
+ }
break;
}
err:
diff --git drivers/i2c/chips/rt5501.c drivers/i2c/chips/rt5501.c
index 5bd6e03..2648563 100644
--- drivers/i2c/chips/rt5501.c
+++ drivers/i2c/chips/rt5501.c
@@ -619,15 +619,13 @@ static void hs_imp_detec_func(struct work_struct *work)
rt5501_write_reg(0x0,0xc0);
rt5501_write_reg(0x81,0x30);
-
rt5501_write_reg(0x90,0xd0);
rt5501_write_reg(0x93,0x9d);
rt5501_write_reg(0x95,0x7b);
- rt5501_write_reg(0xa4,0x01);
-
- rt5501_write_reg(0x97,0x11);
+ rt5501_write_reg(0xa4,0x52);
+ rt5501_write_reg(0x97,0x00);
rt5501_write_reg(0x98,0x22);
- rt5501_write_reg(0x99,0x44);
+ rt5501_write_reg(0x99,0x33);
rt5501_write_reg(0x9a,0x55);
rt5501_write_reg(0x9b,0x66);x
rt5501_write_reg(0x9c,0x99);
@@ -696,7 +694,7 @@ static void volume_ramp_func(struct work_struct *work)
mutex_unlock(&rt5501_query.actionlock);
return;
}
- msleep(1);
+ mdelay(1);
rt5501_write_reg(1,val);
val++;
}
@@ -1035,15 +1033,13 @@ int rt5501_probe(struct i2c_client *client, const struct i2c_device_id *id)
rt5501_write_reg(0x0,0xc0);
rt5501_write_reg(0x81,0x30);
-
rt5501_write_reg(0x90,0xd0);
rt5501_write_reg(0x93,0x9d);
rt5501_write_reg(0x95,0x7b);
- rt5501_write_reg(0xa4,0x01);
-
- rt5501_write_reg(0x97,0x11);
+ rt5501_write_reg(0xa4,0x52);
+ rt5501_write_reg(0x97,0x00);
rt5501_write_reg(0x98,0x22);
- rt5501_write_reg(0x99,0x44);
+ rt5501_write_reg(0x99,0x33);
rt5501_write_reg(0x9a,0x55);
rt5501_write_reg(0x9b,0x66);
rt5501_write_reg(0x9c,0x99);
@junk-labs
Copy link
Author

junk-labs commented Nov 3, 2016

サウンドドライバと音量調整チップのバージョンを上げて下記の不具合を解消しようという試み。

不具合

【ROM焼き】au HTC J butterfly HTL21 root10
http://potato.2ch.net/test/read.cgi/smartphone/1434684523/108

108 :SIM無しさん : :2015/08/30(日) 18:23:14.46 ID:b/wOZekv
音楽やインターネットラジオを本体スピーカー、およびイヤホンから再生しているのですが音量が安定しません。
音量を最大にしても聞き始めから一秒ほどで中くらいの音量に下がってしまいます。
本体の再起動やカード類の抜き差し、
音量コントロールアプリでの調整、
音楽再生アプリ削除、
本体ボリューム全最大などいろいろ試しましたが結果は変わりませんでした。
他に、直る方法などありますでしょうか?

素材

audio_amp_update-form-m7ulstockui_6.04.1700.16.diff

CyanogenMod/android_kernel_htc_msm8960@784ba5c
↑より新しいのがあったので差し替え
HTCDev One M7 Google Play Edition -6.04.1700.16
m7ulstockui-3.4.10-gd08e956.zip

apq8064_update-form-.dlxwl__4.09.605.1.diff

HTCDev Droid DNA 4.09.605.1
dlxwl-3.4.10-g6a3a21b.tar.gz

結果

下記のアプリ(ヘッドセットと本体スピーカー)で不具合を確認出来なくなった

  • 音楽(標準)
  • LINE通話
  • モンスターストライク

まだ残ってる不具合

  • ツムツムの不具合はこれで直らない
  • 通話は未確認

@junk-labs
Copy link
Author

後いじくれるところと言ったらRUUで焼く本体ファームをDNAにしちまうか…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment