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