drm/radeon: rework the backlight control to be an asic callback
This cleans up the interface a bit as well. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
e3a1592085
commit
37e9b6a62f
|
@ -73,7 +73,7 @@ radeon_atom_set_backlight_level_to_reg(struct radeon_device *rdev,
|
|||
}
|
||||
|
||||
void
|
||||
atombios_set_panel_brightness(struct radeon_encoder *radeon_encoder)
|
||||
atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
|
||||
{
|
||||
struct drm_encoder *encoder = &radeon_encoder->base;
|
||||
struct drm_device *dev = radeon_encoder->base.dev;
|
||||
|
@ -82,8 +82,13 @@ atombios_set_panel_brightness(struct radeon_encoder *radeon_encoder)
|
|||
DISPLAY_DEVICE_OUTPUT_CONTROL_PS_ALLOCATION args;
|
||||
int index;
|
||||
|
||||
if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
|
||||
if (!(rdev->mode_info.firmware_flags & ATOM_BIOS_INFO_BL_CONTROLLED_BY_GPU))
|
||||
return;
|
||||
|
||||
if ((radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
|
||||
radeon_encoder->enc_priv) {
|
||||
dig = radeon_encoder->enc_priv;
|
||||
dig->backlight_level = level;
|
||||
radeon_atom_set_backlight_level_to_reg(rdev, dig->backlight_level);
|
||||
|
||||
switch (radeon_encoder->encoder_id) {
|
||||
|
@ -137,11 +142,7 @@ static int radeon_atom_backlight_update_status(struct backlight_device *bd)
|
|||
struct radeon_backlight_privdata *pdata = bl_get_data(bd);
|
||||
struct radeon_encoder *radeon_encoder = pdata->encoder;
|
||||
|
||||
if (radeon_encoder->enc_priv) {
|
||||
struct radeon_encoder_atom_dig *dig = radeon_encoder->enc_priv;
|
||||
dig->backlight_level = radeon_atom_bl_level(bd);
|
||||
atombios_set_panel_brightness(radeon_encoder);
|
||||
}
|
||||
atombios_set_backlight_level(radeon_encoder, radeon_atom_bl_level(bd));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1153,6 +1153,8 @@ struct radeon_asic {
|
|||
u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
|
||||
/* wait for vblank */
|
||||
void (*wait_for_vblank)(struct radeon_device *rdev, int crtc);
|
||||
/* set backlight level */
|
||||
void (*set_backlight_level)(struct radeon_encoder *radeon_encoder, u8 level);
|
||||
} display;
|
||||
/* copy functions for bo handling */
|
||||
struct {
|
||||
|
@ -1461,7 +1463,7 @@ struct radeon_atif {
|
|||
struct radeon_atif_notifications notifications;
|
||||
struct radeon_atif_functions functions;
|
||||
struct radeon_atif_notification_cfg notification_cfg;
|
||||
struct radeon_encoder *backlight_ctl;
|
||||
struct radeon_encoder *encoder_for_bl;
|
||||
};
|
||||
|
||||
struct radeon_atcs_functions {
|
||||
|
@ -1741,6 +1743,7 @@ void radeon_ring_write(struct radeon_ring *ring, uint32_t v);
|
|||
#define radeon_irq_set(rdev) (rdev)->asic->irq.set((rdev))
|
||||
#define radeon_irq_process(rdev) (rdev)->asic->irq.process((rdev))
|
||||
#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->display.get_vblank_counter((rdev), (crtc))
|
||||
#define radeon_set_backlight_level(rdev, e, l) (rdev)->asic->display.set_backlight_level((e), (l))
|
||||
#define radeon_fence_ring_emit(rdev, r, fence) (rdev)->asic->ring[(r)].emit_fence((rdev), (fence))
|
||||
#define radeon_semaphore_ring_emit(rdev, r, cp, semaphore, emit_wait) (rdev)->asic->ring[(r)].emit_semaphore((rdev), (cp), (semaphore), (emit_wait))
|
||||
#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy.blit((rdev), (s), (d), (np), (f))
|
||||
|
|
|
@ -364,19 +364,23 @@ int radeon_atif_handler(struct radeon_device *rdev,
|
|||
DRM_DEBUG_DRIVER("ATIF: %d pending SBIOS requests\n", count);
|
||||
|
||||
if (req.pending & ATIF_PANEL_BRIGHTNESS_CHANGE_REQUEST) {
|
||||
struct radeon_encoder *enc = atif->backlight_ctl;
|
||||
struct radeon_encoder *enc = atif->encoder_for_bl;
|
||||
|
||||
if (enc) {
|
||||
struct radeon_encoder_atom_dig *dig = enc->enc_priv;
|
||||
dig->backlight_level = req.backlight_level;
|
||||
|
||||
DRM_DEBUG_DRIVER("Changing brightness to %d\n",
|
||||
req.backlight_level);
|
||||
|
||||
atombios_set_panel_brightness(enc);
|
||||
radeon_set_backlight_level(rdev, enc, req.backlight_level);
|
||||
|
||||
backlight_force_update(dig->bl_dev,
|
||||
BACKLIGHT_UPDATE_HOTKEY);
|
||||
if (rdev->is_atom_bios) {
|
||||
struct radeon_encoder_atom_dig *dig = enc->enc_priv;
|
||||
backlight_force_update(dig->bl_dev,
|
||||
BACKLIGHT_UPDATE_HOTKEY);
|
||||
} else {
|
||||
struct radeon_encoder_lvds *dig = enc->enc_priv;
|
||||
backlight_force_update(dig->bl_dev,
|
||||
BACKLIGHT_UPDATE_HOTKEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* TODO: check other events */
|
||||
|
@ -577,16 +581,26 @@ int radeon_acpi_init(struct radeon_device *rdev)
|
|||
list_for_each_entry(tmp, &rdev->ddev->mode_config.encoder_list,
|
||||
head) {
|
||||
struct radeon_encoder *enc = to_radeon_encoder(tmp);
|
||||
struct radeon_encoder_atom_dig *dig = enc->enc_priv;
|
||||
|
||||
if ((enc->devices & (ATOM_DEVICE_LCD_SUPPORT)) &&
|
||||
dig->bl_dev != NULL) {
|
||||
target = enc;
|
||||
break;
|
||||
enc->enc_priv) {
|
||||
if (rdev->is_atom_bios) {
|
||||
struct radeon_encoder_atom_dig *dig = enc->enc_priv;
|
||||
if (dig->bl_dev) {
|
||||
target = enc;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
struct radeon_encoder_lvds *dig = enc->enc_priv;
|
||||
if (dig->bl_dev) {
|
||||
target = enc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
atif->backlight_ctl = target;
|
||||
atif->encoder_for_bl = target;
|
||||
if (!target) {
|
||||
/* Brightness change notification is enabled, but we
|
||||
* didn't find a backlight controller, this should
|
||||
|
|
|
@ -198,6 +198,7 @@ static struct radeon_asic r100_asic = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &radeon_legacy_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -272,6 +273,7 @@ static struct radeon_asic r200_asic = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &radeon_legacy_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -346,6 +348,7 @@ static struct radeon_asic r300_asic = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &radeon_legacy_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -420,6 +423,7 @@ static struct radeon_asic r300_asic_pcie = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &radeon_legacy_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -494,6 +498,7 @@ static struct radeon_asic r420_asic = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -568,6 +573,7 @@ static struct radeon_asic rs400_asic = {
|
|||
.bandwidth_update = &r100_bandwidth_update,
|
||||
.get_vblank_counter = &r100_get_vblank_counter,
|
||||
.wait_for_vblank = &r100_wait_for_vblank,
|
||||
.set_backlight_level = &radeon_legacy_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -642,6 +648,7 @@ static struct radeon_asic rs600_asic = {
|
|||
.bandwidth_update = &rs600_bandwidth_update,
|
||||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -716,6 +723,7 @@ static struct radeon_asic rs690_asic = {
|
|||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.bandwidth_update = &rs690_bandwidth_update,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -790,6 +798,7 @@ static struct radeon_asic rv515_asic = {
|
|||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.bandwidth_update = &rv515_bandwidth_update,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -864,6 +873,7 @@ static struct radeon_asic r520_asic = {
|
|||
.bandwidth_update = &rv515_bandwidth_update,
|
||||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r100_copy_blit,
|
||||
|
@ -937,6 +947,7 @@ static struct radeon_asic r600_asic = {
|
|||
.bandwidth_update = &rv515_bandwidth_update,
|
||||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1010,6 +1021,7 @@ static struct radeon_asic rs780_asic = {
|
|||
.bandwidth_update = &rs690_bandwidth_update,
|
||||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1083,6 +1095,7 @@ static struct radeon_asic rv770_asic = {
|
|||
.bandwidth_update = &rv515_bandwidth_update,
|
||||
.get_vblank_counter = &rs600_get_vblank_counter,
|
||||
.wait_for_vblank = &avivo_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1156,6 +1169,7 @@ static struct radeon_asic evergreen_asic = {
|
|||
.bandwidth_update = &evergreen_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1229,6 +1243,7 @@ static struct radeon_asic sumo_asic = {
|
|||
.bandwidth_update = &evergreen_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1302,6 +1317,7 @@ static struct radeon_asic btc_asic = {
|
|||
.bandwidth_update = &evergreen_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1406,6 +1422,7 @@ static struct radeon_asic cayman_asic = {
|
|||
.bandwidth_update = &evergreen_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1500,6 +1517,7 @@ static struct radeon_asic trinity_asic = {
|
|||
.bandwidth_update = &dce6_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = &r600_copy_blit,
|
||||
|
@ -1604,6 +1622,7 @@ static struct radeon_asic si_asic = {
|
|||
.bandwidth_update = &dce6_bandwidth_update,
|
||||
.get_vblank_counter = &evergreen_get_vblank_counter,
|
||||
.wait_for_vblank = &dce4_wait_for_vblank,
|
||||
.set_backlight_level = &atombios_set_backlight_level,
|
||||
},
|
||||
.copy = {
|
||||
.blit = NULL,
|
||||
|
@ -1697,6 +1716,7 @@ int radeon_asic_init(struct radeon_device *rdev)
|
|||
rdev->asic->pm.set_engine_clock = &radeon_legacy_set_engine_clock;
|
||||
rdev->asic->pm.get_memory_clock = &radeon_legacy_get_memory_clock;
|
||||
rdev->asic->pm.set_memory_clock = NULL;
|
||||
rdev->asic->display.set_backlight_level = &radeon_legacy_set_backlight_level;
|
||||
}
|
||||
break;
|
||||
case CHIP_RS400:
|
||||
|
|
|
@ -42,6 +42,10 @@ uint32_t radeon_atom_get_memory_clock(struct radeon_device *rdev);
|
|||
void radeon_atom_set_memory_clock(struct radeon_device *rdev, uint32_t mem_clock);
|
||||
void radeon_atom_set_clock_gating(struct radeon_device *rdev, int enable);
|
||||
|
||||
void atombios_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level);
|
||||
void radeon_legacy_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level);
|
||||
|
||||
|
||||
/*
|
||||
* r100,rv100,rs100,rv200,rs200
|
||||
*/
|
||||
|
|
|
@ -290,10 +290,9 @@ static uint8_t radeon_legacy_lvds_level(struct backlight_device *bd)
|
|||
return level;
|
||||
}
|
||||
|
||||
static int radeon_legacy_backlight_update_status(struct backlight_device *bd)
|
||||
void
|
||||
radeon_legacy_set_backlight_level(struct radeon_encoder *radeon_encoder, u8 level)
|
||||
{
|
||||
struct radeon_backlight_privdata *pdata = bl_get_data(bd);
|
||||
struct radeon_encoder *radeon_encoder = pdata->encoder;
|
||||
struct drm_device *dev = radeon_encoder->base.dev;
|
||||
struct radeon_device *rdev = dev->dev_private;
|
||||
int dpms_mode = DRM_MODE_DPMS_ON;
|
||||
|
@ -301,19 +300,31 @@ static int radeon_legacy_backlight_update_status(struct backlight_device *bd)
|
|||
if (radeon_encoder->enc_priv) {
|
||||
if (rdev->is_atom_bios) {
|
||||
struct radeon_encoder_atom_dig *lvds = radeon_encoder->enc_priv;
|
||||
dpms_mode = lvds->dpms_mode;
|
||||
lvds->backlight_level = radeon_legacy_lvds_level(bd);
|
||||
if (lvds->backlight_level > 0)
|
||||
dpms_mode = lvds->dpms_mode;
|
||||
else
|
||||
dpms_mode = DRM_MODE_DPMS_OFF;
|
||||
lvds->backlight_level = level;
|
||||
} else {
|
||||
struct radeon_encoder_lvds *lvds = radeon_encoder->enc_priv;
|
||||
dpms_mode = lvds->dpms_mode;
|
||||
lvds->backlight_level = radeon_legacy_lvds_level(bd);
|
||||
if (lvds->backlight_level > 0)
|
||||
dpms_mode = lvds->dpms_mode;
|
||||
else
|
||||
dpms_mode = DRM_MODE_DPMS_OFF;
|
||||
lvds->backlight_level = level;
|
||||
}
|
||||
}
|
||||
|
||||
if (bd->props.brightness > 0)
|
||||
radeon_legacy_lvds_update(&radeon_encoder->base, dpms_mode);
|
||||
else
|
||||
radeon_legacy_lvds_update(&radeon_encoder->base, DRM_MODE_DPMS_OFF);
|
||||
radeon_legacy_lvds_update(&radeon_encoder->base, dpms_mode);
|
||||
}
|
||||
|
||||
static int radeon_legacy_backlight_update_status(struct backlight_device *bd)
|
||||
{
|
||||
struct radeon_backlight_privdata *pdata = bl_get_data(bd);
|
||||
struct radeon_encoder *radeon_encoder = pdata->encoder;
|
||||
|
||||
radeon_legacy_set_backlight_level(radeon_encoder,
|
||||
radeon_legacy_lvds_level(bd));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -698,8 +698,6 @@ void radeon_panel_mode_fixup(struct drm_encoder *encoder,
|
|||
struct drm_display_mode *adjusted_mode);
|
||||
void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc);
|
||||
|
||||
void atombios_set_panel_brightness(struct radeon_encoder *radeon_encoder);
|
||||
|
||||
/* legacy tv */
|
||||
void radeon_legacy_tv_adjust_crtc_reg(struct drm_encoder *encoder,
|
||||
uint32_t *h_total_disp, uint32_t *h_sync_strt_wid,
|
||||
|
|
Loading…
Reference in New Issue