Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c
4574 views
/*1* Copyright 2011-2013 Maarten Lankhorst, 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#include "nv50/nv98_video.h"2324static void25nv98_decoder_setup_ppp(struct nouveau_vp3_decoder *dec, struct nouveau_vp3_video_buffer *target, uint32_t low700) {26struct nouveau_pushbuf *push = dec->pushbuf[2];2728uint32_t stride_in = mb(dec->base.width);29uint32_t stride_out = mb(target->resources[0]->width0);30uint32_t dec_h = mb(dec->base.height);31uint32_t dec_w = mb(dec->base.width);32uint64_t in_addr;33uint32_t y2, cbcr, cbcr2, i;34struct nouveau_pushbuf_refn bo_refs[] = {35{ NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },36{ NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },37{ dec->ref_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },38#if NOUVEAU_VP3_DEBUG_FENCE39{ dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },40#endif41};42unsigned num_refs = ARRAY_SIZE(bo_refs);4344for (i = 0; i < 2; ++i) {45struct nv50_miptree *mt = (struct nv50_miptree *)target->resources[i];46bo_refs[i].bo = mt->base.bo;47}4849nouveau_pushbuf_refn(push, bo_refs, num_refs);50nouveau_vp3_ycbcr_offsets(dec, &y2, &cbcr, &cbcr2);5152BEGIN_NV04(push, SUBC_PPP(0x700), 10);53in_addr = nouveau_vp3_video_addr(dec, target) >> 8;5455PUSH_DATA (push, (stride_out << 24) | (stride_out << 16) | low700); // 70056PUSH_DATA (push, (stride_in << 24) | (stride_in << 16) | (dec_h << 8) | dec_w); // 70457assert(dec_w == stride_in);5859/* Input: */60PUSH_DATA (push, in_addr); // 70861PUSH_DATA (push, in_addr + y2); // 70c62PUSH_DATA (push, in_addr + cbcr); // 71063PUSH_DATA (push, in_addr + cbcr2); // 7146465for (i = 0; i < 2; ++i) {66struct nv50_miptree *mt = (struct nv50_miptree *)target->resources[i];6768PUSH_DATA (push, mt->base.address >> 8);69PUSH_DATA (push, (mt->base.address + mt->total_size/2) >> 8);70mt->base.status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;71}72}7374static uint32_t75nv98_decoder_vc1_ppp(struct nouveau_vp3_decoder *dec, struct pipe_vc1_picture_desc *desc, struct nouveau_vp3_video_buffer *target) {76struct nouveau_pushbuf *push = dec->pushbuf[2];7778nv98_decoder_setup_ppp(dec, target, 0x1412);79assert(!desc->deblockEnable);80assert(!(dec->base.width & 0xf));81assert(!(dec->base.height & 0xf));8283BEGIN_NV04(push, SUBC_PPP(0x400), 1);84PUSH_DATA (push, desc->pquant << 11);8586// 728 = wtf?87return 0x10;88}8990void91nv98_decoder_ppp(struct nouveau_vp3_decoder *dec, union pipe_desc desc, struct nouveau_vp3_video_buffer *target, unsigned comm_seq) {92enum pipe_video_format codec = u_reduce_video_profile(dec->base.profile);93struct nouveau_pushbuf *push = dec->pushbuf[2];94unsigned ppp_caps = 0x10;9596nouveau_pushbuf_space(push, 32, 4, 0);9798switch (codec) {99case PIPE_VIDEO_FORMAT_MPEG12: {100unsigned mpeg2 = dec->base.profile != PIPE_VIDEO_PROFILE_MPEG1;101nv98_decoder_setup_ppp(dec, target, 0x1410 | mpeg2);102break;103}104case PIPE_VIDEO_FORMAT_MPEG4: nv98_decoder_setup_ppp(dec, target, 0x1414); break;105case PIPE_VIDEO_FORMAT_VC1: ppp_caps = nv98_decoder_vc1_ppp(dec, desc.vc1, target); break;106case PIPE_VIDEO_FORMAT_MPEG4_AVC: nv98_decoder_setup_ppp(dec, target, 0x1413); break;107default: assert(0);108}109BEGIN_NV04(push, SUBC_PPP(0x734), 2);110PUSH_DATA (push, comm_seq);111PUSH_DATA (push, ppp_caps);112113#if NOUVEAU_VP3_DEBUG_FENCE114BEGIN_NV04(push, SUBC_PPP(0x240), 3);115PUSH_DATAh(push, (dec->fence_bo->offset + 0x20));116PUSH_DATA (push, (dec->fence_bo->offset + 0x20));117PUSH_DATA (push, dec->fence_seq);118119BEGIN_NV04(push, SUBC_PPP(0x300), 1);120PUSH_DATA (push, 1);121PUSH_KICK (push);122123{124unsigned spin = 0;125126do {127usleep(100);128if ((spin++ & 0xff) == 0xff)129debug_printf("p%u: %u\n", dec->fence_seq, dec->fence_map[8]);130} while (dec->fence_seq > dec->fence_map[8]);131}132#else133BEGIN_NV04(push, SUBC_PPP(0x300), 1);134PUSH_DATA (push, 0);135PUSH_KICK (push);136#endif137}138139140