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.

Linux/AM5718: AM5718 custom board interfacing with camera sensor

Part Number: AM5718

Tool/software: Linux

Hi Margarita,

i am working on dual-camera-demo to achiieve functionality i want to. So i have made many changes which is here attached.

One problem that i am facing in this is when ever i will try to set different format from existing one i will get the below error.

VIDIOC_S_FMT: Device or resource busy

I have tried many methods to solve this issue will you please guide me to overcome this problem.

Will you please look at below attached code .Specially loopback.c in function int main(). Where i want to set different resolution after capture successfully one image.

One thing that i want to mention here is i don't want to close fd of device whenever i will set resolution.So that's why i have made some changes in exit sequence.

Thanks,

Simit4405.dual-camera-demo-modified.zip

  • Hello Simit,

    I will take a look. I will get back to you when I have something.

    BR
    Margarita
  • Hello,

    On first look I see this in the code :
    cap0_device.fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
    but I do not see V4L2_PIX_FMT_SGBRG8 where is set.

    BR
    Margarita
  • Hello,

    We have hard binded the PixelFormat to V4L2_PIX_FMT_SGBRG8.
    So what ever we will set it is taken as default to V4L2_PIX_FMT_SGBRG8.
    eventhough i have changed cap0_device.fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_SGBRG8; but still got the same issue.

    Thanks,
    Simit
  • Hello,

    This is Gentle reminder.

    Thanks,
    Simit
  • Hello,

    Please in the guide there is Debugging chapter that you could try.
    When you request the buffers they will be allocated based on the current format. Changing the format later will mean a change in buffer size. Please try to free the buffer and re-allocate it again.
    You could find more information about V4L2 VIDIOC_S_FMT IOCTL here.
    linuxtv.org/.../vidioc-g-fmt.html

    BR
    Margarita
  • Hello,

    We are following same thing that you have mentioned but still we are getting the issue while setting the format.

    I don't understand while it is still stuck in set format .Will you please help me in this.

    Thanks,
    Simit
  • Hello,

    Please check this bytes_pp = 2 it is for yuyv format. You must change it to 1.

    BR
    Margarita
  • Hello,

    Sorry ignore last answer I was looking the original code. You may check this thread it could be in help:
    e2e.ti.com/.../704311

    BR
    Margarita
  • Hello,

    I don't get anything from your referring thread the pixle format i have already changed from YUYV to V4L2_PIX_FMT_SGBRG8.

    Still if you find anything will you please guide me.

    What i understand here is that even though i will free the buffer i don't think it will affected because after getting error in Set_Format i will also getting problem in all remaining process.

    This is my output log will you please look into this and let me know if you find any problem here.
    Here i am trying to set same resolution 2 times . On First time it will succedded but in second time i will get the error of" VIDIOC_S_FMT: Device or resource busy" even though i am using Following function before setting resolution second time.

    end_streaming();   // This will use to set STREAM_OFF
    free_vid_buffers(NBUF);  // This will free CMEM buffers
    v4l2_exit_device1(&cap0_device); // Here i am freeing cap0_device buffer


    (NOTE : i have removed completely drm because in my application i don't need any display device that's why i have changed api)

    Starting of First Image
    **************
    device->fd == 4

    Capture 0: Opened Channel

    Capture 0: Init done successfully

    Capture 0: Capable of streaming

    set_image_resolution_3
    alloc : -> 4 147488
    Allocating memory from CMEM pool
    cmem_buf = 147504
    CMEM buffer pointer is 0xb5428000
    alloc : -> 4 147568
    Allocating memory from CMEM pool
    cmem_buf = 147584
    CMEM buffer pointer is 0xb47a2000
    alloc : -> 4 147648
    Allocating memory from CMEM pool
    cmem_buf = 147664
    CMEM buffer pointer is 0xb3b1c000
    init_loopback1_1
    init_loopback1_2
    init_loopback1_3
    init_loopback1_4
    address = 0x22aa0 and 141984
    deque = 13128960
    Width=4208 Height=3120
    1----> 66.322998 milliseconds
    2----> 142.744003
    3----->1.263000
    address = 0x22aa0 and 141984

    Starting of Second image
    **************
    Capture 0: Capable of streaming

    VIDIOC_S_FMT: Device or resource busy
    alloc : -> 4 147488
    Allocating memory from CMEM pool
    cmem_buf = 147504
    CMEM buffer pointer is 0xb5428000
    alloc : -> 4 147568
    Allocating memory from CMEM pool
    cmem_buf = 147584
    CMEM buffer pointer is 0xb47a2000
    alloc : -> 4 147648
    Allocating memory from CMEM pool
    cmem_buf = 147664
    CMEM buffer pointer is 0xb3b1c000
    init_loopback1_1
    init_loopback1_2
    init_loopback1_3
    ERROR:v4l2_request_buffer:310: VIDIOC_REQBUFS failed: Inappropriate ioctl for device (-1)
    Error
    init_loopback1_4
    ERROR:v4l2_queue_buffer:375: invalid buffer
    ERROR:v4l2_queue_buffer:381: VIDIOC_QBUF failed: Inappropriate ioctl for device (-1)
    ERROR:v4l2_queue_buffer:381: VIDIOC_QBUF failed: Inappropriate ioctl for device (-1)
    address = 0x22aa0 and 141984
    ERROR:v4l2_stream_on:264: VIDIOC_STREAMON failed: Inappropriate ioctl for device (-1)
    address = 0x22aa0 and 141984
    ERROR:v4l2_stream_off:285: VIDIOC_STREAMOFF failed: Inappropriate ioctl for device (-1)
    *** Error in `./a.out': double free or corruption (top): 0x00024110 ***
    Aborted (core dumped)



    Thanks,
    Simit

  • Hello,

    Let me clear something I get confused from your first post about the format.
    You are able to capture in SGBRG8 and you do not see any errors right?
    You are observing the errors when you are trying to change the resolution at run time?

    BR
    Margarita
  • Hi Margarita,


    somehow we manage the resolution change issue but still we did not get the expected speed.

    Now we must need to change the cal driver for line by line instead of frame by frame.
    so please guide us for required modification for line by line implementation.
    this is the our last hope to increase the fps for our end application goal.

    Thanks,
    Simit
  • Hello,

    Simit Ghane said:
    somehow we manage the resolution change issue but still we did not get the expected speed.

    Great, please verify your answer so this thread to be closed.

    Simit Ghane said:
    Now we must need to change the cal driver for line by line instead of frame by frame.
    so please guide us for required modification for line by line implementation.

    Please open a new thread about this.

    Thank you!

    BR
    Margarita