| /*************************************************************************/ /*! |
| @File km_apphint.c |
| @Title Apphint routines |
| @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved |
| @Description Device specific functions |
| @License MIT |
| |
| The contents of this file are subject to the MIT license as set out below. |
| |
| Permission is hereby granted, free of charge, to any person obtaining a copy |
| of this software and associated documentation files (the "Software"), to deal |
| in the Software without restriction, including without limitation the rights |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| copies of the Software, and to permit persons to whom the Software is |
| furnished to do so, subject to the following conditions: |
| |
| The above copyright notice and this permission notice shall be included in |
| all copies or substantial portions of the Software. |
| |
| This License is also included in this distribution in the file called |
| "MIT-COPYING". |
| |
| EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS |
| PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
| BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
| PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR |
| COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| */ /**************************************************************************/ |
| |
| #include <errno.h> |
| #include <stdlib.h> |
| #include <string.h> |
| |
| #include "magma_util/macros.h" |
| |
| extern "C" { |
| /* Common and SO layer */ |
| #include "img_defs.h" |
| |
| /* for action device access */ |
| #include "pvrsrv.h" |
| |
| /* defines for default values */ |
| #include "rgx_fwif.h" |
| |
| #include "km_apphint_defs.h" |
| #include "km_apphint.h" |
| |
| #include "htbuffer_sf.h" |
| #include "htbuffer_types.h" |
| } |
| |
| /* |
| ******************************************************************************* |
| Data types |
| ******************************************************************************/ |
| union apphint_value { |
| IMG_UINT64 UINT64; |
| IMG_UINT32 UINT32; |
| bool BOOL; |
| const IMG_CHAR *STRING; |
| }; |
| |
| struct apphint_action |
| { |
| union apphint_value stored; |
| }; |
| |
| /* |
| ******************************************************************************* |
| Global state |
| ******************************************************************************/ |
| static struct apphint_state |
| { |
| struct apphint_action val[APPHINT_ID_MAX]; |
| |
| } apphint = { |
| /* statically initialise default values to ensure that any module_params |
| * provided on the command line are not overwritten by defaults. |
| */ |
| .val = |
| { |
| #define UINT32Bitfield UINT32 |
| #define UINT32List UINT32 |
| #define X(a, b, c, d, e) { { .b = d } }, |
| APPHINT_LIST_ALL |
| #undef X |
| #undef UINT32Bitfield |
| #undef UINT32List |
| }, |
| }; |
| |
| |
| /* |
| ******************************************************************************* |
| Public interface |
| ******************************************************************************/ |
| int |
| pvr_apphint_init(void) |
| { |
| return 0; |
| } |
| |
| int |
| pvr_apphint_device_register(PVRSRV_DEVICE_NODE *device) |
| { |
| return 0; |
| } |
| |
| |
| void |
| pvr_apphint_device_unregister(PVRSRV_DEVICE_NODE *device) |
| { |
| } |
| |
| void |
| pvr_apphint_deinit(void) |
| { |
| } |
| |
| void |
| pvr_apphint_dump_state(void) |
| { |
| } |
| |
| int |
| pvr_apphint_get_uint64(APPHINT_ID apphint_id, IMG_UINT64 *pVal) |
| { |
| DASSERT(apphint_id < APPHINT_ID_MAX); |
| *pVal = apphint.val[apphint_id].stored.UINT64; |
| return 0; |
| } |
| |
| int |
| pvr_apphint_get_uint32(APPHINT_ID apphint_id, IMG_UINT32 *pVal) |
| { |
| DASSERT(apphint_id < APPHINT_ID_MAX); |
| *pVal = apphint.val[apphint_id].stored.UINT32; |
| return 0; |
| } |
| |
| int |
| pvr_apphint_get_bool(APPHINT_ID apphint_id, IMG_BOOL *pVal) |
| { |
| DASSERT(apphint_id < APPHINT_ID_MAX); |
| *pVal = (IMG_BOOL)apphint.val[apphint_id].stored.BOOL; |
| return 0; |
| } |
| |
| int |
| pvr_apphint_get_string(APPHINT_ID apphint_id, IMG_CHAR *pBuffer, size_t size) |
| { |
| DASSERT(apphint_id < APPHINT_ID_MAX); |
| int error = -ERANGE; |
| if (apphint.val[apphint_id].stored.STRING) |
| { |
| if (strlcpy(pBuffer, apphint.val[apphint_id].stored.STRING, size) < size) |
| { |
| error = 0; |
| } |
| } |
| return error; |
| } |
| |
| void |
| pvr_apphint_register_handlers_uint64( |
| APPHINT_ID id, |
| PVRSRV_ERROR (*query)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_UINT64 *value), |
| PVRSRV_ERROR (*set)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_UINT64 value), |
| const PVRSRV_DEVICE_NODE *device, |
| const void *private_data) |
| { |
| // AppHints can't be queryed (from outside the driver) or changed, so the callbacks aren't |
| // used. |
| // TODO(fxbug.dev/13196): Implement. |
| } |
| |
| void |
| pvr_apphint_register_handlers_uint32( |
| APPHINT_ID id, |
| PVRSRV_ERROR (*query)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_UINT32 *value), |
| PVRSRV_ERROR (*set)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_UINT32 value), |
| const PVRSRV_DEVICE_NODE *device, |
| const void *private_data) |
| { |
| // AppHints can't be queryed (from outside the driver) or changed, so the callbacks aren't |
| // used. |
| // TODO(fxbug.dev/13196): Implement. |
| } |
| |
| void |
| pvr_apphint_register_handlers_bool( |
| APPHINT_ID id, |
| PVRSRV_ERROR (*query)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_BOOL *value), |
| PVRSRV_ERROR (*set)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_BOOL value), |
| const PVRSRV_DEVICE_NODE *device, |
| const void *private_data) |
| { |
| // AppHints can't be queryed (from outside the driver) or changed, so the callbacks aren't |
| // used. |
| // TODO(fxbug.dev/13196): Implement. |
| } |
| |
| void |
| pvr_apphint_register_handlers_string( |
| APPHINT_ID id, |
| PVRSRV_ERROR (*query)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_CHAR **value), |
| PVRSRV_ERROR (*set)(const PVRSRV_DEVICE_NODE *device, const void *private_data, IMG_CHAR *value), |
| const PVRSRV_DEVICE_NODE *device, |
| const void *private_data) |
| { |
| // AppHints can't be queryed (from outside the driver) or changed, so the callbacks aren't |
| // used. |
| // TODO(fxbug.dev/13196): Implement. |
| } |
| |
| /* EOF */ |