]> git.karo-electronics.de Git - karo-tx-linux.git/commit
staging: comedi: ni_labpc: correct differential channel sequence for AI commands
authorIan Abbott <abbotti@mev.co.uk>
Wed, 27 Feb 2013 12:52:45 +0000 (12:52 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 6 Mar 2013 03:24:21 +0000 (03:24 +0000)
commit8e53d294a77b695883bf20351a60edb35b479904
treea01f2a383c5904cde1862a31b77ddf747519ccb3
parent0fd0ff7e1fcc4b4bc5d17ab1d200f23dea7c681d
staging: comedi: ni_labpc: correct differential channel sequence for AI commands

commit 4c4bc25d0fa6beaf054c0b4c3b324487f266c820 upstream.

Tuomas <tvainikk _at_ gmail _dot_ com> reported problems getting
meaningful output from a Lab-PC+ in differential mode for AI cmds, but
AI insn reads gave correct readings.  He tracked it down to two
problems, one of which is addressed by this patch.

It seems the setting of the channel bits for particular scanning modes
was incorrect for differential mode.  (Only half the number of channels
are available in differential mode; comedi refers to them as channels 0,
1, 2 and 3, but the hardware documentation refers to them as channels 0,
2, 4 and 6.)  In differential mode, the setting of the channel enable
bits in the command1 register should depend on whether the scan enable
bit is set.  Effectively, we need to double the comedi channel number
when the scan enable bit is not set in differential mode.  The scan
enable bit gets set when the AI scan mode is `MODE_MULT_CHAN_UP` or
`MODE_MULT_CHAN_DOWN`, and gets cleared when the AI scan mode is
`MODE_SINGLE_CHAN` or `MODE_SINGLE_CHAN_INTERVAL`.  The existing test
for whether the comedi channel number needs to be doubled in
differential mode is incorrect in `labpc_ai_cmd()`.  This patch corrects
the test.

Thanks to Tuomas for suggesting the fix.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/staging/comedi/drivers/ni_labpc.c