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.

davinci_display.c problem in ti-davinci

In davinci_doioctl:

case VIDIOC_DQBUF:

The function videobuf_dqbuf will call another function named videobuf_waiton:

 

int videobuf_waiton(struct videobuf_buffer *vb, int non_blocking, int intr)

{

    int retval = 0;

    struct timeval uTimeStart, uTimeStop;

    unsigned long  timeDelta;

   

    DECLARE_WAITQUEUE(wait, current);

 

    MAGIC_CHECK(vb->magic,MAGIC_BUFFER);

    add_wait_queue(&vb->done, &wait);

   

    while (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED) {

        if (non_blocking) {

            retval = -EAGAIN;

            break;

        }

        set_current_state(intr  ? TASK_INTERRUPTIBLE: TASK_UNINTERRUPTIBLE);

        printk("22222vb->state=%d\n",vb->state);

        if (vb->state == STATE_ACTIVE || vb->state == STATE_QUEUED){

            do_gettimeofday(&uTimeStart);

 

            schedule();

 

            do_gettimeofday(&uTimeStop);

            timeDelta = (unsigned long)((uTimeStop.tv_sec-uTimeStart.tv_sec)*1000000+(uTimeStop.tv_usec-uTimeStart.tv_usec));

            printk("schedule: %ld ms\n",timeDelta/1000);

 

        }

        set_current_state(TASK_RUNNING);

        if (intr && signal_pending(current)) {

            dprintk(1,"buffer waiton: -EINTR\n");

            retval = -EINTR;

            break;

        }

    }

    remove_wait_queue(&vb->done, &wait);

    return retval;

}

 

Can anybody tell me the usage of this function and in what case that the vb->state == STATE_ACTIVE ,because in my programme ,the vb->state is always STATE_ACTIVE , i don't known why ?

In my opinion , this function is used to wait a usable buffer , is it right ?

Any advice will be appreciate .

 

regards,

Katee

  • Katee,

    If you can provide more details like versions of applications/sdk/drivers you used, it will be easier for us to help you. Looking at the code above, I think STATE_ACTIVE is set when the buffer is being displayed[in display driver case] or being captured[in capture driver case].  It should be cleared from STATE_ACTIVE when display/capture is done on that buffer.

    Regards,

    Nag

     

     

  • To add to the above reply,

    I believe there are two cases when this situation can happen.

    1. When H/W is not triggering a interupt(cant able to display the buffer?). In that case isr() will not be called, inside which buffer state updation happens.

    2. At least 2 buffers are needed for streaming, otherwise DQ might not happen. Pl check.

     

    hope this helps,

    Regards,

    Nag

  • Nag,

       Thank u so much for your help !  Your replies are very helpful to me .  I am checking my code now , thanks again..

    regards,

    Katee