This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM365 IPNC RDK 5.1.0 : Moduletest with ISIF Input error

Other Parts Discussed in Thread: TVP5158

Hi,


I am trying to run this moduletest, standalone test codes that is available with the RDK.

Basically trying to implement a standalone code to just capture and display bypassing the AVCAPTURE.

Module test  code that is present in the RDK is implemented considering input from IPIPE+RSZ. But my flow of data is  Analog Video Signal -> TVP5158 -> Capture-> Display

PAL 720 x 576 input resolution.

Have modified the DRV_capturetest.c file accordingly the following way and i see  it gives me following error.

root@DM365_IPNC:/opt/ipnc# root@DM365_IPNC:/opt/ipnc# sync ./modroot@DM365_IPNC:/opt/ipnc# ./moduletroot@DM365_IPNC:/opt/ipnc# ./moduletest.out drv_capture
 
 CLK Hz,
 ARM   Hz =  216000000
 DDR   Hz =  171789472
 VPSS  Hz =  171789472
 IMCOP Hz =  171789472
 
 CAPTURE: Opening display.
 ERROR  (drv_captureTest.c|DRV_ca8168.drv_captureTest.cptureTestOpen|164): Open failed
 CAPTURE: Exiting.
Segmentation fault

Can somebody please go through the code below and see if my implementation is correct or if am missing something.

Thanks & Regards,

Swathi


#include <drv_captureTestPriv.h>

static DRV_CaptureTestCtrl gDRV_testCtrl;

int DRV_captureTestOpen()
{
  int status;

  gDRV_testCtrl.captureConfig.imgsConfig.sensorMode = DRV_CAPTURE_TEST_SENSOR_MODE;
  gDRV_testCtrl.captureConfig.imgsConfig.binEnable  = FALSE;
  gDRV_testCtrl.captureConfig.imgsConfig.fps        = 30;

  gDRV_testCtrl.captureConfig.isifConfig.sensorMode = gDRV_testCtrl.captureConfig.imgsConfig.sensorMode;
  gDRV_testCtrl.captureConfig.isifConfig.alawEnable = FALSE;
  gDRV_testCtrl.captureConfig.isifConfig.dpcmEnable = FALSE;
  gDRV_testCtrl.captureConfig.isifConfig.numBuf     = DRV_CAPTURE_TEST_NUM_BUF;
  gDRV_testCtrl.captureConfig.isifConfig.numLscBuf  = 0;

  #ifdef DRV_CAPTURE_TEST_ENABLE_LSC
  gDRV_testCtrl.captureConfig.isifConfig.numLscBuf = DRV_CAPTURE_TEST_NUM_BUF;
  #endif

  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.paxelWidth   = 16;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.paxelHeight  = 8;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.gainFormat   = 0;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.offsetEnable = TRUE;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.offsetScale  = 0x80;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.offsetShift  = 0;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.initX        = 0;
  gDRV_testCtrl.captureConfig.isifConfig.lscConfig.initY        = 0;

  gDRV_testCtrl.captureConfig.h3aConfig.sensorMode  = gDRV_testCtrl.captureConfig.imgsConfig.sensorMode;
  gDRV_testCtrl.captureConfig.h3aConfig.numBufAewb  = DRV_CAPTURE_TEST_NUM_BUF;
  gDRV_testCtrl.captureConfig.h3aConfig.numBufAf    = DRV_CAPTURE_TEST_NUM_BUF;
  gDRV_testCtrl.captureConfig.h3aConfig.aewbVendor  = APPRO_2A;

  gDRV_testCtrl.captureConfig.ipipeConfig.sensorMode              = gDRV_testCtrl.captureConfig.imgsConfig.sensorMode;
  gDRV_testCtrl.captureConfig.ipipeConfig.inputSrc                = DRV_IPIPE_INPUT_SRC_ISIF;
  gDRV_testCtrl.captureConfig.ipipeConfig.boxcarBlockSize         = DRV_IPIPE_BOXCAR_BLOCK_SIZE_NONE;
  gDRV_testCtrl.captureConfig.ipipeConfig.boxcarInShift           = 0;
  gDRV_testCtrl.captureConfig.ipipeConfig.histogramMode           = DRV_IPIPE_HISTO_MODE_NONE;

  gDRV_testCtrl.captureConfig.ipipeConfig.bscNumVectorsRow        = 0;

  #ifdef DRV_CAPTURE_TEST_ENABLE_BSC
  gDRV_testCtrl.captureConfig.ipipeConfig.bscNumVectorsRow        = 3;
  #endif

  #ifdef DRV_CAPTURE_TEST_ENABLE_BOXCAR
  gDRV_testCtrl.captureConfig.ipipeConfig.boxcarBlockSize         = DRV_IPIPE_BOXCAR_BLOCK_SIZE_8x8;
  #endif

  gDRV_testCtrl.captureConfig.ipipeConfig.bscNumVectorsCol        = gDRV_testCtrl.captureConfig.ipipeConfig.bscNumVectorsRow;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszValidDataStartOffset = 0;

  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].enable    = FALSE;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].outFormat = DRV_CAPTURE_TEST_DATA_FORMAT;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].width     = 720;//1280;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].height    = 576;//720;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].flipH     = FALSE;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].flipV     = FALSE;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].numBuf    = DRV_CAPTURE_TEST_NUM_BUF;

  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].enable    = FALSE;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].outFormat = gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].outFormat;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].width     = 720;//640;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].height    = 576;//480;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].flipH     = gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].flipH;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].flipV     = gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].flipV;
  gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[1].numBuf    = gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].numBuf;

  gDRV_testCtrl.displayConfig.winId       = DRV_DISPLAY_VID_WIN_0;
  gDRV_testCtrl.displayConfig.numBuf      = DRV_CAPTURE_TEST_NUM_BUF;
  gDRV_testCtrl.displayConfig.dataFormat  = gDRV_testCtrl.captureConfig.ipipeConfig.rszOutConfig[0].outFormat;
  gDRV_testCtrl.displayConfig.startX      = 0;
  gDRV_testCtrl.displayConfig.startY      = 0;
  gDRV_testCtrl.displayConfig.width       = 720;
  gDRV_testCtrl.displayConfig.height      = 576;
  gDRV_testCtrl.displayConfig.offsetH     = OSA_align(gDRV_testCtrl.displayConfig.width, 32);
  gDRV_testCtrl.displayConfig.offsetV     = gDRV_testCtrl.displayConfig.height;
  gDRV_testCtrl.displayConfig.zoomH       = 0;
  gDRV_testCtrl.displayConfig.zoomV       = 0;
  gDRV_testCtrl.displayConfig.bufFlag     = 0;

  gDRV_testCtrl.displayBufId=0;

  OSA_printf(" CAPTURE: Opening display.\n");

  status = DRV_displayOpen(&gDRV_testCtrl.displayHndl, &gDRV_testCtrl.displayConfig);
  OSA_printf(" %d , %d \n",status, OSA_SOK);
  if(status!=OSA_SOK)
    goto error_exit;

  status = DRV_displaySetMode(DRV_DISPLAY_MODE_PAL);
  OSA_printf(" %d , %d \n",status, OSA_SOK);
  if(status!=OSA_SOK)
    goto error_exit;

  OSA_printf(" DRV_DisaplayMode executed \n");

  DRV_displayGetBufInfo(&gDRV_testCtrl.displayHndl, &gDRV_testCtrl.displayInfo);

  OSA_printf(" CAPTURE: Opening capture on imager %s.\n", DRV_imgsGetImagerName());

  status = DRV_captureOpen(&gDRV_testCtrl.captureConfig, &gDRV_testCtrl.captureInfo);
  if(status!=OSA_SOK)
    goto capture_exit;

  return OSA_SOK;

alloc_exit:
  #ifdef DRV_CAPTURE_TEST_ENABLE_FD
  DRV_faceDetectClose();
  #endif

#ifdef DRV_CAPTURE_TEST_ENABLE_FD
fd_exit:
#endif
  DRV_captureClose();

capture_exit:
  DRV_displayClose(&gDRV_testCtrl.displayHndl);

error_exit:

  OSA_ERROR("Open failed\n");

  return OSA_EFAIL;
}


int DRV_captureTestH3aRun(int count)
{
  int status;
  int bufIdAewb;
  OSA_BufInfo *pBufInfo;

  int accValue[4];

  CSL_H3aAewbOutSumModeOverlay *pAewbWinData;
  Uint8 *curAewbAddr;
  int numWin, i, j, avgG, aGain;

  DRV_IpipeWb wb;

  status = DRV_h3aGetBuf(DRV_H3A_MOD_AEWB, &bufIdAewb, OSA_TIMEOUT_FOREVER);
  if(status!=OSA_SOK) {
    OSA_ERROR("DRV_h3aGetBuf()\n");
    return status;
  }

  pBufInfo =   DRV_h3aGetBufInfo(DRV_H3A_MOD_AEWB, bufIdAewb);
  if(pBufInfo) {

    #ifdef DRV_CAPTURE_TEST_SAVE_H3A_DATA
    if(count>1) {
      static char filename[80];

      if(count%100==0) {
        sprintf(filename, "H3A_%04d_%dx%d.BIN", count, gDRV_testCtrl.captureInfo.h3aInfo.aewbNumWinH, gDRV_testCtrl.captureInfo.h3aInfo.aewbNumWinV);
        OSA_fileWriteFile(filename, pBufInfo->virtAddr, pBufInfo->size);
      }
    }
    #endif


    if(count%(30*5)==0) {
      curAewbAddr = pBufInfo->virtAddr;
      numWin=0;

      accValue[0]=accValue[1]=accValue[2]=accValue[3]=0;

      for(i=0; i<gDRV_testCtrl.captureInfo.h3aInfo.aewbNumWinV; i++) {
        for(j=0; j<gDRV_testCtrl.captureInfo.h3aInfo.aewbNumWinH; j++) {

          pAewbWinData = (CSL_H3aAewbOutSumModeOverlay *)curAewbAddr;

          accValue[0] += pAewbWinData->subSampleAcc[0];
          accValue[1] += pAewbWinData->subSampleAcc[1];
          accValue[2] += pAewbWinData->subSampleAcc[2];
          accValue[3] += pAewbWinData->subSampleAcc[3];

          #if 0
          OSA_printf(" (%2d:%2d) %5d, %5d, %5d, %5d\n", i, j,
                pAewbWinData->subSampleAcc[0], pAewbWinData->subSampleAcc[1],
                pAewbWinData->subSampleAcc[2], pAewbWinData->subSampleAcc[3]
                );
          #endif

          curAewbAddr += sizeof(CSL_H3aAewbOutSumModeOverlay);

          numWin++;

          if(numWin%8==0)
            curAewbAddr += sizeof(CSL_H3aAewbOutUnsatBlkCntOverlay);
        }
        curAewbAddr = (Uint8*)OSA_align( (Uint32)curAewbAddr, 32);
      }

      accValue[0] /= numWin*gDRV_testCtrl.captureInfo.h3aInfo.aewbNumSamplesPerColorInWin;
      accValue[1] /= numWin*gDRV_testCtrl.captureInfo.h3aInfo.aewbNumSamplesPerColorInWin;
      accValue[2] /= numWin*gDRV_testCtrl.captureInfo.h3aInfo.aewbNumSamplesPerColorInWin;
      accValue[3] /= numWin*gDRV_testCtrl.captureInfo.h3aInfo.aewbNumSamplesPerColorInWin;

      #ifdef DRV_CAPTURE_TEST_APPLY_2A
      // do simple AWB
      wb.gainGr = 0x200;
      wb.gainGb = 0x200;

      wb.gainR  = (wb.gainGr*accValue[0])/accValue[1];
      wb.gainB  = (wb.gainGb*accValue[3])/accValue[2];

      DRV_ipipeSetWb(&wb);

      // do simple AE
      avgG = (accValue[0]+accValue[3])/2;

      aGain = 8000 - (avgG*4000)/512;

      DRV_imgsSetAgain(aGain, 0);

      #ifdef DRV_CAPTURE_TEST_PRINT_H3A_INFO
      OSA_printf(" AEWB Avg Color: %5d, %5d, %5d, %5d (AE aGain = %d)\n", accValue[0], accValue[1], accValue[2], accValue[3], aGain);
      #endif

      #endif

    }
  }

  DRV_h3aPutBuf(DRV_H3A_MOD_AEWB, bufIdAewb);

  return status;
}

int DRV_captureTestBscRun(int count)
{
  int status, i, j;
  int bufIdBsc;
  OSA_BufInfo *pBufInfo;
  int rowSum[10], colSum[10];
  Uint16 *curAddr;

  status = DRV_ipipeGetBscBuf(&bufIdBsc, OSA_TIMEOUT_FOREVER);
  if(status!=OSA_SOK) {
    return status;
  }

  pBufInfo =   DRV_ipipeGetBscBufInfo(bufIdBsc);
  if(pBufInfo) {

    #ifdef DRV_CAPTURE_TEST_SAVE_BSC_DATA
    if(count>1) {
      static char filename[80];

      if(count%100==0) {
        sprintf(filename, "BSC_%04d.BIN", count);
        OSA_fileWriteFile(filename, pBufInfo->virtAddr, pBufInfo->size);
      }
    }
    #endif

    #ifdef DRV_CAPTURE_TEST_ENABLE_VS
    {
      ALG_VstabRunPrm vsPrm;

      vsPrm.bscDataVirtAddr = pBufInfo->virtAddr;
      vsPrm.bscDataPhysAddr = pBufInfo->physAddr;

      OSA_prfBegin(&gDRV_testCtrl.vsPrf);

      status = ALG_vstabRun(gDRV_testCtrl.vsHndl, &vsPrm, &gDRV_testCtrl.vsStatus);

      OSA_prfEnd(&gDRV_testCtrl.vsPrf, 1);

      if(status!=OSA_SOK) {
        OSA_ERROR("ALG_vstabRun()\n");
      }

      if(count%(30*5)==0) {
        OSA_prfPrint(&gDRV_testCtrl.vsPrf, "VS", 0);
      }
    }
    #endif

    if(count%(30*3)==0) {
      curAddr = (Uint16*)pBufInfo->virtAddr;

      for(i=0; i<gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.rowNumVectors; i++) {
        rowSum[i] = 0;

        for(j=0; j<gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.rowNumV; j++)  {
          rowSum[i] += *curAddr;
          curAddr++;
        }

        rowSum[i] /= gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.rowNumV;
      }

      curAddr = (Uint16*)(pBufInfo->virtAddr + DRV_IPIPE_BSC_BUFFER_MAX/2);

      for(i=0; i<gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.colNumVectors; i++) {
        colSum[i] = 0;

        for(j=0; j<gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.colNumH; j++)  {
          colSum[i] += *curAddr;
          curAddr++;
        }

        colSum[i] /= gDRV_testCtrl.captureInfo.ipipeInfo.bscInfo.colNumH;
      }

      #ifdef DRV_CAPTURE_TEST_PRINT_BSC_INFO
      OSA_printf(" BSC: Row [%8d, %8d, %8d] Col [%8d, %8d, %8d]\n",
          rowSum[0], rowSum[1], rowSum[2],
          colSum[0], colSum[1], colSum[2]
          );
      #endif
    }
  }

  DRV_ipipePutBscBuf(bufIdBsc);

  return status;
}

int DRV_captureTestRun()
{
  int status, rawBufId;
//  int bufIdRszA, bufIdRszB;
  DRV_FrameCopyPrm frameCopy;
  OSA_BufInfo *pRawBufInfo, *pBufInfo;
  static int count=0;

  status = DRV_isifGetOutBuf(&rawBufId, OSA_TIMEOUT_FOREVER);
  if(status!=OSA_SOK) {
    OSA_ERROR("DRV_isifGetOutBuf()\n");
    return status;
  }
 
  #ifdef AVSERVER_DEBUG_VIDEO_CAPTURE_THR
    #ifdef AVSERVER_DEBUG_RUNNING
    OSA_printf("CAPTURE: Isif Buf %d\n", rawBufId);
    #endif
  #endif
 
  pBufInfo = DRV_isifGetOutBufInfo(rawBufId);
  OSA_printf("Rawbuf->Virtual address = %d, Rawbuf->Physical address = %d, Rawbuf-> width =%d, Rawbuf->height = %d\n",pBufInfo->virtAddr,pBufInfo->physAddr,pBufInfo->width,pBufInfo->height);

    if(pBufInfo) {

    #if 1
      static char filename[80];
      count++;
      if(count%100==0) {
        sprintf(filename, "\mnt\mmc\IMG_%04d_720x576.PPM", count);
        OSA_fileWriteFile(filename, pBufInfo->virtAddr,720*576*1.5);
      }
    #endif

    frameCopy.srcPhysAddr = pBufInfo->physAddr;
    frameCopy.srcVirtAddr = pBufInfo->virtAddr;
    frameCopy.dstPhysAddr = gDRV_testCtrl.displayInfo.physAddr[gDRV_testCtrl.displayBufId];
    frameCopy.dstVirtAddr = gDRV_testCtrl.displayInfo.virtAddr[gDRV_testCtrl.displayBufId];
    frameCopy.srcOffsetH  = OSA_align(720, 32);
    frameCopy.srcOffsetV  = 576;
    frameCopy.dstOffsetH  = gDRV_testCtrl.displayInfo.offsetH;
    frameCopy.dstOffsetV  = gDRV_testCtrl.displayInfo.offsetV;
    frameCopy.copyWidth   = gDRV_testCtrl.displayInfo.width;
    frameCopy.copyHeight  = gDRV_testCtrl.displayInfo.height;
    frameCopy.dataFormat  = gDRV_testCtrl.displayInfo.dataFormat;
    frameCopy.srcStartX   = 0;//(gDRV_testCtrl.captureInfo.ipipeInfo.rszInfo[DRV_IPIPE_RSZ_A].width-gDRV_testCtrl.displayInfo.width)/2;
    frameCopy.srcStartY   = 0;//(gDRV_testCtrl.captureInfo.ipipeInfo.rszInfo[DRV_IPIPE_RSZ_A].height-gDRV_testCtrl.displayInfo.height)/2;

    #ifdef DRV_CAPTURE_TEST_ENABLE_VS
    frameCopy.srcStartX   += gDRV_testCtrl.vsStatus.startX;
    frameCopy.srcStartY   += gDRV_testCtrl.vsStatus.startY;
    #endif

    frameCopy.dstStartX   = 0;
    frameCopy.dstStartY   = 0;

    status = DRV_frameCopy(NULL, &frameCopy);
    if(status!=OSA_SOK) {
      OSA_ERROR("DRV_frameCopy(A)\n");
    }

//  DRV_ipipePutRszBuf(DRV_IPIPE_RSZ_A, bufIdRszA);
//  DRV_ipipePutRszBuf(DRV_IPIPE_RSZ_B, bufIdRszB);
  DRV_displaySwitchBuf( &gDRV_testCtrl.displayHndl, &gDRV_testCtrl.displayBufId, 0, NULL);
  }
  return status;
}

void DRV_captureTestSignalHandler(int signum)
{
  gDRV_testCtrl.testQuit=1;
}

int DRV_captureTestMain(int argc, char **argv)
{
  int status;

  memset(&gDRV_testCtrl, 0, sizeof(gDRV_testCtrl));

  gDRV_testCtrl.testQuit = 0;

  OSA_attachSignalHandler(SIGINT, DRV_captureTestSignalHandler);

  status = DRV_init();
  if(status!=OSA_SOK)
    return status;

  status = DRV_captureTestOpen();
  if(status!=OSA_SOK)
    goto open_exit;

  status = DRV_captureStart(FALSE, TRUE);
  if(status!=OSA_SOK)
    goto start_exit;

  OSA_printf(" CAPTURE: Running.\n");

  status = OSA_SOK;
  while(!gDRV_testCtrl.testQuit && status==OSA_SOK)
    status = DRV_captureTestRun();

  DRV_captureStop();

start_exit:

  OSA_printf(" CAPTURE: Closing capture.\n");
  DRV_captureClose();

  OSA_printf(" CAPTURE: Closing display.\n");
  DRV_displayClose(&gDRV_testCtrl.displayHndl);

  #ifdef DRV_CAPTURE_TEST_ENABLE_FD
  DRV_faceDetectClose();
  #endif

  #ifdef DRV_CAPTURE_TEST_ENABLE_VS
  ALG_vstabDelete(gDRV_testCtrl.vsHndl);
  #endif

  if(gDRV_testCtrl.tmpBufSize) {
//    OSA_fileWriteFile("DATA_DUMP.YUV", gDRV_testCtrl.tmpBufVirtAddr, gDRV_testCtrl.tmpBufSize);
    OSA_cmemFree(gDRV_testCtrl.tmpBufVirtAddr);
  }

open_exit:
  OSA_printf(" CAPTURE: Exiting.\n");
  DRV_exit();
  OSA_printf(" CAPTURE: Bye Bye !!!\n");

  return status;
}

  • Hi Swathi,

    It will be bit tedious to decode the entire thing.

    Well are you using any JTAG debugger tool ?

    It most likely seems like the memory corruption !! You can find the root cause for segmentation fault using KGDB or GDB ..

    Regards,

    Lyf



  • Hi,


    Thanks for your time and reply. I was just trying few stuffs out in getting this to work.

    So, I now have a code that does the following.


    Sensor input -> TVP(BT-656 output) -> ISIF Capture ( YUV420 ) -> Display.

    My resolution is 720 x 576.

    But the display image looks like this. I have checked with the capture and display formats and addresses.

    Should I do some resize before I display for a YUV data out from ISIF ? Can somebody correct me if am wrong.

    Thanks,

    Swathi