Lines Matching +full:brightness +full:- +full:levels

1 // SPDX-License-Identifier: GPL-2.0-only
29 * "Each brightness level is represented by a number between 0 and 100,
31 * power consumption or 50% brightness, as defined by the OEM."
35 * the percentage of brightness only
37 #define ACPI_TO_RAW(v, d) (d->raw_bd->props.max_brightness * v / 100)
38 #define RAW_TO_ACPI(v, d) (v * 100 / d->raw_bd->props.max_brightness)
44 struct int3406_thermal_data *d = cooling_dev->devdata; in int3406_thermal_get_max_state()
46 *state = d->upper_limit - d->lower_limit; in int3406_thermal_get_max_state()
54 struct int3406_thermal_data *d = cooling_dev->devdata; in int3406_thermal_set_cur_state()
57 if (state > d->upper_limit - d->lower_limit) in int3406_thermal_set_cur_state()
58 return -EINVAL; in int3406_thermal_set_cur_state()
60 acpi_level = d->br->levels[d->upper_limit - state]; in int3406_thermal_set_cur_state()
64 return backlight_device_set_brightness(d->raw_bd, raw_level); in int3406_thermal_set_cur_state()
71 struct int3406_thermal_data *d = cooling_dev->devdata; in int3406_thermal_get_cur_state()
75 acpi_level = RAW_TO_ACPI(d->raw_bd->props.brightness, d); in int3406_thermal_get_cur_state()
82 for (index = d->lower_limit; index < d->upper_limit; index++) { in int3406_thermal_get_cur_state()
83 if (acpi_level <= d->br->levels[index]) in int3406_thermal_get_cur_state()
87 *state = d->upper_limit - index; in int3406_thermal_get_cur_state()
105 return i == nr ? -ENOENT : i; in int3406_thermal_get_index()
113 status = acpi_evaluate_integer(d->handle, "DDDL", NULL, &lower_limit); in int3406_thermal_get_limit()
115 d->lower_limit = int3406_thermal_get_index(d->br->levels, in int3406_thermal_get_limit()
116 d->br->count, lower_limit); in int3406_thermal_get_limit()
118 status = acpi_evaluate_integer(d->handle, "DDPC", NULL, &upper_limit); in int3406_thermal_get_limit()
120 d->upper_limit = int3406_thermal_get_index(d->br->levels, in int3406_thermal_get_limit()
121 d->br->count, upper_limit); in int3406_thermal_get_limit()
124 d->lower_limit = d->lower_limit > 0 ? d->lower_limit : 2; in int3406_thermal_get_limit()
125 d->upper_limit = d->upper_limit > 0 ? d->upper_limit : d->br->count - 1; in int3406_thermal_get_limit()
136 struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); in int3406_thermal_probe()
141 if (!ACPI_HANDLE(&pdev->dev)) in int3406_thermal_probe()
142 return -ENODEV; in int3406_thermal_probe()
144 d = devm_kzalloc(&pdev->dev, sizeof(*d), GFP_KERNEL); in int3406_thermal_probe()
146 return -ENOMEM; in int3406_thermal_probe()
147 d->handle = ACPI_HANDLE(&pdev->dev); in int3406_thermal_probe()
151 return -ENODEV; in int3406_thermal_probe()
152 d->raw_bd = bd; in int3406_thermal_probe()
154 ret = acpi_video_get_levels(ACPI_COMPANION(&pdev->dev), &d->br, NULL); in int3406_thermal_probe()
160 d->cooling_dev = thermal_cooling_device_register(acpi_device_bid(adev), in int3406_thermal_probe()
162 if (IS_ERR(d->cooling_dev)) in int3406_thermal_probe()
165 ret = acpi_install_notify_handler(adev->handle, ACPI_DEVICE_NOTIFY, in int3406_thermal_probe()
175 thermal_cooling_device_unregister(d->cooling_dev); in int3406_thermal_probe()
177 kfree(d->br); in int3406_thermal_probe()
178 return -ENODEV; in int3406_thermal_probe()
185 thermal_cooling_device_unregister(d->cooling_dev); in int3406_thermal_remove()
186 kfree(d->br); in int3406_thermal_remove()