• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dma_free_writecombine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dma_free_writecombine函数的典型用法代码示例。如果您正苦于以下问题:C++ dma_free_writecombine函数的具体用法?C++ dma_free_writecombine怎么用?C++ dma_free_writecombine使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dma_free_writecombine函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sun7i_pcm_free_dma_buffers

static void sun7i_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
	struct snd_pcm_substream *substream;
	struct snd_dma_buffer *buf;
	int stream;
	
	for (stream = 0; stream < 2; stream++) {
		substream = pcm->streams[stream].substream;
		if (!substream)
			continue;

		buf = &substream->dma_buffer;
		if (!buf->area)
			continue;

		dma_free_writecombine(pcm->card->dev, buf->bytes,
				      buf->area, buf->addr);
		buf->area = NULL;
	}
}
开发者ID:mfkiwl,项目名称:PhoenixA20_linux_sourcecode,代码行数:20,代码来源:sun7i-i2sdma.c


示例2: nusmart_pcm_free_dma_buffers

void nusmart_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
    struct snd_pcm_substream *substream;
    struct snd_dma_buffer *buf;
    int stream;

    for (stream = 0; stream < 2; stream++) {
        substream = pcm->streams[stream].substream;
        if (!substream)
            continue;
        buf = &substream->dma_buffer;
        if (!buf->area)
            continue;
        DBG_PRINT("pcm_free_dma_buffer, size = %x, stream = %x\n",
                  buf->bytes, stream);

        dma_free_writecombine(pcm->card->dev, buf->bytes,
                              buf->area, buf->addr);
        buf->area = NULL;
    }
}
开发者ID:zp8001,项目名称:STUDY_4.0.3,代码行数:21,代码来源:nusmart-plat.c


示例3: goldfish_mmc_remove

static int goldfish_mmc_remove(struct platform_device *pdev)
{
	struct goldfish_mmc_host *host = platform_get_drvdata(pdev);

	platform_set_drvdata(pdev, NULL);

	BUG_ON(host == NULL);

	mmc_remove_host(host->mmc);
	free_irq(host->irq, host);
#if defined(CONFIG_ARM)
	dma_free_writecombine(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
#elif defined(CONFIG_X86) || defined(CONFIG_MIPS)
	dma_free_coherent(NULL, BUFFER_SIZE, host->virt_base, host->phys_base);
#else
#error NOT SUPPORTED
#endif
	mmc_free_host(host->mmc);

	return 0;
}
开发者ID:keyu-lai,项目名称:Multicore-Round-Robin-Scheduler,代码行数:21,代码来源:goldfish.c


示例4: dmabuf_ioctl_create

static int dmabuf_ioctl_create(struct dmabuf_file *priv,
			       const void __user *data)
{
	struct dmabuf_create args;
	int ret = 0;

	if (priv->buf || priv->virt)
		return -EBUSY;

	if (copy_from_user(&args, data, sizeof(args)))
		return -EFAULT;

	priv->virt = dma_alloc_writecombine(priv->dev, args.size, &priv->phys,
					    GFP_KERNEL | __GFP_NOWARN);
	if (!priv->virt)
		return -ENOMEM;

	args.flags |= O_RDWR;

	priv->buf = dma_buf_export(priv, &dmabuf_ops, args.size, args.flags,
				   NULL);
	if (!priv->buf) {
		ret = -ENOMEM;
		goto free;
	}

	if (IS_ERR(priv->buf)) {
		ret = PTR_ERR(priv->buf);
		goto free;
	}

	priv->size = args.size;

	return 0;

free:
	dma_free_writecombine(NULL, priv->size, priv->virt, priv->phys);
	priv->virt = NULL;
	return ret;
}
开发者ID:SeKwonLee,项目名称:Hongik_NECSST_Tizen2.2_kernel,代码行数:40,代码来源:dma-buf-test.c


示例5: s3c24xx_pcm_free_dma_buffers

static void s3c24xx_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
	struct snd_pcm_substream *substream;
	struct snd_dma_buffer *buf;
	int stream;

	s3cdbg("Entered %s\n", __FUNCTION__);

	for (stream = 0; stream < 2; stream++) {
		substream = pcm->streams[stream].substream;
		if (!substream)
			continue;

		buf = &substream->dma_buffer;
		if (!buf->area)
			continue;

		dma_free_writecombine(pcm->card->dev, buf->bytes,
				      buf->area, buf->addr);
		buf->area = NULL;
	}
}
开发者ID:mik9,项目名称:i5700-leshak-kernel,代码行数:22,代码来源:s3c-pcm-sol.c


示例6: free_mem

static void free_mem(void *buf, dma_addr_t addr, size_t len, enum mem_t type)
{
	if (buf == NULL || type >= MEM_TYPE_MAX || len == 0)
		return;

	switch (type) {
	case MEM_TYPE_DMA:
		dma_free_writecombine(NULL, len, buf, addr);
		break;

	case MEM_TYPE_KMALLOC:
		kfree(buf);
		break;

	case MEM_TYPE_VMALLOC:
		vfree(buf);
		break;

	default:
		return;
	}
}
开发者ID:CVlaspoel,项目名称:VSMC-i9105p,代码行数:22,代码来源:dma_mmap_test.c


示例7: test_init

static int  __init test_init(void)
{
	int ret;

	fb_mem_virt = dma_alloc_writecombine(NULL, 
			FB_MEM_SIZE, &fb_mem_phys, GFP_KERNEL);
	if(!fb_mem_virt)
	{
		DEBUG();
		return -ENOMEM;
	}

	ret = lcd_init();
	if(ret)
	{
		dma_free_writecombine(NULL, FB_MEM_SIZE, 
					fb_mem_virt, fb_mem_phys);
		return ret;
	}

	return misc_register(&mdev);
}
开发者ID:kcoewoys,项目名称:work,代码行数:22,代码来源:fb_drv.c


示例8: rockchip_pcm_free_dma_buffers

static void rockchip_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
	struct snd_pcm_substream *substream;
	struct snd_dma_buffer *buf;
	int stream;

	DBG("Enter::%s----%d\n",__FUNCTION__,__LINE__);

	for (stream = 0; stream < 2; stream++) {
		substream = pcm->streams[stream].substream;
		if (!substream)
			continue;

		buf = &substream->dma_buffer;
		if (!buf->area)
			continue;

		dma_free_writecombine(pcm->card->dev, buf->bytes,
				      buf->area, buf->addr);
		buf->area = NULL;
	}
}
开发者ID:markyzq,项目名称:px2-android-kernel-3.0,代码行数:22,代码来源:rk29_pcm.c


示例9: cns3xxx_pcm_free_dma_buffers

static void cns3xxx_pcm_free_dma_buffers(struct snd_pcm *pcm)
{
	struct snd_pcm_substream *substream;
	struct snd_dma_buffer *buf;
	int stream;

#ifdef __DEBUG_PATH
	printk("%s=>%d\n", __FUNCTION__, __LINE__);
#endif
	for (stream = 0; stream < 2; stream++) {
		substream = pcm->streams[stream].substream;
		if (!substream)
			continue;

		buf = &substream->dma_buffer;
		if (!buf->area)
			continue;
		dma_free_writecombine(pcm->card->dev, buf->bytes,
				      buf->area, buf->addr);
		buf->area = NULL;
	}
}
开发者ID:mausvt,项目名称:seagate_central_cns3420_2-6-35,代码行数:22,代码来源:cns3xxx-pcm.c


示例10: nvhost_3dctx_free

void nvhost_3dctx_free(struct kref *ref)
{
	struct nvhost_hwctx *nctx = container_of(ref, struct nvhost_hwctx, ref);
	struct host1x_hwctx *ctx = to_host1x_hwctx(nctx);

	if (ctx->cpuva) {
		if (ctx->mem_flag)
			dma_free_writecombine(&nctx->channel->dev->dev,
					ctx->restore_size * 4,
					ctx->cpuva,
					ctx->iova);
		else
			dma_free_coherent(&nctx->channel->dev->dev,
					ctx->restore_size * 4,
					ctx->cpuva,
					ctx->iova);

		ctx->cpuva = NULL;
		ctx->iova = 0;
	}

	kfree(ctx);
}
开发者ID:Lloir,项目名称:nvidia-linux-3.10,代码行数:23,代码来源:gr3d.c


示例11: drm_gem_cma_free_object

/*
 * drm_gem_cma_free_object - (struct drm_driver)->gem_free_object callback
 * function
 */
void drm_gem_cma_free_object(struct drm_gem_object *gem_obj)
{
	struct drm_gem_cma_object *cma_obj;

	drm_gem_free_mmap_offset(gem_obj);

	cma_obj = to_drm_gem_cma_obj(gem_obj);

	if (cma_obj->vaddr) {
		dma_free_writecombine(gem_obj->dev->dev, cma_obj->base.size,
				      cma_obj->vaddr, cma_obj->paddr);
		if (cma_obj->sgt) {
			sg_free_table(cma_obj->sgt);
			kfree(cma_obj->sgt);
		}
	} else if (gem_obj->import_attach) {
		drm_prime_gem_destroy(gem_obj, cma_obj->sgt);
	}

	drm_gem_object_release(gem_obj);

	kfree(cma_obj);
}
开发者ID:rzr,项目名称:rcar-m2-tizen-kernel,代码行数:27,代码来源:drm_gem_cma_helper.c


示例12: s3c_dma_init

static int s3c_dma_init(void)
{
	//分配src,dst对应的缓冲区
	src = dma_alloc_writecombine(NULL, BUF_SIZE, &src_phys, GFP_KERNEL);
	if(NULL == src)
	{
		printk("can not alloc buf for src");
		return -ENOMEM;
	}

	dst = dma_alloc_writecombine(NULL, BUF_SIZE, &dst_phys, GFP_KERNEL);
	if(NULL == dst)
	{
		dma_free_writecombine(NULL, BUF_SIZE, src, src_phys);
		printk("can not alloc buf for dst");
		return -ENOMEM;
	}

	major = register_chrdev(0, "s3c_dma", &dma_fops);

	cls = class_create(THIS_MODULE, "s3c_dma");
	class_device_create(cls, NULL, MKDEV(major, 0), NULL, "dma");
	return 0;
}
开发者ID:mallius,项目名称:drivers-m,代码行数:24,代码来源:22_drv_dma.c


示例13: goldfish_mmc_probe

static int goldfish_mmc_probe(struct platform_device *pdev)
{
	struct mmc_host *mmc;
	struct goldfish_mmc_host *host = NULL;
	struct resource *res;
	int ret = 0;
	int irq;
	dma_addr_t buf_addr;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	irq = platform_get_irq(pdev, 0);
	if (res == NULL || irq < 0)
		return -ENXIO;

	mmc = mmc_alloc_host(sizeof(struct goldfish_mmc_host), &pdev->dev);
	if (mmc == NULL) {
		ret = -ENOMEM;
		goto err_alloc_host_failed;
	}

	host = mmc_priv(mmc);
	host->mmc = mmc;
#if defined(CONFIG_ARM)
	host->reg_base = (void __iomem *)IO_ADDRESS(res->start - IO_START);
	host->virt_base = dma_alloc_writecombine(&pdev->dev, BUFFER_SIZE,
						 &buf_addr, GFP_KERNEL);
#elif defined(CONFIG_X86) || defined(CONFIG_MIPS)
    /*
     * Use NULL for dev for ISA-like devices
     */
	host->reg_base = ioremap(res->start, res->end - res->start + 1);
	host->virt_base = dma_alloc_coherent(NULL, BUFFER_SIZE, &buf_addr, GFP_KERNEL);
#else
#error NOT SUPPORTED
#endif
	if(host->virt_base == 0) {
		ret = -EBUSY;
		goto dma_alloc_failed;
	}
	host->phys_base = buf_addr;

	host->id = pdev->id;
	host->irq = irq;

	mmc->ops = &goldfish_mmc_ops;
	mmc->f_min = 400000;
	mmc->f_max = 24000000;
	mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
	mmc->caps = MMC_CAP_4_BIT_DATA;

	/* Use scatterlist DMA to reduce per-transfer costs.
	 * NOTE max_seg_size assumption that small blocks aren't
	 * normally used (except e.g. for reading SD registers).
	 */
	mmc->max_segs = 32;
	mmc->max_blk_size = 2048;	/* MMC_BLOCK_LENGTH is 11 bits (+1) */
	mmc->max_blk_count = 2048;	/* MMC_BLOCK_COUNT is 11 bits (+1) */
	mmc->max_req_size = BUFFER_SIZE;
	mmc->max_seg_size = mmc->max_req_size;

	ret = request_irq(host->irq, goldfish_mmc_irq, 0, DRIVER_NAME, host);
	if (ret)
		goto err_request_irq_failed;

	host->dev = &pdev->dev;
	platform_set_drvdata(pdev, host);

	ret = device_create_file(&pdev->dev, &dev_attr_cover_switch);
	if (ret)
		dev_warn(mmc_dev(host->mmc), "Unable to create sysfs attributes\n");

	GOLDFISH_MMC_WRITE(host, MMC_SET_BUFFER, host->phys_base);	
	GOLDFISH_MMC_WRITE(host, MMC_INT_ENABLE, 
		MMC_STAT_END_OF_CMD | MMC_STAT_END_OF_DATA | MMC_STAT_STATE_CHANGE |
		MMC_STAT_CMD_TIMEOUT);

	mmc_add_host(mmc);

	return 0;

err_request_irq_failed:
#if defined(CONFIG_ARM)
	dma_free_writecombine(&pdev->dev, BUFFER_SIZE, host->virt_base, host->phys_base);
#elif defined(CONFIG_X86) || defined(CONFIG_MIPS)
	dma_free_coherent(NULL, BUFFER_SIZE, host->virt_base, host->phys_base);
#else
#error NOT SUPPORTED
#endif
dma_alloc_failed:
	mmc_free_host(host->mmc);
err_alloc_host_failed:
	return ret;
}
开发者ID:keyu-lai,项目名称:Multicore-Round-Robin-Scheduler,代码行数:93,代码来源:goldfish.c


示例14: videoin_init

int __devinit videoin_init(void)
{
	int ret = 0;
	int i;
	unsigned int u32PacketBuf0, u32PacketBuf1, u32PacketBuf2;
	unsigned int u32PlanarBuf0, u32PlanarBuf1;
	UINT32 u32PhyAddr;
	videoin_priv_t *priv = (videoin_priv_t *)&videoin_priv;
	
	g_u32FbPhyAddr = inp32(REG_LCM_FSADDR);					
	
	DBG_PRINTF("%s\n",__FUNCTION__);				
	/* initialize locks */
	init_MUTEX(&videoin_priv.lock);
	
	priv->jdev.owner = THIS_MODULE;
	priv->jdev.type = VID_TYPE_CAPTURE | VID_TYPE_SCALES;
	priv->jdev.hardware = VID_HARDWARE_W55FA93;
	priv->jdev.release = videoin_release;
	priv->jdev.fops = &videoin_fops;
	priv->jdev.priv = &videoin_priv;
	priv->preview_width     = LCDWIDTH; //CONFIG_VIDEOIN_PREVIEW_RESOLUTION_X;
	priv->preview_height    = LCDHEIGHT; //CONFIG_VIDEOIN_PREVIEW_RESOLUTION_Y;
	
	priv->videoin_buffersize = CONFIG_VIDEOIN_PREVIEW_BUFFER_SIZE;
	
	priv->videoin_buffer = kmalloc(sizeof(__u8*) * CONFIG_VIDEOIN_BUFFER_COUNT, GFP_KERNEL);
#ifdef CONFIG_VIDEOIN_VPOST_OVERLAY_BUFFER
	DBG_PRINTF("\nUsing Overlay\n");
	/*For 1 * Packet pipe*/
	u32PhysPacketBuf = w55fa93_FB_BG_PHY_ADDR;
	u32VirtPacketBuf = phys_to_virt(u32PhysPacketBuf);
	
	/*For Planar pipe*/
	priv->vaddr = videoin_dmamalloc(VIDEOIN_ENCODE_BUFFER_SIZE);
	if (!priv->vaddr)
		return -ENOMEM;
#else
	DBG_PRINTF("\nUsing FSC\n");
	//Allocate 3 buffer for preview 
	u32PacketBuf0 = videoin_dmamalloc_phy(0, LCDWIDTH*LCDHEIGHT*LCDBPP/8);		//Packet buffer 0
	if (!u32PacketBuf0)
	{
		printk("VideoIn allocated buffer fail\n");
		return -ENOMEM;	
	}
	u32PacketBuf1 = videoin_dmamalloc_phy(1, LCDWIDTH*LCDHEIGHT*LCDBPP/8);		//Packet buffer 1
	if (!u32PacketBuf1)
	{
		printk("VideoIn allocated buffer fail\n");
		return -ENOMEM;	
	}
	u32PacketBuf2 = videoin_dmamalloc_phy(2, LCDWIDTH*LCDHEIGHT*LCDBPP/8);		//Packet buffer 2
	if (!u32PacketBuf2)
	{
		printk("VideoIn allocated buffer fail\n");
		return -ENOMEM;		
	}
	//Allocate 2 buffer for JEPG encode  
	u32PlanarBuf0 = videoin_dmamalloc_phy(3, VIDEOIN_ENCODE_BUFFER_SIZE);			//Planar buffer 0	
	w55fa93_JPG_Y0_ADDR = u32PlanarBuf0;
	if (!u32PlanarBuf0)
	{
		printk("VideoIn allocated buffer fail\n");
		return -ENOMEM;
	}
	u32PlanarBuf1 = videoin_dmamalloc_phy(4, VIDEOIN_ENCODE_BUFFER_SIZE);			//Planar buffer 1
	w55fa93_JPG_Y1_ADDR = u32PlanarBuf1;
	if (!u32PlanarBuf1)
	{
		printk("VideoIn allocated buffer fail\n");
		return -ENOMEM;
	}
#endif
	
	for(i = 0; i < CONFIG_VIDEOIN_BUFFER_COUNT; i++)
	{
		priv->videoin_buffer[i] = priv->paddr + i * CONFIG_VIDEOIN_PREVIEW_BUFFER_SIZE;
		DBG_PRINTF("bufer[%d]:%x\n", i, priv->videoin_buffer[i]);
	}

	if (video_register_device(&priv->jdev, VFL_TYPE_GRABBER, videoin_nr) == -1) {
		printk("%s: video_register_device failed\n", __FUNCTION__);
		dma_free_writecombine(NULL/*dev*/, VIDEOIN_ENCODE_BUFFER_SIZE, priv->vaddr, priv->paddr);
		kfree(priv->videoin_buffer);//2010-07-27
		return -EPIPE;
	}

	if (!request_mem_region((unsigned long)W55FA93_VA_VIDEOIN, W55FA93_SZ_VIDEOIN, "w55fa93-videoin"))
	{
		printk("%s: request_mem_region failed\n", __FUNCTION__);
		video_unregister_device(&videoin_priv.jdev);
		dma_free_writecombine(NULL/*dev*/, VIDEOIN_ENCODE_BUFFER_SIZE, priv->vaddr, priv->paddr);
		kfree(priv->videoin_buffer); //2010-07-27
		return -EBUSY;
	}

	ret = request_irq(IRQ_CAP, irq_handler, SA_INTERRUPT, "w55fa93-videoin", priv);
	if (ret) {
		printk("cannot get irq %d - err %d\n", IRQ_CAP, ret);
//.........这里部分代码省略.........
开发者ID:me-oss,项目名称:me-linux,代码行数:101,代码来源:videoin.c


示例15: s3c_mem_ioctl


//.........这里部分代码省略.........
		if (param.vir_addr == -EINVAL) {
			printk(KERN_INFO "S3C_MEM_SHARE_ALLOC FAILED\n");
			flag = 0;
			mutex_unlock(&mem_cacheable_share_alloc_lock);
			return -EFAULT;
		}
		DEBUG("MALLOC_SHARE : param.phy_addr = 0x%X \t "
				"size = %d \t param.vir_addr = 0x%X, %d\n",
				param.phy_addr, param.size, param.vir_addr,
				__LINE__);

		if (copy_to_user((struct s3c_mem_alloc *)arg, &param,
					sizeof(struct s3c_mem_alloc))) {
			flag = 0;
			mutex_unlock(&mem_cacheable_share_alloc_lock);
			return -EFAULT;
		}
		flag = 0;
		mutex_unlock(&mem_cacheable_share_alloc_lock);

		break;

	case S3C_MEM_FREE:
		mutex_lock(&mem_free_lock);
		if (copy_from_user(&param, (struct s3c_mem_alloc *)arg,
					sizeof(struct s3c_mem_alloc))) {
			mutex_unlock(&mem_free_lock);
			return -EFAULT;
		}

		DEBUG("KERNEL FREE : param.phy_addr = 0x%X \t "
				"size = %d \t param.vir_addr = 0x%X, %d\n",
				param.phy_addr, param.size, param.vir_addr,
				__LINE__);

		if (do_munmap(mm, param.vir_addr, param.size) < 0) {
			printk(KERN_INFO "do_munmap() failed !!\n");
			mutex_unlock(&mem_free_lock);
			return -EINVAL;
		}

#ifdef USE_DMA_ALLOC
		virt_addr = param.kvir_addr;
		dma_free_writecombine(NULL, param.size,
				(unsigned int *) virt_addr, param.phy_addr);
#else
		virt_addr = (unsigned long *)phys_to_virt(param.phy_addr);
		kfree(virt_addr);
#endif
		param.size = 0;
		DEBUG("do_munmap() succeed !!\n");

		if (copy_to_user((struct s3c_mem_alloc *)arg, &param,
					sizeof(struct s3c_mem_alloc))) {
			mutex_unlock(&mem_free_lock);
			return -EFAULT;
		}

		mutex_unlock(&mem_free_lock);

		break;

	case S3C_MEM_SHARE_FREE:
		mutex_lock(&mem_share_free_lock);
		if (copy_from_user(&param, (struct s3c_mem_alloc *)arg,
					sizeof(struct s3c_mem_alloc))) {
			mutex_unlock(&mem_share_free_lock);
			return -EFAULT; }

		DEBUG("MEM_SHARE_FREE : param.phy_addr = 0x%X \t "
				"size = %d \t param.vir_addr = 0x%X, %d\n",
				param.phy_addr, param.size, param.vir_addr,
				__LINE__);

		if (do_munmap(mm, param.vir_addr, param.size) < 0) {
			printk(KERN_INFO "do_munmap() failed - MEM_SHARE_FREE!!\n");
			mutex_unlock(&mem_share_free_lock);
			return -EINVAL;
		}

		param.vir_addr = 0;
		DEBUG("do_munmap() succeed !! - MEM_SHARE_FREE\n");

		if (copy_to_user((struct s3c_mem_alloc *)arg, &param,
					sizeof(struct s3c_mem_alloc))) {
			mutex_unlock(&mem_share_free_lock);
			return -EFAULT;
		}

		mutex_unlock(&mem_share_free_lock);

		break;

	default:
		DEBUG("s3c_mem_ioctl() : default !!\n");
		return -EINVAL;
	}

	return 0;
}
开发者ID:AproSamurai,项目名称:Arcturus,代码行数:101,代码来源:s3c_mem.c


示例16: tegra_bo_destroy

static void tegra_bo_destroy(struct drm_device *drm, struct tegra_bo *bo)
{
	dma_free_writecombine(drm->dev, bo->gem.size, bo->vaddr, bo->paddr);
}
开发者ID:monojo,项目名称:xu3,代码行数:4,代码来源:gem.c


示例17: drm_gem_cma_buf_destroy

static void drm_gem_cma_buf_destroy(struct drm_device *drm,
		struct drm_gem_cma_object *cma_obj)
{
	dma_free_writecombine(drm->dev, cma_obj->base.size, cma_obj->vaddr,
			cma_obj->paddr);
}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:6,代码来源:drm_gem_cma_helper.c


示例18: dma_free_dma_buffers

static void dma_free_dma_buffers(struct snd_pcm *pcm)
{
    struct snd_pcm_substream *substream;
    struct snd_dma_buffer *buf;
    int stream;

    pr_debug("Entered %s\n", __func__);
#if defined(CONFIG_SND_SAMSUNG_LP) || !defined(CONFIG_SND_SAMSUNG_RP)
    for (stream = 1; stream < 2; stream++) {
#else
    for (stream = 0; stream < 2; stream++) {
#endif
        substream = pcm->streams[stream].substream;
        if (!substream)
            continue;

        buf = &substream->dma_buffer;
        if (!buf->area)
            continue;

        dma_free_writecombine(pcm->card->dev, buf->bytes,
                              buf->area, buf->addr);
        buf->area = NULL;
    }
}

static u64 dma_mask = DMA_BIT_MASK(32);

static int dma_new(struct snd_card *card,
                   struct snd_soc_dai *dai, struct snd_pcm *pcm)
{
    int ret = 0;

    pr_debug("Entered %s\n", __func__);

    if (!card->dev->dma_mask)
        card->dev->dma_mask = &dma_mask;
    if (!card->dev->coherent_dma_mask)
        card->dev->coherent_dma_mask = 0xffffffff;

#if !defined(CONFIG_SND_SAMSUNG_LP) || defined(CONFIG_SND_SAMSUNG_RP)
    if (dai->driver->playback.channels_min) {
        ret = preallocate_dma_buffer(pcm,
                                     SNDRV_PCM_STREAM_PLAYBACK);
        if (ret)
            goto out;
    }
#elif defined(CONFIG_SND_SAMSUNG_SPDIF)
    if (card->number == 1) { //card 1 only for spdif out.
        if (dai->driver->playback.channels_min) {
            ret = preallocate_dma_buffer(pcm,
                                         SNDRV_PCM_STREAM_PLAYBACK);
            if (ret)
                goto out;
        }
    }
#endif
    if (dai->driver->capture.channels_min) {
        ret = preallocate_dma_buffer(pcm,
                                     SNDRV_PCM_STREAM_CAPTURE);
        if (ret)
            goto out;
    }
out:
    return ret;
}
开发者ID:gloryliu,项目名称:meizu-mx-kernel,代码行数:66,代码来源:dma.c


示例19: sdhci_bcm2708_probe


//.........这里部分代码省略.........
	if (!host->ioaddr) {
		dev_err(&pdev->dev, "failed to remap registers\n");
		ret = -ENOMEM;
		goto err_remap;
	}

	host_priv = SDHCI_HOST_PRIV(host);

#ifdef CONFIG_MMC_SDHCI_BCM2708_DMA
	host_priv->dma_wanted = 0;
#ifdef CHECK_DMA_USE
	host_priv->dmas_pending = 0;
	host_priv->when_started = 0;
	host_priv->when_reset = 0;
	host_priv->when_stopped = 0;
#endif
	host_priv->sg_ix = 0;
	host_priv->sg_done = 0;
	host_priv->complete = NULL;
	host_priv->dma_waits = SDHCI_BCM_DMA_WAITS;

	host_priv->cb_base = dma_alloc_writecombine(&pdev->dev, SZ_4K,
						    &host_priv->cb_handle,
						    GFP_KERNEL);
	if (!host_priv->cb_base) {
		dev_err(&pdev->dev, "cannot allocate DMA CBs\n");
		ret = -ENOMEM;
		goto err_alloc_cb;
	}

	ret = bcm_dma_chan_alloc(BCM_DMA_FEATURE_FAST,
				 &host_priv->dma_chan_base,
				 &host_priv->dma_irq);
	if (ret < 0) {
		dev_err(&pdev->dev, "couldn't allocate a DMA channel\n");
		goto err_add_dma;
	}
	host_priv->dma_chan = ret;

	ret = request_irq(host_priv->dma_irq, sdhci_bcm2708_dma_irq,0,//IRQF_SHARED,
			  DRIVER_NAME " (dma)", host);
	if (ret) {
		dev_err(&pdev->dev, "cannot set DMA IRQ\n");
		goto err_add_dma_irq;
	}
	host->second_irq = host_priv->dma_irq;
	DBG("DMA CBs %p handle %08X DMA%d %p DMA IRQ %d\n",
	    host_priv->cb_base, (unsigned)host_priv->cb_handle,
	    host_priv->dma_chan, host_priv->dma_chan_base,
	    host_priv->dma_irq);

    // we support 3.3V
    host->caps |= SDHCI_CAN_VDD_330;
    if (allow_highspeed)
        host->mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;

    /* single block writes cause data loss with some SD cards! */
    host->mmc->caps2 |= MMC_CAP2_FORCE_MULTIBLOCK;
#endif

	ret = sdhci_add_host(host);
	if (ret)
		goto err_add_host;

	platform_set_drvdata(pdev, host);
	ret = device_create_file(&pdev->dev, &dev_attr_use_dma);
	ret = device_create_file(&pdev->dev, &dev_attr_dma_wait);
	ret = device_create_file(&pdev->dev, &dev_attr_status);

#ifdef CONFIG_MMC_SDHCI_BCM2708_DMA
	/* enable extension fifo for paced DMA transfers */
	sdhci_bcm2708_writel(host, 1, REG_EXRDFIFO_EN);
	sdhci_bcm2708_writel(host, 4, REG_EXRDFIFO_CFG);
#endif

	printk(KERN_INFO "%s: BCM2708 SDHC host at 0x%08llx DMA %d IRQ %d\n",
	       mmc_hostname(host->mmc), (unsigned long long)iomem->start,
	       host_priv->dma_chan, host_priv->dma_irq);

	return 0;

err_add_host:
#ifdef CONFIG_MMC_SDHCI_BCM2708_DMA
	free_irq(host_priv->dma_irq, host);
err_add_dma_irq:
	bcm_dma_chan_free(host_priv->dma_chan);
err_add_dma:
	dma_free_writecombine(&pdev->dev, SZ_4K, host_priv->cb_base,
			      host_priv->cb_handle);
err_alloc_cb:
#endif
	iounmap(host->ioaddr);
err_remap:
	release_mem_region(iomem->start, resource_size(iomem));
err_request:
	sdhci_free_host(host);
err:
	dev_err(&pdev->dev, "probe failed, err %d\n", ret);
	return ret;
}
开发者ID:LinuxEmbed,项目名称:LinuxEmbed-RPI-Linux,代码行数:101,代码来源:sdhci-bcm2708.c


示例20: dma_copy_init

static int __init dma_copy_init(void)
{
    int ret;
    dev_t devt;
    printk("dma_copy init\n");
    dma_buf.src = dma_alloc_writecombine(NULL, BUF_SZ, &dma_buf.src_phys,GFP_KERNEL);
    if (!dma_buf.src ) {
        CL_DBG_PRINT("src-dma alloc failed\n");
        ret = -ENOMEM;
		goto err_alloc_dma_src;
    }

    dma_buf.dst = dma_alloc_writecombine(NULL, BUF_SZ, &dma_buf.dst_phys, GFP_KERNEL);
    if (!dma_buf.dst) {
        CL_DBG_PRINT("dst-dma alloc failed\n");
        ret = -ENOMEM;
        goto err_alloc_dma_dst;
    }

    ret = alloc_chrdev_region(&devt, 0, DEV_NUM, device_name);
    if (ret) {
        CL_DBG_PRINT("dma_copy: alloc_chardev_region failed!\n");
        goto err_alloc_chrdev_region;
    }

    major = MAJOR(devt);
    cdev_init(&dma_copy_dev.cdev, &dma_copy_fops);
    dma_copy_dev.cdev.ops=&dma_copy_fops;
    dma_copy_dev.cdev.owner = THIS_MODULE;

    ret = cdev_add(&dma_copy_dev.cdev, devt, DEV_NUM);
    if (ret) {
        goto err_cdev_add;
    }

    dma_copy_class = class_create(THIS_MODULE,class_name);
    if(IS_ERR(dma_copy_class)) {
        CL_DBG_PRINT(" failed in creating class.\n");
        ret = PTR_ERR(dma_copy_class);
        goto err_class_create;
    }

    if(IS_ERR(device_create(dma_copy_class,NULL,devt,NULL,device_name))) {
        CL_DBG_PRINT("device_create failed\n");
        goto err_device_create;
    }

    dma_copy_dev.hw.dma_regs = ioremap(DMA3_BASE_ADDR, sizeof(struct dma_regs));
    if (!dma_copy_dev.hw.dma_regs ) {
        CL_DBG_PRINT(" dma ioremap failed.\n");
        ret = -ENOMEM;
        goto err_ioremap;

    }
    init_waitqueue_head(&dma_copy_dev.dma_waitq);
    ret = request_irq(INT_DMA3, dma_copy_irq, IRQF_SHARED, "dma3", &dma_copy_dev);
    if(ret) {
        CL_DBG_PRINT("dma3 busy\n");
        goto err_req_irq;
    }
    return ret;

err_req_irq:
    iounmap(dma_copy_dev.hw.dma_regs);
err_ioremap:
    device_destroy(dma_copy_class, MKDEV(major, 0));
err_device_create:
    class_destroy(dma_copy_class);
err_class_create:
    cdev_del(&dma_copy_dev.cdev);
err_cdev_add:
    unregister_chrdev_region(MKDEV(major, 0), DEV_NUM);
err_alloc_chrdev_region:
	dma_free_writecombine(NULL, BUF_SZ, dma_buf.dst, dma_buf.dst_phys);
err_alloc_dma_dst:
	dma_free_writecombine(NULL, BUF_SZ, dma_buf.src, dma_buf.src_phys);
err_alloc_dma_src:
    return ret;
}
开发者ID:clscu,项目名称:study_exercise,代码行数:79,代码来源:dma_copy.c



注:本文中的dma_free_writecombine函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dma_map_page函数代码示例发布时间:2022-05-30
下一篇:
C++ dma_free_coherent函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap