All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Renato S. Yamane" <renatoyamane@mandic.com.br>
To: jonathan@buzzard.me.uk, john@neggie.net, linux-acpi@vger.kernel.org
Subject: [Test_Module] Changing brightness in Toshiba notebooks with Phoenix Bios
Date: Fri, 15 Jun 2007 09:23:12 -0300	[thread overview]
Message-ID: <467284B0.4090407@mandic.com.br> (raw)

This module below work fine in some tested laptops with Phoenix BIOS.

And omnibook driver available in [1] work fine in some laptops with 
TOSHIBA BIOS is not recognized by toshiba_acpi.

[1]:
svn export https://svn.sourceforge.net/svnroot/omnibook/omnibook/trunk

Forwarding from: Toshiba_Linux-Users (tlinux-users@linux.toshiba-dme.co.jp)

=============
To compile:
Edit a Makefile and add:
   obj-m := test.o

then run in the same directory:

  make -C /usr/src/linux SUBDIRS=`pwd` modules

Then make the file for the new device:

  mknod test_file c 181 0

Load de module:

  insmod test.ko

And now, if you are very very lucky, maybe it will work:

   echo 3 > test_file

But I warn: THE MOST PROBABLY THING WILL HAPPEN IS THE FREEZE OF THE
LAPTOP IF YOUR MODEL DOESN'T MATCH EXACTLY WITH THE MODEL I TESTED. If
you don't have a Phoenix BIOS don't try this, and if you have.. well..
it's your election x)

Here is the driver

test.c
=================== CUT HERE ===================
/*
* Module for Toshiba lcd bright change.
* I only made it for my Toshiba Satellite Pro A100 with Phoenix BIOS
* I don't know under which models it works (I suppose very few)
* The asm code I inserted I took it from a disass of the windows
* driver provided by Toshiba.
* WARNING:
* The driver does NOT make any tests if the model is valid or not
* so, the MOST probably effect of running this will be the hang of
* the laptop, or something worse.
* PLEASE DON'T USE THIS unless you really know what you are doing
* This module isn't made for give support to any Toshiba model,
* only for tests purpouses , sorry about it.
*
* Jaime F. <jaimeff@gmail.com>
* License: GNU/GPL
*/


#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/io.h>

#define DEVICE_NAME "lcd_bright"
#define MAJOR_NUM 181

char *ptr;

static ssize_t
device_write(struct file *file,
             const char __user * buffer, size_t length, loff_t * offset)
{
  char *addr;
  addr=(char *)__pa(ptr);
  addr+=0x10;

  strcpy(ptr, "INVTOS");
  //ptr+=10;
  *(ptr+16)=(char) buffer[0]-0x30;
  //printk("escribiendo %x\n", *ptr);
/*
  inb( 0x2e);
  inb( 0x2f);
  outb(7, 0x2e);
  outb(9, 0x2f);
  v3=inb(0x2f);
  outb2(0x2e, 0x55);
  outb2(0x2e, 7);
  outb2(0x2f,0x10);
  outb2(0x2e,0xe0);
  v4=inb(0x2f);
  outb2(0x2f,2);
  v5=inb(0x2f);
  outb2(0x2f,3);

  outb2(0x2e, 7);
  outb2(0x2f,9);
  outb2(0x2e,0x60);
  v1=inb(0x2f);
  outb2(0x2e,7);
  outb2(0x2f,0x10);
  outb2(0x2e,0xe0);
  outb2(0x2f,0);
  outb2(0x2e, 7);
  outb2(0x2f, 9);
  outb2 ( 0x2e, 0xaa);
  outb2 ( 0x400, 0xAF);
  v2=inb( 0x401);
  outb2( 0x400, 0xAF);
*/

  __asm__("cli\n"
        /*        "mov $0x01E4, %%eax\n"
                  "mov $0x00b0, %%dx\n"
                  "movb $0x02, 0xEF\n"
                  "out %%eax, %%dx\n"
*/
                "mov %0, %%edx\n"
                "mov %%edx, %%edi\n"
                "mov $0x20, %%ecx\n"
                "mov $0x8000f840, %%eax\n mov $0xcf8, %%edx\n out %%eax,
%%dx\n"
                "mov $0xcfc, %%dx\n"
                "in %%dx, %%eax\n"
                "and $0x0000ff80, %%eax\n"
                "add $0x2c, %%eax\n"
                "mov %%ax, %%dx\n"
                "in %%dx, %%eax\n"
                "push %%eax\n"
//              "mov %%ax, %%dx\n"
                "xor %%eax, %%eax\n"
                "out %%eax, %%dx\n"
                "mov $0xA2E4, %%eax\n"
                "mov $0xb2, %%dx\n"
                "out %%eax, %%dx\n"
                "pop %%eax\n"
                "mov $0x102c, %%dx\n"
                "out %%eax, %%dx\n"
/*              "movl $0x10, %%edx\n\t"
                "movl %%edx, %%edi\n\t"
                "movl $0x20, %%ecx\n"
                "movw  $0x00E4, %%ax\n"
                "movb  $0x5, %%ah\n"
                "outw  %%ax, $0xb2\n"
                "movl %%eax, %0\n sti\n"
                */
        :
        :"r"(addr): "%eax", "%edx", "%ecx","%edi", "%esi");
  return length;
}

struct file_operations Fops = {
  .write = device_write,
};

int init_module()
{
  int ret_val;
  ptr=(char *)kmalloc(100, GFP_KERNEL);
  ptr+=10;
  ret_val = register_chrdev(MAJOR_NUM, DEVICE_NAME, &Fops);

  if (ret_val < 0)
  {
    printk(KERN_ALERT "El registro del dispositivo falló (%d)\n", ret_val);
    return ret_val;
  }

return 0;
}

void cleanup_module()
{
  int ret;

  ret = unregister_chrdev(MAJOR_NUM, DEVICE_NAME);

  if (ret < 0)
    printk(KERN_ALERT "Error: unregister_chrdev: %d\n", ret);
}

===================== CUT HERE ====================

Best Regards,
Renato S. Yamane
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2007-06-15 12:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-15 12:23 Renato S. Yamane [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-06-15  0:17 [Test_Module] Changing brightness in Toshiba notebooks with Phoenix Bios Renato S. Yamane
2007-07-16 17:28 ` Rolf Eike Beer

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=467284B0.4090407@mandic.com.br \
    --to=renatoyamane@mandic.com.br \
    --cc=john@neggie.net \
    --cc=jonathan@buzzard.me.uk \
    --cc=linux-acpi@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.