|
|
@ -898,31 +898,71 @@ bool HardwareInfo::suspend( suspend_type suspend ) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
/*!
|
|
|
|
* Function to set brightness via TDE hardware library (if supported by hardware)
|
|
|
|
* Function to set brightness level via TDE hardware library (if supported by hardware)
|
|
|
|
* \param level Integer with the level to set, (range: 0 - \ref availableBrightnessLevels )
|
|
|
|
* \param level Integer with the level to set, (range: 0 - \ref availableBrightnessLevels )
|
|
|
|
* \param percent Integer with the brightness percentage to set
|
|
|
|
|
|
|
|
* \return boolean with result of the operation
|
|
|
|
* \return boolean with result of the operation
|
|
|
|
* \retval true if successful
|
|
|
|
* \retval true if successful
|
|
|
|
* \retval false else, if a error occurs
|
|
|
|
* \retval false else, if a error occurs
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
bool HardwareInfo::setBrightness ( int level, int percent ){
|
|
|
|
bool HardwareInfo::setBrightnessLevel(int level)
|
|
|
|
if (trace) kdDebug() << funcinfo << "IN: " << "level: " << level << " percent: " << percent << endl;
|
|
|
|
{
|
|
|
|
|
|
|
|
if (trace) kdDebug() << funcinfo << "IN: " << "level: " << level << endl;
|
|
|
|
|
|
|
|
|
|
|
|
bool retval = false;
|
|
|
|
bool retval = false;
|
|
|
|
|
|
|
|
int maxBrightness = getMaxBrightnessLevel();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Use the first backlight in the list
|
|
|
|
|
|
|
|
TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
|
|
|
|
|
|
|
|
TDEGenericDevice *hwdevice;
|
|
|
|
|
|
|
|
hwdevice = hwlist.first();
|
|
|
|
|
|
|
|
TDEBacklightDevice *backlightdevice = static_cast<TDEBacklightDevice*>(hwdevice);
|
|
|
|
|
|
|
|
|
|
|
|
if ((level == -1) && (percent >= 0)) {
|
|
|
|
if (backlightdevice) {
|
|
|
|
if (percent == 0) {
|
|
|
|
if (!brightness) {
|
|
|
|
|
|
|
|
checkBrightness();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Make sure level is within valid range
|
|
|
|
|
|
|
|
if (level < 0) {
|
|
|
|
level = 0;
|
|
|
|
level = 0;
|
|
|
|
} else if (percent >= 98) {
|
|
|
|
}
|
|
|
|
level = (availableBrightnessLevels - 1);
|
|
|
|
else if (level > maxBrightness) {
|
|
|
|
|
|
|
|
level = maxBrightness;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!brightness) {
|
|
|
|
|
|
|
|
kdError() << "Change brightness not supported " << endl;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
level = (int)((float)availableBrightnessLevels * ((float)percent/100.0));
|
|
|
|
if (currentBrightnessLevel == level) {
|
|
|
|
if (level > (availableBrightnessLevels -1))
|
|
|
|
kdDebug() << "Brightness level not changed, requested level == current level" << endl;
|
|
|
|
level = availableBrightnessLevels -1;
|
|
|
|
retval = true;
|
|
|
|
kdDebug() << "percentage mapped to new level: " << level << endl;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
backlightdevice->setRawBrightness(level);
|
|
|
|
|
|
|
|
retval = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check for actual brightness level to be sure everything was set correct
|
|
|
|
|
|
|
|
checkCurrentBrightness();
|
|
|
|
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
|
|
|
* Function to set brightness percentage via TDE hardware library (if supported by hardware)
|
|
|
|
|
|
|
|
* \param percent Integer with the brightness percentage to set
|
|
|
|
|
|
|
|
* \return boolean with result of the operation
|
|
|
|
|
|
|
|
* \retval true if successful
|
|
|
|
|
|
|
|
* \retval false else, if a error occurs
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
bool HardwareInfo::setBrightnessPercentage(int percent)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (trace) kdDebug() << funcinfo << "IN: " << " percent: " << percent << endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool retval = false;
|
|
|
|
|
|
|
|
int maxBrightness = getMaxBrightnessLevel();
|
|
|
|
|
|
|
|
|
|
|
|
// Use the first backlight in the list
|
|
|
|
// Use the first backlight in the list
|
|
|
|
TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
|
|
|
|
TDEGenericHardwareList hwlist = m_hwdevices->listByDeviceClass(TDEGenericDeviceType::Backlight);
|
|
|
|
TDEGenericDevice *hwdevice;
|
|
|
|
TDEGenericDevice *hwdevice;
|
|
|
@ -934,8 +974,17 @@ bool HardwareInfo::setBrightness ( int level, int percent ){
|
|
|
|
checkBrightness();
|
|
|
|
checkBrightness();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!brightness || (level < 0 ) || (level >= availableBrightnessLevels)) {
|
|
|
|
// Make sure percentage is within valid range
|
|
|
|
kdError() << "Change brightness or requested level not supported " << endl;
|
|
|
|
if (percent < 0) {
|
|
|
|
|
|
|
|
percent = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (percent > 100) {
|
|
|
|
|
|
|
|
percent = 100;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int level = (int)(maxBrightness * percent / 100.0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!brightness) {
|
|
|
|
|
|
|
|
kdError() << "Change brightness not supported " << endl;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (currentBrightnessLevel == level) {
|
|
|
|
if (currentBrightnessLevel == level) {
|
|
|
|
kdDebug() << "Brightness level not changed, requested level == current level" << endl;
|
|
|
|
kdDebug() << "Brightness level not changed, requested level == current level" << endl;
|
|
|
@ -1137,35 +1186,11 @@ bool HardwareInfo::setBrightnessUp(int percentageStep) {
|
|
|
|
|
|
|
|
|
|
|
|
checkCurrentBrightness();
|
|
|
|
checkCurrentBrightness();
|
|
|
|
|
|
|
|
|
|
|
|
if (supportBrightness() && (getCurrentBrightnessLevel() >= 0) &&
|
|
|
|
if (supportBrightness() && getCurrentBrightnessLevel() < getMaxBrightnessLevel() &&
|
|
|
|
(getCurrentBrightnessLevel() != (getMaxBrightnessLevel()-1))) {
|
|
|
|
percentageStep > 0)
|
|
|
|
int setTo = 0;
|
|
|
|
{
|
|
|
|
int minPercStep = 10;
|
|
|
|
int currentPerc = (int)(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
int currentPerc = (int)(((float)getCurrentBrightnessLevel()/(float)(getMaxBrightnessLevel()-1))*100.0);
|
|
|
|
retval = setBrightnessPercentage(currentPerc + percentageStep);
|
|
|
|
|
|
|
|
|
|
|
|
if (percentageStep > 0 && (percentageStep <= (100-currentPerc))) {
|
|
|
|
|
|
|
|
minPercStep = percentageStep;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((currentPerc + minPercStep) > 100) {
|
|
|
|
|
|
|
|
// set to 100 %
|
|
|
|
|
|
|
|
setTo = getMaxBrightnessLevel() -1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setTo = (int)(((float)(getMaxBrightnessLevel()-1))*(((float)(currentPerc + minPercStep))/100.0));
|
|
|
|
|
|
|
|
if ((setTo == getCurrentBrightnessLevel()) && (setTo < (getMaxBrightnessLevel() -1))) {
|
|
|
|
|
|
|
|
setTo++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (trace) {
|
|
|
|
|
|
|
|
kdDebug() << "Max: " << getMaxBrightnessLevel()
|
|
|
|
|
|
|
|
<< " Current: " << getCurrentBrightnessLevel()
|
|
|
|
|
|
|
|
<< " minPercStep: " << minPercStep
|
|
|
|
|
|
|
|
<< " currentPerc: " << currentPerc
|
|
|
|
|
|
|
|
<< " setTo: " << setTo << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
retval = setBrightness(setTo, -1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
@ -1186,33 +1211,9 @@ bool HardwareInfo::setBrightnessDown(int percentageStep) {
|
|
|
|
|
|
|
|
|
|
|
|
checkCurrentBrightness();
|
|
|
|
checkCurrentBrightness();
|
|
|
|
|
|
|
|
|
|
|
|
if (supportBrightness() && (getCurrentBrightnessLevel() > 0)) {
|
|
|
|
if (supportBrightness() && getCurrentBrightnessLevel() > 0 && percentageStep > 0) {
|
|
|
|
int setTo = 0;
|
|
|
|
int currentPerc = (int)(100.0 * getCurrentBrightnessLevel() / getMaxBrightnessLevel());
|
|
|
|
int minPercStep = 10;
|
|
|
|
retval = setBrightnessPercentage(currentPerc - percentageStep);
|
|
|
|
int currentPerc = (int)(((float)getCurrentBrightnessLevel()/(float)(getMaxBrightnessLevel()-1))*100.0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (percentageStep > 0 && (percentageStep < currentPerc)) {
|
|
|
|
|
|
|
|
minPercStep = percentageStep;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((currentPerc - minPercStep) < 0) {
|
|
|
|
|
|
|
|
setTo = 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
setTo = (int)(((float)(getMaxBrightnessLevel()-1))*(((float)(currentPerc - minPercStep))/100.0));
|
|
|
|
|
|
|
|
if ((setTo == getCurrentBrightnessLevel()) && (setTo > 0)) {
|
|
|
|
|
|
|
|
setTo--;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (trace) {
|
|
|
|
|
|
|
|
kdDebug() << "Max: " << getMaxBrightnessLevel()
|
|
|
|
|
|
|
|
<< " Current: " << getCurrentBrightnessLevel()
|
|
|
|
|
|
|
|
<< " minPercStep: " << minPercStep
|
|
|
|
|
|
|
|
<< " currentPerc: " << currentPerc
|
|
|
|
|
|
|
|
<< " setTo: " << setTo << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
retval = setBrightness(setTo, -1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|
kdDebugFuncOut(trace);
|
|
|
|