Hi Maarten,<div>I tried the v2 patch with my good old geforce 8600M GS, and it worked well. The CPU usage seems a little higher than usual, I'd said 60% instead of 40% for a 720p video, but I'll try with a higher bitrate video and without building with debug parameters to see if I can found a performance gain.</div>
<div>The only problem is that I cannot seek through the video without an segfault on that error "X11 error: BadAccess (attempt to access private resource denied)", I attached a gdb backtrace. It appears to be related to the drawing of the mplayer OSD.</div>
<div><div><br></div><div>Regards,</div>Emeric</div><div><br><div class="gmail_quote">2011/9/10 Maarten Lankhorst <span dir="ltr"><<a href="mailto:m.b.lankhorst@gmail.com">m.b.lankhorst@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Try to use the PMPEG where available<br>
<br>
Signed-off-by: Maarten Lankhorst <<a href="mailto:m.b.lankhorst@gmail.com">m.b.lankhorst@gmail.com</a>><br>
---<br>
<br>
v2: Fixed nvfx check, and use > 0x80 to see if 8274 is available<br>
If that is incorrect, fix is8274 before committing, I'm not 100%<br>
sure on what card 8274 is first available.<br>
<br>
src/gallium/drivers/nouveau/nouveau_video.c | 892 ++++++++++++++++++++++++++-<br>
src/gallium/drivers/nouveau/nouveau_video.h | 42 ++<br>
src/gallium/drivers/nouveau/nv17_mpeg.xml.h | 265 ++++++++<br>
src/gallium/drivers/nouveau/nv31_mpeg.xml.h | 130 ++++<br>
src/gallium/drivers/nvfx/nvfx_context.c | 4 +-<br>
src/gallium/drivers/nvfx/nvfx_context.h | 2 +<br>
6 files changed, 1328 insertions(+), 7 deletions(-)<br>
create mode 100644 src/gallium/drivers/nouveau/nouveau_video.h<br>
create mode 100644 src/gallium/drivers/nouveau/nv17_mpeg.xml.h<br>
create mode 100644 src/gallium/drivers/nouveau/nv31_mpeg.xml.h<br>
<br>
diff --git a/src/gallium/drivers/nouveau/nouveau_video.c b/src/gallium/drivers/nouveau/nouveau_video.c<br>
index 620c030..75124e5 100644<br>
--- a/src/gallium/drivers/nouveau/nouveau_video.c<br>
+++ b/src/gallium/drivers/nouveau/nouveau_video.c<br>
@@ -1,9 +1,842 @@<br>
+/*<br>
+ * Copyright 2011 Maarten Lankhorst<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice shall be included in<br>
+ * all copies or substantial portions of the Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,<br>
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF<br>
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br>
+ * SOFTWARE.<br>
+ */<br>
<br>
#include "vl/vl_decoder.h"<br>
#include "vl/vl_video_buffer.h"<br>
<br>
-#include "nouveau/nouveau_screen.h"<br>
-#include "nouveau/nouveau_context.h"<br>
+#include "nouveau_screen.h"<br>
+#include "nouveau_context.h"<br>
+#include "nouveau_video.h"<br>
+<br>
+#include "nvfx/nvfx_context.h"<br>
+#include "nvfx/nvfx_resource.h"<br>
+#include "nouveau/nouveau_bo.h"<br>
+#include "nouveau/nouveau_buffer.h"<br>
+#include "util/u_video.h"<br>
+#include "util/u_format.h"<br>
+#include "util/u_sampler.h"<br>
+#include "nouveau/nouveau_device.h"<br>
+#include "nouveau_winsys.h"<br>
+<br>
+static bool<br>
+nouveau_video_is_nvfx(struct nouveau_decoder *dec) {<br>
+ if (dec->screen->device->chipset < 0x50)<br>
+ return true;<br>
+ if (dec->screen->device->chipset >= 0x60 && dec->screen->device->chipset < 0x70)<br>
+ return true;<br>
+ return false;<br>
+}<br>
+<br>
+static int<br>
+nouveau_vpe_init(struct nouveau_decoder *dec) {<br>
+ int ret;<br>
+ if (dec->cmds)<br>
+ return 0;<br>
+ ret = nouveau_bo_map(dec->cmd_bo, NOUVEAU_BO_RDWR);<br>
+ if (ret) {<br>
+ debug_printf("Mapping cmd bo: %s\n", strerror(-ret));<br>
+ return ret;<br>
+ }<br>
+ ret = nouveau_bo_map(dec->data_bo, NOUVEAU_BO_RDWR);<br>
+ if (ret) {<br>
+ nouveau_bo_unmap(dec->cmd_bo);<br>
+ debug_printf("Mapping data bo: %s\n", strerror(-ret));<br>
+ return ret;<br>
+ }<br>
+ dec->cmds = dec->cmd_bo->map;<br>
+ dec->data = dec->data_bo->map;<br>
+ return ret;<br>
+}<br>
+<br>
+static void<br>
+nouveau_vpe_synch(struct nouveau_decoder *dec) {<br>
+ struct nouveau_channel *chan = dec->screen->channel;<br>
+#if 0<br>
+ if (dec->fence_map) {<br>
+ BEGIN_RING(chan, dec->mpeg, NV84_MPEG_QUERY_COUNTER, 1);<br>
+ OUT_RING(chan, ++dec->fence_seq);<br>
+ FIRE_RING(chan);<br>
+ while (dec->fence_map[0] != dec->fence_seq)<br>
+ usleep(1000);<br>
+ } else<br>
+#endif<br>
+ FIRE_RING(chan);<br>
+}<br>
+<br>
+static void<br>
+nouveau_vpe_fini(struct nouveau_decoder *dec) {<br>
+ struct nouveau_channel *chan = dec->screen->channel;<br>
+ if (!dec->cmds)<br>
+ return;<br>
+<br>
+ nouveau_bo_unmap(dec->data_bo);<br>
+ nouveau_bo_unmap(dec->cmd_bo);<br>
+<br>
+ MARK_RING(chan, 8, 2);<br>
+ BEGIN_RING(chan, dec->mpeg, NV31_MPEG_CMD_OFFSET, 2);<br>
+ OUT_RELOCl(chan, dec->cmd_bo, 0, NOUVEAU_BO_RD|NOUVEAU_BO_GART);<br>
+ OUT_RING(chan, dec->ofs * 4);<br>
+<br>
+ BEGIN_RING(chan, dec->mpeg, NV31_MPEG_DATA_OFFSET, 2);<br>
+ OUT_RELOCl(chan, dec->data_bo, 0, NOUVEAU_BO_RD|NOUVEAU_BO_GART);<br>
+ OUT_RING(chan, dec->data_pos * 4);<br>
+<br>
+ BEGIN_RING(chan, dec->mpeg, NV31_MPEG_EXEC, 1);<br>
+ OUT_RING(chan, 1);<br>
+<br>
+ nouveau_vpe_synch(dec);<br>
+ dec->ofs = dec->data_pos = dec->num_surfaces = 0;<br>
+ dec->cmds = dec->data = NULL;<br>
+ dec->current = dec->future = dec->past = 8;<br>
+}<br>
+<br>
+static INLINE void<br>
+nouveau_vpe_mb_dct_blocks(struct nouveau_decoder *dec, const struct pipe_mpeg12_macroblock *mb)<br>
+{<br>
+ int cbb;<br>
+ unsigned cbp = mb->coded_block_pattern;<br>
+ short *db = mb->blocks;<br>
+ for (cbb = 0x20; cbb > 0; cbb >>= 1) {<br>
+ if (cbb & cbp) {<br>
+ static const int lookup[64] = {<br>
+ 0, 1, 8,16, 9, 2, 3,10,<br>
+ 17,24,32,25,18,11, 4, 5,<br>
+ 12,19,26,33,40,48,41,34,<br>
+ 27,20,13, 6, 7,14,21,28,<br>
+ 35,42,49,56,57,50,43,36,<br>
+ 29,22,15,23,30,37,44,51,<br>
+ 58,59,52,45,38,31,39,46,<br>
+ 53,60,61,54,47,55,62,63<br>
+ };<br>
+ int i, j = 0, found = 0;<br>
+ for (i = 0; i < 64; ++i) {<br>
+ if (!db[lookup[i]]) { j += 2; continue; }<br>
+ dec->data[dec->data_pos++] = (db[lookup[i]] << 16) | j;<br>
+ j = 0;<br>
+ found = 1;<br>
+ }<br>
+ if (found)<br>
+ dec->data[dec->data_pos - 1] |= 1;<br>
+ else<br>
+ dec->data[dec->data_pos++] = 1;<br>
+ db += 64;<br>
+ } else if (mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA) {<br>
+ dec->data[dec->data_pos++] = 1;<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+static INLINE void<br>
+nouveau_vpe_mb_data_blocks(struct nouveau_decoder *dec, const struct pipe_mpeg12_macroblock *mb)<br>
+{<br>
+ int cbb;<br>
+ unsigned cbp = mb->coded_block_pattern;<br>
+ short *db = mb->blocks;<br>
+ for (cbb = 0x20; cbb > 0; cbb >>= 1) {<br>
+ if (cbb & cbp) {<br>
+ memcpy(&dec->data[dec->data_pos], db, 128);<br>
+ dec->data_pos += 32;<br>
+ db += 64;<br>
+ } else if (mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA) {<br>
+ memset(&dec->data[dec->data_pos], 0, 128);<br>
+ dec->data_pos += 32;<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+static INLINE void<br>
+nouveau_vpe_mb_dct_header(struct nouveau_decoder *dec,<br>
+ const struct pipe_mpeg12_macroblock *mb,<br>
+ bool luma)<br>
+{<br>
+ unsigned base_dct, cbp;<br>
+ bool intra = mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA;<br>
+ unsigned x = mb->x * 16;<br>
+ unsigned y = luma ? mb->y * 16 : mb->y * 8;<br>
+<br>
+ /* Setup the base dct header */<br>
+ base_dct = dec->current << NV17_MPEG_CMD_CHROMA_MB_HEADER_SURFACE__SHIFT;<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_RUN_SINGLE;<br>
+<br>
+ if (!(mb->x & 1))<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_X_COORD_EVEN;<br>
+ if (intra)<br>
+ cbp = 0x3f;<br>
+ else<br>
+ cbp = mb->coded_block_pattern;<br>
+<br>
+ if (dec->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME) {<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_TYPE_FRAME;<br>
+ if (luma && mb->macroblock_modes.bits.dct_type == PIPE_MPEG12_DCT_TYPE_FIELD)<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_FRAME_DCT_TYPE_FIELD;<br>
+ } else {<br>
+ if (dec->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_BOTTOM)<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_FIELD_BOTTOM;<br>
+ if (!intra)<br>
+ y *= 2;<br>
+ }<br>
+<br>
+ if (luma) {<br>
+ base_dct |= NV17_MPEG_CMD_LUMA_MB_HEADER_OP_LUMA_MB_HEADER;<br>
+ base_dct |= (cbp >> 2) << NV17_MPEG_CMD_LUMA_MB_HEADER_CBP__SHIFT;<br>
+ } else {<br>
+ base_dct |= NV17_MPEG_CMD_CHROMA_MB_HEADER_OP_CHROMA_MB_HEADER;<br>
+ base_dct |= (cbp & 3) << NV17_MPEG_CMD_CHROMA_MB_HEADER_CBP__SHIFT;<br>
+ }<br>
+ nouveau_vpe_write(dec, base_dct);<br>
+ nouveau_vpe_write(dec, NV17_MPEG_CMD_MB_COORDS_OP_MB_COORDS |<br>
+ x | (y << NV17_MPEG_CMD_MB_COORDS_Y__SHIFT));<br>
+}<br>
+<br>
+static INLINE unsigned int<br>
+nouveau_vpe_mb_mv_flags(bool luma, int mv_h, int mv_v, bool forward, bool first, bool vert)<br>
+{<br>
+ unsigned mc_header = 0;<br>
+ if (luma)<br>
+ mc_header |= NV17_MPEG_CMD_LUMA_MV_HEADER_OP_LUMA_MV_HEADER;<br>
+ else<br>
+ mc_header |= NV17_MPEG_CMD_CHROMA_MV_HEADER_OP_CHROMA_MV_HEADER;<br>
+ if (mv_h & 1)<br>
+ mc_header |= NV17_MPEG_CMD_CHROMA_MV_HEADER_X_HALF;<br>
+ if (mv_v & 1)<br>
+ mc_header |= NV17_MPEG_CMD_CHROMA_MV_HEADER_Y_HALF;<br>
+ if (!forward)<br>
+ mc_header |= NV17_MPEG_CMD_CHROMA_MV_HEADER_DIRECTION_BACKWARD;<br>
+ if (!first)<br>
+ mc_header |= NV17_MPEG_CMD_CHROMA_MV_HEADER_IDX;<br>
+ if (vert)<br>
+ mc_header |= NV17_MPEG_CMD_LUMA_MV_HEADER_FIELD_BOTTOM;<br>
+ return mc_header;<br>
+}<br>
+<br>
+static unsigned pos(int pos, int mov, int max) {<br>
+ int ret = pos + mov;<br>
+ if (pos < 0)<br>
+ return 0;<br>
+ if (pos >= max)<br>
+ return max-1;<br>
+ return ret;<br>
+}<br>
+<br>
+/* because we want -1 / 2 = -1 */<br>
+static int div_down(int val, int mult) {<br>
+ val &= ~(mult - 1);<br>
+ return val / mult;<br>
+}<br>
+<br>
+static int div_up(int val, int mult) {<br>
+ val += mult - 1;<br>
+ return val / mult;<br>
+}<br>
+<br>
+static INLINE void<br>
+nouveau_vpe_mb_mv(struct nouveau_decoder *dec, unsigned mc_header,<br>
+ bool luma, bool frame, bool forward, bool vert,<br>
+ int x, int y, const short motions[2],<br>
+ unsigned surface, bool first)<br>
+{<br>
+ unsigned mc_vector;<br>
+ int mv_horizontal = motions[0];<br>
+ int mv_vertical = motions[1];<br>
+ int mv2 = mc_header & NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT_2;<br>
+ unsigned width = dec->base.width;<br>
+ unsigned height = dec->base.height;<br>
+ if (mv2)<br>
+ mv_vertical = div_down(mv_vertical, 2);<br>
+ assert(frame); // Untested for non-frames<br>
+ if (!frame)<br>
+ height *= 2;<br>
+<br>
+ mc_header |= surface << NV17_MPEG_CMD_CHROMA_MV_HEADER_SURFACE__SHIFT;<br>
+ if (!luma) {<br>
+ mv_vertical = div_up(mv_vertical, 2);<br>
+ mv_horizontal = div_up(mv_horizontal, 2);<br>
+ height /= 2;<br>
+ }<br>
+ mc_header |= nouveau_vpe_mb_mv_flags(luma, mv_horizontal, mv_vertical, forward, first, vert);<br>
+ nouveau_vpe_write(dec, mc_header);<br>
+<br>
+ mc_vector = NV17_MPEG_CMD_MV_COORDS_OP_MV_COORDS;<br>
+ if (luma)<br>
+ mc_vector |= pos(x, div_down(mv_horizontal, 2), width);<br>
+ else<br>
+ mc_vector |= pos(x, mv_horizontal & ~1, width);<br>
+ if (!mv2)<br>
+ mc_vector |= pos(y, div_down(mv_vertical, 2), height) << NV17_MPEG_CMD_MV_COORDS_Y__SHIFT;<br>
+ else<br>
+ mc_vector |= pos(y, mv_vertical & ~1, height) << NV17_MPEG_CMD_MV_COORDS_Y__SHIFT;<br>
+ nouveau_vpe_write(dec, mc_vector);<br>
+}<br>
+<br>
+static void<br>
+nouveau_vpe_mb_mv_header(struct nouveau_decoder *dec,<br>
+ const struct pipe_mpeg12_macroblock *mb,<br>
+ bool luma)<br>
+{<br>
+ bool frame = dec->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FRAME;<br>
+ unsigned base;<br>
+ bool forward, backward;<br>
+ int y, y2, x = mb->x * 16;<br>
+ if (luma)<br>
+ y = mb->y * (frame ? 16 : 32);<br>
+ else<br>
+ y = mb->y * (frame ? 8 : 16);<br>
+ if (frame)<br>
+ y2 = y;<br>
+ else<br>
+ y2 = y + (luma ? 16 : 8);<br>
+<br>
+ forward = mb->macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_FORWARD;<br>
+ backward = mb->macroblock_type & PIPE_MPEG12_MB_TYPE_MOTION_BACKWARD;<br>
+ assert(!forward || dec->past < 8);<br>
+ assert(!backward || dec->future < 8);<br>
+ if (frame) {<br>
+ switch (mb->macroblock_modes.bits.frame_motion_type) {<br>
+ case PIPE_MPEG12_MO_TYPE_FRAME: goto mv1;<br>
+ case PIPE_MPEG12_MO_TYPE_FIELD: goto mv2;<br>
+ case PIPE_MPEG12_MO_TYPE_DUAL_PRIME: {<br>
+ base = NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT_2;<br>
+ if (forward) {<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE, FALSE,<br>
+ x, y, mb->PMV[0][0], dec->past, TRUE);<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE, TRUE,<br>
+ x, y2, mb->PMV[0][0], dec->past, FALSE);<br>
+ }<br>
+ if (backward && forward) {<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, !forward, TRUE,<br>
+ x, y, mb->PMV[1][0], dec->future, TRUE);<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, !forward, FALSE,<br>
+ x, y2, mb->PMV[1][1], dec->future, FALSE);<br>
+ } else assert(!backward);<br>
+ break;<br>
+ }<br>
+ default: assert(0);<br>
+ }<br>
+ } else {<br>
+ switch (mb->macroblock_modes.bits.field_motion_type) {<br>
+ case PIPE_MPEG12_MO_TYPE_FIELD: goto mv1;<br>
+ case PIPE_MPEG12_MO_TYPE_16x8: goto mv2;<br>
+ case PIPE_MPEG12_MO_TYPE_DUAL_PRIME: {<br>
+ base = NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT_HALF_MB;<br>
+ if (frame)<br>
+ base |= NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE_FRAME;<br>
+ if (forward)<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE,<br>
+ dec->picture_structure != PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_TOP,<br>
+ x, y, mb->PMV[0][0], dec->past, TRUE);<br>
+ if (backward && forward)<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, FALSE,<br>
+ dec->picture_structure == PIPE_MPEG12_PICTURE_STRUCTURE_FIELD_TOP,<br>
+ x, y, mb->PMV[0][1], dec->future, TRUE);<br>
+ else assert(!backward);<br>
+ break;<br>
+ }<br>
+ default: assert(0);<br>
+ }<br>
+ }<br>
+ return;<br>
+<br>
+mv1:<br>
+ base = NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT_HALF_MB;<br>
+ if (frame)<br>
+ base |= NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE_FRAME;<br>
+ /* frame 16x16 */<br>
+ if (forward)<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE, FALSE,<br>
+ x, y, mb->PMV[0][0], dec->past, TRUE);<br>
+ if (backward)<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, !forward, FALSE,<br>
+ x, y, mb->PMV[0][1], dec->future, TRUE);<br>
+ return;<br>
+<br>
+mv2:<br>
+ base = NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT_2;<br>
+ if (!frame)<br>
+ base |= NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT_HALF_MB;<br>
+ if (forward) {<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE,<br>
+ mb->motion_vertical_field_select & PIPE_MPEG12_FS_FIRST_FORWARD,<br>
+ x, y, mb->PMV[0][0], dec->past, TRUE);<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, TRUE,<br>
+ mb->motion_vertical_field_select & PIPE_MPEG12_FS_SECOND_FORWARD,<br>
+ x, y2, mb->PMV[1][0], dec->past, FALSE);<br>
+ }<br>
+ if (backward) {<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, !forward,<br>
+ mb->motion_vertical_field_select & PIPE_MPEG12_FS_FIRST_BACKWARD,<br>
+ x, y, mb->PMV[0][1], dec->future, TRUE);<br>
+ nouveau_vpe_mb_mv(dec, base, luma, frame, !forward,<br>
+ mb->motion_vertical_field_select & PIPE_MPEG12_FS_SECOND_BACKWARD,<br>
+ x, y2, mb->PMV[1][1], dec->future, FALSE);<br>
+ }<br>
+}<br>
+<br>
+static unsigned<br>
+nouveau_decoder_surface_index(struct nouveau_decoder *dec,<br>
+ struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_video_buffer *buf = (struct nouveau_video_buffer *)buffer;<br>
+ struct nouveau_channel *chan = dec->screen->channel;<br>
+ struct nouveau_bo *bo_y, *bo_c;<br>
+ unsigned i;<br>
+<br>
+ if (!buf)<br>
+ return 8;<br>
+ for (i = 0; i < dec->num_surfaces; ++i) {<br>
+ if (dec->surfaces[i] == buf)<br>
+ return i;<br>
+ }<br>
+ assert(i < 8);<br>
+ dec->surfaces[i] = buf;<br>
+ dec->num_surfaces++;<br>
+<br>
+ if (nouveau_video_is_nvfx(dec)) {<br>
+ bo_y = ((struct nvfx_resource *)buf->resources[0])->bo;<br>
+ bo_c = ((struct nvfx_resource *)buf->resources[1])->bo;<br>
+ } else {<br>
+ bo_y = ((struct nv04_resource *)buf->resources[0])->bo;<br>
+ bo_c = ((struct nv04_resource *)buf->resources[1])->bo;<br>
+ }<br>
+ MARK_RING(chan, 3, 2);<br>
+ BEGIN_RING(chan, dec->mpeg, NV31_MPEG_IMAGE_Y_OFFSET(i), 2);<br>
+ OUT_RELOCl(chan, bo_y, 0, NOUVEAU_BO_RDWR);<br>
+ OUT_RELOCl(chan, bo_c, 0, NOUVEAU_BO_RDWR);<br>
+ return i;<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_set_picture_parameters(struct pipe_video_decoder *decoder,<br>
+ struct pipe_picture_desc *picture_desc)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;<br>
+ struct pipe_mpeg12_picture_desc *desc;<br>
+ desc = (struct pipe_mpeg12_picture_desc *)picture_desc;<br>
+ dec->picture_structure = desc->picture_structure;<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_set_reference_frames(struct pipe_video_decoder *decoder,<br>
+ struct pipe_video_buffer **buffers,<br>
+ unsigned count)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;<br>
+ if (count >= 1 && buffers[0])<br>
+ dec->past = nouveau_decoder_surface_index(dec, buffers[0]);<br>
+ if (count >= 2 && buffers[1])<br>
+ dec->future = nouveau_decoder_surface_index(dec, buffers[1]);<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_set_decode_target(struct pipe_video_decoder *decoder,<br>
+ struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;<br>
+ dec->current = nouveau_decoder_surface_index(dec, buffer);<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_decode_macroblock(struct pipe_video_decoder *decoder,<br>
+ const struct pipe_macroblock *pipe_mb,<br>
+ unsigned num_macroblocks)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;<br>
+ const struct pipe_mpeg12_macroblock *mb;<br>
+ unsigned i;<br>
+ assert(dec->current < 8);<br>
+<br>
+ if (nouveau_vpe_init(dec)) return;<br>
+ mb = (const struct pipe_mpeg12_macroblock *)pipe_mb;<br>
+ for (i = 0; i < num_macroblocks; ++i, mb++) {<br>
+ if (mb->macroblock_type & PIPE_MPEG12_MB_TYPE_INTRA) {<br>
+ nouveau_vpe_mb_dct_header(dec, mb, TRUE);<br>
+ nouveau_vpe_mb_dct_header(dec, mb, FALSE);<br>
+ } else {<br>
+ nouveau_vpe_mb_mv_header(dec, mb, TRUE);<br>
+ nouveau_vpe_mb_dct_header(dec, mb, TRUE);<br>
+<br>
+ nouveau_vpe_mb_mv_header(dec, mb, FALSE);<br>
+ nouveau_vpe_mb_dct_header(dec, mb, FALSE);<br>
+ }<br>
+ if (dec->base.entrypoint <= PIPE_VIDEO_ENTRYPOINT_IDCT)<br>
+ nouveau_vpe_mb_dct_blocks(dec, mb);<br>
+ else<br>
+ nouveau_vpe_mb_data_blocks(dec, mb);<br>
+ }<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_flush(struct pipe_video_decoder *decoder)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder *)decoder;<br>
+ if (dec->ofs)<br>
+ nouveau_vpe_fini(dec);<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_destroy(struct pipe_video_decoder *decoder)<br>
+{<br>
+ struct nouveau_decoder *dec = (struct nouveau_decoder*)decoder;<br>
+<br>
+ if (dec->cmds) {<br>
+ nouveau_bo_unmap(dec->data_bo);<br>
+ nouveau_bo_unmap(dec->cmd_bo);<br>
+ }<br>
+<br>
+ if (dec->data_bo)<br>
+ nouveau_bo_ref(NULL, &dec->data_bo);<br>
+ if (dec->cmd_bo)<br>
+ nouveau_bo_ref(NULL, &dec->cmd_bo);<br>
+ if (dec->fence_bo)<br>
+ nouveau_bo_ref(NULL, &dec->fence_bo);<br>
+ nouveau_grobj_free(&dec->mpeg);<br>
+ FREE(dec);<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_begin_frame(struct pipe_video_decoder *decoder)<br>
+{<br>
+}<br>
+<br>
+static void<br>
+nouveau_decoder_end_frame(struct pipe_video_decoder *decoder)<br>
+{<br>
+}<br>
+<br>
+static struct pipe_video_decoder *<br>
+nouveau_create_decoder(struct pipe_context *context,<br>
+ struct nouveau_screen *screen,<br>
+ enum pipe_video_profile profile,<br>
+ enum pipe_video_entrypoint entrypoint,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_channel *chan = screen->channel;<br>
+ struct nouveau_grobj *mpeg = NULL;<br>
+ struct nouveau_decoder *dec;<br>
+ int ret;<br>
+ bool is8274 = screen->device->chipset > 0x80;<br>
+<br>
+ debug_printf("Acceleration level: %s\n", entrypoint <= PIPE_VIDEO_ENTRYPOINT_BITSTREAM ? "bit":<br>
+ entrypoint == PIPE_VIDEO_ENTRYPOINT_IDCT ? "IDCT" : "MC");<br>
+<br>
+ if (getenv("XVMC_VL"))<br>
+ goto vl;<br>
+ if (u_reduce_video_profile(profile) != PIPE_VIDEO_CODEC_MPEG12)<br>
+ goto vl;<br>
+ if (screen->device->chipset >= 0x98 && screen->device->chipset != 0xa0)<br>
+ goto vl;<br>
+<br>
+ width = align(width, 64);<br>
+ height = align(height, 64);<br>
+<br>
+ if (is8274)<br>
+ ret = nouveau_grobj_alloc(chan, 0xbeef8274, 0x8274, &mpeg);<br>
+ else<br>
+ ret = nouveau_grobj_alloc(chan, 0xbeef8274, 0x3174, &mpeg);<br>
+ if (ret < 0) {<br>
+ debug_printf("Creation failed: %s (%i)\n", strerror(-ret), ret);<br>
+ return NULL;<br>
+ }<br>
+<br>
+ dec = CALLOC_STRUCT(nouveau_decoder);<br>
+ if (!dec) {<br>
+ nouveau_grobj_free(&mpeg);<br>
+ goto fail;<br>
+ }<br>
+ dec->mpeg = mpeg;<br>
+ dec->base.context = context;<br>
+ dec->base.profile = profile;<br>
+ dec->base.entrypoint = entrypoint;<br>
+ dec->base.chroma_format = chroma_format;<br>
+ dec->base.width = width;<br>
+ dec->base.height = height;<br>
+ dec->base.destroy = nouveau_decoder_destroy;<br>
+ dec->base.begin_frame = nouveau_decoder_begin_frame;<br>
+ dec->base.end_frame = nouveau_decoder_end_frame;<br>
+ dec->base.set_decode_target = nouveau_decoder_set_decode_target;<br>
+ dec->base.set_picture_parameters = nouveau_decoder_set_picture_parameters;<br>
+ dec->base.set_reference_frames = nouveau_decoder_set_reference_frames;<br>
+ dec->base.decode_macroblock = nouveau_decoder_decode_macroblock;<br>
+ dec->base.flush = nouveau_decoder_flush;<br>
+ dec->screen = screen;<br>
+<br>
+ ret = nouveau_bo_new(dec->screen->device, NOUVEAU_BO_GART, 0, 1024 * 1024, &dec->cmd_bo);<br>
+ if (ret)<br>
+ goto fail;<br>
+<br>
+ ret = nouveau_bo_new(dec->screen->device, NOUVEAU_BO_GART, 0, width * height * 6, &dec->data_bo);<br>
+ if (ret)<br>
+ goto fail;<br>
+<br>
+ ret = nouveau_bo_new(dec->screen->device, NOUVEAU_BO_GART|NOUVEAU_BO_MAP, 0, 4096,<br>
+ &dec->fence_bo);<br>
+ if (ret)<br>
+ goto fail;<br>
+ nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR);<br>
+ dec->fence_map = dec->fence_bo->map;<br>
+ nouveau_bo_unmap(dec->fence_bo);<br>
+ dec->fence_map[0] = 0;<br>
+<br>
+ if (is8274)<br>
+ MARK_RING(chan, 25, 3);<br>
+ else<br>
+ MARK_RING(chan, 20, 2);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV31_MPEG_DMA_CMD, 1);<br>
+ OUT_RING(chan, chan->vram->handle);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV31_MPEG_DMA_DATA, 1);<br>
+ OUT_RING(chan, chan->vram->handle);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV31_MPEG_DMA_IMAGE, 1);<br>
+ OUT_RING(chan, chan->vram->handle);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV31_MPEG_PITCH, 2);<br>
+ OUT_RING(chan, width | NV31_MPEG_PITCH_UNK);<br>
+ OUT_RING(chan, (height << NV31_MPEG_SIZE_H__SHIFT) | width);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV31_MPEG_FORMAT, 2);<br>
+ OUT_RING(chan, 0);<br>
+ switch (entrypoint) {<br>
+ case PIPE_VIDEO_ENTRYPOINT_BITSTREAM: OUT_RING(chan, 0x100); break;<br>
+ case PIPE_VIDEO_ENTRYPOINT_IDCT: OUT_RING(chan, 1); break;<br>
+ case PIPE_VIDEO_ENTRYPOINT_MC: OUT_RING(chan, 0); break;<br>
+ default: assert(0);<br>
+ }<br>
+<br>
+ if (is8274) {<br>
+ BEGIN_RING(chan, mpeg, NV84_MPEG_DMA_QUERY, 1);<br>
+ OUT_RING(chan, chan->vram->handle);<br>
+<br>
+ BEGIN_RING(chan, mpeg, NV84_MPEG_QUERY_OFFSET, 2);<br>
+ OUT_RELOCl(chan, dec->fence_bo, 0, NOUVEAU_BO_WR|NOUVEAU_BO_GART);<br>
+ OUT_RING(chan, dec->fence_seq);<br>
+ }<br>
+<br>
+ ret = nouveau_vpe_init(dec);<br>
+ if (ret)<br>
+ goto fail;<br>
+ nouveau_vpe_fini(dec);<br>
+ return &dec->base;<br>
+<br>
+fail:<br>
+ nouveau_decoder_destroy(&dec->base);<br>
+ return NULL;<br>
+<br>
+vl:<br>
+ debug_printf("Using g3dvl renderer\n");<br>
+ return vl_create_decoder(context, profile, entrypoint,<br>
+ chroma_format, width, height);<br>
+}<br>
+<br>
+static struct pipe_sampler_view **<br>
+nouveau_video_buffer_sampler_view_planes(struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_video_buffer *buf = (struct nouveau_video_buffer *)buffer;<br>
+ struct pipe_sampler_view sv_templ;<br>
+ struct pipe_context *pipe;<br>
+ unsigned i;<br>
+<br>
+ assert(buf);<br>
+<br>
+ pipe = buf->base.context;<br>
+<br>
+ for (i = 0; i < buf->num_planes; ++i ) {<br>
+ if (!buf->sampler_view_planes[i]) {<br>
+ memset(&sv_templ, 0, sizeof(sv_templ));<br>
+ u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);<br>
+<br>
+ if (util_format_get_nr_components(buf->resources[i]->format) == 1)<br>
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = sv_templ.swizzle_a = PIPE_SWIZZLE_RED;<br>
+<br>
+ buf->sampler_view_planes[i] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);<br>
+ if (!buf->sampler_view_planes[i])<br>
+ goto error;<br>
+ }<br>
+ }<br>
+<br>
+ return buf->sampler_view_planes;<br>
+<br>
+error:<br>
+ for (i = 0; i < buf->num_planes; ++i )<br>
+ pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+static struct pipe_sampler_view **<br>
+nouveau_video_buffer_sampler_view_components(struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_video_buffer *buf = (struct nouveau_video_buffer *)buffer;<br>
+ struct pipe_sampler_view sv_templ;<br>
+ struct pipe_context *pipe;<br>
+ unsigned i, j, component;<br>
+<br>
+ assert(buf);<br>
+<br>
+ pipe = buf->base.context;<br>
+<br>
+ for (component = 0, i = 0; i < buf->num_planes; ++i ) {<br>
+ unsigned nr_components = util_format_get_nr_components(buf->resources[i]->format);<br>
+<br>
+ for (j = 0; j < nr_components; ++j, ++component) {<br>
+ assert(component < VL_MAX_PLANES);<br>
+<br>
+ if (!buf->sampler_view_components[component]) {<br>
+ memset(&sv_templ, 0, sizeof(sv_templ));<br>
+ u_sampler_view_default_template(&sv_templ, buf->resources[i], buf->resources[i]->format);<br>
+ sv_templ.swizzle_r = sv_templ.swizzle_g = sv_templ.swizzle_b = PIPE_SWIZZLE_RED + j;<br>
+ sv_templ.swizzle_a = PIPE_SWIZZLE_ONE;<br>
+ buf->sampler_view_components[component] = pipe->create_sampler_view(pipe, buf->resources[i], &sv_templ);<br>
+ if (!buf->sampler_view_components[component])<br>
+ goto error;<br>
+ }<br>
+ }<br>
+ }<br>
+<br>
+ return buf->sampler_view_components;<br>
+<br>
+error:<br>
+ for (i = 0; i < 3; ++i )<br>
+ pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+static struct pipe_surface **<br>
+nouveau_video_buffer_surfaces(struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_video_buffer *buf = (struct nouveau_video_buffer *)buffer;<br>
+ struct pipe_surface surf_templ;<br>
+ struct pipe_context *pipe;<br>
+ unsigned i;<br>
+<br>
+ assert(buf);<br>
+<br>
+ pipe = buf->base.context;<br>
+<br>
+ for (i = 0; i < buf->num_planes; ++i ) {<br>
+ if (!buf->surfaces[i]) {<br>
+ memset(&surf_templ, 0, sizeof(surf_templ));<br>
+ surf_templ.format = buf->resources[i]->format;<br>
+ surf_templ.usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;<br>
+ buf->surfaces[i] = pipe->create_surface(pipe, buf->resources[i], &surf_templ);<br>
+ if (!buf->surfaces[i])<br>
+ goto error;<br>
+ }<br>
+ }<br>
+<br>
+ return buf->surfaces;<br>
+<br>
+error:<br>
+ for (i = 0; i < buf->num_planes; ++i )<br>
+ pipe_surface_reference(&buf->surfaces[i], NULL);<br>
+<br>
+ return NULL;<br>
+}<br>
+<br>
+static void<br>
+nouveau_video_buffer_destroy(struct pipe_video_buffer *buffer)<br>
+{<br>
+ struct nouveau_video_buffer *buf = (struct nouveau_video_buffer *)buffer;<br>
+ unsigned i;<br>
+<br>
+ assert(buf);<br>
+<br>
+ for (i = 0; i < buf->num_planes; ++i) {<br>
+ pipe_surface_reference(&buf->surfaces[i], NULL);<br>
+ pipe_sampler_view_reference(&buf->sampler_view_planes[i], NULL);<br>
+ pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);<br>
+ pipe_resource_reference(&buf->resources[i], NULL);<br>
+ }<br>
+ for (;i < 3;++i)<br>
+ pipe_sampler_view_reference(&buf->sampler_view_components[i], NULL);<br>
+<br>
+ FREE(buffer);<br>
+}<br>
+<br>
+static struct pipe_video_buffer *<br>
+nouveau_video_buffer_create(struct pipe_context *pipe,<br>
+ struct nouveau_screen *screen,<br>
+ enum pipe_format buffer_format,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_video_buffer *buffer;<br>
+ struct pipe_resource templ;<br>
+<br>
+ /* Only do a linear surface when a hardware decoder is used<br>
+ * hardware decoder is only supported on some chipsets<br>
+ * and it only supports the NV12 format<br>
+ */<br>
+ if (buffer_format != PIPE_FORMAT_NV12 || getenv("XVMC_VL") ||<br>
+ (screen->device->chipset >= 0x98 && screen->device->chipset != 0xa0))<br>
+ return vl_video_buffer_create(pipe, buffer_format, chroma_format, width, height);<br>
+<br>
+ assert(chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);<br>
+ width = align(width, 64);<br>
+ height = align(height, 64);<br>
+<br>
+ buffer = CALLOC_STRUCT(nouveau_video_buffer);<br>
+ if (!buffer)<br>
+ return NULL;<br>
+<br>
+ buffer->base.context = pipe;<br>
+ buffer->base.destroy = nouveau_video_buffer_destroy;<br>
+ buffer->base.get_sampler_view_planes = nouveau_video_buffer_sampler_view_planes;<br>
+ buffer->base.get_sampler_view_components = nouveau_video_buffer_sampler_view_components;<br>
+ buffer->base.get_surfaces = nouveau_video_buffer_surfaces;<br>
+ buffer->base.chroma_format = chroma_format;<br>
+ buffer->base.width = width;<br>
+ buffer->base.height = height;<br>
+ buffer->num_planes = 2;<br>
+<br>
+ memset(&templ, 0, sizeof(templ));<br>
+ templ.target = PIPE_TEXTURE_2D;<br>
+ templ.format = PIPE_FORMAT_R8_UNORM;<br>
+ templ.width0 = width;<br>
+ templ.height0 = height;<br>
+ templ.depth0 = 1;<br>
+ templ.array_size = 1;<br>
+ templ.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;<br>
+ templ.usage = PIPE_USAGE_STATIC;<br>
+ templ.flags = NOUVEAU_RESOURCE_FLAG_LINEAR;<br>
+<br>
+ buffer->resources[0] = pipe->screen->resource_create(pipe->screen, &templ);<br>
+ if (!buffer->resources[0])<br>
+ goto error;<br>
+ templ.width0 /= 2;<br>
+ templ.height0 /= 2;<br>
+ templ.format = PIPE_FORMAT_R8G8_UNORM;<br>
+ buffer->resources[1] = pipe->screen->resource_create(pipe->screen, &templ);<br>
+ if (!buffer->resources[1])<br>
+ goto error;<br>
+ return &buffer->base;<br>
+<br>
+error:<br>
+ nouveau_video_buffer_destroy(&buffer->base);<br>
+ FREE(buffer);<br>
+ return NULL;<br>
+}<br>
<br>
static int<br>
nouveau_screen_get_video_param(struct pipe_screen *pscreen,<br>
@@ -33,9 +866,60 @@ nouveau_screen_init_vdec(struct nouveau_screen *screen)<br>
screen->base.is_video_format_supported = vl_video_buffer_is_format_supported;<br>
}<br>
<br>
+static struct pipe_video_decoder *<br>
+nvfx_context_create_decoder(struct pipe_context *context,<br>
+ enum pipe_video_profile profile,<br>
+ enum pipe_video_entrypoint entrypoint,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_screen *screen = &nvfx_context(context)->screen->base;<br>
+ return nouveau_create_decoder(context, screen, profile, entrypoint,<br>
+ chroma_format, width, height);<br>
+}<br>
+<br>
+static struct pipe_video_buffer *<br>
+nvfx_context_video_buffer_create(struct pipe_context *pipe,<br>
+ enum pipe_format buffer_format,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_screen *screen = &nvfx_context(pipe)->screen->base;<br>
+ return nouveau_video_buffer_create(pipe, screen, buffer_format, chroma_format, width, height);<br>
+}<br>
+<br>
+void<br>
+nvfx_context_init_vdec(struct nvfx_context *nv)<br>
+{<br>
+ nv->pipe.create_video_decoder = nvfx_context_create_decoder;<br>
+ nv->pipe.create_video_buffer = nvfx_context_video_buffer_create;<br>
+}<br>
+<br>
+static struct pipe_video_decoder *<br>
+nouveau_context_create_decoder(struct pipe_context *context,<br>
+ enum pipe_video_profile profile,<br>
+ enum pipe_video_entrypoint entrypoint,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_screen *screen = nouveau_context(context)->screen;<br>
+ return nouveau_create_decoder(context, screen, profile, entrypoint,<br>
+ chroma_format, width, height);<br>
+}<br>
+<br>
+static struct pipe_video_buffer *<br>
+nouveau_context_video_buffer_create(struct pipe_context *pipe,<br>
+ enum pipe_format buffer_format,<br>
+ enum pipe_video_chroma_format chroma_format,<br>
+ unsigned width, unsigned height)<br>
+{<br>
+ struct nouveau_screen *screen = nouveau_context(pipe)->screen;<br>
+ return nouveau_video_buffer_create(pipe, screen, buffer_format, chroma_format, width, height);<br>
+}<br>
+<br>
void<br>
nouveau_context_init_vdec(struct nouveau_context *nv)<br>
{<br>
- nv->pipe.create_video_decoder = vl_create_decoder;<br>
- nv->pipe.create_video_buffer = vl_video_buffer_create;<br>
+ nv->pipe.create_video_decoder = nouveau_context_create_decoder;<br>
+ nv->pipe.create_video_buffer = nouveau_context_video_buffer_create;<br>
}<br>
diff --git a/src/gallium/drivers/nouveau/nouveau_video.h b/src/gallium/drivers/nouveau/nouveau_video.h<br>
new file mode 100644<br>
index 0000000..c6875c3<br>
--- /dev/null<br>
+++ b/src/gallium/drivers/nouveau/nouveau_video.h<br>
@@ -0,0 +1,42 @@<br>
+#ifndef __NOUVEAU_VIDEO_H__<br>
+#define __NOUVEAU_SCREEN_H__<br>
+<br>
+#include "nv17_mpeg.xml.h"<br>
+#include "nv31_mpeg.xml.h"<br>
+<br>
+struct nouveau_video_buffer {<br>
+ struct pipe_video_buffer base;<br>
+ unsigned num_planes;<br>
+ struct pipe_resource *resources[2];<br>
+ struct pipe_sampler_view *sampler_view_planes[2];<br>
+ struct pipe_sampler_view *sampler_view_components[3];<br>
+ struct pipe_surface *surfaces[2];<br>
+};<br>
+<br>
+struct nouveau_decoder {<br>
+ struct pipe_video_decoder base;<br>
+ struct nouveau_screen *screen;<br>
+ struct nouveau_grobj *mpeg;<br>
+ struct nouveau_bo *cmd_bo, *data_bo, *fence_bo;<br>
+<br>
+ unsigned *fence_map;<br>
+ unsigned fence_seq;<br>
+<br>
+ unsigned ofs;<br>
+ unsigned *cmds;<br>
+<br>
+ unsigned *data;<br>
+ unsigned data_pos;<br>
+ unsigned picture_structure;<br>
+<br>
+ unsigned past, future, current;<br>
+ unsigned num_surfaces;<br>
+ struct nouveau_video_buffer *surfaces[8];<br>
+};<br>
+<br>
+static INLINE void<br>
+nouveau_vpe_write(struct nouveau_decoder *dec, unsigned data) {<br>
+ dec->cmds[dec->ofs++] = data;<br>
+}<br>
+<br>
+#endif<br>
diff --git a/src/gallium/drivers/nouveau/nv17_mpeg.xml.h b/src/gallium/drivers/nouveau/nv17_mpeg.xml.h<br>
new file mode 100644<br>
index 0000000..a27310f<br>
--- /dev/null<br>
+++ b/src/gallium/drivers/nouveau/nv17_mpeg.xml.h<br>
@@ -0,0 +1,265 @@<br>
+#ifndef ___RNNDB_NV17_MPEG_XML<br>
+#define ___RNNDB_NV17_MPEG_XML<br>
+<br>
+/* Autogenerated file, DO NOT EDIT manually!<br>
+<br>
+This file was generated by the rules-ng-ng headergen tool in this git repository:<br>
+<a href="http://0x04.net/cgit/index.cgi/rules-ng-ng" target="_blank">http://0x04.net/cgit/index.cgi/rules-ng-ng</a><br>
+git clone git://<a href="http://0x04.net/rules-ng-ng" target="_blank">0x04.net/rules-ng-ng</a><br>
+<br>
+The rules-ng-ng source files this header was generated from are:<br>
+- ../rnndb/nv17_mpeg.xml ( 6846 bytes, from 2011-08-08 14:21:26)<br>
+- ../rnndb/copyright.xml ( 6452 bytes, from 2011-07-15 12:42:43)<br>
+- ../rnndb/nvchipsets.xml ( 3617 bytes, from 2011-07-22 11:37:48)<br>
+<br>
+Copyright (C) 2006-2011 by the following authors:<br>
+- Artur Huillet <<a href="mailto:arthur.huillet@free.fr">arthur.huillet@free.fr</a>> (ahuillet)<br>
+- Ben Skeggs (darktama, darktama_)<br>
+- B. R. <<a href="mailto:koala_br@users.sourceforge.net">koala_br@users.sourceforge.net</a>> (koala_br)<br>
+- Carlos Martin <<a href="mailto:carlosmn@users.sf.net">carlosmn@users.sf.net</a>> (carlosmn)<br>
+- Christoph Bumiller <<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>> (calim, chrisbmr)<br>
+- Dawid Gajownik <<a href="mailto:gajownik@users.sf.net">gajownik@users.sf.net</a>> (gajownik)<br>
+- Dmitry Baryshkov<br>
+- Dmitry Eremin-Solenikov <<a href="mailto:lumag@users.sf.net">lumag@users.sf.net</a>> (lumag)<br>
+- EdB <<a href="mailto:edb_@users.sf.net">edb_@users.sf.net</a>> (edb_)<br>
+- Erik Waling <<a href="mailto:erikwailing@users.sf.net">erikwailing@users.sf.net</a>> (erikwaling)<br>
+- Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> (curro)<br>
+- imirkin <<a href="mailto:imirkin@users.sf.net">imirkin@users.sf.net</a>> (imirkin)<br>
+- jb17bsome <<a href="mailto:jb17bsome@bellsouth.net">jb17bsome@bellsouth.net</a>> (jb17bsome)<br>
+- Jeremy Kolb <<a href="mailto:kjeremy@users.sf.net">kjeremy@users.sf.net</a>> (kjeremy)<br>
+- Laurent Carlier <<a href="mailto:lordheavym@gmail.com">lordheavym@gmail.com</a>> (lordheavy)<br>
+- Luca Barbieri <<a href="mailto:luca@luca-barbieri.com">luca@luca-barbieri.com</a>> (lb, lb1)<br>
+- Maarten Maathuis <<a href="mailto:madman2003@gmail.com">madman2003@gmail.com</a>> (stillunknown)<br>
+- Marcin Kościelnicki <<a href="mailto:koriakin@0x04.net">koriakin@0x04.net</a>> (mwk, koriakin)<br>
+- Mark Carey <<a href="mailto:mark.carey@gmail.com">mark.carey@gmail.com</a>> (careym)<br>
+- Matthieu Castet <<a href="mailto:matthieu.castet@parrot.com">matthieu.castet@parrot.com</a>> (mat-c)<br>
+- nvidiaman <<a href="mailto:nvidiaman@users.sf.net">nvidiaman@users.sf.net</a>> (nvidiaman)<br>
+- Patrice Mandin <<a href="mailto:patmandin@gmail.com">patmandin@gmail.com</a>> (pmandin, pmdata)<br>
+- Pekka Paalanen <<a href="mailto:pq@iki.fi">pq@iki.fi</a>> (pq, ppaalanen)<br>
+- Peter Popov <<a href="mailto:ironpeter@users.sf.net">ironpeter@users.sf.net</a>> (ironpeter)<br>
+- Richard Hughes <<a href="mailto:hughsient@users.sf.net">hughsient@users.sf.net</a>> (hughsient)<br>
+- Rudi Cilibrasi <<a href="mailto:cilibrar@users.sf.net">cilibrar@users.sf.net</a>> (cilibrar)<br>
+- Serge Martin<br>
+- Simon Raffeiner<br>
+- Stephane Loeuillet <<a href="mailto:leroutier@users.sf.net">leroutier@users.sf.net</a>> (leroutier)<br>
+- Stephane Marchesin <<a href="mailto:stephane.marchesin@gmail.com">stephane.marchesin@gmail.com</a>> (marcheu)<br>
+- sturmflut <<a href="mailto:sturmflut@users.sf.net">sturmflut@users.sf.net</a>> (sturmflut)<br>
+- Sylvain Munaut <tnt@246tNt.com><br>
+- Victor Stinner <<a href="mailto:victor.stinner@haypocalc.com">victor.stinner@haypocalc.com</a>> (haypo)<br>
+- Wladmir van der Laan <<a href="mailto:laanwj@gmail.com">laanwj@gmail.com</a>> (miathan6)<br>
+- Younes Manton <<a href="mailto:younes.m@gmail.com">younes.m@gmail.com</a>> (ymanton)<br>
+<br>
+Permission is hereby granted, free of charge, to any person obtaining<br>
+a copy of this software and associated documentation files (the<br>
+"Software"), to deal in the Software without restriction, including<br>
+without limitation the rights to use, copy, modify, merge, publish,<br>
+distribute, sublicense, and/or sell copies of the Software, and to<br>
+permit persons to whom the Software is furnished to do so, subject to<br>
+the following conditions:<br>
+<br>
+The above copyright notice and this permission notice (including the<br>
+next paragraph) shall be included in all copies or substantial<br>
+portions of the Software.<br>
+<br>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE<br>
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION<br>
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION<br>
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+*/<br>
+<br>
+<br>
+#define NV17_MPEG_CMD_NOP_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_NOP_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_NOP_OP_NOP 0x10000000<br>
+#define NV17_MPEG_CMD_SURFACE_OFFSET__MASK 0x00ffffff<br>
+#define NV17_MPEG_CMD_SURFACE_OFFSET__SHIFT 0<br>
+#define NV17_MPEG_CMD_SURFACE_OFFSET__SHR 5<br>
+#define NV17_MPEG_CMD_SURFACE_PLANE__MASK 0x01000000<br>
+#define NV17_MPEG_CMD_SURFACE_PLANE__SHIFT 24<br>
+#define NV17_MPEG_CMD_SURFACE_PLANE_LUMA 0x00000000<br>
+#define NV17_MPEG_CMD_SURFACE_PLANE_CHROMA 0x01000000<br>
+#define NV17_MPEG_CMD_SURFACE_INDEX__MASK 0x0e000000<br>
+#define NV17_MPEG_CMD_SURFACE_INDEX__SHIFT 25<br>
+#define NV17_MPEG_CMD_SURFACE_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_SURFACE_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_SURFACE_OP_SURFACE 0x20000000<br>
+#define NV17_MPEG_CMD_SIZE_WIDTH__MASK 0x000007ff<br>
+#define NV17_MPEG_CMD_SIZE_WIDTH__SHIFT 0<br>
+#define NV17_MPEG_CMD_SIZE_HEIGHT__MASK 0x007ff000<br>
+#define NV17_MPEG_CMD_SIZE_HEIGHT__SHIFT 12<br>
+#define NV17_MPEG_CMD_SIZE_OP__MASK 0xff000000<br>
+#define NV17_MPEG_CMD_SIZE_OP__SHIFT 24<br>
+#define NV17_MPEG_CMD_SIZE_OP_SIZE 0x30000000<br>
+#define NV17_MPEG_CMD_PITCH_PITCH__MASK 0x0000007f<br>
+#define NV17_MPEG_CMD_PITCH_PITCH__SHIFT 0<br>
+#define NV17_MPEG_CMD_PITCH_OP__MASK 0xff000000<br>
+#define NV17_MPEG_CMD_PITCH_OP__SHIFT 24<br>
+#define NV17_MPEG_CMD_PITCH_OP_PITCH 0x31000000<br>
+#define NV17_MPEG_CMD_MODE_IDCT_ENABLE 0x00000001<br>
+#define NV17_MPEG_CMD_MODE_IQ_ENABLE 0x00000010<br>
+#define NV17_MPEG_CMD_MODE_OP__MASK 0xff000000<br>
+#define NV17_MPEG_CMD_MODE_OP__SHIFT 24<br>
+#define NV17_MPEG_CMD_MODE_OP_MODE 0x32000000<br>
+#define NV17_MPEG_CMD_IQ_SETUP_QUANT_SCALE__MASK 0x000001fe<br>
+#define NV17_MPEG_CMD_IQ_SETUP_QUANT_SCALE__SHIFT 1<br>
+#define NV17_MPEG_CMD_IQ_SETUP_INTRA_DC_MULT__MASK 0x00001e00<br>
+#define NV17_MPEG_CMD_IQ_SETUP_INTRA_DC_MULT__SHIFT 9<br>
+#define NV17_MPEG_CMD_IQ_SETUP_UNK13__MASK 0x00006000<br>
+#define NV17_MPEG_CMD_IQ_SETUP_UNK13__SHIFT 13<br>
+#define NV17_MPEG_CMD_IQ_SETUP_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_IQ_SETUP_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_IQ_SETUP_OP_IQ_SETUP 0x40000000<br>
+#define NV17_MPEG_CMD_IQ_MATRIX_INTRA 0x00000001<br>
+#define NV17_MPEG_CMD_IQ_MATRIX_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_IQ_MATRIX_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_IQ_MATRIX_OP_IQ_MATRIX 0x50000000<br>
+#define NV17_MPEG_CMD_BLOCK_DATA_INTRA 0x00000001<br>
+#define NV17_MPEG_CMD_BLOCK_DATA_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_BLOCK_DATA_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_BLOCK_DATA_OP_BLOCK_DATA 0x60000000<br>
+#define NV17_MPEG_BLOCK_DATA_LAST 0x00000001<br>
+#define NV17_MPEG_BLOCK_DATA_IDX__MASK 0x0000003e<br>
+#define NV17_MPEG_BLOCK_DATA_IDX__SHIFT 1<br>
+#define NV17_MPEG_BLOCK_DATA_IDX__SHR 1<br>
+#define NV17_MPEG_BLOCK_DATA_COORD1__MASK 0x0003ffc0<br>
+#define NV17_MPEG_BLOCK_DATA_COORD1__SHIFT 6<br>
+#define NV17_MPEG_BLOCK_DATA_COORD1_FORCE_0 0x00010000<br>
+#define NV17_MPEG_BLOCK_DATA_COORD0__MASK 0x7ff80000<br>
+#define NV17_MPEG_BLOCK_DATA_COORD0__SHIFT 19<br>
+#define NV17_MPEG_BLOCK_DATA_COORD0_FORCE_0 0x80000000<br>
+#define NV17_MPEG_CMD_SYNC_INTR 0x00000001<br>
+#define NV17_MPEG_CMD_SYNC_OP__MASK 0xff000000<br>
+#define NV17_MPEG_CMD_SYNC_OP__SHIFT 24<br>
+#define NV17_MPEG_CMD_SYNC_OP_SYNC 0x70000000<br>
+#define NV17_MPEG_CMD_SEQUENCE_OP__MASK 0xff000000<br>
+#define NV17_MPEG_CMD_SEQUENCE_OP__SHIFT 24<br>
+#define NV17_MPEG_CMD_SEQUENCE_OP_SEQUENCE 0x71000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_X_COORD__MASK 0x00008000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_X_COORD__SHIFT 15<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_X_COORD_ODD 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_X_COORD_EVEN 0x00008000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_RUN__MASK 0x00010000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_RUN__SHIFT 16<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_RUN_DOUBLE 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_RUN_SINGLE 0x00010000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FIELD__MASK 0x00020000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FIELD__SHIFT 17<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FIELD_TOP 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FIELD_BOTTOM 0x00020000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_TYPE__MASK 0x00080000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_TYPE__SHIFT 19<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_TYPE_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_TYPE_FRAME 0x00080000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_SURFACE__MASK 0x00700000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_SURFACE__SHIFT 20<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FRAME_DCT_TYPE__MASK 0x00800000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FRAME_DCT_TYPE__SHIFT 23<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FRAME_DCT_TYPE_FRAME 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_FRAME_DCT_TYPE_FIELD 0x00800000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_CBP__MASK 0x0c000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_CBP__SHIFT 26<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_CHROMA_MB_HEADER_OP_CHROMA_MB_HEADER 0x80000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_X_COORD__MASK 0x00008000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_X_COORD__SHIFT 15<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_X_COORD_ODD 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_X_COORD_EVEN 0x00008000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_RUN__MASK 0x00010000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_RUN__SHIFT 16<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_RUN_DOUBLE 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_RUN_SINGLE 0x00010000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FIELD__MASK 0x00020000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FIELD__SHIFT 17<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FIELD_TOP 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FIELD_BOTTOM 0x00020000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_TYPE__MASK 0x00080000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_TYPE__SHIFT 19<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_TYPE_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_TYPE_FRAME 0x00080000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_SURFACE__MASK 0x00700000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_SURFACE__SHIFT 20<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FRAME_DCT_TYPE__MASK 0x00800000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FRAME_DCT_TYPE__SHIFT 23<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FRAME_DCT_TYPE_FRAME 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_FRAME_DCT_TYPE_FIELD 0x00800000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_CBP__MASK 0x0f000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_CBP__SHIFT 24<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_LUMA_MB_HEADER_OP_LUMA_MB_HEADER 0x90000000<br>
+#define NV17_MPEG_CMD_MB_COORDS_X__MASK 0x000007ff<br>
+#define NV17_MPEG_CMD_MB_COORDS_X__SHIFT 0<br>
+#define NV17_MPEG_CMD_MB_COORDS_Y__MASK 0x007ff000<br>
+#define NV17_MPEG_CMD_MB_COORDS_Y__SHIFT 12<br>
+#define NV17_MPEG_CMD_MB_COORDS_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_MB_COORDS_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_MB_COORDS_OP_MB_COORDS 0xa0000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT__MASK 0x00010000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT__SHIFT 16<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT_1 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_COUNT_2 0x00010000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_FIELD__MASK 0x00020000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_FIELD__SHIFT 17<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_FIELD_TOP 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_FIELD_BOTTOM 0x00020000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE__MASK 0x00080000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE__SHIFT 19<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_TYPE_FRAME 0x00080000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_SURFACE__MASK 0x00700000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_SURFACE__SHIFT 20<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_IDX 0x00800000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT__MASK 0x01000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT__SHIFT 24<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_MV_SPLIT_HALF_MB 0x01000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_Y_HALF 0x02000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_X_HALF 0x04000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_DIRECTION__MASK 0x08000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_DIRECTION__SHIFT 27<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_DIRECTION_FORWARD 0x00000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_DIRECTION_BACKWARD 0x08000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_CHROMA_MV_HEADER_OP_CHROMA_MV_HEADER 0xc0000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_COUNT__MASK 0x00010000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_COUNT__SHIFT 16<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_COUNT_1 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_COUNT_2 0x00010000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_FIELD__MASK 0x00020000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_FIELD__SHIFT 17<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_FIELD_TOP 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_FIELD_BOTTOM 0x00020000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_TYPE__MASK 0x00080000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_TYPE__SHIFT 19<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_TYPE_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_TYPE_FRAME 0x00080000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_SURFACE__MASK 0x00700000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_SURFACE__SHIFT 20<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_IDX 0x00800000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_MV_SPLIT__MASK 0x01000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_MV_SPLIT__SHIFT 24<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_MV_SPLIT_FIELD 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_MV_SPLIT_HALF_MB 0x01000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_Y_HALF 0x02000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_X_HALF 0x04000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_DIRECTION__MASK 0x08000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_DIRECTION__SHIFT 27<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_DIRECTION_FORWARD 0x00000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_DIRECTION_BACKWARD 0x08000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_LUMA_MV_HEADER_OP_LUMA_MV_HEADER 0xd0000000<br>
+#define NV17_MPEG_CMD_MV_COORDS_X__MASK 0x000007ff<br>
+#define NV17_MPEG_CMD_MV_COORDS_X__SHIFT 0<br>
+#define NV17_MPEG_CMD_MV_COORDS_Y__MASK 0x007ff000<br>
+#define NV17_MPEG_CMD_MV_COORDS_Y__SHIFT 12<br>
+#define NV17_MPEG_CMD_MV_COORDS_OP__MASK 0xf0000000<br>
+#define NV17_MPEG_CMD_MV_COORDS_OP__SHIFT 28<br>
+#define NV17_MPEG_CMD_MV_COORDS_OP_MV_COORDS 0xe0000000<br>
+<br>
+#endif /* ___RNNDB_NV17_MPEG_XML */<br>
diff --git a/src/gallium/drivers/nouveau/nv31_mpeg.xml.h b/src/gallium/drivers/nouveau/nv31_mpeg.xml.h<br>
new file mode 100644<br>
index 0000000..a8c1e32<br>
--- /dev/null<br>
+++ b/src/gallium/drivers/nouveau/nv31_mpeg.xml.h<br>
@@ -0,0 +1,130 @@<br>
+#ifndef ___RNNDB_NV31_MPEG_XML<br>
+#define ___RNNDB_NV31_MPEG_XML<br>
+<br>
+/* Autogenerated file, DO NOT EDIT manually!<br>
+<br>
+This file was generated by the rules-ng-ng headergen tool in this git repository:<br>
+<a href="http://0x04.net/cgit/index.cgi/rules-ng-ng" target="_blank">http://0x04.net/cgit/index.cgi/rules-ng-ng</a><br>
+git clone git://<a href="http://0x04.net/rules-ng-ng" target="_blank">0x04.net/rules-ng-ng</a><br>
+<br>
+The rules-ng-ng source files this header was generated from are:<br>
+- ../rnndb/nv31_mpeg.xml ( 2269 bytes, from 2011-08-02 11:17:20)<br>
+- ../rnndb/copyright.xml ( 6452 bytes, from 2011-07-15 12:42:43)<br>
+- ../rnndb/nvchipsets.xml ( 3617 bytes, from 2011-07-22 11:37:48)<br>
+- ../rnndb/nv_object.xml ( 12672 bytes, from 2011-07-15 12:42:43)<br>
+- ../rnndb/nv_defs.xml ( 4437 bytes, from 2011-07-15 12:42:43)<br>
+- ../rnndb/nv50_defs.xml ( 5468 bytes, from 2011-07-15 12:42:43)<br>
+<br>
+Copyright (C) 2006-2011 by the following authors:<br>
+- Artur Huillet <<a href="mailto:arthur.huillet@free.fr">arthur.huillet@free.fr</a>> (ahuillet)<br>
+- Ben Skeggs (darktama, darktama_)<br>
+- B. R. <<a href="mailto:koala_br@users.sourceforge.net">koala_br@users.sourceforge.net</a>> (koala_br)<br>
+- Carlos Martin <<a href="mailto:carlosmn@users.sf.net">carlosmn@users.sf.net</a>> (carlosmn)<br>
+- Christoph Bumiller <<a href="mailto:e0425955@student.tuwien.ac.at">e0425955@student.tuwien.ac.at</a>> (calim, chrisbmr)<br>
+- Dawid Gajownik <<a href="mailto:gajownik@users.sf.net">gajownik@users.sf.net</a>> (gajownik)<br>
+- Dmitry Baryshkov<br>
+- Dmitry Eremin-Solenikov <<a href="mailto:lumag@users.sf.net">lumag@users.sf.net</a>> (lumag)<br>
+- EdB <<a href="mailto:edb_@users.sf.net">edb_@users.sf.net</a>> (edb_)<br>
+- Erik Waling <<a href="mailto:erikwailing@users.sf.net">erikwailing@users.sf.net</a>> (erikwaling)<br>
+- Francisco Jerez <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> (curro)<br>
+- imirkin <<a href="mailto:imirkin@users.sf.net">imirkin@users.sf.net</a>> (imirkin)<br>
+- jb17bsome <<a href="mailto:jb17bsome@bellsouth.net">jb17bsome@bellsouth.net</a>> (jb17bsome)<br>
+- Jeremy Kolb <<a href="mailto:kjeremy@users.sf.net">kjeremy@users.sf.net</a>> (kjeremy)<br>
+- Laurent Carlier <<a href="mailto:lordheavym@gmail.com">lordheavym@gmail.com</a>> (lordheavy)<br>
+- Luca Barbieri <<a href="mailto:luca@luca-barbieri.com">luca@luca-barbieri.com</a>> (lb, lb1)<br>
+- Maarten Maathuis <<a href="mailto:madman2003@gmail.com">madman2003@gmail.com</a>> (stillunknown)<br>
+- Marcin Kościelnicki <<a href="mailto:koriakin@0x04.net">koriakin@0x04.net</a>> (mwk, koriakin)<br>
+- Mark Carey <<a href="mailto:mark.carey@gmail.com">mark.carey@gmail.com</a>> (careym)<br>
+- Matthieu Castet <<a href="mailto:matthieu.castet@parrot.com">matthieu.castet@parrot.com</a>> (mat-c)<br>
+- nvidiaman <<a href="mailto:nvidiaman@users.sf.net">nvidiaman@users.sf.net</a>> (nvidiaman)<br>
+- Patrice Mandin <<a href="mailto:patmandin@gmail.com">patmandin@gmail.com</a>> (pmandin, pmdata)<br>
+- Pekka Paalanen <<a href="mailto:pq@iki.fi">pq@iki.fi</a>> (pq, ppaalanen)<br>
+- Peter Popov <<a href="mailto:ironpeter@users.sf.net">ironpeter@users.sf.net</a>> (ironpeter)<br>
+- Richard Hughes <<a href="mailto:hughsient@users.sf.net">hughsient@users.sf.net</a>> (hughsient)<br>
+- Rudi Cilibrasi <<a href="mailto:cilibrar@users.sf.net">cilibrar@users.sf.net</a>> (cilibrar)<br>
+- Serge Martin<br>
+- Simon Raffeiner<br>
+- Stephane Loeuillet <<a href="mailto:leroutier@users.sf.net">leroutier@users.sf.net</a>> (leroutier)<br>
+- Stephane Marchesin <<a href="mailto:stephane.marchesin@gmail.com">stephane.marchesin@gmail.com</a>> (marcheu)<br>
+- sturmflut <<a href="mailto:sturmflut@users.sf.net">sturmflut@users.sf.net</a>> (sturmflut)<br>
+- Sylvain Munaut <tnt@246tNt.com><br>
+- Victor Stinner <<a href="mailto:victor.stinner@haypocalc.com">victor.stinner@haypocalc.com</a>> (haypo)<br>
+- Wladmir van der Laan <<a href="mailto:laanwj@gmail.com">laanwj@gmail.com</a>> (miathan6)<br>
+- Younes Manton <<a href="mailto:younes.m@gmail.com">younes.m@gmail.com</a>> (ymanton)<br>
+<br>
+Permission is hereby granted, free of charge, to any person obtaining<br>
+a copy of this software and associated documentation files (the<br>
+"Software"), to deal in the Software without restriction, including<br>
+without limitation the rights to use, copy, modify, merge, publish,<br>
+distribute, sublicense, and/or sell copies of the Software, and to<br>
+permit persons to whom the Software is furnished to do so, subject to<br>
+the following conditions:<br>
+<br>
+The above copyright notice and this permission notice (including the<br>
+next paragraph) shall be included in all copies or substantial<br>
+portions of the Software.<br>
+<br>
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,<br>
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF<br>
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.<br>
+IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE<br>
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION<br>
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION<br>
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+*/<br>
+<br>
+<br>
+<br>
+#define NV31_MPEG_PITCH 0x00000160<br>
+#define NV31_MPEG_PITCH_PITCH__MASK 0x00001fff<br>
+#define NV31_MPEG_PITCH_PITCH__SHIFT 0<br>
+#define NV31_MPEG_PITCH_UNK 0x00010000<br>
+<br>
+#define NV31_MPEG_SIZE 0x00000164<br>
+#define NV31_MPEG_SIZE_W__MASK 0x0000ffff<br>
+#define NV31_MPEG_SIZE_W__SHIFT 0<br>
+#define NV31_MPEG_SIZE_H__MASK 0xffff0000<br>
+#define NV31_MPEG_SIZE_H__SHIFT 16<br>
+<br>
+#define NV31_MPEG_DMA_CMD 0x00000190<br>
+<br>
+#define NV31_MPEG_DMA_DATA 0x000001a0<br>
+<br>
+#define NV31_MPEG_DMA_IMAGE 0x000001b0<br>
+<br>
+#define NV84_MPEG_DMA_QUERY 0x000001c0<br>
+<br>
+#define NV31_MPEG_IMAGE_Y_OFFSET(i0) (0x00000200 + 0x8*(i0))<br>
+#define NV31_MPEG_IMAGE_Y_OFFSET__ESIZE 0x00000008<br>
+#define NV31_MPEG_IMAGE_Y_OFFSET__LEN 0x00000008<br>
+<br>
+#define NV31_MPEG_IMAGE_C_OFFSET(i0) (0x00000204 + 0x8*(i0))<br>
+#define NV31_MPEG_IMAGE_C_OFFSET__ESIZE 0x00000008<br>
+#define NV31_MPEG_IMAGE_C_OFFSET__LEN 0x00000008<br>
+<br>
+#define NV31_MPEG_FORMAT 0x00000310<br>
+#define NV31_MPEG_FORMAT_DATA_FORMAT__MASK 0x00000001<br>
+#define NV31_MPEG_FORMAT_DATA_FORMAT__SHIFT 0<br>
+#define NV31_MPEG_FORMAT_DATA_FORMAT_S16 0x00000000<br>
+#define NV31_MPEG_FORMAT_DATA_FORMAT_S8 0x00000001<br>
+#define NV31_MPEG_FORMAT_UNK8 0x00000100<br>
+<br>
+#define NV31_MPEG_IDCT_ENABLE 0x00000314<br>
+<br>
+<br>
+#define NV84_MPEG_QUERY_OFFSET 0x0000031c<br>
+<br>
+#define NV84_MPEG_QUERY_COUNTER 0x00000320<br>
+<br>
+#define NV31_MPEG_CMD_OFFSET 0x00000380<br>
+<br>
+#define NV31_MPEG_CMD_SIZE 0x00000384<br>
+<br>
+#define NV31_MPEG_DATA_OFFSET 0x0000038c<br>
+<br>
+#define NV31_MPEG_DATA_SIZE 0x00000390<br>
+<br>
+#define NV31_MPEG_EXEC 0x00000394<br>
+<br>
+<br>
+#endif /* ___RNNDB_NV31_MPEG_XML */<br>
diff --git a/src/gallium/drivers/nvfx/nvfx_context.c b/src/gallium/drivers/nvfx/nvfx_context.c<br>
index e2cdcf6..37425b1 100644<br>
--- a/src/gallium/drivers/nvfx/nvfx_context.c<br>
+++ b/src/gallium/drivers/nvfx/nvfx_context.c<br>
@@ -90,9 +90,6 @@ nvfx_create(struct pipe_screen *pscreen, void *priv)<br>
nvfx->pipe.clear = nvfx_clear;<br>
nvfx->pipe.flush = nvfx_flush;<br>
<br>
- nvfx->pipe.create_video_decoder = vl_create_decoder;<br>
- nvfx->pipe.create_video_buffer = vl_video_buffer_create;<br>
-<br>
nvfx->is_nv4x = screen->is_nv4x;<br>
nvfx->use_nv4x = screen->use_nv4x;<br>
/* TODO: it seems that nv30 might have fixed function clipping usable with vertex programs<br>
@@ -126,6 +123,7 @@ nvfx_create(struct pipe_screen *pscreen, void *priv)<br>
nvfx->relocs_needed = NVFX_RELOCATE_ALL;<br>
<br>
LIST_INITHEAD(&nvfx->render_cache);<br>
+ nvfx_context_init_vdec(nvfx);<br>
<br>
return &nvfx->pipe;<br>
}<br>
diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h<br>
index dad912b..cb40a52 100644<br>
--- a/src/gallium/drivers/nvfx/nvfx_context.h<br>
+++ b/src/gallium/drivers/nvfx/nvfx_context.h<br>
@@ -340,6 +340,8 @@ extern void nvfx_init_vertprog_functions(struct nvfx_context *nvfx);<br>
/* nvfx_push.c */<br>
extern void nvfx_push_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info);<br>
<br>
+extern void nvfx_context_init_vdec(struct nvfx_context *);<br>
+<br>
static inline void nvfx_emit_vtx_attr(struct nouveau_channel* chan,<br>
struct nouveau_grobj *eng3d, unsigned attrib, const float* v,<br>
unsigned ncomp)<br>
--<br>
1.7.6<br>
<br>
<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div>