1 /*************************************************************************/ /*!
3 @Title RGX Register configuration
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description RGX Regconfig routines
6 @License Dual MIT/GPLv2
8 The contents of this file are subject to the MIT license as set out below.
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
32 This License is also included in this distribution in the file called
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
44 #include "rgxregconfig.h"
45 #include "pvr_debug.h"
47 #include "rgxfwutils.h"
49 #include "sync_internal.h"
52 PVRSRV_ERROR PVRSRVRGXSetRegConfigTypeKM(CONNECTION_DATA * psDevConnection,
53 PVRSRV_DEVICE_NODE *psDeviceNode,
54 IMG_UINT8 ui8RegCfgType)
56 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
57 PVRSRV_ERROR eError = PVRSRV_OK;
58 PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
59 RGX_REG_CONFIG *psRegCfg = &psDevInfo->sRegCongfig;
60 RGXFWIF_REG_CFG_TYPE eRegCfgType = (RGXFWIF_REG_CFG_TYPE) ui8RegCfgType;
62 PVR_UNREFERENCED_PARAMETER(psDevConnection);
64 if (eRegCfgType < psRegCfg->eRegCfgTypeToPush)
66 PVR_DPF((PVR_DBG_ERROR,
67 "PVRSRVRGXSetRegConfigTypeKM: Register configuration requested (%d) is not valid since it has to be at least %d."
68 " Configurations of different types need to go in order",
70 psRegCfg->eRegCfgTypeToPush));
71 return PVRSRV_ERROR_REG_CONFIG_INVALID_TYPE;
74 psRegCfg->eRegCfgTypeToPush = eRegCfgType;
78 PVR_UNREFERENCED_PARAMETER(psDevConnection);
80 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigTypeKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
81 return PVRSRV_ERROR_FEATURE_DISABLED;
85 PVRSRV_ERROR PVRSRVRGXAddRegConfigKM(CONNECTION_DATA * psConnection,
86 PVRSRV_DEVICE_NODE *psDeviceNode,
87 IMG_UINT32 ui32RegAddr,
88 IMG_UINT64 ui64RegValue,
89 IMG_UINT64 ui64RegMask)
91 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
92 PVRSRV_ERROR eError = PVRSRV_OK;
93 RGXFWIF_KCCB_CMD sRegCfgCmd;
94 PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
95 RGX_REG_CONFIG *psRegCfg = &psDevInfo->sRegCongfig;
97 PVR_UNREFERENCED_PARAMETER(psConnection);
99 if (psRegCfg->bEnabled)
101 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXAddRegConfigKM: Cannot add record whilst register configuration active."));
102 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
104 if (psRegCfg->ui32NumRegRecords == RGXFWIF_REG_CFG_MAX_SIZE)
106 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXAddRegConfigKM: Register configuration full."));
107 return PVRSRV_ERROR_REG_CONFIG_FULL;
110 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
111 sRegCfgCmd.uCmdData.sRegConfigData.sRegConfig.ui64Addr = (IMG_UINT64) ui32RegAddr;
112 sRegCfgCmd.uCmdData.sRegConfigData.sRegConfig.ui64Value = ui64RegValue;
113 sRegCfgCmd.uCmdData.sRegConfigData.sRegConfig.ui64Mask = ui64RegMask;
114 sRegCfgCmd.uCmdData.sRegConfigData.eRegConfigType = psRegCfg->eRegCfgTypeToPush;
115 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_ADD;
117 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
122 PDUMP_FLAGS_CONTINUOUS);
123 if (eError != PVRSRV_OK)
125 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXAddRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
129 psRegCfg->ui32NumRegRecords++;
133 PVR_UNREFERENCED_PARAMETER(psConnection);
135 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXSetRegConfigPIKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
136 return PVRSRV_ERROR_FEATURE_DISABLED;
140 PVRSRV_ERROR PVRSRVRGXClearRegConfigKM(CONNECTION_DATA * psConnection,
141 PVRSRV_DEVICE_NODE *psDeviceNode)
143 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
144 PVRSRV_ERROR eError = PVRSRV_OK;
145 RGXFWIF_KCCB_CMD sRegCfgCmd;
146 PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
147 RGX_REG_CONFIG *psRegCfg = &psDevInfo->sRegCongfig;
149 PVR_UNREFERENCED_PARAMETER(psConnection);
151 if (psRegCfg->bEnabled)
153 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: Attempt to clear register configuration whilst active."));
154 return PVRSRV_ERROR_REG_CONFIG_ENABLED;
157 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
158 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_CLEAR;
160 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
165 PDUMP_FLAGS_CONTINUOUS);
166 if (eError != PVRSRV_OK)
168 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
172 psRegCfg->ui32NumRegRecords = 0;
173 psRegCfg->eRegCfgTypeToPush = RGXFWIF_REG_CFG_TYPE_PWR_ON;
177 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXClearRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
179 PVR_UNREFERENCED_PARAMETER(psConnection);
181 return PVRSRV_ERROR_FEATURE_DISABLED;
185 PVRSRV_ERROR PVRSRVRGXEnableRegConfigKM(CONNECTION_DATA * psConnection,
186 PVRSRV_DEVICE_NODE *psDeviceNode)
188 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
189 PVRSRV_ERROR eError = PVRSRV_OK;
190 RGXFWIF_KCCB_CMD sRegCfgCmd;
191 PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
192 RGX_REG_CONFIG *psRegCfg = &psDevInfo->sRegCongfig;
194 PVR_UNREFERENCED_PARAMETER(psConnection);
196 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
197 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_ENABLE;
199 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
204 PDUMP_FLAGS_CONTINUOUS);
205 if (eError != PVRSRV_OK)
207 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
211 psRegCfg->bEnabled = IMG_TRUE;
215 PVR_UNREFERENCED_PARAMETER(psConnection);
217 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXEnableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
218 return PVRSRV_ERROR_FEATURE_DISABLED;
222 PVRSRV_ERROR PVRSRVRGXDisableRegConfigKM(CONNECTION_DATA * psConnection,
223 PVRSRV_DEVICE_NODE *psDeviceNode)
225 #if defined(SUPPORT_USER_REGISTER_CONFIGURATION)
226 PVRSRV_ERROR eError = PVRSRV_OK;
227 RGXFWIF_KCCB_CMD sRegCfgCmd;
228 PVRSRV_RGXDEV_INFO *psDevInfo = psDeviceNode->pvDevice;
229 RGX_REG_CONFIG *psRegCfg = &psDevInfo->sRegCongfig;
231 PVR_UNREFERENCED_PARAMETER(psConnection);
233 sRegCfgCmd.eCmdType = RGXFWIF_KCCB_CMD_REGCONFIG;
234 sRegCfgCmd.uCmdData.sRegConfigData.eCmdType = RGXFWIF_REGCFG_CMD_DISABLE;
236 eError = RGXScheduleCommand(psDeviceNode->pvDevice,
241 PDUMP_FLAGS_CONTINUOUS);
242 if (eError != PVRSRV_OK)
244 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: RGXScheduleCommand failed. Error:%u", eError));
248 psRegCfg->bEnabled = IMG_FALSE;
252 PVR_DPF((PVR_DBG_ERROR, "PVRSRVRGXDisableRegConfigKM: Feature disabled. Compile with SUPPORT_USER_REGISTER_CONFIGURATION"));
253 PVR_UNREFERENCED_PARAMETER(psConnection);
255 return PVRSRV_ERROR_FEATURE_DISABLED;
260 /******************************************************************************
261 End of file (rgxregconfig.c)
262 ******************************************************************************/