参照元

説明

引数

返り値

参考

実装

/**
 * __vb2_queue_alloc() - allocate videobuf buffer structures and (for MMAP type)
 * video buffer memory for all buffers/planes on the queue and initializes the
 * queue
 *
 * Returns the number of buffers successfully allocated.
 */
static int __vb2_queue_alloc(struct vb2_queue *q, enum vb2_memory memory,
                             unsigned int num_buffers, unsigned int num_planes)
{
        unsigned int buffer;
        struct vb2_buffer *vb;
        int ret;
        for (buffer = 0; buffer < num_buffers; ++buffer) {
                /* Allocate videobuf buffer structures */
                vb = kzalloc(q->buf_struct_size, GFP_KERNEL);
                if (!vb) {
                        dprintk(1, "memory alloc for buffer struct failed\n");
                        break;
                }
                vb->state = VB2_BUF_STATE_DEQUEUED;
                vb->vb2_queue = q;
                vb->num_planes = num_planes;
                vb->index = q->num_buffers + buffer;
                vb->type = q->type;
                vb->memory = memory;

                /* Allocate video buffer memory for the MMAP type */
                if (memory == VB2_MEMORY_MMAP) {
                        ret = __vb2_buf_mem_alloc(vb);
                        if (ret) {
                                dprintk(1, "failed allocating memory for "
                                                "buffer %d\n", buffer);
                                kfree(vb);
                                break;
                        }
                        /*
                         * Call the driver-provided buffer initialization
                         * callback, if given. An error in initialization
                         * results in queue setup failure.
                         */
                        ret = call_vb_qop(vb, buf_init, vb);
                        if (ret) {
                                dprintk(1, "buffer %d %p initialization"
                                        " failed\n", buffer, vb);
                                __vb2_buf_mem_free(vb);
                                kfree(vb);
                                break;
                        }
                }

                q->bufs[q->num_buffers + buffer] = vb;
        }

        __setup_lengths(q, buffer);
        if (memory == VB2_MEMORY_MMAP)
                __setup_offsets(q, buffer);
        dprintk(1, "allocated %d buffers, %d plane(s) each\n",
                        buffer, num_planes);

        return buffer;
}

コメント


トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2016-02-09 (火) 11:28:12