*参照元 [#d1fc00e4]
#backlinks

*説明 [#f9810c58]
-パス: [[linux-4.4.1/drivers/media/v4l2-core/videobuf2-core.c]]

-FIXME: これは何?
--説明


**引数 [#j21002e1]
-struct vb2_queue *q
--
--[[linux-4.4.1/vb2_queue]]
-enum vb2_memory memory
--
--[[linux-4.4.1/vb2_memory]]
-unsigned int num_buffers
--
-unsigned int num_planes
--


**返り値 [#q9733924]
-int
--


**参考 [#kb1f0a16]


*実装 [#m6fa5210]
 /**
  * __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;
 
-
--[[linux-4.4.1/vb2_buffer]]

         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;
                 }
 
-
--[[linux-4.4.1/kzalloc()]]
--[[linux-4.4.1/dprintk()]]

                 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;
                         }
-
--[[linux-4.4.1/__vb2_buf_mem_alloc()]]
--[[linux-4.4.1/kfree()]]

                         /*
                          * 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;
                         }
-
--vb->vb2_queue->ops->buf_init が呼ばれる。
---vb->vb2_queue は struct vb2_queue * 型
---[[linux-4.4.1/vb2_queue()]]
---[[linux-4.4.1/vb2_queue]]
---vb->vb2_queue->ops は const struct vb2_ops * 型
---[[linux-4.4.1/vb2_ops()]]
---[[linux-4.4.1/vb2_ops]]
--[[linux-4.4.1/call_vb_qop()]]
--[[linux-4.4.1/__vb2_buf_mem_free()]]

                 }
 
                 q->bufs[q->num_buffers + buffer] = vb;
         }
 
         __setup_lengths(q, buffer);
         if (memory == VB2_MEMORY_MMAP)
                 __setup_offsets(q, buffer);
 
-
--[[linux-4.4.1/__setup_lengths()]]
--[[linux-4.4.1/__setup_offsets()]]

         dprintk(1, "allocated %d buffers, %d plane(s) each\n",
                         buffer, num_planes);
 
         return buffer;
 }


*コメント [#h540a849]

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS