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.

DM368 ChainMode Resolution Change Dynamically

Hi ,

has any one tried changing the resolution dynamically while capture resolution is same, in chain mode.

as we know in chain mode at a time only one user resolution we can handle with one resizer.

so i want to change the resolution at runtime, i.e capture resolution will be same but output resolution will be resized to some different resolution.


for example suppose capture resolution is 1920x1080.

if i want the resized output resolution as 1280x1024 

setting the 

   fmt.fmt.pix.width        = 1280;

    fmt.fmt.pix.height       = 1024;

before ioctl(hCapture->fd, VIDIOC_S_FMT, &fmt) call in Capture_create() will give the resized output which is set at capture initialization time.


But if i need to get different resized resolution ( only one resolution at a time ) at run time how can i do it i.e

for dynamically changing the

    fmt.fmt.pix.width       
    fmt.fmt.pix.height    

what i need to do.

if i set fmt.fmt.pix.width   and   fmt.fmt.pix.height    dynamically and call ioctl(hCapture->fd, VIDIOC_S_FMT, &fmt)

i am getting error.

i checked in VIDIOC_S_FMT driver code where i observed it is expecting

ioctl(hCapture->fd, VIDIOC_STREAMON, &type)  should not start before VIDIOC_S_FMT  ioctl call.

 

so i tried to block VIDIOC_STREAMON in Capture_create() and called before Capture_get() as below.


------------------------------------------------------------------------------------------------------------

{

   enum v4l2_buf_type type;   
    struct v4l2_format    fmt;   

   // assert(m_capture);

    int width = 1280;
    int height = 1024;
 
    fmt.fmt.pix.width        = width;
    fmt.fmt.pix.height       = height;

   fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_NV12;
   
    fmt.fmt.pix.bytesperline = 0;
    fmt.fmt.pix.sizeimage = 0;
   
 fmt.fmt.pix.field        = V4L2_FIELD_INTERLACED;
    if (ioctl(hCapture->fd, VIDIOC_S_FMT, &fmt) == -1) {
        printf("Failed VIDIOC_S_FMT  (%s)\n", strerror(errno));
        //cleanup(hCapture);
        //return NULL;
    } 

     /* Start the video streaming */
     type = V4L2_BUF_TYPE_VIDEO_CAPTURE;

 //if(attrs->resizer_is_chainmode == TRUE) {
 // type = type | 0x0100;
 // }
    type = type | 0x0100;
    if (ioctl(hCapture->fd, VIDIOC_STREAMON, &type) == -1) {
        printf("VIDIOC_STREAMON failed \n");
        //cleanup(m_capture);
        //return NULL;
    }

    hCapture->started = TRUE;

----------------------------------------------------------------------------------------




 

 

  • Hi,

    sujit mahapatro said:

    as we know in chain mode at a time only one user resolution we can handle with one resizer.

    It is not necessary that only one resizer output comes in continuous mode. You can configure second resizer also using "output2" structure of rsz_continuous_config .

     

    BTW, following sample sequence should work for you to change the capture resolution. You need to call STREAMOFF ioctl before calling S_FMT ioctl. The following sequence shows how to configure RSZB dynamically (without closing and opening the resizer device) and how to change the input cropping parameters using S_CROP ioctl also.

     

    > > 1) open device

    > > 2) set input & standard

    > > 3) call IOCTL S_FMT

    > > 4) call IOCTL REQBUF (to set capture buffer)

    > > 5) call IOCTL STREAMON (to begin capture)

    > > 6) call IOCTL STREAMOFF (to stop capture)

    > > 7) call IOCTL RSZ_S_CONFIG (say RZB output size is QVGA)

    > > 8) call IOCTL PREV_S_CONFIG

    > > 9) call IOCTL VIDIOC_G_IPNPUT

    > > 10) call IOCTL VIDIOC_S_IPNPUT

    > > 11) call IOCTL S_FMT (say RZA output size is 720P(1280x720))

    > > 12) call IOCTL S_CROP (input size(720x480), change offset to (50x50))

    > > 13) call IOCTL STREAMON (to begin capture)

     

     

  • Hi Anshuman,

    Thanks for the detailed information.

    i am trying the same but VIDIOC_STREAMON ioctl gives error with error code input /output error.