| 1 |
|
| 2 | |
| 3 | * Copyright 2026 Advanced Micro Devices, Inc.
|
| 4 | *
|
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
| 6 | * copy of this software and associated documentation files (the "Software"),
|
| 7 | * to deal in the Software without restriction, including without limitation
|
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
| 9 | * and/or sell copies of the Software, and to permit persons to whom the
|
| 10 | * Software is furnished to do so, subject to the following conditions:
|
| 11 | *
|
| 12 | * The above copyright notice and this permission notice shall be included in
|
| 13 | * all copies or substantial portions of the Software.
|
| 14 | *
|
| 15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
| 18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
| 19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
| 20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
| 21 | * OTHER DEALINGS IN THE SOFTWARE.
|
| 22 |
|
| 23 |
|
| 24 | #ifndef __AMDGPU_DM_BACKLIGHT_H__
|
| 25 | #define __AMDGPU_DM_BACKLIGHT_H__
|
| 26 |
|
| 27 | struct amdgpu_display_manager;
|
| 28 | struct amdgpu_dm_connector;
|
| 29 | struct backlight_device;
|
| 30 | struct backlight_properties;
|
| 31 | struct dc_link;
|
| 32 | struct dc_stream_state;
|
| 33 | struct device;
|
| 34 | struct device_attribute;
|
| 35 | struct drm_connector;
|
| 36 | struct attribute_group;
|
| 37 |
|
| 38 | #define AMDGPU_DM_DEFAULT_MIN_BACKLIGHT 12
|
| 39 | #define AMDGPU_DM_DEFAULT_MAX_BACKLIGHT 255
|
| 40 | #define AMDGPU_DM_MIN_SPREAD ((AMDGPU_DM_DEFAULT_MAX_BACKLIGHT - AMDGPU_DM_DEFAULT_MIN_BACKLIGHT) / 2)
|
| 41 | #define AUX_BL_DEFAULT_TRANSITION_TIME_MS 50
|
| 42 |
|
| 43 | void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm,
|
| 44 | int bl_idx);
|
| 45 | void amdgpu_dm_backlight_set_level(struct amdgpu_display_manager *dm,
|
| 46 | int bl_idx, u32 user_brightness);
|
| 47 | void amdgpu_dm_register_backlight_device(struct amdgpu_dm_connector *aconnector);
|
| 48 | void amdgpu_dm_setup_backlight_device(struct amdgpu_display_manager *dm,
|
| 49 | struct amdgpu_dm_connector *aconnector);
|
| 50 | void amdgpu_dm_update_connector_ext_caps(struct amdgpu_dm_connector *aconnector);
|
| 51 | bool amdgpu_dm_should_create_sysfs(struct amdgpu_dm_connector *aconnector);
|
| 52 |
|
| 53 | extern const struct attribute_group amdgpu_group;
|
| 54 |
|
| 55 | #if IS_ENABLED(CONFIG_DRM_AMD_DC_KUNIT_TEST)
|
| 56 | struct dc_stream_state *dm_find_stream_with_link(struct amdgpu_display_manager *dm,
|
| 57 | struct dc_link *link);
|
| 58 | int amdgpu_dm_backlight_update_status(struct backlight_device *bd);
|
| 59 | u32 amdgpu_dm_backlight_get_level(struct amdgpu_display_manager *dm, int bl_idx);
|
| 60 | int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd);
|
| 61 | ssize_t panel_power_savings_show(struct device *device,
|
| 62 | struct device_attribute *attr,
|
| 63 | char *buf);
|
| 64 | ssize_t panel_power_savings_store(struct device *device,
|
| 65 | struct device_attribute *attr,
|
| 66 | const char *buf, size_t count);
|
| 67 | int get_brightness_range(const struct amdgpu_dm_backlight_caps *caps,
|
| 68 | unsigned int *min, unsigned int *max);
|
| 69 | void convert_custom_brightness(const struct amdgpu_dm_backlight_caps *caps,
|
| 70 | unsigned int min, unsigned int max,
|
| 71 | uint32_t *user_brightness);
|
| 72 | u32 convert_brightness_from_user(const struct amdgpu_dm_backlight_caps *caps,
|
| 73 | uint32_t brightness);
|
| 74 | u32 convert_brightness_to_user(const struct amdgpu_dm_backlight_caps *caps,
|
| 75 | uint32_t brightness);
|
| 76 | int amdgpu_dm_backlight_get_device_index(struct amdgpu_display_manager *dm,
|
| 77 | struct backlight_device *bd);
|
| 78 | void amdgpu_dm_backlight_fill_props(const struct amdgpu_dm_backlight_caps *caps,
|
| 79 | bool is_system_supplied,
|
| 80 | bool custom_curve_enabled,
|
| 81 | struct backlight_properties *props);
|
| 82 | uint amdgpu_dm_get_dc_debug_mask(void);
|
| 83 | void amdgpu_dm_set_dc_debug_mask(uint val);
|
| 84 | int amdgpu_dm_get_abm_level_param(void);
|
| 85 | void amdgpu_dm_set_abm_level_param(int val);
|
| 86 | int amdgpu_dm_get_backlight_param(void);
|
| 87 | void amdgpu_dm_set_backlight_param(int val);
|
| 88 | #endif
|
| 89 |
|
| 90 | #endif
|