1/*
2* Copyright (c) 2011 Intel Corporation. All Rights Reserved.
3* Copyright (c) Imagination Technologies Limited, UK
4*
5* Permission is hereby granted, free of charge, to any person obtaining a
6* copy of this software and associated documentation files (the
7* "Software"), to deal in the Software without restriction, including
8* without limitation the rights to use, copy, modify, merge, publish,
9* distribute, sub license, and/or sell copies of the Software, and to
10* permit persons to whom the Software is furnished to do so, subject to
11* the following conditions:
12*
13* The above copyright notice and this permission notice (including the
14* next paragraph) shall be included in all copies or substantial portions
15* of the Software.
16*
17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
20* IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24*
25*/
26#include <stdio.h>
27#include <unistd.h>
28#include <sys/mman.h>
29#include <sys/types.h>
30#include <sys/stat.h>
31#include <fcntl.h>
32#include <stdarg.h>
33
34#ifdef PDUMP_TEST
35#include "topazscfwif.h"
36#else
37#include "psb_drv_debug.h"
38#include "tng_hostcode.h"
39#include "tng_hostheader.h"
40#include "tng_picmgmt.h"
41#include "tng_jpegES.h"
42#endif
43
44#include "tng_trace.h"
45
46#define PRINT_ARRAY_NEW( FEILD, NUM)            \
47    for(i=0;i< NUM;i++) {                       \
48        if(i%6==0)                              \
49            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t");                   \
50        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t0x%x", data->FEILD[i]); } \
51    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t}\n");
52
53#define PRINT_ARRAY_INT( FEILD, NUM)            \
54do {                                            \
55    int tmp;                                    \
56                                                \
57    for(tmp=0;tmp< NUM;tmp++) {                 \
58        if(tmp%6==0)                            \
59            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t");                   \
60        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t0x%08x", FEILD[tmp]);         \
61    }                                           \
62    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t}\n");                        \
63} while (0)
64
65
66#define PRINT_ARRAY_BYTE( FEILD, NUM)           \
67do {                                            \
68    int tmp;                                    \
69                                                \
70    for(tmp=0;tmp< NUM;tmp++) {                 \
71        if(tmp%8==0)                           \
72            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t");                   \
73        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t0x%02x", FEILD[tmp]);         \
74    }                                           \
75    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t}\n");                        \
76} while (0)
77
78
79/*
80#define PRINT_ARRAY( FEILD, NUM)                \
81    for(i=0;i< NUM;i++)                         \
82        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t0x%x", data->FEILD[i]);       \
83    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t}\n");
84*/
85
86#define PRINT_ARRAY( FEILD, NUM)  PRINT_ARRAY_NEW(FEILD, NUM)
87
88#define PRINT_ARRAY_ADDR(STR, FEILD, NUM)                       \
89do {                                                            \
90    int i = 0;                                                  \
91    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n");                                               \
92    for (i=0;i< NUM;i++)  {                                     \
93        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t%s[%02d]=x%08x = {\t", STR, i, data->FEILD[i]); \
94        if (dump_address_content && data->FEILD[i]) {           \
95            unsigned char *virt = phy2virt(data->FEILD[i]);     \
96            PRINT_ARRAY_BYTE( virt, 64);                        \
97        } else {                                                \
98            drv_debug_msg(VIDEO_ENCODE_PDUMP,"}\n");                                      \
99        }                                                       \
100    }                                                           \
101} while (0)
102
103
104unsigned int duplicate_setvideo_dump = 0;
105unsigned int dump_address_content = 1;
106static unsigned int last_setvideo_dump = 0;
107static unsigned int hide_setvideo_dump = 0;
108
109static unsigned int linear_fb = 0;
110static unsigned int linear_mmio_topaz = 0;
111static unsigned int phy_fb, phy_mmio;
112static IMG_MTX_VIDEO_CONTEXT *mtx_ctx = NULL; /* MTX context */
113
114static int setup_device()
115{
116    unsigned int linear_mmio;
117    int fd;
118
119    /* Allow read/write to ALL io ports */
120    ioperm(0, 1024, 1);
121    iopl(3);
122
123    phy_mmio = pci_get_long(1,0<<3, PCI_BASE_ADDRESS_1);
124    drv_debug_msg(VIDEO_ENCODE_PDUMP,"MMIO:  PCI base1 for MMIO is 0x%08x\n", phy_mmio);
125    phy_fb = pci_get_long(1,0<<3, PCI_BASE_ADDRESS_2);
126    drv_debug_msg(VIDEO_ENCODE_PDUMP,"DDRM:  PCI base2 for FB   is 0x%08x\n", phy_fb);
127
128    phy_mmio &= 0xfff80000;
129    phy_fb &= 0xfffff000;
130
131    fd = open("/dev/mem", O_RDWR);
132    if (fd == -1) {
133        perror("open");
134        exit(-1);
135    }
136
137    /* map frame buffer to user space(map 128M) */
138    linear_fb = (unsigned int)mmap(NULL,128<<20,PROT_READ | PROT_WRITE,
139                             MAP_SHARED,fd, phy_fb);
140
141    /* map mmio to user space(1M) */
142    linear_mmio = (unsigned int)mmap(NULL,0x100000,PROT_READ | PROT_WRITE,
143                              MAP_SHARED,fd, phy_mmio);
144    linear_mmio_topaz = linear_mmio;
145
146    close(fd);
147
148    return 0;
149}
150
151/* convert physicall address to virtual by search MMU */
152static void *phy2virt_mmu(unsigned int phyaddr)
153{
154    unsigned int fb_start, fb_end;
155    int pd_index, pt_index, pg_offset;
156    unsigned int pd_phyaddr, pt_phyaddr; /* phyaddrss of page directory/table */
157    unsigned int mem_start; /* memory start physicall address */
158    unsigned int *pd, *pt;/* virtual of page directory/table */
159    void *mem_virt;
160
161    if (phy_mmio == 0 || phy_fb == 0 || linear_fb == 0 || linear_mmio_topaz == 0) {
162        setup_device();
163    }
164#ifdef _TOPAZHP_DEBUG_TRACE_
165    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: phy_mmio 0x%08x, phy_fb 0x%08x, linear_fb 0x%08x, linear_mmio_topaz 0x%08x\n", phy_mmio, phy_fb, linear_fb, linear_mmio_topaz);
166#endif
167
168    if (phy_mmio == 0 || phy_fb == 0 || linear_fb == 0 || linear_mmio_topaz == 0) {
169        drv_debug_msg(VIDEO_ENCODE_PDUMP,"ERROR:setup_device failed!\n");
170        exit(-1);
171    }
172#ifdef _TOPAZHP_DEBUG_TRACE_
173    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: phy_mmio 0x%08x, phy_fb 0x%08x, linear_fb 0x%08x, linear_mmio_topaz 0x%08x\n", phy_mmio, phy_fb, linear_fb, linear_mmio_topaz);
174#endif
175
176    /* first map page directory */
177    MULTICORE_READ32(REGNUM_TOPAZ_CR_MMU_DIR_LIST_BASE_ADDR, &pd_phyaddr);
178#ifdef _TOPAZHP_DEBUG_TRACE_
179    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: page directory 0x%08x, phy addr is 0x%08x\n", pd_phyaddr, phyaddr);
180#endif
181
182    pd_phyaddr &= 0xfffff000;
183    fb_start = phy_fb;
184    fb_end = fb_start + (128<<20);
185#ifdef _TOPAZHP_DEBUG_TRACE_
186    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: pd_phyaddr 0x%08x, fb_start 0x%08x, fb_end 0x%08x\n", pd_phyaddr, fb_start, fb_end);
187#endif
188
189    if ((pd_phyaddr < fb_start) || (pd_phyaddr > fb_end)) {
190        drv_debug_msg(VIDEO_ENCODE_PDUMP,"ERROR: page directory 0x%08x is not fb range [0x%08x, 0x%08x]\n",
191               pd_phyaddr, fb_start, fb_end);
192        exit(-1);
193    }
194
195    pd_index = phyaddr >> 22; /* the top 10bits are pd index */
196    pt_index = (phyaddr >> 12) & 0x3ff; /* the middle 10 bits are pt index */
197    pg_offset = phyaddr & 0xfff;
198#ifdef _TOPAZHP_DEBUG_TRACE_
199    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: phyaddr 0x%08x, pd_index 0x%08x, pt_index 0x%08x, pg_offset 0x%08x\n", phyaddr, pd_index, pt_index, pg_offset);
200#endif
201
202    /* find page directory entry */
203    pd = (unsigned int *)(linear_fb + (pd_phyaddr - phy_fb));
204#ifdef _TOPAZHP_DEBUG_TRACE_
205    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: pd_index 0x%08x, pd 0x%08x, pd[pd_index] 0x%08x\n", pd_index, pd, pd[pd_index]);
206#endif
207    if ((pd[pd_index] & 1) == 0) {/* not valid */
208        drv_debug_msg(VIDEO_ENCODE_PDUMP,"Error: the page directory index is invalid, not mapped\n");
209        exit(-1);
210    }
211    pt_phyaddr = pd[pd_index] & 0xfffff000;
212
213    /* process page table entry */
214    if ((pt_phyaddr < fb_start) || (pt_phyaddr > fb_end)) {
215        drv_debug_msg(VIDEO_ENCODE_PDUMP,"ERROR: page table 0x%08x is not fb range [0x%08x, 0x%08x]\n",
216               pt_phyaddr, fb_start, fb_end);
217        exit(-1);
218    }
219    pt = (unsigned int *)(linear_fb + (pt_phyaddr - phy_fb));
220#ifdef _TOPAZHP_DEBUG_TRACE_
221    drv_debug_msg(VIDEO_ENCODE_PDUMP,"INFO: pt_index 0x%08x, pt 0x%08x, pt[pt_index] 0x%08x\n", pt_index, pt, pt[pt_index]);
222#endif
223    if ((pt[pt_index] & 1) == 0) {
224        drv_debug_msg(VIDEO_ENCODE_PDUMP,"Error: the page table index is invalid, not mapped\n");
225        exit(-1);
226    }
227
228    mem_start = pt[pt_index] & 0xfffff000;
229
230#if 0
231    drv_debug_msg(VIDEO_ENCODE_PDUMP,"Phy=0x%08x(PD index=%d, PT index=%d, Page offset=%d)\n",
232           phyaddr, pd_index, pt_index, pg_offset);
233    drv_debug_msg(VIDEO_ENCODE_PDUMP,"MMU PD Phy=0x%08x, PT Phy=PD[%d]=0x%08x, PT[%d]=0x%08x, means mem real phy(start)=0x%08x\n",
234           pd_phyaddr, pd_index, pd[pd_index], pt_index, pt[pt_index], mem_start);
235#endif
236    mem_virt = (void *)(linear_fb + (mem_start - phy_fb));
237
238    return mem_virt;
239}
240
241static void *phy2virt(unsigned int phyaddr)
242{
243#ifdef PDUMP_TEST
244    void* phy2virt_pdump(unsigned int phy);
245
246    (void)phy2virt_mmu; /* silence the warning */
247    return phy2virt_pdump(phyaddr);
248#else
249    return phy2virt_mmu(phyaddr);
250#endif
251}
252
253
254static void JPEG_MTX_DMA_dump(JPEG_MTX_DMA_SETUP *data)
255{
256    int i;
257    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ComponentPlane{\n");
258    for(i=0;i<MTX_MAX_COMPONENTS ;i++)
259    {
260        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\t   ui32PhysAddr=%d\n",data->ComponentPlane[i].ui32PhysAddr);
261        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t   ui32Stride=%d",data->ComponentPlane[i].ui32Stride);
262        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t   ui32Height=%d\n",data->ComponentPlane[i].ui32Height);
263    }
264    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	}\n");
265    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	MCUComponent{\n");
266    for(i=0;i<MTX_MAX_COMPONENTS ;i++)
267    {
268        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\t   ui32WidthBlocks=%d",data->MCUComponent[i].ui32WidthBlocks);
269        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t   ui32HeightBlocks=%d",data->MCUComponent[i].ui32HeightBlocks);
270        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t   ui32XLimit=%d\n",data->MCUComponent[i].ui32XLimit);
271        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t   ui32YLimit=%d\n",data->MCUComponent[i].ui32YLimit);
272    }
273    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	}\n");
274    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui32ComponentsInScan =%d\n", data->ui32ComponentsInScan);
275    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui32TableA =%d\n", data->ui32TableA);
276    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16DataInterleaveStatus =%d\n", data->ui16DataInterleaveStatus);
277    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16MaxPipes =%d\n", data->ui16MaxPipes);
278    //drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	apWritebackRegions  {");
279    //PRINT_ARRAY(	apWritebackRegions, WB_FIFO_SIZE);
280}
281
282static void ISSUE_BUFFER_dump(MTX_ISSUE_BUFFERS *data)
283{
284    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui32MCUPositionOfScanAndPipeNo =%d\n", data->ui32MCUPositionOfScanAndPipeNo);
285    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui32MCUCntAndResetFlag =%d\n", data->ui32MCUCntAndResetFlag);
286}
287
288static void JPEG_TABLE_dump(JPEG_MTX_QUANT_TABLE *data)
289{
290    int i;
291    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	aui8LumaQuantParams  {");
292    PRINT_ARRAY(	aui8LumaQuantParams, QUANT_TABLE_SIZE_BYTES);
293    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	aui8ChromaQuantParams  {");
294    PRINT_ARRAY(	aui8ChromaQuantParams, QUANT_TABLE_SIZE_BYTES);
295}
296
297
298static int SETVIDEO_ui32MVSettingsBTable_dump(unsigned int phyaddr)
299{
300    IMG_UINT32 ui32DistanceB, ui32Position;
301    IMG_MV_SETTINGS * pHostMVSettingsBTable;
302
303    pHostMVSettingsBTable = (IMG_MV_SETTINGS *) phy2virt(phyaddr);
304    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32MVSettingsBTable====)\n");
305
306    for (ui32DistanceB = 0; ui32DistanceB < MAX_BFRAMES; ui32DistanceB++)
307    {
308        for (ui32Position = 1; ui32Position <= ui32DistanceB + 1; ui32Position++)
309        {
310            IMG_MV_SETTINGS * pMvElement = (IMG_MV_SETTINGS * ) ((IMG_UINT8 *) pHostMVSettingsBTable + MV_OFFSET_IN_TABLE(ui32DistanceB, ui32Position - 1));
311            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d][ui32Position=%d].ui32MVCalc_Config=0x%08x\n",
312                   ui32DistanceB, ui32Position, pMvElement->ui32MVCalc_Config);
313            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d][ui32Position=%d].ui32MVCalc_Colocated=0x%08x\n",
314                   ui32DistanceB, ui32Position, pMvElement->ui32MVCalc_Colocated);
315            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d][ui32Position=%d].ui32MVCalc_Below=0x%08x\n",
316                   ui32DistanceB, ui32Position, pMvElement->ui32MVCalc_Below);
317        }
318    }
319    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32MVSettingsBTable====)\n");
320
321    return 0;
322}
323
324static int SETVIDEO_ui32MVSettingsHierarchical_dump(unsigned int phyaddr)
325{
326    IMG_UINT32 ui32DistanceB;
327    IMG_MV_SETTINGS * pHostMVSettingsHierarchical;
328
329    pHostMVSettingsHierarchical = (IMG_MV_SETTINGS *) phy2virt(phyaddr);
330
331    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32MVSettingsHierarchical====)\n");
332
333    for (ui32DistanceB = 0; ui32DistanceB < MAX_BFRAMES; ui32DistanceB++) {
334        IMG_MV_SETTINGS *pMvElement = pHostMVSettingsHierarchical + ui32DistanceB;
335
336        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d].ui32MVCalc_Config=0x%08x\n",
337               ui32DistanceB, pMvElement->ui32MVCalc_Config);
338        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d].ui32MVCalc_Colocated=0x%08x\n",
339               ui32DistanceB, pMvElement->ui32MVCalc_Colocated);
340        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t[ui32DistanceB=%d].ui32MVCalc_Below=0x%08x\n",
341               ui32DistanceB, pMvElement->ui32MVCalc_Below);
342
343    }
344    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32MVSettingsHierarchical====)\n");
345
346    return 0;
347}
348
349
350static int SETVIDEO_ui32FlatGopStruct_dump(unsigned int phyaddr)
351{
352    IMG_UINT16 * psGopStructure = (IMG_UINT16 * )phy2virt(phyaddr);
353    int ui8EncodeOrderPos;
354
355    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32FlatGopStruct====)\n");
356
357    /* refer to DDK:MiniGop_GenerateFlat */
358    for (ui8EncodeOrderPos = 0; ui8EncodeOrderPos < MAX_GOP_SIZE; ui8EncodeOrderPos++){
359        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32FlatGopStruct[%d]=0x%04x\n",ui8EncodeOrderPos, psGopStructure[ui8EncodeOrderPos]);
360    }
361    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32FlatGopStruct====)\n");
362
363    return 0;
364}
365
366
367static int SETVIDEO_ui32HierarGopStruct_dump(unsigned int phyaddr)
368{
369    IMG_UINT16 * psGopStructure = (IMG_UINT16 * )phy2virt(phyaddr);
370    int ui8EncodeOrderPos;
371
372    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32HierarGopStruct====)\n");
373
374    /* refer to DDK:MiniGop_GenerateFlat */
375    for (ui8EncodeOrderPos = 0; ui8EncodeOrderPos < MAX_GOP_SIZE; ui8EncodeOrderPos++){
376        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32HierarGopStruct[%d]=0x%04x\n",ui8EncodeOrderPos, psGopStructure[ui8EncodeOrderPos]);
377    }
378    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(====ui32HierarGopStruct====)\n");
379
380    return 0;
381}
382
383
384static char *IMG_FRAME_TEMPLATE_TYPE2Str(IMG_FRAME_TEMPLATE_TYPE tmp)
385{
386    switch (tmp){
387    case IMG_FRAME_IDR:return "IMG_FRAME_IDR";
388    case IMG_FRAME_INTRA:return "IMG_FRAME_INTRA";
389    case IMG_FRAME_INTER_P:return "IMG_FRAME_INTER_P";
390    case IMG_FRAME_INTER_B:return "IMG_FRAME_INTER_B";
391    case IMG_FRAME_INTER_P_IDR:return "IMG_FRAME_INTER_P_IDR";
392    case IMG_FRAME_UNDEFINED:return "IMG_FRAME_UNDEFINED";
393    }
394
395    return "Undefined";
396}
397
398static int MTX_HEADER_PARAMS_dump(MTX_HEADER_PARAMS *p);
399static int apSliceParamsTemplates_dump(SLICE_PARAMS *p)
400{
401    unsigned char *ptmp = (unsigned char*)&p->sSliceHdrTmpl;
402    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32Flags=0x%08x\n", p->ui32Flags);
403    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32SliceConfig=0x%08x\n", p->ui32SliceConfig);
404    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32IPEControl=0x%08x\n", p->ui32IPEControl);
405    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32SeqConfig=0x%08x\n", p->ui32SeqConfig);
406    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\teTemplateType=%s\n", IMG_FRAME_TEMPLATE_TYPE2Str(p->eTemplateType));
407
408    //PRINT_ARRAY_BYTE(ptmp, 64);
409
410    MTX_HEADER_PARAMS_dump(&p->sSliceHdrTmpl);
411
412    return 0;
413}
414
415static int DO_HEADER_dump(MTX_HEADER_PARAMS *data)
416{
417    MTX_HEADER_PARAMS *p = data;
418    unsigned char *q=(unsigned char *)data;
419
420    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t(===RawBits===)");
421    PRINT_ARRAY_BYTE(q, 128);
422
423    MTX_HEADER_PARAMS_dump(p);
424
425    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\n");
426
427    return 0;
428}
429
430static void SETVIDEO_dump(IMG_MTX_VIDEO_CONTEXT *data)
431{
432    unsigned int i;
433    mtx_ctx = data;
434
435    if(hide_setvideo_dump == 1)
436        return ;
437    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t==========IMG_MTX_VIDEO_CONTEXT=============\n");
438    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui64ClockDivBitrate=%lld\n", data->ui64ClockDivBitrate);
439    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32WidthInMbs=%d\n", data->ui32WidthInMbs);
440    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PictureHeightInMbs=%d\n", data->ui32PictureHeightInMbs);
441#ifdef FORCED_REFERENCE
442    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apTmpReconstructured  {");
443    PRINT_ARRAY_ADDR("apTmpReconstructured",	apTmpReconstructured, MAX_PIC_NODES);
444#endif
445    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apReconstructured  {");
446    PRINT_ARRAY_ADDR("apReconstructured",	apReconstructured, MAX_PIC_NODES);
447    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apColocated  {");
448    PRINT_ARRAY_ADDR("apColocated",	apColocated, MAX_PIC_NODES);
449    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apMV  {");
450    PRINT_ARRAY_ADDR("apMV",	apMV, MAX_MV);
451    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apInterViewMV  {");
452//    PRINT_ARRAY(	apInterViewMV, 2 );
453    PRINT_ARRAY_ADDR("apInterViewMV", apInterViewMV, 2);
454
455    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32DebugCRCs=0x%x\n", data->ui32DebugCRCs);
456    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apWritebackRegions  {");
457    PRINT_ARRAY_ADDR("apWritebackRegions",	apWritebackRegions, WB_FIFO_SIZE);
458    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32InitialCPBremovaldelayoffset=0x%x\n", data->ui32InitialCPBremovaldelayoffset);
459    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32MaxBufferMultClockDivBitrate=0x%x\n", data->ui32MaxBufferMultClockDivBitrate);
460    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	pSEIBufferingPeriodTemplate=0x%x\n", data->pSEIBufferingPeriodTemplate);
461    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	pSEIPictureTimingTemplate=0x%x\n", data->pSEIPictureTimingTemplate);
462    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b16EnableMvc=%d\n", data->b16EnableMvc);
463    //drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b16EnableInterViewReference=%d\n", data->b16EnableInterViewReference);
464    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui16MvcViewIdx=0x%x\n", data->ui16MvcViewIdx);
465
466    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apSliceParamsTemplates  {\n");
467    //PRINT_ARRAY_ADDR( apSliceParamsTemplates, 5);
468    for (i=0; i<5; i++) {
469        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tapSliceParamsTemplates[%d]=0x%08x  {\n", i, data->apSliceParamsTemplates[i]);
470        apSliceParamsTemplates_dump(phy2virt(data->apSliceParamsTemplates[i]));
471        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t}\n");
472    }
473
474    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apPicHdrTemplates  {");
475    PRINT_ARRAY_ADDR("apPicHdrTemplates", apPicHdrTemplates, 4);
476    MTX_HEADER_PARAMS_dump(phy2virt(data->apPicHdrTemplates[0]));
477    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32SliceMap  {");
478    PRINT_ARRAY_ADDR("aui32SliceMap", 	aui32SliceMap, MAX_SOURCE_SLOTS_SL);
479
480    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32FlatGopStruct=0x%x\n", data->ui32FlatGopStruct);
481    SETVIDEO_ui32FlatGopStruct_dump(data->ui32FlatGopStruct);
482
483    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apSeqHeader        =0x%x\n", data->apSeqHeader);
484    if (data->apSeqHeader != 0)
485	DO_HEADER_dump((MTX_HEADER_PARAMS *)(phy2virt(data->apSeqHeader)));
486    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apSubSetSeqHeader  =0x%x\n", data->apSubSetSeqHeader);
487    if(data->apSubSetSeqHeader != 0)
488        DO_HEADER_dump((MTX_HEADER_PARAMS *)(phy2virt(data->apSubSetSeqHeader)));
489    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b16NoSequenceHeaders =0x%x\n", data->b16NoSequenceHeaders);
490
491    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8WeightedPredictionEnabled=%d\n", data->b8WeightedPredictionEnabled);
492    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8MTXWeightedImplicitBiPred=0x%x\n", data->ui8MTXWeightedImplicitBiPred);
493    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32WeightedPredictionVirtAddr  {");
494    PRINT_ARRAY(aui32WeightedPredictionVirtAddr, MAX_SOURCE_SLOTS_SL);
495    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32HierarGopStruct=0x%x\n", data->ui32HierarGopStruct);
496    if(data->ui32HierarGopStruct != 0)
497        SETVIDEO_ui32HierarGopStruct_dump(data->ui32HierarGopStruct);
498
499    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	pFirstPassOutParamAddr  {");
500    PRINT_ARRAY_ADDR("pFirstPassOutParamAddr",pFirstPassOutParamAddr, MAX_SOURCE_SLOTS_SL);
501#ifndef EXCLUDE_BEST_MP_DECISION_DATA
502    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	pFirstPassOutBestMultipassParamAddr  {");
503    PRINT_ARRAY_ADDR("pFirstPassOutBestMultipassParamAddr", pFirstPassOutBestMultipassParamAddr, MAX_SOURCE_SLOTS_SL);
504#endif
505    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	pMBCtrlInParamsAddr  {");
506    PRINT_ARRAY_ADDR("pMBCtrlInParamsAddr", pMBCtrlInParamsAddr, MAX_SOURCE_SLOTS_SL);
507    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32InterIntraScale{");
508    PRINT_ARRAY( ui32InterIntraScale, SCALE_TBL_SZ);
509    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32SkippedCodedScale  {");
510    PRINT_ARRAY( ui32SkippedCodedScale, SCALE_TBL_SZ);
511
512
513    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PicRowStride=0x%x\n", data->ui32PicRowStride);
514
515    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	apAboveParams  {");
516    PRINT_ARRAY_ADDR("apAboveParams", apAboveParams, TOPAZHP_NUM_PIPES);
517
518    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32IdrPeriod =0x%x\n ", data->ui32IdrPeriod);
519    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32IntraLoopCnt =0x%x\n", data->ui32IntraLoopCnt);
520    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32BFrameCount =0x%x\n", data->ui32BFrameCount);
521    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8Hierarchical=%d\n", data->b8Hierarchical);
522    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8MPEG2IntraDCPrecision =0x%x\n", data->ui8MPEG2IntraDCPrecision);
523
524    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui8PicOnLevel  {");
525    PRINT_ARRAY(aui8PicOnLevel, MAX_REF_LEVELS);
526    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32VopTimeResolution=0x%x\n", data->ui32VopTimeResolution);
527    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32InitialQp=0x%x\n", data->ui32InitialQp);
528    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32BUSize=0x%x\n", data->ui32BUSize);
529    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	sMVSettingsIdr { \n\t\t\tui32MVCalc_Below=0x%x\n \t\t\tui32MVCalc_Colocated=0x%x\n \t\t\tui32MVCalc_Config=0x%x\n \t\t}\n", data->sMVSettingsIdr.ui32MVCalc_Below,data->sMVSettingsIdr.ui32MVCalc_Colocated, data->sMVSettingsIdr.ui32MVCalc_Config);
530
531    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	sMVSettingsNonB { \n");
532    for(i=0;i<MAX_BFRAMES +1;i++)
533        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\tui32MVCalc_Below=0x%x   ui32MVCalc_Colocated=0x%x   ui32MVCalc_Config=0x%x }\n", data->sMVSettingsNonB[i].ui32MVCalc_Below,data->sMVSettingsNonB[i].ui32MVCalc_Colocated, data->sMVSettingsNonB[i].ui32MVCalc_Config);
534    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t}\n");
535
536    drv_debug_msg(VIDEO_ENCODE_PDUMP," \t	ui32MVSettingsBTable=0x%x\n", data->ui32MVSettingsBTable);
537    SETVIDEO_ui32MVSettingsBTable_dump(data->ui32MVSettingsBTable);
538
539    drv_debug_msg(VIDEO_ENCODE_PDUMP," \t	ui32MVSettingsHierarchical=0x%x\n", data->ui32MVSettingsHierarchical);
540    if(data->ui32MVSettingsHierarchical != 0)
541        SETVIDEO_ui32MVSettingsHierarchical_dump(data->ui32MVSettingsHierarchical);
542
543#ifdef FIRMWARE_BIAS
544    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32DirectBias_P  {");
545    PRINT_ARRAY_NEW(aui32DirectBias_P,27 );
546    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32InterBias_P  {");
547    PRINT_ARRAY_NEW(aui32InterBias_P,27 );
548    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32DirectBias_B  {");
549    PRINT_ARRAY_NEW(aui32DirectBias_B,27 );
550    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32InterBias_B  {");
551    PRINT_ARRAY_NEW(aui32InterBias_B,27 );
552#endif
553    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	eFormat=%d\n", data->eFormat);
554    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	eStandard=%d\n", data->eStandard);
555    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	eRCMode=%d\n", data->eRCMode);
556    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8FirstPic=%d\n", data->b8FirstPic);
557    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8IsInterlaced=%d\n", data->b8IsInterlaced);
558    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8TopFieldFirst=%d\n", data->b8TopFieldFirst);
559    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8ArbitrarySO=%d\n", data->b8ArbitrarySO);
560    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	bOutputReconstructed=%d\n", data->bOutputReconstructed);
561    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8DisableBitStuffing=%d\n", data->b8DisableBitStuffing);
562    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8InsertHRDparams=%d\n", data->b8InsertHRDparams);
563    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8MaxSlicesPerPicture=%d\n", data->ui8MaxSlicesPerPicture);
564    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8NumPipes=%d\n", data->ui8NumPipes);
565    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	bCARC=%d\n", data->bCARC);
566    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	iCARCBaseline=%d\n", data->iCARCBaseline);
567    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCThreshold=%d\n", data->uCARCThreshold);
568    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCCutoff=%d\n", data->uCARCCutoff);
569    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCNegRange=%d\n", data->uCARCNegRange);
570    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCNegScale=%d\n", data->uCARCNegScale);
571    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCPosRange=%d\n", data->uCARCPosRange);
572    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCPosScale=%d\n", data->uCARCPosScale);
573    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	uCARCShift=%d\n", data->uCARCShift);
574    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32MVClip_Config=%d\n", data->ui32MVClip_Config);
575    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PredCombControl=%d\n", data->ui32PredCombControl);
576    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32LRITC_Tile_Use_Config=%d\n", data->ui32LRITC_Tile_Use_Config);
577    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32LRITC_Cache_Chunk_Config=%d\n", data->ui32LRITC_Cache_Chunk_Config);
578    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32IPEVectorClipping=%d\n", data->ui32IPEVectorClipping);
579    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32H264CompControl=%d\n", data->ui32H264CompControl);
580    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32H264CompIntraPredModes=%d\n", data->ui32H264CompIntraPredModes);
581    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32IPCM_0_Config=%d\n", data->ui32IPCM_0_Config);
582    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32IPCM_1_Config=%d\n", data->ui32IPCM_1_Config);
583    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32SPEMvdClipRange=%d\n", data->ui32SPEMvdClipRange);
584    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32JMCompControl=%d\n", data->ui32JMCompControl);
585    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32MBHostCtrl=%d\n", data->ui32MBHostCtrl);
586    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32DeblockCtrl=%d\n", data->ui32DeblockCtrl);
587
588    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32SkipCodedInterIntra=%d\n", data->ui32SkipCodedInterIntra);
589    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32VLCControl=%d\n", data->ui32VLCControl);
590    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32VLCSliceControl=%d\n", data->ui32VLCSliceControl);
591    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32VLCSliceMBControl=%d\n", data->ui32VLCSliceMBControl);
592    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui16CQPOffset=%d\n", data->ui16CQPOffset);
593    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8CodedHeaderPerSlice=%d\n", data->b8CodedHeaderPerSlice);
594    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32FirstPicFlags=%d\n", data->ui32FirstPicFlags);
595    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32NonFirstPicFlags=%d\n", data->ui32NonFirstPicFlags);
596
597#ifndef EXCLUDE_ADAPTIVE_ROUNDING
598    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	bMCAdaptiveRoundingDisable=%d\n",data->bMCAdaptiveRoundingDisable);
599    int j;
600    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui16MCAdaptiveRoundingOffsets[18][4]");
601    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n");
602    for(i=0;i<18;i++){
603        for(j=0;j<4;j++)
604            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\t0x%x", data-> ui16MCAdaptiveRoundingOffsets[i][j]);
605        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n");
606    }
607#endif
608
609#ifdef FORCED_REFERENCE
610    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PatchedReconAddress=0x%x\n", data->ui32PatchedReconAddress);
611    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PatchedRef0Address=0x%x\n", data->ui32PatchedRef0Address);
612    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui32PatchedRef1Address=0x%x\n", data->ui32PatchedRef1Address);
613#endif
614#ifdef LTREFHEADER
615    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	aui32LTRefHeader  {");
616    PRINT_ARRAY_ADDR("aui32LTRefHeader",aui32LTRefHeader, MAX_SOURCE_SLOTS_SL);
617    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	i8SliceHeaderSlotNum=%d\n",data->i8SliceHeaderSlotNum);
618#endif
619    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8ReconIsLongTerm=%d\n", data->b8ReconIsLongTerm);
620    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8Ref0IsLongTerm=%d\n", data->b8Ref0IsLongTerm);
621    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	b8Ref1IsLongTerm=%d\n", data->b8Ref1IsLongTerm);
622    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8RefSpacing=0x%x\n", data->ui8RefSpacing);
623
624    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8FirstPipe=0x%x\n", data->ui8FirstPipe);
625    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8LastPipe=0x%x\n", data->ui8LastPipe);
626    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	ui8PipesToUseFlags=0x%x\n", data->ui8PipesToUseFlags);
627
628    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t	sInParams {\n");
629    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16MBPerFrm=%d\n",data->sInParams.ui16MBPerFrm);
630    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16MBPerBU=%d\n", data->sInParams.ui16MBPerBU);
631    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16BUPerFrm=%d\n",data->sInParams.ui16BUPerFrm);
632    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16IntraPerio=%d\n",data->sInParams.ui16IntraPeriod);
633    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16BFrames=%d\n", data->sInParams.ui16BFrames);
634    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	bHierarchicalMode=%d\n",data->sInParams.mode.h264.bHierarchicalMode);
635    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BitsPerFrm=%d\n",   data->sInParams.i32BitsPerFrm);
636    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BitsPerBU=%d\n",    data->sInParams.i32BitsPerBU);
637    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BitsPerMB=%d\n",    data->sInParams.mode.other.i32BitsPerMB);
638    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BitRate=%d\n",data->sInParams.i32BitRate);
639    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BufferSiz=%d\n",data->sInParams.i32BufferSize );
640    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32InitialLevel=%d\n", data->sInParams.i32InitialLevel);
641    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32InitialDelay=%d\n", data->sInParams.i32InitialDelay);
642    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32BitsPerGOP=%d\n",   data->sInParams.mode.other.i32BitsPerGOP);
643    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16AvQPVal=%d\n", data->sInParams.mode.other.ui16AvQPVal);
644    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui16MyInitQP=%d\n",data->sInParams.mode.other.ui16MyInitQP);
645    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui32RCScaleFactor=%d\n",data->sInParams.mode.h264.ui32RCScaleFactor);
646    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	bScDetectDis;=%d\n", data->sInParams.mode.h264.bScDetectDisable);
647    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	bFrmSkipDisable=%d\n",data->sInParams.bFrmSkipDisable);
648    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	bBUSkipDisable=%d\n",data->sInParams.mode.other.bBUSkipDisable);
649    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8SeInitQP=%d\n",    data->sInParams.ui8SeInitQP	);
650    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8MinQPVal=%d\n",    data->sInParams.ui8MinQPVal	);
651    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8MaxQPVal=%d\n",    data->sInParams.ui8MaxQPVal	);
652    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8MBPerRow=%d\n",    data->sInParams.ui8MBPerRow	);
653    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8ScaleFactor=%d\n",  data->sInParams.ui8ScaleFactor);
654    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8HalfFrame=%d\n",    data->sInParams.mode.other.ui8HalfFrameRate);
655    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	ui8FCode=%d\n",        data->sInParams.mode.other.ui8FCode);
656    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t	i32TransferRate=%d\n",data->sInParams.mode.h264.i32TransferRate);
657
658    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t}\n");
659}
660
661
662struct header_token {
663    int token;
664    char *str;
665} header_tokens[] = {
666    {ELEMENT_STARTCODE_RAWDATA,"ELEMENT_STARTCODE_RAWDATA=0"},
667    {ELEMENT_STARTCODE_MIDHDR,"ELEMENT_STARTCODE_MIDHDR"},
668    {ELEMENT_RAWDATA,"ELEMENT_RAWDATA"},
669    {ELEMENT_QP,"ELEMENT_QP"},
670    {ELEMENT_SQP,"ELEMENT_SQP"},
671    {ELEMENT_FRAMEQSCALE,"ELEMENT_FRAMEQSCALE"},
672    {ELEMENT_SLICEQSCALE,"ELEMENT_SLICEQSCALE"},
673    {ELEMENT_INSERTBYTEALIGN_H264,"ELEMENT_INSERTBYTEALIGN_H264"},
674    {ELEMENT_INSERTBYTEALIGN_MPG4,"ELEMENT_INSERTBYTEALIGN_MPG4"},
675    {ELEMENT_INSERTBYTEALIGN_MPG2,"ELEMENT_INSERTBYTEALIGN_MPG2"},
676    {ELEMENT_VBV_MPG2,"ELEMENT_VBV_MPG2"},
677    {ELEMENT_TEMPORAL_REF_MPG2,"ELEMENT_TEMPORAL_REF_MPG2"},
678    {ELEMENT_CURRMBNR,"ELEMENT_CURRMBNR"},
679    {ELEMENT_FRAME_NUM,"ELEMENT_FRAME_NUM"},
680    {ELEMENT_TEMPORAL_REFERENCE,"ELEMENT_TEMPORAL_REFERENCE"},
681    {ELEMENT_EXTENDED_TR,"ELEMENT_EXTENDED_TR"},
682    {ELEMENT_IDR_PIC_ID,"ELEMENT_IDR_PIC_ID"},
683    {ELEMENT_PIC_ORDER_CNT,"ELEMENT_PIC_ORDER_CNT"},
684    {ELEMENT_GOB_FRAME_ID,"ELEMENT_GOB_FRAME_ID"},
685    {ELEMENT_VOP_TIME_INCREMENT,"ELEMENT_VOP_TIME_INCREMENT"},
686    {ELEMENT_MODULO_TIME_BASE,"ELEMENT_MODULO_TIME_BASE"},
687    {ELEMENT_BOTTOM_FIELD,"ELEMENT_BOTTOM_FIELD"},
688    {ELEMENT_SLICE_NUM,"ELEMENT_SLICE_NUM"},
689    {ELEMENT_MPEG2_SLICE_VERTICAL_POS,"ELEMENT_MPEG2_SLICE_VERTICAL_POS"},
690    {ELEMENT_MPEG2_IS_INTRA_SLICE,"ELEMENT_MPEG2_IS_INTRA_SLICE"},
691    {ELEMENT_MPEG2_PICTURE_STRUCTURE,"ELEMENT_MPEG2_PICTURE_STRUCTURE"},
692    {ELEMENT_REFERENCE,"ELEMENT_REFERENCE"},
693    {ELEMENT_ADAPTIVE,"ELEMENT_ADAPTIVE"},
694    {ELEMENT_DIRECT_SPATIAL_MV_FLAG,"ELEMENT_DIRECT_SPATIAL_MV_FLAG"},
695    {ELEMENT_NUM_REF_IDX_ACTIVE,"ELEMENT_NUM_REF_IDX_ACTIVE"},
696    {ELEMENT_REORDER_L0,"ELEMENT_REORDER_L0"},
697    {ELEMENT_REORDER_L1,"ELEMENT_REORDER_L1"},
698    {ELEMENT_TEMPORAL_ID,"ELEMENT_TEMPORAL_ID"},
699    {ELEMENT_ANCHOR_PIC_FLAG,"ELEMENT_ANCHOR_PIC_FLAG"},
700    {BPH_SEI_NAL_INITIAL_CPB_REMOVAL_DELAY,"BPH_SEI_NAL_INITIAL_CPB_REMOVAL_DELAY"},
701    {BPH_SEI_NAL_INITIAL_CPB_REMOVAL_DELAY_OFFSET,"BPH_SEI_NAL_INITIAL_CPB_REMOVAL_DELAY_OFFSET"},
702    {PTH_SEI_NAL_CPB_REMOVAL_DELAY,"PTH_SEI_NAL_CPB_REMOVAL_DELAY"},
703    {PTH_SEI_NAL_DPB_OUTPUT_DELAY,"PTH_SEI_NAL_DPB_OUTPUT_DELAY"},
704    {ELEMENT_SLICEWEIGHTEDPREDICTIONSTRUCT,"ELEMENT_SLICEWEIGHTEDPREDICTIONSTRUCT"},
705    {ELEMENT_CUSTOM_QUANT,"ELEMENT_CUSTOM_QUANT"}
706};
707
708static char *header_to_str(int token)
709{
710    int i;
711    struct header_token *p;
712
713    for (i=0; i<sizeof(header_tokens)/sizeof(struct header_token); i++) {
714        p = &header_tokens[i];
715        if (p->token == token)
716            return p->str;
717    }
718
719    return "Invalid header token";
720}
721
722static int MTX_HEADER_PARAMS_dump(MTX_HEADER_PARAMS *p)
723{
724    MTX_HEADER_ELEMENT *last_element=NULL;
725    int i;
726
727    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32Elements=%d\n", p->ui32Elements);
728    for (i=0; i<p->ui32Elements; i++) {
729        MTX_HEADER_ELEMENT *q = &(p->asElementStream[0]);
730
731        if (last_element) {
732            int ui8Offset = 0;
733            IMG_UINT8 *ui8P;
734
735            if (last_element->Element_Type==ELEMENT_STARTCODE_RAWDATA ||
736                last_element->Element_Type==ELEMENT_RAWDATA ||
737                last_element->Element_Type==ELEMENT_STARTCODE_MIDHDR)
738            {
739                //Add a new element aligned to word boundary
740                //Find RAWBit size in bytes (rounded to word boundary))
741                ui8Offset=last_element->ui8Size+8+31; // NumberofRawbits (excluding size of bit count field)+ size of the bitcount field
742                ui8Offset/=32; //Now contains rawbits size in words
743                ui8Offset+=1; //Now contains rawbits+element_type size in words
744                ui8Offset*=4; //Convert to number of bytes (total size of structure in bytes, aligned to word boundary).
745            }
746            else
747            {
748                ui8Offset=4;
749            }
750            ui8P=(IMG_UINT8 *) last_element;
751            ui8P+=ui8Offset;
752            q=(MTX_HEADER_ELEMENT *) ui8P;
753        }
754
755        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t----Head %d----\n",i);
756        drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\tElement_Type=%d(0x%x:%s)\n",
757               q->Element_Type, q->Element_Type, header_to_str(q->Element_Type));
758
759        if (q->Element_Type==ELEMENT_STARTCODE_RAWDATA ||
760            q->Element_Type==ELEMENT_RAWDATA ||
761            q->Element_Type==ELEMENT_STARTCODE_MIDHDR) {
762            int i, ui8Offset = 0;
763            IMG_UINT8 *ui8P;
764
765            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\tui8Size=%d(0x%x)\n", q->ui8Size, q->ui8Size);
766            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\t(====aui8Bits===)");
767
768            //Find RAWBit size in bytes (rounded to word boundary))
769            ui8Offset=q->ui8Size+8+31; // NumberofRawbits (excluding size of bit count field)+ size of the bitcount field
770            ui8Offset/=32; //Now contains rawbits size in words
771            //ui8Offset+=1; //Now contains rawbits+element_type size in words
772            ui8Offset*=4; //Convert to number of bytes (total size of structure in bytes, aligned to word boundar
773
774            ui8P = &q->aui8Bits;
775            for (i=0; i<ui8Offset; i++) {
776                if ((i%8) == 0)
777                    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\t\t\t");
778                drv_debug_msg(VIDEO_ENCODE_PDUMP,"0x%02x\t", *ui8P);
779                ui8P++;
780            }
781            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n");
782        } else {
783            drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\t\t(no ui8Size/aui8Bits for this type header)\n");
784        }
785
786        last_element = q;
787    }
788
789    return 0;
790}
791
792static char *eBufferType2str(IMG_REF_BUFFER_TYPE tmp)
793{
794    switch (tmp) {
795    case IMG_BUFFER_REF0:
796        return "IMG_BUFFER_REF0";
797    case IMG_BUFFER_REF1:
798        return "IMG_BUFFER_REF1";
799    case IMG_BUFFER_RECON:
800        return "IMG_BUFFER_RECON";
801    default:
802        return "Unknown Buffer Type";
803    }
804}
805
806static void PROVIDEBUFFER_SOURCE_dump(void *data)
807{
808    IMG_SOURCE_BUFFER_PARAMS *source = (IMG_SOURCE_BUFFER_PARAMS*) data;
809
810    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrYPlane_Field0=0x%x\n",source->ui32PhysAddrYPlane_Field0);
811    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrUPlane_Field0=0x%x\n",source->ui32PhysAddrUPlane_Field0);
812    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrVPlane_Field0=0x%x\n",source->ui32PhysAddrVPlane_Field0);
813    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrYPlane_Field1=0x%x\n",source->ui32PhysAddrYPlane_Field1);
814    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrUPlane_Field1=0x%x\n",source->ui32PhysAddrUPlane_Field1);
815    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32PhysAddrVPlane_Field1=0x%x\n",source->ui32PhysAddrVPlane_Field1);
816    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui32HostContext=%d\n",source->ui32HostContext);
817    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui8DisplayOrderNum=%d\n",source->ui8DisplayOrderNum);
818    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tui8SlotNum=%d\n",source->ui8SlotNum);
819    return ;
820}
821
822static int PROVIDEBUFFER_dump(unsigned int data)
823{
824    IMG_REF_BUFFER_TYPE eBufType = (data & MASK_MTX_MSG_PROVIDE_REF_BUFFER_USE) >> SHIFT_MTX_MSG_PROVIDE_REF_BUFFER_USE;
825    //IMG_BUFFER_DATA *bufdata = p->sData;
826    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\teBufferType=(%s)\n",  eBufferType2str(eBufType));
827    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\n");
828
829    return 0;
830}
831
832static char *eSubtype2str(IMG_PICMGMT_TYPE eSubtype)
833{
834    switch (eSubtype) {
835        case IMG_PICMGMT_REF_TYPE:return "IMG_PICMGMT_REF_TYPE";
836        case IMG_PICMGMT_GOP_STRUCT:return "IMG_PICMGMT_GOP_STRUCT";
837        case IMG_PICMGMT_SKIP_FRAME:return "IMG_PICMGMT_SKIP_FRAME";
838        case IMG_PICMGMT_EOS:return "IMG_PICMGMT_EOS";
839        case IMG_PICMGMT_FLUSH:return "IMG_PICMGMT_FLUSH";
840        case IMG_PICMGMT_QUANT:return "IMG_PICMGMT_QUANT";
841        default: return "Unknow";
842    }
843}
844int PICMGMT_dump(IMG_UINT32 data)
845{
846    IMG_PICMGMT_TYPE eSubType = (data & MASK_MTX_MSG_PICMGMT_SUBTYPE) >> SHIFT_MTX_MSG_PICMGMT_SUBTYPE;
847    IMG_FRAME_TYPE eFrameType = 0;
848    IMG_UINT32 ui32FrameCount = 0;
849
850    drv_debug_msg(VIDEO_ENCODE_PDUMP,
851        "\t\teSubtype=%d(%s)\n", eSubType, eSubtype2str(eSubType));
852    drv_debug_msg(VIDEO_ENCODE_PDUMP,
853        "\t\t(=====(additional data)=====\n");
854    switch (eSubType) {
855        case IMG_PICMGMT_REF_TYPE:
856            eFrameType = (data & MASK_MTX_MSG_PICMGMT_DATA) >> SHIFT_MTX_MSG_PICMGMT_DATA;
857            switch (eFrameType) {
858                case IMG_INTRA_IDR:
859                    drv_debug_msg(VIDEO_ENCODE_PDUMP,
860                        "\t\teFrameType=IMG_INTRA_IDR\n");
861                    break;
862                case IMG_INTRA_FRAME:
863                    drv_debug_msg(VIDEO_ENCODE_PDUMP,
864                        "\t\teFrameType=IMG_INTRA_FRAME\n");
865                    break;
866                case IMG_INTER_P:
867                    drv_debug_msg(VIDEO_ENCODE_PDUMP,
868                        "\t\teFrameType=IMG_INTER_P\n");
869                    break;
870                case IMG_INTER_B:
871                    drv_debug_msg(VIDEO_ENCODE_PDUMP,
872                        "\t\teFrameType=IMG_INTER_B\n");
873                    break;
874            }
875            break;
876        case IMG_PICMGMT_EOS:
877             ui32FrameCount = (data & MASK_MTX_MSG_PICMGMT_DATA) >> SHIFT_MTX_MSG_PICMGMT_DATA;
878             drv_debug_msg(VIDEO_ENCODE_PDUMP,
879                 "\t\tui32FrameCount=%d\n", ui32FrameCount);
880             break;
881        default:
882             break;
883    }
884    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\n\n");
885
886    return 0;
887}
888
889
890static char * cmd2str(int cmdid)
891{
892    switch (cmdid) {
893    case MTX_CMDID_NULL:        return "MTX_CMDID_NULL";
894    case MTX_CMDID_SHUTDOWN:    return "MTX_CMDID_SHUTDOWN";
895	// Video Commands
896    case MTX_CMDID_DO_HEADER:   return "MTX_CMDID_DO_HEADER";
897    case MTX_CMDID_ENCODE_FRAME:return "MTX_CMDID_ENCODE_FRAME";
898    case MTX_CMDID_START_FRAME: return "MTX_CMDID_START_FRAME";
899    case MTX_CMDID_ENCODE_SLICE:return "MTX_CMDID_ENCODE_SLICE";
900    case MTX_CMDID_END_FRAME:   return "MTX_CMDID_END_FRAME";
901    case MTX_CMDID_SETVIDEO:    return "MTX_CMDID_SETVIDEO";
902    case MTX_CMDID_GETVIDEO:    return "MTX_CMDID_GETVIDEO";
903    case MTX_CMDID_PICMGMT:     return "MTX_CMDID_PICMGMT";
904    case MTX_CMDID_RC_UPDATE:   return "MTX_CMDID_RC_UPDATE";
905    case MTX_CMDID_PROVIDE_SOURCE_BUFFER:return "MTX_CMDID_PROVIDE_SOURCE_BUFFER";
906    case MTX_CMDID_PROVIDE_REF_BUFFER:   return "MTX_CMDID_PROVIDE_REF_BUFFER";
907    case MTX_CMDID_PROVIDE_CODED_BUFFER: return "MTX_CMDID_PROVIDE_CODED_BUFFER";
908    case MTX_CMDID_ABORT:       return "MTX_CMDID_ABORT";
909	// JPEG commands
910    case MTX_CMDID_SETQUANT:    return "MTX_CMDID_SETQUANT";
911    case MTX_CMDID_SETUP_INTERFACE:      return "MTX_CMDID_SETUP_INTERFACE";
912    case MTX_CMDID_ISSUEBUFF:   return "MTX_CMDID_ISSUEBUFF";
913    case MTX_CMDID_SETUP:       return "MTX_CMDID_SETUP";
914    case MTX_CMDID_ENDMARKER:
915    default:
916        return "Invalid Command (%d)";
917    }
918}
919
920static int command_parameter_dump(int cmdid, unsigned int cmd_data, unsigned int cmd_addr)
921{
922    MTX_HEADER_PARAMS *header_para;
923    IMG_MTX_VIDEO_CONTEXT *context;
924    JPEG_MTX_QUANT_TABLE *jpeg_table;
925    MTX_ISSUE_BUFFERS *issue_buffer;
926    JPEG_MTX_DMA_SETUP *jpeg_mtx_dma_setup;
927    void *virt_addr = 0;
928    if (cmd_addr != 0)
929        virt_addr = phy2virt(cmd_addr);
930
931    switch (cmdid) {
932        case MTX_CMDID_NULL:
933        case MTX_CMDID_SHUTDOWN:
934        case MTX_CMDID_ENDMARKER :         //!< end marker for enum
935        case MTX_CMDID_GETVIDEO:
936            break;
937        case MTX_CMDID_DO_HEADER:
938            header_para = (MTX_HEADER_PARAMS *)virt_addr;
939            DO_HEADER_dump(header_para);
940            if (duplicate_setvideo_dump)
941                SETVIDEO_dump(mtx_ctx);
942            break;
943        case MTX_CMDID_ENCODE_FRAME:
944            if (duplicate_setvideo_dump)
945                SETVIDEO_dump(mtx_ctx);
946            if (last_setvideo_dump == 1)
947                SETVIDEO_dump(mtx_ctx);
948            break;
949        case MTX_CMDID_SETVIDEO:
950            context = (IMG_MTX_VIDEO_CONTEXT *)virt_addr;
951            if (last_setvideo_dump == 1)
952                mtx_ctx = virt_addr;
953            else
954                SETVIDEO_dump(context);
955            break;
956        case MTX_CMDID_PICMGMT :
957            PICMGMT_dump(cmd_data);
958            break;
959        case  MTX_CMDID_PROVIDE_SOURCE_BUFFER:
960            PROVIDEBUFFER_SOURCE_dump((IMG_SOURCE_BUFFER_PARAMS *)virt_addr);
961            break;
962        case  MTX_CMDID_PROVIDE_REF_BUFFER:
963            PROVIDEBUFFER_dump(cmd_data);
964            break;
965        case MTX_CMDID_PROVIDE_CODED_BUFFER:
966            break;
967
968            // JPEG commands
969        case MTX_CMDID_SETQUANT:          //!< (data: #JPEG_MTX_QUANT_TABLE)\n
970            jpeg_table = (JPEG_MTX_QUANT_TABLE *)virt_addr;
971            JPEG_TABLE_dump(jpeg_table);
972            break;
973        case MTX_CMDID_ISSUEBUFF:         //!< (data: #MTX_ISSUE_BUFFERS)\n
974            issue_buffer = (MTX_ISSUE_BUFFERS *)virt_addr;
975            ISSUE_BUFFER_dump(issue_buffer);
976            break;
977        case MTX_CMDID_SETUP:             //!< (data: #JPEG_MTX_DMA_SETUP)\n\n
978            jpeg_mtx_dma_setup = (JPEG_MTX_DMA_SETUP *)virt_addr;
979            JPEG_MTX_DMA_dump(jpeg_mtx_dma_setup);
980            break;
981        default:
982            break;
983    }
984    return 0;
985}
986static struct RegisterInfomation multicore_regs[] = {
987    {"MULTICORE_SRST",0x0000},
988    {"MULTICORE_INT_STAT",0x0004},
989    {"MULTICORE_MTX_INT_ENAB",0x0008},
990    {"MULTICORE_HOST_INT_ENAB",0x000C},
991    {"MULTICORE_INT_CLEAR",0x0010},
992    {"MULTICORE_MAN_CLK_GATE",0x0014},
993    {"TOPAZ_MTX_C_RATIO",0x0018},
994    {"MMU_STATUS",0x001C},
995    {"MMU_MEM_REQ",0x0020},
996    {"MMU_CONTROL0",0x0024},
997    {"MMU_CONTROL1",0x0028},
998    {"MMU_CONTROL2",0x002C},
999    {"MMU_DIR_LIST_BASE",0x0030},
1000    {"MMU_TILE",0x0038},
1001    {"MTX_DEBUG_MSTR",0x0044},
1002    {"MTX_DEBUG_SLV",0x0048},
1003    {"MULTICORE_CORE_SEL_0",0x0050},
1004    {"MULTICORE_CORE_SEL_1",0x0054},
1005    {"MULTICORE_HW_CFG",0x0058},
1006    {"MULTICORE_CMD_FIFO_WRITE",0x0060},
1007    {"MULTICORE_CMD_FIFO_WRITE_SPACE",0x0064},
1008    {"TOPAZ_CMD_FIFO_READ",0x0070},
1009    {"TOPAZ_CMD_FIFO_READ_AVAILABLE",0x0074},
1010    {"TOPAZ_CMD_FIFO_FLUSH",0x0078},
1011    {"MMU_TILE_EXT",0x0080},
1012    {"FIRMWARE_REG_1",0x0100},
1013    {"FIRMWARE_REG_2",0x0104},
1014    {"FIRMWARE_REG_3",0x0108},
1015    {"CYCLE_COUNTER",0x0110},
1016    {"CYCLE_COUNTER_CTRL",0x0114},
1017    {"MULTICORE_IDLE_PWR_MAN",0x0118},
1018    {"DIRECT_BIAS_TABLE",0x0124},
1019    {"INTRA_BIAS_TABLE",0x0128},
1020    {"INTER_BIAS_TABLE",0x012C},
1021    {"INTRA_SCALE_TABLE",0x0130},
1022    {"QPCB_QPCR_OFFSET",0x0134},
1023    {"INTER_INTRA_SCALE_TABLE",0x0140},
1024    {"SKIPPED_CODED_SCALE_TABLE",0x0144},
1025    {"POLYNOM_ALPHA_COEFF_CORE0",0x0148},
1026    {"POLYNOM_GAMMA_COEFF_CORE0",0x014C},
1027    {"POLYNOM_CUTOFF_CORE0",0x0150},
1028    {"POLYNOM_ALPHA_COEFF_CORE1",0x0154},
1029    {"POLYNOM_GAMMA_COEFF_CORE1",0x0158},
1030    {"POLYNOM_CUTOFF_CORE1",0x015C},
1031    {"POLYNOM_ALPHA_COEFF_CORE2",0x0160},
1032    {"POLYNOM_GAMMA_COEFF_CORE2",0x0164},
1033    {"POLYNOM_CUTOFF_CORE2",0x0168},
1034    {"FIRMWARE_REG_4",0x0300},
1035    {"FIRMWARE_REG_5",0x0304},
1036    {"FIRMWARE_REG_6",0x0308},
1037    {"FIRMWARE_REG_7",0x030C},
1038    {"MULTICORE_RSVD0",0x03B0},
1039    {"TOPAZHP_CORE_ID",0x03C0},
1040    {"TOPAZHP_CORE_REV",0x03D0},
1041    {"TOPAZHP_CORE_DES1",0x03E0},
1042    {"TOPAZHP_CORE_DES2",0x03F0},
1043};
1044
1045
1046static struct RegisterInfomation core_regs[] = {
1047    {"TOPAZHP_SRST",0x0000},
1048    {"TOPAZHP_INTSTAT",0x0004},
1049    {"TOPAZHP_MTX_INTENAB",0x0008},
1050    {"TOPAZHP_HOST_INTENAB",0x000C},
1051    {"TOPAZHP_INTCLEAR",0x0010},
1052    {"TOPAZHP_INT_COMB_SEL",0x0014},
1053    {"TOPAZHP_BUSY",0x0018},
1054    {"TOPAZHP_AUTO_CLOCK_GATING",0x0024},
1055    {"TOPAZHP_MAN_CLOCK_GATING",0x0028},
1056    {"TOPAZHP_RTM",0x0030},
1057    {"TOPAZHP_RTM_VALUE",0x0034},
1058    {"TOPAZHP_MB_PERFORMANCE_RESULT",0x0038},
1059    {"TOPAZHP_MB_PERFORMANCE_MB_NUMBER",0x003C},
1060    {"FIELD_PARITY",0x0188},
1061    {"WEIGHTED_PRED_CONTROL",0x03D0},
1062    {"WEIGHTED_PRED_COEFFS",0x03D4},
1063    {"WEIGHTED_PRED_INV_WEIGHT",0x03E0},
1064    {"TOPAZHP_RSVD0",0x03F0},
1065    {"TOPAZHP_CRC_CLEAR",0x03F4},
1066    {"SPE_ZERO_THRESH",0x0344},
1067    {"SPE0_BEST_SAD_SIGNATURE",0x0348},
1068    {"SPE1_BEST_SAD_SIGNATURE",0x034C},
1069    {"SPE0_BEST_INDEX_SIGNATURE",0x0350},
1070    {"SPE1_BEST_INDEX_SIGNATURE",0x0354},
1071    {"SPE_INTRA_COST_SIGNATURE",0x0358},
1072    {"SPE_MVD_CLIP_RANGE",0x0360},
1073    {"SPE_SUBPEL_RESOLUTION",0x0364},
1074    {"SPE0_MV_SIZE_SIGNATURE",0x0368},
1075    {"SPE1_MV_SIZE_SIGNATURE",0x036C},
1076    {"SPE_MB_PERFORMANCE_RESULT",0x0370},
1077    {"SPE_MB_PERFORMANCE_MB_NUMBER",0x0374},
1078    {"SPE_MB_PERFORMANCE_CLEAR",0x0378},
1079    {"MEM_SIGNATURE_CONTROL",0x0060},
1080    {"MEM_SIGNATURE_ENC_WDATA",0x0064},
1081    {"MEM_SIGNATURE_ENC_RDATA",0x0068},
1082    {"MEM_SIGNATURE_ENC_ADDR",0x006C},
1083    {"PREFETCH_LRITC_SIGNATURE",0x0070},
1084    {"PROC_DMA_CONTROL",0x00E0},
1085    {"PROC_DMA_STATUS",0x00E4},
1086    {"PROC_ESB_ACCESS_CONTROL",0x00EC},
1087    {"PROC_ESB_ACCESS_WORD0",0x00F0},
1088    {"PROC_ESB_ACCESS_WORD1",0x00F4},
1089    {"PROC_ESB_ACCESS_WORD2",0x00F8},
1090    {"PROC_ESB_ACCESS_WORD3",0x00FC},
1091
1092    {"LRITC_TILE_USE_CONFIG",0x0040},
1093    {"LRITC_TILE_USE_STATUS",0x0048},
1094    {"LRITC_TILE_FREE_STATUS",0x004C},
1095    {"LRITC_CACHE_CHUNK_CONFIG",0x0050},
1096    {"LRITC_CACHE_CHUNK_STATUS",0x0054},
1097    {"LRITC_SIGNATURE_ADDR",0x0058},
1098    {"LRITC_SIGNATURE_RDATA",0x005C},
1099
1100    {"SEQ_CUR_PIC_LUMA_BASE_ADDR",0x0100},
1101    {"SEQ_CUR_PIC_CB_BASE_ADDR",0x0104},
1102    {"SEQ_CUR_PIC_CR_BASE_ADDR",0x0108},
1103    {"SEQ_CUR_PIC_ROW_STRIDE",0x010C},
1104    {"SEQ_REF_PIC0_LUMA_BASE_ADDR",0x0110},
1105    {"SEQ_REF_PIC0_CHROMA_BASE_ADDR",0x0114},
1106    {"SEQ_REF_PIC1_LUMA_BASE_ADDR",0x0118},
1107    {"SEQ_REF_PIC1_CHROMA_BASE_ADDR",0x011C},
1108    {"SEQ_CUR_PIC_CONFIG",0x0120},
1109    {"SEQ_CUR_PIC_SIZE",0x0124},
1110    {"SEQ_RECON_LUMA_BASE_ADDR",0x0128},
1111    {"SEQ_RECON_CHROMA_BASE_ADDR",0x012C},
1112    {"SEQ_ABOVE_PARAM_BASE_ADDR",0x0130},
1113    {"SEQ_TEMPORAL_COLOCATED_IN_ADDR",0x0134},
1114    {"SEQ_TEMPORAL_PIC0_MV_IN_ADDR",0x0138},
1115    {"SEQ_TEMPORAL_PIC1_MV_IN_ADDR",0x013C},
1116    {"SEQ_TEMPORAL_COLOCATED_OUT_ADDR",0x0140},
1117    {"SEQ_TEMPORAL_PIC0_MV_OUT_ADDR",0x0144},
1118    {"SEQ_TEMPORAL_PIC1_MV_OUT_ADDR",0x0148},
1119    {"SEQ_MB_FIRST_STAGE_OUT_ADDR",0x014C},
1120    {"SEQ_MB_CONTROL_IN_ADDR",0x0150},
1121    {"SEQUENCER_CONFIG",0x0154},
1122    {"SLICE_CONFIG",0x0158},
1123    {"SLICE_QP_CONFIG",0x015C},
1124    {"SEQUENCER_KICK",0x0160},
1125    {"H264COMP_REJECT_THRESHOLD",0x0184},
1126    {"H264COMP_CUSTOM_QUANT_SP",0x01A0},
1127    {"H264COMP_CUSTOM_QUANT_Q",0x01A4},
1128    {"H264COMP_CONTROL",0x01A8},
1129    {"H264COMP_INTRA_PRED_MODES",0x01AC},
1130    {"H264COMP_MAX_CYCLE_COUNT",0x01B0},
1131    {"H264COMP_MAX_CYCLE_MB",0x01B4},
1132    {"H264COMP_MAX_CYCLE_RESET",0x01B8},
1133    {"H264COMP4X4_PRED_CRC",0x01BC},
1134    {"H264COMP4X4_COEFFS_CRC",0x01C0},
1135    {"H264COMP4X4_RECON_CRC",0x01C4},
1136    {"H264COMP8X8_PRED_CRC",0x01C8},
1137    {"H264COMP8X8_COEFFS_CRC",0x01CC},
1138    {"H264COMP8X8_RECON_CRC",0x01D0},
1139    {"H264COMP16X16_PRED_CRC",0x01D4},
1140    {"H264COMP16X16_COEFFS_CRC",0x01D8},
1141    {"H264COMP16X16_RECON_CRC",0x01DC},
1142    {"H264COMP_ROUND_0",0x01E0},
1143    {"H264COMP_ROUND_1",0x01E4},
1144    {"H264COMP_ROUND_2",0x01E8},
1145    {"H264COMP_ROUND_INIT",0x01EC},
1146    {"H264COMP_VIDEO_CONF_CONTROL_0",0x01F0},
1147    {"H264COMP_VIDEO_CONF_CONTROL_1",0x01F4},
1148    {"H264COMP_VIDEO_CONF_STATUS_0",0x01F8},
1149    {"H264COMP_VIDEO_CONF_STATUS_1",0x01FC},
1150};
1151
1152static struct RegisterInfomation mtx_regs[] = {
1153    {"MTX_ENABLE",0x0000},
1154    {"MTX_STATUS",0x0008},
1155    {"MTX_KICK",0x0080},
1156    {"MTX_KICKI",0x0088},
1157    {"MTX_FAULT0",0x0090},
1158    {"MTX_REGISTER_READ_WRITE_DATA",0x00F8},
1159    {"MTX_REGISTER_READ_WRITE_REQUEST",0x00FC},
1160    {"MTX_RAM_ACCESS_DATA_EXCHANGE",0x0100},
1161    {"MTX_RAM_ACCESS_DATA_TRANSFER",0x0104},
1162    {"MTX_RAM_ACCESS_CONTROL",0x0108},
1163    {"MTX_RAM_ACCESS_STATUS",0x010C},
1164    {"MTX_SOFT_RESET",0x0200},
1165    {"MTX_SYSC_CDMAC",0x0340},
1166    {"MTX_SYSC_CDMAA",0x0344},
1167    {"MTX_SYSC_CDMAS0",0x0348},
1168    {"MTX_SYSC_CDMAS1",0x034C},
1169    {"MTX_SYSC_CDMAT",0x0350}
1170};
1171
1172
1173static struct RegisterInfomation dmac_regs[] = {
1174    {"DMA_Setup",0x0000},
1175    {"DMA_Count",0x0004},
1176    {"DMA_Peripheral_param",0x0008},
1177    {"DMA_IRQ_Stat",0x000c},
1178    {"DMA_2D_Mode",0x0010},
1179    {"DMA_Peripheral_addr",0x0014},
1180    {"DMA_Per_hold",0x0018},
1181    {"DMA_SoftReset",0x0020},
1182};
1183
1184
1185int topazhp_dump_command(unsigned int *comm_dword)
1186{
1187    int cmdid;
1188
1189    if (comm_dword == NULL)
1190        return 1;
1191
1192    cmdid = (comm_dword[0] & MASK_MTX_MSG_CMD_ID) & ~ MASK_MTX_MSG_PRIORITY;
1193
1194    (void)multicore_regs;
1195    (void)core_regs;
1196    (void)mtx_regs;
1197    (void)dmac_regs;
1198
1199    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\tSend command to MTX\n");
1200    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_ID=%s(High priority:%s)\n", cmd2str(cmdid),
1201           (comm_dword[0] & MASK_MTX_MSG_PRIORITY)?"Yes":"No");
1202    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_CORE=%d\n", (comm_dword[0] & MASK_MTX_MSG_CORE) >> SHIFT_MTX_MSG_CORE);
1203    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_COUNT=%d\n", (comm_dword[0] & MASK_MTX_MSG_COUNT) >> SHIFT_MTX_MSG_COUNT);
1204    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_DATA=0x%08x\n", comm_dword[1]);
1205    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_ADDR=0x%08x\n", comm_dword[2]);
1206    drv_debug_msg(VIDEO_ENCODE_PDUMP,"\t\tCMDWORD_WBVALUE=0x%08x\n", comm_dword[3]);
1207    command_parameter_dump(cmdid, comm_dword[1], comm_dword[2]);
1208
1209    return 0;
1210}
1211