linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Brown <broonie@opensource.wolfsonmicro.com>
To: NeilBrown <neilb@suse.de>
Cc: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	"MyungJoo Ham" <myungjoo.ham@gmail.com>,
	linux-kernel@vger.kernel.org,
	"Linus Walleij" <linus.walleij@linaro.org>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Mike Lockwood" <lockwood@android.com>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Kyungmin Park" <kyungmin.park@samsung.com>,
	"Donggeun Kim" <dg77.kim@samsung.com>, "Greg KH" <gregkh@suse.de>,
	"Grant Likely" <grant.likely@secretlab.ca>,
	"Kalle Komierowski" <karl.komierowski@stericsson.com>,
	"Johan PALSSON" <johan.palsson@stericsson.com>,
	"Daniel WILLERUD" <daniel.willerud@stericsson.com>
Subject: Re: [RFC PATCH 0/3] introduce: Multistate Switch Class
Date: Thu, 1 Dec 2011 11:34:50 +0000	[thread overview]
Message-ID: <20111201113449.GD2915@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <20111201162144.187ecca3@notabene.brown>

On Thu, Dec 01, 2011 at 04:21:44PM +1100, NeilBrown wrote:
> On Wed, 30 Nov 2011 15:25:29 -0800 Dmitry Torokhov

> > Physical jack does not have to map 1:1 on logical jack. So 1 physical
> > docking connector can be represented by 1 logical video connector, line
> > in, line out, microphone and maybe else.

> That is just what I was thinking :-)

> It seems that a "connector" could be modelled as a set of binary switches,
> one for each service that is exported (or imported? ... "communicated" maybe)
> through the connector.  When a cable (or dock) is plugged in, some number of
> these switches are all switched on concurrently.  When it is unplugged they
> are all switched off.

> How strongly do we need this understanding of a "group" to be?

It's useful to userspace to know that the grouping is there, and it's
also useful to be able to say that the overall object that was inserted
into the connector is whatever.  That could be done by grouping a bunch
of other objects together.

> Mark says:

> > We also need some way to group things together so that we can understand
> > that we've got a single connector that can detect multiple things (eg,
> > understanding that a cable hsa audio and video capability).

> It isn't immediately obvious why this is the case.  There is no guarantee
> that I want to route audio and video in the same direction.  The best you can
> probably get is a heuristic that both should be routed to the most recently
> available destination.
> But again, maybe I'm missing something important.   I guess the helpful piece
> of information is: How exactly would this knowledge of grouping be used?

Being able to provide useful default behaviour is an important win in
itself, and in many embedded cases the end user has no access to this
sort of policy anyway (consider smartphones and tablets).  You can
probably do much better than you suggest above - for example, if the
device connected is an AV cable then it's more likely that you want to
treat it as a block to be routed together than if the device connected
is a docking station.  You might also choose to do things like
remembering the configurations used with particular cables and restoring
them when reconnected - for example, distinguishing between a car dock
and a desktop docking station.

> One case I am thinking of is the twl4030 driver (a multi-function device for
> power, usb, audio, battery charge etc).
> The battery charger needs to know when the usb device gets a cable plugged in
> so that it can start charging.
> It currently creates a link essentially by using a global variable.

This is the sort of device that MyungJoo is taking about in a lot of his
examples.

> Using a 'switch', the twl-core module could allocate a switch and pass it to
> the usb module for sending notification and to the bci module for receiving
> them.  Whether it passes down a number which is later turned into a pointer,
> or whether it sends down the raw pointer, is just an implementation detail.

We really want something a bit more involved in the USB frameworks for
the specific example of USB stuff (which is being worked on) - ideally
we should be communicating information about how much current the host
allows to be drawn throughout the system.

> Can the same be done for these cable ports that you have in mind?  Presumably
> the common-parent could allocate several switches - maybe even an array of
> switches - and pass the collection of switches to the port, and then pass
> individual switches to individual component drivers.

I *think* so.

> If the switch needs to be exported to user-space then someone needs to
> provide a name for it.  I suspect the common-parent would be the obvious
> choice, or the board file.

Common parents often don't exist - it's not unusual for multiple devices
to be involved in the detection of accessories.  Assuming a straight
tree structure is very dangerous in the embedded context.  Board
assigned naming does seem reasonable to me, though.

> Just to be clear, the functionality that I see a 'switch' supporting is:

> For the owner:
>   - int switch_allocate(void)
>   - void switch_export(int switchnum, char *name)
>      This creates a device which appears in sysfs and has a 'state'
>      attribute which responds to 'poll' requests so a process can find
>      out about changes.

> For the notifier:
>   - void switch_set_state(int switchnum, bool value)
>           This sets the state and notifies all notifiees (listeners).

I think we do want something which lets us say "this is a cable of
type X" so that we can report the difference between otherwise identical
cables as in the car/desktop dock example I mentioned above.

  reply	other threads:[~2011-12-01 11:34 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-24  2:03 [RFC PATCH 0/3] introduce: Multistate Switch Class MyungJoo Ham
2011-11-25 14:02 ` Arnd Bergmann
2011-11-26  5:46   ` MyungJoo Ham
2011-11-26 13:23   ` Kyungmin Park
2011-11-27 22:43   ` Linus Walleij
2011-11-27 23:08     ` Greg KH
2011-11-28  0:09       ` Dmitry Torokhov
2011-11-28  0:19         ` Greg KH
2011-11-28  9:03           ` Dmitry Torokhov
2011-11-28  1:31       ` NeilBrown
2011-11-28  7:27         ` Greg KH
2011-11-28  9:04           ` Dmitry Torokhov
2011-11-30  6:35             ` Greg KH
2011-11-30  6:58               ` MyungJoo Ham
2011-11-30  9:46                 ` Mark Brown
2011-11-30 13:28               ` Linus Walleij
2011-11-30 23:04                 ` NeilBrown
2011-12-01 13:38                   ` Linus Walleij
2011-11-28 13:04           ` Linus Walleij
2011-11-28 15:09             ` Morten CHRISTIANSEN
2011-11-30  6:34               ` Greg KH
2011-11-28 17:53     ` Arnd Bergmann
2011-11-29  9:11       ` MyungJoo Ham
2011-11-29  9:45         ` Linus Walleij
2011-11-29 13:59         ` Arnd Bergmann
2011-11-29 17:05           ` Dmitry Torokhov
2011-11-30  2:58         ` NeilBrown
2011-11-30  6:40           ` MyungJoo Ham
2011-11-30 22:56             ` NeilBrown
2011-11-30 23:17               ` Mark Brown
2011-11-30 23:25                 ` Dmitry Torokhov
2011-12-01  4:51                   ` MyungJoo Ham
2011-12-01  5:21                   ` NeilBrown
2011-12-01 11:34                     ` Mark Brown [this message]
2011-12-05  3:04                       ` NeilBrown
2011-12-05 12:06                         ` Mark Brown
2011-12-05 19:38                           ` NeilBrown
2011-12-05 19:45                             ` Mark Brown
2011-12-01  4:46               ` MyungJoo Ham
2011-12-07  9:31       ` Linus Walleij
2011-12-08  4:42         ` Kyungmin Park
2011-11-26 15:32 ` Greg KH
2011-11-29  8:18   ` MyungJoo Ham
2011-11-28 18:23 ` Mark Brown

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=20111201113449.GD2915@opensource.wolfsonmicro.com \
    --to=broonie@opensource.wolfsonmicro.com \
    --cc=arnd@arndb.de \
    --cc=arve@android.com \
    --cc=daniel.willerud@stericsson.com \
    --cc=dg77.kim@samsung.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=gregkh@suse.de \
    --cc=johan.palsson@stericsson.com \
    --cc=karl.komierowski@stericsson.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lockwood@android.com \
    --cc=myungjoo.ham@gmail.com \
    --cc=neilb@suse.de \
    /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).