Пример #1
0
static int __init samsung_init(void)
{
        struct backlight_properties props;
        memset(&props, 0, sizeof(struct backlight_properties));

        if (!dmi_check_system(samsung_dmi_table))
                return -ENODEV;

        /*
         * The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
         * NP-Q45 uses 0x2a02
         * R468/R418, R518, R510/P510, X320/X420/X520 and X360 uses 0x2a42
         * N220 uses 0xa011
         * Odds are we might need to add more to the
         * list over time...
         */
        pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x27ae, NULL);
        if (!pci_device) 
                pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2a02, NULL);
        if (!pci_device)
                pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0x2a42, NULL);
        if (!pci_device)
                pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, 0xa011, NULL);
        if (!pci_device)
                return -ENODEV;
        

        /* create a backlight device to talk to this one */
        backlight_device = backlight_device_register("samsung",
                                                     &pci_device->dev,
                                                     NULL, &backlight_ops, &props);
        if (IS_ERR(backlight_device)) {
                pci_dev_put(pci_device);
                return PTR_ERR(backlight_device);
        }

        backlight_device->props.max_brightness = MAX_BRIGHT;
        backlight_device->props.brightness = read_brightness();
        backlight_device->props.power = FB_BLANK_UNBLANK;
        backlight_update_status(backlight_device);

        return 0;
}
Пример #2
0
static int __init samsung_init(void)
{
        struct device *parent=NULL;	

	if (use_sabi && !dmi_check_system(samsung_sabi_dmi_table) && !force){
	    printk(KERN_ERR "Samsung-backlight is intended to work only with Samsung laptops.\n");
	    return -ENODEV;
	}
        if (!use_sabi && !dmi_check_system(samsung_dmi_table) && !force){
	    printk(KERN_ERR "Sorry, your laptop is not supported. Try use_sabi=1\n");
	    return -ENODEV;
        }

        if(use_sabi){
	    const char *test_str = "SwSmi@";
	    int pos;
	    int index = 0;
	    void __iomem *base;
	    unsigned int ifaceP;
	
	    mutex_init(&sabi_mutex);
	
	    f0000_segment = ioremap(0xf0000, 0xffff);
	    if (!f0000_segment) {
	        printk(KERN_ERR "Samsung-backlight: Can't map the segment at 0xf0000\n");
	        return -EINVAL;
	    }
	
	    printk(KERN_INFO "Samsung-backlight: checking for SABI support.\n");
	
	    /* Try to find the signature "SwSmi@" in memory to find the header */
	    base = f0000_segment;
	    for (pos = 0; pos < 0xffff; ++pos) {
	        char temp = readb(base + pos);
	        if (temp == test_str[index]) {
	            if (5 == index++)
	                break;
	        }
	        else {
	            index = 0;
	        }
	    }
	    if (pos == 0xffff) {
	        printk(KERN_INFO "Samsung-backlight: SABI is not supported\n");
	        iounmap(f0000_segment);
	        return -EINVAL;
	    }
	
	    sabi = (struct sabi_header __iomem *)(base + pos + 1);
	
	    printk(KERN_INFO "Samsung-backlight: SABI is supported (%x)\n", pos + 0xf0000 - 6);
	    if (debug) {
	        printk(KERN_DEBUG "SABI header:\n");
	        printk(KERN_DEBUG " SMI Port Number = 0x%04x\n", readw(&sabi->port));
	        printk(KERN_DEBUG " SMI Interface Function = 0x%02x\n", readb(&sabi->iface_func));
	        printk(KERN_DEBUG " SMI enable memory buffer = 0x%02x\n", readb(&sabi->en_mem));
	        printk(KERN_DEBUG " SMI restore memory buffer = 0x%02x\n", readb(&sabi->re_mem));
	        printk(KERN_DEBUG " SABI data offset = 0x%04x\n", readw(&sabi->data_offset));
	        printk(KERN_DEBUG " SABI data segment = 0x%04x\n", readw(&sabi->data_segment));
	        printk(KERN_DEBUG " BIOS interface version = 0x%02x\n", readb(&sabi->bios_ifver));
	        printk(KERN_DEBUG " KBD Launcher string = 0x%02x\n", readb(&sabi->launcher_string));
	    }
	
	    /* Get a pointer to the SABI Interface */
	    ifaceP = (readw(&sabi->data_segment) & 0x0ffff) << 4;
	    ifaceP += readw(&sabi->data_offset) & 0x0ffff;
	    sabi_iface = (struct sabi_interface __iomem *)ioremap(ifaceP, 16);
	    if (!sabi_iface) {
	        printk(KERN_ERR "Samsung-backlight: Can't remap %x\n", ifaceP);
	        iounmap(f0000_segment);
	        return -EINVAL;
	    }
	
	    if (debug) {
	        printk(KERN_DEBUG "Samsung-backlight: SABI Interface = %p\n", sabi_iface);
	    }
        }else{
          /*
	   * The Samsung N120, N130, and NC10 use pci device id 0x27ae, while the
	   * NP-Q45 uses 0x2a02.  Odds are we might need to add more to the
	   * list over time...
	   */
          int pcidevids[]={0x27ae,0x2a02,0x2a42,0xa011,0};
	  int i;
          for(i=0, pci_device=NULL;pcidevids[i]>0 && pci_device==NULL;++i)
	    pci_device = pci_get_device(PCI_VENDOR_ID_INTEL, pcidevids[i], NULL);
          if (!pci_device)
            return -ENODEV;
          parent=&pci_device->dev;
        }
 
        /* create a backlight device to talk to this one */
#if LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34)
	backlight_device = backlight_device_register("samsung",
						     parent,
						     NULL, &backlight_ops,NULL);
#else
	backlight_device = backlight_device_register("samsung",
						     parent,
						     NULL, &backlight_ops);
#endif
	if (IS_ERR(backlight_device)) {
                if(pci_device)
		  pci_dev_put(pci_device);
		return PTR_ERR(backlight_device);
	}

	backlight_device->props.max_brightness = use_sabi ? SABI_MAX_BRIGHT : MAX_BRIGHT;
	backlight_device->props.brightness = read_brightness();
	backlight_device->props.power = FB_BLANK_UNBLANK;
	backlight_update_status(backlight_device);

	return 0;
}
Пример #3
0
static int get_brightness(struct backlight_device *bd)
{
        return read_brightness();
	//return bd->props.brightness;
}