* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
-#if defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK30) ||defined(CONFIG_ARCH_RK3188)
+#if (defined(CONFIG_ARCH_RK2928) ||\
+ defined(CONFIG_ARCH_RK30) ||\
+ defined(CONFIG_ARCH_RK3188) ||\
+ defined(CONFIG_ARCH_RK3026))
+
#include <linux/init.h>
#include <linux/module.h>
#include <linux/io.h>
#include <mach/pmu.h>
#endif
#include <plat/efuse.h>
-#if defined(CONFIG_ARCH_RK2928)
+#if (defined(CONFIG_ARCH_RK2928) || defined(CONFIG_ARCH_RK3026))
#include <mach/rk2928_camera.h>
#include <mach/cru.h>
#include <mach/pmu.h>
#define CAMMODULE_NAME "rk_cam_cif"
-#define dprintk(level, fmt, arg...) do { \
+#define wprintk(level, fmt, arg...) do { \
if (debug >= level) \
printk(KERN_WARNING "%s(%d): " fmt,CAMMODULE_NAME,__LINE__,## arg); } while (0)
-#define RKCAMERA_TR(format, ...) printk(KERN_ERR "%s(%d):" format,CAMMODULE_NAME,__LINE__,## __VA_ARGS__)
-#define RKCAMERA_DG(format, ...) dprintk(1, format, ## __VA_ARGS__)
+#define dprintk(level, fmt, arg...) do { \
+ if (debug >= level) \
+ printk(KERN_DEBUG "%s(%d): " fmt,CAMMODULE_NAME,__LINE__,## arg); } while (0)
+
+#define RKCAMERA_TR(format, ...) printk(KERN_ERR "%s(%d):" format,CAMMODULE_NAME,__LINE__,## __VA_ARGS__)
+#define RKCAMERA_DG1(format, ...) wprintk(1, format, ## __VA_ARGS__)
+#define RKCAMERA_DG2(format, ...) dprintk(2, format, ## __VA_ARGS__)
+
// CIF Reg Offset
#define CIF_CIF_CTRL 0x00
#define CIF_CIF_INTEN 0x04
#define RQUEST_RST_CIF0 (0x01 << 14)
#define RQUEST_RST_CIF1 (0x01 << 15)
-#define write_cru_reg(addr, val) __raw_writel(val, addr+RK30_CRU_BASE)
-#define read_cru_reg(addr) __raw_readl(addr+RK30_CRU_BASE)
-#define mask_cru_reg(addr, msk, val) write_cru_reg(addr,(val)|((~(msk))&read_cru_reg(addr)))
+#define write_cru_reg(addr, val) __raw_writel(val, addr+RK30_CRU_BASE)
+#define read_cru_reg(addr) __raw_readl(addr+RK30_CRU_BASE)
+#define mask_cru_reg(addr, msk, val) write_cru_reg(addr,(val)|((~(msk))&read_cru_reg(addr)))
+#endif
+
+#if defined(CONFIG_ARCH_RK3026)
+//CRU,PIXCLOCK
+#define CRU_PCLK_REG30 0xbc
+#define ENANABLE_INVERT_PCLK_CIF0 ((0x1<<23)|(0x1<<7))
+#define DISABLE_INVERT_PCLK_CIF0 ((0x1<<23)|(0x0<<7))
+#define ENANABLE_INVERT_PCLK_CIF1 ENANABLE_INVERT_PCLK_CIF0
+#define DISABLE_INVERT_PCLK_CIF1 DISABLE_INVERT_PCLK_CIF0
+
+#define write_cru_reg(addr, val) __raw_writel(val, addr+RK30_CRU_BASE)
+#define read_cru_reg(addr) __raw_readl(addr+RK30_CRU_BASE)
+#define mask_cru_reg(addr, msk, val) write_cru_reg(addr,(val)|((~(msk))&read_cru_reg(addr)))
+#endif
+
+#if defined(CONFIG_ARCH_RK2928)
+#define write_cru_reg(addr, val)
+#define read_cru_reg(addr) 0
+#define mask_cru_reg(addr, msk, val)
#endif
+
#if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
//GRF_IO_CON3 0x100
#define CIF_DRIVER_STRENGTH_2MA (0x00 << 12)
#define CIF_CLKOUT_AMP_1V8 (0x01 << 10)
#define CIF_CLKOUT_AMP_MASK (0x01 << 26)
-#define write_grf_reg(addr, val) __raw_writel(val, addr+RK30_GRF_BASE)
-#define read_grf_reg(addr) __raw_readl(addr+RK30_GRF_BASE)
-#define mask_grf_reg(addr, msk, val) write_grf_reg(addr,(val)|((~(msk))&read_grf_reg(addr)))
+#define write_grf_reg(addr, val) __raw_writel(val, addr+RK30_GRF_BASE)
+#define read_grf_reg(addr) __raw_readl(addr+RK30_GRF_BASE)
+#define mask_grf_reg(addr, msk, val) write_grf_reg(addr,(val)|((~(msk))&read_grf_reg(addr)))
#else
#define write_grf_reg(addr, val)
-#define read_grf_reg(addr) 0
+#define read_grf_reg(addr) 0
#define mask_grf_reg(addr, msk, val)
#endif
-#if defined(CONFIG_ARCH_RK2928)
-#define write_cru_reg(addr, val)
-#define read_cru_reg(addr) 0
-#define mask_cru_reg(addr, msk, val)
-#endif
-
-
-//when work_with_ipp is not enabled,CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_OFF is not defined.something wrong with it
-#ifdef CONFIG_VIDEO_RK29_WORK_IPP//CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_OFF
-#ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_OFF
-#define CAM_WORKQUEUE_IS_EN() ((pcdev->host_width != pcdev->icd->user_width) || (pcdev->host_height != pcdev->icd->user_height)\
- || (pcdev->icd_cb.sensor_cb))
-#define CAM_IPPWORK_IS_EN() ((pcdev->host_width != pcdev->icd->user_width) || (pcdev->host_height != pcdev->icd->user_height))
-#else
#define CAM_WORKQUEUE_IS_EN() (true)
#define CAM_IPPWORK_IS_EN() ((pcdev->zoominfo.a.c.width != pcdev->icd->user_width) || (pcdev->zoominfo.a.c.height != pcdev->icd->user_height))
-#endif
-#else //CONFIG_VIDEO_RK29_WORK_IPP
-#define CAM_WORKQUEUE_IS_EN() (false)
-#define CAM_IPPWORK_IS_EN() (false)
-#endif
#define IS_CIF0() (pcdev->hostid == RK_CAM_PLATFORM_DEV_ID_0)
#if (CONFIG_CAMERA_SCALE_CROP_MACHINE == RK_CAM_SCALE_CROP_IPP)
*
*v0.3.7:
* 1. support rk3028 , read 3028 chip id by efuse for check cif controller is normal or not;
+*v0.3.9:
+* 1. return real sensor output size in rk_camera_enum_frameintervals;
+* 2. wake up vb after add camera work to list in rk_camera_capture_process;
+*v0.3.b:
+* 1. this verison is support for 3188M, the version has been revert in v0.3.d;
+*v0.3.d:
+* 1. this version is support for rk3028a;
+*
+*v0.3.f:
+* 1. this version is support query fov orientation;
+*v0.3.0x11:
+* 1. fix vb struct may be used again which have been free after stream off, some code modify in soc_camera.c,
+* version is v0.1.1;
+* 1. fix cif clk out can't be turn off;
+*
+*v0.3.0x12:
+* 1. modify cif irq ,remove judge reg_lastpixel==host_width.
+*
*/
-#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 3, 0x07)
+#define RK_CAM_VERSION_CODE KERNEL_VERSION(0, 3, 0x12)
static int version = RK_CAM_VERSION_CODE;
module_param(version, int, S_IRUGO);
#define RK_CAM_W_MIN 48
#define RK_CAM_H_MIN 32
-#define RK_CAM_W_MAX 3856 /* ddl@rock-chips.com : 10M Pixel */
+#define RK_CAM_W_MAX 3856 /* ddl@rock-chips.com : 10M Pixel */
#define RK_CAM_H_MAX 2764
-#define RK_CAM_FRAME_INVAL_INIT 3
-#define RK_CAM_FRAME_INVAL_DC 3 /* ddl@rock-chips.com : */
-#define RK30_CAM_FRAME_MEASURE 5
+#define RK_CAM_FRAME_INVAL_INIT 3
+#define RK_CAM_FRAME_INVAL_DC 3 /* ddl@rock-chips.com : */
+#define RK30_CAM_FRAME_MEASURE 5
+
+
extern void videobuf_dma_contig_free(struct videobuf_queue *q, struct videobuf_buffer *buf);
extern dma_addr_t videobuf_to_dma_contig(struct videobuf_buffer *buf);
/* buffer for one video frame */
struct semaphore sem;
struct v4l2_crop a;
int vir_width;
- int vir_height;
+ int vir_height;
int zoom_rate;
};
#if CAMERA_VIDEOBUF_ARM_ACCESS
struct rk_camera_dev *pcdev;
struct hrtimer timer;
bool istarted;
- };
+};
struct rk_cif_clk
{
//************must modify start************/
bool on;
};
+struct rk_cif_crop
+{
+ spinlock_t lock;
+ struct v4l2_rect c;
+ struct v4l2_rect bounds;
+};
+
+struct rk_cif_irqinfo
+{
+ unsigned int irq;
+ unsigned long cifirq_idx;
+ unsigned long cifirq_normal_idx;
+ unsigned long cifirq_abnormal_idx;
+
+ unsigned long dmairq_idx;
+ spinlock_t lock;
+};
+
struct rk_camera_dev
{
- struct soc_camera_host soc_host;
- struct device *dev;
- /* RK2827x is only supposed to handle one camera on its Quick Capture
- * interface. If anyone ever builds hardware to enable more than
- * one camera, they will have to modify this driver too */
- struct soc_camera_device *icd;
- void __iomem *base;
- int frame_inval; /* ddl@rock-chips.com : The first frames is invalidate */
- unsigned int irq;
- unsigned int fps;
+ struct soc_camera_host soc_host;
+ struct device *dev;
+ /* RK2827x is only supposed to handle one camera on its Quick Capture
+ * interface. If anyone ever builds hardware to enable more than
+ * one camera, they will have to modify this driver too */
+ struct soc_camera_device *icd;
+ void __iomem *base;
+ int frame_inval; /* ddl@rock-chips.com : The first frames is invalidate */
+
+ unsigned int fps;
unsigned int last_fps;
unsigned long frame_interval;
- unsigned int pixfmt;
- //for ipp
- unsigned int vipmem_phybase;
+ unsigned int pixfmt;
+ //for ipp
+ unsigned int vipmem_phybase;
void __iomem *vipmem_virbase;
- unsigned int vipmem_size;
- unsigned int vipmem_bsize;
+ unsigned int vipmem_size;
+ unsigned int vipmem_bsize;
#if CAMERA_VIDEOBUF_ARM_ACCESS
struct rk29_camera_vbinfo *vbinfo;
unsigned int vbinfo_count;
#endif
- int host_width;
- int host_height;
- int host_left; //sensor output size ?
- int host_top;
- int hostid;
+ int host_width;
+ int host_height;
+ int host_left; //sensor output size ?
+ int host_top;
+ int hostid;
int icd_width;
int icd_height;
- struct rk29camera_platform_data *pdata;
- struct resource *res;
- struct list_head capture;
- struct rk_camera_zoominfo zoominfo;
+ struct rk_cif_crop cropinfo;
+ struct rk_cif_irqinfo irqinfo;
+
+ struct rk29camera_platform_data *pdata;
+ struct resource *res;
+ struct list_head capture;
+ struct rk_camera_zoominfo zoominfo;
- spinlock_t lock;
+ spinlock_t lock;
- struct videobuf_buffer *active;
- struct rk_camera_reg reginfo_suspend;
- struct workqueue_struct *camera_wq;
- struct rk_camera_work *camera_work;
+ struct videobuf_buffer *active;
+ struct rk_camera_reg reginfo_suspend;
+ struct workqueue_struct *camera_wq;
+ struct rk_camera_work *camera_work;
struct list_head camera_work_queue;
spinlock_t camera_work_lock;
- unsigned int camera_work_count;
- struct rk_camera_timer fps_timer;
- struct rk_camera_work camera_reinit_work;
- int icd_init;
- rk29_camera_sensor_cb_s icd_cb;
- struct rk_camera_frmivalinfo icd_frmival[2];
- // atomic_t to_process_frames;
+ unsigned int camera_work_count;
+ struct rk_camera_timer fps_timer;
+ struct rk_camera_work camera_reinit_work;
+ int icd_init;
+ rk29_camera_sensor_cb_s icd_cb;
+ struct rk_camera_frmivalinfo icd_frmival[2];
bool timer_get_fps;
unsigned int reinit_times;
struct videobuf_queue *video_vq;
- bool stop_cif;
+ atomic_t stop_cif;
struct timeval first_tv;
-
- int chip_id;
+
+ int chip_id;
};
static const struct v4l2_queryctrl rk_camera_controls[] =
{
- #ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_ON
{
.id = V4L2_CID_ZOOM_ABSOLUTE,
.type = V4L2_CTRL_TYPE_INTEGER,
.maximum = 300,
.step = 5,
.default_value = 100,
- },
- #endif
+ }
};
static struct rk_cif_clk cif_clk[2];
static void rk_camera_capture_process(struct work_struct *work);
static int rk_camera_scale_crop_arm(struct work_struct *work);
+static void rk_camera_cif_reset(struct rk_camera_dev *pcdev, int only_rst)
+{
+ int ctrl_reg,inten_reg,crop_reg,set_size_reg,for_reg,vir_line_width_reg,scl_reg;
+ enum cru_soft_reset cif_reset_index = SOFT_RST_CIF0;
+
+ if (IS_CIF0() == false) {
+#if RK_SUPPORT_CIF1
+ cif_reset_index = SOFT_RST_CIF1;
+#else
+ RKCAMERA_TR("%s: CIF1 is invalidate\n",__FUNCTION__);
+ BUG();
+#endif
+ }
+
+ if (only_rst == true) {
+ cru_set_soft_reset(cif_reset_index, true);
+ udelay(5);
+ cru_set_soft_reset(cif_reset_index, false);
+ } else {
+ ctrl_reg = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
+ crop_reg = read_cif_reg(pcdev->base,CIF_CIF_CROP);
+ set_size_reg = read_cif_reg(pcdev->base,CIF_CIF_SET_SIZE);
+ inten_reg = read_cif_reg(pcdev->base,CIF_CIF_INTEN);
+ for_reg = read_cif_reg(pcdev->base,CIF_CIF_FOR);
+ vir_line_width_reg = read_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH);
+ scl_reg = read_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL);
+
+ cru_set_soft_reset(cif_reset_index, true);
+ udelay(5);
+ cru_set_soft_reset(cif_reset_index, false);
+
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, ctrl_reg&~ENABLE_CAPTURE);
+ write_cif_reg(pcdev->base,CIF_CIF_INTEN, inten_reg);
+ write_cif_reg(pcdev->base,CIF_CIF_CROP, crop_reg);
+ write_cif_reg(pcdev->base,CIF_CIF_SET_SIZE, set_size_reg);
+ write_cif_reg(pcdev->base,CIF_CIF_FOR, for_reg);
+ write_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH,vir_line_width_reg);
+ write_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL,scl_reg);
+ }
+ return;
+}
+
+
/*
* Videobuf operations
*/
pcdev->vipmem_bsize = PAGE_ALIGN(bytes_per_line_host * pcdev->host_height);
if (CAM_WORKQUEUE_IS_EN()) {
- #ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_OFF
- if (CAM_IPPWORK_IS_EN())
- #endif
- {
+
+ if (CAM_IPPWORK_IS_EN()) {
BUG_ON(pcdev->vipmem_size<pcdev->vipmem_bsize);
if (*count > pcdev->vipmem_size/pcdev->vipmem_bsize) { /* Buffers must be limited, when this resolution is genered by IPP */
*count = pcdev->vipmem_size/pcdev->vipmem_bsize;
}
}
+
if ((pcdev->camera_work_count != *count) && pcdev->camera_work) {
kfree(pcdev->camera_work);
pcdev->camera_work = NULL;
#endif
}
pcdev->video_vq = vq;
- RKCAMERA_DG("videobuf size:%d, vipmem_buf size:%d, count:%d \n",*size,pcdev->vipmem_size, *count);
+ RKCAMERA_DG1("videobuf size:%d, vipmem_buf size:%d, count:%d \n",*size,pcdev->vipmem_size, *count);
return 0;
}
* This waits until this buffer is out of danger, i.e., until it is no
* longer in STATE_QUEUED or STATE_ACTIVE
*/
- //videobuf_waiton(vq, &buf->vb, 0, 0);
+ videobuf_waiton(vq, &buf->vb, 0, 0);
videobuf_dma_contig_free(vq, &buf->vb);
dev_dbg(&icd->dev, "%s freed\n", __func__);
buf->vb.state = VIDEOBUF_NEEDS_INIT;
out:
return ret;
}
-#if defined(CONFIG_ARCH_RK3188)
-static void rk_camera_store_register(struct rk_camera_dev *pcdev)
-{
- pcdev->reginfo_suspend.cifCtrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
- pcdev->reginfo_suspend.cifCrop = read_cif_reg(pcdev->base,CIF_CIF_CROP);
- pcdev->reginfo_suspend.cifFs = read_cif_reg(pcdev->base,CIF_CIF_SET_SIZE);
- pcdev->reginfo_suspend.cifIntEn = read_cif_reg(pcdev->base,CIF_CIF_INTEN);
- pcdev->reginfo_suspend.cifFmt= read_cif_reg(pcdev->base,CIF_CIF_FOR);
- pcdev->reginfo_suspend.cifVirWidth = read_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH);
- pcdev->reginfo_suspend.cifScale= read_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL);
-
- cru_set_soft_reset(SOFT_RST_CIF0, true);
- udelay(5);
- cru_set_soft_reset(SOFT_RST_CIF0, false);
-}
-static void rk_camera_restore_register(struct rk_camera_dev *pcdev)
-{
- if (pcdev->reginfo_suspend.cifCtrl&ENABLE_CAPTURE)
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, pcdev->reginfo_suspend.cifCtrl&~ENABLE_CAPTURE);
- write_cif_reg(pcdev->base,CIF_CIF_INTEN, pcdev->reginfo_suspend.cifIntEn);
- write_cif_reg(pcdev->base,CIF_CIF_CROP, pcdev->reginfo_suspend.cifCrop);
- write_cif_reg(pcdev->base,CIF_CIF_SET_SIZE, pcdev->reginfo_suspend.cifFs);
- write_cif_reg(pcdev->base,CIF_CIF_FOR, pcdev->reginfo_suspend.cifFmt);
- write_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH,pcdev->reginfo_suspend.cifVirWidth);
- write_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL, pcdev->reginfo_suspend.cifScale);
- if (pcdev->reginfo_suspend.cifCtrl&ENABLE_CAPTURE)
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, pcdev->reginfo_suspend.cifCtrl);
-
-
-}
-#endif
static inline void rk_videobuf_capture(struct videobuf_buffer *vb,struct rk_camera_dev *rk_pcdev)
{
unsigned int y_addr,uv_addr;
uv_addr = y_addr + vb->width * vb->height;
}
#if defined(CONFIG_ARCH_RK3188)
- rk_camera_store_register(pcdev);
- rk_camera_restore_register(pcdev);
+ rk_camera_cif_reset(pcdev,false);
#endif
write_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_Y, y_addr);
write_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_UV, uv_addr);
rk_videobuf_capture(vb,pcdev);
}
}
+#if (CONFIG_CAMERA_SCALE_CROP_MACHINE == RK_CAM_SCALE_CROP_IPP)
static int rk_pixfmt2ippfmt(unsigned int pixfmt, int *ippfmt)
{
switch (pixfmt)
rk_pixfmt2ippfmt_err:
return -1;
}
+#endif
#if (CONFIG_CAMERA_SCALE_CROP_MACHINE == RK_CAM_SCALE_CROP_RGA)
static int rk_pixfmt2rgafmt(unsigned int pixfmt, int *ippfmt)
{
unsigned long flags = 0;
int err = 0;
- if (!CAM_WORKQUEUE_IS_EN())
+ if (atomic_read(&pcdev->stop_cif)==true) {
+ err = -EINVAL;
+ goto rk_camera_capture_process_end;
+ }
+
+ if (!CAM_WORKQUEUE_IS_EN()) {
+ err = -EINVAL;
goto rk_camera_capture_process_end;
+ }
down(&pcdev->zoominfo.sem);
if (pcdev->icd_cb.scale_crop_cb){
vb->state = VIDEOBUF_DONE;
vb->field_count++;
}
- }
- wake_up(&(camera_work->vb->done));
+ }
spin_lock_irqsave(&pcdev->camera_work_lock, flags);
list_add_tail(&camera_work->queue, &pcdev->camera_work_queue);
- spin_unlock_irqrestore(&pcdev->camera_work_lock, flags);
+ spin_unlock_irqrestore(&pcdev->camera_work_lock, flags);
+ wake_up(&(camera_work->vb->done)); /* ddl@rock-chips.com : v0.3.9 */
return;
}
-static irqreturn_t rk_camera_irq(int irq, void *data)
+
+static void rk_camera_cifrest_delay(struct work_struct *work)
+{
+ struct rk_camera_work *camera_work = container_of(work, struct rk_camera_work, work);
+ struct rk_camera_dev *pcdev = camera_work->pcdev;
+ unsigned long flags = 0;
+
+ mdelay(1);
+ rk_camera_cif_reset(pcdev,false);
+
+ spin_lock_irqsave(&pcdev->camera_work_lock, flags);
+ list_add_tail(&camera_work->queue, &pcdev->camera_work_queue);
+ spin_unlock_irqrestore(&pcdev->camera_work_lock, flags);
+
+ spin_lock_irqsave(&pcdev->lock,flags);
+ if (atomic_read(&pcdev->stop_cif) == false) {
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL) | ENABLE_CAPTURE));
+ RKCAMERA_DG2("After reset cif, enable capture again!\n");
+ }
+ spin_unlock_irqrestore(&pcdev->lock,flags);
+ return;
+}
+
+static inline irqreturn_t rk_camera_cifirq(int irq, void *data)
+{
+ struct rk_camera_dev *pcdev = data;
+ struct rk_camera_work *wk;
+ unsigned int reg_cifctrl,reg_lastpix,reg_lastline;
+
+ write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0x0200); /* clear vip interrupte single */
+
+ reg_cifctrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
+ reg_lastpix = read_cif_reg(pcdev->base,CIF_CIF_LAST_PIX);
+ reg_lastline = read_cif_reg(pcdev->base,CIF_CIF_LAST_LINE);
+
+ pcdev->irqinfo.cifirq_idx++;
+ if ((reg_lastline != pcdev->host_height) /*|| (reg_lastpix != pcdev->host_width)*/) {
+ pcdev->irqinfo.cifirq_abnormal_idx = pcdev->irqinfo.cifirq_idx;
+ RKCAMERA_DG2("Cif irq-%ld is error, %dx%d != %dx%d\n",pcdev->irqinfo.cifirq_abnormal_idx,
+ reg_lastpix,reg_lastline,pcdev->host_width,pcdev->host_height);
+ } else {
+ pcdev->irqinfo.cifirq_normal_idx = pcdev->irqinfo.cifirq_idx;
+ }
+
+ if(reg_cifctrl & ENABLE_CAPTURE) {
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, (reg_cifctrl & ~ENABLE_CAPTURE));
+ }
+
+ if (pcdev->irqinfo.cifirq_abnormal_idx>0) {
+ if ((pcdev->irqinfo.cifirq_idx - pcdev->irqinfo.cifirq_abnormal_idx) == 1 ) {
+ if (!list_empty(&pcdev->camera_work_queue)) {
+ RKCAMERA_DG2("Receive cif irq-%ld and queue work to cif reset\n",pcdev->irqinfo.cifirq_idx);
+ wk = list_entry(pcdev->camera_work_queue.next, struct rk_camera_work, queue);
+ list_del_init(&wk->queue);
+ INIT_WORK(&(wk->work), rk_camera_cifrest_delay);
+ wk->pcdev = pcdev;
+ queue_work(pcdev->camera_wq, &(wk->work));
+ }
+ }
+ }
+
+ return IRQ_HANDLED;
+}
+
+static inline irqreturn_t rk_camera_dmairq(int irq, void *data)
{
struct rk_camera_dev *pcdev = data;
struct videobuf_buffer *vb;
struct rk_camera_work *wk;
struct timeval tv;
- unsigned long tmp_intstat;
- unsigned long tmp_cifctrl;
-
- tmp_intstat = read_cif_reg(pcdev->base,CIF_CIF_INTSTAT);
- tmp_cifctrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
- if(pcdev->stop_cif == true)
- {
- printk("cif has stopped by app,needn't to deal this irq\n");
- write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0xFFFFFFFF); /* clear vip interrupte single */
- return IRQ_HANDLED;
- }
- if ((tmp_intstat & 0x0200) /*&& ((tmp_intstat & 0x1)==0)*/){//bit9 =1 ,bit0 = 0
- write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0x0200); /* clear vip interrupte single */
- if(tmp_cifctrl & ENABLE_CAPTURE)
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl & ~ENABLE_CAPTURE));
- return IRQ_HANDLED;
- }
-
+ unsigned long reg_cifctrl;
+
+ reg_cifctrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
/* ddl@rock-chps.com : Current VIP is run in One Frame Mode, Frame 1 is validate */
if (read_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS) & 0x01) {
- write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0x01); /* clear vip interrupte single */
+ write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0x01); /* clear vip interrupte single */
+
+ pcdev->irqinfo.dmairq_idx++;
+ if (pcdev->irqinfo.cifirq_abnormal_idx == pcdev->irqinfo.dmairq_idx) {
+ write_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS, 0x00000002);
+ goto end;
+ }
+
if (!pcdev->fps) {
do_gettimeofday(&pcdev->first_tv);
}
- pcdev->fps++;
- if (!pcdev->active)
- goto RK_CAMERA_IRQ_END;
+ pcdev->fps++;
+ if (!pcdev->active)
+ goto end;
if (pcdev->frame_inval>0) {
pcdev->frame_inval--;
rk_videobuf_capture(pcdev->active,pcdev);
- goto RK_CAMERA_IRQ_END;
+ goto end;
} else if (pcdev->frame_inval) {
- RKCAMERA_TR("frame_inval : %0x",pcdev->frame_inval);
+ RKCAMERA_TR("frame_inval : %0x",pcdev->frame_inval);
pcdev->frame_inval = 0;
}
+
if(pcdev->fps == RK30_CAM_FRAME_MEASURE) {
do_gettimeofday(&tv);
pcdev->frame_interval = ((tv.tv_sec*1000000 + tv.tv_usec) - (pcdev->first_tv.tv_sec*1000000 + pcdev->first_tv.tv_usec))
- /(RK30_CAM_FRAME_MEASURE-1);
+ /(RK30_CAM_FRAME_MEASURE-1);
}
+
vb = pcdev->active;
- if(!vb){
+ if (!vb) {
printk("no acticve buffer!!!\n");
- goto RK_CAMERA_IRQ_END;
- }
- /* ddl@rock-chips.com : this vb may be deleted from queue */
- if ((vb->state == VIDEOBUF_QUEUED) || (vb->state == VIDEOBUF_ACTIVE)) {
- list_del_init(&vb->queue);
- }
+ goto end;
+ }
+
+ /* ddl@rock-chips.com : this vb may be deleted from queue */
+ if ((vb->state == VIDEOBUF_QUEUED) || (vb->state == VIDEOBUF_ACTIVE)) {
+ list_del_init(&vb->queue);
+ }
pcdev->active = NULL;
if (!list_empty(&pcdev->capture)) {
pcdev->active = list_entry(pcdev->capture.next, struct videobuf_buffer, queue);
- if (pcdev->active) {
+ if (pcdev->active) {
WARN_ON(pcdev->active->state != VIDEOBUF_QUEUED);
- rk_videobuf_capture(pcdev->active,pcdev);
- }
+ rk_videobuf_capture(pcdev->active,pcdev);
+ }
}
if (pcdev->active == NULL) {
- RKCAMERA_DG("video_buf queue is empty!\n");
- }
+ RKCAMERA_DG1("video_buf queue is empty!\n");
+ }
do_gettimeofday(&vb->ts);
- if (CAM_WORKQUEUE_IS_EN()) {
+ if (CAM_WORKQUEUE_IS_EN()) {
if (!list_empty(&pcdev->camera_work_queue)) {
wk = list_entry(pcdev->camera_work_queue.next, struct rk_camera_work, queue);
list_del_init(&wk->queue);
INIT_WORK(&(wk->work), rk_camera_capture_process);
- wk->vb = vb;
- wk->pcdev = pcdev;
- queue_work(pcdev->camera_wq, &(wk->work));
+ wk->vb = vb;
+ wk->pcdev = pcdev;
+ queue_work(pcdev->camera_wq, &(wk->work));
}
- } else {
- if ((vb->state == VIDEOBUF_QUEUED) || (vb->state == VIDEOBUF_ACTIVE)) {
- vb->state = VIDEOBUF_DONE;
- vb->field_count++;
- }
- wake_up(&vb->done);
- }
-
+ } else {
+ if ((vb->state == VIDEOBUF_QUEUED) || (vb->state == VIDEOBUF_ACTIVE)) {
+ vb->state = VIDEOBUF_DONE;
+ vb->field_count++;
+ }
+ wake_up(&vb->done);
+ }
}
-RK_CAMERA_IRQ_END:
- if((tmp_cifctrl & ENABLE_CAPTURE) == 0)
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl | ENABLE_CAPTURE));
+end:
+ if((reg_cifctrl & ENABLE_CAPTURE) == 0)
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, (reg_cifctrl | ENABLE_CAPTURE));
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t rk_camera_irq(int irq, void *data)
+{
+ struct rk_camera_dev *pcdev = data;
+ unsigned long reg_intstat;
+
+ spin_lock(&pcdev->lock);
+
+ if(atomic_read(&pcdev->stop_cif) == true) {
+ write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0xffffffff);
+ goto end;
+ }
+
+ reg_intstat = read_cif_reg(pcdev->base,CIF_CIF_INTSTAT);
+
+ if (reg_intstat & 0x0200)
+ rk_camera_cifirq(irq,data);
+
+ if (reg_intstat & 0x01)
+ rk_camera_dmairq(irq,data);
+
+end:
+ spin_unlock(&pcdev->lock);
return IRQ_HANDLED;
}
break;
}
#endif
- if (vb == pcdev->active) {
- RKCAMERA_DG("Wait for this video buf(0x%x) write finished!\n ",(unsigned int)vb);
- interruptible_sleep_on_timeout(&vb->done, msecs_to_jiffies(500));
- RKCAMERA_DG("This video buf(0x%x) write finished, release now!!\n",(unsigned int)vb);
- }
flush_workqueue(pcdev->camera_wq);
+
+ rk_videobuf_free(vq, buf);
+
#if CAMERA_VIDEOBUF_ARM_ACCESS
if ((pcdev->vbinfo) && (vb->i < pcdev->vbinfo_count)) {
vb_info = pcdev->vbinfo + vb->i;
}
}
-#endif
- rk_videobuf_free(vq, buf);
+#endif
}
static struct videobuf_queue_ops rk_videobuf_ops =
{
int err = 0,cif;
struct rk_cif_clk *clk;
+ struct clk *cif_clk_out_div;
cif = cif_idx - RK29_CAM_PLATFORM_DEV_ID;
if ((cif<0)||(cif>1)) {
}
clk = &cif_clk[cif];
-
+
if(!clk->aclk_cif || !clk->hclk_cif || !clk->cif_clk_in || !clk->cif_clk_out) {
RKCAMERA_TR(KERN_ERR "failed to get cif clock source\n");
err = -ENOENT;
goto rk_camera_clk_ctrl_end;
}
-
+
spin_lock(&clk->lock);
if (on && !clk->on) {
clk_enable(clk->pd_cif);
clk_disable(clk->cif_clk_out);
clk_disable(clk->pd_cif);
clk->on = false;
+ if(cif){
+ cif_clk_out_div = clk_get(NULL, "cif1_out_div");
+ }else{
+ cif_clk_out_div = clk_get(NULL, "cif0_out_div");
+ if(IS_ERR_OR_NULL(cif_clk_out_div)) {
+ cif_clk_out_div = clk_get(NULL, "cif_out_div");
+ }
+ }
+
+ if(IS_ERR_OR_NULL(cif_clk_out_div)) {
+ err = clk_set_parent(clk->cif_clk_out, cif_clk_out_div);
+ clk_put(cif_clk_out_div);
+ } else {
+ err = -1;
+ }
+
+ if(err)
+ RKCAMERA_TR("WARNING %s_%s_%d: camera sensor mclk maybe not close, please check!!!\n", __FILE__, __FUNCTION__, __LINE__);
}
spin_unlock(&clk->lock);
rk_camera_clk_ctrl_end:
return err;
}
-
static int rk_camera_activate(struct rk_camera_dev *pcdev, struct soc_camera_device *icd)
{
/*
* ddl@rock-chips.com : Cif clk control in rk_sensor_power which in rk_camera.c
*/
-
-
- //soft reset the registers
- #if 0 //has somthing wrong when suspend and resume now
- if(IS_CIF0()){
- printk("before set cru register reset cif0 0x%x\n\n",read_cru_reg(CRU_CIF_RST_REG30));
- //dump regs
- {
- printk("CIF_CIF_CTRL = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_CTRL));
- printk("CIF_CIF_INTEN = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_INTEN));
- printk("CIF_CIF_INTSTAT = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_INTSTAT));
- printk("CIF_CIF_FOR = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_FOR));
- printk("CIF_CIF_CROP = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_CROP));
- printk("CIF_CIF_SET_SIZE = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_SET_SIZE));
- printk("CIF_CIF_SCL_CTRL = 0x%x\n",read_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL));
- printk("CRU_PCLK_REG30 = 0X%x\n",read_cru_reg(CRU_PCLK_REG30));
- printk("CIF_CIF_LAST_LINE = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_LAST_LINE));
-
- printk("CIF_CIF_LAST_PIX = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_LAST_PIX));
- printk("CIF_CIF_VIR_LINE_WIDTH = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH));
- printk("CIF_CIF_LINE_NUM_ADDR = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_LINE_NUM_ADDR));
- printk("CIF_CIF_FRM0_ADDR_Y = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_Y));
- printk("CIF_CIF_FRM0_ADDR_UV = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRM0_ADDR_UV));
- printk("CIF_CIF_FRAME_STATUS = 0X%x\n\n",read_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS));
- }
-
- mdelay(100);
- write_cru_reg(CRU_CIF_RST_REG30,(/*read_cru_reg(CRU_CIF_RST_REG30)|*/MASK_RST_CIF0|RQUEST_RST_CIF0 ));
- printk("set cru register reset cif0 0x%x\n",read_cru_reg(CRU_CIF_RST_REG30));
- write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF0)) | MASK_RST_CIF0);
- mdelay(1000);
- printk("clean cru register reset cif0 0x%x\n",read_cru_reg(CRU_CIF_RST_REG30));
- }else{
- write_cru_reg(CRU_CIF_RST_REG30,MASK_RST_CIF1|RQUEST_RST_CIF1 | (read_cru_reg(CRU_CIF_RST_REG30)));
- write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF1)) | MASK_RST_CIF1);
- }
- #endif
write_cif_reg(pcdev->base,CIF_CIF_CTRL,AXI_BURST_16|MODE_ONEFRAME|DISABLE_CAPTURE); /* ddl@rock-chips.com : vip ahb burst 16 */
write_cif_reg(pcdev->base,CIF_CIF_INTEN, 0x01); //capture complete interrupt enable
- RKCAMERA_DG("CIF_CIF_CTRL = 0x%x\n",read_cif_reg(pcdev->base, CIF_CIF_CTRL));
return 0;
}
struct v4l2_subdev *sd;
int ret,i,icd_catch;
struct rk_camera_frmivalenum *fival_list,*fival_nxt;
+ struct v4l2_cropcap cropcap;
+ struct v4l2_mbus_framefmt mf;
+ const struct soc_camera_format_xlate *xlate = NULL;
mutex_lock(&camera_lock);
goto ebusy;
}
- RKCAMERA_DG("%s driver attached to %s\n",RK29_CAM_DRV_NAME,dev_name(icd->pdev));
+ RKCAMERA_DG1("%s driver attached to %s\n",RK29_CAM_DRV_NAME,dev_name(icd->pdev));
pcdev->frame_inval = RK_CAM_FRAME_INVAL_INIT;
pcdev->active = NULL;
goto ebusy;
#endif
v4l2_subdev_call(sd, core, ioctl, RK29_CAM_SUBDEV_CB_REGISTER,(void*)(&pcdev->icd_cb));
+
+ if (v4l2_subdev_call(sd, video, cropcap, &cropcap) == 0) {
+ memcpy(&pcdev->cropinfo.bounds ,&cropcap.bounds,sizeof(struct v4l2_rect));
+ } else {
+ xlate = soc_camera_xlate_by_fourcc(icd, V4L2_PIX_FMT_NV12);
+ mf.width = 10000;
+ mf.height = 10000;
+ mf.field = V4L2_FIELD_NONE;
+ mf.code = xlate->code;
+ mf.reserved[6] = 0xfefe5a5a;
+ v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+
+ pcdev->cropinfo.bounds.left = 0;
+ pcdev->cropinfo.bounds.top = 0;
+ pcdev->cropinfo.bounds.width = mf.width;
+ pcdev->cropinfo.bounds.height = mf.height;
+ }
}
pcdev->icd = icd;
pcdev->icd_init = 0;
-
+
icd_catch = 0;
for (i=0; i<2; i++) {
if (pcdev->icd_frmival[i].icd == icd)
mutex_lock(&camera_lock);
BUG_ON(icd != pcdev->icd);
- RKCAMERA_DG("%s driver detached from %s\n",RK29_CAM_DRV_NAME,dev_name(icd->pdev));
+ RKCAMERA_DG1("%s driver detached from %s\n",RK29_CAM_DRV_NAME,dev_name(icd->pdev));
/* ddl@rock-chips.com: Application will call VIDIOC_STREAMOFF before close device, but
stream may be turn on again before close device, if suspend and resume happened. */
if (read_cif_reg(pcdev->base,CIF_CIF_CTRL) & ENABLE_CAPTURE) {
rk_camera_s_stream(icd,0);
- }
+ }
- //soft reset the registers
- #if 0 //has somthing wrong when suspend and resume now
- if(IS_CIF0()){
- write_cru_reg(CRU_CIF_RST_REG30,MASK_RST_CIF0|RQUEST_RST_CIF0 | (read_cru_reg(CRU_CIF_RST_REG30)));
- write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF0)) | MASK_RST_CIF0);
- }else{
- write_cru_reg(CRU_CIF_RST_REG30,MASK_RST_CIF1|RQUEST_RST_CIF1 | (read_cru_reg(CRU_CIF_RST_REG30)));
- write_cru_reg(CRU_CIF_RST_REG30,(read_cru_reg(CRU_CIF_RST_REG30)&(~RQUEST_RST_CIF1)) | MASK_RST_CIF1);
- }
- #endif
v4l2_subdev_call(sd, core, ioctl, RK29_CAM_SUBDEV_DEACTIVATE,NULL);
//if stream off is not been executed,timer is running.
if(pcdev->fps_timer.istarted){
INIT_LIST_HEAD(&pcdev->capture);
mutex_unlock(&camera_lock);
- RKCAMERA_DG("%s exit\n",__FUNCTION__);
return;
}
static int rk_camera_set_bus_param(struct soc_camera_device *icd, __u32 pixfmt)
{
unsigned long bus_flags, camera_flags, common_flags;
- unsigned int cif_ctrl_val = 0;
+ unsigned int cif_for = 0;
const struct soc_mbus_pixelfmt *fmt;
int ret = 0;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct rk_camera_dev *pcdev = ici->priv;
- RKCAMERA_DG("%s enter\n",__FUNCTION__);
fmt = soc_mbus_get_fmtdesc(icd->current_fmt->code);
if (!fmt)
if (ret < 0)
goto RK_CAMERA_SET_BUS_PARAM_END;
- cif_ctrl_val = read_cif_reg(pcdev->base,CIF_CIF_FOR);
- RKCAMERA_DG("cif_ctrl_val = 0x%x\n",cif_ctrl_val);
+ cif_for = read_cif_reg(pcdev->base,CIF_CIF_FOR);
+
if (common_flags & SOCAM_PCLK_SAMPLE_FALLING) {
if(IS_CIF0()) {
write_cru_reg(CRU_PCLK_REG30, read_cru_reg(CRU_PCLK_REG30) | ENANABLE_INVERT_PCLK_CIF0);
- RKCAMERA_DG("enable cif0 pclk invert\n");
} else {
write_cru_reg(CRU_PCLK_REG30, read_cru_reg(CRU_PCLK_REG30) | ENANABLE_INVERT_PCLK_CIF1);
- RKCAMERA_DG("enable cif1 pclk invert\n");
}
} else {
if(IS_CIF0()){
write_cru_reg(CRU_PCLK_REG30, (read_cru_reg(CRU_PCLK_REG30) & 0xFFFFEFF ) | DISABLE_INVERT_PCLK_CIF0);
- RKCAMERA_DG("diable cif0 pclk invert\n");
} else {
write_cru_reg(CRU_PCLK_REG30, (read_cru_reg(CRU_PCLK_REG30) & 0xFFFEFFF) | DISABLE_INVERT_PCLK_CIF1);
- RKCAMERA_DG("diable cif1 pclk invert\n");
}
}
if (common_flags & SOCAM_HSYNC_ACTIVE_LOW) {
- cif_ctrl_val |= HSY_LOW_ACTIVE;
+ cif_for |= HSY_LOW_ACTIVE;
} else {
- cif_ctrl_val &= ~HSY_LOW_ACTIVE;
+ cif_for &= ~HSY_LOW_ACTIVE;
}
if (common_flags & SOCAM_VSYNC_ACTIVE_HIGH) {
- cif_ctrl_val |= VSY_HIGH_ACTIVE;
+ cif_for |= VSY_HIGH_ACTIVE;
} else {
- cif_ctrl_val &= ~VSY_HIGH_ACTIVE;
+ cif_for &= ~VSY_HIGH_ACTIVE;
}
/* ddl@rock-chips.com : Don't enable capture here, enable in stream_on */
//vip_ctrl_val |= ENABLE_CAPTURE;
- write_cif_reg(pcdev->base,CIF_CIF_FOR, cif_ctrl_val);
- RKCAMERA_DG("ctrl:0x%x CIF_CIF_FOR=%x \n",cif_ctrl_val,read_cif_reg(pcdev->base,CIF_CIF_FOR));
+ write_cif_reg(pcdev->base,CIF_CIF_FOR, cif_for);
+ RKCAMERA_DG1("CIF_CIF_FOR: 0x%x \n",cif_for);
RK_CAMERA_SET_BUS_PARAM_END:
if (ret)
break;
}
-#if (defined(CONFIG_ARCH_RK30) || defined(CONFIG_ARCH_RK2928))
mdelay(100);
- if(IS_CIF0()){
- //pmu_set_idle_request(IDLE_REQ_VIO, true);
- cru_set_soft_reset(SOFT_RST_CIF0, true);
- udelay(5);
- cru_set_soft_reset(SOFT_RST_CIF0, false);
- //pmu_set_idle_request(IDLE_REQ_VIO, false);
-
- }else{
- //pmu_set_idle_request(IDLE_REQ_VIO, true);
- cru_set_soft_reset(SOFT_RST_CIF1, true);
- udelay(5);
- cru_set_soft_reset(SOFT_RST_CIF1, false);
- //pmu_set_idle_request(IDLE_REQ_VIO, false);
- }
-#elif defined(CONFIG_ARCH_RK3188)
-// pmu_set_idle_request(IDLE_REQ_VIO, true);
- cru_set_soft_reset(SOFT_RST_CIF0, true);
- udelay(5);
- cru_set_soft_reset(SOFT_RST_CIF0, false);
-// pmu_set_idle_request(IDLE_REQ_VIO, false);
-
-#endif
+ rk_camera_cif_reset(pcdev,true);
+
write_cif_reg(pcdev->base,CIF_CIF_CTRL,AXI_BURST_16|MODE_ONEFRAME|DISABLE_CAPTURE); /* ddl@rock-chips.com : vip ahb burst 16 */
write_cif_reg(pcdev->base,CIF_CIF_INTEN, 0x01|0x200); //capture complete interrupt enable
write_cif_reg(pcdev->base,CIF_CIF_FOR,cif_fmt_val); /* ddl@rock-chips.com: VIP capture mode and capture format must be set before FS register set */
- // read_cif_reg(pcdev->base,CIF_CIF_INTSTAT); /* clear vip interrupte single */
write_cif_reg(pcdev->base,CIF_CIF_INTSTAT,0xFFFFFFFF);
if((read_cif_reg(pcdev->base,CIF_CIF_CTRL) & MODE_PINGPONG)
||(read_cif_reg(pcdev->base,CIF_CIF_CTRL) & MODE_LINELOOP)) {
//MUST bypass scale
write_cif_reg(pcdev->base,CIF_CIF_SCL_CTRL,0x10);
- RKCAMERA_DG("crop:0x%x fs:0x%x cif_fmt_val:0x%x CIF_CIF_FOR:0x%x\n",cif_crop,cif_fs,cif_fmt_val,read_cif_reg(pcdev->base,CIF_CIF_FOR));
+ RKCAMERA_DG1("CIF_CIF_CROP:0x%x CIF_CIF_FS:0x%x CIF_CIF_FOR:0x%x\n",cif_crop,cif_fs,cif_fmt_val);
return;
}
return 0;
switch (code) {
- case V4L2_MBUS_FMT_UYVY8_2X8:
- case V4L2_MBUS_FMT_YUYV8_2X8:
- case V4L2_MBUS_FMT_YVYU8_2X8:
- case V4L2_MBUS_FMT_VYUY8_2X8:
+ case V4L2_MBUS_FMT_UYVY8_2X8:
+ case V4L2_MBUS_FMT_YUYV8_2X8:
+ case V4L2_MBUS_FMT_YVYU8_2X8:
+ case V4L2_MBUS_FMT_VYUY8_2X8:
+ {
+
#if (CONFIG_CAMERA_SCALE_CROP_MACHINE != RK_CAM_SCALE_CROP_RGA)
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[0];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[0].name,code);
- }
-
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[1];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[1].name,code);
- }
-
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[2];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[2].name,code);
- }
-
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[3];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[3].name,code);
- }
- break;
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[0];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[0].name,code);
+ }
+
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[1];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[1].name,code);
+ }
+
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[2];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[2].name,code);
+ }
+
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[3];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[3].name,code);
+ }
+ break;
#else
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[4];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[4].name,code);
- }
- formats++;
- if (xlate) {
- xlate->host_fmt = &rk_camera_formats[5];
- xlate->code = code;
- xlate++;
- dev_dbg(dev, "Providing format %s using code %d\n",
- rk_camera_formats[5].name,code);
- }
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[4];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[4].name,code);
+ }
+ formats++;
+ if (xlate) {
+ xlate->host_fmt = &rk_camera_formats[5];
+ xlate->code = code;
+ xlate++;
+ dev_dbg(dev, "Providing format %s using code %d\n",
+ rk_camera_formats[5].name,code);
+ }
break;
#endif
+ }
default:
break;
}
{
return;
}
-
-static int rk_camera_set_crop(struct soc_camera_device *icd,
- struct v4l2_crop *a)
+static int rk_camera_cropcap(struct soc_camera_device *icd, struct v4l2_cropcap *cropcap)
{
struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
- struct v4l2_mbus_framefmt mf;
- u32 fourcc = icd->current_fmt->host_fmt->fourcc;
- int ret;
-
- ret = v4l2_subdev_call(sd, video, g_mbus_fmt, &mf);
- if (ret < 0)
- return ret;
-
- if ((mf.width < (a->c.left + a->c.width)) || (mf.height < (a->c.top + a->c.height))) {
-
- mf.width = a->c.left + a->c.width;
- mf.height = a->c.top + a->c.height;
-
- v4l_bound_align_image(&mf.width, RK_CAM_W_MIN, RK_CAM_W_MAX, 1,
- &mf.height, RK_CAM_H_MIN, RK_CAM_H_MAX, 0,
- fourcc == V4L2_PIX_FMT_NV16 ?4 : 0);
-
- ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
- if (ret < 0)
- return ret;
- }
-
- rk_camera_setup_format(icd, fourcc, mf.code, &a->c);
+ int ret=0;
+
+ ret = v4l2_subdev_call(sd, video, cropcap, cropcap);
+ if (ret != 0)
+ goto end;
+ /* ddl@rock-chips.com: driver decide the cropping rectangle */
+ memset(&cropcap->defrect,0x00,sizeof(struct v4l2_rect));
+end:
+ return ret;
+}
+static int rk_camera_get_crop(struct soc_camera_device *icd,struct v4l2_crop *crop)
+{
+ struct soc_camera_host *ici =to_soc_camera_host(icd->dev.parent);
+ struct rk_camera_dev *pcdev = ici->priv;
- icd->user_width = mf.width;
- icd->user_height = mf.height;
+ spin_lock(&pcdev->cropinfo.lock);
+ memcpy(&crop->c,&pcdev->cropinfo.c,sizeof(struct v4l2_rect));
+ spin_unlock(&pcdev->cropinfo.lock);
+
+ return 0;
+}
+static int rk_camera_set_crop(struct soc_camera_device *icd,
+ struct v4l2_crop *crop)
+{
+ struct soc_camera_host *ici =to_soc_camera_host(icd->dev.parent);
+ struct rk_camera_dev *pcdev = ici->priv;
+ spin_lock(&pcdev->cropinfo.lock);
+ memcpy(&pcdev->cropinfo.c,&crop->c,sizeof(struct v4l2_rect));
+ spin_unlock(&pcdev->cropinfo.lock);
return 0;
}
static bool rk_camera_fmt_capturechk(struct v4l2_format *f)
}
if (ret == true)
- RKCAMERA_DG("%dx%d is capture format\n",f->fmt.pix.width, f->fmt.pix.height);
+ RKCAMERA_DG1("%dx%d is capture format\n",f->fmt.pix.width, f->fmt.pix.height);
return ret;
}
static int rk_camera_set_fmt(struct soc_camera_device *icd,
struct v4l2_pix_format *pix = &f->fmt.pix;
struct v4l2_mbus_framefmt mf;
struct v4l2_rect rect;
- int ret,usr_w,usr_h;
+ int ret,usr_w,usr_h,sensor_w,sensor_h;
int stream_on = 0;
+ int ratio, bounds_aspect;
usr_w = pix->width;
usr_h = pix->height;
- RKCAMERA_DG("enter width:%d height:%d\n",usr_w,usr_h);
+ RKCAMERA_DG1("enter width:%d height:%d\n",usr_w,usr_h);
xlate = soc_camera_xlate_by_fourcc(icd, pix->pixelformat);
if (!xlate) {
dev_err(dev, "Format %x not found\n", pix->pixelformat);
if (stream_on & ENABLE_CAPTURE)
write_cif_reg(pcdev->base,CIF_CIF_CTRL, (stream_on & (~ENABLE_CAPTURE)));
- mf.width = pix->width;
- mf.height = pix->height;
- mf.field = pix->field;
- mf.colorspace = pix->colorspace;
- mf.code = xlate->code;
+ mf.width = pix->width;
+ mf.height = pix->height;
+ mf.field = pix->field;
+ mf.colorspace = pix->colorspace;
+ mf.code = xlate->code;
mf.reserved[0] = pix->priv; /* ddl@rock-chips.com : v0.3.3 */
-
- ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
- if (mf.code != xlate->code)
- return -EINVAL;
-
- #ifdef CONFIG_VIDEO_RK29_WORK_IPP
+ mf.reserved[1] = 0;
+
+ ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
+ if (mf.code != xlate->code)
+ return -EINVAL;
+
+ if ((pcdev->cropinfo.c.width == pcdev->cropinfo.bounds.width) &&
+ (pcdev->cropinfo.c.height == pcdev->cropinfo.bounds.height)) {
+ bounds_aspect = (pcdev->cropinfo.bounds.width*10/pcdev->cropinfo.bounds.height);
+ if ((mf.width*10/mf.height) != bounds_aspect) {
+ RKCAMERA_DG1("User request fov unchanged in %dx%d, But sensor %dx%d is croped, so switch to full resolution %dx%d\n",
+ usr_w,usr_h,mf.width, mf.height,pcdev->cropinfo.bounds.width,pcdev->cropinfo.bounds.height);
+
+ mf.width = pcdev->cropinfo.bounds.width/4;
+ mf.height = pcdev->cropinfo.bounds.height/4;
+
+ mf.field = pix->field;
+ mf.colorspace = pix->colorspace;
+ mf.code = xlate->code;
+ mf.reserved[0] = pix->priv;
+ mf.reserved[1] = 0;
+
+ ret = v4l2_subdev_call(sd, video, s_mbus_fmt, &mf);
+ if (mf.code != xlate->code)
+ return -EINVAL;
+ }
+ }
+
+ sensor_w = mf.width;
+ sensor_h = mf.height;
+
+ ratio = ((mf.width*mf.reserved[1])/100)&(~0x03); // 4 align
+ mf.width -= ratio;
+
+ ratio = ((ratio*mf.height/mf.width)+1)&(~0x01); // 2 align
+ mf.height -= ratio;
+
if ((mf.width != usr_w) || (mf.height != usr_h)) {
- int ratio;
+
if (unlikely((mf.width <16) || (mf.width > 8190) || (mf.height < 16) || (mf.height > 8190))) {
RKCAMERA_TR("Senor and IPP both invalid source resolution(%dx%d)\n",mf.width,mf.height);
ret = -EINVAL;
goto RK_CAMERA_SET_FMT_END;
- }
+ }
if (unlikely((usr_w <16)||(usr_h < 16))) {
RKCAMERA_TR("Senor and IPP both invalid destination resolution(%dx%d)\n",usr_w,usr_h);
ret = -EINVAL;
goto RK_CAMERA_SET_FMT_END;
- }
- //need crop ?
- if((mf.width*10/mf.height) != (usr_w*10/usr_h)){
- ratio = ((mf.width*10/usr_w) >= (mf.height*10/usr_h))?(mf.height*10/usr_h):(mf.width*10/usr_w);
- pcdev->host_width = ratio*usr_w/10;
- pcdev->host_height = ratio*usr_h/10;
- //for ipp ,need 4 bit alligned.
- pcdev->host_width &= ~CROP_ALIGN_BYTES;
- pcdev->host_height &= ~CROP_ALIGN_BYTES;
- RKCAMERA_DG("ratio = %d ,host:%d*%d\n",ratio,pcdev->host_width,pcdev->host_height);
- }
- else{ // needn't crop ,just scaled by ipp
- pcdev->host_width = mf.width;
- pcdev->host_height = mf.height;
- }
- } else {
- pcdev->host_width = usr_w;
- pcdev->host_height = usr_h;
+ }
+
+ spin_lock(&pcdev->cropinfo.lock);
+ if (((mf.width*10/mf.height) != (usr_w*10/usr_h))) {
+ if ((pcdev->cropinfo.c.width == 0)&&(pcdev->cropinfo.c.height == 0)) {
+ //Scale + Crop center is for keep aspect ratio unchange
+ ratio = ((mf.width*10/usr_w) >= (mf.height*10/usr_h))?(mf.height*10/usr_h):(mf.width*10/usr_w);
+ pcdev->host_width = ratio*usr_w/10;
+ pcdev->host_height = ratio*usr_h/10;
+ pcdev->host_width &= ~CROP_ALIGN_BYTES;
+ pcdev->host_height &= ~CROP_ALIGN_BYTES;
+
+ pcdev->host_left = ((sensor_w-pcdev->host_width )>>1);
+ pcdev->host_top = ((sensor_h-pcdev->host_height)>>1);
+ } else {
+ //Scale + crop(user define)
+ pcdev->host_width = pcdev->cropinfo.c.width*mf.width/pcdev->cropinfo.bounds.width;
+ pcdev->host_height = pcdev->cropinfo.c.height*mf.height/pcdev->cropinfo.bounds.height;
+ pcdev->host_left = (pcdev->cropinfo.c.left*mf.width/pcdev->cropinfo.bounds.width);
+ pcdev->host_top = (pcdev->cropinfo.c.top*mf.height/pcdev->cropinfo.bounds.height);
+ }
+
+ pcdev->host_left &= (~0x01);
+ pcdev->host_top &= (~0x01);
+ } else {
+ if ((pcdev->cropinfo.c.width == 0)&&(pcdev->cropinfo.c.height == 0)) {
+ //Crop Center for cif can work , then scale
+ pcdev->host_width = mf.width;
+ pcdev->host_height = mf.height;
+ pcdev->host_left = ((sensor_w - mf.width)>>1)&(~0x01);
+ pcdev->host_top = ((sensor_h - mf.height)>>1)&(~0x01);
+ } else {
+ //Crop center for cif can work + crop(user define), then scale
+ pcdev->host_width = pcdev->cropinfo.c.width*mf.width/pcdev->cropinfo.bounds.width;
+ pcdev->host_height = pcdev->cropinfo.c.height*mf.height/pcdev->cropinfo.bounds.height;
+ pcdev->host_left = (pcdev->cropinfo.c.left*mf.width/pcdev->cropinfo.bounds.width)+((sensor_w - mf.width)>>1);
+ pcdev->host_top = (pcdev->cropinfo.c.top*mf.height/pcdev->cropinfo.bounds.height)+((sensor_h - mf.height)>>1);
+ }
+
+ pcdev->host_left &= (~0x01);
+ pcdev->host_top &= (~0x01);
+ }
+ spin_unlock(&pcdev->cropinfo.lock);
+ } else {
+ spin_lock(&pcdev->cropinfo.lock);
+ if ((pcdev->cropinfo.c.width == 0)&&(pcdev->cropinfo.c.height == 0)) {
+ pcdev->host_width = mf.width;
+ pcdev->host_height = mf.height;
+ pcdev->host_left = 0;
+ pcdev->host_top = 0;
+ } else {
+ pcdev->host_width = pcdev->cropinfo.c.width*mf.width/pcdev->cropinfo.bounds.width;
+ pcdev->host_height = pcdev->cropinfo.c.height*mf.height/pcdev->cropinfo.bounds.height;
+ pcdev->host_left = (pcdev->cropinfo.c.left*mf.width/pcdev->cropinfo.bounds.width);
+ pcdev->host_top = (pcdev->cropinfo.c.top*mf.height/pcdev->cropinfo.bounds.height);
+ }
+ spin_unlock(&pcdev->cropinfo.lock);
}
- #else
- //according to crop and scale capability to change , here just cropt to user needed
- if (unlikely((mf.width <16) || (mf.width > 8190) || (mf.height < 16) || (mf.height > 8190))) {
- RKCAMERA_TR("Senor invalid source resolution(%dx%d)\n",mf.width,mf.height);
- ret = -EINVAL;
- goto RK_CAMERA_SET_FMT_END;
- }
- if (unlikely((usr_w <16)||(usr_h < 16))) {
- RKCAMERA_TR("Senor invalid destination resolution(%dx%d)\n",usr_w,usr_h);
- ret = -EINVAL;
- goto RK_CAMERA_SET_FMT_END;
- }
- pcdev->host_width = usr_w;
- pcdev->host_height = usr_h;
- #endif
icd->sense = NULL;
if (!ret) {
- RKCAMERA_DG("host:%d*%d , sensor output:%d*%d,user demand:%d*%d\n",
- pcdev->host_width,pcdev->host_height,mf.width,mf.height,usr_w,usr_h);
rect.width = pcdev->host_width;
rect.height = pcdev->host_height;
- rect.left = ((mf.width-pcdev->host_width )>>1)&(~0x01);
- rect.top = ((mf.height-pcdev->host_height)>>1)&(~0x01);
- pcdev->host_left = rect.left;
- pcdev->host_top = rect.top;
+ rect.left = pcdev->host_left;
+ rect.top = pcdev->host_top;
down(&pcdev->zoominfo.sem);
- #if CIF_DO_CROP
- pcdev->zoominfo.a.c.left = 0;
- pcdev->zoominfo.a.c.top = 0;
- pcdev->zoominfo.a.c.width = pcdev->host_width*100/pcdev->zoominfo.zoom_rate;
- pcdev->zoominfo.a.c.width &= ~CROP_ALIGN_BYTES;
- pcdev->zoominfo.a.c.height = pcdev->host_height*100/pcdev->zoominfo.zoom_rate;
- pcdev->zoominfo.a.c.height &= ~CROP_ALIGN_BYTES;
- pcdev->zoominfo.vir_width = pcdev->zoominfo.a.c.width;
- pcdev->zoominfo.vir_height = pcdev->zoominfo.a.c.height;
- //recalculate the CIF width & height
- rect.width = pcdev->zoominfo.a.c.width ;
- rect.height = pcdev->zoominfo.a.c.height;
- rect.left = ((((pcdev->host_width - pcdev->zoominfo.a.c.width)>>1))+pcdev->host_left)&(~0x01);
- rect.top = ((((pcdev->host_height - pcdev->zoominfo.a.c.height)>>1))+pcdev->host_top)&(~0x01);
- #else
- pcdev->zoominfo.a.c.width = pcdev->host_width*100/pcdev->zoominfo.zoom_rate;
- pcdev->zoominfo.a.c.width &= ~CROP_ALIGN_BYTES;
- pcdev->zoominfo.a.c.height = pcdev->host_height*100/pcdev->zoominfo.zoom_rate;
- pcdev->zoominfo.a.c.height &= ~CROP_ALIGN_BYTES;
- //now digital zoom use ipp to do crop and scale
- if(pcdev->zoominfo.zoom_rate != 100){
- pcdev->zoominfo.a.c.left = ((pcdev->host_width - pcdev->zoominfo.a.c.width)>>1)&(~0x01);
- pcdev->zoominfo.a.c.top = ((pcdev->host_height - pcdev->zoominfo.a.c.height)>>1)&(~0x01);
+#if CIF_DO_CROP // this crop is only for digital zoom
+ pcdev->zoominfo.a.c.left = 0;
+ pcdev->zoominfo.a.c.top = 0;
+ pcdev->zoominfo.a.c.width = pcdev->host_width*100/pcdev->zoominfo.zoom_rate;
+ pcdev->zoominfo.a.c.width &= ~CROP_ALIGN_BYTES;
+ pcdev->zoominfo.a.c.height = pcdev->host_height*100/pcdev->zoominfo.zoom_rate;
+ pcdev->zoominfo.a.c.height &= ~CROP_ALIGN_BYTES;
+ pcdev->zoominfo.vir_width = pcdev->zoominfo.a.c.width;
+ pcdev->zoominfo.vir_height = pcdev->zoominfo.a.c.height;
+ //recalculate the CIF width & height
+ rect.width = pcdev->zoominfo.a.c.width ;
+ rect.height = pcdev->zoominfo.a.c.height;
+ rect.left = ((((pcdev->host_width - pcdev->zoominfo.a.c.width)>>1))+pcdev->host_left)&(~0x01);
+ rect.top = ((((pcdev->host_height - pcdev->zoominfo.a.c.height)>>1))+pcdev->host_top)&(~0x01);
+#else
+ pcdev->zoominfo.a.c.width = pcdev->host_width*100/pcdev->zoominfo.zoom_rate;
+ pcdev->zoominfo.a.c.width &= ~CROP_ALIGN_BYTES;
+ pcdev->zoominfo.a.c.height = pcdev->host_height*100/pcdev->zoominfo.zoom_rate;
+ pcdev->zoominfo.a.c.height &= ~CROP_ALIGN_BYTES;
+ //now digital zoom use ipp to do crop and scale
+ if(pcdev->zoominfo.zoom_rate != 100){
+ pcdev->zoominfo.a.c.left = ((pcdev->host_width - pcdev->zoominfo.a.c.width)>>1)&(~0x01);
+ pcdev->zoominfo.a.c.top = ((pcdev->host_height - pcdev->zoominfo.a.c.height)>>1)&(~0x01);
} else {
- pcdev->zoominfo.a.c.left = 0;
- pcdev->zoominfo.a.c.top = 0;
+ pcdev->zoominfo.a.c.left = 0;
+ pcdev->zoominfo.a.c.top = 0;
}
- pcdev->zoominfo.vir_width = pcdev->host_width;
- pcdev->zoominfo.vir_height = pcdev->host_height;
- #endif
+ pcdev->zoominfo.vir_width = pcdev->host_width;
+ pcdev->zoominfo.vir_height = pcdev->host_height;
+#endif
up(&pcdev->zoominfo.sem);
/* ddl@rock-chips.com: IPP work limit check */
}
}
}
- RKCAMERA_DG(" %s icd width:%d user width:%d (zoom: %dx%d@(%d,%d)->%dx%d)\n",xlate->host_fmt->name,
- rect.width, pix->width, pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height, pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,
+
+ RKCAMERA_DG1("%s CIF Host:%dx%d@(%d,%d) Sensor:%dx%d->%dx%d User crop:(%d,%d,%d,%d)in(%d,%d) (zoom: %dx%d@(%d,%d)->%dx%d)\n",xlate->host_fmt->name,
+ pcdev->host_width,pcdev->host_height,pcdev->host_left,pcdev->host_top,
+ sensor_w,sensor_h,mf.width,mf.height,
+ pcdev->cropinfo.c.left,pcdev->cropinfo.c.top,pcdev->cropinfo.c.width,pcdev->cropinfo.c.height,
+ pcdev->cropinfo.bounds.width,pcdev->cropinfo.bounds.height,
+ pcdev->zoominfo.a.c.width,pcdev->zoominfo.a.c.height, pcdev->zoominfo.a.c.left,pcdev->zoominfo.a.c.top,
pix->width, pix->height);
+
rk_camera_setup_format(icd, pix->pixelformat, mf.code, &rect);
if (CAM_IPPWORK_IS_EN()) {
if((usr_w == 10000) && (usr_h == 10000)) {
pix->width = mf.width;
pix->height = mf.height;
- RKCAMERA_DG("Sensor resolution : %dx%d\n",mf.width,mf.height);
+ RKCAMERA_DG1("Sensor resolution : %dx%d\n",mf.width,mf.height);
goto RK_CAMERA_TRY_FMT_END;
} else {
- RKCAMERA_DG("user demand: %dx%d sensor output: %dx%d \n",usr_w,usr_h,mf.width,mf.height);
- }
-
- #ifdef CONFIG_VIDEO_RK29_WORK_IPP
+ RKCAMERA_DG1("user demand: %dx%d sensor output: %dx%d \n",usr_w,usr_h,mf.width,mf.height);
+ }
+
if ((mf.width != usr_w) || (mf.height != usr_h)) {
bytes_per_line_host = soc_mbus_bytes_per_line(mf.width,icd->current_fmt->host_fmt);
if (is_capture) {
}
#endif
}
- #else
- //need to change according to crop and scale capablicity
- if ((mf.width > usr_w) && (mf.height > usr_h)) {
- pix->width = usr_w;
- pix->height = usr_h;
- } else if ((mf.width < usr_w) && (mf.height < usr_h)) {
- RKCAMERA_TR("%dx%d can't scale up to %dx%d!\n",mf.width,mf.height,usr_w,usr_h);
- pix->width = mf.width;
- pix->height = mf.height;
- }
- #endif
+
pix->colorspace = mf.colorspace;
switch (mf.field) {
return 0;
}
-
+/*
+*card: sensor name _ facing _ device index - orientation _ fov horizontal _ fov vertical
+* 10 5 1 3 3 3 + 5 < 32
+*/
static int rk_camera_querycap(struct soc_camera_host *ici,
struct v4l2_capability *cap)
{
struct rk_camera_dev *pcdev = ici->priv;
struct rkcamera_platform_data *new_camera;
char orientation[5];
+ char fov[9];
int i;
- strlcpy(cap->card, dev_name(pcdev->icd->pdev), sizeof(cap->card));
+ strlcpy(cap->card, dev_name(pcdev->icd->pdev), 18);
memset(orientation,0x00,sizeof(orientation));
for (i=0; i<RK_CAM_NUM;i++) {
if ((pcdev->pdata->info[i].dev_name!=NULL) && (strcmp(dev_name(pcdev->icd->pdev), pcdev->pdata->info[i].dev_name) == 0)) {
sprintf(orientation,"-%d",pcdev->pdata->info[i].orientation);
+ sprintf(fov,"_50_50");
}
}
while (strstr(new_camera->dev_name,"end")==NULL) {
if (strcmp(dev_name(pcdev->icd->pdev), new_camera->dev_name) == 0) {
sprintf(orientation,"-%d",new_camera->orientation);
+ sprintf(fov,"_%d_%d",new_camera->fov_h,new_camera->fov_v);
}
new_camera++;
}
} else {
strcat(cap->card,orientation);
}
+
+ strcat(cap->card,fov); /* ddl@rock-chips.com: v0.3.f */
cap->version = RK_CAM_VERSION_CODE;
cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING;
pcdev->reginfo_suspend.Inval = Reg_Validate;
rk_camera_deactivate(pcdev);
- RKCAMERA_DG("%s Enter Success...\n", __FUNCTION__);
+ RKCAMERA_DG1("%s Enter Success...\n", __FUNCTION__);
} else {
- RKCAMERA_DG("%s icd has been deattach, don't need enter suspend\n", __FUNCTION__);
+ RKCAMERA_DG1("%s icd has been deattach, don't need enter suspend\n", __FUNCTION__);
}
mutex_unlock(&camera_lock);
return ret;
sd = soc_camera_to_subdev(icd);
v4l2_subdev_call(sd, video, s_stream, 1);
- RKCAMERA_DG("%s Enter success\n",__FUNCTION__);
+ RKCAMERA_DG1("%s Enter success\n",__FUNCTION__);
} else {
- RKCAMERA_DG("%s icd has been deattach, don't need enter resume\n", __FUNCTION__);
+ RKCAMERA_DG1("%s icd has been deattach, don't need enter resume\n", __FUNCTION__);
}
rk_camera_resume_end:
RKCAMERA_TR("CIF_CIF_FRAME_STATUS = 0X%x\n",read_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS));
}
- pcdev->stop_cif = true;
+ atomic_set(&pcdev->stop_cif,true);
write_cif_reg(pcdev->base,CIF_CIF_CTRL, (read_cif_reg(pcdev->base,CIF_CIF_CTRL)&(~ENABLE_CAPTURE)));
- RKCAMERA_DG("the reinit times = %d\n",pcdev->reinit_times);
- if(pcdev->video_vq && pcdev->video_vq->irqlock){
- spin_lock_irqsave(pcdev->video_vq->irqlock, flags);
- for (index = 0; index < VIDEO_MAX_FRAME; index++) {
- if (NULL == pcdev->video_vq->bufs[index])
- continue;
-
- if (pcdev->video_vq->bufs[index]->state == VIDEOBUF_QUEUED)
- {
- list_del_init(&pcdev->video_vq->bufs[index]->queue);
- pcdev->video_vq->bufs[index]->state = VIDEOBUF_NEEDS_INIT;
- wake_up_all(&pcdev->video_vq->bufs[index]->done);
+ RKCAMERA_DG1("the reinit times = %d\n",pcdev->reinit_times);
+
+ if(pcdev->video_vq && pcdev->video_vq->irqlock){
+ spin_lock_irqsave(pcdev->video_vq->irqlock, flags);
+ for (index = 0; index < VIDEO_MAX_FRAME; index++) {
+ if (NULL == pcdev->video_vq->bufs[index])
+ continue;
+
+ if (pcdev->video_vq->bufs[index]->state == VIDEOBUF_QUEUED) {
+ list_del_init(&pcdev->video_vq->bufs[index]->queue);
+ pcdev->video_vq->bufs[index]->state = VIDEOBUF_NEEDS_INIT;
+ wake_up_all(&pcdev->video_vq->bufs[index]->done);
printk("wake up video buffer index = %d !!!\n",index);
- }
- }
- spin_unlock_irqrestore(pcdev->video_vq->irqlock, flags);
+ }
+ }
+ spin_unlock_irqrestore(pcdev->video_vq->irqlock, flags);
}else{
- RKCAMERA_TR("video queue has somthing wrong !!\n");
+ RKCAMERA_TR("video queue has somthing wrong !!\n");
}
RKCAMERA_TR("the %d reinit times ,wake up video buffers!\n ",pcdev->reinit_times);
struct soc_camera_link *tmp_soc_cam_link;
tmp_soc_cam_link = to_soc_camera_link(pcdev->icd);
- RKCAMERA_DG("rk_camera_fps_func fps:0x%x\n",pcdev->fps);
+ RKCAMERA_DG1("rk_camera_fps_func fps:0x%x\n",pcdev->fps);
if ((pcdev->fps < 1) || (pcdev->last_fps == pcdev->fps)) {
RKCAMERA_TR("Camera host haven't recevie data from sensor,Reinit sensor delay,last fps = %d,pcdev->fps = %d!\n",pcdev->last_fps,pcdev->fps);
pcdev->camera_reinit_work.pcdev = pcdev;
fival_pre = fival_nxt;
while (fival_nxt != NULL) {
- RKCAMERA_DG("%s %c%c%c%c %dx%d framerate : %d/%d\n", dev_name(&pcdev->icd->dev),
+ RKCAMERA_DG1("%s %c%c%c%c %dx%d framerate : %d/%d\n", dev_name(&pcdev->icd->dev),
fival_nxt->fival.pixel_format & 0xFF, (fival_nxt->fival.pixel_format >> 8) & 0xFF,
(fival_nxt->fival.pixel_format >> 16) & 0xFF, (fival_nxt->fival.pixel_format >> 24),
fival_nxt->fival.width, fival_nxt->fival.height, fival_nxt->fival.discrete.denominator,
pcdev->fps_timer.pcdev = pcdev;
pcdev->timer_get_fps = false;
pcdev->reinit_times = 0;
- pcdev->stop_cif = false;
-// hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL);
+
+ spin_lock_irqsave(&pcdev->lock,flags);
+ atomic_set(&pcdev->stop_cif,false);
+ pcdev->irqinfo.cifirq_idx = 0;
+ pcdev->irqinfo.cifirq_normal_idx = 0;
+ pcdev->irqinfo.cifirq_abnormal_idx = 0;
+ pcdev->irqinfo.dmairq_idx = 0;
+
cif_ctrl_val |= ENABLE_CAPTURE;
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
+ spin_unlock_irqrestore(&pcdev->lock,flags);
+
hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL);
pcdev->fps_timer.istarted = true;
} else {
cif_ctrl_val &= ~ENABLE_CAPTURE;
spin_lock_irqsave(&pcdev->lock, flags);
write_cif_reg(pcdev->base,CIF_CIF_CTRL, cif_ctrl_val);
- pcdev->stop_cif = true;
+ atomic_set(&pcdev->stop_cif,true);
spin_unlock_irqrestore(&pcdev->lock, flags);
flush_workqueue((pcdev->camera_wq));
- RKCAMERA_DG("STREAM_OFF cancel timer and flush work:0x%x \n", ret);
}
//must be reinit,or will be somthing wrong in irq process.
if(enable == false) {
pcdev->active = NULL;
INIT_LIST_HEAD(&pcdev->capture);
}
- RKCAMERA_DG("s_stream: enable : 0x%x , CIF_CIF_CTRL = 0x%x\n",enable,read_cif_reg(pcdev->base,CIF_CIF_CTRL));
+ RKCAMERA_DG1("s_stream: enable : 0x%x , CIF_CIF_CTRL = 0x%x\n",enable,read_cif_reg(pcdev->base,CIF_CIF_CTRL));
return 0;
}
int rk_camera_enum_frameintervals(struct soc_camera_device *icd, struct v4l2_frmivalenum *fival)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
struct rk_camera_dev *pcdev = ici->priv;
+ struct v4l2_subdev *sd = soc_camera_to_subdev(icd);
struct rk_camera_frmivalenum *fival_list = NULL;
struct v4l2_frmivalenum *fival_head = NULL;
struct rkcamera_platform_data *new_camera;
int i,ret = 0,index;
+ const struct soc_camera_format_xlate *xlate;
+ struct v4l2_mbus_framefmt mf;
+ __u32 pixfmt;
index = fival->index & 0x00ffffff;
if ((fival->index & 0xff000000) == 0xff000000) { /* ddl@rock-chips.com: detect framerate */
if ((i == index) && (fival->height == fival_head->height) && (fival->width == fival_head->width)) {
memcpy(fival, fival_head, sizeof(struct v4l2_frmivalenum));
- fival->reserved[1] = (pcdev->icd_width<<16)|(pcdev->icd_height);
- RKCAMERA_DG("%s %dx%d@%c%c%c%c framerate : %d/%d\n", dev_name(pcdev->icd->pdev),
+
+ pixfmt = fival->pixel_format; /* ddl@rock-chips.com: v0.3.9 */
+ xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
+ memset(&mf,0x00,sizeof(struct v4l2_mbus_framefmt));
+ mf.width = fival->width;
+ mf.height = fival->height;
+ mf.code = xlate->code;
+
+ v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+
+ fival->reserved[1] = (mf.width<<16)|(mf.height);
+
+ RKCAMERA_DG1("%s %dx%d@%c%c%c%c framerate : %d/%d\n", dev_name(pcdev->icd->pdev),
fival->width, fival->height,
fival->pixel_format & 0xFF, (fival->pixel_format >> 8) & 0xFF,
(fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
(fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
index);
else
- RKCAMERA_DG("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(pcdev->icd->pdev),
+ RKCAMERA_DG1("%s have not catch %d%d@%c%c%c%c index(%d) framerate\n",dev_name(pcdev->icd->pdev),
fival->width,fival->height,
fival->pixel_format & 0xFF, (fival->pixel_format >> 8) & 0xFF,
(fival->pixel_format >> 16) & 0xFF, (fival->pixel_format >> 24),
printk(KERN_ERR "%s(%d): %s have not found in new_camera[] and rk_camera_platform_data!",
__FUNCTION__,__LINE__,dev_name(pcdev->icd->pdev));
} else {
+
+ pixfmt = fival->pixel_format; /* ddl@rock-chips.com: v0.3.9 */
+ xlate = soc_camera_xlate_by_fourcc(icd, pixfmt);
+ memset(&mf,0x00,sizeof(struct v4l2_mbus_framefmt));
+ mf.width = fival->width;
+ mf.height = fival->height;
+ mf.code = xlate->code;
+
+ v4l2_subdev_call(sd, video, try_mbus_fmt, &mf);
+
fival->discrete.numerator= 1000;
fival->discrete.denominator = 15000;
fival->type = V4L2_FRMIVAL_TYPE_DISCRETE;
+ fival->reserved[1] = (mf.width<<16)|(mf.height);
}
}
}
return ret;
}
-#ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_ON
static int rk_camera_set_digit_zoom(struct soc_camera_device *icd,
const struct v4l2_queryctrl *qctrl, int zoom_rate)
{
//change the crop and scale parameters
#if CIF_DO_CROP
- a.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- //a.c.width = pcdev->host_width*100/zoom_rate;
- a.c.width = pcdev->host_width*100/zoom_rate;
- a.c.width &= ~CROP_ALIGN_BYTES;
- a.c.height = pcdev->host_height*100/zoom_rate;
- a.c.height &= ~CROP_ALIGN_BYTES;
- a.c.left = (((pcdev->host_width - a.c.width)>>1)+pcdev->host_left)&(~0x01);
- a.c.top = (((pcdev->host_height - a.c.height)>>1)+pcdev->host_top)&(~0x01);
- pcdev->stop_cif = true;
- tmp_cifctrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl & ~ENABLE_CAPTURE));
- hrtimer_cancel(&(pcdev->fps_timer.timer));
- flush_workqueue((pcdev->camera_wq));
- down(&pcdev->zoominfo.sem);
- pcdev->zoominfo.a.c.left = 0;
- pcdev->zoominfo.a.c.top = 0;
- pcdev->zoominfo.a.c.width = a.c.width;
- pcdev->zoominfo.a.c.height = a.c.height;
- pcdev->zoominfo.vir_width = pcdev->zoominfo.a.c.width;
- pcdev->zoominfo.vir_height = pcdev->zoominfo.a.c.height;
- pcdev->frame_inval = 1;
- write_cif_reg(pcdev->base,CIF_CIF_CROP, (a.c.left + (a.c.top<<16)));
- write_cif_reg(pcdev->base,CIF_CIF_SET_SIZE, ((a.c.width ) + (a.c.height<<16)));
- write_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH, a.c.width);
- write_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS, 0x00000002);//frame1 has been ready to receive data,frame 2 is not used
- if(pcdev->active)
- rk_videobuf_capture(pcdev->active,pcdev);
- if(tmp_cifctrl & ENABLE_CAPTURE)
- write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl | ENABLE_CAPTURE));
- up(&pcdev->zoominfo.sem);
- pcdev->stop_cif = false;
- hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL);
- RKCAMERA_DG("zoom_rate:%d (%dx%d at (%d,%d)-> %dx%d)\n", zoom_rate,a.c.width, a.c.height, a.c.left, a.c.top, icd->user_width, icd->user_height );
+ a.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ //a.c.width = pcdev->host_width*100/zoom_rate;
+ a.c.width = pcdev->host_width*100/zoom_rate;
+ a.c.width &= ~CROP_ALIGN_BYTES;
+ a.c.height = pcdev->host_height*100/zoom_rate;
+ a.c.height &= ~CROP_ALIGN_BYTES;
+ a.c.left = (((pcdev->host_width - a.c.width)>>1)+pcdev->host_left)&(~0x01);
+ a.c.top = (((pcdev->host_height - a.c.height)>>1)+pcdev->host_top)&(~0x01);
+ atomic_set(&pcdev->stop_cif,true);
+ tmp_cifctrl = read_cif_reg(pcdev->base,CIF_CIF_CTRL);
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl & ~ENABLE_CAPTURE));
+ hrtimer_cancel(&(pcdev->fps_timer.timer));
+ flush_workqueue((pcdev->camera_wq));
+
+ down(&pcdev->zoominfo.sem);
+ pcdev->zoominfo.a.c.left = 0;
+ pcdev->zoominfo.a.c.top = 0;
+ pcdev->zoominfo.a.c.width = a.c.width;
+ pcdev->zoominfo.a.c.height = a.c.height;
+ pcdev->zoominfo.vir_width = pcdev->zoominfo.a.c.width;
+ pcdev->zoominfo.vir_height = pcdev->zoominfo.a.c.height;
+ pcdev->frame_inval = 1;
+ write_cif_reg(pcdev->base,CIF_CIF_CROP, (a.c.left + (a.c.top<<16)));
+ write_cif_reg(pcdev->base,CIF_CIF_SET_SIZE, ((a.c.width ) + (a.c.height<<16)));
+ write_cif_reg(pcdev->base,CIF_CIF_VIR_LINE_WIDTH, a.c.width);
+ write_cif_reg(pcdev->base,CIF_CIF_FRAME_STATUS, 0x00000002);//frame1 has been ready to receive data,frame 2 is not used
+ if(pcdev->active)
+ rk_videobuf_capture(pcdev->active,pcdev);
+ if(tmp_cifctrl & ENABLE_CAPTURE)
+ write_cif_reg(pcdev->base,CIF_CIF_CTRL, (tmp_cifctrl | ENABLE_CAPTURE));
+ up(&pcdev->zoominfo.sem);
+
+ atomic_set(&pcdev->stop_cif,false);
+ hrtimer_start(&(pcdev->fps_timer.timer),ktime_set(3, 0),HRTIMER_MODE_REL);
+ RKCAMERA_DG1("zoom_rate:%d (%dx%d at (%d,%d)-> %dx%d)\n", zoom_rate,a.c.width, a.c.height, a.c.left, a.c.top, icd->user_width, icd->user_height );
#else
- a.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- a.c.width = pcdev->host_width*100/zoom_rate;
- a.c.width &= ~CROP_ALIGN_BYTES;
- a.c.height = pcdev->host_height*100/zoom_rate;
- a.c.height &= ~CROP_ALIGN_BYTES;
- a.c.left = (pcdev->host_width - a.c.width)>>1;
- a.c.top = (pcdev->host_height - a.c.height)>>1;
- down(&pcdev->zoominfo.sem);
- pcdev->zoominfo.a.c.height = a.c.height;
- pcdev->zoominfo.a.c.width = a.c.width;
- pcdev->zoominfo.a.c.top = a.c.top;
- pcdev->zoominfo.a.c.left = a.c.left;
- pcdev->zoominfo.vir_width = pcdev->host_width;
- pcdev->zoominfo.vir_height= pcdev->host_height;
- up(&pcdev->zoominfo.sem);
- RKCAMERA_DG("zoom_rate:%d (%dx%d at (%d,%d)-> %dx%d)\n", zoom_rate,a.c.width, a.c.height, a.c.left, a.c.top, icd->user_width, icd->user_height );
+ a.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ a.c.width = pcdev->host_width*100/zoom_rate;
+ a.c.width &= ~CROP_ALIGN_BYTES;
+ a.c.height = pcdev->host_height*100/zoom_rate;
+ a.c.height &= ~CROP_ALIGN_BYTES;
+ a.c.left = (pcdev->host_width - a.c.width)>>1;
+ a.c.top = (pcdev->host_height - a.c.height)>>1;
+
+ down(&pcdev->zoominfo.sem);
+ pcdev->zoominfo.a.c.height = a.c.height;
+ pcdev->zoominfo.a.c.width = a.c.width;
+ pcdev->zoominfo.a.c.top = a.c.top;
+ pcdev->zoominfo.a.c.left = a.c.left;
+ pcdev->zoominfo.vir_width = pcdev->host_width;
+ pcdev->zoominfo.vir_height= pcdev->host_height;
+ up(&pcdev->zoominfo.sem);
+
+ RKCAMERA_DG1("zoom_rate:%d (%dx%d at (%d,%d)-> %dx%d)\n", zoom_rate,a.c.width, a.c.height, a.c.left, a.c.top, icd->user_width, icd->user_height );
#endif
return 0;
}
-#endif
+
static inline struct v4l2_queryctrl const *rk_camera_soc_camera_find_qctrl(
struct soc_camera_host_ops *ops, int id)
{
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
const struct v4l2_queryctrl *qctrl;
-#ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_ON
struct rk_camera_dev *pcdev = ici->priv;
-#endif
+
int ret = 0;
qctrl = rk_camera_soc_camera_find_qctrl(ici->ops, sctrl->id);
switch (sctrl->id)
{
- #ifdef CONFIG_VIDEO_RK29_DIGITALZOOM_IPP_ON
case V4L2_CID_ZOOM_ABSOLUTE:
{
if ((sctrl->value < qctrl->minimum) || (sctrl->value > qctrl->maximum)){
}
break;
}
- #endif
default:
ret = -ENOIOCTLCMD;
break;
.suspend = rk_camera_suspend,
.resume = rk_camera_resume,
.enum_frameinervals = rk_camera_enum_frameintervals,
+ .cropcap = rk_camera_cropcap,
.set_crop = rk_camera_set_crop,
+ .get_crop = rk_camera_get_crop,
.get_formats = rk_camera_get_formats,
.put_formats = rk_camera_put_formats,
.set_fmt = rk_camera_set_fmt,
#if defined(CONFIG_ARCH_RK3066B) || defined(CONFIG_ARCH_RK3188)
switch(cif_index){
case 0:
- iomux_set(CIF0_CLKOUT);
+ {
+ iomux_set(CIF0_CLKOUT);
write_grf_reg(GRF_IO_CON3, (CIF_DRIVER_STRENGTH_MASK|CIF_DRIVER_STRENGTH_8MA));
write_grf_reg(GRF_IO_CON4, (CIF_CLKOUT_AMP_MASK|CIF_CLKOUT_AMP_1V8));
#if (CONFIG_CAMERA_INPUT_FMT_SUPPORT & (RK_CAM_INPUT_FMT_RAW10|RK_CAM_INPUT_FMT_RAW12))
#endif
break;
+ }
default:
RKCAMERA_TR("%s(%d): Cif index(%d) is invalidate!!!\n",__FUNCTION__,__LINE__, cif_index);
break;
#elif defined(CONFIG_ARCH_RK30)
switch(cif_index){
case 0:
+ {
rk30_mux_api_set(GPIO1B3_CIF0CLKOUT_NAME, GPIO1B_CIF0_CLKOUT);
#if (CONFIG_CAMERA_INPUT_FMT_SUPPORT & (RK_CAM_INPUT_FMT_RAW10|RK_CAM_INPUT_FMT_RAW12))
rk30_mux_api_set(GPIO1B4_CIF0DATA0_NAME, GPIO1B_CIF0_DATA0);
rk30_mux_api_set(GPIO1B7_CIFDATA11_NAME, GPIO1B_CIF_DATA11);
#endif
break;
+ }
case 1:
+ {
rk30_mux_api_set(GPIO1C0_CIF1DATA2_RMIICLKOUT_RMIICLKIN_NAME,GPIO1C_CIF1_DATA2);
rk30_mux_api_set(GPIO1C1_CIFDATA3_RMIITXEN_NAME,GPIO1C_CIF_DATA3);
rk30_mux_api_set(GPIO1C2_CIF1DATA4_RMIITXD1_NAME,GPIO1C_CIF1_DATA4);
rk30_mux_api_set(GPIO1D6_CIF1DATA11_NAME,GPIO1D_CIF1_DATA11);
rk30_mux_api_set(GPIO1D7_CIF1CLKOUT_NAME,GPIO1D_CIF1_CLKOUT);
break;
+ }
default:
RKCAMERA_TR("%s(%d): Cif index(%d) is invalidate!!!\n",__FUNCTION__,__LINE__, cif_index);
break;
goto exit_alloc;
}
- pcdev->zoominfo.zoom_rate = 100;
- pcdev->hostid = pdev->id;
- #ifdef CONFIG_SOC_RK3028
- pcdev->chip_id = rk3028_version_val();
- #else
- pcdev->chip_id = -1;
- #endif
+ pcdev->zoominfo.zoom_rate = 100;
+ pcdev->hostid = pdev->id;
+ #ifdef CONFIG_SOC_RK3028
+ pcdev->chip_id = rk3028_version_val();
+ #else
+ pcdev->chip_id = -1;
+ #endif
+
+
if (IS_CIF0()) {
clk = &cif_clk[0];
cif_clk[0].pd_cif = clk_get(NULL, "pd_cif0");
if (pcdev->pdata->sensor_mclk == NULL)
pcdev->pdata->sensor_mclk = rk_camera_mclk_ctrl;
}
- #ifdef CONFIG_VIDEO_RK29_WORK_IPP
+
meminfo_ptr = IS_CIF0()? (&pcdev->pdata->meminfo):(&pcdev->pdata->meminfo_cif1);
meminfo_ptrr = IS_CIF0()? (&pcdev->pdata->meminfo_cif1):(&pcdev->pdata->meminfo);
pcdev->vipmem_phybase = meminfo_ptr->start;
pcdev->vipmem_size = meminfo_ptr->size;
pcdev->vipmem_virbase = meminfo_ptr->vbase;
- #endif
+
INIT_LIST_HEAD(&pcdev->capture);
INIT_LIST_HEAD(&pcdev->camera_work_queue);
spin_lock_init(&pcdev->lock);
spin_lock_init(&pcdev->camera_work_lock);
+
+ memset(&pcdev->cropinfo.c,0x00,sizeof(struct v4l2_rect));
+ spin_lock_init(&pcdev->cropinfo.lock);
sema_init(&pcdev->zoominfo.sem,1);
/*
}
}
- pcdev->irq = irq;
+ pcdev->irqinfo.irq = irq;
pcdev->dev = &pdev->dev;
/* config buffer address */
/* request irq */
if(irq > 0){
- err = request_irq(pcdev->irq, rk_camera_irq, 0, RK29_CAM_DRV_NAME,
+ err = request_irq(pcdev->irqinfo.irq, rk_camera_irq, 0, RK29_CAM_DRV_NAME,
pcdev);
if (err) {
dev_err(pcdev->dev, "Camera interrupt register failed \n");
}
}
-//#ifdef CONFIG_VIDEO_RK29_WORK_IPP
if(IS_CIF0()) {
pcdev->camera_wq = create_workqueue("rk_cam_wkque_cif0");
} else {
#elif(CONFIG_CAMERA_SCALE_CROP_MACHINE == RK_CAM_SCALE_CROP_PP)
pcdev->icd_cb.scale_crop_cb = rk_camera_scale_crop_pp;
#endif
- RKCAMERA_DG("%s exit \n",__FUNCTION__);
return 0;
exit_free_irq:
}
}
- free_irq(pcdev->irq, pcdev);
+ free_irq(pcdev->irqinfo.irq, pcdev);
if (pcdev->camera_wq) {
destroy_workqueue(pcdev->camera_wq);
pcdev->camera_wq = NULL;
struct rk29camera_mem_res *meminfo_ptr,*meminfo_ptrr;
int i;
- free_irq(pcdev->irq, pcdev);
+ free_irq(pcdev->irqinfo.irq, pcdev);
if (pcdev->camera_wq) {
destroy_workqueue(pcdev->camera_wq);