1 /************************************************************************** 2 * 3 * Copyright (C) 2022 Kylin Software Co., Ltd. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be included 13 * in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 21 * OTHER DEALINGS IN THE SOFTWARE. 22 * 23 **************************************************************************/ 24 25 /** 26 * @file 27 * The video interface of the vrend renderer. 28 * 29 * These interfaces are mainly called by the vrend deocode submodule 30 * to process the corresponding virgl context video command. 31 * 32 * @author Feng Jiang <[email protected]> 33 */ 34 35 #ifndef VREND_VIDEO_H 36 #define VREND_VIDEO_H 37 38 #include <virgl_hw.h> 39 40 #define VREND_VIDEO_BUFFER_PLANE_NUM 3 41 42 struct vrend_video_context; 43 44 int vrend_video_init(int drm_fd); 45 void vrend_video_fini(void); 46 47 int vrend_video_fill_caps(union virgl_caps *caps); 48 49 struct vrend_video_context *vrend_video_create_context(struct vrend_context *ctx); 50 void vrend_video_destroy_context(struct vrend_video_context *ctx); 51 52 int vrend_video_create_codec(struct vrend_video_context *ctx, 53 uint32_t handle, 54 uint32_t profile, 55 uint32_t entrypoint, 56 uint32_t chroma_format, 57 uint32_t level, 58 uint32_t width, 59 uint32_t height, 60 uint32_t max_ref, 61 uint32_t flags); 62 void vrend_video_destroy_codec(struct vrend_video_context *ctx, 63 uint32_t handle); 64 65 int vrend_video_create_buffer(struct vrend_video_context *ctx, 66 uint32_t handle, 67 uint32_t format, 68 uint32_t width, 69 uint32_t height, 70 uint32_t *res_handles, 71 unsigned int num_res); 72 void vrend_video_destroy_buffer(struct vrend_video_context *ctx, 73 uint32_t handle); 74 75 int vrend_video_begin_frame(struct vrend_video_context *ctx, 76 uint32_t cdc_handle, 77 uint32_t tgt_handle); 78 int vrend_video_decode_bitstream(struct vrend_video_context *ctx, 79 uint32_t cdc_handle, 80 uint32_t tgt_handle, 81 uint32_t desc_handle, 82 unsigned num_buffers, 83 const uint32_t *buffer_handles, 84 const uint32_t *buffer_sizes); 85 int vrend_video_encode_bitstream(struct vrend_video_context *ctx, 86 uint32_t cdc_handle, 87 uint32_t src_handle, 88 uint32_t dest_handle, 89 uint32_t desc_handle, 90 uint32_t feed_handle); 91 int vrend_video_end_frame(struct vrend_video_context *ctx, 92 uint32_t cdc_handle, 93 uint32_t tgt_handle); 94 95 #endif /* VREND_VIDEO_H */ 96