linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2] Another approach to IR
@ 2009-12-01 15:08 Jon Smirl
  2009-12-01 15:47 ` Maxim Levitsky
  0 siblings, 1 reply; 72+ messages in thread
From: Jon Smirl @ 2009-12-01 15:08 UTC (permalink / raw)
  To: awalls, dmitry.torokhov, j, jarod, jarod, khc, linux-input,
	linux-kernel, linux-media, lirc-list, mchehab, superm1,
	Christoph Bartelmus

While reading all of these IR threads another way of handling IR
occurred to me that pretty much eliminates the need for LIRC and
configuration files in default cases. The best way to make everything
"just work" is to eliminate it.

The first observation is that the IR profile of various devices are
well known. Most devices profiles are in the published One-for-All
database. These device profiles consist of vendor/device/command
triplets. There is one triplet for each command like play, pause, 1,
2, 3, power, etc.

The second observation is that universal remotes know how to generate
commands for all of the common devices.

Let's define evdev messages for IR than contain vendor/device/command
triplets. I already posted code for doing that in my original patch
set. These messages are generated from in-kernel code.

Now add a small amount of code to MythTV, etc to act on these evdev
messages. Default MythTV, etc to respond to the IR commands for a
common DVR device. Program your universal remote to send the commands
for this device. You're done. Everything will "just work" - no LIRC,
no irrecord, no config files, no command mapping, etc.

Of course there are details involved in making this work. MythTV will
have to have a config option to allow it to emulate several different
DVR devices so that you can pick one that you don't own. It should
also have choices for emulating the common devices defined for the
remotes included with various Linux video board like the Hauppauge
remote.

For apps that haven't been modified you will have to run a daemon
which will capture vendor/device/command evdev events and convert them
into keystroke commands than work the menus. You'll need a config file
for this and have to write scripts. Instead I'd just go modify the app
the respond to the IR events, it is easy to do.

Long run, we define a MythTV IR profile, mplayer profile, etc and get
these into the IR database for universal remotes. Now MythTV can stop
emulating another vendor's device.

For the default MythTV case no external support will need to be
installed if the protocol decode engines are in the kernel. The raw
data will come in, run through the engines, and pop out as evdev
messages with a vendor/device/command triplet. Devices that decode in
hardware will just send vendor/device/command triplets.

-- 
Jon Smirl
jonsmirl@gmail.com

^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: [RFC v2] Another approach to IR
@ 2009-12-03 17:08 Emmanuel Fusté
  0 siblings, 0 replies; 72+ messages in thread
From: Emmanuel Fusté @ 2009-12-03 17:08 UTC (permalink / raw)
  To: mchehab, linux-kernel, linux-media

> Jon Smirl wrote:
> > On Wed, Dec 2, 2009 at 11:13 PM, Jarod Wilson <jarod@wilsonet.com> wrote:
> >> On Dec 2, 2009, at 9:48 PM, Trent Piepho wrote:
> >> ...
> >>>>>> Now I understand that if 2 remotes send completely identical signals we
> >>>>>> won't be able to separate them, but in cases when we can I think we
> >>>>>> should.
> >>>>> I don't have a problem with that, if its a truly desired feature.  But
> >>>>> for the most part, I don't see the point.  Generally, you go from
> >>>>> having multiple remotes, one per device (where "device" is your TV,
> >>>>> amplifier, set top box, htpc, etc), to having a single universal remote
> >>>>> that controls all of those devices.  But for each device (IR receiver),
> >>>>> *one* IR command set.  The desire to use multiple distinct remotes with
> >>>>> a single IR receiver doesn't make sense to me.  Perhaps I'm just not
> >>>>> creative enough in my use of IR.  :)
> >>> Most universal remotes I'm familiar with emulate multiple remotes.  I.e.
> >>> my tv remote generates one set of scancodes for the numeric keys.  The DVD
> >>> remote generates a different set.  The amplifier remote in "tv mode"
> >>> generates the same codes as the tv remote, and in "dvd mode" the same codes
> >>> as the dvd remote.  From the perspective of the IR receiver there is no
> >>> difference between having both the DVD and TV remotes, or using the
> >>> aplifier remote to control both devices.
> >> Okay, in the above scenario, you've still got a single input device...
> >>
> >>> Now, my aplifier remote has a number of modes.  Some control devices I
> >>> have, like "vcr mode", and there is nothing I can do about that.  Some,
> >>> like "md mode" don't control devices I have.  That means they are free to
> >>> do things on the computer.  Someone else with the same remote (or any
> >>> number of remotes that use the same protocol and scancodes) might have
> >>> different devices.
> >>>
> >>> So I want my computer to do stuff when I push "JVC MD #xx" keys, but ignore
> >>> "JVC VCR #yyy" yets.  Someone with an MD player and not a VCR would want to
> >>> opposite.  Rather than force everyone to create custom keymaps, it's much
> >>> easier if we can use the standard keymaps from a database of common remotes
> >>> and simply tell mythtv to only use remote #xxx or not to use remote #yyy.
> >> Sure, but the key is that this can't be done automagically. The IR driver has no way of knowing that user A wants JVC MD keys handled and JVC VCR keys ignored, and user B wants vice versa, while user C wants both ignored, etc. This is somewhat tangential to whether or not there's a separate input device per "remote" though. You can use multiple remotes/protocols with a single input device or lirc device already (if the hardware doesn't have to be put explicitly into a mode to listen for that proto, of course, but then its a hardware decoding device feeding a single input device anyway, so...).
> >>
> >>> It sounds like you're thinking of a receiver that came bundled with a
> >>> remote and that's it.  Not someone with a number of remotes that came with
> >>> different pieces of AV gear that they want to use with their computer.
> >> No, I just pick *one* remote and use it for everything, not schizophrenically hopping from one remote to another, expecting them all the be able to control everything. :) Its a hell of a lot easier to find buttons w/o looking at the remote if you always use the same one for everything, for one.
> >>
> >> Anyway, I think I'm talking myself in circles. Supporting multiple remotes via multiple input devices (or even via a single input device) isn't at all interesting to me for my own use, but if there really is demand for such support (and it appears there is), then fine, lets do it.
> > 
> > Simple use case:
> > 
> > You have a multifunction remote. Press the CABLE key - it sends out
> > commands that control the cable box, press the TV key - now the
> > commands control the TV, press CD - now the CD player, etc.
> > 
> > Now imagine a headless Linux box running a music server and a home
> > automation app. Press the CD key - commands get routed to the music
> > server, press the AUX key - commands get routed to the home automation
> > app.
> > 
> > This is accomplished by recognizing the device code part of the IR
> > signal and figuring out that there are two different device codes in
> > use. The commands of then routed to two evdev devices corresponding to
> > the two different device codes.
> > 
> > Using things like Alt-Tab to switch apps is impossible. There's no
> > screen to look at.
>
> This usecase makes sense to me.
>
> With the risk of repeating myself, you don't have two physical remotes.
> The needed feature is a way to split one source of input events (that
> happens to be an infrared remote, but it could also be any other type of input
> device, like a bluetooth remote) into several different evdev interfaces,
> based on scancode groups. 
>
In real world you generally have two physical remote. In this particular case you simply have a sort of semi-universal remote, a two or tree in one remote.
More particularly, you have a remote which is aimed at talking to two or tree different "real" devices or in our case different applications. If the application is a multifunction one it should be seen as multiple application.
Don't mix IR encoding informations and applications : I don't care if each button of my mono-function remote use a different IR protocol that what the mapping table is for. One simple remote is a group of button, each button is the result of an IR transmission decoded in an internal IR stack representation.
Don't mix IR encoding informations and remote representation : that not because a protocol have a concept of vendor/device/command or sort of that we should do automatic grouping by vendor/device/command. These protocol/vendor/device/command informations should only be reported as "raw" data to simplify the life of the application responsible to create the mapping tableS.
We should have one evdev device per mapping table. Each table has a label.
For one simple "mono" function remote, I create one table labeled "simplexyz" or better, I told to my IR config app that I have the remote model "simplexyz" and the good mapping is fetched from the database an injected is the "simplexyz" mapping table, effectively creating the "simplexyz" device. In my cd player app, in the "remote config menu", I chose "simplexyz" device as the used remote.
For my "tree in one" remote model yamahaxyz , my config app fetch and create tree mapping: yamahaxyz-vcr, yamahaxyz-cd, yamahaxyz-tv, creating tree device. In cdplayer application, I add yamahaxyz-cd as a remote, in mythtv, I add yamahaxyz-tv for the TV part and yamahaxyz-vcr for the recording part. Multifunction application should provide a way to use a different device for each "standard as in real world" base function.
In this example, I could assign the same remote yamahaxyz-vcr for tv and vcr part of Mythtv (because vrc generally include a tv tuner and all the button to use it in the vcr ir group) to control the two functions of Mythtv.
In all application, I use standard evdev keycodes, augmented with some new added because of this new kind of input device.
Each IR aware application simply use one or more device for each different base profile function.
(1)You could even think of an application which use one of your remote (mapping table) to re-inject standard keyboad events to control your other applications with key shortcuts. Don't forget to map alt-tab ;-)
With this scheme, we stay in the pure evdev world for more than 90% of the time, even to load mappings/create devices. The only IR-internals aware application is the one to create/modify mappings, a remote editor.

Universal remote are emulating a bunch of simple or multifunction remote and are not a natural beast, users take time to set them up. As such they could be views from your application as a collections of standard remote or one or more purely user defined ones. For this later case, I expect to have a great graphical remote mapping editor with auto learn features. 

This is the most flexible and simple scheme. I could not think of a case it could not handle and it achieve a clean layering between the IR events and the applications.
For the other layers, we have the IR receiver device part, and the decoding part. The device part is an in kernel device driver problem. Even for dumb serial and pp devices for which we should have a line discipline and a parport client driver to archive good acquisition timing and low cpu/power usage (no userspace busywait loop).
Device with hardware decoding and or no raw capability feed directly the input subsystem to be dispatched to the different evdev devices.
lircd could still be used for his scripting part as seen in (1)
For the raw receivers, we could have in kernel decoders and/or lircd in user space. It is just the mater of feeding a sort of lirc device instead of the in kernel decoder. But please, raw ir data in the form of pulse event has nothing to do with the input and event layer.

Splitting one source of input events into several different evdev interfaces is a very simple thing at the input subsystem layer. And as explain, this splitting should never never never be based on protocol/vendor/device/command scancode groups but only based on mapping table.

My two cents, 


Cheers,
Emmanuel.


^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: [RFC v2] Another approach to IR
@ 2009-12-03 17:56 Emmanuel Fusté
  0 siblings, 0 replies; 72+ messages in thread
From: Emmanuel Fusté @ 2009-12-03 17:56 UTC (permalink / raw)
  To: mchehab, linux-kernel, linux-media

>
> Em Thu, 3 Dec 2009 11:50:04 -0500
> Jon Smirl <jonsmirl@gmail.com> escreveu:
>
> > On Thu, Dec 3, 2009 at 11:33 AM, Mauro Carvalho Chehab
> > <mchehab@redhat.com> wrote:
> > > Ferenc Wagner wrote:
> > >> Mauro Carvalho Chehab <mchehab@redhat.com> writes:
> > >>
> > >>> Dmitry Torokhov wrote:
> > >>>
> > >
> > >> The interesting thing is that input.h defines KEY_TV, KEY_PC, KEY_SAT,
> > >> KEY_CD, KEY_TAPE etc., but no corresponding scan codes will ever be sent
> > >> by any remote (ok, I'm stretching it a bit).
> > >
> > > Unfortunately, this is not true. Some IR's do send a keycode for TV/PC/SAT/CD, etc.
> > >
> > > On those remotes, if you press TV and then press for example Channel UP
> > > and press Radio, then press Channel UP, the channel UP code will be the same.
> > >
> > > For example, on Hauppauge Grey IR, we have:
> > >
> > > <TV>
> > > [13425.128525] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e1c keycode 0x179
> > > [13425.136733] ir_input_key_event: em28xx IR (em28xx #0): key event code=377 down=1
> > > [13425.144170] ir_input_key_event: em28xx IR (em28xx #0): key event code=377 down=0
> > >
> > > <CHANNEL UP>
> > > [13428.350223] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e20 keycode 0x192
> > > [13428.358434] ir_input_key_event: em28xx IR (em28xx #0): key event code=402 down=1
> > > [13428.365871] ir_input_key_event: em28xx IR (em28xx #0): key event code=402 down=0
> > >
> > > <Radio>
> > > [13430.672266] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e0c keycode 0x181
> > > [13430.680473] ir_input_key_event: em28xx IR (em28xx #0): key event code=385 down=1
> > > [13430.687913] ir_input_key_event: em28xx IR (em28xx #0): key event code=385 down=0
> > >
> > > <CHANNEL UP>
> > > [13433.697268] ir_g_keycode_from_table: em28xx IR (em28xx #0): scancode 0x1e20 keycode 0x192
> > > [13433.705480] ir_input_key_event: em28xx IR (em28xx #0): key event code=402 down=1
> > > [13433.712916] ir_input_key_event: em28xx IR (em28xx #0): key event code=402 down=0
> > >
> > > In this IR, the address is bogus: it is always 0x1e. This scenario is very common with the
> > > shipped IR's.
> > 
> > The remote is treating everything as a single integrated device which
> > is not inconsistent with what has been said. In this case there really
> > is only one multi-function device not two independent ones.
> > 
> > If you want to control two independent devices you need to buy a
> > different remote. Remotes are cheap so that's not a big deal.
> > 
> > If you really want to use this remote to control two independent
> > devices you need user space scripting to split the single device into
> > two devices and then inject new events into the input layer. This is a
> > complex case and not in the goal of getting 90% of users to "just
> > work".
>
> This remote is a typical example of the IR's that are provided together with media boards.
> On all such IR's I know, it does generate one key event for TV, SAT, DVB, DVD... keys and
> this event doesn't change the status of subsequent keys.
>
> 100% of the users of such boards will have the shipped IR. Some amount will be happy of
> just using the provided IR to control different applications at their computer or embedded
> hardware, and some amount will prefer to buy a multi-purpose IR that will allow him
> to control not only his computer, but also, his TV, his Air conditioning, etc.
>
> Both usages should be supported.
>
> All I'm saying is that, in the case where people have only the shipped IR, if he wants to
> see TV, the produced keycode will be KEY_TV, and then to change a channel, it will
> receive KEY_CHANNELUP, to control his TV app. When the user decides to switch to DVB, 
> he will press KEY_DVB and then KEY_PLAY to play his movie.
>
> So, an application like MythTV should be able to work with those keys.
>   
Eeeerrrkkk, what a ...... device .
For such quirky device, we could imagine a special mapping support:
We could maps scancode 0x1e1c and 0x1e0c special keycode wich inform the 
input layer to surcharge the  vendor or device with a specific 
value/mask for following  keypresses of such remote. The mask could be 
choose to generate out of bound value in regards of the used protocol 
for the vendor or the device part to not overlap with another existing 
remote.
Generate a complete map and so a device for each special key and you're 
done. No special case on the application side.
In kernel states are a bit ugly, but this particular case is not too 
complicated and your dumb shitty remote is promoted to first class one.


Regards,
Emmanuel.



^ permalink raw reply	[flat|nested] 72+ messages in thread
* Re: [RFC v2] Another approach to IR
@ 2009-12-03 18:01 Emmanuel Fusté
  0 siblings, 0 replies; 72+ messages in thread
From: Emmanuel Fusté @ 2009-12-03 18:01 UTC (permalink / raw)
  To: linux-kernel, linux-media

>
> On Thu, Dec 03, 2009 at 02:33:56PM -0200, Mauro Carvalho Chehab wrote:
> > Ferenc Wagner wrote:
> > > Mauro Carvalho Chehab <mchehab@redhat.com> writes:
> > 
> > We should not forget that simple IR's don't have any key to select the address,
> > so the produced codes there will never have KEY_TV/KEY_DVD, etc.
>
> Wait, wait, KEY_TV, KEY_DVD, KEY_TAPE - they should be used to select
> media inputs in a device/application. My receiver accepts codees like
> that.
>   
Yes, it seem that there is confusion here.
Forget my proposition. It is a corner case that could be handled later 
if needed.


Cheers,
Emmanuel.

^ permalink raw reply	[flat|nested] 72+ messages in thread

end of thread, other threads:[~2009-12-04 16:11 UTC | newest]

Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-01 15:08 [RFC v2] Another approach to IR Jon Smirl
2009-12-01 15:47 ` Maxim Levitsky
2009-12-01 16:16   ` Jon Smirl
2009-12-01 17:03     ` Mauro Carvalho Chehab
2009-12-01 17:09       ` Devin Heitmueller
2009-12-01 17:29         ` Mauro Carvalho Chehab
2009-12-01 17:54           ` Dmitry Torokhov
2009-12-01 19:00             ` Mauro Carvalho Chehab
2009-12-01 19:27               ` Jon Smirl
2009-12-01 20:11               ` Dmitry Torokhov
2009-12-01 21:05                 ` Mauro Carvalho Chehab
2009-12-02  9:38                   ` Dmitry Torokhov
2009-12-02 12:44                     ` Mauro Carvalho Chehab
2009-12-02 17:10                       ` Dmitry Torokhov
2009-12-02 17:30                         ` Jon Smirl
2009-12-02 18:23                           ` Dmitry Torokhov
2009-12-02 18:57                             ` Jon Smirl
2009-12-02 20:54                               ` Mauro Carvalho Chehab
2009-12-02 19:22                           ` Jarod Wilson
2009-12-02 19:56                             ` Dmitry Torokhov
2009-12-02 20:04                               ` Jarod Wilson
2009-12-02 20:14                                 ` Dmitry Torokhov
2009-12-02 20:23                                   ` Mauro Carvalho Chehab
2009-12-02 20:53                                     ` Dmitry Torokhov
2009-12-02 21:13                                       ` Mauro Carvalho Chehab
2009-12-03 16:03                                         ` Ferenc Wagner
2009-12-03 16:33                                           ` Mauro Carvalho Chehab
2009-12-03 16:50                                             ` Jon Smirl
2009-12-03 17:19                                               ` Mauro Carvalho Chehab
2009-12-03 17:31                                             ` Dmitry Torokhov
2009-12-04 16:11                                               ` Ferenc Wagner
2009-12-02 20:42                                   ` Jarod Wilson
2009-12-02 20:48                                     ` Dmitry Torokhov
2009-12-02 20:57                                       ` Jarod Wilson
2009-12-02 21:12                                         ` Trent Piepho
2009-12-02 21:28                                           ` Jarod Wilson
2009-12-02 21:40                                             ` Mauro Carvalho Chehab
2009-12-03 18:06                                             ` Krzysztof Halasa
2009-12-03  1:19                                   ` Andy Walls
2009-12-03  2:27                                     ` hermann pitton
2009-12-03  0:20                                 ` Jon Smirl
2009-12-03  2:22                                   ` Mauro Carvalho Chehab
2009-12-03  5:08                                     ` Jon Smirl
2009-12-03 11:09                                       ` Mauro Carvalho Chehab
2009-12-03 18:18                                         ` Krzysztof Halasa
2009-12-03 20:54                                           ` Mauro Carvalho Chehab
2009-12-03  2:48                                   ` Trent Piepho
2009-12-03  4:13                                     ` Jarod Wilson
2009-12-03  5:18                                       ` Jon Smirl
2009-12-03 11:20                                         ` Mauro Carvalho Chehab
2009-12-03 19:48                                   ` alhaz
2009-12-02 19:33                         ` Mauro Carvalho Chehab
2009-12-02 19:50                           ` Jon Smirl
2009-12-02 19:58                             ` Jon Smirl
2009-12-02 20:47                             ` Mauro Carvalho Chehab
2009-12-02 19:55                           ` Jarod Wilson
2009-12-03  1:02                             ` Andy Walls
2009-12-03 10:00                               ` Mauro Carvalho Chehab
2009-12-03 12:02                                 ` Andy Walls
2009-12-03 11:09                               ` Mauro Carvalho Chehab
2009-12-02 20:01                           ` Dmitry Torokhov
2009-12-02 15:37                     ` Jon Smirl
2009-12-02 17:00                       ` Dmitry Torokhov
2009-12-02 11:26                   ` Gerd Hoffmann
2009-12-02 12:45                     ` Mauro Carvalho Chehab
2009-12-01 17:35         ` Patrick Boettcher
2009-12-01 17:41           ` Mauro Carvalho Chehab
2009-12-01 18:19       ` Jon Smirl
2009-12-01 17:37   ` Mauro Carvalho Chehab
  -- strict thread matches above, loose matches on Subject: below --
2009-12-03 17:08 Emmanuel Fusté
2009-12-03 17:56 Emmanuel Fusté
2009-12-03 18:01 Emmanuel Fusté

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).