/* HwMpeg.h * * Copyright 2004 BEAM Ltd. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BEAM LTD, TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Terry Barnaby * * * Description * This code provides access to a Hardware MPEG controller. */ #ifndef _HWMPEG_H_ #define _HWMPEG_H_ #include /* TMP Bits */ #define TRUE 1 /* HwMpeg flags */ #define HWMPEG_FLAG_SECOND_FIELD 0x00000004 #define HWMPEG_FLAG_PROGRESSIVE_SEQUENCE 0x00000010 #define HWMPEG_FLAG_ALTERNATE_SCAN 0x00000100 #define HWMPEG_FLAG_PRED_DCT_FRAME 0x00000040 #define HWMPEG_FLAG_TOP_FIELD_FIRST 0x00000080 #define HWMPEG_FLAG_Q_SCALE_TYPE 0x00000400 #define HWMPEG_FLAG_INTRA_VLC_FORMAT 0x00000800 #define HWMPEG_FLAG_CONCEALMENT_MOTION_VECTORS 0x00000200 #define HWMPEG_FLAG_ZIG_ZAG_SCAN 0x00000000 #define HWMPEG_FLAG_PRED_DCT_FIELD 0x00000000 #define HWMPEG_FLAG_BOTTOM_FIELD_FIRST 0x00000000 #define HWMPEG_MCODE_MPEG_1 0x00000001 #define HWMPEG_MCODE_MPEG_2 0x00000002 #define HWMPEG_PSTRUCT_TOP_FIELD 0x00000001 #define HWMPEG_PSTRUCT_BOTTOM_FIELD 0x00000002 #define HWMPEG_PSTRUCT_FRAME_PICTURE (HWMPEG_PSTRUCT_TOP_FIELD | HWMPEG_PSTRUCT_BOTTOM_FIELD) /* Errors */ #define HWMPEG_ERROR_OK 0 #define HWMPEG_ERROR_UNSPECIFIED 1 /* HwMpeg* hardware controller data structure */ typedef struct _HwMpeg HwMpeg; /* HwMpeg* configuartion information. All info needed to perform a HW decode. */ /* TargetFrame is where resulting data would be stored. Ideally this */ /* would be abstracted somewhat to allow target to be an onscreen overlay */ /* Some more config info is needed here. */ typedef struct _HwMpegSurface { uint32_t data; } HwMpegSurface; typedef struct _HwMpegQMatrix { unsigned char intra_quantiser_matrix[64]; unsigned char non_intra_quantiser_matrix[64]; } HwMpegQMatrix; /* typedef struct _HwMpegInit { int drmFd; int performLocking; int regAddress; } HwMpegInit; */ typedef struct _HwMpegConfig { int flags; int width; int height; HwMpegSurface targetFrame; /* Target frame offset into screen memory */ HwMpegSurface pastFrame; /* Past frame offset into screen memory */ HwMpegSurface futureFrame; /* Future frame offset into screen memory */ int mpeg_coding; int picture_structure; int picture_coding_type; int intra_dc_precision; int FHMV_range; int FVMV_range; int BHMV_range; int BVMV_range; } HwMpegConfig; /* MpegInit: Initialises MPEG Decoder and returns pointer to allocated Mpeg data structure */ /* This would open the DRM driver and allocate some resources */ int hwMpegInit(HwMpeg** mpeg, int drmFd, int performLocking); /* HwMpegLoadQMatrix: Loads Q Matrix */ int hwMpegLoadQMatrix(HwMpeg* mpeg, HwMpegQMatrix* qmatrix); /* HwMpegFieldStart: Configures MPEG controller for next set of slices */ int hwMpegFieldStart(HwMpeg* mpeg, HwMpegConfig* config); /* HwMpegWriteSlice: Writes a slice, buffering in a FIFO as necessary and waiting for hardware */ int hwMpegWriteSlice(HwMpeg* mpeg, void* data, uint32_t nBytes, uint32_t sCode); /* HwMpegFieldEnd: End of slices for this field */ int hwMpegFieldEnd(HwMpeg* mpeg); /* HwMpegWaitComplete: Waits till MPEG controller has completed all outstanding work */ int hwMpegWaitComplete(HwMpeg* mpeg); /* Closes the MPEG decoder */ int hwMpegClose(HwMpeg* mpeg); #endif /*_HWMPEG_H_ */