*参照元 [#q68a9020]
#backlinks

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

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


**引数 [#qf5022a2]
-struct dma_buf *dbuf
--
--[[linux-4.4.1/dma_buf]]
-struct device *dev
--
--[[linux-4.4.1/device]]
-struct dma_buf_attachment *dbuf_attach
--
--[[linux-4.4.1/dma_buf_attachment]]


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


**参考 [#j4c7e519]


*実装 [#w3d8541e]
 static int vb2_dc_dmabuf_ops_attach(struct dma_buf *dbuf, struct device *dev,
         struct dma_buf_attachment *dbuf_attach)
 {
         struct vb2_dc_attachment *attach;
         unsigned int i;
         struct scatterlist *rd, *wr;
         struct sg_table *sgt;
         struct vb2_dc_buf *buf = dbuf->priv;
         int ret;
 
-
--[[linux-4.4.1/vb2_dc_attachment]]
--[[linux-4.4.1/scatterlist]]
--[[linux-4.4.1/sg_table]]
--[[linux-4.4.1/vb2_dc_buf]]

         attach = kzalloc(sizeof(*attach), GFP_KERNEL);
         if (!attach)
                 return -ENOMEM;
 
-
--[[linux-4.4.1/kzalloc()]]

         sgt = &attach->sgt;
         /* Copy the buf->base_sgt scatter list to the attachment, as we can't
          * map the same scatter list to multiple attachments at the same time.
          */
         ret = sg_alloc_table(sgt, buf->sgt_base->orig_nents, GFP_KERNEL);
         if (ret) {
                 kfree(attach);
                 return -ENOMEM;
         }
 
-
--buf->sgt_base は struct sg_table 型
--buf->sgt_base->orig_nents は unsigned long 型
--[[linux-4.4.1/sg_table]]
--[[linux-4.4.1/sg_alloc_table()]]
--[[linux-4.4.1/kfree()]]

         rd = buf->sgt_base->sgl;
         wr = sgt->sgl;
         for (i = 0; i < sgt->orig_nents; ++i) {
                 sg_set_page(wr, sg_page(rd), rd->length, rd->offset);
                 rd = sg_next(rd);
                 wr = sg_next(wr);
         }
 
-
--buf->sgt_base->sgl は struct scatterlist * 型
--[[linux-4.4.1/scatterlist]]
--[[linux-4.4.1/sg_set_page()]]
--[[linux-4.4.1/sg_page()]]
--[[linux-4.4.1/sg_next()]]

         attach->dma_dir = DMA_NONE;
         dbuf_attach->priv = attach;
 
         return 0;
 }


*コメント [#zfaa0091]


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