参照元

説明

引数

返り値

参考

実装

static int vb2_dc_map_dmabuf(void *mem_priv)
{
        struct vb2_dc_buf *buf = mem_priv;
        struct sg_table *sgt;
        unsigned long contig_size;
        if (WARN_ON(!buf->db_attach)) {
                pr_err("trying to pin a non attached buffer\n");
                return -EINVAL;
        }

        if (WARN_ON(buf->dma_sgt)) {
                pr_err("dmabuf buffer is already pinned\n");
                return 0;
        }
        /* get the associated scatterlist for this buffer */
        sgt = dma_buf_map_attachment(buf->db_attach, buf->dma_dir);
        if (IS_ERR(sgt)) {
                pr_err("Error getting dmabuf scatterlist\n");
                return -EINVAL;
        }
        /* checking if dmabuf is big enough to store contiguous chunk */
        contig_size = vb2_dc_get_contiguous_size(sgt);
        if (contig_size < buf->size) {
                pr_err("contiguous chunk is too small %lu/%lu b\n",
                        contig_size, buf->size);
                dma_buf_unmap_attachment(buf->db_attach, sgt, buf->dma_dir);
                return -EFAULT;
        }
        buf->dma_addr = sg_dma_address(sgt->sgl);
        buf->dma_sgt = sgt;
        buf->vaddr = NULL;
        return 0;
}

コメント


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