xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/nouveau/nouveau_video.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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[VL_NUM_COMPONENTS];
14    struct pipe_sampler_view *sampler_view_planes[VL_NUM_COMPONENTS];
15    struct pipe_sampler_view *sampler_view_components[VL_NUM_COMPONENTS];
16    struct pipe_surface      *surfaces[VL_NUM_COMPONENTS * 2];
17 };
18 
19 struct nouveau_decoder {
20    struct pipe_video_codec 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
nouveau_vpe_write(struct nouveau_decoder * dec,unsigned data)49 nouveau_vpe_write(struct nouveau_decoder *dec, unsigned data) {
50    dec->cmds[dec->ofs++] = data;
51 }
52 
53 static inline void
PUSH_MTHDl(struct nouveau_pushbuf * push,int subc,int mthd,struct nouveau_bo * bo,uint32_t offset,struct nouveau_bufctx * ctx,int bin,uint32_t rw)54 PUSH_MTHDl(struct nouveau_pushbuf *push, int subc, int mthd,
55            struct nouveau_bo *bo, uint32_t offset,
56            struct nouveau_bufctx *ctx, int bin, uint32_t rw)
57 {
58    nouveau_bufctx_mthd(ctx, bin, NV04_FIFO_PKHDR(subc, mthd, 1),
59                        bo, offset,
60                        NOUVEAU_BO_LOW | (bo->flags & NOUVEAU_BO_APER) | rw,
61                        0, 0);
62 
63    PUSH_DATA(push, bo->offset + offset);
64 }
65 
66 #define SUBC_MPEG(mthd) 1, mthd
67 #define NV31_MPEG(mthd) SUBC_MPEG(NV31_MPEG_##mthd)
68 #define NV84_MPEG(mthd) SUBC_MPEG(NV84_MPEG_##mthd)
69 
70 #endif
71