I
I
Ivan Karabadzhak2014-02-22 20:34:54
linux
Ivan Karabadzhak, 2014-02-22 20:34:54

What is the i8042_command function in Linux?

I have Dell v131. The touchpad works cool on the new drivers, but its LED does not work when turned off. I wrote a program that responds to Fn + F3 and disables the touchpad, but I have no idea how to work with LED. In Linux, like from kernel 3.4 (it definitely works on the latest ubuntu), you can do this:

echo 1 > /sys/class/leds/dell-laptop::touchpad/brightness

or
echo 0 > /sys/class/leds/dell-laptop::touchpad/brightness

I found some files in the kernel where this is implemented (drivers/platform/x86/dell-laptop.c).
There is code there:
static void touchpad_led_on(void)
{
  int command = 0x97;
  char data = 1;
  i8042_command(&data, command | 1 << 12);
}

I also dug up this in other files:
int i8042_command(unsigned char *param, int command)
{
  unsigned long flags;
  int retval;

  spin_lock_irqsave(&i8042_lock, flags);
  retval = __i8042_command(param, command);
  spin_unlock_irqrestore(&i8042_lock, flags);

  return retval;
}

static int __i8042_command(unsigned char *param, int command)
{
  int i, error;

  if (i8042_noloop && command == I8042_CMD_AUX_LOOP)
    return -1;

  error = i8042_wait_write();
  if (error)
    return error;

  dbg("%02x -> i8042 (command)\n", command & 0xff);
  i8042_write_command(command & 0xff);

  for (i = 0; i < ((command >> 12) & 0xf); i++) {
    error = i8042_wait_write();
    if (error)
      return error;
    dbg("%02x -> i8042 (parameter)\n", param[i]);
    i8042_write_data(param[i]);
  }

  for (i = 0; i < ((command >> 8) & 0xf); i++) {
    error = i8042_wait_read();
    if (error) {
      dbg("     -- i8042 (timeout)\n");
      return error;
    }

    if (command == I8042_CMD_AUX_LOOP &&
        !(i8042_read_status() & I8042_STR_AUXDATA)) {
      dbg("     -- i8042 (auxerr)\n");
      return -1;
    }

    param[i] = i8042_read_data();
    dbg("%02x <- i8042 (return)\n", param[i]);
  }

  return 0;
}

I want to write the same under Windows 7. But I don't really understand what to do. I don’t even know where to dig, since I have never written drivers and so on. Tell me, please, something.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
garisson, 2014-02-23
@Jakeroid

try to take dll geekhideout.com/iodll.shtml
and write a program for writing/reading i/o ports ps/2
as far as I understand, the layout of the functions is something like this -
port mode description
0x60 Read/Write Data Port (i8042_write_data()/i8042_read_data( ))
0x64 Read Status Register 0x64
Write Command Register (i8042_write_command())
but will the system allow writing/reading ports from non-privileged mode and will there be a conflict with the keyboard/mouse driver?
you can add an additional driver ( msdn.microsoft.com/en-us/windows/hardware/hh852365.aspx- Windows Driver Kit - there are also examples) - it is likely that it will even work

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question