1706f2543Smrg/*
2706f2543Smrg * Xephyr - A kdrive X server thats runs in a host X window.
3706f2543Smrg *          Authored by Matthew Allum <mallum@openedhand.com>
4706f2543Smrg *
5706f2543Smrg * Copyright © 2007 OpenedHand Ltd
6706f2543Smrg *
7706f2543Smrg * Permission to use, copy, modify, distribute, and sell this software and its
8706f2543Smrg * documentation for any purpose is hereby granted without fee, provided that
9706f2543Smrg * the above copyright notice appear in all copies and that both that
10706f2543Smrg * copyright notice and this permission notice appear in supporting
11706f2543Smrg * documentation, and that the name of OpenedHand Ltd not be used in
12706f2543Smrg * advertising or publicity pertaining to distribution of the software without
13706f2543Smrg * specific, written prior permission. OpenedHand Ltd makes no
14706f2543Smrg * representations about the suitability of this software for any purpose.  It
15706f2543Smrg * is provided "as is" without express or implied warranty.
16706f2543Smrg *
17706f2543Smrg * OpenedHand Ltd DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
18706f2543Smrg * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
19706f2543Smrg * EVENT SHALL OpenedHand Ltd BE LIABLE FOR ANY SPECIAL, INDIRECT OR
20706f2543Smrg * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21706f2543Smrg * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
22706f2543Smrg * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
23706f2543Smrg * PERFORMANCE OF THIS SOFTWARE.
24706f2543Smrg *
25706f2543Smrg * Authors:
26706f2543Smrg *    Dodji Seketeli <dodji@openedhand.com>
27706f2543Smrg */
28706f2543Smrg#ifndef __EPHYRHOSTVIDEO_H__
29706f2543Smrg#define __EPHYRHOSTVIDEO_H__
30706f2543Smrg
31706f2543Smrgtypedef void* EphyrHostXVAdaptor ;
32706f2543Smrgtypedef struct _EphyrHostXVAdaptorArray EphyrHostXVAdaptorArray ;
33706f2543Smrg
34706f2543Smrgtypedef struct _EphyrHostVideoFormat {
35706f2543Smrg    char depth ;
36706f2543Smrg    short visual_class;
37706f2543Smrg} EphyrHostVideoFormat ;
38706f2543Smrg
39706f2543Smrgtypedef struct _EphyrHostRational {
40706f2543Smrg    int numerator ;
41706f2543Smrg    int denominator ;
42706f2543Smrg} EphyrHostRational;
43706f2543Smrg
44706f2543Smrgtypedef struct _EphyrHostEncoding {
45706f2543Smrg    int id ;
46706f2543Smrg    char *name ;
47706f2543Smrg    unsigned short width, height ;
48706f2543Smrg    EphyrHostRational rate ;
49706f2543Smrg} EphyrHostEncoding ;
50706f2543Smrg
51706f2543Smrgtypedef struct _EphyrHostAttribute {
52706f2543Smrg    int flags;
53706f2543Smrg    int min_value;
54706f2543Smrg    int max_value;
55706f2543Smrg    char *name;
56706f2543Smrg} EphyrHostAttribute ;
57706f2543Smrg
58706f2543Smrgtypedef struct _EphyrHostImageFormat {
59706f2543Smrg    int id;                      /* Unique descriptor for the format */
60706f2543Smrg    int type;                    /* XvRGB, XvYUV */
61706f2543Smrg    int byte_order;              /* LSBFirst, MSBFirst */
62706f2543Smrg    char guid[16];               /* Globally Unique IDentifier */
63706f2543Smrg    int bits_per_pixel;
64706f2543Smrg    int format;                  /* XvPacked, XvPlanar */
65706f2543Smrg    int num_planes;
66706f2543Smrg
67706f2543Smrg    /* for RGB formats only */
68706f2543Smrg    int depth;
69706f2543Smrg    unsigned int red_mask;
70706f2543Smrg    unsigned int green_mask;
71706f2543Smrg    unsigned int blue_mask;
72706f2543Smrg
73706f2543Smrg    /* for YUV formats only */
74706f2543Smrg    unsigned int y_sample_bits;
75706f2543Smrg    unsigned int u_sample_bits;
76706f2543Smrg    unsigned int v_sample_bits;
77706f2543Smrg    unsigned int horz_y_period;
78706f2543Smrg    unsigned int horz_u_period;
79706f2543Smrg    unsigned int horz_v_period;
80706f2543Smrg    unsigned int vert_y_period;
81706f2543Smrg    unsigned int vert_u_period;
82706f2543Smrg    unsigned int vert_v_period;
83706f2543Smrg    char component_order[32];    /* eg. UYVY */
84706f2543Smrg    int scanline_order;          /* XvTopToBottom, XvBottomToTop */
85706f2543Smrg} EphyrHostImageFormat ;
86706f2543Smrg
87706f2543Smrgtypedef struct {
88706f2543Smrg    unsigned short x1, y1, x2, y2 ;
89706f2543Smrg} EphyrHostBox ;
90706f2543Smrg
91706f2543Smrgvoid ephyrHostXVInit (void) ;
92706f2543Smrg
93706f2543Smrgvoid ephyrHostFree (void *a_pointer) ;
94706f2543Smrg
95706f2543Smrg/*
96706f2543Smrg * host adaptor array
97706f2543Smrg */
98706f2543SmrgBool ephyrHostXVQueryAdaptors (EphyrHostXVAdaptorArray **a_adaptors) ;
99706f2543Smrgvoid ephyrHostXVAdaptorArrayDelete (EphyrHostXVAdaptorArray *a_adaptors) ;
100706f2543Smrgint ephyrHostXVAdaptorArrayGetSize (const EphyrHostXVAdaptorArray *a_this) ;
101706f2543SmrgEphyrHostXVAdaptor* ephyrHostXVAdaptorArrayAt (const EphyrHostXVAdaptorArray *a_this,
102706f2543Smrg                                               int a_index) ;
103706f2543Smrg
104706f2543Smrg/*
105706f2543Smrg * host adaptor
106706f2543Smrg */
107706f2543Smrg
108706f2543Smrgchar ephyrHostXVAdaptorGetType (const EphyrHostXVAdaptor *a_this) ;
109706f2543Smrgconst char* ephyrHostXVAdaptorGetName (const EphyrHostXVAdaptor *a_this) ;
110706f2543SmrgEphyrHostVideoFormat* ephyrHostXVAdaptorGetVideoFormats
111706f2543Smrg                                                (const EphyrHostXVAdaptor *a_this,
112706f2543Smrg                                                 int *a_nb_formats) ;
113706f2543Smrgint ephyrHostXVAdaptorGetNbPorts (const EphyrHostXVAdaptor *a_this) ;
114706f2543Smrgint ephyrHostXVAdaptorGetFirstPortID (const EphyrHostXVAdaptor *a_this) ;
115706f2543Smrg
116706f2543SmrgBool ephyrHostXVAdaptorHasPutVideo (const EphyrHostXVAdaptor *a_this,
117706f2543Smrg                                    Bool *a_result) ;
118706f2543SmrgBool ephyrHostXVAdaptorHasGetVideo (const EphyrHostXVAdaptor *a_this,
119706f2543Smrg                                    Bool *a_result) ;
120706f2543SmrgBool ephyrHostXVAdaptorHasPutStill (const EphyrHostXVAdaptor *a_this,
121706f2543Smrg                                    Bool *a_result) ;
122706f2543SmrgBool ephyrHostXVAdaptorHasGetStill (const EphyrHostXVAdaptor *a_this,
123706f2543Smrg                                    Bool *a_result) ;
124706f2543SmrgBool ephyrHostXVAdaptorHasPutImage (const EphyrHostXVAdaptor *a_this,
125706f2543Smrg                                    Bool *a_result) ;
126706f2543Smrg
127706f2543Smrg/*
128706f2543Smrg * encoding
129706f2543Smrg */
130706f2543SmrgBool ephyrHostXVQueryEncodings (int a_port_id,
131706f2543Smrg                                EphyrHostEncoding **a_encodings,
132706f2543Smrg                                unsigned int *a_num_encodings) ;
133706f2543Smrg
134706f2543Smrgvoid ephyrHostEncodingsDelete (EphyrHostEncoding *a_encodings,
135706f2543Smrg                               int a_num_encodings) ;
136706f2543Smrg
137706f2543Smrg/*
138706f2543Smrg * attribute
139706f2543Smrg */
140706f2543SmrgBool ephyrHostXVQueryPortAttributes (int a_port_id,
141706f2543Smrg                                     EphyrHostAttribute **a_attributes,
142706f2543Smrg                                     int *a_num_attributes) ;
143706f2543Smrg
144706f2543Smrgvoid ephyrHostAttributesDelete (EphyrHostAttribute *a_attributes) ;
145706f2543Smrg/*
146706f2543Smrg * image format
147706f2543Smrg */
148706f2543Smrg
149706f2543SmrgBool ephyrHostXVQueryImageFormats (int a_port_id,
150706f2543Smrg                                   EphyrHostImageFormat **a_formats,
151706f2543Smrg                                   int *a_num_format) ;
152706f2543Smrg/*
153706f2543Smrg * Port Attribute Get/Set
154706f2543Smrg */
155706f2543SmrgBool ephyrHostXVSetPortAttribute (int a_port_id,
156706f2543Smrg                                  int a_atom,
157706f2543Smrg                                  int a_attr_value) ;
158706f2543SmrgBool ephyrHostXVGetPortAttribute (int a_port_id,
159706f2543Smrg                                  int a_atom,
160706f2543Smrg                                  int *a_attr_value) ;
161706f2543Smrg/*
162706f2543Smrg *size query
163706f2543Smrg */
164706f2543SmrgBool ephyrHostXVQueryBestSize (int a_port_id,
165706f2543Smrg                               Bool a_motion,
166706f2543Smrg                               unsigned int a_frame_w,
167706f2543Smrg                               unsigned int a_frame_h,
168706f2543Smrg                               unsigned int a_drw_w,
169706f2543Smrg                               unsigned int a_drw_h,
170706f2543Smrg                               unsigned int *a_actual_w,
171706f2543Smrg                               unsigned int *a_actual_h) ;
172706f2543Smrg
173706f2543SmrgBool ephyrHostXVQueryImageAttributes (int a_port_id,
174706f2543Smrg                                      int a_image_id /*image fourcc code*/,
175706f2543Smrg                                      unsigned short *a_width,
176706f2543Smrg                                      unsigned short *a_height,
177706f2543Smrg                                      int *a_image_size,
178706f2543Smrg                                      int *a_pitches,
179706f2543Smrg                                      int *a_offsets) ;
180706f2543Smrg/*
181706f2543Smrg * atom
182706f2543Smrg */
183706f2543SmrgBool ephyrHostGetAtom (const char* a_name,
184706f2543Smrg                       Bool a_create_if_not_exists,
185706f2543Smrg                       int *a_atom) ;
186706f2543Smrgchar* ephyrHostGetAtomName (int a_atom) ;
187706f2543Smrg
188706f2543Smrg/*
189706f2543Smrg *PutImage
190706f2543Smrg * (ignore clipping for now)
191706f2543Smrg */
192706f2543SmrgBool ephyrHostXVPutImage (int a_screen_num,
193706f2543Smrg                          int a_port_id,
194706f2543Smrg                          int a_image_id,
195706f2543Smrg                          int a_drw_x,
196706f2543Smrg                          int a_drw_y,
197706f2543Smrg                          int a_drw_w,
198706f2543Smrg                          int a_drw_h,
199706f2543Smrg                          int a_src_x,
200706f2543Smrg                          int a_src_y,
201706f2543Smrg                          int a_src_w,
202706f2543Smrg                          int a_src_h,
203706f2543Smrg                          int a_image_width,
204706f2543Smrg                          int a_image_height,
205706f2543Smrg                          unsigned char *a_buf,
206706f2543Smrg                          EphyrHostBox *a_clip_rects,
207706f2543Smrg                          int a_clip_rect_nums) ;
208706f2543Smrg
209706f2543Smrg/*
210706f2543Smrg * Putvideo/PutStill/GetVideo
211706f2543Smrg */
212706f2543SmrgBool ephyrHostXVPutVideo (int a_screen_num,
213706f2543Smrg                          int a_port_id,
214706f2543Smrg                          int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
215706f2543Smrg                          int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
216706f2543Smrg
217706f2543SmrgBool ephyrHostXVGetVideo (int a_screen_num,
218706f2543Smrg                          int a_port_id,
219706f2543Smrg                          int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
220706f2543Smrg                          int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
221706f2543Smrg
222706f2543SmrgBool ephyrHostXVPutStill (int a_screen_num,
223706f2543Smrg                          int a_port_id,
224706f2543Smrg                          int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
225706f2543Smrg                          int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
226706f2543Smrg
227706f2543SmrgBool ephyrHostXVGetStill (int a_screen_num,
228706f2543Smrg                          int a_port_id,
229706f2543Smrg                          int a_vid_x, int a_vid_y, int a_vid_w, int a_vid_h,
230706f2543Smrg                          int a_drw_x, int a_drw_y, int a_drw_w, int a_drw_h) ;
231706f2543Smrg
232706f2543Smrg/*
233706f2543Smrg * StopVideo
234706f2543Smrg */
235706f2543SmrgBool ephyrHostXVStopVideo (int a_screen_num, int a_port_id) ;
236706f2543Smrg
237706f2543Smrg#endif /*__EPHYRHOSTVIDEO_H__*/
238706f2543Smrg
239