static int video_proc_show(struct seq_file *m, void *v) { struct toshiba_acpi_dev *dev = m->private; u32 value; int ret; ret = get_video_status(dev, &value); if (!ret) { int is_lcd = (value & HCI_VIDEO_OUT_LCD) ? 1 : 0; int is_crt = (value & HCI_VIDEO_OUT_CRT) ? 1 : 0; int is_tv = (value & HCI_VIDEO_OUT_TV) ? 1 : 0; seq_printf(m, "lcd_out: %d\n", is_lcd); seq_printf(m, "crt_out: %d\n", is_crt); seq_printf(m, "tv_out: %d\n", is_tv); } return ret; }
static ssize_t video_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data; char *cmd, *buffer; int ret; int value; int remain = count; int lcd_out = -1; int crt_out = -1; int tv_out = -1; u32 video_out; cmd = kmalloc(count + 1, GFP_KERNEL); if (!cmd) return -ENOMEM; if (copy_from_user(cmd, buf, count)) { kfree(cmd); return -EFAULT; } cmd[count] = '\0'; buffer = cmd; /* */ while (remain) { if (sscanf(buffer, " lcd_out : %i", &value) == 1) lcd_out = value & 1; else if (sscanf(buffer, " crt_out : %i", &value) == 1) crt_out = value & 1; else if (sscanf(buffer, " tv_out : %i", &value) == 1) tv_out = value & 1; /* */ do { ++buffer; --remain; } while (remain && *(buffer - 1) != ';'); } kfree(cmd); ret = get_video_status(dev, &video_out); if (!ret) { unsigned int new_video_out = video_out; if (lcd_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); if (crt_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); if (tv_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); /* */ if (new_video_out != video_out) ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); } return ret ? ret : count; }
static ssize_t video_proc_write(struct file *file, const char __user *buf, size_t count, loff_t *pos) { struct toshiba_acpi_dev *dev = PDE(file->f_path.dentry->d_inode)->data; char *cmd, *buffer; int ret; int value; int remain = count; int lcd_out = -1; int crt_out = -1; int tv_out = -1; u32 video_out; cmd = kmalloc(count + 1, GFP_KERNEL); if (!cmd) return -ENOMEM; if (copy_from_user(cmd, buf, count)) { kfree(cmd); return -EFAULT; } cmd[count] = '\0'; buffer = cmd; /* scan expression. Multiple expressions may be delimited with ; * * NOTE: to keep scanning simple, invalid fields are ignored */ while (remain) { if (sscanf(buffer, " lcd_out : %i", &value) == 1) lcd_out = value & 1; else if (sscanf(buffer, " crt_out : %i", &value) == 1) crt_out = value & 1; else if (sscanf(buffer, " tv_out : %i", &value) == 1) tv_out = value & 1; /* advance to one character past the next ; */ do { ++buffer; --remain; } while (remain && *(buffer - 1) != ';'); } kfree(cmd); ret = get_video_status(dev, &video_out); if (!ret) { unsigned int new_video_out = video_out; if (lcd_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_LCD, lcd_out); if (crt_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_CRT, crt_out); if (tv_out != -1) _set_bit(&new_video_out, HCI_VIDEO_OUT_TV, tv_out); /* To avoid unnecessary video disruption, only write the new * video setting if something changed. */ if (new_video_out != video_out) ret = write_acpi_int(METHOD_VIDEO_OUT, new_video_out); } return ret ? ret : count; }
static int __devinit toshiba_acpi_add(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev; const char *hci_method; u32 dummy; bool bt_present; int ret = 0; struct backlight_properties props; if (toshiba_acpi) return -EBUSY; pr_info("Toshiba Laptop ACPI Extras version %s\n", TOSHIBA_ACPI_VERSION); hci_method = find_hci_method(acpi_dev->handle); if (!hci_method) { pr_err("HCI interface not found\n"); return -ENODEV; } dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->acpi_dev = acpi_dev; dev->method_hci = hci_method; acpi_dev->driver_data = dev; if (toshiba_acpi_setup_keyboard(dev)) pr_info("Unable to activate hotkeys\n"); mutex_init(&dev->mutex); props.type = BACKLIGHT_PLATFORM; props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; dev->backlight_dev = backlight_device_register("toshiba", &acpi_dev->dev, dev, &toshiba_backlight_data, &props); if (IS_ERR(dev->backlight_dev)) { ret = PTR_ERR(dev->backlight_dev); pr_err("Could not register toshiba backlight device\n"); dev->backlight_dev = NULL; goto error; } dev->backlight_dev->props.brightness = get_lcd(dev->backlight_dev); /* */ if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) { dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth", &acpi_dev->dev, RFKILL_TYPE_BLUETOOTH, &toshiba_rfk_ops, dev); if (!dev->bt_rfk) { pr_err("unable to allocate rfkill device\n"); ret = -ENOMEM; goto error; } ret = rfkill_register(dev->bt_rfk); if (ret) { pr_err("unable to register rfkill device\n"); rfkill_destroy(dev->bt_rfk); goto error; } } if (toshiba_illumination_available(dev)) { dev->led_dev.name = "toshiba::illumination"; dev->led_dev.max_brightness = 1; dev->led_dev.brightness_set = toshiba_illumination_set; dev->led_dev.brightness_get = toshiba_illumination_get; if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev)) dev->illumination_supported = 1; } /* */ ret = get_video_status(dev, &dummy); dev->video_supported = !ret; ret = get_fan_status(dev, &dummy); dev->fan_supported = !ret; create_toshiba_proc_entries(dev); toshiba_acpi = dev; return 0; error: toshiba_acpi_remove(acpi_dev, 0); return ret; }
static int toshiba_acpi_add(struct acpi_device *acpi_dev) { struct toshiba_acpi_dev *dev; const char *hci_method; u32 dummy; bool bt_present; int ret = 0; if (toshiba_acpi) return -EBUSY; pr_info("Toshiba Laptop ACPI Extras version %s\n", TOSHIBA_ACPI_VERSION); hci_method = find_hci_method(acpi_dev->handle); if (!hci_method) { pr_err("HCI interface not found\n"); return -ENODEV; } dev = kzalloc(sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; dev->acpi_dev = acpi_dev; dev->method_hci = hci_method; acpi_dev->driver_data = dev; if (toshiba_acpi_setup_keyboard(dev)) pr_info("Unable to activate hotkeys\n"); mutex_init(&dev->mutex); ret = toshiba_acpi_setup_backlight(dev); if (ret) goto error; /* Register rfkill switch for Bluetooth */ if (hci_get_bt_present(dev, &bt_present) == HCI_SUCCESS && bt_present) { dev->bt_rfk = rfkill_alloc("Toshiba Bluetooth", &acpi_dev->dev, RFKILL_TYPE_BLUETOOTH, &toshiba_rfk_ops, dev); if (!dev->bt_rfk) { pr_err("unable to allocate rfkill device\n"); ret = -ENOMEM; goto error; } ret = rfkill_register(dev->bt_rfk); if (ret) { pr_err("unable to register rfkill device\n"); rfkill_destroy(dev->bt_rfk); goto error; } } if (toshiba_illumination_available(dev)) { dev->led_dev.name = "toshiba::illumination"; dev->led_dev.max_brightness = 1; dev->led_dev.brightness_set = toshiba_illumination_set; dev->led_dev.brightness_get = toshiba_illumination_get; if (!led_classdev_register(&acpi_dev->dev, &dev->led_dev)) dev->illumination_supported = 1; } /* Determine whether or not BIOS supports fan and video interfaces */ ret = get_video_status(dev, &dummy); dev->video_supported = !ret; ret = get_fan_status(dev, &dummy); dev->fan_supported = !ret; create_toshiba_proc_entries(dev); toshiba_acpi = dev; return 0; error: toshiba_acpi_remove(acpi_dev); return ret; }