Lines Matching +full:d +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
37 #define ACPI_TO_RAW(v, d) (d->raw_bd->props.max_brightness * v / 100) argument
38 #define RAW_TO_ACPI(v, d) (v * 100 / d->raw_bd->props.max_brightness) argument
44 struct int3406_thermal_data *d = cooling_dev->devdata; in int3406_thermal_get_max_state() local
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() local
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()
62 raw_level = ACPI_TO_RAW(acpi_level, d); 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() local
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()
108 static void int3406_thermal_get_limit(struct int3406_thermal_data *d) in int3406_thermal_get_limit() argument
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()
137 struct int3406_thermal_data *d; in int3406_thermal_probe() local
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()
145 if (!d) 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()
158 int3406_thermal_get_limit(d); in int3406_thermal_probe()
160 d->cooling_dev = thermal_cooling_device_register(acpi_device_bid(adev), in int3406_thermal_probe()
161 d, &video_cooling_ops); 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()
166 int3406_notify, d); in int3406_thermal_probe()
170 platform_set_drvdata(pdev, d); 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()
183 struct int3406_thermal_data *d = platform_get_drvdata(pdev); in int3406_thermal_remove() local
185 thermal_cooling_device_unregister(d->cooling_dev); in int3406_thermal_remove()
186 kfree(d->br); in int3406_thermal_remove()