Skip to contentSkip to conversation

Add support for MPEG2 and VC-1 on VP3/VP4 for NV98-NVAF

PATCH New Ilia Mirkin 2 participants 11 messages Aug 11, 2013 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

cover Add support for MPEG2 and VC-1 on VP3/VP4 for NV98-NVAF

As it turns out, with the proprietary firmware, the VP3 and VP4 interfaces are identical. Furthermore, this is all already implemented for nvc0. So these patches (a) move the easily sharable bits of the nvc0 implementation into the nouveau directory, and then (b) implement the other parts in nv50. The non-shared parts are still largely copies, but there are some differences, not the least of which is the BEGIN_NV04 vs BEGIN_NVC0 stuff. Probably more refactoring is possible, but right now there is ~1k lines of code in nouveau, and ~1k lines of code in each of nvc0/nvc0_video* and nv50/nv98_video*.

For whatever reason, h264 and mpeg4 don't work "out of the box". With h264, the decoder hangs after decoding a few frames, and I think reports are that mpeg4 just doesn't work at all. (I also seem to remember hearing that mpeg4 didn't work on nvc0+ either, so that's likely related.) I played with it a bunch, but I couldn't figure out what was wrong. Getting h264 to work will be a larger effort, and will be able to build on this patchset. For now h264 and mpeg4 are not reported in the capabilities of pre-nvc0 cards.

This patchset has received limited testing on VP3, pre-nvc0 VP4, post-nvc0 VP4, and VP5. It's worth noting that the mpeg1 decoding looks all weird and blocky, but it's the exact same issue as when using the blob. And the same bug exists on VP2 (although not with mesa/xvmc). They probably are missing some detail about difference of mpeg2 vs mpeg1 (oddification maybe? who knows... same bug exists with mesa/vdpau on top of VP2, so it's something subtle that mplayer/ffmpeg gets right but mesa's and nvidia's mpeg parsers don't).

For people who aren't already intimately familiar with the video decoding acceleration situation on nvidia cards, take a look at
http://nouveau.freedesktop.org/wiki/VideoAcceleration/ for information on how to obtain firmware, what kernels to use, what cards support what, etc.

You can also find these patches at https://github.com/imirkin/mesa.git vp4-2

For reviewing purposes, you might prefer to look at the patches with diff -M
-C although I didn't think that would be appropriate for sending to the ML.

Ilia Mirkin (10):
nvc0: refactor video buffer management logic into nouveau_vp3
nvc0: standardize on using #if for NVC0_DEBUG_FENCE
nvc0: move nvc0_decoder into nouveau, rename to nouveau_vp3_decoder
nvc0: move bsp param-filling logic into nouveau
nvc0: move vp param filling logic into nouveau
nvc0: move some of the simpler decoder functions into nouveau
nvc0: move firmware loading functions to nouveau
nvc0: move video param and format support functions to nouveau
nv50: separate video logic from noalloc
nv50: add vp3/vp4 support for mpeg2/vc1

 src/gallium/drivers/nouveau/Makefile.sources       |   5 +-
 src/gallium/drivers/nouveau/nouveau_vp3_video.c    | 399 ++++++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video.h    | 228 ++++++++++
 .../drivers/nouveau/nouveau_vp3_video_bsp.c        | 310 +++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video_vp.c | 485 ++++++++++++++++++++
 src/gallium/drivers/nv50/Makefile.sources          |   6 +-
 src/gallium/drivers/nv50/nv50_context.c            |   5 +-
 src/gallium/drivers/nv50/nv50_context.h            |  14 +
 src/gallium/drivers/nv50/nv50_miptree.c            |   6 +-
 src/gallium/drivers/nv50/nv50_resource.h           |   1 +
 src/gallium/drivers/nv50/nv50_screen.c             |   7 +-
 src/gallium/drivers/nv50/nv50_winsys.h             |   4 -
 src/gallium/drivers/nv50/nv84_video.c              |   2 +-
 src/gallium/drivers/nv50/nv84_video.h              |   4 +
 src/gallium/drivers/nv50/nv98_video.c              | 308 +++++++++++++
 src/gallium/drivers/nv50/nv98_video.h              |  48 ++
 src/gallium/drivers/nv50/nv98_video_bsp.c          | 159 +++++++
 src/gallium/drivers/nv50/nv98_video_ppp.c          | 143 ++++++
 src/gallium/drivers/nv50/nv98_video_vp.c           | 202 +++++++++
 src/gallium/drivers/nvc0/nvc0_context.h            |   5 -
 src/gallium/drivers/nvc0/nvc0_screen.c             |  18 +-
 src/gallium/drivers/nvc0/nvc0_video.c              | 332 +-------------
 src/gallium/drivers/nvc0/nvc0_video.h              | 191 +-------
 src/gallium/drivers/nvc0/nvc0_video_bsp.c          | 301 +-----------
 src/gallium/drivers/nvc0/nvc0_video_ppp.c          |  16 +-
 src/gallium/drivers/nvc0/nvc0_video_vp.c           | 502 +--------------------
 26 files changed, 2396 insertions(+), 1305 deletions(-)
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video.c
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video.h
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video_bsp.c
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video_vp.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video.h
 create mode 100644 src/gallium/drivers/nv50/nv98_video_bsp.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video_ppp.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video_vp.c
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/10 nvc0: refactor video buffer management logic into nouveau_vp3

---
 src/gallium/drivers/nouveau/Makefile.sources    |   3 +-
 src/gallium/drivers/nouveau/nouveau_vp3_video.c | 165 ++++++++++++++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video.h |  38 ++++++
 src/gallium/drivers/nvc0/nvc0_video.c           | 135 +------------------
 src/gallium/drivers/nvc0/nvc0_video.h           |  29 ++---
 src/gallium/drivers/nvc0/nvc0_video_bsp.c       |   4 +-
 src/gallium/drivers/nvc0/nvc0_video_ppp.c       |   6 +-
 src/gallium/drivers/nvc0/nvc0_video_vp.c        |  38 +++---
 8 files changed, 243 insertions(+), 175 deletions(-)
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video.c
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video.h
src/gallium/drivers/nouveau/Makefile.sources +2 -1
index cc9e68f..f7c9249 100644
@@ -4,4 +4,5 @@ C_SOURCES := \
 	nouveau_mm.c \
 	nouveau_buffer.c \
 	nouveau_heap.c \
-	nouveau_video.c
+	nouveau_video.c \
+	nouveau_vp3_video.c
src/gallium/drivers/nouveau/nouveau_vp3_video.c new file +165 -0

165 lines not on this page · raw message

src/gallium/drivers/nouveau/nouveau_vp3_video.h new file +38 -0
new file mode 100644
index 0000000..bff5d76
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011-2013 Maarten Lankhorst
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "pipe/p_defines.h"
+#include "vl/vl_video_buffer.h"
+
+struct nouveau_vp3_video_buffer {
+   struct pipe_video_buffer base;
+   unsigned num_planes, valid_ref;
+   struct pipe_resource *resources[VL_NUM_COMPONENTS];
+   struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
+   struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
+   struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2];
+};
+
+struct pipe_video_buffer *
+nouveau_vp3_video_buffer_create(struct pipe_context *pipe,
+                                const struct pipe_video_buffer *templat,
+                                int flags);
src/gallium/drivers/nvc0/nvc0_video.c +4 -131

153 lines not on this page · raw message

src/gallium/drivers/nvc0/nvc0_video.h +10 -19
index aed1424..271ed5c 100644
@@ -22,9 +22,9 @@
 
 #include "nvc0_context.h"
 #include "nvc0_screen.h"
+#include "nouveau/nouveau_vp3_video.h"
 
 #include "vl/vl_decoder.h"
-#include "vl/vl_video_buffer.h"
 #include "vl/vl_types.h"
 
 #include "util/u_video.h"
@@ -53,15 +53,6 @@ union pipe_desc {
    struct pipe_h264_picture_desc *h264;
 };
 
-struct nvc0_video_buffer {
-   struct pipe_video_buffer base;
-   unsigned num_planes, valid_ref;
-   struct pipe_resource *resources[VL_NUM_COMPONENTS];
-   struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
-   struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
-   struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2];
-};
-
 struct nvc0_decoder {
    struct pipe_video_decoder base;
    struct nouveau_client *client;
@@ -105,7 +96,7 @@ struct nvc0_decoder {
    // and give shaders a chance to run as well.
 
    struct {
-      struct nvc0_video_buffer *vidbuf;
+      struct nouveau_vp3_video_buffer *vidbuf;
       unsigned last_used;
       unsigned field_pic_flag : 1;
       unsigned decoded_top : 1;
@@ -151,7 +142,7 @@ static INLINE uint32_t mb_half(uint32_t coord)
 }
 
 static INLINE uint64_t
-nvc0_video_addr(struct nvc0_decoder *dec, struct nvc0_video_buffer *target)
+nvc0_video_addr(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer *target)
 {
    uint64_t ret;
    if (target)
@@ -197,25 +188,25 @@ nvc0_decoder_inter_sizes(struct nvc0_decoder *dec, uint32_t slice_count,
 
 extern unsigned
 nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
-                 struct nvc0_video_buffer *target,
+                 struct nouveau_vp3_video_buffer *target,
                  unsigned comm_seq, unsigned num_buffers,
                  const void *const *data, const unsigned *num_bytes,
                  unsigned *vp_caps, unsigned *is_ref,
-                 struct nvc0_video_buffer *refs[16]);
+                 struct nouveau_vp3_video_buffer *refs[16]);
 
 extern void nvc0_decoder_vp_caps(struct nvc0_decoder *dec,
                                  union pipe_desc desc,
-                                 struct nvc0_video_buffer *target,
+                                 struct nouveau_vp3_video_buffer *target,
                                  unsigned comm_seq,
                                  unsigned *caps, unsigned *is_ref,
-                                 struct nvc0_video_buffer *refs[16]);
+                                 struct nouveau_vp3_video_buffer *refs[16]);
 
 extern void
 nvc0_decoder_vp(struct nvc0_decoder *dec, union pipe_desc desc,
-                struct nvc0_video_buffer *target, unsigned comm_seq,
+                struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
                 unsigned caps, unsigned is_ref,
-                struct nvc0_video_buffer *refs[16]);
+                struct nouveau_vp3_video_buffer *refs[16]);
 
 extern void
 nvc0_decoder_ppp(struct nvc0_decoder *dec, union pipe_desc desc,
-                 struct nvc0_video_buffer *target, unsigned comm_seq);
+                 struct nouveau_vp3_video_buffer *target, unsigned comm_seq);
src/gallium/drivers/nvc0/nvc0_video_bsp.c +2 -2
index 450dc2b..8f93861 100644
@@ -241,11 +241,11 @@ static void dump_comm_bsp(struct comm *comm)
 
 unsigned
 nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
-                 struct nvc0_video_buffer *target,
+                 struct nouveau_vp3_video_buffer *target,
                  unsigned comm_seq, unsigned num_buffers,
                  const void *const *data, const unsigned *num_bytes,
                  unsigned *vp_caps, unsigned *is_ref,
-                 struct nvc0_video_buffer *refs[16])
+                 struct nouveau_vp3_video_buffer *refs[16])
 {
    struct nouveau_pushbuf *push = dec->pushbuf[0];
    enum pipe_video_codec codec = u_reduce_video_profile(dec->base.profile);
src/gallium/drivers/nvc0/nvc0_video_ppp.c +3 -3
index efa2527..823e360 100644
@@ -23,7 +23,7 @@
 #include "nvc0_video.h"
 
 static void
-nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nvc0_video_buffer *target, uint32_t low700) {
+nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer *target, uint32_t low700) {
    struct nouveau_pushbuf *push = dec->pushbuf[2];
 
    uint32_t stride_in = mb(dec->base.width);
@@ -73,7 +73,7 @@ nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nvc0_video_buffer *targe
 }
 
 static uint32_t
-nvc0_decoder_vc1_ppp(struct nvc0_decoder *dec, struct pipe_vc1_picture_desc *desc, struct nvc0_video_buffer *target) {
+nvc0_decoder_vc1_ppp(struct nvc0_decoder *dec, struct pipe_vc1_picture_desc *desc, struct nouveau_vp3_video_buffer *target) {
    struct nouveau_pushbuf *push = dec->pushbuf[2];
 
    nvc0_decoder_setup_ppp(dec, target, 0x1412);
@@ -89,7 +89,7 @@ nvc0_decoder_vc1_ppp(struct nvc0_decoder *dec, struct pipe_vc1_picture_desc *des
 }
 
 void
-nvc0_decoder_ppp(struct nvc0_decoder *dec, union pipe_desc desc, struct nvc0_video_buffer *target, unsigned comm_seq) {
+nvc0_decoder_ppp(struct nvc0_decoder *dec, union pipe_desc desc, struct nouveau_vp3_video_buffer *target, unsigned comm_seq) {
    enum pipe_video_codec codec = u_reduce_video_profile(dec->base.profile);
    struct nouveau_pushbuf *push = dec->pushbuf[2];
    unsigned ppp_caps = 0x10;
src/gallium/drivers/nvc0/nvc0_video_vp.c +19 -19
index c5d4f94..7c1691c 100644
@@ -170,7 +170,7 @@ struct h264_picparm_vp { // 700..a00
 };
 
 static void
-nvc0_decoder_handle_references(struct nvc0_decoder *dec, struct nvc0_video_buffer *refs[16], unsigned seq, struct nvc0_video_buffer *target)
+nvc0_decoder_handle_references(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer *refs[16], unsigned seq, struct nouveau_vp3_video_buffer *target)
 {
    unsigned h264 = u_reduce_video_profile(dec->base.profile) == PIPE_VIDEO_CODEC_MPEG4_AVC;
    unsigned i, idx, empty_spot = dec->base.max_references + 1;
@@ -221,7 +221,7 @@ nvc0_decoder_handle_references(struct nvc0_decoder *dec, struct nvc0_video_buffe
 }
 
 static void
-nvc0_decoder_kick_ref(struct nvc0_decoder *dec, struct nvc0_video_buffer *target)
+nvc0_decoder_kick_ref(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer *target)
 {
    dec->refs[target->valid_ref].vidbuf = NULL;
    dec->refs[target->valid_ref].last_used = 0;
@@ -231,7 +231,7 @@ nvc0_decoder_kick_ref(struct nvc0_decoder *dec, struct nvc0_video_buffer *target
 static uint32_t
 nvc0_decoder_fill_picparm_mpeg12_vp(struct nvc0_decoder *dec,
                                     struct pipe_mpeg12_picture_desc *desc,
-                                    struct nvc0_video_buffer *refs[16],
+                                    struct nouveau_vp3_video_buffer *refs[16],
                                     unsigned *is_ref,
                                     char *map)
 {
@@ -272,15 +272,15 @@ nvc0_decoder_fill_picparm_mpeg12_vp(struct nvc0_decoder *dec,
    memcpy(pic_vp->intra_quantizer_matrix, desc->intra_matrix, 0x40);
    memcpy(pic_vp->non_intra_quantizer_matrix, desc->non_intra_matrix, 0x40);
    memcpy(map, pic_vp, sizeof(*pic_vp));
-   refs[0] = (struct nvc0_video_buffer *)desc->ref[0];
-   refs[!!refs[0]] = (struct nvc0_video_buffer *)desc->ref[1];
+   refs[0] = (struct nouveau_vp3_video_buffer *)desc->ref[0];
+   refs[!!refs[0]] = (struct nouveau_vp3_video_buffer *)desc->ref[1];
    return ret | (dec->base.profile != PIPE_VIDEO_PROFILE_MPEG1);
 }
 
 static uint32_t
 nvc0_decoder_fill_picparm_mpeg4_vp(struct nvc0_decoder *dec,
                                    struct pipe_mpeg4_picture_desc *desc,
-                                   struct nvc0_video_buffer *refs[16],
+                                   struct nouveau_vp3_video_buffer *refs[16],
                                    unsigned *is_ref,
                                    char *map)
 {
@@ -320,15 +320,15 @@ nvc0_decoder_fill_picparm_mpeg4_vp(struct nvc0_decoder *dec,
    memcpy(pic_vp->intra, desc->intra_matrix, 0x40);
    memcpy(pic_vp->non_intra, desc->non_intra_matrix, 0x40);
    memcpy(map, pic_vp, sizeof(*pic_vp));
-   refs[0] = (struct nvc0_video_buffer *)desc->ref[0];
-   refs[!!refs[0]] = (struct nvc0_video_buffer *)desc->ref[1];
+   refs[0] = (struct nouveau_vp3_video_buffer *)desc->ref[0];
+   refs[!!refs[0]] = (struct nouveau_vp3_video_buffer *)desc->ref[1];
    return ret;
 }
 
 static uint32_t
 nvc0_decoder_fill_picparm_h264_vp(struct nvc0_decoder *dec,
                                   const struct pipe_h264_picture_desc *d,
-                                  struct nvc0_video_buffer *refs[16],
+                                  struct nouveau_vp3_video_buffer *refs[16],
                                   unsigned *is_ref,
                                   char *map)
 {
@@ -377,7 +377,7 @@ nvc0_decoder_fill_picparm_h264_vp(struct nvc0_decoder *dec,
    for (i = 0; i < d->num_ref_frames; ++i) {
       if (!d->ref[i])
          break;
-      refs[j] = (struct nvc0_video_buffer *)d->ref[i];
+      refs[j] = (struct nouveau_vp3_video_buffer *)d->ref[i];
       h->refs[j].fifo_idx = j + 1;
       h->refs[j].tmp_idx = refs[j]->valid_ref;
       h->refs[j].field_order_cnt[0] = d->field_order_cnt_list[i][0];
@@ -412,8 +412,8 @@ nvc0_decoder_fill_picparm_h264_vp(struct nvc0_decoder *dec,
 static void
 nvc0_decoder_fill_picparm_h264_vp_refs(struct nvc0_decoder *dec,
                                        struct pipe_h264_picture_desc *d,
-                                       struct nvc0_video_buffer *refs[16],
-                                       struct nvc0_video_buffer *target,
+                                       struct nouveau_vp3_video_buffer *refs[16],
+                                       struct nouveau_vp3_video_buffer *target,
                                        char *map)
 {
    struct h264_picparm_vp *h = (struct h264_picparm_vp *)map;
@@ -431,7 +431,7 @@ nvc0_decoder_fill_picparm_h264_vp_refs(struct nvc0_decoder *dec,
 static uint32_t
 nvc0_decoder_fill_picparm_vc1_vp(struct nvc0_decoder *dec,
                                  struct pipe_vc1_picture_desc *d,
-                                 struct nvc0_video_buffer *refs[16],
+                                 struct nouveau_vp3_video_buffer *refs[16],
                                  unsigned *is_ref,
                                  char *map)
 {
@@ -455,8 +455,8 @@ nvc0_decoder_fill_picparm_vc1_vp(struct nvc0_decoder *dec,
    vc->overlap = d->overlap;
    vc->quantizer = d->quantizer;
    vc->u36 = 0; // ? No idea what this one is..
-   refs[0] = (struct nvc0_video_buffer *)d->ref[0];
-   refs[!!refs[0]] = (struct nvc0_video_buffer *)d->ref[1];
+   refs[0] = (struct nouveau_vp3_video_buffer *)d->ref[0];
+   refs[!!refs[0]] = (struct nouveau_vp3_video_buffer *)d->ref[1];
    return 0x12;
 }
 
@@ -494,9 +494,9 @@ static void dump_comm_vp(struct nvc0_decoder *dec, struct comm *comm, u32 comm_s
 #endif
 
 void nvc0_decoder_vp_caps(struct nvc0_decoder *dec, union pipe_desc desc,
-                          struct nvc0_video_buffer *target, unsigned comm_seq,
+                          struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
                           unsigned *caps, unsigned *is_ref,
-                          struct nvc0_video_buffer *refs[16])
+                          struct nouveau_vp3_video_buffer *refs[16])
 {
    struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NVC0_VIDEO_QDEPTH];
    enum pipe_video_codec codec = u_reduce_video_profile(dec->base.profile);
@@ -528,9 +528,9 @@ void nvc0_decoder_vp_caps(struct nvc0_decoder *dec, union pipe_desc desc,
 
 void
 nvc0_decoder_vp(struct nvc0_decoder *dec, union pipe_desc desc,
-                struct nvc0_video_buffer *target, unsigned comm_seq,
+                struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
                 unsigned caps, unsigned is_ref,
-                struct nvc0_video_buffer *refs[16])
+                struct nouveau_vp3_video_buffer *refs[16])
 {
    struct nouveau_pushbuf *push = dec->pushbuf[1];
    uint32_t bsp_addr, comm_addr, inter_addr, ucode_addr, pic_addr[17], last_addr, null_addr;
Signature · 1 line
1.8.1.5
#2 lore raw

PATCH 2/10 nvc0: standardize on using #if for NVC0_DEBUG_FENCE

In reply to Ilia Mirkin
---
 src/gallium/drivers/nvc0/nvc0_video.c     | 2 +-
 src/gallium/drivers/nvc0/nvc0_video.h     | 6 +++---
 src/gallium/drivers/nvc0/nvc0_video_bsp.c | 4 ++--
 src/gallium/drivers/nvc0/nvc0_video_ppp.c | 2 +-
 src/gallium/drivers/nvc0/nvc0_video_vp.c  | 2 +-
 5 files changed, 8 insertions(+), 8 deletions(-)
src/gallium/drivers/nvc0/nvc0_video.c +1 -1
index 626d0d4..18de2ed 100644
@@ -116,7 +116,7 @@ nvc0_decoder_destroy(struct pipe_video_decoder *decoder)
    nouveau_bo_ref(NULL, &dec->bitplane_bo);
    nouveau_bo_ref(NULL, &dec->inter_bo[0]);
    nouveau_bo_ref(NULL, &dec->inter_bo[1]);
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
    nouveau_bo_ref(NULL, &dec->fence_bo);
 #endif
    nouveau_bo_ref(NULL, &dec->fw_bo);
src/gallium/drivers/nvc0/nvc0_video.h +3 -3
index 271ed5c..67eca7c 100644
@@ -33,9 +33,9 @@
 #define VP_OFFSET 0x200
 #define COMM_OFFSET 0x500
 
-//#define NVC0_DEBUG_FENCE 1
+#define NVC0_DEBUG_FENCE 0
 
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
 # define NVC0_VIDEO_QDEPTH 1
 #else
 # define NVC0_VIDEO_QDEPTH 2
@@ -59,7 +59,7 @@ struct nvc0_decoder {
    struct nouveau_object *channel[3], *bsp, *vp, *ppp;
    struct nouveau_pushbuf *pushbuf[3];
 
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
    /* dump fence and comm, as needed.. */
    unsigned *fence_map;
    struct comm *comm;
src/gallium/drivers/nvc0/nvc0_video_bsp.c +2 -2
index 8f93861..bdb9c64 100644
@@ -261,7 +261,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    struct nouveau_pushbuf_refn bo_refs[] = {
       { bsp_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
       { inter_bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
       { dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
 #endif
       { dec->bitplane_bo, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
@@ -271,7 +271,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    if (!dec->bitplane_bo)
       num_refs--;
 
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
    fence_extra = 4;
 #endif
 
src/gallium/drivers/nvc0/nvc0_video_ppp.c +1 -1
index 823e360..836add3 100644
@@ -36,7 +36,7 @@ nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer
       { NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { dec->ref_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
       { dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
 #endif
    };
src/gallium/drivers/nvc0/nvc0_video_vp.c +1 -1
index 7c1691c..74e3915 100644
@@ -543,7 +543,7 @@ nvc0_decoder_vp(struct nvc0_decoder *dec, union pipe_desc desc,
       { inter_bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { dec->ref_bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { bsp_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
-#ifdef NVC0_DEBUG_FENCE
+#if NVC0_DEBUG_FENCE
       { dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
 #endif
       { dec->fw_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
Signature · 1 line
1.8.1.5

A message that is not in the archive (sent off-list or not yet received): 1376205558-23540-1-git-send-email-imirkin-FrUbXkNCsVf2fBVCVOL8/[email protected]

#4 lore raw

PATCH 3/10 nvc0: move nvc0_decoder into nouveau, rename to nouveau_vp3_decoder

---
 src/gallium/drivers/nouveau/nouveau_vp3_video.h | 160 +++++++++++++++++++++++
 src/gallium/drivers/nvc0/nvc0_video.c           |  22 ++--
 src/gallium/drivers/nvc0/nvc0_video.h           | 165 +-----------------------
 src/gallium/drivers/nvc0/nvc0_video_bsp.c       |  28 ++--
 src/gallium/drivers/nvc0/nvc0_video_ppp.c       |  16 +--
 src/gallium/drivers/nvc0/nvc0_video_vp.c        |  60 ++++-----
 6 files changed, 227 insertions(+), 224 deletions(-)
src/gallium/drivers/nouveau/nouveau_vp3_video.h +160 -0
index bff5d76..7322138 100644
@@ -21,8 +21,11 @@
  */
 
 #include "pipe/p_defines.h"
+
 #include "vl/vl_video_buffer.h"
 
+#include "util/u_video.h"
+
 struct nouveau_vp3_video_buffer {
    struct pipe_video_buffer base;
    unsigned num_planes, valid_ref;
@@ -32,6 +35,163 @@ struct nouveau_vp3_video_buffer {
    struct pipe_surface *surfaces[VL_NUM_COMPONENTS * 2];
 };
 
+#define SLICE_SIZE 0x200
+#define VP_OFFSET 0x200
+#define COMM_OFFSET 0x500
+
+#define NOUVEAU_VP3_DEBUG_FENCE 0
+
+#if NOUVEAU_VP3_DEBUG_FENCE
+# define NOUVEAU_VP3_VIDEO_QDEPTH 1
+#else
+# define NOUVEAU_VP3_VIDEO_QDEPTH 2
+#endif
+
+#define SUBC_BSP(m) dec->bsp_idx, (m)
+#define SUBC_VP(m) dec->vp_idx, (m)
+#define SUBC_PPP(m) dec->ppp_idx, (m)
+
+union pipe_desc {
+   struct pipe_picture_desc *base;
+   struct pipe_mpeg12_picture_desc *mpeg12;
+   struct pipe_mpeg4_picture_desc *mpeg4;
+   struct pipe_vc1_picture_desc *vc1;
+   struct pipe_h264_picture_desc *h264;
+};
+
+struct nouveau_vp3_decoder {
+   struct pipe_video_decoder base;
+   struct nouveau_client *client;
+   struct nouveau_object *channel[3], *bsp, *vp, *ppp;
+   struct nouveau_pushbuf *pushbuf[3];
+
+#if NOUVEAU_VP3_DEBUG_FENCE
+   /* dump fence and comm, as needed.. */
+   unsigned *fence_map;
+   struct comm *comm;
+
+   struct nouveau_bo *fence_bo;
+#endif
+
+   struct nouveau_bo *fw_bo, *bitplane_bo;
+
+   // array size max_references + 2, contains unpostprocessed images
+   // added at the end of ref_bo is a tmp array
+   // tmp is an array for h264, with each member being used for a ref frame or current
+   // target.. size = (((mb(w)*((mb(h)+1)&~1))+3)>>2)<<8 * (max_references+1)
+   // for other codecs, it simply seems that size = w*h is enough
+   // unsure what it's supposed to contain..
+   struct nouveau_bo *ref_bo;
+
+   struct nouveau_bo *inter_bo[2];
+
+   struct nouveau_bo *bsp_bo[NOUVEAU_VP3_VIDEO_QDEPTH];
+
+   // bo's used by each cycle:
+
+   // bsp_bo: contains raw bitstream data and parameters for BSP and VP.
+   // inter_bo: contains data shared between BSP and VP
+   // ref_bo: reference image data, used by PPP and VP
+   // bitplane_bo: contain bitplane data (similar to ref_bo), used by BSP only
+   // fw_bo: used by VP only.
+
+   // Needed amount of copies in optimal case:
+   // 2 copies of inter_bo, VP would process the last inter_bo, while BSP is
+   // writing out a new set.
+   // NOUVEAU_VP3_VIDEO_QDEPTH copies of bsp_bo. We don't want to block the
+   // pipeline ever, and give shaders a chance to run as well.
+
+   struct {
+      struct nouveau_vp3_video_buffer *vidbuf;
+      unsigned last_used;
+      unsigned field_pic_flag : 1;
+      unsigned decoded_top : 1;
+      unsigned decoded_bottom : 1;
+   } refs[17];
+   unsigned fence_seq, fw_sizes, last_frame_num, tmp_stride, ref_stride;
+
+   unsigned bsp_idx, vp_idx, ppp_idx;
+};
+
+struct comm {
+	uint32_t bsp_cur_index; // 000
+	uint32_t byte_ofs; // 004
+	uint32_t status[0x10]; // 008
+	uint32_t pos[0x10]; // 048
+	uint8_t pad[0x100 - 0x88]; // 0a0 bool comm_encrypted
+
+	uint32_t pvp_cur_index; // 100
+	uint32_t acked_byte_ofs; // 104
+	uint32_t status_vp[0x10]; // 108
+	uint16_t mb_y[0x10]; //148
+	uint32_t pvp_stage; // 168 0xeeXX
+	uint16_t parse_endpos_index; // 16c
+	uint16_t irq_index; // 16e
+	uint8_t  irq_470[0x10]; // 170
+	uint32_t irq_pos[0x10]; // 180
+	uint32_t parse_endpos[0x10]; // 1c0
+};
+
+static INLINE uint32_t nouveau_vp3_video_align(uint32_t h)
+{
+   return ((h+0x3f)&~0x3f);
+};
+
+static INLINE uint32_t mb(uint32_t coord)
+{
+   return (coord + 0xf)>>4;
+}
+
+static INLINE uint32_t mb_half(uint32_t coord)
+{
+   return (coord + 0x1f)>>5;
+}
+
+static INLINE uint64_t
+nouveau_vp3_video_addr(struct nouveau_vp3_decoder *dec, struct nouveau_vp3_video_buffer *target)
+{
+   uint64_t ret;
+   if (target)
+      ret = dec->ref_stride * target->valid_ref;
+   else
+      ret = dec->ref_stride * (dec->base.max_references+1);
+   return dec->ref_bo->offset + ret;
+}
+
+static INLINE void
+nouveau_vp3_ycbcr_offsets(struct nouveau_vp3_decoder *dec, uint32_t *y2,
+                          uint32_t *cbcr, uint32_t *cbcr2)
+{
+   uint32_t w = mb(dec->base.width), size;
+   *y2 = mb_half(dec->base.height)*w;
+   *cbcr = *y2 * 2;
+   *cbcr2 = *cbcr + w * (nouveau_vp3_video_align(dec->base.height)>>6);
+
+   /* The check here should never fail because it means a bug
+    * in the code rather than a bug in hardware..
+    */
+   size = (2 * (*cbcr2 - *cbcr) + *cbcr) << 8;
+   if (size > dec->ref_stride) {
+      debug_printf("Overshot ref_stride (%u) with size %u and ofs (%u,%u,%u)\n",
+                   dec->ref_stride, size, *y2<<8, *cbcr<<8, *cbcr2<<8);
+      *y2 = *cbcr = *cbcr2 = 0;
+      assert(size <= dec->ref_stride);
+   }
+}
+
+static INLINE void
+nouveau_vp3_inter_sizes(struct nouveau_vp3_decoder *dec, uint32_t slice_count,
+                        uint32_t *slice_size, uint32_t *bucket_size,
+                        uint32_t *ring_size)
+{
+   *slice_size = (SLICE_SIZE * slice_count)>>8;
+   if (u_reduce_video_profile(dec->base.profile) == PIPE_VIDEO_CODEC_MPEG12)
+      *bucket_size = 0;
+   else
+      *bucket_size = mb(dec->base.width) * 3;
+   *ring_size = (dec->inter_bo[0]->size >> 8) - *bucket_size - *slice_size;
+}
+
 struct pipe_video_buffer *
 nouveau_vp3_video_buffer_create(struct pipe_context *pipe,
                                 const struct pipe_video_buffer *templat,
src/gallium/drivers/nvc0/nvc0_video.c +11 -11
index 18de2ed..73963c2 100644
@@ -62,7 +62,7 @@ nvc0_decoder_decode_bitstream(struct pipe_video_decoder *decoder,
                               const void *const *data,
                               const unsigned *num_bytes)
 {
-   struct nvc0_decoder *dec = (struct nvc0_decoder *)decoder;
+   struct nouveau_vp3_decoder *dec = (struct nouveau_vp3_decoder *)decoder;
    struct nouveau_vp3_video_buffer *target = (struct nouveau_vp3_video_buffer *)video_target;
    uint32_t comm_seq = ++dec->fence_seq;
    union pipe_desc desc;
@@ -88,7 +88,7 @@ nvc0_decoder_decode_bitstream(struct pipe_video_decoder *decoder,
 static void
 nvc0_decoder_flush(struct pipe_video_decoder *decoder)
 {
-   struct nvc0_decoder *dec = (struct nvc0_decoder *)decoder;
+   struct nouveau_vp3_decoder *dec = (struct nouveau_vp3_decoder *)decoder;
    (void)dec;
 }
 
@@ -109,19 +109,19 @@ nvc0_decoder_end_frame(struct pipe_video_decoder *decoder,
 static void
 nvc0_decoder_destroy(struct pipe_video_decoder *decoder)
 {
-   struct nvc0_decoder *dec = (struct nvc0_decoder *)decoder;
+   struct nouveau_vp3_decoder *dec = (struct nouveau_vp3_decoder *)decoder;
    int i;
 
    nouveau_bo_ref(NULL, &dec->ref_bo);
    nouveau_bo_ref(NULL, &dec->bitplane_bo);
    nouveau_bo_ref(NULL, &dec->inter_bo[0]);
    nouveau_bo_ref(NULL, &dec->inter_bo[1]);
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    nouveau_bo_ref(NULL, &dec->fence_bo);
 #endif
    nouveau_bo_ref(NULL, &dec->fw_bo);
 
-   for (i = 0; i < NVC0_VIDEO_QDEPTH; ++i)
+   for (i = 0; i < NOUVEAU_VP3_VIDEO_QDEPTH; ++i)
       nouveau_bo_ref(NULL, &dec->bsp_bo[i]);
 
    nouveau_object_del(&dec->bsp);
@@ -173,7 +173,7 @@ nvc0_create_decoder(struct pipe_context *context,
                     bool chunked_decode)
 {
    struct nouveau_screen *screen = &((struct nvc0_context *)context)->screen->base;
-   struct nvc0_decoder *dec;
+   struct nouveau_vp3_decoder *dec;
    struct nouveau_pushbuf **push;
    union nouveau_bo_config cfg;
    bool kepler = screen->device->chipset >= 0xe0;
@@ -196,7 +196,7 @@ nvc0_create_decoder(struct pipe_context *context,
       return NULL;
    }
 
-   dec = CALLOC_STRUCT(nvc0_decoder);
+   dec = CALLOC_STRUCT(nouveau_vp3_decoder);
    if (!dec)
       return NULL;
    dec->client = screen->client;
@@ -288,7 +288,7 @@ nvc0_create_decoder(struct pipe_context *context,
    dec->base.begin_frame = nvc0_decoder_begin_frame;
    dec->base.end_frame = nvc0_decoder_end_frame;
 
-   for (i = 0; i < NVC0_VIDEO_QDEPTH && !ret; ++i)
+   for (i = 0; i < NOUVEAU_VP3_VIDEO_QDEPTH && !ret; ++i)
       ret = nouveau_bo_new(screen->device, NOUVEAU_BO_VRAM,
                            0, 1 << 20, &cfg, &dec->bsp_bo[i]);
    if (!ret)
@@ -325,7 +325,7 @@ nvc0_create_decoder(struct pipe_context *context,
    }
    case PIPE_VIDEO_CODEC_MPEG4_AVC: {
       codec = 3;
-      dec->tmp_stride = 16 * mb_half(width) * nvc0_video_align(height) * 3 / 2;
+      dec->tmp_stride = 16 * mb_half(width) * nouveau_vp3_video_align(height) * 3 / 2;
       tmp_size = dec->tmp_stride * (max_references + 1);
       assert(max_references <= 16);
       break;
@@ -415,7 +415,7 @@ nvc0_create_decoder(struct pipe_context *context,
          goto fail;
    }
 
-   dec->ref_stride = mb(width)*16 * (mb_half(height)*32 + nvc0_video_align(height)/2);
+   dec->ref_stride = mb(width)*16 * (mb_half(height)*32 + nouveau_vp3_video_align(height)/2);
    ret = nouveau_bo_new(screen->device, NOUVEAU_BO_VRAM, 0,
                         dec->ref_stride * (max_references+2) + tmp_size,
                         &cfg, &dec->ref_bo);
@@ -438,7 +438,7 @@ nvc0_create_decoder(struct pipe_context *context,
 
    ++dec->fence_seq;
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    ret = nouveau_bo_new(screen->device, NOUVEAU_BO_GART|NOUVEAU_BO_MAP,
                         0, 0x1000, NULL, &dec->fence_bo);
    if (ret)
src/gallium/drivers/nvc0/nvc0_video.h +4 -161

187 lines not on this page · raw message

src/gallium/drivers/nvc0/nvc0_video_bsp.c +14 -14
index bdb9c64..c632a5e 100644
@@ -110,7 +110,7 @@ struct h264_picparm_bsp {
 };
 
 static uint32_t
-nvc0_decoder_fill_picparm_mpeg12_bsp(struct nvc0_decoder *dec,
+nvc0_decoder_fill_picparm_mpeg12_bsp(struct nouveau_vp3_decoder *dec,
                                      struct pipe_mpeg12_picture_desc *desc,
                                      char *map)
 {
@@ -132,7 +132,7 @@ nvc0_decoder_fill_picparm_mpeg12_bsp(struct nvc0_decoder *dec,
 }
 
 static uint32_t
-nvc0_decoder_fill_picparm_mpeg4_bsp(struct nvc0_decoder *dec,
+nvc0_decoder_fill_picparm_mpeg4_bsp(struct nouveau_vp3_decoder *dec,
                                     struct pipe_mpeg4_picture_desc *desc,
                                     char *map)
 {
@@ -157,7 +157,7 @@ nvc0_decoder_fill_picparm_mpeg4_bsp(struct nvc0_decoder *dec,
 }
 
 static uint32_t
-nvc0_decoder_fill_picparm_vc1_bsp(struct nvc0_decoder *dec,
+nvc0_decoder_fill_picparm_vc1_bsp(struct nouveau_vp3_decoder *dec,
                                   struct pipe_vc1_picture_desc *d,
                                   char *map)
 {
@@ -189,7 +189,7 @@ nvc0_decoder_fill_picparm_vc1_bsp(struct nvc0_decoder *dec,
 }
 
 static uint32_t
-nvc0_decoder_fill_picparm_h264_bsp(struct nvc0_decoder *dec,
+nvc0_decoder_fill_picparm_h264_bsp(struct nouveau_vp3_decoder *dec,
                                    struct pipe_h264_picture_desc *d,
                                    char *map)
 {
@@ -230,7 +230,7 @@ nvc0_decoder_fill_picparm_h264_bsp(struct nvc0_decoder *dec,
    return caps | 3;
 }
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
 static void dump_comm_bsp(struct comm *comm)
 {
    unsigned idx = comm->bsp_cur_index & 0xf;
@@ -240,7 +240,7 @@ static void dump_comm_bsp(struct comm *comm)
 #endif
 
 unsigned
-nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
+nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
                  struct nouveau_vp3_video_buffer *target,
                  unsigned comm_seq, unsigned num_buffers,
                  const void *const *data, const unsigned *num_bytes,
@@ -255,13 +255,13 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    uint32_t endmarker, caps;
    struct strparm_bsp *str_bsp;
    int ret, i;
-   struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NVC0_VIDEO_QDEPTH];
+   struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH];
    struct nouveau_bo *inter_bo = dec->inter_bo[comm_seq & 1];
    unsigned fence_extra = 0;
    struct nouveau_pushbuf_refn bo_refs[] = {
       { bsp_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
       { inter_bo, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
       { dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
 #endif
       { dec->bitplane_bo, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM },
@@ -271,7 +271,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    if (!dec->bitplane_bo)
       num_refs--;
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    fence_extra = 4;
 #endif
 
@@ -329,7 +329,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    /* Reserved for picparm_vp */
    bsp += 0x300;
    /* Reserved for comm */
-#if !NVC0_DEBUG_FENCE
+#if !NOUVEAU_VP3_DEBUG_FENCE
    memset(bsp, 0, 0x200);
 #endif
    bsp += 0x200;
@@ -351,7 +351,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
    bsp_addr = bsp_bo->offset >> 8;
    inter_addr = inter_bo->offset >> 8;
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    memset(dec->comm, 0, 0x200);
    comm_addr = (dec->fence_bo->offset + COMM_OFFSET) >> 8;
 #else
@@ -370,7 +370,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
 
       bitplane_addr = dec->bitplane_bo->offset >> 8;
 
-      nvc0_decoder_inter_sizes(dec, 1, &slice_size, &bucket_size, &ring_size);
+      nouveau_vp3_inter_sizes(dec, 1, &slice_size, &bucket_size, &ring_size);
       BEGIN_NVC0(push, SUBC_BSP(0x400), 6);
       PUSH_DATA (push, bsp_addr); // 400 picparm addr
       PUSH_DATA (push, inter_addr); // 404 interparm addr
@@ -379,7 +379,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
       PUSH_DATA (push, bitplane_addr); // 410 BITPLANE_DATA
       PUSH_DATA (push, 0x400); // 414 BITPLANE_DATA_SIZE
    } else {
-      nvc0_decoder_inter_sizes(dec, desc.h264->slice_count, &slice_size, &bucket_size, &ring_size);
+      nouveau_vp3_inter_sizes(dec, desc.h264->slice_count, &slice_size, &bucket_size, &ring_size);
       BEGIN_NVC0(push, SUBC_BSP(0x400), 8);
       PUSH_DATA (push, bsp_addr); // 400 picparm addr
       PUSH_DATA (push, inter_addr); // 404 interparm addr
@@ -392,7 +392,7 @@ nvc0_decoder_bsp(struct nvc0_decoder *dec, union pipe_desc desc,
       // TODO: Double check 414 / 418 with nvidia trace
    }
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    BEGIN_NVC0(push, SUBC_BSP(0x240), 3);
    PUSH_DATAh(push, dec->fence_bo->offset);
    PUSH_DATA (push, dec->fence_bo->offset);
src/gallium/drivers/nvc0/nvc0_video_ppp.c +8 -8
index 836add3..496db80 100644
@@ -23,7 +23,7 @@
 #include "nvc0_video.h"
 
 static void
-nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer *target, uint32_t low700) {
+nvc0_decoder_setup_ppp(struct nouveau_vp3_decoder *dec, struct nouveau_vp3_video_buffer *target, uint32_t low700) {
    struct nouveau_pushbuf *push = dec->pushbuf[2];
 
    uint32_t stride_in = mb(dec->base.width);
@@ -36,7 +36,7 @@ nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer
       { NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { NULL, NOUVEAU_BO_WR | NOUVEAU_BO_VRAM },
       { dec->ref_bo, NOUVEAU_BO_RD | NOUVEAU_BO_VRAM },
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
       { dec->fence_bo, NOUVEAU_BO_WR | NOUVEAU_BO_GART },
 #endif
    };
@@ -48,10 +48,10 @@ nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer
    }
 
    nouveau_pushbuf_refn(push, bo_refs, num_refs);
-   nvc0_decoder_ycbcr_offsets(dec, &y2, &cbcr, &cbcr2);
+   nouveau_vp3_ycbcr_offsets(dec, &y2, &cbcr, &cbcr2);
 
    BEGIN_NVC0(push, SUBC_PPP(0x700), 10);
-   in_addr = nvc0_video_addr(dec, target) >> 8;
+   in_addr = nouveau_vp3_video_addr(dec, target) >> 8;
 
    PUSH_DATA (push, (stride_out << 24) | (stride_out << 16) | low700); // 700
    PUSH_DATA (push, (stride_in << 24) | (stride_in << 16) | (dec_h << 8) | dec_w); // 704
@@ -73,7 +73,7 @@ nvc0_decoder_setup_ppp(struct nvc0_decoder *dec, struct nouveau_vp3_video_buffer
 }
 
 static uint32_t
-nvc0_decoder_vc1_ppp(struct nvc0_decoder *dec, struct pipe_vc1_picture_desc *desc, struct nouveau_vp3_video_buffer *target) {
+nvc0_decoder_vc1_ppp(struct nouveau_vp3_decoder *dec, struct pipe_vc1_picture_desc *desc, struct nouveau_vp3_video_buffer *target) {
    struct nouveau_pushbuf *push = dec->pushbuf[2];
 
    nvc0_decoder_setup_ppp(dec, target, 0x1412);
@@ -89,13 +89,13 @@ nvc0_decoder_vc1_ppp(struct nvc0_decoder *dec, struct pipe_vc1_picture_desc *des
 }
 
 void
-nvc0_decoder_ppp(struct nvc0_decoder *dec, union pipe_desc desc, struct nouveau_vp3_video_buffer *target, unsigned comm_seq) {
+nvc0_decoder_ppp(struct nouveau_vp3_decoder *dec, union pipe_desc desc, struct nouveau_vp3_video_buffer *target, unsigned comm_seq) {
    enum pipe_video_codec codec = u_reduce_video_profile(dec->base.profile);
    struct nouveau_pushbuf *push = dec->pushbuf[2];
    unsigned ppp_caps = 0x10;
    unsigned fence_extra = 0;
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    fence_extra = 4;
 #endif
 
@@ -116,7 +116,7 @@ nvc0_decoder_ppp(struct nvc0_decoder *dec, union pipe_desc desc, struct nouveau_
    PUSH_DATA (push, comm_seq);
    PUSH_DATA (push, ppp_caps);
 
-#if NVC0_DEBUG_FENCE
+#if NOUVEAU_VP3_DEBUG_FENCE
    BEGIN_NVC0(push, SUBC_PPP(0x240), 3);
    PUSH_DATAh(push, (dec->fence_bo->offset + 0x20));
    PUSH_DATA (push, (dec->fence_bo->offset + 0x20));
src/gallium/drivers/nvc0/nvc0_video_vp.c +30 -30

208 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#5 lore raw

PATCH 5/10 nvc0: move vp param filling logic into nouveau

In reply to a message not in the archive
---
 src/gallium/drivers/nouveau/Makefile.sources       |   3 +-
 src/gallium/drivers/nouveau/nouveau_vp3_video.h    |   6 +
 src/gallium/drivers/nouveau/nouveau_vp3_video_vp.c | 485 +++++++++++++++++++++
 src/gallium/drivers/nvc0/nvc0_video.h              |   7 -
 src/gallium/drivers/nvc0/nvc0_video_bsp.c          |   2 +-
 src/gallium/drivers/nvc0/nvc0_video_vp.c           | 472 +-------------------
 6 files changed, 499 insertions(+), 476 deletions(-)
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video_vp.c
src/gallium/drivers/nouveau/Makefile.sources +2 -1
index ca33207..7912f67 100644
@@ -6,4 +6,5 @@ C_SOURCES := \
 	nouveau_heap.c \
 	nouveau_video.c \
 	nouveau_vp3_video.c \
-	nouveau_vp3_video_bsp.c
+	nouveau_vp3_video_bsp.c \
+	nouveau_vp3_video_vp.c
src/gallium/drivers/nouveau/nouveau_vp3_video.h +6 -0
index 2558d57..8d3548a 100644
@@ -202,3 +202,9 @@ nouveau_vp3_bsp(struct nouveau_vp3_decoder *dec,  union pipe_desc desc,
                 struct nouveau_vp3_video_buffer *target,
                 unsigned comm_seq, unsigned num_buffers,
                 const void *const *data, const unsigned *num_bytes);
+
+void
+nouveau_vp3_vp_caps(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
+                    struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
+                    unsigned *caps, unsigned *is_ref,
+                    struct nouveau_vp3_video_buffer *refs[16]);
src/gallium/drivers/nouveau/nouveau_vp3_video_vp.c new file +485 -0

485 lines not on this page · raw message

src/gallium/drivers/nvc0/nvc0_video.h +0 -7
index 1ceb6eb..5cd79f6 100644
@@ -37,13 +37,6 @@ nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
                  unsigned *vp_caps, unsigned *is_ref,
                  struct nouveau_vp3_video_buffer *refs[16]);
 
-extern void nvc0_decoder_vp_caps(struct nouveau_vp3_decoder *dec,
-                                 union pipe_desc desc,
-                                 struct nouveau_vp3_video_buffer *target,
-                                 unsigned comm_seq,
-                                 unsigned *caps, unsigned *is_ref,
-                                 struct nouveau_vp3_video_buffer *refs[16]);
-
 extern void
 nvc0_decoder_vp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
                 struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
src/gallium/drivers/nvc0/nvc0_video_bsp.c +1 -1
index 06c85e6..2ce5519 100644
@@ -74,7 +74,7 @@ nvc0_decoder_bsp(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
    caps = nouveau_vp3_bsp(dec, desc, target, comm_seq,
                           num_buffers, data, num_bytes);
 
-   nvc0_decoder_vp_caps(dec, desc, target, comm_seq, vp_caps, is_ref, refs);
+   nouveau_vp3_vp_caps(dec, desc, target, comm_seq, vp_caps, is_ref, refs);
 
    nouveau_pushbuf_space(push, 6 + (codec == PIPE_VIDEO_CODEC_MPEG4_AVC ? 9 : 7) + fence_extra + 2, num_refs, 0);
    nouveau_pushbuf_refn(push, bo_refs, num_refs);
src/gallium/drivers/nvc0/nvc0_video_vp.c +5 -467

485 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#6 lore raw

PATCH 7/10 nvc0: move firmware loading functions to nouveau

In reply to a message not in the archive
---
 src/gallium/drivers/nouveau/nouveau_vp3_video.c | 101 ++++++++++++++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video.h |   5 ++
 src/gallium/drivers/nvc0/nvc0_video.c           |  92 +--------------------
 3 files changed, 108 insertions(+), 90 deletions(-)
src/gallium/drivers/nouveau/nouveau_vp3_video.c +101 -0
index 6abc581..a3387b3 100644
@@ -20,6 +20,10 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#include <sys/mman.h>
+#include <stdio.h>
+#include <fcntl.h>
+
 #include "nouveau_screen.h"
 #include "nouveau_context.h"
 #include "nouveau_vp3_video.h"
@@ -226,3 +230,100 @@ nouveau_vp3_decoder_init_common(struct pipe_video_decoder *dec)
    dec->begin_frame = nouveau_vp3_decoder_begin_frame;
    dec->end_frame = nouveau_vp3_decoder_end_frame;
 }
+
+static void vp4_getpath(enum pipe_video_profile profile, char *path)
+{
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-mpeg12-0");
+         break;
+      }
+      case PIPE_VIDEO_CODEC_MPEG4: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-mpeg4-0");
+         break;
+      }
+      case PIPE_VIDEO_CODEC_VC1: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-vc1-0");
+         break;
+      }
+      case PIPE_VIDEO_CODEC_MPEG4_AVC: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-h264-0");
+         break;
+      }
+      default: assert(0);
+   }
+}
+
+int
+nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec,
+                          enum pipe_video_profile profile,
+                          unsigned chipset)
+{
+   int fd;
+   char path[PATH_MAX];
+   ssize_t r;
+   uint32_t *end, endval;
+
+   vp4_getpath(profile, path);
+
+   if (nouveau_bo_map(dec->fw_bo, NOUVEAU_BO_WR, dec->client))
+      return 1;
+
+   fd = open(path, O_RDONLY | O_CLOEXEC);
+   if (fd < 0) {
+      fprintf(stderr, "opening firmware file %s failed: %m\n", path);
+      return 1;
+   }
+   r = read(fd, dec->fw_bo->map, 0x4000);
+   close(fd);
+
+   if (r < 0) {
+      fprintf(stderr, "reading firmware file %s failed: %m\n", path);
+      return 1;
+   }
+
+   if (r == 0x4000) {
+      fprintf(stderr, "firmware file %s too large!\n", path);
+      return 1;
+   }
+
+   if (r & 0xff) {
+      fprintf(stderr, "firmware file %s wrong size!\n", path);
+      return 1;
+   }
+
+   end = dec->fw_bo->map + r - 4;
+   endval = *end;
+   while (endval == *end)
+      end--;
+
+   r = (intptr_t)end - (intptr_t)dec->fw_bo->map + 4;
+
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12: {
+         assert((r & 0xff) == 0xe0);
+         dec->fw_sizes = (0x2e0<<16) | (r - 0x2e0);
+         break;
+      }
+      case PIPE_VIDEO_CODEC_MPEG4: {
+         assert((r & 0xff) == 0xe0);
+         dec->fw_sizes = (0x2e0<<16) | (r - 0x2e0);
+         break;
+      }
+      case PIPE_VIDEO_CODEC_VC1: {
+         assert((r & 0xff) == 0xac);
+         dec->fw_sizes = (0x3ac<<16) | (r - 0x3ac);
+         break;
+      }
+      case PIPE_VIDEO_CODEC_MPEG4_AVC: {
+         assert((r & 0xff) == 0x70);
+         dec->fw_sizes = (0x370<<16) | (r - 0x370);
+         break;
+      }
+      default:
+         return 1;
+   }
+   munmap(dec->fw_bo->map, dec->fw_bo->size);
+   dec->fw_bo->map = NULL;
+   return 0;
+}
src/gallium/drivers/nouveau/nouveau_vp3_video.h +5 -0
index cb088fe..5e40385 100644
@@ -200,6 +200,11 @@ nouveau_vp3_video_buffer_create(struct pipe_context *pipe,
 void
 nouveau_vp3_decoder_init_common(struct pipe_video_decoder *decoder);
 
+int
+nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec,
+                          enum pipe_video_profile profile,
+                          unsigned chipset);
+
 uint32_t
 nouveau_vp3_bsp(struct nouveau_vp3_decoder *dec,  union pipe_desc desc,
                 struct nouveau_vp3_video_buffer *target,
src/gallium/drivers/nvc0/nvc0_video.c +2 -90

116 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#7 lore raw

PATCH 8/10 nvc0: move video param and format support functions to nouveau

In reply to a message not in the archive
---
 src/gallium/drivers/nouveau/nouveau_vp3_video.c | 37 +++++++++++++++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video.h | 10 +++++++
 src/gallium/drivers/nvc0/nvc0_context.h         |  5 ----
 src/gallium/drivers/nvc0/nvc0_screen.c          | 18 +++---------
 src/gallium/drivers/nvc0/nvc0_video.c           | 26 -----------------
 5 files changed, 51 insertions(+), 45 deletions(-)
src/gallium/drivers/nouveau/nouveau_vp3_video.c +37 -0
index a3387b3..95ba7ec 100644
@@ -327,3 +327,40 @@ nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec,
    dec->fw_bo->map = NULL;
    return 0;
 }
+
+int
+nouveau_vp3_screen_get_video_param(struct pipe_screen *pscreen,
+                                   enum pipe_video_profile profile,
+                                   enum pipe_video_cap param)
+{
+   switch (param) {
+   case PIPE_VIDEO_CAP_SUPPORTED:
+      return profile >= PIPE_VIDEO_PROFILE_MPEG1;
+   case PIPE_VIDEO_CAP_NPOT_TEXTURES:
+      return 1;
+   case PIPE_VIDEO_CAP_MAX_WIDTH:
+   case PIPE_VIDEO_CAP_MAX_HEIGHT:
+      return nouveau_screen(pscreen)->device->chipset < 0xd0 ? 2048 : 4096;
+   case PIPE_VIDEO_CAP_PREFERED_FORMAT:
+      return PIPE_FORMAT_NV12;
+   case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED:
+   case PIPE_VIDEO_CAP_PREFERS_INTERLACED:
+      return true;
+   case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE:
+      return false;
+   default:
+      debug_printf("unknown video param: %d\n", param);
+      return 0;
+   }
+}
+
+boolean
+nouveau_vp3_screen_video_supported(struct pipe_screen *screen,
+                                   enum pipe_format format,
+                                   enum pipe_video_profile profile)
+{
+   if (profile != PIPE_VIDEO_PROFILE_UNKNOWN)
+      return format == PIPE_FORMAT_NV12;
+
+   return vl_video_buffer_is_format_supported(screen, format, profile);
+}
src/gallium/drivers/nouveau/nouveau_vp3_video.h +10 -0
index 5e40385..f1a1054 100644
@@ -216,3 +216,13 @@ nouveau_vp3_vp_caps(struct nouveau_vp3_decoder *dec, union pipe_desc desc,
                     struct nouveau_vp3_video_buffer *target, unsigned comm_seq,
                     unsigned *caps, unsigned *is_ref,
                     struct nouveau_vp3_video_buffer *refs[16]);
+
+int
+nouveau_vp3_screen_get_video_param(struct pipe_screen *pscreen,
+                                   enum pipe_video_profile profile,
+                                   enum pipe_video_cap param);
+
+boolean
+nouveau_vp3_screen_video_supported(struct pipe_screen *screen,
+                                   enum pipe_format format,
+                                   enum pipe_video_profile profile);
src/gallium/drivers/nvc0/nvc0_context.h +0 -5
index 9e58960..db6bb10 100644
@@ -346,11 +346,6 @@ struct pipe_video_buffer *
 nvc0_video_buffer_create(struct pipe_context *pipe,
                          const struct pipe_video_buffer *templat);
 
-int
-nvc0_screen_get_video_param(struct pipe_screen *pscreen,
-                            enum pipe_video_profile profile,
-                            enum pipe_video_cap param);
-
 /* nvc0_push.c */
 void nvc0_push_vbo(struct nvc0_context *, const struct pipe_draw_info *);
 
src/gallium/drivers/nvc0/nvc0_screen.c +4 -14
index bc5580b..93a2902 100644
@@ -27,6 +27,8 @@
 #include "vl/vl_decoder.h"
 #include "vl/vl_video_buffer.h"
 
+#include "nouveau/nouveau_vp3_video.h"
+
 #include "nvc0_context.h"
 #include "nvc0_screen.h"
 
@@ -63,18 +65,6 @@ nvc0_screen_is_format_supported(struct pipe_screen *pscreen,
    return (nvc0_format_table[format].usage & bindings) == bindings;
 }
 
-static boolean
-nvc0_screen_video_supported(struct pipe_screen *screen,
-                            enum pipe_format format,
-                            enum pipe_video_profile profile)
-{
-   if (profile != PIPE_VIDEO_PROFILE_UNKNOWN)
-      return format == PIPE_FORMAT_NV12;
-
-   return vl_video_buffer_is_format_supported(screen, format, profile);
-}
-
-
 static int
 nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
 {
@@ -593,8 +583,8 @@ nvc0_screen_create(struct nouveau_device *dev)
 
    nvc0_screen_init_resource_functions(pscreen);
 
-   screen->base.base.get_video_param = nvc0_screen_get_video_param;
-   screen->base.base.is_video_format_supported = nvc0_screen_video_supported;
+   screen->base.base.get_video_param = nouveau_vp3_screen_get_video_param;
+   screen->base.base.is_video_format_supported = nouveau_vp3_screen_video_supported;
 
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, 4096, NULL,
                         &screen->fence.bo);
src/gallium/drivers/nvc0/nvc0_video.c +0 -26
index e0f29be..5891f09 100644
@@ -25,32 +25,6 @@
 #include "util/u_sampler.h"
 #include "util/u_format.h"
 
-int
-nvc0_screen_get_video_param(struct pipe_screen *pscreen,
-                            enum pipe_video_profile profile,
-                            enum pipe_video_cap param)
-{
-   switch (param) {
-   case PIPE_VIDEO_CAP_SUPPORTED:
-      return profile >= PIPE_VIDEO_PROFILE_MPEG1;
-   case PIPE_VIDEO_CAP_NPOT_TEXTURES:
-      return 1;
-   case PIPE_VIDEO_CAP_MAX_WIDTH:
-   case PIPE_VIDEO_CAP_MAX_HEIGHT:
-      return nouveau_screen(pscreen)->device->chipset < 0xd0 ? 2048 : 4096;
-   case PIPE_VIDEO_CAP_PREFERED_FORMAT:
-      return PIPE_FORMAT_NV12;
-   case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED:
-   case PIPE_VIDEO_CAP_PREFERS_INTERLACED:
-      return true;
-   case PIPE_VIDEO_CAP_SUPPORTS_PROGRESSIVE:
-      return false;
-   default:
-      debug_printf("unknown video param: %d\n", param);
-      return 0;
-   }
-}
-
 static void
 nvc0_decoder_decode_bitstream(struct pipe_video_decoder *decoder,
                               struct pipe_video_buffer *video_target,
Signature · 1 line
1.8.1.5
#8 lore raw

PATCH 9/10 nv50: separate video logic from noalloc

In reply to a message not in the archive

The upcoming vp3 logic will want the video layout, but allocated by the miptree.

---
 src/gallium/drivers/nv50/nv50_miptree.c  | 6 ++++--
 src/gallium/drivers/nv50/nv50_resource.h | 1 +
 src/gallium/drivers/nv50/nv84_video.c    | 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)
src/gallium/drivers/nv50/nv50_miptree.c +4 -2
index 28be768..461710e 100644
@@ -335,8 +335,10 @@ nv50_miptree_create(struct pipe_screen *pscreen,
 
    if (unlikely(pt->flags & NV50_RESOURCE_FLAG_VIDEO)) {
       nv50_miptree_init_layout_video(mt);
-      /* BO allocation done by client */
-      return pt;
+      if (pt->flags & NV50_RESOURCE_FLAG_NOALLOC) {
+         /* BO allocation done by client */
+         return pt;
+      }
    } else
    if (bo_config.nv50.memtype != 0) {
       nv50_miptree_init_layout_tiled(mt);
src/gallium/drivers/nv50/nv50_resource.h +1 -0
index c520a72..b104404 100644
@@ -17,6 +17,7 @@ void
 nv50_screen_init_resource_functions(struct pipe_screen *pscreen);
 
 #define NV50_RESOURCE_FLAG_VIDEO (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 0)
+#define NV50_RESOURCE_FLAG_NOALLOC (NOUVEAU_RESOURCE_FLAG_DRV_PRIV << 1)
 
 #define NV50_TILE_SHIFT_X(m) 6
 #define NV50_TILE_SHIFT_Y(m) ((((m) >> 4) & 0xf) + 2)
src/gallium/drivers/nv50/nv84_video.c +1 -1
index d5f6295..b24ea8f 100644
@@ -669,7 +669,7 @@ nv84_video_buffer_create(struct pipe_context *pipe,
    templ.format = PIPE_FORMAT_R8_UNORM;
    templ.width0 = align(template->width, 2);
    templ.height0 = align(template->height, 4) / 2;
-   templ.flags = NV50_RESOURCE_FLAG_VIDEO;
+   templ.flags = NV50_RESOURCE_FLAG_VIDEO | NV50_RESOURCE_FLAG_NOALLOC;
    templ.array_size = 2;
 
    cfg.nv50.tile_mode = 0x20;
Signature · 1 line
1.8.1.5
#9 lore raw

PATCH 4/10 nvc0: move bsp param-filling logic into nouveau

In reply to Ilia Mirkin
---
 src/gallium/drivers/nouveau/Makefile.sources       |   3 +-
 src/gallium/drivers/nouveau/nouveau_vp3_video.h    |  10 +-
 .../drivers/nouveau/nouveau_vp3_video_bsp.c        | 310 +++++++++++++++++++++
 src/gallium/drivers/nvc0/nvc0_video_bsp.c          | 277 +-----------------
 4 files changed, 324 insertions(+), 276 deletions(-)
 create mode 100644 src/gallium/drivers/nouveau/nouveau_vp3_video_bsp.c
src/gallium/drivers/nouveau/Makefile.sources +2 -1
index f7c9249..ca33207 100644
@@ -5,4 +5,5 @@ C_SOURCES := \
 	nouveau_buffer.c \
 	nouveau_heap.c \
 	nouveau_video.c \
-	nouveau_vp3_video.c
+	nouveau_vp3_video.c \
+	nouveau_vp3_video_bsp.c
src/gallium/drivers/nouveau/nouveau_vp3_video.h +8 -2
index 7322138..2558d57 100644
@@ -20,10 +20,10 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include "pipe/p_defines.h"
+#include <libdrm/nouveau.h>
 
+#include "pipe/p_defines.h"
 #include "vl/vl_video_buffer.h"
-
 #include "util/u_video.h"
 
 struct nouveau_vp3_video_buffer {
@@ -196,3 +196,9 @@ struct pipe_video_buffer *
 nouveau_vp3_video_buffer_create(struct pipe_context *pipe,
                                 const struct pipe_video_buffer *templat,
                                 int flags);
+
+uint32_t
+nouveau_vp3_bsp(struct nouveau_vp3_decoder *dec,  union pipe_desc desc,
+                struct nouveau_vp3_video_buffer *target,
+                unsigned comm_seq, unsigned num_buffers,
+                const void *const *data, const unsigned *num_bytes);
src/gallium/drivers/nouveau/nouveau_vp3_video_bsp.c new file +310 -0

310 lines not on this page · raw message

src/gallium/drivers/nvc0/nvc0_video_bsp.c +4 -273

304 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#10 lore raw

PATCH 6/10 nvc0: move some of the simpler decoder functions into nouveau

In reply to Ilia Mirkin
---
 src/gallium/drivers/nouveau/nouveau_vp3_video.c | 63 ++++++++++++++++++++++++
 src/gallium/drivers/nouveau/nouveau_vp3_video.h |  3 ++
 src/gallium/drivers/nvc0/nvc0_video.c           | 65 ++-----------------------
 3 files changed, 69 insertions(+), 62 deletions(-)
src/gallium/drivers/nouveau/nouveau_vp3_video.c +63 -0
index a55c2e8..6abc581 100644
@@ -163,3 +163,66 @@ error:
    nouveau_vp3_video_buffer_destroy(&buffer->base);
    return NULL;
 }
+
+static void
+nouveau_vp3_decoder_flush(struct pipe_video_decoder *decoder)
+{
+}
+
+static void
+nouveau_vp3_decoder_begin_frame(struct pipe_video_decoder *decoder,
+                                struct pipe_video_buffer *target,
+                                struct pipe_picture_desc *picture)
+{
+}
+
+static void
+nouveau_vp3_decoder_end_frame(struct pipe_video_decoder *decoder,
+                              struct pipe_video_buffer *target,
+                              struct pipe_picture_desc *picture)
+{
+}
+
+static void
+nouveau_vp3_decoder_destroy(struct pipe_video_decoder *decoder)
+{
+   struct nouveau_vp3_decoder *dec = (struct nouveau_vp3_decoder *)decoder;
+   int i;
+
+   nouveau_bo_ref(NULL, &dec->ref_bo);
+   nouveau_bo_ref(NULL, &dec->bitplane_bo);
+   nouveau_bo_ref(NULL, &dec->inter_bo[0]);
+   nouveau_bo_ref(NULL, &dec->inter_bo[1]);
+#if NOUVEAU_VP3_DEBUG_FENCE
+   nouveau_bo_ref(NULL, &dec->fence_bo);
+#endif
+   nouveau_bo_ref(NULL, &dec->fw_bo);
+
+   for (i = 0; i < NOUVEAU_VP3_VIDEO_QDEPTH; ++i)
+      nouveau_bo_ref(NULL, &dec->bsp_bo[i]);
+
+   nouveau_object_del(&dec->bsp);
+   nouveau_object_del(&dec->vp);
+   nouveau_object_del(&dec->ppp);
+
+   if (dec->channel[0] != dec->channel[1]) {
+      for (i = 0; i < 3; ++i) {
+         nouveau_pushbuf_del(&dec->pushbuf[i]);
+         nouveau_object_del(&dec->channel[i]);
+      }
+   } else {
+      nouveau_pushbuf_del(dec->pushbuf);
+      nouveau_object_del(dec->channel);
+   }
+
+   FREE(dec);
+}
+
+void
+nouveau_vp3_decoder_init_common(struct pipe_video_decoder *dec)
+{
+   dec->destroy = nouveau_vp3_decoder_destroy;
+   dec->flush = nouveau_vp3_decoder_flush;
+   dec->begin_frame = nouveau_vp3_decoder_begin_frame;
+   dec->end_frame = nouveau_vp3_decoder_end_frame;
+}
src/gallium/drivers/nouveau/nouveau_vp3_video.h +3 -0
index 8d3548a..cb088fe 100644
@@ -197,6 +197,9 @@ nouveau_vp3_video_buffer_create(struct pipe_context *pipe,
                                 const struct pipe_video_buffer *templat,
                                 int flags);
 
+void
+nouveau_vp3_decoder_init_common(struct pipe_video_decoder *decoder);
+
 uint32_t
 nouveau_vp3_bsp(struct nouveau_vp3_decoder *dec,  union pipe_desc desc,
                 struct nouveau_vp3_video_buffer *target,
src/gallium/drivers/nvc0/nvc0_video.c +3 -62

94 lines not on this page · raw message

Signature · 1 line
1.8.1.5
#11 lore raw

PATCH 10/10 nv50: add vp3/vp4 support for mpeg2/vc1

In reply to Ilia Mirkin

h264/mpeg4 remain disabled for pre-nvc0, there's some minor bug/difference which causes the decoding to hang after some frames.

---
 src/gallium/drivers/nouveau/nouveau_vp3_video.c |  39 ++-
 src/gallium/drivers/nv50/Makefile.sources       |   6 +-
 src/gallium/drivers/nv50/nv50_context.c         |   5 +-
 src/gallium/drivers/nv50/nv50_context.h         |  14 ++
 src/gallium/drivers/nv50/nv50_screen.c          |   7 +-
 src/gallium/drivers/nv50/nv50_winsys.h          |   4 -
 src/gallium/drivers/nv50/nv84_video.h           |   4 +
 src/gallium/drivers/nv50/nv98_video.c           | 308 ++++++++++++++++++++++++
 src/gallium/drivers/nv50/nv98_video.h           |  48 ++++
 src/gallium/drivers/nv50/nv98_video_bsp.c       | 159 ++++++++++++
 src/gallium/drivers/nv50/nv98_video_ppp.c       | 143 +++++++++++
 src/gallium/drivers/nv50/nv98_video_vp.c        | 202 ++++++++++++++++
 12 files changed, 927 insertions(+), 12 deletions(-)
 create mode 100644 src/gallium/drivers/nv50/nv98_video.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video.h
 create mode 100644 src/gallium/drivers/nv50/nv98_video_bsp.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video_ppp.c
 create mode 100644 src/gallium/drivers/nv50/nv98_video_vp.c
src/gallium/drivers/nouveau/nouveau_vp3_video.c +36 -3
index 95ba7ec..5926ff2 100644
@@ -231,6 +231,25 @@ nouveau_vp3_decoder_init_common(struct pipe_video_decoder *dec)
    dec->end_frame = nouveau_vp3_decoder_end_frame;
 }
 
+static void vp3_getpath(enum pipe_video_profile profile, char *path)
+{
+   switch (u_reduce_video_profile(profile)) {
+      case PIPE_VIDEO_CODEC_MPEG12: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-vp3-mpeg12-0");
+         break;
+      }
+      case PIPE_VIDEO_CODEC_VC1: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-vp3-vc1-0");
+         break;
+      }
+      case PIPE_VIDEO_CODEC_MPEG4_AVC: {
+         sprintf(path, "/lib/firmware/nouveau/vuc-vp3-h264-0");
+         break;
+      }
+      default: assert(0);
+   }
+}
+
 static void vp4_getpath(enum pipe_video_profile profile, char *path)
 {
    switch (u_reduce_video_profile(profile)) {
@@ -264,7 +283,10 @@ nouveau_vp3_load_firmware(struct nouveau_vp3_decoder *dec,
    ssize_t r;
    uint32_t *end, endval;
 
-   vp4_getpath(profile, path);
+   if (chipset >= 0xa3 && chipset != 0xaa && chipset != 0xac)
+      vp4_getpath(profile, path);
+   else
+      vp3_getpath(profile, path);
 
    if (nouveau_bo_map(dec->fw_bo, NOUVEAU_BO_WR, dec->client))
       return 1;
@@ -333,14 +355,25 @@ nouveau_vp3_screen_get_video_param(struct pipe_screen *pscreen,
                                    enum pipe_video_profile profile,
                                    enum pipe_video_cap param)
 {
+   int chipset = nouveau_screen(pscreen)->device->chipset;
+   int vp3 = chipset < 0xa3 || chipset == 0xaa || chipset == 0xac;
+   int vp5 = chipset >= 0xd0;
+   enum pipe_video_codec codec = u_reduce_video_profile(profile);
    switch (param) {
    case PIPE_VIDEO_CAP_SUPPORTED:
-      return profile >= PIPE_VIDEO_PROFILE_MPEG1;
+      /* For now, h264 and mpeg4 don't work on pre-nvc0. */
+      if (chipset < 0xc0)
+         return codec == PIPE_VIDEO_CODEC_MPEG12 ||
+            codec == PIPE_VIDEO_CODEC_VC1;
+      /* In the general case, this should work, once the pre-nvc0 problems are
+       * resolved. */
+      return profile >= PIPE_VIDEO_PROFILE_MPEG1 && (
+            !vp3 || codec != PIPE_VIDEO_CODEC_MPEG4);
    case PIPE_VIDEO_CAP_NPOT_TEXTURES:
       return 1;
    case PIPE_VIDEO_CAP_MAX_WIDTH:
    case PIPE_VIDEO_CAP_MAX_HEIGHT:
-      return nouveau_screen(pscreen)->device->chipset < 0xd0 ? 2048 : 4096;
+      return vp5 ? 4096 : 2048;
    case PIPE_VIDEO_CAP_PREFERED_FORMAT:
       return PIPE_FORMAT_NV12;
    case PIPE_VIDEO_CAP_SUPPORTS_INTERLACED:
src/gallium/drivers/nv50/Makefile.sources +5 -1
index 0fdac51..9a2d102 100644
@@ -16,7 +16,11 @@ C_SOURCES := \
 	nv50_query.c \
 	nv84_video.c \
 	nv84_video_bsp.c \
-	nv84_video_vp.c
+	nv84_video_vp.c \
+	nv98_video.c \
+	nv98_video_bsp.c \
+	nv98_video_vp.c \
+	nv98_video_ppp.c
 
 CODEGEN_NV50_SOURCES := \
 	codegen/nv50_ir.cpp \
src/gallium/drivers/nv50/nv50_context.c +3 -2
index 79a0473..6fdbb0b 100644
@@ -267,8 +267,9 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
       pipe->create_video_decoder = nv84_create_decoder;
       pipe->create_video_buffer = nv84_video_buffer_create;
    } else {
-      /* Unsupported, but need to init pointers. */
-      nouveau_context_init_vdec(&nv50->base);
+      /* VP3/4 */
+      pipe->create_video_decoder = nv98_create_decoder;
+      pipe->create_video_buffer = nv98_video_buffer_create;
    }
 
    flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_RD;
src/gallium/drivers/nv50/nv50_context.h +14 -0
index b204cc8..52a1aa5 100644
@@ -313,4 +313,18 @@ nv84_screen_video_supported(struct pipe_screen *screen,
                             enum pipe_format format,
                             enum pipe_video_profile profile);
 
+/* nv98_video.c */
+struct pipe_video_decoder *
+nv98_create_decoder(struct pipe_context *context,
+                    enum pipe_video_profile profile,
+                    enum pipe_video_entrypoint entrypoint,
+                    enum pipe_video_chroma_format chroma_format,
+                    unsigned width, unsigned height,
+                    unsigned max_references,
+                    bool expect_chunked_decode);
+
+struct pipe_video_buffer *
+nv98_video_buffer_create(struct pipe_context *pipe,
+                         const struct pipe_video_buffer *template);
+
 #endif
src/gallium/drivers/nv50/nv50_screen.c +5 -2
index 2951eb4..5f57d96 100644
@@ -27,6 +27,8 @@
 #include "nv50_context.h"
 #include "nv50_screen.h"
 
+#include "nouveau/nouveau_vp3_video.h"
+
 #include "nouveau/nv_object.xml.h"
 #include <errno.h>
 
@@ -656,8 +658,9 @@ nv50_screen_create(struct nouveau_device *dev)
       screen->base.base.get_video_param = nv84_screen_get_video_param;
       screen->base.base.is_video_format_supported = nv84_screen_video_supported;
    } else {
-      /* Unsupported, but need to init pointers. */
-      nouveau_screen_init_vdec(&screen->base);
+      /* VP3/4 */
+      screen->base.base.get_video_param = nouveau_vp3_screen_get_video_param;
+      screen->base.base.is_video_format_supported = nouveau_vp3_screen_video_supported;
    }
 
    ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0, 4096,
src/gallium/drivers/nv50/nv50_winsys.h +0 -4
index e04247b..145ee70 100644
@@ -60,10 +60,6 @@ PUSH_REFN(struct nouveau_pushbuf *push, struct nouveau_bo *bo, uint32_t flags)
 #define SUBC_COMPUTE(m) 6, (m)
 #define NV50_COMPUTE(n) SUBC_COMPUTE(NV50_COMPUTE_##n)
 
-/* These are expected to be on their own pushbufs */
-#define SUBC_BSP(m) 2, (m)
-#define SUBC_VP(m) 2, (m)
-
 
 static INLINE uint32_t
 NV50_FIFO_PKHDR(int subc, int mthd, unsigned size)
src/gallium/drivers/nv50/nv84_video.h +4 -0
index 4ff8cf3..4240cef 100644
@@ -33,6 +33,10 @@
 
 #include "nv50_context.h"
 
+/* These are expected to be on their own pushbufs */
+#define SUBC_BSP(m) 2, (m)
+#define SUBC_VP(m) 2, (m)
+
 union pipe_desc {
    struct pipe_picture_desc *base;
    struct pipe_mpeg12_picture_desc *mpeg12;
src/gallium/drivers/nv50/nv98_video.c new file +308 -0

308 lines not on this page · raw message

src/gallium/drivers/nv50/nv98_video.h new file +48 -0

48 lines not on this page · raw message

src/gallium/drivers/nv50/nv98_video_bsp.c new file +159 -0

159 lines not on this page · raw message

src/gallium/drivers/nv50/nv98_video_ppp.c new file +143 -0

143 lines not on this page · raw message

src/gallium/drivers/nv50/nv98_video_vp.c new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
1.8.1.5