1 /**************************************************************************
5 Copyright 2011 Samsung Electronics co., Ltd. All Rights Reserved.
7 Contact: SooChan Lim <sc1.lim@samsung.com>, Sangjin Lee <lsj119@samsung.com>
9 Permission is hereby granted, free of charge, to any person obtaining a
10 copy of this software and associated documentation files (the
11 "Software"), to deal in the Software without restriction, including
12 without limitation the rights to use, copy, modify, merge, publish,
13 distribute, sub license, and/or sell copies of the Software, and to
14 permit persons to whom the Software is furnished to do so, subject to
15 the following conditions:
17 The above copyright notice and this permission notice (including the
18 next paragraph) shall be included in all copies or substantial portions
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
22 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
24 IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
25 ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
26 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 **************************************************************************/
33 #include <sys/types.h>
36 #include "drm_slp_bufmgr.h"
37 #include "tbm_bufmgr.h"
40 drm_slp_bufmgr_init(int fd, void *arg)
42 tbm_bufmgr bufmgr = NULL;
44 bufmgr = tbm_bufmgr_init (fd);
47 fprintf (stderr, "[libdrm_slp:%d]: error bufmgr is null\n", getpid());
51 return (drm_slp_bufmgr)bufmgr;
55 drm_slp_bufmgr_destroy(drm_slp_bufmgr bufmgr)
57 tbm_bufmgr_deinit ((tbm_bufmgr)bufmgr);
61 drm_slp_bo_unref(drm_slp_bo bo)
63 tbm_bo_unref ((tbm_bo)bo);
67 drm_slp_bo_import(drm_slp_bufmgr bufmgr, unsigned int key)
71 bo = tbm_bo_import ((tbm_bufmgr)bufmgr, key);
74 fprintf (stderr, "[libdrm_slp:%d]: error bo is null\n", getpid());
78 return (drm_slp_bo)bo;
82 drm_slp_bo_map(drm_slp_bo bo, int device, int opt)
84 tbm_bo_handle bo_handle;
87 bo_handle = tbm_bo_map ((tbm_bo)bo, device, opt);
88 if (bo_handle.ptr == NULL)
90 fprintf (stderr, "[libdrm_slp:%d]: error bo_handle is null\n", getpid());
96 case TBM_DEVICE_DEFAULT:
100 ret = (unsigned int)bo_handle.u32;
103 ret = (unsigned int)bo_handle.ptr;
106 fprintf (stderr, "[libdrm_slp:%d]: error wrong device type\n", getpid());
114 drm_slp_bo_unmap(drm_slp_bo bo, int device)
116 tbm_bo_unmap ((tbm_bo)bo);