summaryrefslogtreecommitdiff
path: root/drivers/mxc/gpu-viv/hal/kernel
diff options
context:
space:
mode:
authorYong Gan <yong.gan@nxp.com>2018-04-18 07:20:55 +0800
committerLeonard Crestez <leonard.crestez@nxp.com>2018-08-24 12:41:33 +0300
commitca6e99575f120d92e3b201fab9a5e57de42c5aee (patch)
tree322050822efdf54fb4bb8d1b2864f04add5e7efb /drivers/mxc/gpu-viv/hal/kernel
parentedfc91d35b2e7c1f47d6af35777c2ed18e07d507 (diff)
MGS-3694 [#imx-913] enable fb fd and tile status fd in GPU and DCSS on wayland
Save the meta data info in the _gcsVIDMEM_NODE. DCSS can query the meta data, and get the tile statust buffer info. Date: Apr 13, 2018 Signed-off-by: Yong Gan yong.gan@nxp.com
Diffstat (limited to 'drivers/mxc/gpu-viv/hal/kernel')
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c89
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h4
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_metadata.h88
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c4
-rw-r--r--drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h17
5 files changed, 200 insertions, 2 deletions
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c
index 457fc6b62c40..efb015993a57 100644
--- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c
+++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.c
@@ -146,6 +146,7 @@ gctCONST_STRING _DispatchText[] =
gcmDEFINE2TEXT(gcvHAL_DESTROY_MMU),
gcmDEFINE2TEXT(gcvHAL_SHBUF),
gcmDEFINE2TEXT(gcvHAL_GET_GRAPHIC_BUFFER_FD),
+ gcmDEFINE2TEXT(gcvHAL_SET_VIDEO_MEMORY_METADATA),
gcmDEFINE2TEXT(gcvHAL_GET_VIDEO_MEMORY_FD),
gcmDEFINE2TEXT(gcvHAL_CONFIG_POWER_MANAGEMENT),
gcmDEFINE2TEXT(gcvHAL_WRAP_USER_MEMORY),
@@ -1640,6 +1641,90 @@ OnError:
/*******************************************************************************
**
+** gckKERNEL_SetVidMemMetadata
+**
+** Set/Get metadata to/from gckVIDMEM_NODE object.
+**
+** INPUT:
+**
+** gckKERNEL Kernel
+** Pointer to an gckKERNEL object.
+**
+** gctUINT32 ProcessID
+** ProcessID of current process.
+**
+** INOUT:
+**
+** gcsHAL_INTERFACE * Interface
+** Pointer to a interface structure
+*/
+#if defined(CONFIG_DMA_SHARED_BUFFER)
+#include <linux/dma-buf.h>
+
+gceSTATUS
+gckKERNEL_SetVidMemMetadata(
+ IN gckKERNEL Kernel,
+ IN gctUINT32 ProcessID,
+ INOUT gcsHAL_INTERFACE * Interface
+ )
+{
+ gceSTATUS status = gcvSTATUS_NOT_SUPPORTED;
+ gckVIDMEM_NODE nodeObj = gcvNULL;
+
+ gcmkHEADER_ARG("Kernel=0x%X ProcessID=%d", Kernel, ProcessID);
+
+ gcmkONERROR(gckVIDMEM_HANDLE_Lookup(Kernel, ProcessID, Interface->u.SetVidMemMetadata.node, &nodeObj));
+
+ if (Interface->u.SetVidMemMetadata.readback)
+ {
+ Interface->u.SetVidMemMetadata.ts_fd = nodeObj->metadata.ts_fd;
+ Interface->u.SetVidMemMetadata.fc_enabled = nodeObj->metadata.fc_enabled;
+ Interface->u.SetVidMemMetadata.fc_value = nodeObj->metadata.fc_value;
+ Interface->u.SetVidMemMetadata.fc_value_upper = nodeObj->metadata.fc_value_upper;
+ Interface->u.SetVidMemMetadata.compressed = nodeObj->metadata.compressed;
+ Interface->u.SetVidMemMetadata.compress_format = nodeObj->metadata.compress_format;
+ }
+ else
+ {
+ nodeObj->metadata.ts_fd = Interface->u.SetVidMemMetadata.ts_fd;
+ if (nodeObj->metadata.ts_fd > 0)
+ {
+ nodeObj->metadata.ts_dma_buf = dma_buf_get(nodeObj->metadata.ts_fd);
+ if (IS_ERR(nodeObj->metadata.ts_dma_buf))
+ {
+ gcmkONERROR(gcvSTATUS_NOT_FOUND);
+ }
+ dma_buf_put(nodeObj->metadata.ts_dma_buf);
+ }
+ nodeObj->metadata.fc_enabled = Interface->u.SetVidMemMetadata.fc_enabled;
+ nodeObj->metadata.fc_value = Interface->u.SetVidMemMetadata.fc_value;
+ nodeObj->metadata.fc_value_upper = Interface->u.SetVidMemMetadata.fc_value_upper;
+ nodeObj->metadata.compressed = Interface->u.SetVidMemMetadata.compressed;
+ nodeObj->metadata.compress_format = Interface->u.SetVidMemMetadata.compress_format;
+ }
+
+ gcmkFOOTER();
+
+OnError:
+ return status;
+}
+
+#else
+
+gceSTATUS
+gckKERNEL_SetVidMemMetadata(
+ IN gckKERNEL Kernel,
+ IN gctUINT32 ProcessID,
+ INOUT gcsHAL_INTERFACE * Interface
+ )
+{
+ gcmkFATAL("The kernel did NOT support CONFIG_DMA_SHARED_BUFFER");
+ return gcvSTATUS_NOT_SUPPORTED;
+}
+#endif
+
+/*******************************************************************************
+**
** gckKERNEL_QueryVidMemPoolNodes
**
** Loop all databases to query used memory nodes of a specific pool.
@@ -3015,6 +3100,10 @@ gckKERNEL_Dispatch(
0));
break;
+ case gcvHAL_SET_VIDEO_MEMORY_METADATA:
+ gcmkONERROR(gckKERNEL_SetVidMemMetadata(Kernel, processID, Interface));
+ break;
+
case gcvHAL_GET_VIDEO_MEMORY_FD:
gcmkONERROR(gckVIDMEM_NODE_GetFd(
Kernel,
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h
index 438ca886a4b5..9dac34d2fe8f 100644
--- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h
+++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel.h
@@ -59,8 +59,8 @@
#include "gc_hal.h"
#include "gc_hal_kernel_hardware.h"
#include "gc_hal_driver.h"
-
#include "gc_hal_kernel_mutex.h"
+#include "gc_hal_kernel_metadata.h"
#if gcdENABLE_VG
#include "gc_hal_kernel_vg.h"
@@ -1095,6 +1095,8 @@ struct _gckVIDMEM
typedef struct _gcsVIDMEM_NODE
{
+ _VIV_VIDMEM_METADATA metadata;
+
/* Pointer to gcuVIDMEM_NODE. */
gcuVIDMEM_NODE_PTR node;
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_metadata.h b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_metadata.h
new file mode 100644
index 000000000000..55dd82393099
--- /dev/null
+++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_metadata.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+*
+* The MIT License (MIT)
+*
+* Copyright (c) 2014 - 2018 Vivante Corporation
+*
+* 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.
+*
+* 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. 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.
+*
+*****************************************************************************
+*
+* The GPL License (GPL)
+*
+* Copyright (C) 2014 - 2018 Vivante Corporation
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software Foundation,
+* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*
+*****************************************************************************
+*
+* Note: This software is released under dual MIT and GPL licenses. A
+* recipient may use this file under the terms of either the MIT license or
+* GPL License. If you wish to use only one license not the other, you can
+* indicate your decision by deleting one of the above license notices in your
+* version of this file.
+*
+*****************************************************************************/
+
+#ifndef __gc_hal_kernel_metadata_h_
+#define __gc_hal_kernel_metadata_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Macro to combine four characters into a Charcater Code. */
+#define __FOURCC(a, b, c, d) \
+ ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
+
+#define VIV_VIDMEM_METADATA_MAGIC __FOURCC('v', 'i', 'v', 'm')
+
+/* Metadata for cross-device fd share with additional (ts) info. */
+typedef struct _VIV_VIDMEM_METADATA
+{
+ uint32_t magic;
+
+ int32_t ts_fd;
+ void * ts_dma_buf;
+
+ uint32_t fc_enabled;
+ uint32_t fc_value;
+ uint32_t fc_value_upper;
+
+ uint32_t compressed;
+ uint32_t compress_format;
+} _VIV_VIDMEM_METADATA;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gc_hal_kernel_metadata_h_ */
diff --git a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c
index 49adff00c601..c1b6629a9fcf 100644
--- a/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c
+++ b/drivers/mxc/gpu-viv/hal/kernel/gc_hal_kernel_video_memory.c
@@ -2617,6 +2617,9 @@ gckVIDMEM_NODE_Allocate(
node = pointer;
+ node->metadata.magic = VIV_VIDMEM_METADATA_MAGIC;
+ node->metadata.ts_fd = -1;
+
node->node = VideoNode;
node->kernel = Kernel;
node->type = Type;
@@ -3158,7 +3161,6 @@ OnError:
return status;
}
-
typedef struct _gcsVIDMEM_NODE_FDPRIVATE
{
gcsFDPRIVATE base;
diff --git a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h
index b9a812782e4d..69ffbc40a2bd 100644
--- a/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h
+++ b/drivers/mxc/gpu-viv/hal/kernel/inc/gc_hal_driver.h
@@ -226,6 +226,7 @@ typedef enum _gceHAL_COMMAND_CODES
*/
gcvHAL_GET_GRAPHIC_BUFFER_FD,
+ gcvHAL_SET_VIDEO_MEMORY_METADATA,
/* Connect a video node to an OS native fd. */
gcvHAL_GET_VIDEO_MEMORY_FD,
@@ -1243,6 +1244,22 @@ typedef struct _gcsHAL_INTERFACE
}
GetGraphicBufferFd;
+ struct _gcsHAL_VIDEO_MEMORY_METADATA
+ {
+ /* Allocated video memory. */
+ IN gctUINT32 node;
+
+ IN gctUINT32 readback;
+
+ INOUT gctINT32 ts_fd;
+ INOUT gctUINT32 fc_enabled;
+ INOUT gctUINT32 fc_value;
+ INOUT gctUINT32 fc_value_upper;
+
+ INOUT gctUINT32 compressed;
+ INOUT gctUINT32 compress_format;
+ }
+ SetVidMemMetadata;
struct _gcsHAL_GET_VIDEO_MEMORY_FD
{