~ubuntu-branches/ubuntu/precise/xserver-xorg-video-openchrome-lts-trusty/precise-proposed

« back to all changes in this revision

Viewing changes to src/xvmc/viaXvMCPriv.h

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst
  • Date: 2014-05-15 12:47:33 UTC
  • Revision ID: package-import@ubuntu.com-20140515124733-qw5cb5dqlvejqsy3
Tags: upstream-0.3.3
Import upstream version 0.3.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 * VIA Unichrome XvMC extension client lib.
 
3
 *
 
4
 * Copyright (c) 2004 Thomas Hellstr�m. All rights reserved.
 
5
 *
 
6
 * Permission is hereby granted, free of charge, to any person obtaining a
 
7
 * copy of this software and associated documentation files (the "Software"),
 
8
 * to deal in the Software without restriction, including without limitation
 
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
10
 * and/or sell copies of the Software, and to permit persons to whom the
 
11
 * Software is furnished to do so, subject to the following conditions:
 
12
 *
 
13
 * The above copyright notice and this permission notice shall be included in
 
14
 * all copies or substantial portions of the Software.
 
15
 *
 
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
19
 * AUTHOR(S) OR COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
21
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
22
 * DEALINGS IN THE SOFTWARE.
 
23
 */
 
24
 
 
25
#ifndef _VIAXVMCPRIV_H
 
26
#define _VIAXVMCPRIV_H 1
 
27
 
 
28
#include <X11/Xlibint.h>
 
29
#include <X11/extensions/XvMC.h>
 
30
#include <X11/extensions/XvMClib.h>
 
31
#include <stdlib.h>
 
32
#include <X11/Xutil.h>
 
33
#include "vldXvMC.h"
 
34
#include "via_xvmc.h"
 
35
 
 
36
typedef struct
 
37
{
 
38
    int x;
 
39
    int y;
 
40
    int w;
 
41
    int h;
 
42
} XvMCRegion;
 
43
 
 
44
extern Status _xvmc_create_context(Display * dpy, XvMCContext * context,
 
45
    int *priv_count, uint ** priv_data);
 
46
extern Status _xvmc_destroy_context(Display * dpy, XvMCContext * context);
 
47
extern Status _xvmc_create_surface(Display * dpy, XvMCContext * context,
 
48
    XvMCSurface * surface, int *priv_count, uint ** priv_data);
 
49
extern Status _xvmc_destroy_surface(Display * dpy, XvMCSurface * surface);
 
50
extern Status _xvmc_create_subpicture(Display * dpy, XvMCContext * context,
 
51
    XvMCSubpicture * subpicture, int *priv_count, uint ** priv_data);
 
52
extern Status _xvmc_destroy_subpicture(Display * dpy,
 
53
    XvMCSubpicture * subpicture);
 
54
 
 
55
#define VIA_SUBPIC_PALETTE_SIZE 16     /*Number of colors in subpicture palette */
 
56
#define VIA_CBUFFERSIZE 4096           /*Hardware command buffer size */
 
57
#define VIA_MAX_BUFS 2                 /*Number of YUV buffers per surface */
 
58
#define VIA_MAX_RENDSURF 3             /*Maximum numbers of surfaces per context
 
59
                                        * that can answer RENDERING to a rendering
 
60
                                        * query */
 
61
 
 
62
typedef enum
 
63
{
 
64
    context_drawHash,
 
65
    context_lowLevel,
 
66
    context_mutex,
 
67
    context_sAreaMap,
 
68
    context_fbMap,
 
69
    context_mmioMap,
 
70
    context_drmContext,
 
71
    context_fd,
 
72
    context_driConnection,
 
73
    context_context,
 
74
    context_none
 
75
} ContextRes;
 
76
 
 
77
typedef struct
 
78
{
 
79
    unsigned ctxNo;                    /* XvMC private context reference number */
 
80
    pthread_mutex_t ctxMutex;          /* Mutex for multi-threading. Not used */
 
81
    drm_context_t drmcontext;          /* The drm context */
 
82
    drm_handle_t fbOffset;             /* Handle to drm frame-buffer area */
 
83
    drm_handle_t mmioOffset;           /* Handle to drm mmio area */
 
84
    drm_handle_t sAreaOffset;          /* Handle to drm shared memory area */
 
85
    unsigned fbSize;                   /* Size of drm frame-buffer area */
 
86
    unsigned mmioSize;                 /* Size of drm mmio area */
 
87
    unsigned sAreaSize;                /* Size of drm shared memory area */
 
88
    unsigned sAreaPrivOffset;          /* Offset in sarea to private part */
 
89
    drmAddress fbAddress;              /* Virtual address of frame buffer area */
 
90
    drmAddress mmioAddress;            /* Virtual address of mmio area */
 
91
    drmAddress sAreaAddress;           /* Virtual address of shared memory area */
 
92
    char busIdString[21];              /* Busid of video card */
 
93
    unsigned yStride;                  /* Y stride of surfaces in this context */
 
94
    int fd;                            /* FD for connection to drm module */
 
95
    unsigned char intra_quantiser_matrix[64];
 
96
    unsigned char non_intra_quantiser_matrix[64];
 
97
    unsigned char chroma_intra_quantiser_matrix[64];
 
98
    unsigned char chroma_non_intra_quantiser_matrix[64];
 
99
    unsigned rendSurf[VIA_MAX_RENDSURF];        /* Which surfaces answer rendering to
 
100
                                                 * a rendering query */
 
101
    int decoderOn;                     /* Decoder switched on ? */
 
102
    int intraLoaded;                   /* Intra quantiser matrix loaded in
 
103
                                        * decoder? */
 
104
    int nonIntraLoaded;                /* Non-Intra quantiser matrix loaded
 
105
                                        * in decoder */
 
106
    int chromaIntraLoaded;
 
107
    int chromaNonIntraLoaded;
 
108
    int haveDecoder;                   /* Does this context own decoder? */
 
109
    int attribChanged;                 /* Attributes have changed and need to
 
110
                                        * be uploaded to Xv at next frame
 
111
                                        * display */
 
112
    drmLockPtr hwLock;                 /* Virtual address Pointer to the
 
113
                                        * heavyweight drm hardware lock */
 
114
    unsigned xvMCPort;                 /* XvMC private port. Corresponds to
 
115
                                        * an Xv port, but not by number */
 
116
    ViaXvMCAttrHolder attrib;          /* This contexts attributes and their
 
117
                                        * values */
 
118
    XvAttribute attribDesc[VIA_NUM_XVMC_ATTRIBUTES];    /* Attribute decriptions */
 
119
    int useAGP;                        /* Use the AGP ringbuffer to upload data to the chip */
 
120
    void *xl;                          /* Lowlevel context. Opaque to us. */
 
121
    int haveXv;                        /* Have I initialized the Xv
 
122
                                        * connection for this surface? */
 
123
    XvImage *xvImage;                  /* Fake Xv Image used for command
 
124
                                        * buffer transport to the X server */
 
125
    GC  gc;                            /* X GC needed for displaying */
 
126
    Drawable draw;                     /* Drawable to undisplay from */
 
127
    XvPortID port;                     /* Xv Port ID when displaying */
 
128
    int lastSrfDisplaying;
 
129
    ContextRes resources;
 
130
    CARD32 timeStamp;
 
131
    CARD32 videoTimeStamp;
 
132
    XID id;
 
133
    unsigned screen;
 
134
    unsigned depth;
 
135
    unsigned stride;
 
136
    XVisualInfo visualInfo;
 
137
    void *drawHash;
 
138
    CARD32 chipId;
 
139
    XvMCRegion sRegion;
 
140
    XvMCRegion dRegion;
 
141
} ViaXvMCContext;
 
142
 
 
143
typedef struct
 
144
{
 
145
    pthread_mutex_t subMutex;          /* Currently not used. */
 
146
    unsigned srfNo;                    /* XvMC private surface number */
 
147
    unsigned offset;                   /* Offset into frame-buffer area */
 
148
    unsigned stride;                   /* Storage stride */
 
149
    unsigned width;                    /* Width */
 
150
    unsigned height;                   /* Height */
 
151
    CARD32 palette[VIA_SUBPIC_PALETTE_SIZE];    /* YUV Palette */
 
152
    ViaXvMCContext *privContext;       /* Pointer to context private data */
 
153
    int ia44;                          /* IA44 or AI44 format */
 
154
    int needsSync;
 
155
    CARD32 timeStamp;
 
156
} ViaXvMCSubPicture;
 
157
 
 
158
typedef struct
 
159
{
 
160
    pthread_mutex_t srfMutex;          /* For multithreading. Not used. */
 
161
    pthread_cond_t bufferAvailable;    /* For multithreading. Not used. */
 
162
    unsigned srfNo;                    /* XvMC private surface numbers */
 
163
    unsigned numBuffers;               /* Number of picture buffers */
 
164
    unsigned curBuf;                   /* Which is the current buffer? */
 
165
    unsigned offsets[VIA_MAX_BUFS];    /* Offsets of picture buffers
 
166
                                        * into the frame-buffer area */
 
167
    unsigned yStride;                  /* Stride of YUV420 Y component. */
 
168
    unsigned width;                    /* Dimensions */
 
169
    unsigned height;
 
170
    int progressiveSequence;           /* Mpeg progressive picture? Hmm? */
 
171
    ViaXvMCContext *privContext;       /* XvMC context private part. */
 
172
    ViaXvMCSubPicture *privSubPic;     /* Subpicture to be blended when
 
173
                                        * displaying. NULL if none. */
 
174
    int needsSync;
 
175
    int syncMode;
 
176
    CARD32 timeStamp;
 
177
    int topFieldFirst;
 
178
} ViaXvMCSurface;
 
179
 
 
180
/*
 
181
 * Take and release the global drm hardware lock.
 
182
 */
 
183
 
 
184
#define HW_LOCK(ctx)                                            \
 
185
    DRM_LOCK((ctx)->fd,(ctx)->hwLock,(ctx)->drmcontext,0)
 
186
#define HW_UNLOCK(ctx)                                          \
 
187
    DRM_UNLOCK((ctx)->fd,(ctx->hwLock),(ctx)->drmcontext)
 
188
 
 
189
/*
 
190
 * Low-level Mpeg functions in viaLowLevel.c
 
191
 */
 
192
 
 
193
#define VIABLIT_TRANSCOPY 0
 
194
#define VIABLIT_COPY 1
 
195
#define VIABLIT_FILL 2
 
196
 
 
197
#endif