1 /*
2     This file is provided under a dual BSD/GPLv2 license.  When using or
3     redistributing this file, you may do so under either license.
4 
5     GPL LICENSE SUMMARY
6 
7     Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
8 
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of version 2 of the GNU General Public License as
11     published by the Free Software Foundation.
12 
13     This program is distributed in the hope that it will be useful, but
14     WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16     General Public License for more details.
17 
18     You should have received a copy of the GNU General Public License
19     along with this program; if not, write to the Free Software
20     Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21     The full GNU General Public License is included in this distribution
22     in the file called LICENSE.GPL.
23 
24     Contact Information:
25 
26     BSD LICENSE
27 
28     Copyright(c) 2007-2009 Intel Corporation. All rights reserved.
29     All rights reserved.
30 
31     Redistribution and use in source and binary forms, with or without
32     modification, are permitted provided that the following conditions
33     are met:
34 
35     * Redistributions of source code must retain the above copyright
36     notice, this list of conditions and the following disclaimer.
37     * Redistributions in binary form must reproduce the above copyright
38     notice, this list of conditions and the following disclaimer in
39     the documentation and/or other materials provided with the
40     distribution.
41     * Neither the name of Intel Corporation nor the names of its
42     contributors may be used to endorse or promote products derived
43     from this software without specific prior written permission.
44 
45     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
46     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
47     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
48     A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
49     OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
50     SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
51     LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
52     DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
53     THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
54     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
55     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 
57 */
58 #ifndef VIDDEC_FW_COMMON_DEFS_H
59 #define VIDDEC_FW_COMMON_DEFS_H
60 
61 #define VIDDEC_FW_PARSER_IPC_HOST_INT    0x87654321
62 #define EMITTER_WORKLOAD_ENTRIES    2048
63 
64 /* This enum defines priority level for opening a stream */
65 enum viddec_stream_priority
66 {
67     viddec_stream_priority_BACKGROUND, /* Lowest priority stream */
68     viddec_stream_priority_REALTIME,   /* Real time highest priority stream */
69     viddec_stream_priority_INVALID,
70 };
71 
72 /* This enum defines supported flush types */
73 enum viddec_stream_flushtype
74 {
75     VIDDEC_STREAM_FLUSH_DISCARD, /* Reinitialise to start state */
76     VIDDEC_STREAM_FLUSH_PRESERVE, /* Reinitialise to start state  by preserving sequence info*/
77 };
78 
79 enum viddec_stream_inband_flags
80 {
81     VIDDEC_STREAM_DEFAULT_FLAG=0, /* Default value for flags */
82     VIDDEC_STREAM_EOS,          /* End of stream message */
83     VIDDEC_STREAM_DISCONTINUITY,  /* new segment which forces flush and preserve */
84 };
85 
86 /* Message descriptor for Parser's Input and output queues. needs to be 8 byte aligned */
87 typedef struct viddec_input_buffer
88 {
89     unsigned int             flags; /* Flags for Inband messages like EOS, valid range defined in viddec_stream_inband_flags */
90     unsigned int             phys;/* DDR addr of where ES/WKLD is at. */
91     unsigned int             len;/* size of buffer at phys_addr */
92     unsigned int             id;/* A id for the buffer which is not used or modified by the FW. */
93 #ifdef HOST_ONLY
94     unsigned char           *buf; /* virt pointer to buffer. This is a don't care for FW */
95 #endif
96 }ipc_msg_data;
97 
98 typedef ipc_msg_data viddec_input_buffer_t;
99 typedef ipc_msg_data viddec_ipc_msg_data;
100 
101 /* Return types for interface functions */
102 typedef enum
103 {
104     VIDDEC_FW_SUCCESS, /* succesful with current operation */
105     VIDDEC_FW_NORESOURCES, /* No resources to execute the requested functionality */
106     VIDDEC_FW_FAILURE,    /* Failed for Uknown reason */
107     VIDDEC_FW_INVALID_PARAM, /* The parameters that were passed are Invalid */
108     VIDDEC_FW_PORT_FULL,     /* The operation failed since queue is full */
109     VIDDEC_FW_PORT_EMPTY,   /* The operation failed since queue is empty */
110     VIDDEC_FW_NEED_FREE_WKLD, /* The operation failed since a free wkld is not available */
111 }viddec_fw_return_types_t;
112 
113 /* Defines for Interrupt mask and status */
114 typedef enum
115 {
116     VIDDEC_FW_WKLD_DATA_AVAIL=1, /* A processed workload is available */
117     VIDDEC_FW_INPUT_WATERMARK_REACHED=2,     /* The input path is below the set watermark for current stream */
118 }viddec_fw_parser_int_status_t;
119 
120 /* Defines for attributes on stream, If not set explicitly will be default values */
121 typedef enum
122 {
123     VIDDEC_FW_INPUT_Q_WATERMARK, /* Define for setting Input queue watermarks */
124     VIDDEC_FW_STREAM_PRIORITY,    /* Define for setting stream priority */
125 }viddec_fw_stream_attributes_t;
126 
127 typedef struct
128 {
129     unsigned int input_q_space; /* Num of messages that can be written to input queue */
130     unsigned int output_q_data; /* Num of messages in output queue */
131     unsigned int workload_q_status; /* Number of free wklds available to parser */
132 }viddec_fw_q_status_t;
133 
134 typedef struct
135 {
136     unsigned int to_fw_q_space;     /* Num of messages that can be written to input queue */
137     unsigned int from_fw_q_data;    /* Num of messages in output queue */
138 }viddec_fw_decoder_q_status_t;
139 
140 enum viddec_fw_decoder_int_status
141 {
142     VIDDEC_FW_DECODER_INT_STATUS_STREAM_0       = (1<< 0), /* Decoder Stream 0 Requires Service */
143     VIDDEC_FW_DECODER_INT_STATUS_STREAM_1       = (1<< 1), /* Decoder Stream 1 Requires Service */
144     VIDDEC_FW_DECODER_INT_STATUS_STREAM_2       = (1<< 2), /* Decoder Stream 2 Requires Service */
145 
146 
147     VIDDEC_FW_DECODER_INT_STATUS_STREAM_HIGH    = (1<<30), /* Any Decoder Stream >= 30 Requires Service */
148     VIDDEC_FW_DECODER_INT_STATUS_AUTO_API       = (1<<31)  /* An Auto-API Function has completed */
149 };
150 
151 /** Hardware Accelerated stream formats */
152 enum viddec_stream_format
153 {
154    MFD_STREAM_FORMAT_MPEG=1,
155    MFD_STREAM_FORMAT_H264,
156    MFD_STREAM_FORMAT_VC1,
157    MFD_STREAM_FORMAT_MPEG42,
158 
159    MFD_STREAM_FORMAT_MAX,   /* must be last  */
160    MFD_STREAM_FORMAT_INVALID
161 };
162 
163 /* Workload specific error codes */
164 enum viddec_fw_workload_error_codes
165 {
166     VIDDEC_FW_WORKLOAD_SUCCESS               = 0,
167     VIDDEC_FW_WORKLOAD_ERR_NOTDECODABLE      = (1 << 0),/* Parser/Decoder detected a non decodable error with this workload */
168     VIDDEC_FW_WORKLOAD_ERR_BUFFERS_OVERFLOW  = (1 << 1),/* Parser Detected more than 64 buffers between two start codes */
169     VIDDEC_FW_WORKLOAD_ERR_ITEMS_OVERFLOW    = (1 << 2),/* Parser Detected overflow of currently allocated workload memory */
170     VIDDEC_FW_WORKLOAD_ERR_FLUSHED_FRAME     = (1 << 3),/* This is impartial or empty frame which was flushed by Parser/Decoder */
171     VIDDEC_FW_WORKLOAD_ERR_MISSING_DMEM      = (1 << 4),/* This is impartial or empty frame from Parser/Decoder */
172     VIDDEC_FW_WORKLOAD_ERR_UNSUPPORTED       = (1 << 5),/* Parser Detected unsupported feature in the stream */
173     /* First 8 bits reserved for Non Decodable errors */
174     VIDDEC_FW_WORKLOAD_ERR_CONCEALED         = (1 << 9),/* The decoder concealed some errors in this frame */
175     VIDDEC_FW_WORKLOAD_ERR_MISSING_REFERENCE = (1 << 10),/* Deocder/parser detected at least one of the required reference frames is missing */
176     VIDDEC_FW_WORKLOAD_ERR_IN_REFERENCE      = (1 << 11),/* Deocder/parser detected at least one of the reference frames has errors in it */
177     VIDDEC_FW_WORKLOAD_ERR_DANGLING_FLD      = (1 << 12),/* Parser detected at least one of the fields are missing */
178     VIDDEC_FW_WORKLOAD_ERR_PARTIAL_SLICE     = (1 << 13),/* Deocder detected at least one of the fields are missing */
179     VIDDEC_FW_WORKLOAD_ERR_MACROBLOCK        = (1 << 14),/* Deocder detected macroblock errors */
180     VIDDEC_FW_WORKLOAD_ERR_MISSING_SEQ_INFO  = (1 << 16),/* Parser detected sequence information is missing */
181 
182     VIDDEC_FW_WORKLOAD_ERR_TOPFIELD          = (1 << 17),/* Decoder/Parser detected  errors in "top field" or "frame"*/
183     VIDDEC_FW_WORKLOAD_ERR_BOTTOMFIELD       = (1 << 18),/* Decoder/Parser detected  errors in "bottom field" or "frame" */
184     VIDDEC_FW_WORKLOAD_ERR_BITSTREAM_ERROR   = (1 << 19),/* Parser detected errors */
185 
186 };
187 
188 enum viddec_fw_mpeg2_error_codes
189 {
190     VIDDEC_FW_MPEG2_ERR_CORRUPTED_SEQ_HDR       = (1 << 24),/* Parser detected corruption in sequence header. Will use the previous good sequence info, if found. */
191     VIDDEC_FW_MPEG2_ERR_CORRUPTED_SEQ_EXT       = (1 << 25),/* Parser detected corruption in seqeunce extension. */
192     VIDDEC_FW_MPEG2_ERR_CORRUPTED_SEQ_DISP_EXT  = (1 << 26),/* Parser detected corruption in sequence display extension. */
193     VIDDEC_FW_MPEG2_ERR_CORRUPTED_GOP_HDR       = (1 << 27),/* Parser detected corruption in GOP header. */
194     VIDDEC_FW_MPEG2_ERR_CORRUPTED_PIC_HDR       = (1 << 26),/* Parser detected corruption in picture header. */
195     VIDDEC_FW_MPEG2_ERR_CORRUPTED_PIC_COD_EXT   = (1 << 27),/* Parser detected corruption in picture coding extension. */
196     VIDDEC_FW_MPEG2_ERR_CORRUPTED_PIC_DISP_EXT  = (1 << 28),/* Parser detected corruption in picture display extension. */
197     VIDDEC_FW_MPEG2_ERR_CORRUPTED_QMAT_EXT      = (1 << 29),/* Parser detected corruption in quantization matrix extension. */
198 };
199 
200 #endif
201