Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv50/nv84_video.h
4574 views
/*1* Copyright 2013 Ilia Mirkin2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice shall be included in11* all copies or substantial portions of the Software.12*13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,15* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL16* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR17* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,18* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR19* OTHER DEALINGS IN THE SOFTWARE.20*/2122#ifndef NV84_VIDEO_H_23#define NV84_VIDEO_H_2425#include "vl/vl_decoder.h"26#include "vl/vl_video_buffer.h"27#include "vl/vl_types.h"2829#include "vl/vl_mpeg12_bitstream.h"3031#include "util/u_video.h"3233#include "nv50/nv50_context.h"3435/* These are expected to be on their own pushbufs */36#define SUBC_BSP(m) 2, (m)37#define SUBC_VP(m) 2, (m)3839union pipe_desc {40struct pipe_picture_desc *base;41struct pipe_mpeg12_picture_desc *mpeg12;42struct pipe_mpeg4_picture_desc *mpeg4;43struct pipe_vc1_picture_desc *vc1;44struct pipe_h264_picture_desc *h264;45};4647struct nv84_video_buffer {48struct pipe_video_buffer base;49struct pipe_resource *resources[VL_NUM_COMPONENTS];50struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];51struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];52struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2];5354struct nouveau_bo *interlaced, *full;55int mvidx;56unsigned frame_num, frame_num_max;57};5859struct nv84_decoder {60struct pipe_video_codec base;61struct nouveau_client *client;62struct nouveau_object *bsp_channel, *vp_channel, *bsp, *vp;63struct nouveau_pushbuf *bsp_pushbuf, *vp_pushbuf;64struct nouveau_bufctx *bsp_bufctx, *vp_bufctx;6566struct nouveau_bo *bsp_fw, *bsp_data;67struct nouveau_bo *vp_fw, *vp_data;68struct nouveau_bo *mbring, *vpring;6970/*71* states:72* 0: init73* 1: vpring/mbring cleared, bsp is ready74* 2: bsp is done, vp is ready75* and then vp it back to 176*/77struct nouveau_bo *fence;7879struct nouveau_bo *bitstream;80struct nouveau_bo *vp_params;8182size_t vp_fw2_offset;8384unsigned frame_mbs, frame_size;85/* VPRING layout:86RESIDUAL87CTRL88DEBLOCK890x100090*/91unsigned vpring_deblock, vpring_residual, vpring_ctrl;929394struct vl_mpg12_bs *mpeg12_bs;9596struct nouveau_bo *mpeg12_bo;97void *mpeg12_mb_info;98uint16_t *mpeg12_data;99const int *zscan;100uint8_t mpeg12_intra_matrix[64];101uint8_t mpeg12_non_intra_matrix[64];102};103104static inline uint32_t mb(uint32_t coord)105{106return (coord + 0xf)>>4;107}108109static inline uint32_t mb_half(uint32_t coord)110{111return (coord + 0x1f)>>5;112}113114int115nv84_decoder_bsp(struct nv84_decoder *dec,116struct pipe_h264_picture_desc *desc,117unsigned num_buffers,118const void *const *data,119const unsigned *num_bytes,120struct nv84_video_buffer *dest);121122void123nv84_decoder_vp_h264(struct nv84_decoder *dec,124struct pipe_h264_picture_desc *desc,125struct nv84_video_buffer *dest);126127void128nv84_decoder_vp_mpeg12_mb(struct nv84_decoder *dec,129struct pipe_mpeg12_picture_desc *desc,130const struct pipe_mpeg12_macroblock *mb);131132void133nv84_decoder_vp_mpeg12(struct nv84_decoder *dec,134struct pipe_mpeg12_picture_desc *desc,135struct nv84_video_buffer *dest);136137#endif138139140