hrev43468 adds 1 changeset to branch 'master' old head: 34b63b5b9daa0796faf1a53b3f9594bc025f2cc4 new head: dc0d01abcdc64458f3d8b4965322b56474370d7f ---------------------------------------------------------------------------- dc0d01a: Cleanup. Move unions into functions that use them. * Rename unions to match style guide lines * Group things that make sense together * Move AtomBIOS argument struct creation closer to what uses it [ Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> ] ---------------------------------------------------------------------------- Revision: hrev43468 Commit: dc0d01abcdc64458f3d8b4965322b56474370d7f URL: http://cgit.haiku-os.org/haiku/commit/?id=dc0d01a Author: Alexander von Gluck IV <kallisti5@xxxxxxxxxxx> Date: Sat Dec 10 23:52:31 2011 UTC ---------------------------------------------------------------------------- 3 files changed, 93 insertions(+), 105 deletions(-) src/add-ons/accelerants/radeon_hd/connector.cpp | 35 +++---- src/add-ons/accelerants/radeon_hd/encoder.cpp | 97 +++++++++---------- src/add-ons/accelerants/radeon_hd/pll.cpp | 66 ++++++------- ---------------------------------------------------------------------------- diff --git a/src/add-ons/accelerants/radeon_hd/connector.cpp b/src/add-ons/accelerants/radeon_hd/connector.cpp index a7e438f..54963d2 100644 --- a/src/add-ons/accelerants/radeon_hd/connector.cpp +++ b/src/add-ons/accelerants/radeon_hd/connector.cpp @@ -31,12 +31,6 @@ #define ERROR(x...) _sPrintf("radeon_hd: " x) -union aux_channel_transaction { - PROCESS_AUX_CHANNEL_TRANSACTION_PS_ALLOCATION v1; - PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 v2; -}; - - static int dp_aux_speak(uint32 hwLine, uint8* send, int sendBytes, uint8* recv, int recvBytes, uint8 delay, uint8* ack) @@ -46,14 +40,16 @@ dp_aux_speak(uint32 hwLine, uint8* send, int sendBytes, return B_IO_ERROR; } - union aux_channel_transaction args; int index = GetIndexIntoMasterTable(COMMAND, ProcessAuxChannelTransaction); + // Build AtomBIOS Transaction + union auxChannelTransaction { + PROCESS_AUX_CHANNEL_TRANSACTION_PS_ALLOCATION v1; + PROCESS_AUX_CHANNEL_TRANSACTION_PARAMETERS_V2 v2; + }; + union auxChannelTransaction args; memset(&args, 0, sizeof(args)); - unsigned char* base = (unsigned char*)gAtomContext->scratch; - memcpy(base, send, sendBytes); - args.v1.lpAuxRequest = 0; args.v1.lpDataOut = 16; args.v1.ucDataOutLen = 0; @@ -63,6 +59,9 @@ dp_aux_speak(uint32 hwLine, uint8* send, int sendBytes, //if (ASIC_IS_DCE4(rdev)) // args.v2.ucHPD_ID = chan->rec.hpd; + unsigned char* base = (unsigned char*)gAtomContext->scratch; + memcpy(base, send, sendBytes); + atom_execute_table(gAtomContext, index, (uint32*)&args); *ack = args.v1.ucReplyStatus; @@ -621,13 +620,6 @@ gpio_probe() } -union atom_supported_devices { - struct _ATOM_SUPPORTED_DEVICES_INFO info; - struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; - struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; -}; - - status_t connector_probe_legacy() { @@ -643,8 +635,13 @@ connector_probe_legacy() return B_ERROR; } - union atom_supported_devices* supportedDevices; - supportedDevices = (union atom_supported_devices*) + union atomSupportedDevices { + struct _ATOM_SUPPORTED_DEVICES_INFO info; + struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2; + struct _ATOM_SUPPORTED_DEVICES_INFO_2d1 info_2d1; + }; + union atomSupportedDevices* supportedDevices; + supportedDevices = (union atomSupportedDevices*) (gAtomContext->bios + tableOffset); uint16 deviceSupport diff --git a/src/add-ons/accelerants/radeon_hd/encoder.cpp b/src/add-ons/accelerants/radeon_hd/encoder.cpp index 2a793b9..a8c92a1 100644 --- a/src/add-ons/accelerants/radeon_hd/encoder.cpp +++ b/src/add-ons/accelerants/radeon_hd/encoder.cpp @@ -32,25 +32,16 @@ extern "C" void _sPrintf(const char* format, ...); #define ERROR(x...) _sPrintf("radeon_hd: " x) -union crtc_source_param { - SELECT_CRTC_SOURCE_PS_ALLOCATION v1; - SELECT_CRTC_SOURCE_PARAMETERS_V2 v2; -}; - - void encoder_assign_crtc(uint8 crtcID) { TRACE("%s\n", __func__); + int index = GetIndexIntoMasterTable(COMMAND, SelectCRTC_Source); - union crtc_source_param args; // Table version uint8 tableMajor; uint8 tableMinor; - - memset(&args, 0, sizeof(args)); - if (atom_parse_cmd_header(gAtomContext, index, &tableMajor, &tableMinor) != B_OK) return; @@ -59,6 +50,14 @@ encoder_assign_crtc(uint8 crtcID) uint16 encoderID = gConnector[connectorIndex]->encoder.objectID; uint16 encoderFlags = gConnector[connectorIndex]->encoder.flags; + // Prepare AtomBIOS command arguments + union crtcSourceParam { + SELECT_CRTC_SOURCE_PS_ALLOCATION v1; + SELECT_CRTC_SOURCE_PARAMETERS_V2 v2; + }; + union crtcSourceParam args; + memset(&args, 0, sizeof(args)); + switch (tableMajor) { case 1: switch (tableMinor) { @@ -319,20 +318,11 @@ encoder_tv_setup(uint32 connectorIndex, uint32 pixelClock, int command) } -union lvds_encoder_control { - LVDS_ENCODER_CONTROL_PS_ALLOCATION v1; - LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 v2; -}; - - status_t encoder_digital_setup(uint32 connectorIndex, uint32 pixelClock, int command) { TRACE("%s\n", __func__); - union lvds_encoder_control args; - memset(&args, 0, sizeof(args)); - int index = 0; uint16 encoderFlags = gConnector[connectorIndex]->encoder.flags; @@ -362,6 +352,14 @@ encoder_digital_setup(uint32 connectorIndex, uint32 pixelClock, int command) return B_ERROR; } + // Prepare AtomBIOS command arguments + union lvdsEncoderControl { + LVDS_ENCODER_CONTROL_PS_ALLOCATION v1; + LVDS_ENCODER_CONTROL_PS_ALLOCATION_V2 v2; + }; + union lvdsEncoderControl args; + memset(&args, 0, sizeof(args)); + switch (tableMajor) { case 1: case 2: @@ -447,30 +445,12 @@ encoder_digital_setup(uint32 connectorIndex, uint32 pixelClock, int command) } -union dig_encoder_control { - DIG_ENCODER_CONTROL_PS_ALLOCATION v1; - DIG_ENCODER_CONTROL_PARAMETERS_V2 v2; - DIG_ENCODER_CONTROL_PARAMETERS_V3 v3; - DIG_ENCODER_CONTROL_PARAMETERS_V4 v4; -}; - - status_t encoder_dig_setup(uint32 connectorIndex, uint32 pixelClock, int command) { radeon_shared_info &info = *gInfo->shared_info; - uint32 encoderID = gConnector[connectorIndex]->encoder.objectID; - - union dig_encoder_control args; int index = 0; - - // Table verson - uint8 tableMajor; - uint8 tableMinor; - - memset(&args, 0, sizeof(args)); - if (info.dceMajor > 4) index = GetIndexIntoMasterTable(COMMAND, DIGxEncoderControl); else { @@ -480,15 +460,31 @@ encoder_dig_setup(uint32 connectorIndex, uint32 pixelClock, int command) index = GetIndexIntoMasterTable(COMMAND, DIG2EncoderControl); } + // Table verson + uint8 tableMajor; + uint8 tableMinor; + if (atom_parse_cmd_header(gAtomContext, index, &tableMajor, &tableMinor) != B_OK) { ERROR("%s: cannot parse command table\n", __func__); return B_ERROR; } + // Prepare AtomBIOS command arguments + union digEncoderControl { + DIG_ENCODER_CONTROL_PS_ALLOCATION v1; + DIG_ENCODER_CONTROL_PARAMETERS_V2 v2; + DIG_ENCODER_CONTROL_PARAMETERS_V3 v3; + DIG_ENCODER_CONTROL_PARAMETERS_V4 v4; + }; + union digEncoderControl args; + memset(&args, 0, sizeof(args)); + args.v1.ucAction = command; args.v1.usPixelClock = B_HOST_TO_LENDIAN_INT16(pixelClock / 10); + uint32 encoderID = gConnector[connectorIndex]->encoder.objectID; + #if 0 if (command == ATOM_ENCODER_CMD_SETUP_PANEL_MODE) { if (info.dceMajor >= 4 && 0) // TODO: 0 == if DP bridge @@ -605,34 +601,33 @@ encoder_dig_setup(uint32 connectorIndex, uint32 pixelClock, int command) } -union external_encoder_control { - EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION v1; - EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION_V3 v3; -}; - - status_t encoder_external_setup(uint32 connectorIndex, uint32 pixelClock, int command) { TRACE("%s\n", __func__); - int index = GetIndexIntoMasterTable(COMMAND, ExternalEncoderControl); - union external_encoder_control args; - memset(&args, 0, sizeof(args)); - - int connectorObjectID - = (gConnector[connectorIndex]->objectID & OBJECT_ID_MASK) - >> OBJECT_ID_SHIFT; - uint8 tableMajor; uint8 tableMinor; + int index = GetIndexIntoMasterTable(COMMAND, ExternalEncoderControl); if (atom_parse_cmd_header(gAtomContext, index, &tableMajor, &tableMinor) != B_OK) { ERROR("%s: Error parsing ExternalEncoderControl table\n", __func__); return B_ERROR; } + // Prepare AtomBIOS command arguments + union externalEncoderControl { + EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION v1; + EXTERNAL_ENCODER_CONTROL_PS_ALLOCATION_V3 v3; + }; + union externalEncoderControl args; + memset(&args, 0, sizeof(args)); + + int connectorObjectID + = (gConnector[connectorIndex]->objectID & OBJECT_ID_MASK) + >> OBJECT_ID_SHIFT; + switch (tableMajor) { case 1: // no options needed on table 1.x diff --git a/src/add-ons/accelerants/radeon_hd/pll.cpp b/src/add-ons/accelerants/radeon_hd/pll.cpp index dc09dcc..67242ab 100644 --- a/src/add-ons/accelerants/radeon_hd/pll.cpp +++ b/src/add-ons/accelerants/radeon_hd/pll.cpp @@ -32,32 +32,30 @@ extern "C" void _sPrintf(const char* format, ...); #define ERROR(x...) _sPrintf("radeon_hd: " x) -union firmware_info { - ATOM_FIRMWARE_INFO info; - ATOM_FIRMWARE_INFO_V1_2 info_12; - ATOM_FIRMWARE_INFO_V1_3 info_13; - ATOM_FIRMWARE_INFO_V1_4 info_14; - ATOM_FIRMWARE_INFO_V2_1 info_21; - ATOM_FIRMWARE_INFO_V2_2 info_22; -}; - - status_t pll_limit_probe(pll_info* pll) { - int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); uint8 tableMajor; uint8 tableMinor; uint16 tableOffset; + int index = GetIndexIntoMasterTable(DATA, FirmwareInfo); if (atom_parse_data_header(gAtomContext, index, NULL, &tableMajor, &tableMinor, &tableOffset) != B_OK) { ERROR("%s: Couldn't parse data header\n", __func__); return B_ERROR; } - union firmware_info* firmwareInfo - = (union firmware_info*)(gAtomContext->bios + tableOffset); + union atomFirmwareInfo { + ATOM_FIRMWARE_INFO info; + ATOM_FIRMWARE_INFO_V1_2 info_12; + ATOM_FIRMWARE_INFO_V1_3 info_13; + ATOM_FIRMWARE_INFO_V1_4 info_14; + ATOM_FIRMWARE_INFO_V2_1 info_21; + ATOM_FIRMWARE_INFO_V2_2 info_22; + }; + union atomFirmwareInfo* firmwareInfo + = (union atomFirmwareInfo*)(gAtomContext->bios + tableOffset); /* pixel clock limits */ pll->referenceFreq @@ -284,12 +282,6 @@ pll_compute(pll_info* pll) } -union adjust_pixel_clock { - ADJUST_DISPLAY_PLL_PS_ALLOCATION v1; - ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3 v3; -}; - - void pll_setup_flags(pll_info* pll, uint8 crtcID) { @@ -350,19 +342,24 @@ pll_adjust(pll_info* pll, uint8 crtcID) if (info.dceMajor >= 3) { - union adjust_pixel_clock args; uint8 tableMajor; uint8 tableMinor; int index = GetIndexIntoMasterTable(COMMAND, AdjustDisplayPll); - if (atom_parse_cmd_header(gAtomContext, index, &tableMajor, &tableMinor) != B_OK) { return B_ERROR; } + // Prepare arguments for AtomBIOS call + union adjustPixelClock { + ADJUST_DISPLAY_PLL_PS_ALLOCATION v1; + ADJUST_DISPLAY_PLL_PS_ALLOCATION_V3 v3; + }; + union adjustPixelClock args; memset(&args, 0, sizeof(args)); + switch (tableMajor) { case 1: switch (tableMinor) { @@ -471,16 +468,6 @@ pll_adjust(pll_info* pll, uint8 crtcID) } -union set_pixel_clock { - SET_PIXEL_CLOCK_PS_ALLOCATION base; - PIXEL_CLOCK_PARAMETERS v1; - PIXEL_CLOCK_PARAMETERS_V2 v2; - PIXEL_CLOCK_PARAMETERS_V3 v3; - PIXEL_CLOCK_PARAMETERS_V5 v5; - PIXEL_CLOCK_PARAMETERS_V6 v6; -}; - - status_t pll_set(uint8 pllID, uint32 pixelClock, uint8 crtcID) { @@ -497,19 +484,28 @@ pll_set(uint8 pllID, uint32 pixelClock, uint8 crtcID) pll_compute(pll); // compute dividers - int index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); - union set_pixel_clock args; - memset(&args, 0, sizeof(args)); - uint8 tableMajor; uint8 tableMinor; + int index = GetIndexIntoMasterTable(COMMAND, SetPixelClock); atom_parse_cmd_header(gAtomContext, index, &tableMajor, &tableMinor); uint32 bitsPerChannel = 8; // TODO: Digital Depth, EDID 1.4+ on digital displays // isn't in Haiku edid common code? + // Prepare arguments for AtomBIOS call + union setPixelClock { + SET_PIXEL_CLOCK_PS_ALLOCATION base; + PIXEL_CLOCK_PARAMETERS v1; + PIXEL_CLOCK_PARAMETERS_V2 v2; + PIXEL_CLOCK_PARAMETERS_V3 v3; + PIXEL_CLOCK_PARAMETERS_V5 v5; + PIXEL_CLOCK_PARAMETERS_V6 v6; + }; + union setPixelClock args; + memset(&args, 0, sizeof(args)); + switch (tableMinor) { case 1: args.v1.usPixelClock