radeon_hd : control of brightness
-detect if model > HD600 -apply change by calling ATOM_TRANSMITTER_ACTION_BL_BRIGHTNESS_CONTROL and ATOM_TRANSMITTER_ACTION_LCD_BLON Author : Anarchos <sylvain_kerjean@hotmail.com> Change-Id: I30b9dd66c71e05427b827fc3ef2c7fa6c498646f Reviewed-on: https://review.haiku-os.org/c/haiku/+/2786 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com> Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
parent
7127c048db
commit
69fdc6be3b
@ -38,6 +38,10 @@ status_t radeon_get_pixel_clock_limits(display_mode* mode,
|
|||||||
uint32* low, uint32* high);
|
uint32* low, uint32* high);
|
||||||
status_t radeon_get_edid_info(void* info, size_t size, uint32* edid_version);
|
status_t radeon_get_edid_info(void* info, size_t size, uint32* edid_version);
|
||||||
|
|
||||||
|
//brightness
|
||||||
|
status_t radeon_set_brightness(float brightness);
|
||||||
|
status_t radeon_get_brightness(float* brightness);
|
||||||
|
|
||||||
// accelerant engine
|
// accelerant engine
|
||||||
uint32 radeon_accelerant_engine_count(void);
|
uint32 radeon_accelerant_engine_count(void);
|
||||||
status_t radeon_acquire_engine(uint32 capabilities, uint32 maxWait,
|
status_t radeon_acquire_engine(uint32 capabilities, uint32 maxWait,
|
||||||
|
@ -54,6 +54,10 @@ get_accelerant_hook(uint32 feature, void* data)
|
|||||||
return (void*)radeon_set_display_mode;
|
return (void*)radeon_set_display_mode;
|
||||||
case B_GET_DISPLAY_MODE:
|
case B_GET_DISPLAY_MODE:
|
||||||
return (void*)radeon_get_display_mode;
|
return (void*)radeon_get_display_mode;
|
||||||
|
case B_GET_BRIGHTNESS:
|
||||||
|
return (void*)radeon_get_brightness;
|
||||||
|
case B_SET_BRIGHTNESS:
|
||||||
|
return (void*)radeon_set_brightness;
|
||||||
|
|
||||||
/* memory controller */
|
/* memory controller */
|
||||||
case B_GET_FRAME_BUFFER_CONFIG:
|
case B_GET_FRAME_BUFFER_CONFIG:
|
||||||
|
@ -445,3 +445,66 @@ get_mode_bpp(display_mode* mode)
|
|||||||
__func__);
|
__func__);
|
||||||
return 32;
|
return 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t
|
||||||
|
radeon_get_backlight_register()
|
||||||
|
{
|
||||||
|
// R600 and up is 0x172c else its 0x0018
|
||||||
|
if (gInfo->shared_info->chipsetID >= RADEON_R600)
|
||||||
|
return 0x172c;
|
||||||
|
return 0x0018;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
radeon_set_brightness(float brightness)
|
||||||
|
{
|
||||||
|
TRACE("%s (%f)\n", __func__, brightness);
|
||||||
|
|
||||||
|
if (brightness < 0 || brightness > 1)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
uint32_t backlightReg = radeon_get_backlight_register();
|
||||||
|
uint8_t brightnessRaw = (uint8_t)ceilf(brightness * 255);
|
||||||
|
uint32_t level = Read32(OUT, backlightReg);
|
||||||
|
TRACE("brightness level = %lx\n", level);
|
||||||
|
level &= ~ATOM_S2_CURRENT_BL_LEVEL_MASK;
|
||||||
|
level |= (( brightnessRaw << ATOM_S2_CURRENT_BL_LEVEL_SHIFT )
|
||||||
|
& ATOM_S2_CURRENT_BL_LEVEL_MASK);
|
||||||
|
TRACE("new brightness level = %lx\n", level);
|
||||||
|
|
||||||
|
Write32(OUT, backlightReg, level);
|
||||||
|
|
||||||
|
//TODO crtcID = 0: see create_mode
|
||||||
|
// TODO: multi-monitor? for now we use VESA and not gDisplay edid
|
||||||
|
uint8 crtcID = 0;
|
||||||
|
//TODO : test if it is a LCD ?
|
||||||
|
uint32 connectorIndex = gDisplay[crtcID]->connectorIndex;
|
||||||
|
connector_info* connector = gConnector[connectorIndex];
|
||||||
|
pll_info* pll = &connector->encoder.pll;
|
||||||
|
|
||||||
|
transmitter_dig_setup(connectorIndex, pll->pixelClock,
|
||||||
|
0, 0, ATOM_TRANSMITTER_ACTION_BL_BRIGHTNESS_CONTROL);
|
||||||
|
transmitter_dig_setup(connectorIndex, pll->pixelClock,
|
||||||
|
0, 0, ATOM_TRANSMITTER_ACTION_LCD_BLON);
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
radeon_get_brightness(float* brightness)
|
||||||
|
{
|
||||||
|
TRACE("%s\n", __func__);
|
||||||
|
|
||||||
|
if (brightness == NULL)
|
||||||
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
|
uint32_t backlightReg = Read32(OUT, radeon_get_backlight_register());
|
||||||
|
uint8_t brightnessRaw = ((backlightReg & ATOM_S2_CURRENT_BL_LEVEL_MASK) >>
|
||||||
|
ATOM_S2_CURRENT_BL_LEVEL_SHIFT);
|
||||||
|
*brightness = (float)brightnessRaw / 255;
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user