1d722e3fbSopenharmony_ci/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */ 2d722e3fbSopenharmony_ci 3d722e3fbSopenharmony_ci/* 4d722e3fbSopenharmony_ci * Copyright (C) 2013 Rob Clark <robclark@freedesktop.org> 5d722e3fbSopenharmony_ci * 6d722e3fbSopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7d722e3fbSopenharmony_ci * copy of this software and associated documentation files (the "Software"), 8d722e3fbSopenharmony_ci * to deal in the Software without restriction, including without limitation 9d722e3fbSopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10d722e3fbSopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 11d722e3fbSopenharmony_ci * Software is furnished to do so, subject to the following conditions: 12d722e3fbSopenharmony_ci * 13d722e3fbSopenharmony_ci * The above copyright notice and this permission notice (including the next 14d722e3fbSopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 15d722e3fbSopenharmony_ci * Software. 16d722e3fbSopenharmony_ci * 17d722e3fbSopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18d722e3fbSopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19d722e3fbSopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20d722e3fbSopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21d722e3fbSopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22d722e3fbSopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23d722e3fbSopenharmony_ci * SOFTWARE. 24d722e3fbSopenharmony_ci * 25d722e3fbSopenharmony_ci * Authors: 26d722e3fbSopenharmony_ci * Rob Clark <robclark@freedesktop.org> 27d722e3fbSopenharmony_ci */ 28d722e3fbSopenharmony_ci 29d722e3fbSopenharmony_ci#include <sys/types.h> 30d722e3fbSopenharmony_ci#include <sys/stat.h> 31d722e3fbSopenharmony_ci#include <unistd.h> 32d722e3fbSopenharmony_ci 33d722e3fbSopenharmony_ci#include "kgsl_priv.h" 34d722e3fbSopenharmony_ci 35d722e3fbSopenharmony_cistatic void kgsl_device_destroy(struct fd_device *dev) 36d722e3fbSopenharmony_ci{ 37d722e3fbSopenharmony_ci struct kgsl_device *kgsl_dev = to_kgsl_device(dev); 38d722e3fbSopenharmony_ci free(kgsl_dev); 39d722e3fbSopenharmony_ci} 40d722e3fbSopenharmony_ci 41d722e3fbSopenharmony_cistatic const struct fd_device_funcs funcs = { 42d722e3fbSopenharmony_ci .bo_new_handle = kgsl_bo_new_handle, 43d722e3fbSopenharmony_ci .bo_from_handle = kgsl_bo_from_handle, 44d722e3fbSopenharmony_ci .pipe_new = kgsl_pipe_new, 45d722e3fbSopenharmony_ci .destroy = kgsl_device_destroy, 46d722e3fbSopenharmony_ci}; 47d722e3fbSopenharmony_ci 48d722e3fbSopenharmony_cidrm_private struct fd_device * kgsl_device_new(int fd) 49d722e3fbSopenharmony_ci{ 50d722e3fbSopenharmony_ci struct kgsl_device *kgsl_dev; 51d722e3fbSopenharmony_ci struct fd_device *dev; 52d722e3fbSopenharmony_ci 53d722e3fbSopenharmony_ci kgsl_dev = calloc(1, sizeof(*kgsl_dev)); 54d722e3fbSopenharmony_ci if (!kgsl_dev) 55d722e3fbSopenharmony_ci return NULL; 56d722e3fbSopenharmony_ci 57d722e3fbSopenharmony_ci dev = &kgsl_dev->base; 58d722e3fbSopenharmony_ci dev->funcs = &funcs; 59d722e3fbSopenharmony_ci 60d722e3fbSopenharmony_ci dev->bo_size = sizeof(struct kgsl_bo); 61d722e3fbSopenharmony_ci 62d722e3fbSopenharmony_ci return dev; 63d722e3fbSopenharmony_ci} 64