Commit e68f608e authored by 邱宗炽's avatar 邱宗炽

typo fix and format adjust

Signed-off-by: default avatar邱宗炽 <tqiu@neuros.com.cn>
parent e1da1221
...@@ -52,32 +52,32 @@ MODULE_LICENSE("GPL"); ...@@ -52,32 +52,32 @@ MODULE_LICENSE("GPL");
#define IS_ACTIVE(x) \ #define IS_ACTIVE(x) \
((x) && ACTIVE_DEVICE() && ((x)->id == ACTIVE_DEVICE()->id)) ((x) && ACTIVE_DEVICE() && ((x)->id == ACTIVE_DEVICE()->id))
#define DEVICE_DEACTIVATE(x) do { \ #define DEVICE_DEACTIVATE(x) do { \
if ((x) && (x)->capture_device_deactive && \ if ((x) && (x)->capture_device_deactive && \
(x)->capture_device_deactive()) \ (x)->capture_device_deactive()) \
debug_print(KERN_ERR\ debug_print(KERN_ERR \
"capture device %s deactivate failed\n", \ "capture device %s deactivate failed\n", \
(x)->name); \ (x)->name); \
} while (0) } while (0)
#define DEVICE_ACTIVATE(x) do { \ #define DEVICE_ACTIVATE(x) do { \
if ((x) && (x)->capture_device_active && \ if ((x) && (x)->capture_device_active && \
(x)->capture_device_active()) \ (x)->capture_device_active()) \
debug_print(KERN_ERR \ debug_print(KERN_ERR \
"capture device %s activate failed\n", \ "capture device %s activate failed\n", \
(x)->name); \ (x)->name); \
} while (0) } while (0)
#define DEVICE_INIT(x, params) do { \ #define DEVICE_INIT(x, params) do { \
if ((x) && (x)->capture_device_init && \ if ((x) && (x)->capture_device_init && \
(x)->capture_device_init(params)) \ (x)->capture_device_init(params)) \
debug_print(KERN_ERR \ debug_print(KERN_ERR \
"capture device %s init failed\n", \ "capture device %s init failed\n", \
(x)->name); \ (x)->name); \
} while (0) } while (0)
#define DEVICE_CLEANUP(x) do { \ #define DEVICE_CLEANUP(x) do { \
if ((x) && (x)->capture_device_cleanup && \ if ((x) && (x)->capture_device_cleanup && \
(x)->capture_device_cleanup()) \ (x)->capture_device_cleanup()) \
debug_print(KERN_ERR \ debug_print(KERN_ERR \
"capture device %s cleanup failed\n", \ "capture device %s cleanup failed\n", \
(x)->name); \ (x)->name); \
} while (0) } while (0)
#define DEVICE_CMD(dev, cmd, arg) \ #define DEVICE_CMD(dev, cmd, arg) \
((dev) && (dev)->capture_device_cmd && \ ((dev) && (dev)->capture_device_cmd && \
...@@ -154,7 +154,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id) ...@@ -154,7 +154,7 @@ static irqreturn_t vpfe_isr(int irq, void *dev_id)
vpfe->curFrm->boff + vpfe->field_offset; vpfe->curFrm->boff + vpfe->field_offset;
ccdc_setfbaddr((unsigned long)addr); ccdc_setfbaddr((unsigned long)addr);
} }
} else if (fid == 1) { } else if (fid == 1) {
/* if one field is just being captured */ /* if one field is just being captured */
/* configure the next frame */ /* configure the next frame */
/* get the next frame from the empty queue */ /* get the next frame from the empty queue */
...@@ -196,7 +196,6 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -196,7 +196,6 @@ static int buffer_prepare(struct videobuf_queue *q,
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
if (vb->state == STATE_NEEDS_INIT) { if (vb->state == STATE_NEEDS_INIT) {
vb->width = vpfe->vwin.width; vb->width = vpfe->vwin.width;
vb->height = vpfe->vwin.height; vb->height = vpfe->vwin.height;
...@@ -208,11 +207,13 @@ static int buffer_prepare(struct videobuf_queue *q, ...@@ -208,11 +207,13 @@ static int buffer_prepare(struct videobuf_queue *q,
return 0; return 0;
} }
static void static void
buffer_config(struct videobuf_queue *q, unsigned int count) buffer_config(struct videobuf_queue *q, unsigned int count)
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
int i; int i;
for(i = 0; i < count; i++) { for(i = 0; i < count; i++) {
q->bufs[i]->boff = virt_to_phys(vpfe->fbuffers[i]); q->bufs[i]->boff = virt_to_phys(vpfe->fbuffers[i]);
debug_print(KERN_INFO "buffer address: %x\n", q->bufs[i]->boff); debug_print(KERN_INFO "buffer address: %x\n", q->bufs[i]->boff);
...@@ -226,7 +227,6 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) ...@@ -226,7 +227,6 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
int i; int i;
*size = VPFE_MAX_FBUF_SIZE; *size = VPFE_MAX_FBUF_SIZE;
for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) { for (i = VPFE_DEFNUM_FBUFS; i < *count; i++) {
u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER; u32 size = PAGE_SIZE << VPFE_MAX_FBUF_ORDER;
void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA, void *mem = (void *)__get_free_pages(GFP_KERNEL |GFP_DMA,
...@@ -253,6 +253,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size) ...@@ -253,6 +253,7 @@ buffer_setup(struct videobuf_queue *q, unsigned int *count, unsigned int *size)
static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb) static void buffer_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
{ {
vpfe_obj *vpfe = &vpfe_device; vpfe_obj *vpfe = &vpfe_device;
/* add the buffer to the DMA queue */ /* add the buffer to the DMA queue */
list_add_tail(&vb->queue, &vpfe->dma_queue); list_add_tail(&vb->queue, &vpfe->dma_queue);
vb->state = STATE_QUEUED; vb->state = STATE_QUEUED;
...@@ -262,15 +263,14 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb) ...@@ -262,15 +263,14 @@ static void buffer_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
{ {
/* free the buffer if it is not one of the 3 allocated at initializaiton time */ /* free the buffer if it is not one of the 3 allocated at initializaiton time */
if(vb->i < vpfe_device.numbuffers if(vb->i < vpfe_device.numbuffers
&& vb->i >= VPFE_DEFNUM_FBUFS && vb->i >= VPFE_DEFNUM_FBUFS
&& vpfe_device.fbuffers[vb->i]){ && vpfe_device.fbuffers[vb->i]){
free_pages((unsigned long)vpfe_device.fbuffers[vb->i], free_pages((unsigned long)vpfe_device.fbuffers[vb->i],
VPFE_MAX_FBUF_ORDER); VPFE_MAX_FBUF_ORDER);
vpfe_device.fbuffers[vb->i] = NULL; vpfe_device.fbuffers[vb->i] = NULL;
} }
} }
static struct videobuf_queue_ops video_qops = { static struct videobuf_queue_ops video_qops = {
.buf_setup = buffer_setup, .buf_setup = buffer_setup,
.buf_prepare = buffer_prepare, .buf_prepare = buffer_prepare,
...@@ -305,9 +305,10 @@ static int vpfe_select_capture_device(int id) ...@@ -305,9 +305,10 @@ static int vpfe_select_capture_device(int id)
{ {
int err = 0; int err = 0;
struct vpfe_capture_device *device; struct vpfe_capture_device *device;
down_interruptible(&vpfe_device.device_list_lock); down_interruptible(&vpfe_device.device_list_lock);
list_for_each_entry(device, &vpfe_device.capture_device_list, list_for_each_entry(device, &vpfe_device.capture_device_list,
device_list){ device_list){
if (device->id == id) { if (device->id == id) {
err = vpfe_capture_device_active(device); err = vpfe_capture_device_active(device);
up(&vpfe_device.device_list_lock); up(&vpfe_device.device_list_lock);
...@@ -342,7 +343,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -342,7 +343,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
case VIDIOC_QUERYCAP: case VIDIOC_QUERYCAP:
{ {
struct v4l2_capability *cap = struct v4l2_capability *cap =
(struct v4l2_capability *)arg; (struct v4l2_capability *)arg;
memset(cap, 0, sizeof(*cap)); memset(cap, 0, sizeof(*cap));
*cap = vpfe_drvcap; *cap = vpfe_drvcap;
break; break;
...@@ -383,7 +384,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -383,7 +384,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
pixfmt->pixelformat = vpfe->pixelfmt; pixfmt->pixelformat = vpfe->pixelfmt;
pixfmt->bytesperline = pixfmt->width * 2; pixfmt->bytesperline = pixfmt->width * 2;
pixfmt->sizeimage = pixfmt->sizeimage =
pixfmt->bytesperline * pixfmt->height; pixfmt->bytesperline * pixfmt->height;
pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M; pixfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
up(&vpfe->lock); up(&vpfe->lock);
} }
...@@ -525,8 +526,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -525,8 +526,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe->capture_params.squarepixel = sqp; vpfe->capture_params.squarepixel = sqp;
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VPFE_CMD_CONFIG_CAPTURE, VPFE_CMD_CONFIG_CAPTURE,
&vpfe->capture_params); &vpfe->capture_params);
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -614,13 +615,13 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -614,13 +615,13 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe->capture_params.amuxmode = *index; vpfe->capture_params.amuxmode = *index;
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_S_INPUT, index); VIDIOC_S_INPUT, index);
break; break;
} }
case VIDIOC_CROPCAP: case VIDIOC_CROPCAP:
{ {
struct v4l2_cropcap *cropcap = struct v4l2_cropcap *cropcap =
(struct v4l2_cropcap *)arg; (struct v4l2_cropcap *)arg;
cropcap->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; cropcap->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
cropcap->bounds = cropcap->defrect = vpfe->vwin; cropcap->bounds = cropcap->defrect = vpfe->vwin;
...@@ -637,7 +638,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -637,7 +638,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
ret = -EINVAL; ret = -EINVAL;
} else { } else {
struct v4l2_captureparm *capparm = struct v4l2_captureparm *capparm =
&parm->parm.capture; &parm->parm.capture;
memset(capparm, 0, memset(capparm, 0,
sizeof(struct v4l2_captureparm)); sizeof(struct v4l2_captureparm));
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
...@@ -657,7 +658,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -657,7 +658,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_G_CTRL, arg); VIDIOC_G_CTRL, arg);
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -665,7 +666,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -665,7 +666,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_S_CTRL, arg); VIDIOC_S_CTRL, arg);
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -673,7 +674,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -673,7 +674,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_QUERYCTRL, arg); VIDIOC_QUERYCTRL, arg);
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -720,7 +721,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -720,7 +721,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
down_interruptible(&vpfe->lock); down_interruptible(&vpfe->lock);
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VIDIOC_QUERYSTD, id); VIDIOC_QUERYSTD, id);
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -794,16 +795,16 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -794,16 +795,16 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
debug_print(KERN_INFO "cur frame %x.\n", debug_print(KERN_INFO "cur frame %x.\n",
vpfe->dma_queue.next); vpfe->dma_queue.next);
vpfe->nextFrm = vpfe->curFrm = vpfe->nextFrm = vpfe->curFrm =
list_entry(vpfe->dma_queue.next, list_entry(vpfe->dma_queue.next,
struct videobuf_buffer, queue); struct videobuf_buffer, queue);
/* remove the buffer from the queue */ /* remove the buffer from the queue */
list_del(&vpfe->curFrm->queue); list_del(&vpfe->curFrm->queue);
vpfe->curFrm->state = STATE_ACTIVE; vpfe->curFrm->state = STATE_ACTIVE;
/* sense the current video input standard */ /* sense the current video input standard */
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VPFE_CMD_CONFIG_CAPTURE, VPFE_CMD_CONFIG_CAPTURE,
&vpfe->capture_params); &vpfe->capture_params);
/* configure the ccdc and resizer as needed */ /* configure the ccdc and resizer as needed */
/* start capture by enabling CCDC and resizer */ /* start capture by enabling CCDC and resizer */
ccdc_config_ycbcr(&vpfe->ccdc_params); ccdc_config_ycbcr(&vpfe->ccdc_params);
...@@ -814,7 +815,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -814,7 +815,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
vpfe->started = TRUE; vpfe->started = TRUE;
vpfe->mode_changed = FALSE; vpfe->mode_changed = FALSE;
vpfe->field_offset = vpfe->field_offset =
(vpfe->vwin.height - 2) * vpfe->vwin.width; (vpfe->vwin.height - 2) * vpfe->vwin.width;
ccdc_enable(TRUE); ccdc_enable(TRUE);
up(&vpfe->lock); up(&vpfe->lock);
debug_print(KERN_INFO "started video streaming.\n"); debug_print(KERN_INFO "started video streaming.\n");
...@@ -854,7 +855,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -854,7 +855,7 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
if (params->buf_type == CCDC_BUFTYPE_FLD_INTERLEAVED) { if (params->buf_type == CCDC_BUFTYPE_FLD_INTERLEAVED) {
vpfe->field = V4L2_FIELD_INTERLACED; vpfe->field = V4L2_FIELD_INTERLACED;
} else if (params->buf_type == } else if (params->buf_type ==
CCDC_BUFTYPE_FLD_SEPARATED) { CCDC_BUFTYPE_FLD_SEPARATED) {
vpfe->field = V4L2_FIELD_SEQ_TB; vpfe->field = V4L2_FIELD_SEQ_TB;
} }
if (params->pix_order == CCDC_PIXORDER_YCBYCR) { if (params->pix_order == CCDC_PIXORDER_YCBYCR) {
...@@ -900,8 +901,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file, ...@@ -900,8 +901,8 @@ static int vpfe_doioctl(struct inode *inode, struct file *file,
} }
vpfe->std = std; vpfe->std = std;
ret |= DEVICE_CMD(ACTIVE_DEVICE(), ret |= DEVICE_CMD(ACTIVE_DEVICE(),
VPFE_CMD_CONFIG_CAPTURE, VPFE_CMD_CONFIG_CAPTURE,
params); params);
vpfe->capture_params = *params; vpfe->capture_params = *params;
up(&vpfe->lock); up(&vpfe->lock);
break; break;
...@@ -926,7 +927,7 @@ static int vpfe_ioctl(struct inode *inode, struct file *file, ...@@ -926,7 +927,7 @@ static int vpfe_ioctl(struct inode *inode, struct file *file,
ret = video_usercopy(inode, file, cmd, arg, vpfe_doioctl); ret = video_usercopy(inode, file, cmd, arg, vpfe_doioctl);
if( cmd == VIDIOC_S_FMT || cmd == VIDIOC_TRY_FMT ){ if( cmd == VIDIOC_S_FMT || cmd == VIDIOC_TRY_FMT ){
ret = video_usercopy(inode, file, VIDIOC_G_FMT, ret = video_usercopy(inode, file, VIDIOC_G_FMT,
arg, vpfe_doioctl); arg, vpfe_doioctl);
} }
return ret; return ret;
} }
...@@ -1070,11 +1071,11 @@ int vpfe_capture_device_register(struct vpfe_capture_device *device) ...@@ -1070,11 +1071,11 @@ int vpfe_capture_device_register(struct vpfe_capture_device *device)
/* call capture device specific init routine */ /* call capture device specific init routine */
down_interruptible(&vpfe_device.lock); down_interruptible(&vpfe_device.lock);
DEVICE_INIT(device, &vpfe_device.capture_params); DEVICE_INIT(device, &vpfe_device.capture_params);
up(&vpfe_device.lock); up(&vpfe_device.lock);
debug_print(KERN_INFO "VPFE Capture device %s registered, id = %d.\n", debug_print(KERN_INFO "VPFE Capture device %s registered, id = %d.\n",
device->name, device->id); device->name, device->id);
return 0; return 0;
} }
EXPORT_SYMBOL(vpfe_capture_device_register); EXPORT_SYMBOL(vpfe_capture_device_register);
...@@ -1098,22 +1099,22 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device) ...@@ -1098,22 +1099,22 @@ int vpfe_capture_device_unregister(struct vpfe_capture_device *device)
} }
/* call device specific routine to do the clean up. */ /* call device specific routine to do the clean up. */
DEVICE_CLEANUP(device); DEVICE_CLEANUP(device);
up(&vpfe_device.lock); up(&vpfe_device.lock);
debug_print(KERN_INFO "VPFE Capture device %s unregistered, id = %d\n", debug_print(KERN_INFO "VPFE Capture device %s unregistered, id = %d\n",
device->name, device->id); device->name, device->id);
return 0; return 0;
} }
EXPORT_SYMBOL(vpfe_capture_device_unregister); EXPORT_SYMBOL(vpfe_capture_device_unregister);
static int capture_device_all_unrigister(void) static int capture_device_all_unregister(void)
{ {
int ret = 0; int ret = 0;
struct vpfe_capture_device *device; struct vpfe_capture_device *device;
down_interruptible(&vpfe_device.lock); down_interruptible(&vpfe_device.lock);
list_for_each_entry(device, &vpfe_device.capture_device_list, list_for_each_entry(device, &vpfe_device.capture_device_list,
device_list){ device_list){
ret |= vpfe_capture_device_unregister(device); ret |= vpfe_capture_device_unregister(device);
} }
up(&vpfe_device.lock); up(&vpfe_device.lock);
...@@ -1153,7 +1154,7 @@ static struct platform_device _vpfe_device = { ...@@ -1153,7 +1154,7 @@ static struct platform_device _vpfe_device = {
.id = 1, .id = 1,
.dev = { .dev = {
.release = vpfe_platform_release, .release = vpfe_platform_release,
} }
}; };
static int vpfe_init(void) static int vpfe_init(void)
...@@ -1201,7 +1202,7 @@ static int vpfe_init(void) ...@@ -1201,7 +1202,7 @@ static int vpfe_init(void)
ccdc_reset(); ccdc_reset();
/* setup interrupt handling */ /* setup interrupt handling */
result = request_irq(IRQ_VDINT0, vpfe_isr, IRQF_DISABLED, result = request_irq(IRQ_VDINT0, vpfe_isr, IRQF_DISABLED,
"dm644xv4l2", (void *)&vpfe_device); "dm644xv4l2", (void *)&vpfe_device);
if (result < 0) { if (result < 0) {
printk(KERN_ERR "DaVinci v4l2 capture driver: cannot initialize IRQ\n"); printk(KERN_ERR "DaVinci v4l2 capture driver: cannot initialize IRQ\n");
return result; return result;
...@@ -1217,7 +1218,7 @@ static void vpfe_cleanup(void) ...@@ -1217,7 +1218,7 @@ static void vpfe_cleanup(void)
platform_device_unregister(&_vpfe_device); platform_device_unregister(&_vpfe_device);
driver_unregister(&vpfe_driver); driver_unregister(&vpfe_driver);
capture_device_all_unrigister(); capture_device_all_unregister();
/* disable interrupt */ /* disable interrupt */
free_irq(IRQ_VDINT0, &vpfe_device); free_irq(IRQ_VDINT0, &vpfe_device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment