Skip to content
Permalink
Browse files

Fix to make deep standby working, small Audio fix

  • Loading branch information...
rebel1 committed Sep 26, 2011
1 parent 458a68d commit 0d355b2c17db2bfdb054da3625d1875f55e74dbe
@@ -252,7 +252,7 @@ static struct alc5624_platform_data alc5624_pdata = {
.avdd_mv = 3300, /* Analog vdd in millivolts */
.spkvdd_mv = 5000, /* Speaker Vdd in millivolts */
.hpvdd_mv = 3300, /* Headphone Vdd in millivolts */
.spkvol_scale = 80, /* Scale speaker volume to the percent of maximum range -Be careful: range is logarithmic! */
.spkvol_scale = 88, /* Scale speaker volume to the percent of maximum range -Be careful: range is logarithmic! */

.mic1bias_mv = 2970, /* MIC1 bias voltage */
.mic2bias_mv = 2970, /* MIC2 bias voltage */
@@ -40,7 +40,8 @@ struct evdev {
struct evdev_client {
int head;
int tail;
spinlock_t buffer_lock; /* protects access to buffer, head and tail */
spinlock_t buffer_lock; /* protects access to buffer, head and tail */
bool use_wakelock; /* Some devices should NOT use a wakelock - Sensors are good examples of this */
struct wake_lock wake_lock;
char name[28];
struct fasync_struct *fasync;
@@ -62,7 +63,8 @@ static void evdev_pass_event(struct evdev_client *client,
* "empty" by having client->head == client->tail.
*/
spin_lock(&client->buffer_lock);
wake_lock_timeout(&client->wake_lock, 5 * HZ);
if (client->use_wakelock)
wake_lock_timeout(&client->wake_lock, 5 * HZ);
do {
client->buffer[client->head++] = *event;
client->head &= client->bufsize - 1;
@@ -247,7 +249,8 @@ static int evdev_release(struct inode *inode, struct file *file)
mutex_unlock(&evdev->mutex);

evdev_detach_client(evdev, client);
wake_lock_destroy(&client->wake_lock);
if (client->use_wakelock)
wake_lock_destroy(&client->wake_lock);
kfree(client);

evdev_close_device(evdev);
@@ -265,6 +268,16 @@ static unsigned int evdev_compute_buffer_size(struct input_dev *dev)
return roundup_pow_of_two(n_events);
}

static bool evdev_is_continuous_reporting_sensor(struct input_dev *dev)
{
/* If it has keys of any kind, probably not a sensor ... */
if (test_bit(EV_KEY,dev->evbit))
return false;

/* Otherwise, assume it is a sensor */
return true;
}

static int evdev_open(struct inode *inode, struct file *file)
{
struct evdev *evdev;
@@ -297,11 +310,15 @@ static int evdev_open(struct inode *inode, struct file *file)
goto err_put_evdev;
}

/* Use a wakelock ONLY if not using a continuos reporting sensor */
client->use_wakelock = !evdev_is_continuous_reporting_sensor(evdev->handle.dev);

client->bufsize = bufsize;
spin_lock_init(&client->buffer_lock);
snprintf(client->name, sizeof(client->name), "%s-%d",
dev_name(&evdev->dev), task_tgid_vnr(current));
wake_lock_init(&client->wake_lock, WAKE_LOCK_SUSPEND, client->name);
if (client->use_wakelock)
wake_lock_init(&client->wake_lock, WAKE_LOCK_SUSPEND, client->name);
client->evdev = evdev;
evdev_attach_client(evdev, client);

@@ -316,7 +333,8 @@ static int evdev_open(struct inode *inode, struct file *file)

err_free_client:
evdev_detach_client(evdev, client);
wake_lock_destroy(&client->wake_lock);
if (client->use_wakelock)
wake_lock_destroy(&client->wake_lock);
kfree(client);
err_put_evdev:
put_device(&evdev->dev);
@@ -368,7 +386,7 @@ static int evdev_fetch_next_event(struct evdev_client *client,
if (have_event) {
*event = client->buffer[client->tail++];
client->tail &= client->bufsize - 1;
if (client->head == client->tail)
if (client->head == client->tail && client->use_wakelock)
wake_unlock(&client->wake_lock);
}

@@ -116,6 +116,7 @@ static struct it7260_ts_data *gl_ts;
#define CMD_CALIBRATE 0x13 /* Mass Production Calibration */
#define CMD_RES5 0x14 /* Reserved for internal use */
#define CMD_SET_PT_THRESH 0x15 /* Set Point Threshold */
#define CMD_RESET 0x6F /* Reset fw */


static int it7260_read_query_buffer(struct it7260_ts_data *ts,unsigned char * pucData)
@@ -254,27 +255,33 @@ static int it7260_wait_for_idle(struct it7260_ts_data *ts)
static int it7260_flush(struct it7260_ts_data *ts)
{
int ret = 0;
unsigned char pucBuf[14];
unsigned char ucQuery = QUERY_CMD_STATUS_BUSY;
dev_info(&ts->client->dev,"flushing buffers\n");

// Try a brute force clean first
it7260_read_query_buffer(ts,&ucQuery);
it7260_read_point_buffer(ts,pucBuf);
it7260_read_command_response_buffer(ts,pucBuf,10);

if (ts->client->irq) {
// Interrupt assigned, use it to wait
unsigned char ucQuery = 0;
unsigned char pucPoint[14];
int gpio = irq_to_gpio(ts->client->irq);
int pollend = jiffies + HZ; // 1 second of polling, maximum...
while( !gpio_get_value(gpio) && jiffies < pollend) {
it7260_read_query_buffer(ts,&ucQuery);
it7260_read_point_buffer(ts,pucPoint);
it7260_read_point_buffer(ts,pucBuf);
it7260_read_command_response_buffer(ts,pucBuf,10);
schedule();
};
ret = gpio_get_value(gpio) ? 0 : -1;
} else {
// No interrupt. Use a polling method
unsigned char ucQuery = QUERY_CMD_STATUS_BUSY;
unsigned char pucPoint[14];
int pollend = jiffies + HZ; // 1 second of polling, maximum...
while( (ucQuery & QUERY_CMD_STATUS_BUSY) && jiffies < pollend) {
if (it7260_read_query_buffer(ts,&ucQuery) >= 0) {
it7260_read_point_buffer(ts,pucPoint);
it7260_read_point_buffer(ts,pucBuf);
it7260_read_command_response_buffer(ts,pucBuf,10);
} else {
ucQuery = QUERY_CMD_STATUS_BUSY;
}
@@ -445,7 +452,7 @@ static int it7260_init(struct it7260_ts_data *ts)
return -1;
}

pucCmd[0] = CMD_REINIT_FW;
pucCmd[0] = CMD_RESET;
ret = it7260_write_command_buffer(ts,pucCmd,1);
if (ret < 0) {
dev_err(&ts->client->dev,"failed to reset touchpad\n");
@@ -577,12 +577,12 @@ static const struct {
{ALC5624_PHONEIN_MONO_OUT_VOL , 0xDFDF }, /* Phone input muted, Mono output muted */
{ALC5624_LINE_IN_VOL , 0xFF1F }, /* Mute Line In volume */
{ALC5624_STEREO_DAC_VOL , 0x6808 }, /* Mute volume output to Mono and Speaker */
{ALC5624_MIC_VOL , 0x0808 }, /* Mic volume = 0db */
{ALC5624_MIC_VOL , 0x0000 }, /* Mic volume = +12db gain */
{ALC5624_MIC_ROUTING_CTRL , 0xF0F0 }, /* Mute mic volume to Headphone, Speaker and Mono mixers, Differential mode enabled */
{ALC5624_ADC_REC_GAIN , 0xF58B },
{ALC5624_ADC_REC_MIXER , 0x3F3F }, /* Mic1 as recording sources - will be overriden on init */
{ALC5624_OUTPUT_MIXER_CTRL , 0x6B00 }, /* SPKL from HP mixer, Class D amplifier, SPKR from HP mixer, HPL from headphone mixer, HPR from headphone mixer, Mono from VMid */
{ALC5624_MIC_CTRL , 0x0F02 }, /* 1.8uA short current det, Bias volt =0.9Avdd, +40db gain boost */
{ALC5624_MIC_CTRL , 0x0A02 }, /* 1.8uA short current det, Bias volt =0.9Avdd, +30db gain boost */
{ALC5624_PD_CTRL_STAT , 0x0000 }, /* No powerdown */
{ALC5624_MAIN_SDP_CTRL , 0x8000 }, /* Slave interfase */
{ALC5624_PWR_MANAG_ADD1 , 0x003C }, /* Nothing powered down, except I2S interface, and main references */
@@ -840,6 +840,21 @@ static int mixer_event (struct snd_soc_dapm_widget *w,
}


/*
* Leave some time for bias to ramp up so we avoid pops - 500ms is what is needed
*/
static int micbias_event(struct snd_soc_dapm_widget *w,struct snd_kcontrol *kcontrol, int event)
{
switch (event) {
case SND_SOC_DAPM_POST_PMU:
msleep(500);
break;
default:
break;
}
return 0;
}

static const struct snd_soc_dapm_widget alc5624_dapm_widgets[] = {
SND_SOC_DAPM_MUX("Mono Out Mux", SND_SOC_NOPM, 0, 0,
&alc5624_mono_mux_controls),
@@ -892,8 +907,9 @@ SND_SOC_DAPM_PGA("Mic 2 PGA", ALC5624_PWR_MANAG_ADD3, 2, 0, NULL, 0),
SND_SOC_DAPM_PGA("Mic 1 Pre Amp", ALC5624_PWR_MANAG_ADD3, 1, 0, NULL, 0),
SND_SOC_DAPM_PGA("Mic 2 Pre Amp", ALC5624_PWR_MANAG_ADD3, 0, 0, NULL, 0),

SND_SOC_DAPM_MICBIAS("Mic Bias1", ALC5624_PWR_MANAG_ADD1, 3, 0),
SND_SOC_DAPM_MICBIAS("Mic Bias2", ALC5624_PWR_MANAG_ADD1, 2, 0),
SND_SOC_DAPM_MICBIAS_E("Mic Bias1", ALC5624_PWR_MANAG_ADD1, 3, 0, micbias_event, SND_SOC_DAPM_POST_PMU),
SND_SOC_DAPM_MICBIAS_E("Mic Bias2", ALC5624_PWR_MANAG_ADD1, 2, 0, micbias_event, SND_SOC_DAPM_POST_PMU),

SND_SOC_DAPM_OUTPUT("MONO"),
SND_SOC_DAPM_OUTPUT("HPL"),
SND_SOC_DAPM_OUTPUT("HPR"),
@@ -1697,6 +1713,7 @@ static int alc5624_set_bias_level(struct snd_soc_codec *codec,
/* Codec sys-clock from PLL */
snd_soc_update_bits(codec,ALC5624_GEN_CTRL_REG1, 0x8000,0x8000);
}

break;

case SND_SOC_BIAS_PREPARE:
@@ -1746,7 +1763,7 @@ static int alc5624_set_bias_level(struct snd_soc_codec *codec,
snd_soc_update_bits(codec, ALC5624_MISC_CTRL, 0x8000, 0x0000);

/* Let it stabilize */
msleep(10);
msleep(200);

/* Disable fast Vref */
snd_soc_update_bits(codec, ALC5624_MISC_CTRL, 0x8000, 0x8000);
@@ -2218,8 +2235,6 @@ static __devinit int alc5624_i2c_probe(struct i2c_client *client,
alc5624->mic2boost_db = pdata->mic2boost_db; /* MIC2 gain boost */
alc5624->default_is_mic2 = pdata->default_is_mic2; /* If MIC2 is the default MIC or not */



i2c_set_clientdata(client, alc5624);
alc5624->control_data = client;
alc5624->control_type = SND_SOC_I2C;

0 comments on commit 0d355b2

Please sign in to comment.
You can’t perform that action at this time.