public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: "Péter Ujfalusi" <peter.ujfalusi@ti.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Girdwood, Liam" <lrg@ti.com>, Tony Lindgren <tony@atomide.com>,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Samuel Ortiz <sameo@linux.intel.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	"Lopez Cruz, Misael" <misael.lopez@ti.com>,
	Jorge Eduardo Candelaria <jorge.candelaria@ti.com>
Subject: Re: Re: [PATCH v4 11/18] input: Add initial support for TWL6040 vibrator
Date: Mon, 13 Jun 2011 12:51:16 +0300	[thread overview]
Message-ID: <1530216.k8lJ4nKZ1s@barack> (raw)
In-Reply-To: <20110611231854.GA3979@core.coreip.homeip.net>

On Sunday 12 June 2011 01:18:54 Dmitry Torokhov wrote:
> > +static void twl6040_vibra_enable(struct vibra_info *info)
> > +{
> > +     struct twl6040 *twl6040 = info->twl6040;
> > +     int ret = 0;
> 
> Initialization is not needed.

True.

> > +static void vibra_play_work(struct work_struct *work)
> > +{
> > +     struct vibra_info *info = container_of(work,
> > +                             struct vibra_info, play_work);
> > +
> > +     mutex_lock(&info->mutex);
> > +
> > +     if (info->weak_speed || info->strong_speed) {
> > +             if (!info->enabled)
> > +                     twl6040_vibra_enable(info);
> > +
> > +             twl6040_vibra_set_effect(info);
> > +     } else if (info->enabled)
> > +             twl6040_vibra_disable(info);
> 
> Why do we play with enabling/disabling the device here? Nobody can
> request playing of an effect unless the device has been opened so if we
> manage power state in open/close methods we should not be doing it here
> I think.

We want to preserve as much power as we can.
So if application opens the driver, but it is not requesting to play any 
effect we still keep the device turned off.
When application request for stopping the effect without closing the device, 
we turn off things in a similar way.
The twl4030-vibra driver has been implemented in this way as well.

> > +
> > +     mutex_unlock(&info->mutex);
> > +}

...

> > +static int twl6040_vibra_open(struct input_dev *input)
> > +{
> > +     struct vibra_info *info = input_get_drvdata(input);
> > +
> > +     info->workqueue = create_singlethread_workqueue("vibra");
> > +     if (info->workqueue == NULL) {
> > +             dev_err(&input->dev, "couldn't create workqueue\n");
> > +             return -ENOMEM;
> > +     }
> 
> Why do we need to create a separate workqueue? With arrival of CWQ
> it looks like we should be able to use one of the system-wide
> workqueues for this.

The reason for this is to ensure that we have the lowest latency as possible 
in most case. In the embedded devices we use the vibra for tactile type of 
feedbacks as well, where few tens of ms delay can be felt.

> > +
> > +     return 0;
> > +}
> > +
> > +static void twl6040_vibra_close(struct input_dev *input)
> > +{
> > +     struct vibra_info *info = input_get_drvdata(input);
> > +
> > +     cancel_work_sync(&info->play_work);
> > +     INIT_WORK(&info->play_work, vibra_play_work);
> > +     destroy_workqueue(info->workqueue);
> > +     info->workqueue = NULL;
> > +
> > +     mutex_lock(&info->mutex);
> > +
> > +     if (info->enabled)
> > +             twl6040_vibra_disable(info);
> > +
> > +     mutex_unlock(&info->mutex);
> > +}
> > +
> > +#if CONFIG_PM
> 
> CONFIG_PM_SLEEP.

OK, will be fixed.

> > +static int twl6040_vibra_suspend(struct device *dev)
> > +{
> > +     struct platform_device *pdev = to_platform_device(dev);
> > +     struct vibra_info *info = platform_get_drvdata(pdev);
> > +
> > +     mutex_lock(&info->mutex);
> > +
> > +     if (info->enabled)
> > +             twl6040_vibra_disable(info);
> > +
> > +     mutex_unlock(&info->mutex);
> > +
> > +     return 0;
> > +}
> > +
> > +static SIMPLE_DEV_PM_OPS(twl6040_vibra_pm_ops,
> > +                      twl6040_vibra_suspend, NULL);
> 
> Move twl6040_vibra_pm_ops definition out of the #ifdef block so you
> won't need to protect it use with ifdefs later.

Thanks, I have change this.
 
> > +#endif

...

> > +static int __devexit twl6040_vibra_remove(struct platform_device *pdev)
> > +{
> > +     struct vibra_info *info = platform_get_drvdata(pdev);
> > +
> > +     twl6040_power(info->twl6040, 0);
> 
> If we ensure that device is powered off until open() is called, and
> also powered off when close() is called, then we do not need to switch
> off power here.

True, removed.

> Thanks.
> 
> --
> Dmitry

Thanks for the comments. I will update the series.

-- 
Péter
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2011-06-13  9:51 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-10 11:54 [PATCH v4 00/18] MFD/ASoC/Input: TWL4030/TWL60X0 changes Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 01/18] OMAP: New twl-common for common TWL configuration Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 02/18] OMAP4: Move common twl6030 configuration to twl-common Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 03/18] OMAP3: Move common twl " Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 04/18] OMAP3: Move common regulator " Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 05/18] MFD: twl4030-codec: Rename internals from codec to audio Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 06/18] MFD: twl4030-codec -> twl4030-audio: Rename the driver Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 07/18] MFD: twl4030-audio: Rename platform data Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 08/18] mfd: twl6040: Add initial support Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 09/18] ASoC: twl6040: Convert into TWL6040 MFD child Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 10/18] MFD: twl6040: Change platform data for soc codec driver Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 11/18] input: Add initial support for TWL6040 vibrator Peter Ujfalusi
2011-06-11 23:18   ` Dmitry Torokhov
2011-06-13  9:51     ` Péter Ujfalusi [this message]
2011-06-13 21:20       ` Dmitry Torokhov
2011-06-14  6:34         ` Tejun Heo
2011-06-14  7:17           ` Péter Ujfalusi
2011-06-14  7:31             ` Re: " Tejun Heo
2011-06-14  7:51               ` Péter Ujfalusi
2011-06-14  8:18                 ` Re: Re: " Tejun Heo
2011-06-14 10:22                   ` Péter Ujfalusi
2011-06-15  8:18                     ` Re: Re: Re: " Tejun Heo
2011-06-15  8:23                       ` Tejun Heo
2011-06-16 11:13                         ` Péter Ujfalusi
2011-06-16 12:02                           ` Re: Re: Re: Re: " Tejun Heo
2011-06-16 14:06                             ` Péter Ujfalusi
2011-06-17  9:39                               ` Péter Ujfalusi
2011-06-17  9:43                                 ` Re: [alsa-devel] " Tejun Heo
2011-06-17 10:59                                   ` Péter Ujfalusi
2011-06-18 14:57                                     ` Dmitry Torokhov
2011-06-18 15:36                                       ` Re: Re: [alsa-devel] " Tejun Heo
2011-06-10 11:54 ` [PATCH v4 12/18] OMAP4: SDP4430: Add twl6040 vibrator platform support Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 13/18] ASoC: twl6040: add all ABE DAIs Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 14/18] ASoC: twl6040: Support other sample rates in constraints Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 15/18] ASoC: twl6040: Remove pll and headset mode dependency Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 16/18] ASoC: twl6040: set default constraints Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 17/18] ASoC: twl6040: Configure ramp step based on platform Peter Ujfalusi
2011-06-10 11:54 ` [PATCH v4 18/18] OMAP4: SDP4430: Add twl6040 codec platform support Peter Ujfalusi
2011-06-17 10:06 ` [PATCH v4 00/18] MFD/ASoC/Input: TWL4030/TWL60X0 changes Péter Ujfalusi
2011-06-17  9:39   ` Mark Brown
2011-06-17 10:53     ` Péter Ujfalusi
2011-06-17  9:51       ` Mark Brown
2011-06-17 10:57         ` Péter Ujfalusi

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=1530216.k8lJ4nKZ1s@barack \
    --to=peter.ujfalusi@ti.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jorge.candelaria@ti.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lrg@ti.com \
    --cc=misael.lopez@ti.com \
    --cc=sameo@linux.intel.com \
    --cc=tony@atomide.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