return 0;
}
-static int es_dac_enable(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol, int event)
-{
- struct snd_soc_codec *codec = w->codec;
- unsigned int val;
- pr_debug("%s DAC%d event %d\n", __func__, w->shift, event);
-
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- snd_soc_update_bits(codec, w->reg, 1<<w->shift, 1<<w->shift);
- snd_soc_update_bits(codec, ES_DAC_DIG_EN, ES_DIG_CLK_EN_MASK,
- ES_DIG_CLK_EN);
- snd_soc_update_bits(codec, ES_DAC_DIG_EN, ES_DAC_CLK_EN_MASK,
- ES_DAC_CLK_EN);
- break;
- case SND_SOC_DAPM_POST_PMD:
- snd_soc_update_bits(codec, w->reg, 1<<w->shift , 0);
- snd_soc_update_bits(codec, ES_DAC_DIG_EN, ES_DIG_CLK_EN_MASK,
- 0);
- snd_soc_update_bits(codec, ES_DAC_DIG_EN, ES_DAC_CLK_EN_MASK,
- 0);
- break;
- }
-
- /* find which DAC is enabled */
- val = snd_soc_read(codec, ES_DAC_CTRL);
- snd_soc_update_bits(codec, ES_DAC_DIG_EN, ES_DAC0_LEFT_EN_MASK |
- ES_DAC0_RIGHT_EN_MASK | ES_DAC1_LEFT_EN_MASK |
- ES_DAC1_RIGHT_EN_MASK, val);
-
- return 0;
-}
-
static int mic_event(struct snd_soc_dapm_widget *w,
struct snd_kcontrol *k, int event)
{
SND_SOC_DAPM_ADC("ADC3", NULL, ES_ADC_CTRL, ES_ADC3_ON_SHIFT, 0),
/* DAC */
- SND_SOC_DAPM_DAC_E("DAC0L", NULL, ES_DAC_CTRL, ES_DAC0L_ON_SHIFT,
- 0, es_dac_enable, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_DAC_E("DAC0R", NULL, ES_DAC_CTRL, ES_DAC0R_ON_SHIFT,
- 0, es_dac_enable, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_DAC_E("DAC1L", NULL, ES_DAC_CTRL, ES_DAC1L_ON_SHIFT,
- 0, es_dac_enable, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_DAC_E("DAC1R", NULL, ES_DAC_CTRL, ES_DAC1R_ON_SHIFT,
- 0, es_dac_enable, SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
+ SND_SOC_DAPM_DAC("DAC0L", NULL, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_DAC("DAC0R", NULL, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_DAC("DAC1L", NULL, SND_SOC_NOPM, 0, 0),
+ SND_SOC_DAPM_DAC("DAC1R", NULL, SND_SOC_NOPM, 0, 0),
/* Earphone Mixer */
SND_SOC_DAPM_MIXER("EP MIXER", SND_SOC_NOPM, 0, 0,
u32 resp;
int ret = 0;
- /* Stop the route first */
- ret = escore_cmd(escore, stop_route_cmd, &resp);
- if (ret) {
- pr_err("%s: Route stop failed\n", __func__);
- return ret;
- }
-
/* Disable DHWPT if enabled */
if (escore->algo_type == DHWPT) {
u32 cmd = escore->dhwpt_cmd & 0xFFFF0000;
}
}
- escore->current_preset = 0;
+ /* Stop the route */
+ ret = escore_cmd(escore, stop_route_cmd, &resp);
+ if (ret) {
+ pr_err("%s: Route stop failed\n", __func__);
+ return ret;
+ }
+ escore->current_preset = 0;
return ret;
}
escore->current_preset = msg & 0xFFFF;
rc = escore_queue_msg_to_list(escore, (char *)&msg, sizeof(msg));
- if (!rc && escore->algo_type == DHWPT) {
- msg = escore->dhwpt_cmd;
- rc = escore_queue_msg_to_list(escore,
- (char *)&msg, sizeof(msg));
- }
/* Configure command completion mode */
if (escore->cmd_compl_mode == ES_CMD_COMP_INTR) {
cmd |= escore->pdata->gpio_a_irq_type;
unsigned int reg = e->reg;
unsigned int value = ucontrol->value.enumerated.item[0];
- pr_debug("%s(): %s algo :%d\n", __func__, (value) ? "Enabling" :
- "Disabling", reg);
+ pr_debug("%s(): %s algo :%s\n", __func__, (value) ? "Enabling" :
+ "Disabling", kcontrol->id.name);
+
/* Use 0th array to store the algo status */
cachedcmd_list[0][reg].reg = value;
switch (reg) {
algo_type = DHWPT;
break;
default:
- pr_err("%s(): Algo type not implemented: %d\n", __func__, reg);
+ pr_err("%s(): Algo type not implemented: %s\n", __func__, kcontrol->id.name);
ret = -EINVAL;
break;
}
#endif
exit:
- pr_debug("put input reg %d val %d\n", reg, mux);
+ pr_debug("put input control %s (%d) val %s (%d)\n", kcontrol->id.name, reg, proc_block_input_texts[mux], mux);
return rc;
}
/* TBD: translation */
/* value = escore_read(NULL, reg); */
ucontrol->value.enumerated.item[0] = value;
- pr_debug("get input reg %d val %d\n", reg, value);
+ pr_debug("get input control %s (%d) val %s (%d)\n", kcontrol->id.name, reg, proc_block_input_texts[value], value);
return 0;
}
#endif
exit:
- pr_debug("put output reg %d val %d\n", reg, mux);
+ pr_debug("put output control %s (%d) val %s (%d)\n", kcontrol->id.name, reg, proc_block_output_texts[mux], mux);
return rc;
}
/* TBD: translation */
/* value = escore_read(NULL, reg); */
ucontrol->value.enumerated.item[0] = value;
- pr_debug("get output reg %d val %d\n", reg, value);
+ pr_debug("get output control %s (%d) val %s (%d)\n", kcontrol->id.name, reg, proc_block_output_texts[value], value);
return 0;
}
escore->algo_preset_one = value;
+ /* Ignore Preset ID 0 and don't send command to device,5
+ * but reset algo_preset value so that next preset value
+ * can be set properly. */
+ if (!escore->algo_preset_one) {
+ dev_dbg(escore_priv.dev,
+ "%s(): Algo Preset %d is not supported, Skipped\n",
+ __func__, value);
+ return rc;
+ }
+
if (atomic_read(&escore->active_streams)) {
/* Set the preset immediately */
usleep_range(5000, 5005);
escore->algo_preset_two = value;
+ /* Ignore Preset ID 0 and don't send command to device,5
+ * but reset algo_preset value so that next preset value
+ * can be set properly. */
+ if (!escore->algo_preset_two) {
+ dev_dbg(escore_priv.dev,
+ "%s(): Algo Preset %d is not supported, Skipped\n",
+ __func__, value);
+ return rc;
+ }
+
if (atomic_read(&escore->active_streams)) {
/* Set the preset immediately */
usleep_range(5000, 5005);
.val_shift = 0,
.val_max = 65535,
},
+ [ES_CODEC_OUTPUT_RATE] = {
+ .read_msg = { ES_API_WORD(ES_GET_DEV_PARAM, 0x1604) },
+ .read_msg_len = 4,
+ .write_msg = { ES_API_WORD(ES_SET_DEV_PARAM_ID, 0x1604),
+ ES_API_WORD(ES_SET_DEV_PARAM, 0x0000) },
+ .write_msg_len = 8,
+ .val_shift = 0,
+ .val_max = 65535,
+ },
+
};
int id = DAI_INDEX(dai->id);
int port_map = 0;
u16 clock_control = 0;
+ u16 codec_output_rate = 0;
u8 pcm_port[] = { ES755_PCM_PORT_A,
ES755_PCM_PORT_B,
ES755_PCM_PORT_C };
/* Clear the Port info in write command */
api_access->write_msg[0] &= ES_API_WORD(ES_SET_DEV_PARAM_ID, 0x00ff);
+ /* Set codec output rate 96Khz(0x2) for 192K and 48Khz(0x0) for rest */
+ /* required for droop filter settings */
+ if (params_rate(params) == 192000)
+ codec_output_rate = 0x2;
+
+ rc = escore_write(codec, ES_CODEC_OUTPUT_RATE,
+ codec_output_rate);
+ if (rc) {
+ pr_err("%s(): Preparing write message failed %d\n",
+ __func__, rc);
+ return rc;
+ }
+
/*
* To enter into MP_SLEEP mode during playback, a minimum 3Mhz clock
* is required. For that, minimum 48Khz sample rate, 32 bit word length
static int es755_codec_write(struct snd_soc_codec *codec, unsigned int reg,
unsigned int value)
{
+ u32 resp;
+ u32 cmd;
struct escore_priv *escore = &escore_priv;
int ret = 0;
u8 state_changed = 0;
}
escore->reg_cache[reg].value = value;
+ if (escore->algo_type == DHWPT && reg == ES_HP_L_CTRL) {
+ if (value & 1) {
+ cmd = escore->dhwpt_cmd;
+ ret = escore->bus.ops.cmd(escore, cmd, &resp);
+ if (ret < 0) {
+ pr_err("%s(): Error %d in setting event response\n",
+ __func__, ret);
+ goto out;
+ }
+ }
+ }
+
if (state_changed) {
msleep(20);
pr_debug("%s(): Put chip back into mp_sleep\n", __func__);
goto intr_exit;
}
accdet_status_reg.value = value;
+ redetect_hs = 1; /* initialize the counter */
/* Ignore interurpt if
* plugdet_fsm2 = 1 and plugdet_fsm1 = 1
{
struct escore_priv *escore = (struct escore_priv *)data;
int retry = ES_EVENT_STATUS_RETRY_COUNT;
- int rc, ret;
+ int rc = 0;
+ int ret = 0;
u32 cmd = 0;
u32 event_type = 0;
mutex_lock(&escore->api_mutex);
while (retry) {
- rc = escore->bus.ops.cmd(escore, cmd, &event_type);
- if (!rc || !--retry)
- break;
- pr_info("%s(): wakeup and retry\n", __func__);
- ret = escore_wakeup(escore);
- if (ret) {
- dev_err(escore->dev, "%s() wakeup failed ret = %d\n",
- __func__, ret);
- break;
+ /* Check power state before sending command */
+ if ((escore->escore_power_state == ES_SET_POWER_STATE_NORMAL)
+ || escore->escore_power_state ==
+ ES_SET_POWER_STATE_VS_OVERLAY) {
+ rc = escore->bus.ops.cmd(escore, cmd, &event_type);
+ if (!rc || !--retry)
+ break;
+ } else {
+ pr_info("%s(): wakeup and retry\n", __func__);
+ ret = escore_wakeup(escore);
+ if (ret) {
+ dev_err(escore->dev,
+ "%s() wakeup failed ret = %d\n",
+ __func__, ret);
+ break;
+ }
+
+ if (escore->escore_power_state ==
+ escore->non_vs_sleep_state) {
+ escore->escore_power_state = ES_SET_POWER_STATE_NORMAL;
+ } else if (escore->escore_power_state ==
+ ES_SET_POWER_STATE_VS_LOWPWR) {
+ escore->escore_power_state =
+ ES_SET_POWER_STATE_VS_OVERLAY;
+
+ /* If the chip is not awake,the reading of event will wakeup
+ * the chip which will result in interrupt reconfiguration
+ * from device resume. Reconfiguration is deferred till the
+ * time interrupt is processed from the notifier callback.
+ *
+ * The interrupt reconfiguration in this case will be taken
+ * care of by a low priority notifier callback
+ */
+ escore->defer_intr_config = 1;
+ }
}
}
if (rc < 0) {
goto irq_exit;
}
- if (escore->escore_power_state == escore->non_vs_sleep_state) {
- escore->escore_power_state = ES_SET_POWER_STATE_NORMAL;
- } else if (escore->escore_power_state == ES_SET_POWER_STATE_VS_LOWPWR) {
- escore->escore_power_state = ES_SET_POWER_STATE_VS_OVERLAY;
-
- /* If the chip is not awake, the reading of event will wakeup
- * the chip which will result in interrupt reconfiguration
- * from device resume. Reconfiguration is deferred till the
- * time interrupt is processed from the notifier callback.
- *
- * The interrupt reconfiguration in this case will be taken
- * care of by a low priority notifier callback
- */
- escore->defer_intr_config = 1;
- }
-
mutex_unlock(&escore->api_mutex);
event_type &= ES_MASK_INTR_EVENT;
ES_CMD_COMPL_MODE,
ES_FE_STREAMING,
ES_FEIN2_MUX,
+ ES_CODEC_OUTPUT_RATE,
ES_API_ADDR_MAX,
ES_HS_DELAY,
};
/* Set the Smooth Mute rate to Zero */
cmd = ES_SET_SMOOTH_MUTE << 16 | ES_SMOOTH_MUTE_ZERO;
rc = escore->bus.ops.cmd(escore, cmd, &rsp);
- if (rc) {
+ if (rc)
dev_err(escore->dev, "%s(): escore_cmd fail %d\n",
__func__, rc);
- goto escore_wakeup_exit;
- }
-
- /* Setup the Event response */
- cmd = (ES_SET_EVENT_RESP << 16) |
- escore->pdata->gpio_b_irq_type;
- rc = escore->bus.ops.cmd(escore, cmd, &rsp);
- if (rc < 0)
- pr_err("%s(): Error %d in setting event response\n",
- __func__, rc);
escore_wakeup_exit:
return rc;