Path: blob/21.2-virgl/src/gallium/auxiliary/vl/vl_winsys_drm.c
4565 views
/**************************************************************************1*2* Copyright 2015 Advanced Micro Devices, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#include <assert.h>2829#include "pipe/p_screen.h"30#include "pipe-loader/pipe_loader.h"31#include "frontend/drm_driver.h"3233#include "util/u_memory.h"34#include "vl/vl_winsys.h"3536static void37vl_drm_screen_destroy(struct vl_screen *vscreen);3839struct vl_screen *40vl_drm_screen_create(int fd)41{42struct vl_screen *vscreen;4344vscreen = CALLOC_STRUCT(vl_screen);45if (!vscreen)46return NULL;4748if (pipe_loader_drm_probe_fd(&vscreen->dev, fd))49vscreen->pscreen = pipe_loader_create_screen(vscreen->dev);5051if (!vscreen->pscreen)52goto release_pipe;5354vscreen->destroy = vl_drm_screen_destroy;55vscreen->texture_from_drawable = NULL;56vscreen->get_dirty_area = NULL;57vscreen->get_timestamp = NULL;58vscreen->set_next_timestamp = NULL;59vscreen->get_private = NULL;60return vscreen;6162release_pipe:63if (vscreen->dev)64pipe_loader_release(&vscreen->dev, 1);6566FREE(vscreen);67return NULL;68}6970static void71vl_drm_screen_destroy(struct vl_screen *vscreen)72{73assert(vscreen);7475vscreen->pscreen->destroy(vscreen->pscreen);76pipe_loader_release(&vscreen->dev, 1);77/* CHECK: The VAAPI loader/user preserves ownership of the original fd */78FREE(vscreen);79}808182