Home | History | Annotate | Download | only in nouveau
      1 #ifndef __NOUVEAU_VIDEO_H__
      2 #define __NOUVEAU_VIDEO_H__
      3 
      4 #include "nv17_mpeg.xml.h"
      5 #include "nv31_mpeg.xml.h"
      6 #include "nv_object.xml.h"
      7 
      8 #include "nouveau_winsys.h"
      9 
     10 struct nouveau_video_buffer {
     11    struct pipe_video_buffer base;
     12    unsigned num_planes;
     13    struct pipe_resource     *resources[3];
     14    struct pipe_sampler_view *sampler_view_planes[3];
     15    struct pipe_sampler_view *sampler_view_components[3];
     16    struct pipe_surface      *surfaces[3];
     17 };
     18 
     19 struct nouveau_decoder {
     20    struct pipe_video_decoder base;
     21    struct nouveau_screen *screen;
     22    struct nouveau_pushbuf *push;
     23    struct nouveau_object *chan;
     24    struct nouveau_client *client;
     25    struct nouveau_bufctx *bufctx;
     26    struct nouveau_object *mpeg;
     27    struct nouveau_bo *cmd_bo, *data_bo, *fence_bo;
     28 
     29    unsigned *fence_map;
     30    unsigned fence_seq;
     31 
     32    unsigned ofs;
     33    unsigned *cmds;
     34 
     35    unsigned *data;
     36    unsigned data_pos;
     37    unsigned picture_structure;
     38 
     39    unsigned past, future, current;
     40    unsigned num_surfaces;
     41    struct nouveau_video_buffer *surfaces[8];
     42 };
     43 
     44 #define NV31_VIDEO_BIND_IMG(i)  i
     45 #define NV31_VIDEO_BIND_CMD     NV31_MPEG_IMAGE_Y_OFFSET__LEN
     46 #define NV31_VIDEO_BIND_COUNT  (NV31_MPEG_IMAGE_Y_OFFSET__LEN + 1)
     47 
     48 static INLINE void
     49 nouveau_vpe_write(struct nouveau_decoder *dec, unsigned data) {
     50    dec->cmds[dec->ofs++] = data;
     51 }
     52 
     53 #define SUBC_MPEG(mthd) 1, mthd
     54 #define NV31_MPEG(mthd) SUBC_MPEG(NV31_MPEG_##mthd)
     55 #define NV84_MPEG(mthd) SUBC_MPEG(NV84_MPEG_##mthd)
     56 
     57 static INLINE uint32_t
     58 NV04_FIFO_PKHDR(int subc, int mthd, unsigned size)
     59 {
     60    return 0x00000000 | (size << 18) | (subc << 13) | mthd;
     61 }
     62 
     63 static INLINE uint32_t
     64 NV04_FIFO_PKHDR_NI(int subc, int mthd, unsigned size)
     65 {
     66    return 0x40000000 | (size << 18) | (subc << 13) | mthd;
     67 }
     68 
     69 static INLINE void
     70 BEGIN_NV04(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size)
     71 {
     72    PUSH_SPACE(push, size + 1);
     73    PUSH_DATA (push, NV04_FIFO_PKHDR(subc, mthd, size));
     74 }
     75 
     76 static INLINE void
     77 BEGIN_NI04(struct nouveau_pushbuf *push, int subc, int mthd, unsigned size)
     78 {
     79    PUSH_SPACE(push, size + 1);
     80    PUSH_DATA (push, NV04_FIFO_PKHDR_NI(subc, mthd, size));
     81 }
     82 
     83 static INLINE void
     84 PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd,
     85            struct nouveau_bo *bo, uint32_t offset,
     86 	   struct nouveau_bufctx *ctx, int bin, uint32_t rw)
     87 {
     88    nouveau_bufctx_mthd(ctx, bin, NV04_FIFO_PKHDR(subc, mthd, 1),
     89                        bo, offset,
     90                        NOUVEAU_BO_LOW | (bo->flags & NOUVEAU_BO_APER) | rw,
     91                        0, 0);
     92 
     93    PUSH_DATA(push, bo->offset + offset);
     94 }
     95 
     96 #endif
     97