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.

Is Camera image format received through V4l2 Capture driver 16 bit bayer or NV12 when Single shot mode is enabled on DM 365 ?

Hi

I'm trying to configure the camera capture to single shot mode and get the camera data. I'm using 2.6.32.17 kernel and sdk 4.2  on DM 365 leopard board.As you might be aware that it is interfaced through ISIF.

When previewer and resizer are chained everything works fine but does not work when single shot mode is enabled

when i changed to single shot mode, the VIDIOC_S_STD ioctl fails, In below code if the vpfe is not chained the pix format is not set and returns error.

 /* At CCDC we need to set pix format based on source. */
    if (vpfe_dev->imp_chained) {
        if (vpfe_dev->current_subdev->is_camera)
            pix_fmt = V4L2_PIX_FMT_SBGGR16;
        else if (pix_fmt == V4L2_PIX_FMT_NV12)
            pix_fmt = V4L2_PIX_FMT_UYVY;
    }   
    if (ccdc_dev->hw_ops.set_pixel_format(pix_fmt) < 0) {
        v4l2_err(&vpfe_dev->v4l2_dev,
            "couldn't set pix format in ccdc\n");
        return -EINVAL;
    }   

I tried to hard code the pixel format to V4L2_PIX_FMT_SBGGR16 and check if it works but it did not work since vpfe_dev->imp_chained is not chained i,,e the previewer and resizer are configured  in single shot mode ?

The following are my observations and assumptions


After going through the driver code and the comments, i could understand that VIDIOC_S_STD should NOT be called if the camera data is coming through the ISIF and VIDIOC_S_STD should be called only when it is from a TV decoder chip. So I commented the calling of this ioctl in my application.

VIDIOC_S_FMT ioctl is called with PIX_FMT being , V4L2_PIX_FMT_NV12. When i call the VIDIO_G_FMT after setting it , the format that i received is V4L2_PIX_FMT_SBGGR16 but not V4L2_PIX_FMT_SBGGR16.

conclusion:

When i went through the code, 16 bit bayer i/p is converted to v4l2_pix_fmt_nv12 when it is chained and this does not happen when it is non-chained. which means that the camera data that is received is in BAYER format and not NV12 format.

Is my conclusion right ? i,,e in single shot mode we get 16 bit RAW bayer after which we need to do resizing and format conversion to NV12 is application ?

Assuming that my conclusion is right, i configured the resizer to do format conversion from 16 bit bayer to NV12. I see that the picture in green and blue color i,,e there is movement of image but not in right format.

 

Is there any demo application which configures the camera capture in SINGLE SHOT mode and gets the camera data in NV12 format ??

 

 

 


 

  • Pradeep,

    looks like there is a confusion about terms 'single-shot' and 'continuous'.

    single-shot mode:- In this previewer or resizer or (previewer and resizer chained together) is configured to work on one input video buffer produce the output buffer.

    Example:-

    1. Previewer taking Bayer-16 buffer and outputting yuv422 buffer.

    2. Resizer taking yuv422 buffer and outputting yuv422/nv12 buffer with different height and width.

    Here single-shot means working on one buffer at a time. Next time one buffer wants to be processed, HW needs to be enabled again.

    continuous mode:-  In this case, previwer and resizer are chained to ISIF ( ISIF->PRV->RSZ) so that whatever buffers ISIF is capturing are continuously fed to PRV/RSZ for processing.

    Example:- CAMERA->ISIF->PRV->RSZ

    Camera outputs stream of Bayer frames, ISIF channels them to PRV which converts them to yuv422 format and then channels to RSZ which resizes the frames and converts them to NV12 format. This will be done till application informs driver to stop.

    I believe what you are asking is for 'capturing just a single buffer from sensor'. This is not possible as driver supports 'streaming' which needs at-least 3 buffers.

    Hope this helps. Let me know your exact requirement so that I can help you.

  • Hi Nagabhushan

    Thanks for reply. I would explain what i'm looking for and the problem .  I want to use resizer in single shot mode because i've to use resizer for multiple purpose like
    Task 1. downscaling camera image from 640x480 to 352 *288 and encode it . 
    Task 2. downscale same camera image from 640x480 to 176*144
    Task 3. Upscale any incoming video stream say from 320x240 to 640x480 (say LCD).
    Task 4. Upscale the same incoming image say from 320x240 to 720 x480 (say TV)

    for The above 4 operations i want to use resizer. Now the bottle neck which i see is the resizer being locked up at VPFE i.,e continuous mode. My aim is to break the link

    PRV->RSZ link CAMERA->ISIF->PRV->RSZ 

    i'm using the V4l2 /dev/video0 capture driver and configuring it to get camera image.  I'm not opening the previewer device (the result is the same even i configure the previewer in single shot mode).  The logic which i follow right now is

    Thr 1

    while (1)

    {

          get data from camera i,,e through v4l2 camera capture (/dev/video0) i,,e call VIDIOC_DQBUF

        Resize the camera image so that Task 1 and 2 are completed

        call the VIDIOC_QBUF after using the camera frame

       By doing this I get the camera image continuously but i feel it is in different format might be that this camera image has to be given to PRV and then to resize and NOT directly to resizer . Is it so ? Please explain
    }

    Thr 2

    while (1)

    {

     perform Task 3

    perform Task 4.

    }

    Please note that calling the resizer is mutually exclusive i,,e protected by lock. I hope i've clearly explained about the sequence of operation that i'm doing and what is my requirement . If not please let me know

  • Driver is designed in such a way that PRV and RSZ can only work in either single-shot or continuous modes. If you want to change the mode, you need to reboot the board with

    boot parameter dm365_ipipe.oper_mode set correctly.

    dm365_ipipe.oper_mode=0 means PRV and RSZ can be configured in continuous mode with ISIF

    dm365_ipipe.oper_mode=1 means PRV and RSZ can be configured in single-shot mode

    For your use case, you can follow below method.

    Capture from ISIF.

    Configure (PRV and RSZ) in single-shot mode.

    Based on what buffers you are capturing from ISIF, you can configure PRV and RSZ and do single-shot processing, then send the output to display video node.

    One of the dm355 examples I could see which very closely matches above scenario is here - http://arago-project.org/git/projects/?p=examples-davinci.git;a=blob;f=imp-prev-rsz/dm355/capture_prev_rsz_ss_raw_bayer.c;h=dd428ef292e14da040147e08f023ff7a4ff2f07c;hb=ffbe85626735f3773801811a3e58d6f17e17bbe7

    Hope this helps.

  • Hi Nagabhushan,

        I searched for similar reference on dm365 in sdk 4.2 . I did not find the reference file which captures raw image, gives it to previewer, and then resizes in SINGLE shot where as i could find capturing image from TV decoder, giving it to previewer and resizer. Is there any similar reference code available on dm365 ?

    I went through the dm 365 reference code which captures raw image-> ipipe->resize in continuous mode. I tried to break this link by taking the dm 355 single shot reference. For this i followed the below procedure. I'm able to get the camera data and i feel it is in still raw format that is the image contains pink and blue information i,,e i see the image being captured but seems to be problem in pix format mismatch. The following is my understanding. I went through the VPFE, and driver code to understand the problem Please correct me if i'm wrong.

    1 . If i were to get the camera image from sensor (which is configured to give o/p in RAW bayer ) in yuv420sp format then first i need to get the data from CCDC in V4L2_PIX_FMT_SBGGR16 i,,e 16 bit bayer image. so i configured it by calling VIDIOC_S_FMT in SBGGR16 in progressive mode.

     camera-> isif/CCDC-----> sdram (SBGGR16 say address X). i,,e call VIDIOC_DQBUF to get the camera image from CCDC .

    2. Now this frame has to be given to IPIPE. I see driver code  using the terminology of IMP (image processing block). After going through the code i felt that it is IPIPE + resizer. I've configured the previewer in Single shot mode with i/p pixel format as IPIPE_BAYER (16 bit) and o/p as IPIPE_UYVY ,allocated buffers through cmem APIs

    call PREV_PREVIEW ioctl with following configuration.

    sdram (address X) rcvd from CCDC-----> i/p (pix_fmt IPIPE_BAYER)  call PREV_PREVIEW ioctl --------->sdram address (Y) (uyvy format)

    I took the dump of  the camera image at address (Y) and and opened the file in tools like yuv player which shows images that are in yuv formats. The camera image present at address Y is not in proper format.I've attached the dump taken at address Y.

    Please let me know if my procedure is wrong ? I tried to configure the CCDC and previewer by taking the configuration values present in capture_prev_rsz_onthe_fly_bayer.c but sill i see the same problem. I'm not understand which values to be tuned to get the correct image where the problem is ?

    I went through the encodedecode demo app to check the CCDC raw config params and previewer config params. Is does not configure ccdc params or previewer params which means that the default values in the driver are used for ccdc and previewer configuration. so i commented the configuration of CCDC raw parameters and previewer parameters i,,e i also tried to use the default values in the driver. With configuration of CCDC and IPIPE being same for continuous and single shot mode, if i follow step 1 and 2 , i should get the same type of image as i get when i configured previewer and resizer in continuous mode. In this case also the camera image which is captured contains pink and green colors.

    Please let me know if any one tried to capture from ISIF then given it to previewer in single shot successfully ? Are there any steps which i'm missing out in getting the image from sensor camera in uyvy format ?

     

     

     

     

  •  Hi,

    Is there any update on the issue ?

     

     

     

  • There is a single shot application available on arago(might be there in SDK also). You might wan to check the same to check your implementation of previewer single shot.

    http://arago-project.org/git/projects/?p=examples-davinci.git;a=blob;f=imp-prev-rsz/dm365/do_preview_resize.c;h=d150d7a217baa8fb920f49ecda75e09669558987;hb=ffbe85626735f3773801811a3e58d6f17e17bbe7