// SPDX-License-Identifier: GPL-2.0-only /* * Miscellaneous procedures for dealing with the PowerMac hardware. * Contains support for the backlight. * * Copyright (C) 2000 Benjamin Herrenschmidt * Copyright (C) 2006 Michael Hanselmann <linux-kernel@hansmi.ch> *
*/
/* Although these variables are used in interrupt context, it makes no sense to * protect them. No user is able to produce enough key events per second and * notice the errors that might happen.
*/ staticint pmac_backlight_key_queued; staticint pmac_backlight_set_legacy_queued;
/* The via-pmu code allows the backlight to be grabbed, in which case the * in-kernel control of the brightness needs to be disabled. This should * only be used by really old PowerBooks.
*/ static atomic_t kernel_backlight_disabled = ATOMIC_INIT(0);
/* Protect the pmac_backlight variable below. You should hold this lock when using the pmac_backlight pointer to
prevent its potential removal. */
DEFINE_MUTEX(pmac_backlight_mutex);
/* Main backlight storage * * Backlight drivers in this variable are required to have the "ops" * attribute set and to have an update_status function. * * We can only store one backlight here, but since Apple laptops have only one * internal display, it doesn't matter. Other backlight drivers can be used * independently. *
*/ struct backlight_device *pmac_backlight;
int pmac_has_backlight_type(constchar *type)
{ struct device_node* bk_node = of_find_node_by_name(NULL, "backlight"); int i = of_property_match_string(bk_node, "backlight-control", type);
of_node_put(bk_node); return i >= 0;
}
staticvoid pmac_backlight_key_worker(struct work_struct *work)
{ if (atomic_read(&kernel_backlight_disabled)) return;
mutex_lock(&pmac_backlight_mutex); if (pmac_backlight) { struct backlight_properties *props; int brightness;
/* This function is called in interrupt context */ void pmac_backlight_key(int direction)
{ if (atomic_read(&kernel_backlight_disabled)) return;
/* we can receive multiple interrupts here, but the scheduled work * will run only once, with the last value
*/
pmac_backlight_key_queued = direction;
schedule_work(&pmac_backlight_key_work);
}
staticint __pmac_backlight_set_legacy_brightness(int brightness)
{ int error = -ENXIO;
mutex_lock(&pmac_backlight_mutex); if (pmac_backlight) { struct backlight_properties *props;
/* This function is called in interrupt context */ void pmac_backlight_set_legacy_brightness_pmu(int brightness) { if (atomic_read(&kernel_backlight_disabled)) return;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.