Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[pandora-kernel.git] / drivers / staging / crystalhd / bc_dts_defs.h
1 /********************************************************************
2  * Copyright(c) 2006-2009 Broadcom Corporation.
3  *
4  *  Name: bc_dts_defs.h
5  *
6  *  Description: Common definitions for all components. Only types
7  *               is allowed to be included from this file.
8  *
9  *  AU
10  *
11  *  HISTORY:
12  *
13  ********************************************************************
14  * This header is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU Lesser General Public License as published
16  * by the Free Software Foundation, either version 2.1 of the License.
17  *
18  * This header is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU Lesser General Public License for more details.
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this header.  If not, see <http://www.gnu.org/licenses/>.
24  *******************************************************************/
25
26 #ifndef _BC_DTS_DEFS_H_
27 #define _BC_DTS_DEFS_H_
28
29 #include "bc_dts_types.h"
30
31 /* BIT Mask */
32 #define BC_BIT(_x)              (1 << (_x))
33
34 typedef enum _BC_STATUS {
35         BC_STS_SUCCESS          = 0,
36         BC_STS_INV_ARG          = 1,
37         BC_STS_BUSY             = 2,
38         BC_STS_NOT_IMPL         = 3,
39         BC_STS_PGM_QUIT         = 4,
40         BC_STS_NO_ACCESS        = 5,
41         BC_STS_INSUFF_RES       = 6,
42         BC_STS_IO_ERROR         = 7,
43         BC_STS_NO_DATA          = 8,
44         BC_STS_VER_MISMATCH     = 9,
45         BC_STS_TIMEOUT          = 10,
46         BC_STS_FW_CMD_ERR       = 11,
47         BC_STS_DEC_NOT_OPEN     = 12,
48         BC_STS_ERR_USAGE        = 13,
49         BC_STS_IO_USER_ABORT    = 14,
50         BC_STS_IO_XFR_ERROR     = 15,
51         BC_STS_DEC_NOT_STARTED  = 16,
52         BC_STS_FWHEX_NOT_FOUND  = 17,
53         BC_STS_FMT_CHANGE       = 18,
54         BC_STS_HIF_ACCESS       = 19,
55         BC_STS_CMD_CANCELLED    = 20,
56         BC_STS_FW_AUTH_FAILED   = 21,
57         BC_STS_BOOTLOADER_FAILED = 22,
58         BC_STS_CERT_VERIFY_ERROR = 23,
59         BC_STS_DEC_EXIST_OPEN   = 24,
60         BC_STS_PENDING          = 25,
61         BC_STS_CLK_NOCHG        = 26,
62
63         /* Must be the last one.*/
64         BC_STS_ERROR            = -1
65 } BC_STATUS;
66
67 /*------------------------------------------------------*
68  *    Registry Key Definitions                          *
69  *------------------------------------------------------*/
70 #define BC_REG_KEY_MAIN_PATH    "Software\\Broadcom\\MediaPC\\70010"
71 #define BC_REG_KEY_FWPATH               "FirmwareFilePath"
72 #define BC_REG_KEY_SEC_OPT              "DbgOptions"
73
74 /*
75  * Options:
76  *
77  *  b[5] = Enable RSA KEY in EEPROM Support
78  *  b[6] = Enable Old PIB scheme. (0 = Use PIB with video scheme)
79  *
80  *  b[12] = Enable send message to NotifyIcon
81  *
82  */
83
84 typedef enum _BC_SW_OPTIONS {
85         BC_OPT_DOSER_OUT_ENCRYPT        = BC_BIT(3),
86         BC_OPT_LINK_OUT_ENCRYPT         = BC_BIT(29),
87 } BC_SW_OPTIONS;
88
89 typedef struct _BC_REG_CONFIG{
90         uint32_t                DbgOptions;
91 } BC_REG_CONFIG;
92
93 #if defined(__KERNEL__) || defined(__LINUX_USER__)
94 #else
95 /* Align data structures */
96 #define ALIGN(x)        __declspec(align(x))
97 #endif
98
99 /* mode
100  * b[0]..b[7]   = _DtsDeviceOpenMode
101  * b[8]         =  Load new FW
102  * b[9]         =  Load file play back FW
103  * b[10]        =  Disk format (0 for HD DVD and 1 for BLU ray)
104  * b[11]-b[15]  =  default output resolution
105  * b[16]        =  Skip TX CPB Buffer Check
106  * b[17]        =  Adaptive Output Encrypt/Scramble Scheme
107  * b[18]-b[31]  =  reserved for future use
108  */
109
110 /* To allow multiple apps to open the device. */
111 enum _DtsDeviceOpenMode {
112         DTS_PLAYBACK_MODE = 0,
113         DTS_DIAG_MODE,
114         DTS_MONITOR_MODE,
115         DTS_HWINIT_MODE
116 };
117
118 /* To enable the filter to selectively enable/disable fixes or erratas */
119 enum _DtsDeviceFixMode {
120         DTS_LOAD_NEW_FW         = BC_BIT(8),
121         DTS_LOAD_FILE_PLAY_FW   = BC_BIT(9),
122         DTS_DISK_FMT_BD         = BC_BIT(10),
123         /* b[11]-b[15] : Default output resolution */
124         DTS_SKIP_TX_CHK_CPB     = BC_BIT(16),
125         DTS_ADAPTIVE_OUTPUT_PER = BC_BIT(17),
126         DTS_INTELLIMAP          = BC_BIT(18),
127         /* b[19]-b[21] : select clock frequency */
128         DTS_PLAYBACK_DROP_RPT_MODE = BC_BIT(22)
129 };
130
131 #define DTS_DFLT_RESOLUTION(x)  (x<<11)
132
133 #define DTS_DFLT_CLOCK(x) (x<<19)
134
135 /* F/W File Version corresponding to S/W Releases */
136 enum _FW_FILE_VER {
137         /* S/W release: 02.04.02        F/W release 2.12.2.0 */
138         BC_FW_VER_020402 = ((12<<16) | (2<<8) | (0))
139 };
140
141 /*------------------------------------------------------*
142  *    Stream Types for DtsOpenDecoder()                 *
143  *------------------------------------------------------*/
144 enum _DtsOpenDecStreamTypes {
145         BC_STREAM_TYPE_ES               = 0,
146         BC_STREAM_TYPE_PES              = 1,
147         BC_STREAM_TYPE_TS               = 2,
148         BC_STREAM_TYPE_ES_TSTAMP        = 6,
149 };
150
151 /*------------------------------------------------------*
152  *    Video Algorithms for DtsSetVideoParams()          *
153  *------------------------------------------------------*/
154 enum _DtsSetVideoParamsAlgo {
155         BC_VID_ALGO_H264                = 0,
156         BC_VID_ALGO_MPEG2               = 1,
157         BC_VID_ALGO_VC1                 = 4,
158         BC_VID_ALGO_VC1MP               = 7,
159 };
160
161 /*------------------------------------------------------*
162  *    MPEG Extension to the PPB                         *
163  *------------------------------------------------------*/
164 #define BC_MPEG_VALID_PANSCAN           (1)
165
166 typedef struct _BC_PIB_EXT_MPEG {
167         uint32_t        valid;
168         /* Always valid,  defaults to picture size if no
169          * sequence display extension in the stream. */
170         uint32_t        display_horizontal_size;
171         uint32_t        display_vertical_size;
172
173         /* MPEG_VALID_PANSCAN
174          * Offsets are a copy values from the MPEG stream. */
175         uint32_t        offset_count;
176         int32_t         horizontal_offset[3];
177         int32_t         vertical_offset[3];
178
179 } BC_PIB_EXT_MPEG;
180
181 /*------------------------------------------------------*
182  *    H.264 Extension to the PPB                        *
183  *------------------------------------------------------*/
184 /* Bit definitions for 'other.h264.valid' field */
185 #define H264_VALID_PANSCAN              (1)
186 #define H264_VALID_SPS_CROP             (2)
187 #define H264_VALID_VUI                  (4)
188
189 typedef struct _BC_PIB_EXT_H264 {
190         /* 'valid' specifies which fields (or sets of
191          * fields) below are valid.  If the corresponding
192          * bit in 'valid' is NOT set then that field(s)
193          * is (are) not initialized. */
194         uint32_t        valid;
195
196         /* H264_VALID_PANSCAN */
197         uint32_t        pan_scan_count;
198         int32_t         pan_scan_left[3];
199         int32_t         pan_scan_right[3];
200         int32_t         pan_scan_top[3];
201         int32_t         pan_scan_bottom[3];
202
203         /* H264_VALID_SPS_CROP */
204         int32_t         sps_crop_left;
205         int32_t         sps_crop_right;
206         int32_t         sps_crop_top;
207         int32_t         sps_crop_bottom;
208
209         /* H264_VALID_VUI */
210         uint32_t        chroma_top;
211         uint32_t        chroma_bottom;
212
213 } BC_PIB_EXT_H264;
214
215 /*------------------------------------------------------*
216  *    VC1 Extension to the PPB                          *
217  *------------------------------------------------------*/
218 #define VC1_VALID_PANSCAN               (1)
219
220 typedef struct _BC_PIB_EXT_VC1 {
221         uint32_t        valid;
222
223         /* Always valid, defaults to picture size if no
224          * sequence display extension in the stream. */
225         uint32_t        display_horizontal_size;
226         uint32_t        display_vertical_size;
227
228         /* VC1 pan scan windows */
229         uint32_t        num_panscan_windows;
230         int32_t         ps_horiz_offset[4];
231         int32_t         ps_vert_offset[4];
232         int32_t         ps_width[4];
233         int32_t         ps_height[4];
234
235 } BC_PIB_EXT_VC1;
236
237
238 /*------------------------------------------------------*
239  *    Picture Information Block                         *
240  *------------------------------------------------------*/
241 #if defined(_WIN32) || defined(_WIN64) || defined(__LINUX_USER__)
242 /* Values for 'pulldown' field.  '0' means no pulldown information
243  * was present for this picture. */
244 enum {
245         vdecNoPulldownInfo      = 0,
246         vdecTop                 = 1,
247         vdecBottom              = 2,
248         vdecTopBottom           = 3,
249         vdecBottomTop           = 4,
250         vdecTopBottomTop        = 5,
251         vdecBottomTopBottom     = 6,
252         vdecFrame_X2            = 7,
253         vdecFrame_X3            = 8,
254         vdecFrame_X1            = 9,
255         vdecFrame_X4            = 10,
256 };
257
258 /* Values for the 'frame_rate' field. */
259 enum {
260         vdecFrameRateUnknown = 0,
261         vdecFrameRate23_97,
262         vdecFrameRate24,
263         vdecFrameRate25,
264         vdecFrameRate29_97,
265         vdecFrameRate30,
266         vdecFrameRate50,
267         vdecFrameRate59_94,
268         vdecFrameRate60,
269 };
270
271 /* Values for the 'aspect_ratio' field. */
272 enum {
273         vdecAspectRatioUnknown = 0,
274         vdecAspectRatioSquare,
275         vdecAspectRatio12_11,
276         vdecAspectRatio10_11,
277         vdecAspectRatio16_11,
278         vdecAspectRatio40_33,
279         vdecAspectRatio24_11,
280         vdecAspectRatio20_11,
281         vdecAspectRatio32_11,
282         vdecAspectRatio80_33,
283         vdecAspectRatio18_11,
284         vdecAspectRatio15_11,
285         vdecAspectRatio64_33,
286         vdecAspectRatio160_99,
287         vdecAspectRatio4_3,
288         vdecAspectRatio16_9,
289         vdecAspectRatio221_1,
290         vdecAspectRatioOther = 255,
291 };
292
293 /* Values for the 'colour_primaries' field. */
294 enum {
295         vdecColourPrimariesUnknown = 0,
296         vdecColourPrimariesBT709,
297         vdecColourPrimariesUnspecified,
298         vdecColourPrimariesReserved,
299         vdecColourPrimariesBT470_2M = 4,
300         vdecColourPrimariesBT470_2BG,
301         vdecColourPrimariesSMPTE170M,
302         vdecColourPrimariesSMPTE240M,
303         vdecColourPrimariesGenericFilm,
304 };
305
306 enum {
307         vdecRESOLUTION_CUSTOM   = 0x00000000, /* custom */
308         vdecRESOLUTION_480i     = 0x00000001, /* 480i */
309         vdecRESOLUTION_1080i    = 0x00000002, /* 1080i (1920x1080, 60i) */
310         vdecRESOLUTION_NTSC     = 0x00000003, /* NTSC (720x483, 60i) */
311         vdecRESOLUTION_480p     = 0x00000004, /* 480p (720x480, 60p) */
312         vdecRESOLUTION_720p     = 0x00000005, /* 720p (1280x720, 60p) */
313         vdecRESOLUTION_PAL1     = 0x00000006, /* PAL_1 (720x576, 50i) */
314         vdecRESOLUTION_1080i25  = 0x00000007, /* 1080i25 (1920x1080, 50i) */
315         vdecRESOLUTION_720p50   = 0x00000008, /* 720p50 (1280x720, 50p) */
316         vdecRESOLUTION_576p     = 0x00000009, /* 576p (720x576, 50p) */
317         vdecRESOLUTION_1080i29_97 = 0x0000000A, /* 1080i (1920x1080, 59.94i) */
318         vdecRESOLUTION_720p59_94  = 0x0000000B, /* 720p (1280x720, 59.94p) */
319         vdecRESOLUTION_SD_DVD   = 0x0000000C, /* SD DVD (720x483, 60i) */
320         vdecRESOLUTION_480p656  = 0x0000000D, /* 480p (720x480, 60p), output bus width 8 bit, clock 74.25MHz */
321         vdecRESOLUTION_1080p23_976 = 0x0000000E, /* 1080p23_976 (1920x1080, 23.976p) */
322         vdecRESOLUTION_720p23_976  = 0x0000000F, /* 720p23_976 (1280x720p, 23.976p) */
323         vdecRESOLUTION_240p29_97   = 0x00000010, /* 240p (1440x240, 29.97p ) */
324         vdecRESOLUTION_240p30   = 0x00000011, /* 240p (1440x240, 30p) */
325         vdecRESOLUTION_288p25   = 0x00000012, /* 288p (1440x288p, 25p) */
326         vdecRESOLUTION_1080p29_97 = 0x00000013, /* 1080p29_97 (1920x1080, 29.97p) */
327         vdecRESOLUTION_1080p30  = 0x00000014, /* 1080p30 (1920x1080, 30p) */
328         vdecRESOLUTION_1080p24  = 0x00000015, /* 1080p24 (1920x1080, 24p) */
329         vdecRESOLUTION_1080p25  = 0x00000016, /* 1080p25 (1920x1080, 25p) */
330         vdecRESOLUTION_720p24   = 0x00000017, /* 720p24 (1280x720, 25p) */
331         vdecRESOLUTION_720p29_97  = 0x00000018, /* 720p29.97 (1280x720, 29.97p) */
332         vdecRESOLUTION_480p23_976 = 0x00000019, /* 480p23.976 (720*480, 23.976) */
333         vdecRESOLUTION_480p29_97  = 0x0000001A, /* 480p29.976 (720*480, 29.97p) */
334         vdecRESOLUTION_576p25   = 0x0000001B, /* 576p25 (720*576, 25p) */
335         /* For Zero Frame Rate */
336         vdecRESOLUTION_480p0    = 0x0000001C, /* 480p (720x480, 0p) */
337         vdecRESOLUTION_480i0    = 0x0000001D, /* 480i (720x480, 0i) */
338         vdecRESOLUTION_576p0    = 0x0000001E, /* 576p (720x576, 0p) */
339         vdecRESOLUTION_720p0    = 0x0000001F, /* 720p (1280x720, 0p) */
340         vdecRESOLUTION_1080p0   = 0x00000020, /* 1080p (1920x1080, 0p) */
341         vdecRESOLUTION_1080i0   = 0x00000021, /* 1080i (1920x1080, 0i) */
342 };
343
344 /* Bit definitions for 'flags' field */
345 #define VDEC_FLAG_EOS                           (0x0004)
346
347 #define VDEC_FLAG_FRAME                         (0x0000)
348 #define VDEC_FLAG_FIELDPAIR                     (0x0008)
349 #define VDEC_FLAG_TOPFIELD                      (0x0010)
350 #define VDEC_FLAG_BOTTOMFIELD                   (0x0018)
351
352 #define VDEC_FLAG_PROGRESSIVE_SRC               (0x0000)
353 #define VDEC_FLAG_INTERLACED_SRC                (0x0020)
354 #define VDEC_FLAG_UNKNOWN_SRC                   (0x0040)
355
356 #define VDEC_FLAG_BOTTOM_FIRST                  (0x0080)
357 #define VDEC_FLAG_LAST_PICTURE                  (0x0100)
358
359 #define VDEC_FLAG_PICTURE_META_DATA_PRESENT     (0x40000)
360
361 #endif /* _WIN32 || _WIN64 */
362
363 enum _BC_OUTPUT_FORMAT {
364         MODE420                         = 0x0,
365         MODE422_YUY2                    = 0x1,
366         MODE422_UYVY                    = 0x2,
367 };
368
369 typedef struct _BC_PIC_INFO_BLOCK {
370         /* Common fields. */
371         uint64_t        timeStamp;      /* Timestamp */
372         uint32_t        picture_number; /* Ordinal display number  */
373         uint32_t        width;          /* pixels           */
374         uint32_t        height;         /* pixels           */
375         uint32_t        chroma_format;  /* 0x420, 0x422 or 0x444 */
376         uint32_t        pulldown;
377         uint32_t        flags;
378         uint32_t        frame_rate;
379         uint32_t        aspect_ratio;
380         uint32_t        colour_primaries;
381         uint32_t        picture_meta_payload;
382         uint32_t        sess_num;
383         uint32_t        ycom;
384         uint32_t        custom_aspect_ratio_width_height;
385         uint32_t        n_drop; /* number of non-reference frames remaining to be dropped */
386
387         /* Protocol-specific extensions. */
388         union {
389                 BC_PIB_EXT_H264 h264;
390                 BC_PIB_EXT_MPEG mpeg;
391                 BC_PIB_EXT_VC1   vc1;
392         } other;
393
394 } BC_PIC_INFO_BLOCK, *PBC_PIC_INFO_BLOCK;
395
396 /*------------------------------------------------------*
397  *    ProcOut Info                                      *
398  *------------------------------------------------------*/
399 /* Optional flags for ProcOut Interface.*/
400 enum _POUT_OPTIONAL_IN_FLAGS_{
401         /* Flags from App to Device */
402         BC_POUT_FLAGS_YV12        = 0x01,       /* Copy Data in YV12 format */
403         BC_POUT_FLAGS_STRIDE      = 0x02,       /* Stride size is valid. */
404         BC_POUT_FLAGS_SIZE        = 0x04,       /* Take size information from Application */
405         BC_POUT_FLAGS_INTERLACED  = 0x08,       /* copy only half the bytes */
406         BC_POUT_FLAGS_INTERLEAVED = 0x10,       /* interleaved frame */
407
408         /* Flags from Device to APP */
409         BC_POUT_FLAGS_FMT_CHANGE  = 0x10000,    /* Data is not VALID when this flag is set */
410         BC_POUT_FLAGS_PIB_VALID   = 0x20000,    /* PIB Information valid */
411         BC_POUT_FLAGS_ENCRYPTED   = 0x40000,    /* Data is encrypted. */
412         BC_POUT_FLAGS_FLD_BOT     = 0x80000,    /* Bottom Field data */
413 };
414
415 #if defined(__KERNEL__) || defined(__LINUX_USER__)
416 typedef BC_STATUS(*dts_pout_callback)(void  *shnd, uint32_t width, uint32_t height, uint32_t stride, void *pOut);
417 #else
418 typedef BC_STATUS(*dts_pout_callback)(void  *shnd, uint32_t width, uint32_t height, uint32_t stride, struct _BC_DTS_PROC_OUT *pOut);
419 #endif
420
421 /* Line 21 Closed Caption */
422 /* User Data */
423 #define MAX_UD_SIZE             1792    /* 1920 - 128 */
424
425 typedef struct _BC_DTS_PROC_OUT {
426         uint8_t         *Ybuff;                 /* Caller Supplied buffer for Y data */
427         uint32_t        YbuffSz;                /* Caller Supplied Y buffer size */
428         uint32_t        YBuffDoneSz;            /* Transferred Y datasize */
429
430         uint8_t         *UVbuff;                /* Caller Supplied buffer for UV data */
431         uint32_t        UVbuffSz;               /* Caller Supplied UV buffer size */
432         uint32_t        UVBuffDoneSz;           /* Transferred UV data size */
433
434         uint32_t        StrideSz;               /* Caller supplied Stride Size */
435         uint32_t        PoutFlags;              /* Call IN Flags */
436
437         uint32_t        discCnt;                /* Picture discontinuity count */
438
439         BC_PIC_INFO_BLOCK PicInfo;              /* Picture Information Block Data */
440
441         /* Line 21 Closed Caption */
442         /* User Data */
443         uint32_t        UserDataSz;
444         uint8_t         UserData[MAX_UD_SIZE];
445
446         void            *hnd;
447         dts_pout_callback AppCallBack;
448         uint8_t         DropFrames;
449         uint8_t         b422Mode;               /* Picture output Mode */
450         uint8_t         bPibEnc;                /* PIB encrypted */
451         uint8_t         bRevertScramble;
452
453 } BC_DTS_PROC_OUT;
454
455 typedef struct _BC_DTS_STATUS {
456         uint8_t         ReadyListCount; /* Number of frames in ready list (reported by driver) */
457         uint8_t         FreeListCount;  /* Number of frame buffers free.  (reported by driver) */
458         uint8_t         PowerStateChange; /* Number of active state power transitions (reported by driver) */
459         uint8_t         reserved_[1];
460
461         uint32_t        FramesDropped;  /* Number of frames dropped.  (reported by DIL) */
462         uint32_t        FramesCaptured; /* Number of frames captured. (reported by DIL) */
463         uint32_t        FramesRepeated; /* Number of frames repeated. (reported by DIL) */
464
465         uint32_t        InputCount;     /* Times compressed video has been sent to the HW.
466                                          * i.e. Successful DtsProcInput() calls (reported by DIL) */
467         uint64_t        InputTotalSize; /* Amount of compressed video that has been sent to the HW.
468                                          * (reported by DIL) */
469         uint32_t        InputBusyCount; /* Times compressed video has attempted to be sent to the HW
470                                          * but the input FIFO was full. (reported by DIL) */
471
472         uint32_t        PIBMissCount;   /* Amount of times a PIB is invalid. (reported by DIL) */
473
474         uint32_t        cpbEmptySize;   /* supported only for H.264, specifically changed for
475                                          * Adobe. Report size of CPB buffer available.
476                                          * Reported by DIL */
477         uint64_t        NextTimeStamp;  /* TimeStamp of the next picture that will be returned
478                                          * by a call to ProcOutput. Added for Adobe. Reported
479                                          * back from the driver */
480         uint8_t         reserved__[16];
481
482 } BC_DTS_STATUS;
483
484 #define BC_SWAP32(_v)                   \
485         ((((_v) & 0xFF000000)>>24)|     \
486           (((_v) & 0x00FF0000)>>8)|     \
487           (((_v) & 0x0000FF00)<<8)|     \
488           (((_v) & 0x000000FF)<<24))
489
490 #define WM_AGENT_TRAYICON_DECODER_OPEN  10001
491 #define WM_AGENT_TRAYICON_DECODER_CLOSE 10002
492 #define WM_AGENT_TRAYICON_DECODER_START 10003
493 #define WM_AGENT_TRAYICON_DECODER_STOP  10004
494 #define WM_AGENT_TRAYICON_DECODER_RUN   10005
495 #define WM_AGENT_TRAYICON_DECODER_PAUSE 10006
496
497
498 #endif  /* _BC_DTS_DEFS_H_ */