Thanks to Andy Walls <awalls@md.metrocast.net> for pointing me his
code, that gave me some ideas to better implement it.
After some work with saa7134 bits, I found a way to catch both IRQ
edge pulses. By enabling it, the NEC decoder can now take both
pulse and spaces into account, making it more precise.
Instead of the old strategy of handling the events all at once,
this code implements a state machine. Due to that, it handles
individual pulse or space events, validating them against the
protocol, producing a much more reliable decoding.
With the new implementation, the protocol trailer bits are properly
handled, making possible for the repeat key to work.
Also, the code is now capable of handling both NEC and NEC extended
IR devices. With NEC, it produces a 16 bits code, while with NEC
extended, a 24 bits code is returned.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Converts drivers/media/dvb/ttpci/budget-ci.c to use ir-core rather than
rolling its own keydown timeout handler and reporting keys via
drivers/media/IR/ir-functions.c.
[mchehab@redhat.com: Drop the call to ir_input_init() as it is no longer needed]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Rewrites the keyup/keydown logic in drivers/media/IR/ir-keytable.c.
All knowledge of keystates etc is now internal to ir-keytable.c
and not scattered around ir-raw-event.c and ir-nec-decoder.c (where
it doesn't belong).
In addition, I've changed the API slightly so that ir_input_dev is
passed as the first argument rather than input_dev. If we're ever
going to support multiple keytables we need to move towards making
ir_input_dev the main interface from a driver POV and obscure away
the input_dev as an implementational detail in ir-core.
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The attached patch rewrites much of the keytable code in
drivers/media/IR/ir-keytable.c.
The scancodes are now inserted into the array in sorted
order which allows for a binary search on lookup.
The code has also been shrunk by about 150 lines.
In addition it fixes the following bugs:
Any use of ir_seek_table() was racy.
ir_dev->driver_name is leaked between ir_input_register() and
ir_input_unregister().
ir_setkeycode() unconditionally does clear_bit() on dev->keybit
when removing a mapping, but there might be another mapping with
a different scancode and the same keycode.
This version has been updated to incorporate patch feedback from
Mauro Carvalho Chehab.
[mchehab@redhat.com: Fix a conflict with RC keytable breakup patches and input changes]
Signed-off-by: David Härdeman <david@hardeman.nu>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The code that enables IRQ for the Remote Controller on saa7134 is a little
messy: it is outside saa7134-input, it checks if RC is GPIO based, and
it mixes both serial raw decode with parallel reads from a hardware-based
IR decoder.
Also, currently, it doesn't allow to trigger both transition edges at GPIO16
and GPIO18 lines. A rework on the code is needed to provide a better way
to specify what saa7134-input needs, maybe even moving part of the code from
saa7134-core and saa7134-cards into saa7134-input.
Yet, as a large rework is happening at RC core, it is better to wait until
the core changes stablize, in order to rework saa7134 RC internals.While
this don't happen, let's just change the logic a little bit to allow
enabling IRQ to be generated on both edge transitions, in order to better
support pulse/space raw decoders.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
There's an error at the IRQ2 bit map registers. Also, it doesn't
show what bits are needed for positive and for negative edge.
In the case of IR raw decoding, for some protocols, it is important
to detect both positive and negative edges. So, a latter patch
will need to use the other values.
Also, the code that detects problems on IRQ handling is incomplete,
as it disables only one of the IRQ bits for GPIO16 and GPIO18.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Now that the remote keymaps were broken into separate modules,
get rid of the keycode tables that were hardcoded into ir-common.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Instead of using the ugly keymap sequences, use the new rc-*.ko keymap
files. For now, it is still needed to have one keymap loaded, for the
RC code to work. Later patches will remove this depenency.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
A latter patch will reuse the ir_input_register with a different meaning.
Before it, change all occurrences to a temporary name.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The original Remote Controller approach were very messy: a big file,
that were part of ir-common kernel module, containing 64 different
RC keymap tables, used by the V4L/DVB drivers.
Better to break each RC keymap table into a separate module,
registering them into rc core on a process similar to the fs/nls tables.
As an userspace program is now in charge of loading those tables,
adds an option to allow the complete removal of those tables from
kernelspace.
Yet, on embedded devices like Set Top Boxes and TV sets, maybe the
only available input device is the IR. So, we should keep allowing
the usage of in-kernel tables, but a latter patch should change
the default to 'n', after giving some time for distros to add
the v4l-utils with the ir-keytable program, to allow the table
load via userspace.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Instead of having all RC tables hardcoded on one file with
all tables there, add infrastructure for registering and dynamically
load the table(s) when needed.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Instead of having one big file with lots of keytables, create one include
file for each IR keymap.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The usage of macros ensures that the proper namespace is being used
by all tables. It also makes easier to associate a keytable with
the name used inside the drivers.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Several DVB drivers use a different name convention. As we're moving
the keytables, we need to use the same convention on all places.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Replaces most of the occurences of IR keytables on V4L drivers by a macro
that evaluates to provide the name of the exported symbol.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
It seems impossible for ov to be NULL at this point.
The semantic match that finds the problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
expression E, E1;
identifier f;
statement S1,S3;
iterator iter;
@@
if ((E == NULL && ...) || ...)
{
... when != false ((E == NULL && ...) || ...)
when != true ((E != NULL && ...) || ...)
when != iter(E,...) S1
when != E = E1
(
sizeof(E->f)
|
* E->f
)
... when any
return ...;
}
else S3
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
cap->driver is a 16 char buffer and dev->name is a 32 char buffer.
I don't see an actual problem, but we may as well make the static
checkers happy.
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Especially when IR needs to do polling, it generates lots of wakeups per
second. This makes no sense, if the input event device is closed.
Adds a callback handler to the IR hardware driver, to allow registering
an open/close ops.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
IR is an alias for Infrared Remote, while RC is an alias for Remote
Controller.
While currently all implementations are with Infrared Remote Controller,
this subsystem is not meant to be used only by IR type of RC's. So,
as discussed on both linux-media and linux-input, the better is to
rename the subsystem as Remote Controller.
While, currently, the only application that uses the /sys/class/irrcv is
ir-keytable application, and its sysfs support works only with the
current linux-next code, it is still possible to change the userspace API
without the risk of breaking applications. So, better to rename this
sooner than later.
Later patches will be needed to rename the files and to move them away
from drivers/media, but this is not a critical issue. So, for now,
let's just change the name of the sysfs class/nodes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
With the help of raw_register/raw_unregister, adds a sysfs group
associated with the decoder, inside the corresponding irrcv node.
Writing 1 to nec_decoder/enabled enables the decoder, while
writing 0 disables it.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Some decoders and a lirc_dev interface may need some other operations to work.
For example: IR device register/unregister and ir_keydown events may need to
be tracked.
As some operations can occur in interrupt time, and a lock is needed to prevent
un-registering a decode while decoding a key, the lock needed to be convert
into a spin lock.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Instead of hardcoding the protocols into ir-core, add a register interface
for the IR protocol decoders, and convert ir-nec-decoder into a client of
ir-core.
With this approach, it is possible to dynamically load the needed IR protocols,
and to add a RAW IR interface module, registered as one IR raw protocol decoder.
This patch opens a way to register a lirc_dev interface to work as an userspace
IR protocol decoder.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
At raw_decode mode, the key is processed after the end of a timer. The
previous code resets the timer every time something is received at the IR
port. While this works fine with IR's that don't implement repeat, like
Avermedia RM-JX IR, it keeps waiting until keydown, on IR's that implement
NEC repeat command, like the Terratec yellow.
The solution is to change the behaviour to do the timeout after the first
received data.
The timeout is currently set to 15 ms, as it works fine with NEC protcocol.
It may need some adjustments to support other protocols and to better handle
spurious detections that may happen with some IR sensors.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Adds a method to pass IR raw pulse/code events into ir-core. This is
needed in order to support LIRC. It also helps to move common code
from the drivers into the core.
In order to allow testing, it implements a simple NEC protocol decoder
at ir-nec-decoder.c file. The logic is about the same used at saa7134
driver that handles Avermedia M135A and Encore FM53 boards.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The V4L2 specification requires drivers to use the write events in the
file operations poll handler for output devices. The uvcvideo driver
erroneously used read events for all devices. Fix this.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Those control, as their names imply, control the camera aperture
settings.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The camera requires the STREAM_NO_FID quirk. Add a corresponding entry
in the device IDs list.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
The camera requires the PROBE_DEF quirk. Add a corresponding entry in
the device IDs list.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Some webcams handled by both sn9c102 or zc0301 and some gspca subdrivers
(sonixb, sonixj and zc3xx) were not handled when gspca was generated but
not the associated subdrivers.
Signed-off-by: Jean-François Moine <moinejf@free.fr>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
For the sequence streamon -> streamoff and again s_input, it fails
to lock the signal, since streamoff puts TVP514x into power off state
which leads to failure in sub-sequent s_input.
So add powerup sequence in s_routing (if disabled), since it is
important to lock the signal at this stage.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Sudhakar Rajashekhara <sudhakar.raj@ti.com>
Signed-off-by: Muralidharan Karicheri <mkaricheri@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
For the devices like AM3517, it is expected that driver clears the
interrupt in ISR. Since this is device spcific, callback function
added to the platform_data.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
Signed-off-by: Muralidharan Karicheri <mkaricheri@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Converted this old V4L1 driver to V4L2.
I would like to thank Takeo Takahashi who very kindly tested this
driver for me. Much appreciated!
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Tested-by: Takeo Takahashi <takahashi.takeo@renesas.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>