source: svn/newcon3bcm2_21bu/magnum/portinginterface/xvd/7552/bxvd_devcmds_priv.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 54.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2004-2012, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bxvd_devcmds_priv.c $
11 * $brcm_Revision: Hydra_Software_Devel/168 $
12 * $brcm_Date: 3/14/12 3:22p $
13 *
14 * Module Description:
15 *   See Module Overview below
16 *
17 * Revision History:
18 *
19 * $brcm_Log: /magnum/portinginterface/xvd/7401/bxvd_devcmds_priv.c $
20 *
21 * Hydra_Software_Devel/168   3/14/12 3:22p davidp
22 * SW7435-8: Add more detailed error handling output.
23 *
24 * Hydra_Software_Devel/167   1/20/12 3:48p davidp
25 * SW7208-175: Add support for 1920 portrait decode.
26 *
27 * Hydra_Software_Devel/166   6/27/11 4:13p davidp
28 * SW7425-542: Merge devel branch to mainline.
29 *
30 * Hydra_Software_Devel/SW7425-542/4   6/14/11 10:14a btosi
31 * SW7425-542: cleaned up warning
32 *
33 * Hydra_Software_Devel/SW7425-542/3   6/9/11 1:19p btosi
34 * SW7425-542: added in support for the Host Memory Interface
35 *
36 * Hydra_Software_Devel/SW7425-542/2   6/7/11 5:46p davidp
37 * SW7425-542: Use macros to access display info.
38 *
39 * Hydra_Software_Devel/SW7425-542/1   5/31/11 3:16p davidp
40 * SW7425-542: Add support for Host Interface Memory (ARC Scratch memory)
41 * FW API changes.
42 *
43 * Hydra_Software_Devel/165   4/4/11 4:37p davidp
44 * SW7425-284: Add XPT Rave register info to AVD FW init command.
45 *
46 * Hydra_Software_Devel/164   10/15/10 6:37p davidp
47 * SW7425-16: Add support for base layer ARC, additional FW api memory
48 * arguments.
49 *
50 * Hydra_Software_Devel/163   8/3/10 9:06a pblanco
51 * SW7400-2857: Reduced BXVD_Open memory footprint by 512 bytes by moving
52 * FW command and reply buffers to the XVD handle structure.
53 *
54 * Hydra_Software_Devel/162   7/30/10 2:10p pblanco
55 * SW7400-2857: Backed out memory reduction changes.
56 *
57 * Hydra_Software_Devel/160   4/23/10 8:22a davidp
58 * SW7125-365: Create BXVD_FW_CMD and BXVD_FW_RSP union type to fix new
59 * compiler strict alias rules.
60 *
61 * Hydra_Software_Devel/159   2/17/10 2:51p davidp
62 * SW7468-74: Add chip_prod_revision field to FW init command.
63 *
64 * Hydra_Software_Devel/158   1/19/10 4:45p davidp
65 * SW7405-3667: Clear decoder context bIfBusy flag on FW command timeout
66 * and when resetting the decoder.
67 *
68 * Hydra_Software_Devel/157   1/6/10 2:28p btosi
69 * SW7405-3137: merged branch into mainline
70 *
71 * Hydra_Software_Devel/156   12/11/09 1:03p davidp
72 * SW7405-3572: Change ChannelClose command argument to use ChannelHandle
73 * instead of ChannelId.
74 *
75 * Hydra_Software_Devel/155   11/30/09 4:38p btosi
76 * SW7405-3245: added BXVD_DBG_* macros.  Map to either BDBG_INSTANCE_* or
77 * BDBG_*
78 * at compile.
79 *
80 * Hydra_Software_Devel/154   8/19/09 5:04p davidp
81 * PR56375: Remove BXVD_P_HostCmdSendDecChannelOpenResponseHandler_isr,
82 * this routine is nolonger needed.
83 *
84 * Hydra_Software_Devel/153   8/7/09 7:32p davidp
85 * PR56375: Disable FW MBX polling by default.
86 *
87 * Hydra_Software_Devel/152   8/7/09 4:49p davidp
88 * PR56375: Add poll FW MBX support for chip bringups.
89 *
90 * Hydra_Software_Devel/151   6/25/09 6:05p davidp
91 * PR56375: Remove unneeded callback for AVD FW command processing. This
92 * fixes the polled debug method of cmd acknowledgement.
93 *
94 * Hydra_Software_Devel/150   3/31/09 2:59p davidp
95 * PR53685: Debug command string needed to be byte swapped on BE systems.
96 *
97 * Hydra_Software_Devel/149   1/27/09 1:52p rayshap
98 * PR51271: Add debug print
99 *
100 * Hydra_Software_Devel/148   1/21/09 2:01p nilesh
101 * PR45052: Converted BDBG_xxx to BDBG_INSTANCE_xxx calls to support
102 * multiple channels
103 *
104 * Hydra_Software_Devel/147   10/17/08 5:33p davidp
105 * PR45799: Add Host L2 interrupt set register address to AVD FW init
106 * command.
107 *
108 * Hydra_Software_Devel/146   8/5/08 2:23p davidp
109 * PR45080: Add support for AVD status block, block address now returned
110 * in FW channel open command.
111 *
112 * Hydra_Software_Devel/145   8/1/08 4:58p davidp
113 * PR43272: Merge PR43272 branch to mainline, new FW memory configuration
114 * API.
115 *
116 * Hydra_Software_Devel/PR43272/1   7/17/08 12:37p davidp
117 * PR43272: Add support for additional FW memory configuration parameters,
118 * Direct mode and IL Work list memory.
119 *
120 * Hydra_Software_Devel/144   6/10/08 4:29p davidp
121 * PR38955: Add bvnf_intr_context_base to init command.
122 *
123 * Hydra_Software_Devel/143   5/8/08 4:35p davidp
124 * PR40234: Added timeout parameter to BXVD_P_SendDecoderCommand, FW debug
125 * log command requires longer timeout.
126 *
127 * Hydra_Software_Devel/142   4/25/08 6:20p davidp
128 * PR40234: Use BKNI_Memcpy instead of strncpy.
129 *
130 * Hydra_Software_Devel/141   4/21/08 10:47a nilesh
131 * PR41952: Fixed compiler warning when DEBUG=n
132 *
133 * Hydra_Software_Devel/140   4/18/08 3:19p davidp
134 * PR40234: Use symbolic constants, code cleanup.
135 *
136 * Hydra_Software_Devel/139   4/14/08 5:24p davidp
137 * PR40234: Move dbg log memory parameters from FW init cmd to FW dbg log
138 * control cmd.
139 *
140 * Hydra_Software_Devel/138   4/11/08 4:53p davidp
141 * PR40234: Merge decoder debug logging from branch to
142 * Hydra_Software_Devel/.
143 *
144 * Hydra_Software_Devel/PR40234/1   4/10/08 3:37p davidp
145 * PR40234: Add support for decoder debug logging.
146 *
147 * Hydra_Software_Devel/137   4/1/08 2:43p davidp
148 * PR27168: Remove FW get version command.
149 *
150 * Hydra_Software_Devel/136   2/26/08 4:42p davidp
151 * PR39937: Remove unused BXVD_P_HostCmdDecChannelSpeed routine.
152 *
153 * Hydra_Software_Devel/135   2/13/08 4:59p nilesh
154 * PR38570: Added cabac worklist address and size to BDBG messages in
155 * ChannelOpen()
156 *
157 * Hydra_Software_Devel/134   1/29/08 5:54p davidp
158 * PR39098: Remove enable uart macro, functionality moved to BSP code.
159 *
160 * Hydra_Software_Devel/133   1/24/08 11:39a nilesh
161 * PR38570: Merge CABAC worklist API changes to mainline
162 *
163 * Hydra_Software_Devel/PR38570/1   1/21/08 5:11p nilesh
164 * PR38570: Added support for cabac worklist buffer and size parameter to
165 * AVD ChannelOpen
166 *
167 * Hydra_Software_Devel/132   12/20/07 11:58a nilesh
168 * PR36790: Fixed problem with XVD not sending channel number in
169 * ChannelSpeed command.  Cleaned up BDBG messages.
170 *
171 * Hydra_Software_Devel/131   9/12/07 11:50a nilesh
172 * PR29915: Fixed error reporting when CPU2Host mailbox register is null
173 * after a command response is received from the decoder
174 *
175 * Hydra_Software_Devel/130   9/6/07 5:35p nilesh
176 * PR29915: Added BERR_TRACE wrapper around all return codes
177 *
178 * Hydra_Software_Devel/129   8/21/07 3:04p davidp
179 * PR34052: Remove nolonger used register addr pointers from BXVD_Handle,
180 * use platform_info.stReg structure to reference registers
181 *
182 * Hydra_Software_Devel/128   8/13/07 4:07p nilesh
183 * PR29915: Multi-decode merge to mainline
184 *
185 * Hydra_Software_Devel/xvd_PR29915_Rel_Mosaic_FW_API/11   7/10/07 6:18p nilesh
186 * PR29915: Added 7405 support to mosaic branch
187 *
188 * Hydra_Software_Devel/xvd_PR29915_Rel_Mosaic_FW_API/10   7/10/07 10:41a nilesh
189 * PR29915: Merged from mainline 07/10/2007
190 *
191 * Hydra_Software_Devel/127   6/28/07 3:24p nilesh
192 * PR32611: Fixed heaps used for offset->virtual address conversion for
193 * data structures returned by firmware
194 *
195 * Hydra_Software_Devel/xvd_PR29915_Rel_Mosaic_FW_API/9   6/28/07 1:36p davidp
196 * PR29915: Move remaining data structure definitions for
197 * bxvd_devcmds_priv.h to bxvd_vdec_api.h
198 *
199 * Hydra_Software_Devel/xvd_PR29915_Rel_Mosaic_FW_API/8   6/27/07 4:57p davidp
200 * PR29915: Removed unused data types and data structures per code review.
201 *
202 * Hydra_Software_Devel/xvd_PR29915_Rel_Mosaic_FW_API/7   6/19/07 12:12p nilesh
203 * PR29915: Merge from mainline.
204 *
205 * Hydra_Software_Devel/126   5/15/07 1:20p pblanco
206 * PR28215: Added support for variable stripe width and multiple.
207 *
208 * Hydra_Software_Devel/125   5/14/07 11:30a nilesh
209 * PR30249: Merged UOD 2.x changes to mainline
210 *
211 * Hydra_Software_Devel/PR30249/1   5/10/07 2:09p nilesh
212 * PR30249: Added support for new stripe_multiple parameter in AVD Init
213 *
214 * Hydra_Software_Devel/124   4/24/07 1:39p nilesh
215 * PR22766: Added support for new FW API to provide FGT buffer address and
216 * size
217 *
218 * Hydra_Software_Devel/123   4/10/07 2:34p davidp
219 * PR29622: Change buffer widht and height being passed to FW, also
220 * allocate less picture buffer memory.
221 *
222 * Hydra_Software_Devel/122   3/27/07 10:32a pblanco
223 * PR27168: Changed hardcoded constants to defined constants.
224 *
225 * Hydra_Software_Devel/121   3/15/07 10:25a pblanco
226 * PR27168: Removed deprecated FW command event and associated code.
227 *
228 * Hydra_Software_Devel/120   3/1/07 3:27p gaurava
229 * PR 28215: Removed the old UART frequency/baud params and added stripe
230 * width.
231 *
232 * Hydra_Software_Devel/119   12/12/06 2:55p davidp
233 * PR25443: Merge Simplified FW API branch into mainline
234 *
235 * Hydra_Software_Devel/118   12/11/06 2:51p nilesh
236 * PR26414: Merge branch PR26414 to mainline
237 *
238 * Hydra_Software_Devel/PR26414/2   12/11/06 10:53a nilesh
239 * PR26414: Added AVD response callback error handling during a watchdog
240 * reset
241 *
242 * Hydra_Software_Devel/PR26414/1   12/8/06 12:20p nilesh
243 * PR26414: Fixed race condition when SeqHdr interrupt occurred before XVD
244 * copied necessary data from the AVD ChannelOpen response for use by the
245 * SeqHdr interrupt handler.
246 *
247 * Hydra_Software_Devel/117   11/21/06 5:29p gaurava
248 * PR 25724: Removed CPB related information from ChannelStatus since they
249 * are not available in 7401 and were there only in 7411 chip. 7401 uses
250 * RAVE instead that has CDB/ITB.
251 *
252 * Hydra_Software_Devel/116   9/28/06 2:14p pblanco
253 * PR21690: Added debug message to still picture decode host command.
254 *
255 * Hydra_Software_Devel/115   9/22/06 2:22p davidp
256 * PR22867: Update FW memory usage table, add secure memory heap support.
257 *
258 * Hydra_Software_Devel/114   9/19/06 7:23a pblanco
259 * PR21690: Removed obsolete pool info messages from init command.
260 *
261 * Hydra_Software_Devel/113   9/12/06 3:39p davidp
262 * PR24121: Enter critical section after XVD command done event is
263 * signaled and before we test the ifBusy flag in SendDecodeCommand().
264 *
265 * Hydra_Software_Devel/112   9/11/06 6:37p davidp
266 * PR24121: Add critical section lock around checking/setting device busy
267 * flag in BXVD_P_SendDecoderCommand_isr().
268 *
269 * Hydra_Software_Devel/111   9/8/06 10:36a nilesh
270 * PR23113: Cleaned up code. Added buffer debug info in CMD_INIT
271 *
272 * Hydra_Software_Devel/110   9/5/06 3:04p davidp
273 * PR22867: Merge secure heap (Cabac) support
274 *
275 * Hydra_Software_Devel/xvd_cabac_heap/1   8/30/06 5:10p davidp
276 * 22867: Separate FW memory so Cabac bin memory can me moved to secure
277 * heap.
278 *
279 * Hydra_Software_Devel/109   8/29/06 8:27a pblanco
280 * PR22673: Temporarily disabled mailbox interrupts for 7118... poll
281 * instead.
282 *
283 * Hydra_Software_Devel/108   8/9/06 3:06p davidp
284 * PR20394: PCR TimeBase decoder setting now assigned a default value in
285 * BXVD_OpenChannel.
286 *
287 * Hydra_Software_Devel/107   8/2/06 5:23p davidp
288 * PR22071: Replace usleep with BKNI_Sleep.
289 *
290 * Hydra_Software_Devel/106   8/1/06 2:54p davidp
291 * PR22673: Fix compiler warnings, uInstance unused.
292 *
293 * Hydra_Software_Devel/105   7/27/06 8:14p davidp
294 * PR22673: Move chip specific send FW command code to platform files.
295 *
296 * Hydra_Software_Devel/104   7/20/06 2:23p nilesh
297 * PR22673: Created BXVD_P_CONTEXT_PLATFORM macro to allow platform-
298 * specific fields in BXVD_P_Context struct
299 *
300 * Hydra_Software_Devel/103   7/18/06 12:09a nilesh
301 * PR22673: Code restructure for 97400, 97401 B0, and 97118
302 *
303 * Hydra_Software_Devel/PR22673/1   7/17/06 2:33p nilesh
304 * PR22673: Restructure on 97401
305 *
306 * Hydra_Software_Devel/102   7/17/06 1:56p pblanco
307 * PR22673: Removed 7401a0 conditionalized code and restructured some of
308 * the remaining conditional code.
309 *
310 * Hydra_Software_Devel/101   7/6/06 9:41a pblanco
311 * PR21943: Fixed conditional compilation for 7401 B0, broken when
312 * conditionalizing for 7118.
313 *
314 * Hydra_Software_Devel/100   7/5/06 3:20p pblanco
315 * PR21943: Conditionalization for 7118
316 *
317 * Hydra_Software_Devel/99   6/28/06 11:29a pblanco
318 * PR20017: Conditionalize definition of heapInfo in
319 * BXVD_P_SendDecoderCommand for A0 only.
320 *
321 * Hydra_Software_Devel/98   6/21/06 6:13p davidp
322 * PR22259: Add Watchdog support and fix a couple problems related to L2
323 * MBX interrupt processing
324 *
325 * Hydra_Software_Devel/97   6/21/06 1:52p pblanco
326 * PR20017: Added BMEM_ValidateHeap call in BXVD_P_SendDecoderCommand
327 * prior to host command address write for 7401b0.
328 *
329 * Hydra_Software_Devel/96   6/20/06 5:42p pblanco
330 * PR20017: Moved heap info request to A0 conditionalized code.
331 *
332 * Hydra_Software_Devel/95   6/15/06 4:06p davidp
333 * PR20017: Remove references to mmap'd FW heap
334 *
335 * Hydra_Software_Devel/94   6/13/06 10:56a pblanco
336 * PR20017: Removed unused address to offset conversion code per Rol
337 * Lewis' email.
338 *
339 * Hydra_Software_Devel/93   6/12/06 6:09p davidp
340 * PR20017: Allocate memory for FW code out of framework heap.
341 *
342 * Hydra_Software_Devel/92   6/12/06 10:56a pblanco
343 * PR20017: Removed unused host commands for SET_ENDIAN, BUFFERCONFIG and
344 * SETCHANNELACTIVE.
345 *
346 * Hydra_Software_Devel/91   6/9/06 6:25p davidp
347 * PR21846: Fixed compiler warnings caused by gcc option "-O3"
348 *
349 * Hydra_Software_Devel/90   6/8/06 4:31p davidp
350 * PR20017: Add support for FW/MIPS cmd mailbox interrupt.
351 *
352 * Hydra_Software_Devel/89   6/8/06 9:18a pblanco
353 * PR20017: Changed chip version test conditionals from A0 and B0 to
354 * BCHP_VER_A0 and BCHP_VER_B0 to conform with the rest of magnum.
355 *
356 * Hydra_Software_Devel/88   5/31/06 1:33p pblanco
357 * PR20017: More changes to support B0 relocatable code.
358 *
359 * Hydra_Software_Devel/87   5/26/06 4:37p davidp
360 * PR20017: Disable FW mailbox polling for all but 7401 B0
361 *
362 * Hydra_Software_Devel/86   5/25/06 3:54p pblanco
363 * PR20017: Changed heap reference pointer for B0.
364 *
365 * Hydra_Software_Devel/85   5/25/06 3:09p pblanco
366 * PR20017: Reloc sanity check in.
367 *
368 * Hydra_Software_Devel/84   5/16/06 10:21a pblanco
369 *
370 * PR20649: Cleanup for B0. Conditionals must be replaced or removed in
371 * later development.
372 *
373 * Hydra_Software_Devel/83   5/10/06 11:01a pblanco
374 * PR19877: Removed unused host commands identified by Gaurav.
375 *
376 * Hydra_Software_Devel/82   5/5/06 3:28p davidp
377 * PR21156: Fix 7400 flavor of BXVD_P_ReleasePPB_isr.
378 *
379 * Hydra_Software_Devel/81   5/5/06 2:10p davidp
380 * PR21156: Add BXVD_P_ReleasePPB_isr and related _isr routines for DM to
381 * use at ISR time.
382 *
383 * Hydra_Software_Devel/80   5/3/06 9:55a pblanco
384 * PR20649: Added polling mode to 7401 SendDecoderCommand in preparation
385 * for relocatable FW testing. Default as checked in is set to interrupt
386 * mode.
387 *
388 * Hydra_Software_Devel/79   4/27/06 4:16p pblanco
389 * PR19877: Changed FW busy error return to BXVD_ERR_FW_IS_BUSY instead of
390 * the incorrect BERR_INVALID_PARAMETER.
391 *
392 * Hydra_Software_Devel/78   4/27/06 9:16a pblanco
393 * PR19877: Moved the busy flag clear so that it's reset immediately after
394 * a timeout.
395 *
396 * Hydra_Software_Devel/77   4/26/06 3:17p pblanco
397 * PR19877: Made sure that busy wait flag is cleared before returning
398 * through error path.
399 *
400 * Hydra_Software_Devel/76   4/17/06 7:58p davidp
401 * PR18906: Previous fix lost in merge, version 60 edits were lost
402 *
403 * Hydra_Software_Devel/75   4/17/06 4:40p davidp
404 * PR20906: Add nowait support for 7400 SendDecoderCommand
405 *
406 * Hydra_Software_Devel/74   4/6/06 3:59p pblanco
407 * PR19877: Removed code that referenced removed private channel context
408 * structure members.
409 *
410 * Hydra_Software_Devel/73   4/5/06 2:09p pblanco
411 * PR15434: Changed channel open formal parameter from Port to
412 * RaveEndianess.
413 *
414 * Hydra_Software_Devel/72   3/31/06 4:18p pblanco
415 * PR19877: Fix build problems due to latest FW update.
416 *
417 * Hydra_Software_Devel/71   3/31/06 3:33p gaurava
418 * PR 15434: Removed port from ChannelOpen. Used the same location for
419 * telling the decoder that the CDB is in big/little endian format. big-
420 * endian is 0 and little_endian is 1.
421 *
422 * Hydra_Software_Devel/70   3/28/06 10:26a pblanco
423 * PR20274: Added host command calls for BUD and host sparse trick play
424 * modes.
425 *
426 * Hydra_Software_Devel/69   3/28/06 8:52a pblanco
427 * PR19877: Fetch vdec_status_block address at channel open time.
428 *
429 * Hydra_Software_Devel/68   3/27/06 6:34p davidp
430 * PR20353: Add Decode Still Picture support for 7400
431 *
432 * Hydra_Software_Devel/67   3/24/06 1:35p pblanco
433 * PR20274: Interim checkin prior to FW implementation.
434 *
435 * Hydra_Software_Devel/66   3/22/06 5:16p davidp
436 * PR20347: Add L2 interrupt support
437 *
438 * Hydra_Software_Devel/65   3/7/06 11:50a pblanco
439 * PR19785: Changed host command code for skip picture to reflect enum
440 * change. Values are now mapped from XVD to values understood by the
441 * firmware.
442 *
443 * Hydra_Software_Devel/64   3/6/06 3:24p pblanco
444 * PR19785: FW can use the newly specified skip enums directly, no need
445 * for the switch statement to map the values.
446 *
447 * Hydra_Software_Devel/62   3/6/06 9:27a pblanco
448 * PR19785: Implemented host command portion of set skip picture mode.
449 *
450 * Hydra_Software_Devel/61   3/6/06 8:47a pblanco
451 * PR20017: Check in of Olive's changes after successful weekend
452 * regression test.
453 *
454 * Hydra_Software_Devel/60   2/28/06 4:36p davidp
455 * PR18906: Pass proper field polarity/frame value to VDC for
456 * PictureDataRdy interrupt regardless if decode is in progress.:
457 *
458 * Hydra_Software_Devel/59   2/21/06 1:46p pblanco
459 * PR19785: Implemented BXVD_SetSkipPictureMode API. This also needs FW
460 * support.
461 *
462 * Hydra_Software_Devel/58   2/17/06 3:17p davidp
463 * PR16792: Modify FW API for Still Picture Decode, feature now working:
464 *
465 * Hydra_Software_Devel/57   2/2/06 4:04p pblanco
466 * PR19123: More code cleanup. Changed all instances of uAvcInstance to
467 * uDecoderInstance and removed last remaining references to the old
468 * decoder context array.
469 *
470 * Hydra_Software_Devel/56   2/2/06 10:59a pblanco
471 * PR19123: Switch UART pin mux in send command depending on decoder
472 * instance.
473 *
474 * Hydra_Software_Devel/55   2/1/06 3:53p pblanco
475 * PR19123: Changed "AVC" instance array in XVD context structure to a
476 * single instance of type BXVD_DecoderContext. Tested against 7401 with
477 * no regressions and against 7400 with no regressions.
478 *
479 * Hydra_Software_Devel/54   2/1/06 2:24p pblanco
480 * PR19123: Added code to switch pin muxes depending on which decoder
481 * instance is active.
482 *
483 * Hydra_Software_Devel/53   2/1/06 8:51a pblanco
484 * PR19123: More 7400 porting work and bug fixes.
485 *
486 * Hydra_Software_Devel/52   1/30/06 4:32p pblanco
487 * PR19308: Use correct definitions for local command structures.
488 *
489 * Hydra_Software_Devel/51   1/30/06 1:18p pblanco
490 * PR19308: Fix command packet being passed to enable trick play.
491 *
492 * Hydra_Software_Devel/50   1/30/06 9:00a pblanco
493 * PR19308: Made sure buffer initializations are correct and that an
494 * unsigned long is being passed as the mode value in
495 * BXVD_P_HostCmdDecEnableBRCMTrickPlay. Also added debugging messages on
496 * input and output.
497 *
498 * Hydra_Software_Devel/49   1/27/06 11:04a pblanco
499 * PR19123: Conditionalize unistd.h include for 7400. We need to use
500 * usleep on this platform for now.
501 *
502 * Hydra_Software_Devel/46   1/26/06 1:32p pblanco
503 * PR19123: Removed debug printfs and added video memory size to command
504 * packet for 7400 FW init.
505 *
506 * Hydra_Software_Devel/45   1/25/06 1:42p pblanco
507 * PR19123: Fix build error caused by previous check in.
508 *
509 * Hydra_Software_Devel/44   1/25/06 11:54a pblanco
510 * PR19123: Support for second decoder mailbox address and event.
511 *
512 * Hydra_Software_Devel/43   1/24/06 2:51p pblanco
513 * PR19123: 7400 firmware bring up debugging changes.
514 *
515 * Hydra_Software_Devel/42   1/18/06 2:19p pblanco
516 * PR19123: Modifications for 7400. Make sure code builds for this
517 * platform.
518 *
519 * Hydra_Software_Devel/41   1/16/06 2:11p davidp
520 * PR16792: BXVD_Open now uses two heap pointers, one for FW code (2MB)
521 * the other for FW picture buffers.:
522 *
523 * Hydra_Software_Devel/40   1/10/06 11:18a pblanco
524 * PR16052: Added implementation of BXVD_P_HostCmdDecEnableBRCMTrickPlay.
525 *
526 * Hydra_Software_Devel/39   12/23/05 6:50p davidp
527 * PR16878: Reset Decoder in Watchdog ISR, add BXVD_Open setting for
528 * watchdog timer value, pass WD info to FW:
529 *
530 * Hydra_Software_Devel/38   12/21/05 5:59p davidp
531 * PR16052: Add Still picture support:
532 *
533 * Hydra_Software_Devel/37   12/15/05 6:06p davidp
534 * PR16052: Support for hold last picture on channel change:
535 *
536 * Hydra_Software_Devel/36   12/12/05 3:09p pblanco
537 * PR16052: More still picture internals (sanity checkin)
538 *
539 * Hydra_Software_Devel/35   12/9/05 3:21p vsilyaev
540 * PR 18019: Fixed include files
541 *
542 * Hydra_Software_Devel/34   12/9/05 1:31p pblanco
543 * PR16052: Fixed a compilation warning.
544 *
545 * Hydra_Software_Devel/33   12/9/05 12:29p pblanco
546 * PR16052: Added skeleton for still picture host command.
547 *
548 * Hydra_Software_Devel/32   11/10/05 8:00a pblanco
549 * PR16052: FW now uses heap info to determine load and execution
550 * addresses. Also removed unused code that existed when XVD used to
551 * create and map its own heap. Corresponding changes were made in
552 * related modules also checked in at this time.
553 *
554 * Hydra_Software_Devel/32   11/10/05 7:55a pblanco
555 * PR16052: FW now uses heap info to determine load and execution
556 * addresses. Also removed unused code that existed when XVD used to
557 * create and map its own heap. Corresponding changes were made in
558 * related modules also checked in at this time.
559 *
560 * Hydra_Software_Devel/32   11/10/05 7:53a pblanco
561 * PR16052: FW now uses heap info to determine load and execution
562 * addresses. Also removed unused code that existed when XVD used to
563 * create and map its own heap. Corresponding changes were made in
564 * related modules also checked in at this time.
565 *
566 * Hydra_Software_Devel/30   11/8/05 1:42p davidp
567 * PR17935: Update decoder register definitions to match latest RDB:
568 *
569 * Hydra_Software_Devel/29   11/3/05 3:15p pblanco
570 * PR16052: Added DM underflow count to status items returned by
571 * BXVD_GetChannelStatus.
572 *
573 * Hydra_Software_Devel/28   10/25/05 7:58p davidp
574 * PR16052: Fix compiler warnings and remove <CR> from report message
575 * strings:
576 *
577 * Hydra_Software_Devel/27   10/21/05 5:38p davidp
578 * PR17706: Set release PPB argument for VDEC channel close command based
579 * on channel change mode.:
580 *
581 * Hydra_Software_Devel/26   10/20/05 5:30p gaurava
582 * PR 16052: Made inner loop firmware relocatable so added the PC address
583 * to Init command
584 *
585 * Hydra_Software_Devel/25   9/29/05 2:34p pblanco
586 * PR16052: Changed inner and outer loop UART from 115200 to 38400.
587 *
588 * Hydra_Software_Devel/24   9/26/05 2:27p pblanco
589 * PR16052: Passing RUL descriptor mask through to firmware.
590 *
591 * Hydra_Software_Devel/22   9/13/05 1:48p pblanco
592 * PR16052: Cleaned up decoder flush code.
593 *
594 * Hydra_Software_Devel/21   9/7/05 6:01a pblanco
595 * PR16052: Fixed bad arguments for BDBG_MSG calls.
596 *
597 * Hydra_Software_Devel/20   9/6/05 10:28a pblanco
598 * PR16052: Made sure correct addresses were copied from open channel
599 * response to channel context.
600 *
601 * Hydra_Software_Devel/19   9/2/05 10:05a pblanco
602 * PR16052: Fixed compile errors when DEBUG=y.
603 *
604 * Hydra_Software_Devel/18   9/2/05 9:11a davidp
605 * PR16052: Add support for multiple L3 interrupts:
606 *
607 * Hydra_Software_Devel/17   8/29/05 8:38a pblanco
608 * PR16052: Support for new FW.
609 *
610 * Hydra_Software_Devel/16   8/25/05 5:17p davidp
611 * PR16052: Add FW command mailbox interrupt support:
612 *
613 * Hydra_Software_Devel/15   8/25/05 1:38p pblanco
614 * PR16052: Fixed a potential SEGV that would occur if the response timed
615 * out.
616 *
617 * Hydra_Software_Devel/14   8/24/05 1:16p pblanco
618 * PR16052: Added support for multiple AVC instances and removed debugging
619 * printfs.
620 *
621 * Hydra_Software_Devel/13   8/23/05 1:46p pblanco
622 * PR16052: Additional host command support, code cleanup and bug fixes.
623 *
624 * Hydra_Software_Devel/12   8/18/05 2:12p pblanco
625 * PR16052: Code fixes for BXVD_OpenChannel and BXVD_StartDecode.
626 *
627 * Hydra_Software_Devel/11   8/16/05 1:06p pblanco
628 * PR16052: FW download and execution are working... this is a sanity
629 * checkin.
630 *
631 * Hydra_Software_Devel/10   8/15/05 10:16a pblanco
632 * PR16052: Corrected initial command parameters and reformatted some
633 * code.
634 *
635 * Hydra_Software_Devel/9   8/12/05 7:04a pblanco
636 * PR16052: Temporarily commented out some functionality.
637 *
638 * Hydra_Software_Devel/8   8/4/05 3:19p ebrakus
639 * PR16052: add support for buffer config
640 *
641 * Hydra_Software_Devel/7   8/3/05 4:49p ebrakus
642 * PR16052: Add support for SetChannelActive and BufferConfig
643 *
644 * Hydra_Software_Devel/6   8/3/05 2:13p ebrakus
645 * PR16052: Minor cleanup
646 *
647 * Hydra_Software_Devel/5   7/29/05 3:03p ebrakus
648 * PR16052: add last     remaining commands
649 *
650 * Hydra_Software_Devel/4   7/27/05 4:44p ebrakus
651 * PR16052: update decoder interface for correct mailbox location
652 *
653 * Hydra_Software_Devel/3   7/26/05 1:08p ebrakus
654 * PR16052: fix unresolved symbol
655 *
656 * Hydra_Software_Devel/2   7/26/05 12:35p ebrakus
657 * PR16052: ca hange vdec_api defined values to Mangnum format
658 *
659 * Hydra_Software_Devel/1   7/25/05 12:46p ebrakus
660 * PR16052: Initial checkin
661 *
662 ***************************************************************************/
663#include "bstd.h"
664#include "bxvd_platform.h"
665#include "bxvd_priv.h"         
666#include "bkni.h"                /* malloc */
667#include "bavc.h"
668
669#include "bxvd_priv.h"
670#include "bxvd_reg.h"
671
672#define CPU_2_HOST_INT_CLEAR 0x80000000
673
674/* If FW cmd MBX handshake polling desired, enable polling here */
675/* #define BXVD_POLL_FW_MBX 1 */
676
677#define FW_CMD_TIMEOUT_NORMAL    1000
678#define FW_CMD_TIMEOUT_DEBUGCMD  1500
679#define B0_POLL_DELAY 6000
680
681#if BSTD_CPU_ENDIAN == BSTD_ENDIAN_BIG
682#define BXVD_P_SWAP32(a) (((a&0xFF)<<24)|((a&0xFF00)<<8)|((a&0xFF0000)>>8)|((a&0xFF000000)>>24))
683
684static int _strlen(const char *s) 
685{
686   int i=0;
687   while (*s++) i++;
688   return i;
689}
690#endif
691
692BDBG_MODULE(BXVD_CMDS);
693
694/* TODO: Find the proper values for items tagged with this define*/
695#define TBD_VALUE (0)
696
697/******************************************************************************
698Summary:
699  This function is used to send commands to the AVC decoder.
700
701Description:
702  General function for sending commands to AVC decoder.  Used by
703  functions that handle specific commands.
704
705Input:
706  hXvd       - XVD instance handle
707  uInstance  - Decoder instance. Always 0 for 7401, 7118 0 or 1 for 7400
708  *pCmd      - pointer to command structure to send to AVC
709  *pRsp      - pointer to buffer to receive response.
710
711Returns:
712  BERR_SUCCESS
713  BERR_INVALID_PARAMETER - decoder related failure
714 
715See Also:
716
717******************************************************************************/
718
719BERR_Code BXVD_P_SendDecoderCommand(
720   BXVD_Handle hXvd,
721   uint32_t       uInstance,
722   const BXVD_Cmd *pCmd,
723   BXVD_Rsp       *pRsp,
724   uint32_t       uiTimeout
725   )
726{
727   BERR_Code         eStatus = BERR_SUCCESS;
728   BXVD_P_RspGeneric *pGenericRsp;       /* Used to extract the status field */
729
730   volatile uint32_t uInBox;
731
732#if BXVD_POLL_FW_MBX
733   int i;
734   volatile uint32_t uIntrVal;
735#endif
736
737   BDBG_ENTER(BXVD_P_SendDecoderCommand);
738
739   BDBG_ASSERT(pCmd);
740   BDBG_ASSERT(pRsp);
741
742   uInstance = uInstance;
743
744   BKNI_EnterCriticalSection();
745
746   /* Check to if we're already waiting for a reply from this decoder */
747   if (hXvd->stDecoderContext.bIfBusy)
748   {
749      BKNI_LeaveCriticalSection();
750      BXVD_DBG_MSG(hXvd, ("Decoder is busy... exiting"));
751      return BERR_TRACE(BXVD_ERR_FW_IS_BUSY);
752   }
753
754   /* Set device busy */
755   hXvd->stDecoderContext.bIfBusy = 1; 
756   BKNI_LeaveCriticalSection();
757
758   /* Clear out any previously completed FW command done events */
759   BKNI_ResetEvent(hXvd->stDecoderContext.hFWCmdDoneEvent);
760
761   /* write the command parameters to the AVC  */
762   BKNI_Memcpy((void*)(hXvd->stDecoderContext.ulCmdBufferAddr),
763               (void*)(pCmd),
764               sizeof(BXVD_Cmd));
765       
766#if BXVD_POLL_FW_MBX
767   /* zero out the response mailbox*/
768   BXVD_P_WRITE_FWRSP_MBX(hXvd, uInstance, 0);
769#endif
770
771   BXVD_P_WRITE_FWCMD_TO_MBX(hXvd, uInstance, hXvd->uiCmdBufferVector);
772
773#if BXVD_POLL_FW_MBX
774
775   /* poll for response */
776   uInBox = 0;
777   for ( i = 0; i < 200; i++)
778   {
779      BKNI_Sleep(1);
780
781      uInBox = BXVD_Reg_Read32(hXvd, hXvd->stPlatformInfo.stReg.uiDecode_OuterCPU2HostMailbox); 
782
783      if (uInBox !=0) 
784         break;
785   }
786
787   BXVD_DBG_MSG(hXvd, ("Decoder:%d, mbx:%08x", uInstance, uInBox));
788
789   uIntrVal = BXVD_Reg_Read32(hXvd, hXvd->stPlatformInfo.stReg.uiDecode_OuterInterruptClear);
790
791   BXVD_DBG_MSG(hXvd, ("IntGen_clr:%08x\n", uIntrVal));
792
793   /* See if the firmware timed out before the response */
794   if ( i >= 200)
795   {
796      BXVD_DBG_ERR(hXvd, ("BXVD_P_SendDecoderCommand timed out waiting for response"));
797   }
798
799#else
800
801   /* Interrupt driven implementation */
802
803   /* wait for response from FW */
804   uInBox = 0;
805
806   eStatus = BERR_TRACE(BKNI_WaitForEvent(hXvd->stDecoderContext.hFWCmdDoneEvent, uiTimeout));
807
808   if(BERR_TIMEOUT == eStatus)
809   {
810      BXVD_DBG_ERR(hXvd, ("FW command: %08x response timed out", pCmd->cmd));
811      hXvd->stDecoderContext.bIfBusy = 0;
812      return BERR_TRACE(eStatus);
813   }
814
815   /* get the response from the AVC  */
816
817   uInBox = BXVD_Reg_Read32(hXvd, hXvd->stPlatformInfo.stReg.uiDecode_OuterCPU2HostMailbox);
818
819#endif
820
821   /* Clear device busy */
822   hXvd->stDecoderContext.bIfBusy = 0; 
823   
824   /* get the response from the AVC  */
825   if (uInBox)
826   {
827      BKNI_Memcpy((void*)(pRsp),
828        (void*)(hXvd->stDecoderContext.ulCmdBufferAddr),
829        sizeof(BXVD_Rsp));
830
831
832     /* make sure it is the correct command */
833      if (((pCmd->cmd) | BXVD_CMD_RESPONSE) != (pRsp->cmd)) 
834      {
835         BDBG_LEAVE(BXVD_P_SendDecoderCommand);
836         return BERR_TRACE(BERR_INVALID_PARAMETER);
837      }
838
839      pGenericRsp = (BXVD_P_RspGeneric *)(pRsp);
840
841      /* Check for command error */
842      if ( pGenericRsp->ulStatus )
843      {
844         BDBG_ERR(("AVD firmware error return %d", pGenericRsp->ulStatus ));
845         BDBG_LEAVE(BXVD_P_SendDecoderCommand);
846         return BERR_TRACE(BERR_INVALID_PARAMETER);
847      }
848
849   }
850   else
851   {
852      BXVD_DBG_ERR(hXvd, ("FW RSP MBX PTR NULL"));
853      return BERR_TRACE(BERR_UNKNOWN);
854   }
855   
856   BKNI_ResetEvent(hXvd->stDecoderContext.hFWCmdDoneEvent);
857   
858   BDBG_LEAVE(BXVD_P_SendDecoderCommand);
859   return BERR_TRACE(eStatus);
860}
861
862/***************************************************************************
863 *  {secret}
864 *      BXVD_P_HostCmdSendInit
865 *      Command causes the AVC decoder to initialize.
866 *  All internal state and any partially completed operations
867 *  will be lost.
868 ***************************************************************************/
869BERR_Code BXVD_P_HostCmdSendInit
870(
871 BXVD_Handle  hXvd,                /* XVD context */
872 uint32_t     uDecoderInstance,    /* AVC instance */
873 uint32_t     eRaveEndianess       /* Endianess of data in Rave CDB/ITB */
874 )
875{
876   BXVD_Cmd             *pCmd;         
877   BXVD_Rsp             *pRsp;
878   BERR_Code            eStatus = BERR_SUCCESS; /* Status return */
879
880   BXVD_Cmd_Initialize *pInit;                 /* Pointer to command */
881   BXVD_Rsp_Initialize *pInitRsp;              /* Pointer to response */
882
883   /* Clear out the context and set defaults. */
884   pCmd = &hXvd->FWCmd.cmd;
885   pRsp = &hXvd->FWRsp.rsp;
886
887   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
888   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
889
890   pInit = &hXvd->FWCmd.init;
891   pInitRsp = &hXvd->FWRsp.init;
892 
893   /* Command ID */
894   pInit->command = BXVD_CMD_INITIALIZE;
895 
896   /* parameters */
897   pInit->cdb_little_endian = eRaveEndianess;
898   pInit->stripe_width = hXvd->uiDecode_StripeWidth;
899   pInit->stripe_height = hXvd->uiDecode_StripeMultiple;
900   pInit->bvnf_intr_context_base = hXvd->stPlatformInfo.stReg.uiBvnf_Intr2_3_AvdStatus;
901   pInit->host_L2_intr_set = hXvd->stPlatformInfo.stReg.uiAvd_CPUL2InterruptSet;
902   pInit->chip_prod_revision = hXvd->uiChip_ProductRevision;
903   pInit->rave_context_reg_size = BXVD_P_RAVE_CONTEXT_SIZE;
904   pInit->rave_cx_hold_clr_status = BXVD_P_RAVE_CX_HOLD_CLR_STATUS;
905   pInit->rave_packet_count = BXVD_P_RAVE_PACKET_COUNT; 
906
907   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_INITIALIZE:"));
908   BXVD_DBG_MSG(hXvd, (" command: %#x", pInit->command));
909   BXVD_DBG_MSG(hXvd, (" cdb_little_endian: %d", pInit->cdb_little_endian));
910   BXVD_DBG_MSG(hXvd, (" stripe_width: %d", pInit->stripe_width));
911   BXVD_DBG_MSG(hXvd, (" stripe_height: %d", pInit->stripe_height));
912   BXVD_DBG_MSG(hXvd, (" bvnf_intr_context base: %08x", pInit->bvnf_intr_context_base));
913   BXVD_DBG_MSG(hXvd, (" host_L2_intr_set: %08x", pInit->host_L2_intr_set));
914   BXVD_DBG_MSG(hXvd, (" chip_prod_revision: %08x", pInit->chip_prod_revision));
915   BXVD_DBG_MSG(hXvd, (" rave_context_reg_size: %08x", pInit->rave_context_reg_size));
916   BXVD_DBG_MSG(hXvd, (" rave_cx_hold_clr_status: %08x", pInit->rave_cx_hold_clr_status));
917   BXVD_DBG_MSG(hXvd, (" rave_packet_count: %08x", pInit->rave_packet_count));
918
919   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd, 
920                                                  uDecoderInstance, 
921                                                  pCmd,
922                                                  pRsp,
923                                                  FW_CMD_TIMEOUT_NORMAL));
924
925   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_INITIALIZE:"));
926   BXVD_DBG_MSG(hXvd, (" command: %#x", pInitRsp->command));
927   BXVD_DBG_MSG(hXvd, (" status: %#x", pInitRsp->status));           
928   BXVD_DBG_MSG(hXvd, (" sw_version: %#x", pInitRsp->sw_version));
929
930
931   BXVD_P_DBG_MSG_DISP_INFO_OFFSET(hXvd, pInitRsp);
932
933   if( eStatus != BERR_SUCCESS )
934   {
935      return BERR_TRACE(eStatus);
936   }
937   else if (!BXVD_P_IS_FW_VERSION_VALID(pInitRsp))
938   {
939      BXVD_DBG_WRN(hXvd, ("Incompatible FW version"));
940
941      eStatus = BERR_INVALID_PARAMETER;
942   }
943
944   /*
945    * Save the parameters passed back from the firmware.
946    */
947
948   BXVD_P_SAVE_DISPLAY_INFO(hXvd, pInitRsp);
949
950   hXvd->sRevisionInfo.ulDecoderFwRev = pInitRsp->sw_version;
951
952   return BERR_TRACE(eStatus);
953}
954
955
956/***************************************************************************
957 *  {secret}
958 *      BXVD_P_HostCmdSendInit
959 *      Command causes the AVC decoder to initialize.
960 *  All internal state and any partially completed operations
961 *  will be lost.
962 ***************************************************************************/
963BERR_Code BXVD_P_HostCmdSendConfig
964(
965 BXVD_Handle  hXvd,              /* XVD context */
966 uint32_t     uiVecIndex,        /* Display device index */
967 uint32_t     uiInterruptMask    /* RUL done mask for specified display */
968)
969{
970   BXVD_Cmd             *pCmd;
971   BXVD_Rsp             *pRsp;
972
973   BERR_Code            eStatus = BERR_SUCCESS; /* Status return */
974
975   BXVD_Cmd_Config *pCfgCmd;   /* Pointer to command */
976   BXVD_Rsp_Config *pCfgRsp;   /* Pointer to response */
977
978   /* Clear out the context and set defaults. */
979   pCmd = &hXvd->FWCmd.cmd;
980   pRsp = &hXvd->FWRsp.rsp;
981
982   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
983   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
984
985   pCfgCmd = &hXvd->FWCmd.config;
986   pCfgRsp = &hXvd->FWRsp.config;
987 
988   /* Command ID */
989   pCfgCmd->command = BXVD_CMD_CONFIG;
990 
991   /* parameters */
992   pCfgCmd->vec_index = uiVecIndex;
993   pCfgCmd->interrupt_mask = uiInterruptMask;
994
995   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CONFIG:"));
996   BXVD_DBG_MSG(hXvd, (" vec_index: %d", pCfgCmd->vec_index));
997   BXVD_DBG_MSG(hXvd, (" interrupt_mask: %#x", pCfgCmd->interrupt_mask));
998
999   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd, 
1000                                                  hXvd->uDecoderInstance, 
1001                                                  pCmd,
1002                                                  pRsp,
1003                                                  FW_CMD_TIMEOUT_NORMAL));
1004
1005   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CONFIG:"));
1006   BXVD_DBG_MSG(hXvd, (" command: %#x", pCfgRsp->command));
1007   BXVD_DBG_MSG(hXvd, (" status: %#x", pCfgRsp->status));           
1008
1009   return BERR_TRACE(eStatus);
1010}
1011
1012/***************************************************************************
1013 *  {secret}
1014 *      BXVD_P_HostCmdSendDecChannelOpen
1015 ***************************************************************************/
1016BERR_Code BXVD_P_HostCmdSendDecChannelOpen
1017(
1018        BXVD_Handle         hXvd,
1019        BXVD_ChannelHandle  hXvdCh,
1020        bool                bStillPictureMode,
1021        uint32_t            uiMaxResolution,
1022        BXVD_P_DecodeFWMemSize  *pstDecodeFWMemSize,
1023        BXVD_P_DecodeFWBaseAddrs *pstDecodeFWBaseAddrs
1024)
1025{
1026   BXVD_Cmd             *pCmd;
1027   BXVD_Rsp             *pRsp;
1028   
1029   BERR_Code        eStatus = BERR_SUCCESS;/* Status return       */
1030   BXVD_Cmd_ChannelOpen *pChOpen;       /* Pointer to command  */
1031   BXVD_Rsp_ChannelOpen *pChOpenRsp;    /* Pointer to response */
1032
1033   uint32_t            uiStatusBlkAddr;
1034
1035   /* Clear out the context and set defaults. */
1036   pCmd = &hXvd->FWCmd.cmd;
1037   pRsp = &hXvd->FWRsp.rsp;
1038   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1039   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1040
1041   pChOpen = &hXvd->FWCmd.channelOpen;
1042   pChOpenRsp = &hXvd->FWRsp.channelOpen;
1043
1044   /* Command ID */
1045   pChOpen->command = BXVD_CMD_CHANNELOPEN;
1046   pChOpen->channel_number = hXvdCh->ulChannelNum;
1047
1048   pChOpen->still_picture_mode = (unsigned long) bStillPictureMode;
1049
1050   pChOpen->max_resolution_enum = uiMaxResolution;
1051
1052   pChOpen->context_memory_base = pstDecodeFWBaseAddrs->uiFWContextBase; 
1053   pChOpen->context_memory_size = pstDecodeFWMemSize->uiFWContextSize; 
1054
1055   pChOpen->video_memory_base = pstDecodeFWBaseAddrs->uiFWPicBlockBase;
1056   pChOpen->video_block_size = pstDecodeFWMemSize->uiFWPicBlockSize;
1057   pChOpen->video_block_count = pstDecodeFWMemSize->uiFWPicBlockCount;
1058
1059   pChOpen->cabac_memory_base = pstDecodeFWBaseAddrs->uiFWCabacBase; 
1060   pChOpen->cabac_memory_size = pstDecodeFWMemSize->uiFWCabacSize; 
1061
1062   pChOpen->cabac_wl_base = pstDecodeFWBaseAddrs->uiFWCabacWorklistBase; 
1063   pChOpen->cabac_wl_size = pstDecodeFWMemSize->uiFWCabacWorklistSize; 
1064
1065   pChOpen->direct_mode_storage_base = pstDecodeFWBaseAddrs->uiFWDirectModeBase;
1066   pChOpen->direct_mode_storage_size = pstDecodeFWMemSize->uiFWDirectModeSize;
1067
1068   pChOpen->il_wl_base = pstDecodeFWBaseAddrs->uiFWInnerLoopWorklistBase;
1069   pChOpen->il_wl_size = pstDecodeFWMemSize->uiFWInnerLoopWorklistSize; 
1070   
1071   pChOpen->bl_mv_store_base = pstDecodeFWBaseAddrs->uiFWInterLayerMVBase;
1072   pChOpen->bl_mv_store_size = pstDecodeFWMemSize->uiFWInterLayerMVSize;
1073
1074   pChOpen->bl_video_store_base = pstDecodeFWBaseAddrs->uiFWInterLayerPicBase;
1075   pChOpen->bl_video_store_size = pstDecodeFWMemSize->uiFWInterLayerPicSize;
1076
1077   /* parameters */
1078
1079   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CHANNELOPEN:"));
1080   BXVD_DBG_MSG(hXvd, (" command: %#x", pChOpen->command));
1081   BXVD_DBG_MSG(hXvd, (" channel_number: %d", pChOpen->channel_number));
1082   BXVD_DBG_MSG(hXvd, (" max_resolution_enum: %d", pChOpen->max_resolution_enum));
1083   BXVD_DBG_MSG(hXvd, (" still_picture_mode: %d", pChOpen->still_picture_mode));
1084   BXVD_DBG_MSG(hXvd, (" context_memory_base: %#x", pChOpen->context_memory_base));
1085   BXVD_DBG_MSG(hXvd, (" context_memory_size: %#x", pChOpen->context_memory_size));
1086   BXVD_DBG_MSG(hXvd, (" video_memory_base: %#x", pChOpen->video_memory_base));
1087   BXVD_DBG_MSG(hXvd, (" video_block_size: %#x", pChOpen->video_block_size));
1088   BXVD_DBG_MSG(hXvd, (" video_block_count: %d", pChOpen->video_block_count));
1089   BXVD_DBG_MSG(hXvd, (" cabac_memory_base: %#x", pChOpen->cabac_memory_base));
1090   BXVD_DBG_MSG(hXvd, (" cabac_memory_size: %#x", pChOpen->cabac_memory_size));
1091   BXVD_DBG_MSG(hXvd, (" bl_mv_store_base: %#x", pChOpen->bl_mv_store_base));
1092   BXVD_DBG_MSG(hXvd, (" bl_mv_store_size: %#x", pChOpen->bl_mv_store_size));
1093   BXVD_DBG_MSG(hXvd, (" cabac_worklist_base: %#x", pChOpen->cabac_wl_base));
1094   BXVD_DBG_MSG(hXvd, (" cabac_worklist_size: %#x", pChOpen->cabac_wl_size));
1095   BXVD_DBG_MSG(hXvd, (" direct_mode_storage_base: %#x", pChOpen->direct_mode_storage_base));
1096   BXVD_DBG_MSG(hXvd, (" direct_mode_storage_size: %#x", pChOpen->direct_mode_storage_size));
1097   BXVD_DBG_MSG(hXvd, (" il_wl_base: %#x", pChOpen->il_wl_base));
1098   BXVD_DBG_MSG(hXvd, (" il_wl_size: %#x", pChOpen->il_wl_size));
1099   BXVD_DBG_MSG(hXvd, (" bl_video_store_base: %#x", pChOpen->bl_video_store_base));
1100   BXVD_DBG_MSG(hXvd, (" bl_video_store_size: %#x", pChOpen->bl_video_store_size));
1101
1102   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd,
1103                                                  hXvd->uDecoderInstance, 
1104                                                  pCmd,
1105                                                  pRsp,
1106                                                  FW_CMD_TIMEOUT_NORMAL));
1107
1108   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CHANNELOPEN:"));
1109   BXVD_DBG_MSG(hXvd, (" command: %#x", pChOpenRsp->command));
1110   BXVD_DBG_MSG(hXvd, (" status: %#x", pChOpenRsp->status));
1111   BXVD_DBG_MSG(hXvd, (" picture_delivery_buffer: %#x", pChOpenRsp->picture_delivery_buffer));
1112   BXVD_DBG_MSG(hXvd, (" picture_release_buffer: %#x", pChOpenRsp->picture_release_buffer));
1113
1114   /* Save the return info of interest. */
1115
1116#if BXVD_P_FW_HIM_API
1117
1118   /* Initialize the delivery queue parameters.
1119    */
1120   BKNI_Memset( &(hXvdCh->stDeliveryQueue), 0, sizeof ( BXVD_P_AVD_Queue ) );
1121
1122   hXvdCh->stDeliveryQueue.ulQueueOffset              = pChOpenRsp->picture_delivery_buffer;
1123
1124   hXvdCh->stDeliveryQueue.stReadIndex.ulByteOffset   = pChOpenRsp->delivery_q_read_byte_offset;
1125   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stDeliveryQueue.stReadIndex, 1 );
1126
1127   hXvdCh->stDeliveryQueue.stWriteIndex.ulByteOffset  = pChOpenRsp->delivery_q_write_byte_offset;
1128   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stDeliveryQueue.stWriteIndex, 1 );
1129
1130   /* Initialize the release queue parameters.
1131    */
1132   BKNI_Memset( &(hXvdCh->stReleaseQueue), 0, sizeof ( BXVD_P_AVD_Queue ) );
1133
1134   hXvdCh->stReleaseQueue.ulQueueOffset               = pChOpenRsp->picture_release_buffer;
1135
1136   hXvdCh->stReleaseQueue.stReadIndex.ulByteOffset    = pChOpenRsp->release_q_read_byte_offset;
1137   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stReleaseQueue.stReadIndex, 1 );
1138   
1139   hXvdCh->stReleaseQueue.stWriteIndex.ulByteOffset   = pChOpenRsp->release_q_write_byte_offset;
1140   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stReleaseQueue.stWriteIndex, 1 );
1141
1142   hXvdCh->stReleaseQueue.stShadowWriteIndex.ulByteOffset   = pChOpenRsp->shadow_write_byte_offset;
1143   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stReleaseQueue.stShadowWriteIndex, 1 );
1144
1145   /* Initialize the drop count parameters.
1146    */
1147   BKNI_Memset( &(hXvdCh->stDropCountIndex), 0, sizeof ( BXVD_P_HIM_Offsets ) );
1148
1149   hXvdCh->stDropCountIndex.ulByteOffset        = pChOpenRsp->drop_count_byte_offset;
1150   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stDropCountIndex, 2 );
1151
1152   /* Initialize the AVD status block parameters.
1153    */
1154   BKNI_Memset( &(hXvdCh->stStatusBlockIndex), 0, sizeof ( BXVD_P_HIM_Offsets ) );
1155   
1156   hXvdCh->stStatusBlockIndex.ulByteOffset      = pChOpenRsp->avd_status_addr;
1157   BXVD_P_HOSTINTERFACEMEMORY_COOK_OFFSETS( hXvdCh->stStatusBlockIndex, 4 );
1158
1159   /* unused */
1160   uiStatusBlkAddr = 0 ;
1161   hXvdCh->ulAvdStatusBlock = 0;
1162
1163#else
1164   BXVD_DBG_MSG(hXvd, (" dms_release_buffer: %#x", pChOpenRsp->dm_return_address));
1165   BXVD_DBG_MSG(hXvd, (" avd_status_address = %#x", pChOpenRsp->avd_status_address));
1166       
1167   hXvdCh->ulPicBuf           = pChOpenRsp->picture_delivery_buffer;
1168   hXvdCh->ulPicRelBuf        = pChOpenRsp->picture_release_buffer;
1169   hXvdCh->ulPicInfoRelBuf    = pChOpenRsp->dm_return_address; 
1170 
1171   uiStatusBlkAddr            = (uint32_t) pChOpenRsp->avd_status_address;
1172
1173   BMEM_ConvertOffsetToAddress(hXvd->hSystemHeap, 
1174                               uiStatusBlkAddr,
1175                               (void *)&hXvdCh->ulAvdStatusBlock);
1176#endif
1177       
1178
1179   hXvdCh->bDecoderChannelOpened = true;
1180       
1181   return BERR_TRACE(eStatus);
1182}
1183
1184/***************************************************************************
1185 *  {secret}
1186 *      BXVD_P_HostCmdSendDecChannelClose
1187 ***************************************************************************/
1188BERR_Code BXVD_P_HostCmdSendDecChannelClose
1189(
1190   BXVD_Handle         hXvd,
1191   BXVD_ChannelHandle  hXvdCh
1192)
1193{
1194   BXVD_Cmd             *pCmd;
1195   BXVD_Rsp             *pRsp;
1196
1197   BERR_Code        eStatus  = BERR_SUCCESS; /* Status return */
1198
1199   BXVD_Cmd_ChannelClose *pChClose;          /* Pointer to command  */
1200   BXVD_Rsp_ChannelClose *pChCloseRsp;      /* Pointer to response */
1201
1202   /* Clear out the context and set defaults. */
1203   pCmd = &hXvd->FWCmd.cmd;
1204   pRsp = &hXvd->FWRsp.rsp;
1205   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1206   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1207
1208   pChClose = &hXvd->FWCmd.channelClose;
1209   pChCloseRsp = &hXvd->FWRsp.channelClose;
1210
1211   /* Command ID */
1212   pChClose->command = BXVD_CMD_CHANNELCLOSE;
1213   pChClose->channel_number = hXvdCh->ulChannelNum;
1214       
1215   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CHANNELCLOSE:"));
1216   BXVD_DBG_MSG(hXvd, (" command: %#x", pChClose->command));
1217   BXVD_DBG_MSG(hXvd, (" channel_number: %d", pChClose->channel_number));
1218
1219   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd, 
1220                                                  hXvd->uDecoderInstance, 
1221                                                  pCmd,
1222                                                  pRsp,
1223                                                  FW_CMD_TIMEOUT_NORMAL));
1224   
1225   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CHANNELCLOSE:"));
1226   BXVD_DBG_MSG(hXvd, (" command: %#x", pChCloseRsp->command));
1227   BXVD_DBG_MSG(hXvd, (" status: %#x", pChCloseRsp->status));           
1228   
1229   hXvdCh->bDecoderChannelOpened = false;
1230
1231   return BERR_TRACE(eStatus);
1232}
1233
1234/***************************************************************************
1235 *  {secret}
1236 *      BXVD_P_HostCmdSendDecChannelOpen
1237 ***************************************************************************/
1238BERR_Code BXVD_P_HostCmdSendDecChannelStart
1239(
1240   BXVD_Handle         hXvd,
1241   uint32_t            ulChannelNumber,
1242   uint32_t            eProtocol,
1243   uint32_t            eChannelMode,
1244   uint32_t            ulRaveContextBase,
1245   uint32_t            aulRaveContextBaseExt[],
1246   uint32_t            ulVecIndex
1247   )
1248{
1249   BXVD_Cmd             *pCmd;
1250   BXVD_Rsp             *pRsp;
1251
1252   BERR_Code        eStatus = BERR_SUCCESS;/* Status return       */
1253   BXVD_Cmd_ChannelStart        *pChStart;      /* Pointer to command  */
1254   BXVD_Rsp_ChannelStart        *pChStartRsp;   /* Pointer to response */
1255
1256   /* Clear out the context and set defaults. */
1257   pCmd = &hXvd->FWCmd.cmd;
1258   pRsp = &hXvd->FWRsp.rsp;
1259   BKNI_Memset((void*)pCmd, 0x0, sizeof(BXVD_Cmd));
1260   BKNI_Memset((void*)pRsp, 0x0, sizeof(BXVD_Rsp));
1261
1262   pChStart = &hXvd->FWCmd.channelStart;
1263   pChStartRsp = &hXvd->FWRsp.channelStart;
1264
1265   /* Command ID */
1266   pChStart->command = BXVD_CMD_CHANNELSTART;
1267       
1268   /* parameters */
1269   pChStart->protocol = eProtocol;     
1270
1271   pChStart->channel_mode = eChannelMode;
1272   pChStart->channel_number = ulChannelNumber;;
1273
1274   pChStart->rave_ctxt_base = ulRaveContextBase;
1275   pChStart->rave_ctxt_base_ext = aulRaveContextBaseExt[0];
1276   pChStart->vec_index = ulVecIndex;
1277
1278   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CHANNELSTART:"));
1279   BXVD_DBG_MSG(hXvd, (" command: %#x", pChStart->command));
1280   BXVD_DBG_MSG(hXvd, (" protocol: %d", pChStart->protocol));
1281   BXVD_DBG_MSG(hXvd, (" channel_mode: %#x", pChStart->channel_mode));
1282   BXVD_DBG_MSG(hXvd, (" vec_index: %d", pChStart->vec_index));
1283   BXVD_DBG_MSG(hXvd, (" channel_number: %d", pChStart->channel_number));
1284   BXVD_DBG_MSG(hXvd, (" rave_ctxt_base: %#x", pChStart->rave_ctxt_base));
1285   BXVD_DBG_MSG(hXvd, (" rave_ctxt_base_ext: %#x", pChStart->rave_ctxt_base_ext));
1286
1287   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd,
1288                                                  hXvd->uDecoderInstance, 
1289                                                  pCmd,
1290                                                  pRsp,
1291                                                  FW_CMD_TIMEOUT_NORMAL));
1292
1293   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CHANNELSTART:"));
1294   BXVD_DBG_MSG(hXvd, (" command: %#x", pChStartRsp->command));
1295   BXVD_DBG_MSG(hXvd, (" status: %#x", pChStartRsp->status));           
1296   BXVD_DBG_MSG(hXvd, (" frames_outstanding: %d", pChStartRsp->frames_outstanding));
1297
1298   return BERR_TRACE(eStatus);
1299}
1300
1301
1302
1303/***************************************************************************
1304 *  {secret}
1305 *      BXVD_P_HostCmdSendDecChannelStop
1306 ***************************************************************************/
1307BERR_Code BXVD_P_HostCmdSendDecChannelStop
1308(
1309        BXVD_Handle        hXvd,
1310        uint32_t           ulChannelNum
1311)
1312{
1313   BXVD_Cmd             *pCmd;
1314   BXVD_Rsp             *pRsp;
1315
1316   BERR_Code        eStatus  = BERR_SUCCESS; /* Status return */
1317
1318   BXVD_Cmd_ChannelStop *pChStop;            /* Pointer to command  */
1319   BXVD_Rsp_ChannelStop *pChStopRsp;      /* Pointer to response */
1320
1321   BSTD_UNUSED(ulChannelNum);
1322
1323   /* Clear out the context and set defaults. */
1324   pCmd = &hXvd->FWCmd.cmd;
1325   pRsp = &hXvd->FWRsp.rsp;
1326   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1327   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1328
1329   pChStop = &hXvd->FWCmd.channelStop;
1330   pChStopRsp = &hXvd->FWRsp.channelStop;
1331
1332   /* Command ID */
1333   pChStop->command = BXVD_CMD_CHANNELSTOP;
1334   pChStop->channel_number = ulChannelNum;
1335
1336   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CHANNELSTOP:"));
1337   BXVD_DBG_MSG(hXvd, (" command: %#x", pChStop->command));
1338   BXVD_DBG_MSG(hXvd, (" channel_number: %d", pChStop->channel_number));
1339
1340   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd, 
1341                                                  hXvd->uDecoderInstance,
1342                                                  pCmd,
1343                                                  pRsp,
1344                                                  FW_CMD_TIMEOUT_NORMAL));
1345
1346   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CHANNELSTOP:"));
1347   BXVD_DBG_MSG(hXvd, (" command: %#x", pChStopRsp->command));
1348   BXVD_DBG_MSG(hXvd, (" status: %#x", pChStopRsp->status));           
1349   
1350   return BERR_TRACE(eStatus);
1351}
1352
1353/***************************************************************************
1354 *      {secret}
1355 *      BXVD_P_HostCmdSetSkipPictureMode
1356 ***************************************************************************/
1357BERR_Code BXVD_P_HostCmdSetSkipPictureMode
1358(
1359   BXVD_Handle    hXvd,
1360   uint32_t       ulChannelNum,
1361   BXVD_SkipMode  eSkipMode
1362)
1363{
1364   BERR_Code        eStatus = BERR_SUCCESS;
1365   BXVD_Cmd             *pCmd;
1366   BXVD_Rsp             *pRsp;
1367
1368   BXVD_Cmd_ChannelSpeed *pChanSpeed;
1369   BXVD_Rsp_ChannelSpeed *pChanSpeedRsp;
1370
1371   /* Clear out the context and set defaults. */
1372   pCmd = &hXvd->FWCmd.cmd;
1373   pRsp = &hXvd->FWRsp.rsp;
1374   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1375   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1376
1377   pChanSpeed = &hXvd->FWCmd.channelSpeed;
1378   pChanSpeedRsp = &hXvd->FWRsp.channelSpeed;
1379
1380   pChanSpeed->command = BXVD_CMD_CHANNELSPEED;
1381   pChanSpeed->channel_number = ulChannelNum;
1382
1383   /*
1384    * Map XVD skip modes to values used by the firmware.
1385    */
1386
1387   switch(eSkipMode)
1388   {
1389      case BXVD_SkipMode_eDecode_I_Only:
1390         pChanSpeed->speed = VDEC_SPEED_IONLY;   
1391         break;
1392      case BXVD_SkipMode_eDecode_IP_Only:
1393         pChanSpeed->speed = VDEC_SPEED_IPONLY; 
1394         break;
1395      case BXVD_SkipMode_eDecode_IPB:
1396         pChanSpeed->speed = VDEC_SPEED_NORMAL; 
1397         break;
1398      case BXVD_SkipMode_eDecode_Ref_Only:
1399         pChanSpeed->speed = VDEC_SPEED_REFONLY; 
1400         break;
1401      default:
1402         return BERR_TRACE(BERR_INVALID_PARAMETER);
1403   };
1404
1405   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_CHANNELSPEED:"));
1406   BXVD_DBG_MSG(hXvd, (" command: %#x", pChanSpeed->command));
1407   BXVD_DBG_MSG(hXvd, (" channel_number: %d", pChanSpeed->channel_number));
1408   BXVD_DBG_MSG(hXvd, (" speed: %d", pChanSpeed->speed));
1409
1410   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd,
1411                                                  hXvd->uDecoderInstance,
1412                                                  pCmd,
1413                                                  pRsp,
1414                                                  FW_CMD_TIMEOUT_NORMAL));
1415
1416   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_CHANNELSPEED:"));
1417   BXVD_DBG_MSG(hXvd, (" command: %#x", pChanSpeedRsp->command));
1418   BXVD_DBG_MSG(hXvd, (" status: %#x", pChanSpeedRsp->status));           
1419
1420   return BERR_TRACE(eStatus);
1421}
1422
1423
1424/***************************************************************************
1425 *  Summary
1426 *
1427 *     BXVD_P_HostCmdDramLogControl: Send debug log control command
1428 *
1429 *  Description
1430 *
1431 *     The decoders outer loop debug output can be loggef to memory for XVD
1432 *     to read and pass to the application. This routines starts and stops
1433 *     the logging of the debug data to the log buffer.
1434 *
1435 ***************************************************************************/
1436BERR_Code BXVD_P_HostCmdDbgLogControl
1437(
1438   BXVD_Handle    hXvd,
1439   bool           logStart
1440)
1441{
1442   BERR_Code        eStatus = BERR_SUCCESS;
1443   BXVD_Cmd             *pCmd;
1444   BXVD_Rsp             *pRsp;
1445
1446   BXVD_Cmd_DbgLogControl *pDbgLog;
1447   BXVD_Rsp_DbgLogControl *pDbgLogRsp;
1448
1449   /* Clear out the context and set defaults. */
1450   pCmd = &hXvd->FWCmd.cmd;
1451   pRsp = &hXvd->FWRsp.rsp;
1452   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1453   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1454
1455   pDbgLog = &hXvd->FWCmd.dbgLogControl;
1456   pDbgLogRsp = &hXvd->FWRsp.dbgLogControl;
1457
1458   pDbgLog->command = BXVD_CMD_DBGLOGCONTROL;
1459   pDbgLog->logStart = (uint32_t) logStart;
1460
1461   pDbgLog->dbglog_memory_base = hXvd->uiDecoderDbgBufPhyAddr;
1462   pDbgLog->dbglog_memory_size = hXvd->stSettings.uiDecoderDebugLogBufferSize;
1463
1464
1465   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_DBGLogControl:"));
1466   BXVD_DBG_MSG(hXvd, (" command: %#x", pDbgLog->command));
1467   BXVD_DBG_MSG(hXvd, (" logStart: %d", pDbgLog->logStart));
1468   BXVD_DBG_MSG(hXvd, (" dbglog_mem_base: %08x", pDbgLog->dbglog_memory_base));
1469   BXVD_DBG_MSG(hXvd, (" dbglog_mem_size: %08x", pDbgLog->dbglog_memory_size));
1470
1471   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd,
1472                                                  hXvd->uDecoderInstance,
1473                                                  pCmd,
1474                                                  pRsp,
1475                                                  FW_CMD_TIMEOUT_NORMAL));
1476
1477   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_DbgLogControl"));
1478   BXVD_DBG_MSG(hXvd, (" command: %#x", pDbgLogRsp->command));
1479   BXVD_DBG_MSG(hXvd, (" status: %#x", pDbgLogRsp->status));           
1480
1481   return BERR_TRACE(eStatus);
1482}
1483
1484
1485/***************************************************************************
1486 *  Summary
1487 *
1488 *     BXVD_P_HostCmdDbgLogCommand: Send debug command
1489 *
1490 *  Description
1491 *
1492 *     The decoders outer loop will process debug command, the output for
1493 *     the command is written to the debug log buffer. This routine sends
1494 *     the outer loop the debug command string.
1495 *
1496 ***************************************************************************/
1497BERR_Code BXVD_P_HostCmdDbgLogCommand
1498(
1499   BXVD_Handle    hXvd,
1500   char           *pCommand
1501)
1502{
1503   BERR_Code        eStatus = BERR_SUCCESS;
1504   BXVD_Cmd             *pCmd;
1505   BXVD_Rsp             *pRsp;
1506
1507   BXVD_Cmd_DbgLogCommand *pDbgCmd;
1508   BXVD_Rsp_DbgLogCommand *pDbgCmdRsp;
1509
1510#if BSTD_CPU_ENDIAN == BSTD_ENDIAN_BIG
1511   int32_t  len, i;
1512   uint32_t *pTmpCmd, *pTmpLogCmd;
1513#endif
1514
1515   /* Clear out the context and set defaults. */
1516   pCmd = &hXvd->FWCmd.cmd;
1517   pRsp = &hXvd->FWRsp.rsp;
1518   BKNI_Memset((void*)pCmd, BXVD_P_MEM_ZERO, sizeof(BXVD_Cmd));
1519   BKNI_Memset((void*)pRsp, BXVD_P_MEM_ZERO, sizeof(BXVD_Rsp));
1520
1521   pDbgCmd = &hXvd->FWCmd.dbgLogCommand;
1522   pDbgCmdRsp = &hXvd->FWRsp.dbgLogCommand;
1523
1524   pDbgCmd->command = BXVD_CMD_DBGLOGCOMMAND;
1525
1526#if BSTD_CPU_ENDIAN == BSTD_ENDIAN_LITTLE
1527   BKNI_Memcpy(&pDbgCmd->logCmd[0], pCommand, sizeof(pDbgCmd->logCmd));
1528#else
1529   len = _strlen(pCommand)/4;
1530
1531   pTmpCmd = (uint32_t *)pCommand;
1532   pTmpLogCmd = (uint32_t *)&pDbgCmd->logCmd[0];
1533
1534   for ( i = 0 ; i <= len ; i++ ) 
1535   {
1536      *pTmpLogCmd = BXVD_P_SWAP32(*pTmpCmd);
1537      pTmpCmd++;
1538      pTmpLogCmd++;
1539   }
1540#endif
1541
1542   BXVD_DBG_MSG(hXvd, ("BXVD_CMD_Dbg_LOG_CMD:"));
1543   BXVD_DBG_MSG(hXvd, (" command: %#x", pDbgCmd->command));
1544   BXVD_DBG_MSG(hXvd, (" logCmd: %s", &pDbgCmd->logCmd[0]));
1545
1546   eStatus = BERR_TRACE(BXVD_P_SendDecoderCommand(hXvd,
1547                                                  hXvd->uDecoderInstance,
1548                                                  pCmd,
1549                                                  pRsp,
1550                                                  FW_CMD_TIMEOUT_DEBUGCMD));
1551
1552   BXVD_DBG_MSG(hXvd, ("BXVD_RSP_DbgLogCommand"));
1553   BXVD_DBG_MSG(hXvd, (" command: %#x", pDbgCmdRsp->command));
1554   BXVD_DBG_MSG(hXvd, (" status: %#x", pDbgCmdRsp->status));           
1555
1556   return BERR_TRACE(eStatus);
1557}
1558
1559/* End of File */
Note: See TracBrowser for help on using the repository browser.