mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
Merge tag 'v5.9-rc4' into drm-next
Backmerge 5.9-rc4 as there is a nasty qxl conflict that needs to be resolved. Signed-off-by: Dave Airlie <airlied@redhat.com>
This commit is contained in:
@@ -2871,12 +2871,18 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
|
||||
&dm_atomic_state_funcs);
|
||||
|
||||
r = amdgpu_display_modeset_create_props(adev);
|
||||
if (r)
|
||||
if (r) {
|
||||
dc_release_state(state->context);
|
||||
kfree(state);
|
||||
return r;
|
||||
}
|
||||
|
||||
r = amdgpu_dm_audio_init(adev);
|
||||
if (r)
|
||||
if (r) {
|
||||
dc_release_state(state->context);
|
||||
kfree(state);
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -2893,6 +2899,8 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)
|
||||
#if defined(CONFIG_ACPI)
|
||||
struct amdgpu_dm_backlight_caps caps;
|
||||
|
||||
memset(&caps, 0, sizeof(caps));
|
||||
|
||||
if (dm->backlight_caps.caps_valid)
|
||||
return;
|
||||
|
||||
@@ -2931,51 +2939,50 @@ static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)
|
||||
return rc ? 0 : 1;
|
||||
}
|
||||
|
||||
static u32 convert_brightness(const struct amdgpu_dm_backlight_caps *caps,
|
||||
const uint32_t user_brightness)
|
||||
static int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
|
||||
unsigned *min, unsigned *max)
|
||||
{
|
||||
u32 min, max, conversion_pace;
|
||||
u32 brightness = user_brightness;
|
||||
|
||||
if (!caps)
|
||||
goto out;
|
||||
return 0;
|
||||
|
||||
if (!caps->aux_support) {
|
||||
max = caps->max_input_signal;
|
||||
min = caps->min_input_signal;
|
||||
/*
|
||||
* The brightness input is in the range 0-255
|
||||
* It needs to be rescaled to be between the
|
||||
* requested min and max input signal
|
||||
* It also needs to be scaled up by 0x101 to
|
||||
* match the DC interface which has a range of
|
||||
* 0 to 0xffff
|
||||
*/
|
||||
conversion_pace = 0x101;
|
||||
brightness =
|
||||
user_brightness
|
||||
* conversion_pace
|
||||
* (max - min)
|
||||
/ AMDGPU_MAX_BL_LEVEL
|
||||
+ min * conversion_pace;
|
||||
if (caps->aux_support) {
|
||||
// Firmware limits are in nits, DC API wants millinits.
|
||||
*max = 1000 * caps->aux_max_input_signal;
|
||||
*min = 1000 * caps->aux_min_input_signal;
|
||||
} else {
|
||||
/* TODO
|
||||
* We are doing a linear interpolation here, which is OK but
|
||||
* does not provide the optimal result. We probably want
|
||||
* something close to the Perceptual Quantizer (PQ) curve.
|
||||
*/
|
||||
max = caps->aux_max_input_signal;
|
||||
min = caps->aux_min_input_signal;
|
||||
|
||||
brightness = (AMDGPU_MAX_BL_LEVEL - user_brightness) * min
|
||||
+ user_brightness * max;
|
||||
// Multiple the value by 1000 since we use millinits
|
||||
brightness *= 1000;
|
||||
brightness = DIV_ROUND_CLOSEST(brightness, AMDGPU_MAX_BL_LEVEL);
|
||||
// Firmware limits are 8-bit, PWM control is 16-bit.
|
||||
*max = 0x101 * caps->max_input_signal;
|
||||
*min = 0x101 * caps->min_input_signal;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
out:
|
||||
return brightness;
|
||||
static u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
|
||||
uint32_t brightness)
|
||||
{
|
||||
unsigned min, max;
|
||||
|
||||
if (!get_brightness_range(caps, &min, &max))
|
||||
return brightness;
|
||||
|
||||
// Rescale 0..255 to min..max
|
||||
return min + DIV_ROUND_CLOSEST((max - min) * brightness,
|
||||
AMDGPU_MAX_BL_LEVEL);
|
||||
}
|
||||
|
||||
static u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
|
||||
uint32_t brightness)
|
||||
{
|
||||
unsigned min, max;
|
||||
|
||||
if (!get_brightness_range(caps, &min, &max))
|
||||
return brightness;
|
||||
|
||||
if (brightness < min)
|
||||
return 0;
|
||||
// Rescale min..max to 0..255
|
||||
return DIV_ROUND_CLOSEST(AMDGPU_MAX_BL_LEVEL * (brightness - min),
|
||||
max - min);
|
||||
}
|
||||
|
||||
static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
|
||||
@@ -2991,7 +2998,7 @@ static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
|
||||
|
||||
link = (struct dc_link *)dm->backlight_link;
|
||||
|
||||
brightness = convert_brightness(&caps, bd->props.brightness);
|
||||
brightness = convert_brightness_from_user(&caps, bd->props.brightness);
|
||||
// Change brightness based on AUX property
|
||||
if (caps.aux_support)
|
||||
return set_backlight_via_aux(link, brightness);
|
||||
@@ -3008,7 +3015,7 @@ static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
|
||||
|
||||
if (ret == DC_ERROR_UNEXPECTED)
|
||||
return bd->props.brightness;
|
||||
return ret;
|
||||
return convert_brightness_to_user(&dm->backlight_caps, ret);
|
||||
}
|
||||
|
||||
static const struct backlight_ops amdgpu_dm_backlight_ops = {
|
||||
|
||||
Reference in New Issue
Block a user