*参照元 [#x5e93a01]
#backlinks

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

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


**引数 [#d261ec0b]
-struct vb2_queue *q
--
--[[linux-4.4.1/vb2_queue]]
-int *fd
--
-unsigned int type
--
-unsigned int index
--
-unsigned int plane
--
-unsigned int flags
--


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


**参考 [#u50f0daf]


*実装 [#z2ce41c9]
 /**
  * vb2_core_expbuf() - Export a buffer as a file descriptor
  * @q:          videobuf2 queue
  * @fd:         file descriptor associated with DMABUF (set by driver) *
  * @type:       buffer type
  * @index:      id number of the buffer
  * @plane:      index of the plane to be exported, 0 for single plane queues
  * @flags:      flags for newly created file, currently only O_CLOEXEC is
  *              supported, refer to manual of open syscall for more details
  *
  * The return values from this function are intended to be directly returned
  * from vidioc_expbuf handler in driver.
  */
 int vb2_core_expbuf(struct vb2_queue *q, int *fd, unsigned int type,
                 unsigned int index, unsigned int plane, unsigned int flags)
 {
         struct vb2_buffer *vb = NULL;
         struct vb2_plane *vb_plane;
         int ret;
         struct dma_buf *dbuf;
 
-
--[[linux-4.4.1/vb2_buffer]]
--[[linux-4.4.1/vb2_plane]]
--[[linux-4.4.1/dma_buf]]

         if (q->memory != VB2_MEMORY_MMAP) {
                 dprintk(1, "queue is not currently set up for mmap\n");
                 return -EINVAL;
         }
 
-
--[[linux-4.4.1/dprintk()]]

         if (!q->mem_ops->get_dmabuf) {
                 dprintk(1, "queue does not support DMA buffer exporting\n");
                 return -EINVAL;
         }
 
-q->mem_ops は const struct vb2_mem_ops * 型
--[[linux-4.4.1/vb2_mem_ops]]

         if (flags & ~(O_CLOEXEC | O_ACCMODE)) {
                 dprintk(1, "queue does support only O_CLOEXEC and access mode flags\n");
                 return -EINVAL;
         }
 
         if (type != q->type) {
                 dprintk(1, "invalid buffer type\n");
                 return -EINVAL;
         }
 
         if (index >= q->num_buffers) {
                 dprintk(1, "buffer index out of range\n");
                 return -EINVAL;
         }
 
         vb = q->bufs[index];
 
-q->bufs は struct vb2_buffer *[VB2_MAX_FRAME] 型
--[[linux-4.4.1/vb2_buffer]]
--[[linux-4.4.1/VB2_MAX_FRAME]]

         if (plane >= vb->num_planes) {
                 dprintk(1, "buffer plane out of range\n");
                 return -EINVAL;
         }
 
         if (vb2_fileio_is_active(q)) {
                 dprintk(1, "expbuf: file io in progress\n");
                 return -EBUSY;
         }
 
-
--[[linux-4.4.1/vb2_fileio_is_active()]]

         vb_plane = &vb->planes[plane];
 
-vb->planes は struct vb2_plane[VB2_MAX_PLANES] 型
--[[linux-4.4.1/vb2_plane]]
--[[linux-4.4.1/VB2_MAX_PLANES]]

        dbuf = call_ptr_memop(vb, get_dmabuf, vb_plane->mem_priv,
                                flags & O_ACCMODE);
-vb->vb2_queue->mem_ops->get_dmabuf を呼び出す。
--vb->vb2_queue は struct vb2_queue * 型
--vb->vb2_queue->mem_ops は const struct vb2_mem_ops * 型
--[[linux-4.4.1/vb2_queue]]
--[[linux-4.4.1/vb2_mem_ops]]
--[[linux-4.4.1/call_ptr_memop()]]

        if (IS_ERR_OR_NULL(dbuf)) {
                dprintk(1, "failed to export buffer %d, plane %d\n",
                        index, plane);
                return -EINVAL;
        }

         if (IS_ERR_OR_NULL(dbuf)) {
                 dprintk(1, "failed to export buffer %d, plane %d\n",
                         index, plane);
                 return -EINVAL;
         }
 
-
--[[linux-4.4.1/IS_ERR_OR_NULL()]]

        ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE);
        if (ret < 0) {
                dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
                        index, plane, ret);
                dma_buf_put(dbuf);
                return ret;
        }

         ret = dma_buf_fd(dbuf, flags & ~O_ACCMODE);
         if (ret < 0) {
                 dprintk(3, "buffer %d, plane %d failed to export (%d)\n",
                         index, plane, ret);
                 dma_buf_put(dbuf);
                 return ret;
         }
 
-
--[[linux-4.4.1/dma_buf_fd()]]
--[[linux-4.4.1/dma_buf_put()]]

        dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
                index, plane, ret);
        *fd = ret;

        return 0;
}
EXPORT_SYMBOL_GPL(vb2_core_expbuf);
         dprintk(3, "buffer %d, plane %d exported as %d descriptor\n",
                 index, plane, ret);
         *fd = ret;
 
         return 0;
 }
 EXPORT_SYMBOL_GPL(vb2_core_expbuf);
-
--[[linux-4.4.1/EXPORT_SYMBOL_GPL()]]


*コメント [#p66cec3a]

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