toshiba_acpi: Transflective backlight updates

This patch changes the tr function second parameter from bool to u32,
to be on par with the rest of the TCI functions of the driver, and the
code was updated accordingly.

Also, the check for translective support was moved to the *add
function, as the {__get, set}_lcd_brightness functions make use of it.

Signed-off-by: Azael Avalos <coproscefalo@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
This commit is contained in:
Azael Avalos 2015-07-22 18:09:13 -06:00 коммит произвёл Darren Hart
Родитель a88bc06e5a
Коммит 695f606090
1 изменённых файлов: 11 добавлений и 19 удалений

Просмотреть файл

@ -1187,22 +1187,17 @@ static int toshiba_hotkey_event_type_get(struct toshiba_acpi_dev *dev,
} }
/* Transflective Backlight */ /* Transflective Backlight */
static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, bool *enabled) static int get_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 *status)
{ {
u32 hci_result; u32 hci_result = hci_read(dev, HCI_TR_BACKLIGHT, status);
u32 status;
hci_result = hci_read(dev, HCI_TR_BACKLIGHT, &status);
*enabled = !status;
return hci_result == TOS_SUCCESS ? 0 : -EIO; return hci_result == TOS_SUCCESS ? 0 : -EIO;
} }
static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, bool enable) static int set_tr_backlight_status(struct toshiba_acpi_dev *dev, u32 status)
{ {
u32 hci_result; u32 hci_result = hci_write(dev, HCI_TR_BACKLIGHT, !status);
u32 value = !enable;
hci_result = hci_write(dev, HCI_TR_BACKLIGHT, value);
return hci_result == TOS_SUCCESS ? 0 : -EIO; return hci_result == TOS_SUCCESS ? 0 : -EIO;
} }
@ -1216,12 +1211,11 @@ static int __get_lcd_brightness(struct toshiba_acpi_dev *dev)
int brightness = 0; int brightness = 0;
if (dev->tr_backlight_supported) { if (dev->tr_backlight_supported) {
bool enabled; int ret = get_tr_backlight_status(dev, &value);
int ret = get_tr_backlight_status(dev, &enabled);
if (ret) if (ret)
return ret; return ret;
if (enabled) if (value)
return 0; return 0;
brightness++; brightness++;
} }
@ -1271,8 +1265,7 @@ static int set_lcd_brightness(struct toshiba_acpi_dev *dev, int value)
u32 hci_result; u32 hci_result;
if (dev->tr_backlight_supported) { if (dev->tr_backlight_supported) {
bool enable = !value; int ret = set_tr_backlight_status(dev, !value);
int ret = set_tr_backlight_status(dev, enable);
if (ret) if (ret)
return ret; return ret;
@ -2563,7 +2556,6 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
struct backlight_properties props; struct backlight_properties props;
int brightness; int brightness;
int ret; int ret;
bool enabled;
/* /*
* Some machines don't support the backlight methods at all, and * Some machines don't support the backlight methods at all, and
@ -2580,10 +2572,6 @@ static int toshiba_acpi_setup_backlight(struct toshiba_acpi_dev *dev)
return 0; return 0;
} }
/* Determine whether or not BIOS supports transflective backlight */
ret = get_tr_backlight_status(dev, &enabled);
dev->tr_backlight_supported = !ret;
/* /*
* Tell acpi-video-detect code to prefer vendor backlight on all * Tell acpi-video-detect code to prefer vendor backlight on all
* systems with transflective backlight and on dmi matched systems. * systems with transflective backlight and on dmi matched systems.
@ -2723,6 +2711,10 @@ static int toshiba_acpi_add(struct acpi_device *acpi_dev)
if (toshiba_acpi_setup_keyboard(dev)) if (toshiba_acpi_setup_keyboard(dev))
pr_info("Unable to activate hotkeys\n"); pr_info("Unable to activate hotkeys\n");
/* Determine whether or not BIOS supports transflective backlight */
ret = get_tr_backlight_status(dev, &dummy);
dev->tr_backlight_supported = !ret;
ret = toshiba_acpi_setup_backlight(dev); ret = toshiba_acpi_setup_backlight(dev);
if (ret) if (ret)
goto error; goto error;