105b261ecSmrg
205b261ecSmrg/*
305b261ecSmrg * Copyright (c) 1998-2003 by The XFree86 Project, Inc.
405b261ecSmrg *
505b261ecSmrg * Permission is hereby granted, free of charge, to any person obtaining a
605b261ecSmrg * copy of this software and associated documentation files (the "Software"),
705b261ecSmrg * to deal in the Software without restriction, including without limitation
805b261ecSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
905b261ecSmrg * and/or sell copies of the Software, and to permit persons to whom the
1005b261ecSmrg * Software is furnished to do so, subject to the following conditions:
1105b261ecSmrg *
1205b261ecSmrg * The above copyright notice and this permission notice shall be included in
1305b261ecSmrg * all copies or substantial portions of the Software.
1405b261ecSmrg *
1505b261ecSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1605b261ecSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1705b261ecSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1805b261ecSmrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1905b261ecSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
2005b261ecSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2105b261ecSmrg * OTHER DEALINGS IN THE SOFTWARE.
2205b261ecSmrg *
2305b261ecSmrg * Except as contained in this notice, the name of the copyright holder(s)
2405b261ecSmrg * and author(s) shall not be used in advertising or otherwise to promote
2505b261ecSmrg * the sale, use or other dealings in this Software without prior written
2605b261ecSmrg * authorization from the copyright holder(s) and author(s).
2705b261ecSmrg */
2805b261ecSmrg
2905b261ecSmrg#ifndef _XF86XV_H_
3005b261ecSmrg#define _XF86XV_H_
3105b261ecSmrg
3205b261ecSmrg#include "xvdix.h"
3305b261ecSmrg#include "xf86str.h"
3405b261ecSmrg
3505b261ecSmrg#define VIDEO_OVERLAID_IMAGES			0x00000004
3605b261ecSmrg#define VIDEO_OVERLAID_STILLS			0x00000008
379ace9065Smrg/*
389ace9065Smrg * Usage of VIDEO_CLIP_TO_VIEWPORT is not recommended.
399ace9065Smrg * It can make reput behaviour inconsistent.
409ace9065Smrg */
4105b261ecSmrg#define VIDEO_CLIP_TO_VIEWPORT			0x00000010
4205b261ecSmrg
4335c4bbdfSmrgtypedef XvImageRec XF86ImageRec, *XF86ImagePtr;
4405b261ecSmrg
4505b261ecSmrgtypedef struct {
4635c4bbdfSmrg    ScrnInfoPtr pScrn;
4735c4bbdfSmrg    int id;
4835c4bbdfSmrg    unsigned short width, height;
4935c4bbdfSmrg    int *pitches;               /* bytes */
5035c4bbdfSmrg    int *offsets;               /* in bytes from start of framebuffer */
5135c4bbdfSmrg    DevUnion devPrivate;
5205b261ecSmrg} XF86SurfaceRec, *XF86SurfacePtr;
5305b261ecSmrg
5435c4bbdfSmrgtypedef int (*PutVideoFuncPtr) (ScrnInfoPtr pScrn,
5535c4bbdfSmrg                                short vid_x, short vid_y, short drw_x,
5635c4bbdfSmrg                                short drw_y, short vid_w, short vid_h,
5735c4bbdfSmrg                                short drw_w, short drw_h, RegionPtr clipBoxes,
5835c4bbdfSmrg                                void *data, DrawablePtr pDraw);
5935c4bbdfSmrgtypedef int (*PutStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
6035c4bbdfSmrg                                short drw_x, short drw_y, short vid_w,
6135c4bbdfSmrg                                short vid_h, short drw_w, short drw_h,
6235c4bbdfSmrg                                RegionPtr clipBoxes, void *data,
6335c4bbdfSmrg                                DrawablePtr pDraw);
6435c4bbdfSmrgtypedef int (*GetVideoFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
6535c4bbdfSmrg                                short drw_x, short drw_y, short vid_w,
6635c4bbdfSmrg                                short vid_h, short drw_w, short drw_h,
6735c4bbdfSmrg                                RegionPtr clipBoxes, void *data,
6835c4bbdfSmrg                                DrawablePtr pDraw);
6935c4bbdfSmrgtypedef int (*GetStillFuncPtr) (ScrnInfoPtr pScrn, short vid_x, short vid_y,
7035c4bbdfSmrg                                short drw_x, short drw_y, short vid_w,
7135c4bbdfSmrg                                short vid_h, short drw_w, short drw_h,
7235c4bbdfSmrg                                RegionPtr clipBoxes, void *data,
7335c4bbdfSmrg                                DrawablePtr pDraw);
7435c4bbdfSmrgtypedef void (*StopVideoFuncPtr) (ScrnInfoPtr pScrn, void *data, Bool Exit);
7535c4bbdfSmrgtypedef int (*SetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
7635c4bbdfSmrg                                        INT32 value, void *data);
7735c4bbdfSmrgtypedef int (*GetPortAttributeFuncPtr) (ScrnInfoPtr pScrn, Atom attribute,
7835c4bbdfSmrg                                        INT32 *value, void *data);
7935c4bbdfSmrgtypedef void (*QueryBestSizeFuncPtr) (ScrnInfoPtr pScrn, Bool motion,
8035c4bbdfSmrg                                      short vid_w, short vid_h, short drw_w,
8135c4bbdfSmrg                                      short drw_h, unsigned int *p_w,
8235c4bbdfSmrg                                      unsigned int *p_h, void *data);
8335c4bbdfSmrgtypedef int (*PutImageFuncPtr) (ScrnInfoPtr pScrn, short src_x, short src_y,
8435c4bbdfSmrg                                short drw_x, short drw_y, short src_w,
8535c4bbdfSmrg                                short src_h, short drw_w, short drw_h,
8635c4bbdfSmrg                                int image, unsigned char *buf, short width,
8735c4bbdfSmrg                                short height, Bool Sync, RegionPtr clipBoxes,
8835c4bbdfSmrg                                void *data, DrawablePtr pDraw);
8935c4bbdfSmrgtypedef int (*ReputImageFuncPtr) (ScrnInfoPtr pScrn, short src_x, short src_y,
9035c4bbdfSmrg                                  short drw_x, short drw_y, short src_w,
9135c4bbdfSmrg                                  short src_h, short drw_w, short drw_h,
9235c4bbdfSmrg                                  RegionPtr clipBoxes, void *data,
9335c4bbdfSmrg                                  DrawablePtr pDraw);
9435c4bbdfSmrgtypedef int (*QueryImageAttributesFuncPtr) (ScrnInfoPtr pScrn, int image,
9535c4bbdfSmrg                                            unsigned short *width,
9635c4bbdfSmrg                                            unsigned short *height,
9735c4bbdfSmrg                                            int *pitches, int *offsets);
9805b261ecSmrg
9905b261ecSmrgtypedef enum {
10005b261ecSmrg    XV_OFF,
10105b261ecSmrg    XV_PENDING,
10205b261ecSmrg    XV_ON
10305b261ecSmrg} XvStatus;
10405b261ecSmrg
10505b261ecSmrg/*** this is what the driver needs to fill out ***/
10605b261ecSmrg
10705b261ecSmrgtypedef struct {
10835c4bbdfSmrg    int id;
1099207c819Smaya    /*const*/ char *name; /* dozens of drivers write to this value */
11035c4bbdfSmrg    unsigned short width, height;
11135c4bbdfSmrg    XvRationalRec rate;
11205b261ecSmrg} XF86VideoEncodingRec, *XF86VideoEncodingPtr;
11305b261ecSmrg
11405b261ecSmrgtypedef struct {
11535c4bbdfSmrg    char depth;
11635c4bbdfSmrg    short class;
11705b261ecSmrg} XF86VideoFormatRec, *XF86VideoFormatPtr;
11805b261ecSmrg
11935c4bbdfSmrgtypedef XvAttributeRec XF86AttributeRec, *XF86AttributePtr;
12005b261ecSmrg
12105b261ecSmrgtypedef struct {
12235c4bbdfSmrg    unsigned int type;
12335c4bbdfSmrg    int flags;
12435c4bbdfSmrg    const char *name;
12535c4bbdfSmrg    int nEncodings;
12635c4bbdfSmrg    XF86VideoEncodingPtr pEncodings;
12735c4bbdfSmrg    int nFormats;
12835c4bbdfSmrg    XF86VideoFormatPtr pFormats;
12935c4bbdfSmrg    int nPorts;
13035c4bbdfSmrg    DevUnion *pPortPrivates;
13135c4bbdfSmrg    int nAttributes;
13235c4bbdfSmrg    XF86AttributePtr pAttributes;
13335c4bbdfSmrg    int nImages;
13435c4bbdfSmrg    XF86ImagePtr pImages;
13535c4bbdfSmrg    PutVideoFuncPtr PutVideo;
13635c4bbdfSmrg    PutStillFuncPtr PutStill;
13735c4bbdfSmrg    GetVideoFuncPtr GetVideo;
13835c4bbdfSmrg    GetStillFuncPtr GetStill;
13935c4bbdfSmrg    StopVideoFuncPtr StopVideo;
14035c4bbdfSmrg    SetPortAttributeFuncPtr SetPortAttribute;
14135c4bbdfSmrg    GetPortAttributeFuncPtr GetPortAttribute;
14235c4bbdfSmrg    QueryBestSizeFuncPtr QueryBestSize;
14335c4bbdfSmrg    PutImageFuncPtr PutImage;
14435c4bbdfSmrg    ReputImageFuncPtr ReputImage;       /* image/still */
14535c4bbdfSmrg    QueryImageAttributesFuncPtr QueryImageAttributes;
14605b261ecSmrg} XF86VideoAdaptorRec, *XF86VideoAdaptorPtr;
14705b261ecSmrg
14805b261ecSmrgtypedef struct {
14935c4bbdfSmrg    XF86ImagePtr image;
15035c4bbdfSmrg    int flags;
15135c4bbdfSmrg    int (*alloc_surface) (ScrnInfoPtr pScrn,
15235c4bbdfSmrg                          int id,
15335c4bbdfSmrg                          unsigned short width,
15435c4bbdfSmrg                          unsigned short height, XF86SurfacePtr surface);
15535c4bbdfSmrg    int (*free_surface) (XF86SurfacePtr surface);
15635c4bbdfSmrg    int (*display) (XF86SurfacePtr surface,
15735c4bbdfSmrg                    short vid_x, short vid_y,
15835c4bbdfSmrg                    short drw_x, short drw_y,
15935c4bbdfSmrg                    short vid_w, short vid_h,
16035c4bbdfSmrg                    short drw_w, short drw_h, RegionPtr clipBoxes);
16135c4bbdfSmrg    int (*stop) (XF86SurfacePtr surface);
16235c4bbdfSmrg    int (*getAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 *value);
16335c4bbdfSmrg    int (*setAttribute) (ScrnInfoPtr pScrn, Atom attr, INT32 value);
16435c4bbdfSmrg    int max_width;
16535c4bbdfSmrg    int max_height;
16635c4bbdfSmrg    int num_attributes;
16735c4bbdfSmrg    XF86AttributePtr attributes;
16805b261ecSmrg} XF86OffscreenImageRec, *XF86OffscreenImagePtr;
16905b261ecSmrg
1706747b715Smrgextern _X_EXPORT Bool
17135c4bbdfSmrg xf86XVScreenInit(ScreenPtr pScreen, XF86VideoAdaptorPtr * Adaptors, int num);
17205b261ecSmrg
17335c4bbdfSmrgtypedef int (*xf86XVInitGenericAdaptorPtr) (ScrnInfoPtr pScrn,
17435c4bbdfSmrg                                            XF86VideoAdaptorPtr ** Adaptors);
17505b261ecSmrg
1766747b715Smrgextern _X_EXPORT int
17735c4bbdfSmrg xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc);
17805b261ecSmrg
1796747b715Smrgextern _X_EXPORT int
18035c4bbdfSmrg xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** Adaptors);
18105b261ecSmrg
1826747b715Smrgextern _X_EXPORT Bool
18335c4bbdfSmrg
18435c4bbdfSmrgxf86XVRegisterOffscreenImages(ScreenPtr pScreen,
18535c4bbdfSmrg                              XF86OffscreenImagePtr images, int num);
18605b261ecSmrg
1876747b715Smrgextern _X_EXPORT XF86OffscreenImagePtr
18835c4bbdfSmrgxf86XVQueryOffscreenImages(ScreenPtr pScreen, int *num);
18935c4bbdfSmrg
19035c4bbdfSmrgextern _X_EXPORT XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr
19135c4bbdfSmrg                                                                   pScrn);
19205b261ecSmrg
1936747b715Smrgextern _X_EXPORT void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
19405b261ecSmrg
1956747b715Smrgextern _X_EXPORT void
19635c4bbdfSmrg xf86XVFillKeyHelper(ScreenPtr pScreen, CARD32 key, RegionPtr clipboxes);
19705b261ecSmrg
1986747b715Smrgextern _X_EXPORT void
19935c4bbdfSmrg
20035c4bbdfSmrgxf86XVFillKeyHelperDrawable(DrawablePtr pDraw, CARD32 key, RegionPtr clipboxes);
20105b261ecSmrg
2029ace9065Smrgextern _X_EXPORT void
20335c4bbdfSmrg
20435c4bbdfSmrgxf86XVFillKeyHelperPort(DrawablePtr pDraw, void *data, CARD32 key,
20535c4bbdfSmrg                        RegionPtr clipboxes, Bool fillEverything);
2069ace9065Smrg
2076747b715Smrgextern _X_EXPORT Bool
20835c4bbdfSmrg
20935c4bbdfSmrgxf86XVClipVideoHelper(BoxPtr dst,
21035c4bbdfSmrg                      INT32 *xa,
21135c4bbdfSmrg                      INT32 *xb,
21235c4bbdfSmrg                      INT32 *ya,
21335c4bbdfSmrg                      INT32 *yb, RegionPtr reg, INT32 width, INT32 height);
21405b261ecSmrg
2156747b715Smrgextern _X_EXPORT void
21635c4bbdfSmrg
21735c4bbdfSmrgxf86XVCopyYUV12ToPacked(const void *srcy,
21835c4bbdfSmrg                        const void *srcv,
21935c4bbdfSmrg                        const void *srcu,
22035c4bbdfSmrg                        void *dst,
22135c4bbdfSmrg                        int srcPitchy,
22235c4bbdfSmrg                        int srcPitchuv, int dstPitch, int h, int w);
22305b261ecSmrg
2246747b715Smrgextern _X_EXPORT void
22535c4bbdfSmrg
22635c4bbdfSmrgxf86XVCopyPacked(const void *src,
22735c4bbdfSmrg                 void *dst, int srcPitch, int dstPitch, int h, int w);
22835c4bbdfSmrg
22935c4bbdfSmrg#endif                          /* _XF86XV_H_ */
230