1
/*****************************************************************************
2
* VIA Unichrome XvMC extension client lib.
4
* Copyright (c) 2004 Thomas Hellstr�m. All rights reserved.
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:
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
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.
25
#ifndef _VIAXVMCPRIV_H
26
#define _VIAXVMCPRIV_H 1
28
#include <X11/Xlibint.h>
29
#include <X11/extensions/XvMC.h>
30
#include <X11/extensions/XvMClib.h>
32
#include <X11/Xutil.h>
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);
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
72
context_driConnection,
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
104
int nonIntraLoaded; /* Non-Intra quantiser matrix loaded
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
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
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;
131
CARD32 videoTimeStamp;
136
XVisualInfo visualInfo;
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 */
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 */
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. */
181
* Take and release the global drm hardware lock.
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)
190
* Low-level Mpeg functions in viaLowLevel.c
193
#define VIABLIT_TRANSCOPY 0
194
#define VIABLIT_COPY 1
195
#define VIABLIT_FILL 2