[alsa-devel] [PATCH 2/3] asoc tlv320aic3x: add GPIO support
This patch adds support for AIC3x GPIO lines. They can be configured for many possible functions as well as be driven manually. I also introduced i2c read functionality since the GPIO state register has to be read from hardware every time and can not be served from cache.
Signed-off-by: Daniel Mack daniel@caiaq.de
At Fri, 25 Apr 2008 11:17:52 +0200, Daniel Mack wrote:
+int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio) +{
- u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG;
- u8 val, bit = gpio ? 2: 1;
- aic3x_read(codec, reg, &val);
- return !!(val & (1 << bit));
I prefer a form like return (val >> bit) & 1;
"!!" often makes hard to read.
Takashi
On Fri, Apr 25, 2008 at 11:25:38AM +0200, Takashi Iwai wrote:
+int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio) +{
- u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG;
- u8 val, bit = gpio ? 2: 1;
- aic3x_read(codec, reg, &val);
- return !!(val & (1 << bit));
I prefer a form like return (val >> bit) & 1;
"!!" often makes hard to read.
Ok, agreed. New patch below.
Best regards, Daniel
On Fri, Apr 25, 2008 at 11:25:38AM +0200, Takashi Iwai wrote:
+int aic3x_get_gpio(struct snd_soc_codec *codec, int gpio) +{
- u8 reg = gpio ? AIC3X_GPIO2_REG : AIC3X_GPIO1_REG;
- u8 val, bit = gpio ? 2: 1;
- aic3x_read(codec, reg, &val);
- return !!(val & (1 << bit));
I prefer a form like return (val >> bit) & 1;
"!!" often makes hard to read.
Patch rebased to match with other changes introduced by the clocking patch.
Daniel
participants (2)
-
Daniel Mack
-
Takashi Iwai