summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaurabh Bipin Chandra2013-09-05 05:16:56 -0500
committerSaurabh Bipin Chandra2013-09-05 10:44:04 -0500
commita502de00cbe7e704379f6ddbdf6ee3cc2c4f4274 (patch)
treebf587610df3f43149016a713d59b1f19c8f73c25 /libdce_linux.c
parent2cf99e4c810f3fe1eddd1e02469643384002079f (diff)
downloadhardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.tar.gz
hardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.tar.xz
hardware-ti-libdce-a502de00cbe7e704379f6ddbdf6ee3cc2c4f4274.zip
[LINUX] Moving Linux specific functions to new c file
This patch moves Linux specific functions to libdce_linux.c. It also takes in the DRM Initialization cleanup changes in dce_init from: https://gerrit.ext.ti.com/gerrit/omap/#/c/12888 Change-Id: I570341c8dfbe1d120bc89071a86020b6ba5d4cac Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
Diffstat (limited to 'libdce_linux.c')
-rw-r--r--libdce_linux.c133
1 files changed, 133 insertions, 0 deletions
diff --git a/libdce_linux.c b/libdce_linux.c
new file mode 100644
index 0000000..99c8b8d
--- /dev/null
+++ b/libdce_linux.c
@@ -0,0 +1,133 @@
1/*
2 * Copyright (c) 2013, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <stdlib.h>
34#include <string.h>
35#include <stdio.h>
36#include <xdc/std.h>
37
38#include <xf86drm.h>
39#include <omap_drm.h>
40#include <omap_drmif.h>
41
42#include <MmRpc.h>
43#include "dce_priv.h"
44
45#define INVALID_DRM_FD (-1)
46
47int OmapDrm_FD = INVALID_DRM_FD;
48
49void *dce_init(void)
50{
51 struct omap_device *OmapDev = NULL;
52 dce_error_status eError = DCE_EOK;
53
54 printf(" >> dce_init\n");
55
56 /* Open omapdrm device */
57 if( !OmapDrm_FD && OmapDrm_FD == INVALID_DRM_FD ) {
58 printf("Open omapdrm device \n");
59 OmapDrm_FD = drmOpen("omapdrm", "platform:omapdrm:00");
60 _ASSERT(OmapDrm_FD > 0, DCE_EOMAPDRM_FAIL);
61 }
62 OmapDev = omap_device_new(OmapDrm_FD);
63 _ASSERT(OmapDev != NULL, DCE_EOMAPDRM_FAIL);
64
65EXIT:
66 return ((void *)OmapDev);
67}
68
69void dce_deinit(void *dev)
70{
71 omap_device_del(dev);
72 dev = NULL;
73 close(OmapDrm_FD);
74 OmapDrm_FD = INVALID_DRM_FD;
75
76 return;
77}
78
79int dce_buf_lock(int num, size_t *handle)
80{
81 int i;
82 MmRpc_BufDesc *desc = NULL;
83 dce_error_status eError = DCE_EOK;
84
85 _ASSERT(num > 0, DCE_EINVALID_INPUT);
86
87 desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER);
88 _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
89
90 for( i = 0; i < num; i++ ) {
91 desc[i].handle = handle[i];
92 }
93
94 eError = MmRpc_use(MmRpcHandle, MmRpc_BufType_Handle, num, desc);
95
96 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
97EXIT:
98 return (eError);
99}
100
101int dce_buf_unlock(int num, size_t *handle)
102{
103 int i;
104 MmRpc_BufDesc *desc = NULL;
105 dce_error_status eError = DCE_EOK;
106
107 _ASSERT(num > 0, DCE_EINVALID_INPUT);
108
109 desc = memplugin_alloc(num * sizeof(MmRpc_BufDesc), 0, TILER_1D_BUFFER);
110 _ASSERT(desc != NULL, DCE_EOUT_OF_MEMORY);
111
112 for( i = 0; i < num; i++ ) {
113 desc[i].handle = handle[i];
114 }
115
116 eError = MmRpc_release(MmRpcHandle, MmRpc_BufType_Handle, num, desc);
117
118 _ASSERT(eError == DCE_EOK, DCE_EIPC_CALL_FAIL);
119EXIT:
120 return (eError);
121}
122
123/* Incase of X11 or Wayland the fd can be shared to libdce using this call */
124void dce_set_fd(int dce_fd)
125{
126 OmapDrm_FD = dce_fd;
127}
128
129int dce_get_fd(void)
130{
131 return (OmapDrm_FD);
132}
133