diff options
author | Scott Peterson <speterson@nvidia.com> | 2013-01-04 15:51:44 -0800 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2013-01-09 05:23:40 -0800 |
commit | fe38018d13f9f20402ce2ab929b8fa08795b3a42 (patch) | |
tree | 9d878d030ad48774bfa81c24f7027c1abe08f417 | |
parent | 254ffc21535b7caafe1eba785015ef5fdbea5090 (diff) |
arm: tegra: roth: Reduce volume change clicks
Reduce the number of clicks in volume changes
by only writing TFA8997 device presets when a
new preset is detected.
Bug 1211519 Partial fix
Change-Id: Ia3f268cc3db57a4de6c4ba245a06c70aac094504
Reviewed-on: http://git-master/r/188829
(cherry picked from commit e11061bfd0e7c0bcf7d8b2ffd7709cfdbfcc01b5)
Signed-off-by: Scott Peterson <speterson@nvidia.com>
Change-Id: Ib332cd9a99562120dd1092045e883b2c9c97ba90
Reviewed-on: http://git-master/r/189663
Reviewed-by: Mandar Padmawar <mpadmawar@nvidia.com>
Tested-by: Mandar Padmawar <mpadmawar@nvidia.com>
-rw-r--r-- | drivers/misc/tfa9887.c | 72 | ||||
-rw-r--r-- | include/linux/tfa9887.h | 2 |
2 files changed, 29 insertions, 45 deletions
diff --git a/drivers/misc/tfa9887.c b/drivers/misc/tfa9887.c index c2cbca46088a..5dff8a009bdf 100644 --- a/drivers/misc/tfa9887.c +++ b/drivers/misc/tfa9887.c @@ -476,25 +476,6 @@ int DspSetParam(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, int rpcStatus = STATUS_OK; int tries = 0; -#if 1 - { - /* minimize the number of I2C transactions by making use of the autoincrement in I2C */ - unsigned char buffer[7]; - /* first the data for CF_CONTROLS */ - buffer[0] = (unsigned char)((cf_ctrl >> 8) & 0xFF); - buffer[1] = (unsigned char)(cf_ctrl & 0xFF); - /* write the contents of CF_MAD which is the subaddress following CF_CONTROLS */ - buffer[2] = (unsigned char)((cf_mad >> 8) & 0xFF); - buffer[3] = (unsigned char)(cf_mad & 0xFF); - /* write the module and RPC id into CF_MEM, which follows CF_MAD */ - buffer[4] = 0; - buffer[5] = module_id + 128; - buffer[6] = param_id; - error = - regmap_raw_write(tfa9887_byte->regmap, TFA9887_CF_CONTROLS, - buffer, sizeof(buffer)); - } -#else error = Tfa9887_WriteRegister(tfa9887, TFA9887_CF_CONTROLS, cf_ctrl); if (error == Tfa9887_Error_Ok) { error = Tfa9887_WriteRegister(tfa9887, TFA9887_CF_MAD, cf_mad); @@ -506,7 +487,6 @@ int DspSetParam(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, id[2] = param_id; error = regmap_raw_write(tfa9887_byte->regmap, TFA9887_CF_MEM,&id, 3); } -#endif error = regmap_raw_write(tfa9887_byte->regmap, TFA9887_CF_MEM, data, num_bytes); @@ -517,12 +497,12 @@ int DspSetParam(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, do { error = Tfa9887_ReadRegister(tfa9887, TFA9887_CF_STATUS, &cf_status); tries++; - udelay(100); + usleep_range(100, 200); } while ( (error==Tfa9887_Error_Ok) && ((cf_status & 0x0100) == 0) && (tries < 10) ); /* don't wait forever, DSP is pretty quick to respond (< 1ms) */ if (tries >= 100) { /* something wrong with communication with DSP */ - //pr_info("Setparam failed\n"); + pr_info("Setparam failed\n"); error = -1; } } @@ -531,6 +511,7 @@ int DspSetParam(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, if (error == Tfa9887_Error_Ok) { error = Tfa9887_WriteRegister(tfa9887, TFA9887_CF_CONTROLS,cf_ctrl); } + if (error == Tfa9887_Error_Ok) { error = Tfa9887_WriteRegister(tfa9887, TFA9887_CF_MAD, cf_mad); } @@ -726,7 +707,7 @@ int Tfa9887_Init(int sRate) { int error = 0; srate = sRate; - if((tfa9887R) && (tfa9887R->deviceInit)) { + if ((tfa9887R) && (tfa9887R->deviceInit)) { coldStartup(tfa9887R, tfa9887R_byte, srate); //Tfa9887_WriteRegister(tfa9887R, 0x0B, 0x5A); /* unlock key2 */ //Tfa9887_WriteRegister(tfa9887R, TFA9887_MTP, 0); /* MTPOTC=1, MTPEX=0 */ @@ -740,7 +721,7 @@ int Tfa9887_Init(int sRate) } } - if((tfa9887L) && (tfa9887L->deviceInit)) { + if ((tfa9887L) && (tfa9887L->deviceInit)) { coldStartup(tfa9887L, tfa9887L_byte, srate); //Tfa9887_WriteRegister(tfa9887L, 0x0B, 0x5A); /* unlock key2 */ //Tfa9887_WriteRegister(tfa9887L, TFA9887_MTP, 0); /* MTPOTC=1, MTPEX=0 */ @@ -760,24 +741,26 @@ int Tfa9887_Init(int sRate) int Tfa9887_SetEq(void) { - int error = 0; - if((tfa9887R) && (tfa9887R->deviceInit)) - error = SetEq(tfa9887R,tfa9887R_byte); - if((tfa9887L) && (tfa9887L->deviceInit)) - error = SetEq(tfa9887L,tfa9887L_byte); - return error; + int error = 0; + if ((tfa9887R) && (tfa9887R->deviceInit)) + error = SetEq(tfa9887R, tfa9887R_byte); + if ((tfa9887L) && (tfa9887L->deviceInit)) + error = SetEq(tfa9887L, tfa9887L_byte); + return error; } -int Tfa9887_SetPreset(void) +int Tfa9887_SetPreset(unsigned int preset) { - int error = 0; - unsigned short status; - - if((tfa9887R) && (tfa9887R->deviceInit)) - error = SetPreset(tfa9887R,tfa9887R_byte); - if((tfa9887L) && (tfa9887L->deviceInit)) - error = SetPreset(tfa9887L,tfa9887L_byte); - return error; + int error = 0; + unsigned short status; + if (preset != preset_mode) { + preset_mode = preset; + if ((tfa9887R) && (tfa9887R->deviceInit)) + error = SetPreset(tfa9887R, tfa9887R_byte); + if ((tfa9887L) && (tfa9887L->deviceInit)) + error = SetPreset(tfa9887L, tfa9887L_byte); + } + return error; } int coldStartup(struct tfa9887_priv *tfa9887, struct tfa9887_priv *tfa9887_byte, int sRate) @@ -1065,9 +1048,9 @@ int stereoRouting(struct tfa9887_priv *tfa9887) int Tfa9887_Powerdown(int powerdown) { int error = 0; - if((tfa9887R) && (tfa9887R->deviceInit)) + if ((tfa9887R) && (tfa9887R->deviceInit)) error = Powerdown(tfa9887R, tfa9887R_byte, powerdown); - if((tfa9887L) && (tfa9887L->deviceInit)) + if ((tfa9887L) && (tfa9887L->deviceInit)) error = Powerdown(tfa9887L, tfa9887L_byte, powerdown); return error; } @@ -1289,6 +1272,7 @@ static ssize_t tfa9887_vol_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { ssize_t ret = count; + unsigned int preset; //printk("+tfa9887_vol_store: %d, %d\n", *buf, count); if (!tfa9887R || !tfa9887L || @@ -1302,11 +1286,11 @@ static ssize_t tfa9887_vol_store(struct kobject *kobj, goto fail; } if (*buf >= DB_CUTOFF_INDEX) - preset_mode = MAX_DB_INDEX - *buf; + preset = MAX_DB_INDEX - *buf; else - preset_mode = PRESET_DEFAULT; + preset = PRESET_DEFAULT; - Tfa9887_SetPreset(); + Tfa9887_SetPreset(preset); fail: //printk("-tfa9887_vol_store: %d\n", count); return ret; diff --git a/include/linux/tfa9887.h b/include/linux/tfa9887.h index 90ad62e08ec8..47315f112ee1 100644 --- a/include/linux/tfa9887.h +++ b/include/linux/tfa9887.h @@ -55,7 +55,7 @@ int Tfa9887_SetEq(void); int SetEq(struct tfa9887_priv *tfa9887,struct tfa9887_priv *tfa9887_byte); -int Tfa9887_SetPreset(void); +int Tfa9887_SetPreset(unsigned int preset); int SetPreset(struct tfa9887_priv *tfa9887,struct tfa9887_priv *tfa9887_byte); |