From: Marek Vasut <marek.vasut@gmail.com>
To: Vasily Khoruzhick <anarsoul@gmail.com>
Cc: alsa-devel@alsa-project.org,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Ben Dooks <ben-linux@fluff.org>,
Philipp Zabel <philipp.zabel@gmail.com>,
Liam Girdwood <lrg@slimlogic.co.uk>
Subject: Re: [PATCH v4 1/3] ASoC: uda1380: make driver more powersave-friendly
Date: Sun, 29 Aug 2010 21:11:51 +0200 [thread overview]
Message-ID: <201008292111.51406.marek.vasut@gmail.com> (raw)
In-Reply-To: <201008292113.21777.anarsoul@gmail.com>
Dne Ne 29. srpna 2010 20:13:07 Vasily Khoruzhick napsal(a):
> В сообщении от 29 августа 2010 20:37:03 автор Marek Vasut написал:
> > > + void *control_data;
> >
> > It's already in codec->control_data, isn't it ?
>
> I'm using priv->control_data as temporary storage to initialize codec-
>
> >control_data later, as there's no snd_soc_codec in i2c_probe
Now I know, nevermind.
> >
> > > @@ -145,7 +185,6 @@ static void uda1380_flush_work(struct work_struct
> > > *work) uda1380_read_reg_cache(uda1380_codec, reg));
> > >
> > > clear_bit(bit, &uda1380_cache_dirty);
> > >
> > > }
> > >
> > > -
> >
> > Remove
>
> It improves code formatting.
It's unrelated to this patch though ... maybe some general "formating fixes"
patch would be appropriate.
>
> > > @@ -560,18 +599,40 @@ static int uda1380_set_bias_level(struct
> > > snd_soc_codec *codec, enum snd_soc_bias_level level)
> > >
> > > {
> > >
> > > int pm = uda1380_read_reg_cache(codec, UDA1380_PM);
> > >
> > > + struct uda1380_platform_data *pdata = codec->dev->platform_data;
> > > +
> > > + if (codec->bias_level == level)
> > > + return 0;
> > >
> > > switch (level) {
> > > case SND_SOC_BIAS_ON:
> > >
> > > case SND_SOC_BIAS_PREPARE:
> > > + /* ADC, DAC on */
> > >
> > > uda1380_write(codec, UDA1380_PM, R02_PON_BIAS | pm);
> > > break;
> > >
> > > case SND_SOC_BIAS_STANDBY:
> > > - uda1380_write(codec, UDA1380_PM, R02_PON_BIAS);
> > > - break;
> > > - case SND_SOC_BIAS_OFF:
> > > + if (codec->bias_level == SND_SOC_BIAS_OFF) {
> > > + if (pdata->gpio_power != -EINVAL) {
> > > + gpio_set_value(pdata->gpio_power, 1);
> > > + uda1380_reset(codec);
> > > + }
> > > +
> > > + uda1380_sync_cache(codec);
> > > + }
> > >
> > > uda1380_write(codec, UDA1380_PM, 0x0);
> >
> > Maybe some comment won't hurt here about what that 0x0 does.
>
> Well, code explain it pretty well, it puts codec into stand-by mode :)
/* Writing 0x0 to UDA1380_PM register puts codec into sleep mode */
>
> > > break;
> > >
> > > + case SND_SOC_BIAS_OFF:
> > if (pdata->gpio_power == -EINVAL)
> >
> > break;
> >
> > ...code...
> >
> > might help your alignment below.
>
> Ok
>
> > > + if (pdata->gpio_power != -EINVAL) {
> > > + int reg;
> > > + gpio_set_value(pdata->gpio_power, 0);
> > > +
> > > + /* Mark mixer regs cache dirty to sync them with
> > > + * codec regs on power on.
> > > + */
> > > + for (reg = UDA1380_MVOL; reg < UDA1380_CACHEREGNUM;
> > > + reg++)
> > > + set_bit(reg - 0x10, &uda1380_cache_dirty);
> > > + }
> > >
> > > }
> > > codec->bias_level = level;
> > > return 0;
> > >
> > > @@ -651,16 +712,6 @@ static int uda1380_suspend(struct snd_soc_codec
> > > *codec, pm_message_t state)
> > >
> > > static int uda1380_resume(struct snd_soc_codec *codec)
> > > {
> > >
> > > - int i;
> > > - u8 data[2];
> > > - u16 *cache = codec->reg_cache;
> > > -
> > > - /* Sync reg_cache with the hardware */
> > > - for (i = 0; i < ARRAY_SIZE(uda1380_reg); i++) {
> > > - data[0] = (i << 1) | ((cache[i] >> 8) & 0x0001);
> > > - data[1] = cache[i] & 0x00ff;
> > > - codec->hw_write(codec->control_data, data, 2);
> > > - }
> > >
> > > uda1380_set_bias_level(codec, SND_SOC_BIAS_STANDBY);
> > > return 0;
> > >
> > > }
> > >
> > > @@ -671,29 +722,32 @@ static int uda1380_probe(struct snd_soc_codec
> > > *codec)
> > >
> > > struct uda1380_priv *uda1380 = snd_soc_codec_get_drvdata(codec);
> > > int ret;
> > >
> > > + uda1380->codec = codec;
> > > +
> > >
> > > codec->hw_write = (hw_write_t)i2c_master_send;
> > >
> > > + codec->control_data = uda1380->control_data;
> > >
> > > - if (!pdata || !pdata->gpio_power || !pdata->gpio_reset)
> > > + if (!pdata)
> > >
> > > return -EINVAL;
> > >
> > > - ret = gpio_request(pdata->gpio_power, "uda1380 power");
> > > - if (ret)
> > > - return ret;
> > > - ret = gpio_request(pdata->gpio_reset, "uda1380 reset");
> > > - if (ret)
> > > - goto err_gpio;
> > > -
> > > - gpio_direction_output(pdata->gpio_power, 1);
> > > -
> > > - /* we may need to have the clock running here - pH5 */
> > > - gpio_direction_output(pdata->gpio_reset, 1);
> > > - udelay(5);
> > > - gpio_set_value(pdata->gpio_reset, 0);
> >
> > if (gpio_is_valid(...gpio...)) {
> >
> > }
>
> Will not work for s3c24xx:
>
> static inline int gpio_is_valid(int number)
> {
> /* only some non-negative numbers are valid */
> return ((unsigned)number) < ARCH_NR_GPIOS;
> }
>
Why won't it work? You have some negative values of GPIO pins there?
> > > + if (pdata->gpio_reset != -EINVAL) {
> > > + ret = gpio_request(pdata->gpio_reset, "uda1380 reset");
> > > + if (ret)
> > > + goto err_out;
> > > + gpio_direction_output(pdata->gpio_reset, 0);
> >
> > Handle return value and dont depend on this setting the GPIO value, use
> > gpio_set_value() too please.
>
> This code handles reset-less machines (for example, h1940).
> gpio_direction_output is neccessary here to ensure that pin is in output
> mode.
>
ret = gpio_direction_output(pdata->gpio_reset, 0);
if (ret) {
dev_err();
goto err;
}
gpio_set_value();
...
err:
gpio_free();
Stuff like this.
> > > + }
> > >
> > > - ret = uda1380_reset(codec);
> > > - if (ret < 0) {
> > > - dev_err(codec->dev, "Failed to issue reset\n");
> > > - goto err_reset;
> > > + if (pdata->gpio_power != -EINVAL) {
> > > + ret = gpio_request(pdata->gpio_power, "uda1380 power");
> > > + if (ret)
> > > + goto err_gpio;
> > > + gpio_direction_output(pdata->gpio_power, 0);
HERE, see below.
> > > + } else {
> > > + ret = uda1380_reset(codec);
> > > + if (ret) {
> > > + dev_err(codec->dev, "Failed to issue reset\n");
> > > + goto err_reset;
> > > + }
> > >
> > > }
> >
> > Ditto.
>
> Handling here machine which lacks power pin.
This should have been ... scroll to my previous comment starting with HERE.
>
> > > + uda1380->control_data = i2c;
> >
> > So is this needed ? Can't you access codec->control_data ?
>
> See comment above.
See comment above. :)
>
> > > kfree(uda1380);
> > >
> > > +
> >
> > Remove
>
> It improves formatting.
See comment above. :)
>
> > > return ret;
> > >
> > > }
> >
> > Cheers
>
> thanks,
>
> Regards
> Vasily
Cheers
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next prev parent reply other threads:[~2010-08-29 19:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-29 17:11 [PATCH v4 0/3] ASoC: Add iPAQ RX1950 support Vasily Khoruzhick
2010-08-29 17:11 ` [PATCH v4 1/3] ASoC: uda1380: make driver more powersave-friendly Vasily Khoruzhick
2010-08-29 17:37 ` Marek Vasut
2010-08-29 18:13 ` Vasily Khoruzhick
2010-08-29 19:11 ` Marek Vasut [this message]
2010-08-29 18:50 ` [PATCH v5 " Vasily Khoruzhick
2010-08-29 19:33 ` [PATCH v6 " Vasily Khoruzhick
2010-08-29 17:11 ` [PATCH v4 2/3] ASoC: Add HP iPAQ RX1950 support Vasily Khoruzhick
2010-08-29 17:39 ` Marek Vasut
2010-08-29 18:15 ` Vasily Khoruzhick
2010-08-29 18:53 ` [PATCH v5 " Vasily Khoruzhick
2010-08-29 19:16 ` Marek Vasut
2010-08-29 17:11 ` [PATCH v4 3/3] ARM: S3C24XX: I2S multi-component-related fixes Vasily Khoruzhick
2010-08-29 17:41 ` Marek Vasut
2010-08-29 17:47 ` Vasily Khoruzhick
2010-08-29 19:12 ` Marek Vasut
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201008292111.51406.marek.vasut@gmail.com \
--to=marek.vasut@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=anarsoul@gmail.com \
--cc=ben-linux@fluff.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=lrg@slimlogic.co.uk \
--cc=philipp.zabel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).