forked from mirrors/linux
		
	drm/amdgpu: simplify ATIF backlight handling
Just register the a pointer to the backlight device and use that. Unifies the DC and non-DC handling. Acked-by: Evan Quan <evan.quan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
		
							parent
							
								
									ba806f98f8
								
							
						
					
					
						commit
						97d798b276
					
				
					 1 changed files with 29 additions and 42 deletions
				
			
		| 
						 | 
					@ -64,7 +64,9 @@ struct amdgpu_atif {
 | 
				
			||||||
	struct amdgpu_atif_notifications notifications;
 | 
						struct amdgpu_atif_notifications notifications;
 | 
				
			||||||
	struct amdgpu_atif_functions functions;
 | 
						struct amdgpu_atif_functions functions;
 | 
				
			||||||
	struct amdgpu_atif_notification_cfg notification_cfg;
 | 
						struct amdgpu_atif_notification_cfg notification_cfg;
 | 
				
			||||||
	struct amdgpu_encoder *encoder_for_bl;
 | 
					#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
 | 
				
			||||||
 | 
						struct backlight_device *bd;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
	struct amdgpu_dm_backlight_caps backlight_caps;
 | 
						struct amdgpu_dm_backlight_caps backlight_caps;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -444,45 +446,21 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
 | 
							DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ((req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) &&
 | 
							if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
 | 
				
			||||||
		    !amdgpu_device_has_dc_support(adev)) {
 | 
					#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
 | 
				
			||||||
			struct amdgpu_encoder *enc = atif->encoder_for_bl;
 | 
								if (atif->bd) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (enc) {
 | 
					 | 
				
			||||||
				struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				DRM_DEBUG_DRIVER("Changing brightness to %d\n",
 | 
									DRM_DEBUG_DRIVER("Changing brightness to %d\n",
 | 
				
			||||||
						 req.backlight_level);
 | 
											 req.backlight_level);
 | 
				
			||||||
 | 
					 | 
				
			||||||
				amdgpu_display_backlight_set_level(adev, enc, req.backlight_level);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
 | 
					 | 
				
			||||||
				backlight_force_update(dig->bl_dev,
 | 
					 | 
				
			||||||
						       BACKLIGHT_UPDATE_HOTKEY);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
#if defined(CONFIG_DRM_AMD_DC)
 | 
					 | 
				
			||||||
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
 | 
					 | 
				
			||||||
		if ((req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) &&
 | 
					 | 
				
			||||||
		    amdgpu_device_has_dc_support(adev)) {
 | 
					 | 
				
			||||||
			struct amdgpu_display_manager *dm = &adev->dm;
 | 
					 | 
				
			||||||
			struct backlight_device *bd = dm->backlight_dev;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (bd) {
 | 
					 | 
				
			||||||
				DRM_DEBUG_DRIVER("Changing brightness to %d\n",
 | 
					 | 
				
			||||||
						 req.backlight_level);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				/*
 | 
									/*
 | 
				
			||||||
				 * XXX backlight_device_set_brightness() is
 | 
									 * XXX backlight_device_set_brightness() is
 | 
				
			||||||
				 * hardwired to post BACKLIGHT_UPDATE_SYSFS.
 | 
									 * hardwired to post BACKLIGHT_UPDATE_SYSFS.
 | 
				
			||||||
				 * It probably should accept 'reason' parameter.
 | 
									 * It probably should accept 'reason' parameter.
 | 
				
			||||||
				 */
 | 
									 */
 | 
				
			||||||
				backlight_device_set_brightness(bd, req.backlight_level);
 | 
									backlight_device_set_brightness(atif->bd, req.backlight_level);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
#endif
 | 
					
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
 | 
							if (req.pending & ATIF_DGPU_DISPLAY_EVENT) {
 | 
				
			||||||
			if (adev->flags & AMD_IS_PX) {
 | 
								if (adev->flags & AMD_IS_PX) {
 | 
				
			||||||
				pm_runtime_get_sync(adev->ddev->dev);
 | 
									pm_runtime_get_sync(adev->ddev->dev);
 | 
				
			||||||
| 
						 | 
					@ -829,23 +807,32 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
 | 
				
			||||||
	adev->atif = atif;
 | 
						adev->atif = atif;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (atif->notifications.brightness_change) {
 | 
						if (atif->notifications.brightness_change) {
 | 
				
			||||||
		struct drm_encoder *tmp;
 | 
					#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
 | 
				
			||||||
 | 
							if (amdgpu_device_has_dc_support(adev)) {
 | 
				
			||||||
 | 
					#if defined(CONFIG_DRM_AMD_DC)
 | 
				
			||||||
 | 
								struct amdgpu_display_manager *dm = &adev->dm;
 | 
				
			||||||
 | 
								atif->bd = dm->backlight_dev;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								struct drm_encoder *tmp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* Find the encoder controlling the brightness */
 | 
								/* Find the encoder controlling the brightness */
 | 
				
			||||||
		list_for_each_entry(tmp, &adev->ddev->mode_config.encoder_list,
 | 
								list_for_each_entry(tmp, &adev->ddev->mode_config.encoder_list,
 | 
				
			||||||
				head) {
 | 
										    head) {
 | 
				
			||||||
			struct amdgpu_encoder *enc = to_amdgpu_encoder(tmp);
 | 
									struct amdgpu_encoder *enc = to_amdgpu_encoder(tmp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
 | 
									if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
 | 
				
			||||||
			    enc->enc_priv) {
 | 
									    enc->enc_priv) {
 | 
				
			||||||
				struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
 | 
										struct amdgpu_encoder_atom_dig *dig = enc->enc_priv;
 | 
				
			||||||
				if (dig->bl_dev) {
 | 
										if (dig->bl_dev) {
 | 
				
			||||||
					atif->encoder_for_bl = enc;
 | 
											atif->bd = dig->bl_dev;
 | 
				
			||||||
					break;
 | 
											break;
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (atif->functions.sbios_requests && !atif->functions.system_params) {
 | 
						if (atif->functions.sbios_requests && !atif->functions.system_params) {
 | 
				
			||||||
		/* XXX check this workraround, if sbios request function is
 | 
							/* XXX check this workraround, if sbios request function is
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue