/** * ispdss_put_resource - Release all the resource. **/ void ispdss_put_resource() { struct isp_device *isp_res = dev_get_drvdata(dev_ctx.isp); int i = 0; if (dev_ctx.opened != 1) return; /* unmap output buffers if allocated */ for (i = 0; i < dev_ctx.num_video_buffers; ++i) { if (dev_ctx.out_buf_virt_addr[i]) { iommu_kunmap(isp_res->iommu, dev_ctx.out_buf_virt_addr[i]); dev_ctx.out_buf_virt_addr[i] = 0; } if (dev_ctx.in_buf_virt_addr[i]) { iommu_kunmap(isp_res->iommu, dev_ctx.in_buf_virt_addr[i]); dev_ctx.in_buf_virt_addr[i] = 0; } } ispdss_tmp_buf_free(); /* make device available */ dev_ctx.opened = 0; /* stop the isp */ isp_stop(dev_ctx.isp); /* release isp resource*/ isp_put(); return ; }
/** * prev2resz_release - Releases device resources */ static int prev2resz_release(struct inode *inode, struct file *fp) { struct prev2resz_fhdl *fh = fp->private_data; u32 timeout = 0; while ((p2r_ctx.status.prv_busy != PREV2RESZ_FREE || p2r_ctx.status.rsz_busy != PREV2RESZ_FREE) && (timeout < 20)) { timeout++; schedule(); } p2r_ctx.status.prv_busy = PREV2RESZ_FREE; p2r_ctx.status.rsz_busy = PREV2RESZ_FREE; p2r_ctx.opened--; /* This will Free memory allocated to the buffers, * and flushes the queue */ if (&fh->src_vbq) videobuf_queue_cancel(&fh->src_vbq); if (&fh->dst_vbq) videobuf_queue_cancel(&fh->dst_vbq); fp->private_data = NULL; isp_stop(fh->isp); kfree(fh); isp_put(); return 0; }
void ispmmu_cleanup(void) { isp_get(); if (isp_iommu) iommu_put(isp_iommu); isp_put(); isp_iommu = NULL; }
/** * prev2resz_open - Initializes and opens the device */ static int prev2resz_open(struct inode *inode, struct file *fp) { struct prev2resz_fhdl *fh; int ret = 0; fh = kzalloc(sizeof(struct prev2resz_fhdl), GFP_KERNEL); if (NULL == fh) return -ENOMEM; fh->isp = isp_get(); if (fh->isp == NULL) { dev_err(p2r_device, "Can't get ISP device\n"); ret = -EBUSY; goto err_isp; } fh->isp_dev = dev_get_drvdata(fh->isp); if (fh->isp_dev == NULL) { dev_err(p2r_device, "Can't get ISP driver data\n"); ret = -EBUSY; goto err_isp; } fh->isp_prev = &fh->isp_dev->isp_prev; fh->isp_resz = &fh->isp_dev->isp_res; fh->src_vbq.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; fh->dst_vbq.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; p2r_ctx.status.prv_busy = PREV2RESZ_FREE; p2r_ctx.status.rsz_busy = PREV2RESZ_FREE; init_completion(&p2r_ctx.resz_complete); p2r_ctx.opened++; fp->private_data = fh; videobuf_queue_sg_init(&fh->src_vbq, &p2r_ctx.vbq_ops, NULL, &fh->src_vbq_lock, fh->src_vbq.type, V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh); spin_lock_init(&fh->src_vbq_lock); videobuf_queue_sg_init(&fh->dst_vbq, &p2r_ctx.vbq_ops, NULL, &fh->dst_vbq_lock, fh->dst_vbq.type, V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh); spin_lock_init(&fh->dst_vbq_lock); return 0; err_isp: isp_put(); kfree(fh); return ret; }
/** * previewer_open - Initializes and opens the Preview Wrapper * @inode: Inode structure associated with the Preview Wrapper * @filp: File structure associated with the Preview Wrapper * * Returns 0 if successful, -EACCES if its unable to initialize default config, * -EBUSY if its already opened or the ISP module is not available, or -ENOMEM * if its unable to allocate the device in kernel space memory. **/ static int previewer_open(struct inode *inode, struct file *filp) { int ret = 0; struct prev_device *device = prevdevice; struct prev_params *config = isppreview_get_config(); struct prev_fh *fh; if (config == NULL) { dev_err(prev_dev, "Unable to initialize default config " "from isppreviewer\n\n"); return -EACCES; } if (device->opened || (filp->f_flags & O_NONBLOCK)) { dev_err(prev_dev, "previewer_open: device is already " "opened\n"); return -EBUSY; } fh = kzalloc(sizeof(struct prev_fh), GFP_KERNEL); if (NULL == fh) return -ENOMEM; isp_get(); ret = isppreview_request(); if (ret) { isp_put(); dev_err(prev_dev, "Can't acquire isppreview\n"); return ret; } device->params = config; device->opened = 1; filp->private_data = fh; fh->inout_type = V4L2_BUF_TYPE_VIDEO_CAPTURE; fh->lsc_type = V4L2_BUF_TYPE_PRIVATE; fh->device = device; videobuf_queue_sg_init(&fh->inout_vbq, &device->vbq_ops, NULL, &device->inout_vbq_lock, fh->inout_type, V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh); videobuf_queue_sg_init(&fh->lsc_vbq, &device->vbq_ops, NULL, &device->lsc_vbq_lock, fh->lsc_type, V4L2_FIELD_NONE, sizeof(struct videobuf_buffer), fh); init_completion(&device->wfc); device->wfc.done = 0; mutex_init(&device->prevwrap_mutex); return 0; }
int __init ispmmu_init(void) { int err = 0; isp_get(); isp_iommu = iommu_get("isp"); if (IS_ERR(isp_iommu)) { err = PTR_ERR(isp_iommu); isp_iommu = NULL; } isp_put(); return err; }
/* Sets the divisor for xclka, xclkb */ int camispcfg_set_xclk(unsigned int xclka_b,unsigned int div) { unsigned int xclk_div; isp_get(); if(xclka_b == 1){ xclk_div = isp_negotiate_xclka(div); isp_set_xclka(CM_CAM_MCLK_HZ/xclk_div); } else if(xclka_b == 2){ xclk_div = isp_negotiate_xclkb(div); isp_set_xclkb(xclk_div); } isp_put(); }
static void cam_misc_disableClk() { /* powerup the isp/cam domain on the 3410 */ if (isp_count_local == 0) { isp_get(); isp_count_local++; } isp_power_settings(1); isp_set_xclk(0, 0); /* Need to make sure that all encounters of the isp clocks are disabled*/ while (isp_count_local > 0) { isp_put(); isp_count_local--; } }
/** * previewer_release - Releases Preview Wrapper and frees up allocated memory * @inode: Inode structure associated with the Preview Wrapper * @filp: File structure associated with the Preview Wrapper * * Always returns 0. **/ static int previewer_release(struct inode *inode, struct file *filp) { struct prev_fh *fh = filp->private_data; struct prev_device *device = fh->device; struct videobuf_queue *q1 = &fh->inout_vbq; struct videobuf_queue *q2 = &fh->lsc_vbq; device->opened = 0; device->params = NULL; isppreview_free(); isp_put(); videobuf_mmap_free(q1); videobuf_mmap_free(q2); prev_bufsize = 0; lsc_bufsize = 0; filp->private_data = NULL; kfree(fh); dev_dbg(prev_dev, "previewer_release\n"); return 0; }
/* Sets the sensor related settings in CCDC registers */ int camispcfg_set_ccdc(unsigned char addr, unsigned int val) { unsigned int old_val; isp_get(); switch(addr) { case GET_ADDRESS(CAM_CCDC_SYNCMODE): { old_val = omap_readl(ISPCCDC_SYN_MODE); old_val &= ~CAM_CCDC_SYNCMODE_MASK; val &= CAM_CCDC_SYNCMODE_MASK; omap_writel(old_val | val,ISPCCDC_SYN_MODE); printk("oldval = 0x%x, val = 0x%x", old_val, val); printk(" ccdc sync mode val = 0x%x", omap_readl(ISPCCDC_SYN_MODE)); } break; default: break; }; isp_put(); return 0; }
/* Sets the sensor related settings in ISPCTRL registers */ int camispcfg_set_ispif(unsigned char addr, unsigned int val) { unsigned int old_val; isp_get(); switch(addr) { case GET_ADDRESS(CAM_ISPIF_CTRL): { old_val = omap_readl(ISP_CTRL); old_val &= ~CAM_ISPIF_CTRL_MASK; val &= CAM_ISPIF_CTRL_MASK; omap_writel(old_val | val,ISP_CTRL); printk("oldval = 0x%x, val = 0x%x", old_val, val); printk(" ispctrl val = 0x%x", omap_readl(ISP_CTRL)); } break; default: break; }; isp_put(); return 0; }
static int isp_video_release(struct file *file) { struct isp_video *video = video_drvdata(file); struct v4l2_fh *vfh = file->private_data; struct isp_video_fh *handle = to_isp_video_fh(vfh); /* Disable streaming and free the buffers queue resources. */ isp_video_streamoff(file, vfh, video->type); mutex_lock(&handle->queue.lock); isp_video_queue_cleanup(&handle->queue); mutex_unlock(&handle->queue.lock); /* Release the file handle. */ v4l2_fh_del(vfh); kfree(handle); file->private_data = NULL; /* If this was the last user, clean up the pipeline. */ if (atomic_dec_return(&video->users) == 0) isp_put(video->isp); return 0; }