
#ifndef _PXA3XX_VIDEO_H_
#define _PXA3XX_VIDEO_H_


typedef struct _PXA3xxPortPriv {
	int brightness;
	int saturation;
	RegionRec clip;
	CARD32 size;
	KdOffscreenArea *off_screen;
	DrawablePtr pDraw;
	PixmapPtr pPixmap;

	CARD32 tmp_offset;			/* offset from video mem base of tmp area */
	CARD32 tmp_pitch;			/* pitch of offscreen tmp area */
	CARD8 *tmp_virt;			/* virtual address of offscreen tmp area */

	int ov_pitch;				/* pitch of overlay */

	int id;
	int tmp_x1, tmp_y1, tmp_x2, tmp_y2;	/* Where to copy from in the tmp buffer */
	int tmp_w, tmp_h;
	int ov_w, ov_h;				/* size of overlay */

} PXA3xxPortPrivRec, *PXA3xxPortPrivPtr;

struct pxa3xxOverlayInfo {
	char *name;
	int num; 

	int fd;
	struct fb_var_screeninfo var;
	struct fb_fix_screeninfo fix;
		
	void *virt;
	unsigned long phys;

	int x, y, w, h;
	int bpp, format;
};

struct pxa3xxVideoPriv {
	KdVideoAdaptorPtr pAdaptor;
	int num_texture_ports;

	struct pxa3xxOverlayInfo ov[2];

	

};

Bool PXA3xxInitVideo(ScreenPtr pScreen);
void PXA3xxFiniVideo(ScreenPtr pScreen);
KdVideoAdaptorPtr PXA3xxSetupImageVideo(ScreenPtr pScreen);


int PXA3xxDisplayVideo(KdScreenInfo *screen, PXA3xxPortPrivPtr pPortPriv);
void PXA3xxStopVideo(KdScreenInfo *screen, pointer data, Bool exit);
int PXA3xxSetPortAttribute(KdScreenInfo *screen, Atom attribute, int value, pointer data);
int PXA3xxGetPortAttribute(KdScreenInfo *screen, Atom attribute, int *value, pointer data);
int PXA3xxQueryImageAttributes(KdScreenInfo *screen, int id, unsigned short *w,
		unsigned short *h, int *pitches, int *offsets);
int PXA3xxReputImage(KdScreenInfo *screen, DrawablePtr pDraw, short drw_x, short drw_y,
		RegionPtr clipBoxes, pointer data);
int PXA3xxPutImage(KdScreenInfo *screen, DrawablePtr pDraw,
	       short src_x, short src_y,
	       short drw_x, short drw_y,
	       short src_w, short src_h,
	       short drw_w, short drw_h,
	       int id,
	       unsigned char *buf,
	       short width,
	       short height,
	       Bool sync,
	       RegionPtr clipBoxes,
	       pointer data);
void PXA3xxQueryBestSize(KdScreenInfo *screen, Bool motion, short vid_w, short vid_h, 
		short drw_w, short drw_h, unsigned int *p_w, unsigned int *p_h, pointer data);

int PXA3xxCopyPlanarData(KdScreenInfo *screen, unsigned char *buf,
			int srcPitch, int dstPitch,  /* of chroma */
			int srcH, int top, int left,
			int h, int w, int id );

int inline getOverlayPlanes(struct pxa3xxOverlayInfo *ov, unsigned char **YPtr, unsigned char **UPtr, unsigned char **VPtr);
int inline getOverlayPlanesPhys(struct pxa3xxOverlayInfo *ov, unsigned long *YPtr, unsigned long *UPtr, unsigned long *VPtr);
int setupOverlay(struct pxa3xxOverlayInfo *ov, int x, int y, int w, int h, int format, int bpp);
int openOverlay(struct pxa3xxOverlayInfo *ov);
void closeOverlay(struct pxa3xxOverlayInfo *ov);
int inline checkOverlay(struct pxa3xxOverlayInfo *ov, int x, int y, int w, int h, int format, int bpp);
void PXA3xxClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2, BoxPtr extents, INT32 width, INT32 height);
void PXA3xxVideoSave(ScreenPtr pScreen, KdOffscreenArea *area);

#endif /* _PXA3XX_VIDEO_H_ */

