1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2013 Ilia Mirkin 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 12bf215546Sopenharmony_ci * all copies or substantial portions of the Software. 13bf215546Sopenharmony_ci * 14bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 21bf215546Sopenharmony_ci */ 22bf215546Sopenharmony_ci 23bf215546Sopenharmony_ci#ifndef NV84_VIDEO_H_ 24bf215546Sopenharmony_ci#define NV84_VIDEO_H_ 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "vl/vl_decoder.h" 27bf215546Sopenharmony_ci#include "vl/vl_video_buffer.h" 28bf215546Sopenharmony_ci#include "vl/vl_types.h" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci#include "vl/vl_mpeg12_bitstream.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "util/u_video.h" 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#include "nv50/nv50_context.h" 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci/* These are expected to be on their own pushbufs */ 37bf215546Sopenharmony_ci#define SUBC_BSP(m) 2, (m) 38bf215546Sopenharmony_ci#define SUBC_VP(m) 2, (m) 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ciunion pipe_desc { 41bf215546Sopenharmony_ci struct pipe_picture_desc *base; 42bf215546Sopenharmony_ci struct pipe_mpeg12_picture_desc *mpeg12; 43bf215546Sopenharmony_ci struct pipe_mpeg4_picture_desc *mpeg4; 44bf215546Sopenharmony_ci struct pipe_vc1_picture_desc *vc1; 45bf215546Sopenharmony_ci struct pipe_h264_picture_desc *h264; 46bf215546Sopenharmony_ci}; 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_cistruct nv84_video_buffer { 49bf215546Sopenharmony_ci struct pipe_video_buffer base; 50bf215546Sopenharmony_ci struct pipe_resource *resources[VL_NUM_COMPONENTS]; 51bf215546Sopenharmony_ci struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS]; 52bf215546Sopenharmony_ci struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS]; 53bf215546Sopenharmony_ci struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2]; 54bf215546Sopenharmony_ci 55bf215546Sopenharmony_ci struct nouveau_bo *interlaced, *full; 56bf215546Sopenharmony_ci int mvidx; 57bf215546Sopenharmony_ci unsigned frame_num, frame_num_max; 58bf215546Sopenharmony_ci}; 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_cistruct nv84_decoder { 61bf215546Sopenharmony_ci struct pipe_video_codec base; 62bf215546Sopenharmony_ci struct nouveau_client *client; 63bf215546Sopenharmony_ci struct nouveau_object *bsp_channel, *vp_channel, *bsp, *vp; 64bf215546Sopenharmony_ci struct nouveau_pushbuf *bsp_pushbuf, *vp_pushbuf; 65bf215546Sopenharmony_ci struct nouveau_bufctx *bsp_bufctx, *vp_bufctx; 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci struct nouveau_bo *bsp_fw, *bsp_data; 68bf215546Sopenharmony_ci struct nouveau_bo *vp_fw, *vp_data; 69bf215546Sopenharmony_ci struct nouveau_bo *mbring, *vpring; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci /* 72bf215546Sopenharmony_ci * states: 73bf215546Sopenharmony_ci * 0: init 74bf215546Sopenharmony_ci * 1: vpring/mbring cleared, bsp is ready 75bf215546Sopenharmony_ci * 2: bsp is done, vp is ready 76bf215546Sopenharmony_ci * and then vp it back to 1 77bf215546Sopenharmony_ci */ 78bf215546Sopenharmony_ci struct nouveau_bo *fence; 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_ci struct nouveau_bo *bitstream; 81bf215546Sopenharmony_ci struct nouveau_bo *vp_params; 82bf215546Sopenharmony_ci 83bf215546Sopenharmony_ci size_t vp_fw2_offset; 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci unsigned frame_mbs, frame_size; 86bf215546Sopenharmony_ci /* VPRING layout: 87bf215546Sopenharmony_ci RESIDUAL 88bf215546Sopenharmony_ci CTRL 89bf215546Sopenharmony_ci DEBLOCK 90bf215546Sopenharmony_ci 0x1000 91bf215546Sopenharmony_ci */ 92bf215546Sopenharmony_ci unsigned vpring_deblock, vpring_residual, vpring_ctrl; 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci struct vl_mpg12_bs *mpeg12_bs; 96bf215546Sopenharmony_ci 97bf215546Sopenharmony_ci struct nouveau_bo *mpeg12_bo; 98bf215546Sopenharmony_ci void *mpeg12_mb_info; 99bf215546Sopenharmony_ci uint16_t *mpeg12_data; 100bf215546Sopenharmony_ci const int *zscan; 101bf215546Sopenharmony_ci uint8_t mpeg12_intra_matrix[64]; 102bf215546Sopenharmony_ci uint8_t mpeg12_non_intra_matrix[64]; 103bf215546Sopenharmony_ci}; 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_cistatic inline uint32_t mb(uint32_t coord) 106bf215546Sopenharmony_ci{ 107bf215546Sopenharmony_ci return (coord + 0xf)>>4; 108bf215546Sopenharmony_ci} 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_cistatic inline uint32_t mb_half(uint32_t coord) 111bf215546Sopenharmony_ci{ 112bf215546Sopenharmony_ci return (coord + 0x1f)>>5; 113bf215546Sopenharmony_ci} 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ciint 116bf215546Sopenharmony_cinv84_decoder_bsp(struct nv84_decoder *dec, 117bf215546Sopenharmony_ci struct pipe_h264_picture_desc *desc, 118bf215546Sopenharmony_ci unsigned num_buffers, 119bf215546Sopenharmony_ci const void *const *data, 120bf215546Sopenharmony_ci const unsigned *num_bytes, 121bf215546Sopenharmony_ci struct nv84_video_buffer *dest); 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_civoid 124bf215546Sopenharmony_cinv84_decoder_vp_h264(struct nv84_decoder *dec, 125bf215546Sopenharmony_ci struct pipe_h264_picture_desc *desc, 126bf215546Sopenharmony_ci struct nv84_video_buffer *dest); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_civoid 129bf215546Sopenharmony_cinv84_decoder_vp_mpeg12_mb(struct nv84_decoder *dec, 130bf215546Sopenharmony_ci struct pipe_mpeg12_picture_desc *desc, 131bf215546Sopenharmony_ci const struct pipe_mpeg12_macroblock *mb); 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_civoid 134bf215546Sopenharmony_cinv84_decoder_vp_mpeg12(struct nv84_decoder *dec, 135bf215546Sopenharmony_ci struct pipe_mpeg12_picture_desc *desc, 136bf215546Sopenharmony_ci struct nv84_video_buffer *dest); 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_ci#endif 139