Commit b9069d8b authored by steven.zhang's avatar steven.zhang Committed by Terry.Qiu

ARM: Davinci: port video previewer to kernel 2.6.23

Signed-off-by: default avatarTerry.Qiu <tqiu@neuros.com.cn>
parent 5fc27c61
...@@ -18,8 +18,13 @@ ...@@ -18,8 +18,13 @@
/* davinci_previewer.c file */ /* davinci_previewer.c file */
/* Copyright (c) 2008 Neuros Technology
* ported to udev for 2.6.23. -------- 03-14-2008 steven.zhang@neuros
*
*/
/* include Linux files */ /* include Linux files */
#include <linux/config.h> #include <linux/autoconf.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> /* printk() */ #include <linux/kernel.h> /* printk() */
...@@ -30,9 +35,9 @@ ...@@ -30,9 +35,9 @@
#include <linux/cdev.h> /* Used for struct cdev */ #include <linux/cdev.h> /* Used for struct cdev */
#include <linux/dma-mapping.h> /* For class_simple_create */ #include <linux/dma-mapping.h> /* For class_simple_create */
#include <linux/interrupt.h> /* For IRQ_HANDLED and irqreturn_t */ #include <linux/interrupt.h> /* For IRQ_HANDLED and irqreturn_t */
#include <linux/platform_device.h> /* For platform dependent device */
#include <asm/uaccess.h> /* for VERIFY_READ/VERIFY_WRITE/ #include <asm/uaccess.h> /* for VERIFY_READ/VERIFY_WRITE/
copy_from_user */ copy_from_user */
#include <linux/devfs_fs_kernel.h> /* for devfs */
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <asm/arch/davinci_previewer_hw.h> #include <asm/arch/davinci_previewer_hw.h>
...@@ -62,7 +67,7 @@ void inline prev_free_pages(unsigned long addr, unsigned long bufsize) ...@@ -62,7 +67,7 @@ void inline prev_free_pages(unsigned long addr, unsigned long bufsize)
reduction depending on the features enabled by the application. */ reduction depending on the features enabled by the application. */
void prev_calculate_crop(struct prev_params *config, struct prev_cropsize *crop) void prev_calculate_crop(struct prev_params *config, struct prev_cropsize *crop)
{ {
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (!config || !crop) { if (!config || !crop) {
...@@ -119,13 +124,13 @@ int get_status(struct prev_status *status) ...@@ -119,13 +124,13 @@ int get_status(struct prev_status *status)
irqreturn_t previewer_isr(int irq, void *device_id, struct pt_regs * regs) irqreturn_t previewer_isr(int irq, void *device_id, struct pt_regs * regs)
{ {
struct prev_device *prevdevice = (struct prev_device *)device_id; struct prev_device *prevdevice = (struct prev_device *)device_id;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
/* indicate the completion ofr frame processing */ /* indicate the completion ofr frame processing */
if (prevdevice) if (prevdevice)
complete(&(prevdevice->wfc)); complete(&(prevdevice->wfc));
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -136,7 +141,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs) ...@@ -136,7 +141,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs)
unsigned long adr; unsigned long adr;
u32 size; u32 size;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (!reqbufs || !device) { if (!reqbufs || !device) {
dev_err(prev_dev, "request_buffer: error in argument\n"); dev_err(prev_dev, "request_buffer: error in argument\n");
return -EINVAL; return -EINVAL;
...@@ -474,7 +479,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs) ...@@ -474,7 +479,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs)
return -EINVAL; return -EINVAL;
} }
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -483,7 +488,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs) ...@@ -483,7 +488,7 @@ int request_buffer(struct prev_device *device, struct prev_reqbufs *reqbufs)
in prev_buffer. */ in prev_buffer. */
int query_buffer(struct prev_device *device, struct prev_buffer *buffer) int query_buffer(struct prev_device *device, struct prev_buffer *buffer)
{ {
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (!buffer || !device) { if (!buffer || !device) {
dev_err(prev_dev, "query_buffer: error in argument\n"); dev_err(prev_dev, "query_buffer: error in argument\n");
...@@ -522,7 +527,7 @@ int query_buffer(struct prev_device *device, struct prev_buffer *buffer) ...@@ -522,7 +527,7 @@ int query_buffer(struct prev_device *device, struct prev_buffer *buffer)
return -EINVAL; return -EINVAL;
} }
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -530,7 +535,7 @@ int validate_params(struct prev_params *params) ...@@ -530,7 +535,7 @@ int validate_params(struct prev_params *params)
{ {
struct prev_cropsize crop; struct prev_cropsize crop;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (!params) { if (!params) {
dev_err(prev_dev, "validate_params:error in argument"); dev_err(prev_dev, "validate_params:error in argument");
...@@ -606,7 +611,7 @@ int validate_params(struct prev_params *params) ...@@ -606,7 +611,7 @@ int validate_params(struct prev_params *params)
return -EINVAL; return -EINVAL;
} }
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -615,7 +620,7 @@ int free_buffers(struct prev_device *device) ...@@ -615,7 +620,7 @@ int free_buffers(struct prev_device *device)
{ {
int i; int i;
unsigned long adr; unsigned long adr;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (!device) { if (!device) {
dev_err(prev_dev, "\nfree_buffers:error in argument"); dev_err(prev_dev, "\nfree_buffers:error in argument");
return -EINVAL; return -EINVAL;
...@@ -651,7 +656,7 @@ int free_buffers(struct prev_device *device) ...@@ -651,7 +656,7 @@ int free_buffers(struct prev_device *device)
} }
device->out_numbuffers = 0; device->out_numbuffers = 0;
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -662,7 +667,7 @@ int preview(struct prev_device *device, struct prev_convert *convert) ...@@ -662,7 +667,7 @@ int preview(struct prev_device *device, struct prev_convert *convert)
int bpp, size, cropsize; int bpp, size, cropsize;
unsigned long in_addr, out_addr; unsigned long in_addr, out_addr;
struct prev_cropsize crop; struct prev_cropsize crop;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
/* error checking */ /* error checking */
if (!convert || !device) { if (!convert || !device) {
...@@ -778,7 +783,7 @@ int preview(struct prev_device *device, struct prev_convert *convert) ...@@ -778,7 +783,7 @@ int preview(struct prev_device *device, struct prev_convert *convert)
/* wait untill processing is not completed */ /* wait untill processing is not completed */
wait_for_completion_interruptible(&(device->wfc)); wait_for_completion_interruptible(&(device->wfc));
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -795,7 +800,7 @@ int previewer_open(struct inode *inode, struct file *filp) ...@@ -795,7 +800,7 @@ int previewer_open(struct inode *inode, struct file *filp)
struct prev_params *config = NULL; struct prev_params *config = NULL;
struct prev_device *device = &prevdevice; struct prev_device *device = &prevdevice;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
if (device->opened || filp->f_flags & O_NONBLOCK) { if (device->opened || filp->f_flags & O_NONBLOCK) {
dev_err dev_err
...@@ -821,7 +826,7 @@ int previewer_open(struct inode *inode, struct file *filp) ...@@ -821,7 +826,7 @@ int previewer_open(struct inode *inode, struct file *filp)
prevdevice.wfc.done = 0; prevdevice.wfc.done = 0;
init_MUTEX(&(prevdevice.sem)); init_MUTEX(&(prevdevice.sem));
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -830,7 +835,7 @@ int previewer_release(struct inode *inode, struct file *filp) ...@@ -830,7 +835,7 @@ int previewer_release(struct inode *inode, struct file *filp)
/* get the configuratin from private_date member of file */ /* get the configuratin from private_date member of file */
struct prev_params *config = filp->private_data; struct prev_params *config = filp->private_data;
struct prev_device *device = &prevdevice; struct prev_device *device = &prevdevice;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
/* call free_buffers to free memory allocated to buffers */ /* call free_buffers to free memory allocated to buffers */
free_buffers(device); free_buffers(device);
...@@ -846,7 +851,7 @@ int previewer_release(struct inode *inode, struct file *filp) ...@@ -846,7 +851,7 @@ int previewer_release(struct inode *inode, struct file *filp)
/* change the device status to available */ /* change the device status to available */
device->opened = 0; device->opened = 0;
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
...@@ -857,7 +862,7 @@ int previewer_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -857,7 +862,7 @@ int previewer_mmap(struct file *filp, struct vm_area_struct *vma)
int i, flag = 0; int i, flag = 0;
/* get the page offset */ /* get the page offset */
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT; unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
/* page offset passed in mmap should one from input buffers */ /* page offset passed in mmap should one from input buffers */
for (i = 0; i < device->in_numbuffers; i++) { for (i = 0; i < device->in_numbuffers; i++) {
...@@ -887,7 +892,7 @@ int previewer_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -887,7 +892,7 @@ int previewer_mmap(struct file *filp, struct vm_area_struct *vma)
return -EAGAIN; return -EAGAIN;
} }
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return 0; return 0;
} }
int previewer_ioctl(struct inode *inode, struct file *file, int previewer_ioctl(struct inode *inode, struct file *file,
...@@ -899,7 +904,7 @@ int previewer_ioctl(struct inode *inode, struct file *file, ...@@ -899,7 +904,7 @@ int previewer_ioctl(struct inode *inode, struct file *file,
/* get the address of global object of prev_device structure */ /* get the address of global object of prev_device structure */
struct prev_device *device = &prevdevice; struct prev_device *device = &prevdevice;
dev_dbg(prev_dev, __FUNCTION__ "E\n"); dev_dbg(prev_dev, __FUNCTION__);
/* Before decoding check for correctness of cmd */ /* Before decoding check for correctness of cmd */
if (_IOC_TYPE(cmd) != PREV_IOC_BASE) { if (_IOC_TYPE(cmd) != PREV_IOC_BASE) {
...@@ -1017,7 +1022,7 @@ int previewer_ioctl(struct inode *inode, struct file *file, ...@@ -1017,7 +1022,7 @@ int previewer_ioctl(struct inode *inode, struct file *file,
ret = -EINVAL; ret = -EINVAL;
} }
dev_dbg(prev_dev, __FUNCTION__ "L\n"); dev_dbg(prev_dev, __FUNCTION__);
return ret; return ret;
} }
static void previewer_platform_release(struct device *device) static void previewer_platform_release(struct device *device)
...@@ -1052,7 +1057,7 @@ static struct cdev cdev; ...@@ -1052,7 +1057,7 @@ static struct cdev cdev;
/* global variable which keeps major and minor number of the driver in it */ /* global variable which keeps major and minor number of the driver in it */
static dev_t dev; static dev_t dev;
static struct class_simple *prev_class = NULL; static struct class *prev_class = NULL;
static struct platform_device previewer_device = { static struct platform_device previewer_device = {
.name = "davinci_previewer", .name = "davinci_previewer",
...@@ -1120,7 +1125,7 @@ int __init previewer_init(void) ...@@ -1120,7 +1125,7 @@ int __init previewer_init(void)
return -EINVAL; return -EINVAL;
} }
prev_class = class_simple_create(THIS_MODULE, "davinci_previewer"); prev_class = class_create(THIS_MODULE, "davinci_previewer");
if (!prev_class) { if (!prev_class) {
printk("previewer_init: error in creating device class\n"); printk("previewer_init: error in creating device class\n");
driver_unregister(&previewer_driver); driver_unregister(&previewer_driver);
...@@ -1131,21 +1136,8 @@ int __init previewer_init(void) ...@@ -1131,21 +1136,8 @@ int __init previewer_init(void)
return -EIO; return -EIO;
} }
/* make entry in the devfs */ /* register device class */
result = devfs_mk_cdev(dev, S_IFCHR | S_IRUGO | S_IWUSR, "%s%d", class_device_create(prev_class, NULL, dev, NULL, "davinci_previewer");
"davinci_previewer", 0);
if (result < 0) {
printk("previewer_init: error in devfs_register_chrdev\n");
unregister_chrdev_region(dev, 1);
class_simple_destroy(prev_class);
unregister_chrdev(MAJOR(dev), DRIVERNAME);
cdev_del(&cdev);
return result;
}
/* register simple device class */
class_simple_device_add(prev_class, dev, NULL, "davinci_previewer");
/* Set up the Interrupt handler for PRVINT interrupt */ /* Set up the Interrupt handler for PRVINT interrupt */
result = request_irq(IRQ_PRVUINT, previewer_isr, SA_INTERRUPT, result = request_irq(IRQ_PRVUINT, previewer_isr, SA_INTERRUPT,
...@@ -1155,9 +1147,8 @@ int __init previewer_init(void) ...@@ -1155,9 +1147,8 @@ int __init previewer_init(void)
printk("previewer_init:cannot get irq\n"); printk("previewer_init:cannot get irq\n");
unregister_chrdev_region(dev, 1); unregister_chrdev_region(dev, 1);
class_simple_device_remove(dev); class_device_destroy(prev_class, dev);
devfs_remove("%s%d", "davinci_previewer", 0); class_destroy(prev_class);
class_simple_destroy(prev_class);
driver_unregister(&previewer_driver); driver_unregister(&previewer_driver);
platform_device_unregister(&previewer_device); platform_device_unregister(&previewer_device);
cdev_del(&cdev); cdev_del(&cdev);
...@@ -1177,14 +1168,11 @@ void __exit previewer_cleanup(void) ...@@ -1177,14 +1168,11 @@ void __exit previewer_cleanup(void)
/* remove major number allocated to this driver */ /* remove major number allocated to this driver */
unregister_chrdev_region(dev, 1); unregister_chrdev_region(dev, 1);
/* remove simple class device */ /* destroy class device */
class_simple_device_remove(dev); class_device_destroy(prev_class, dev);
/* remove prev device from devfs */
devfs_remove("%s%d", "davinci_previewer", 0);
/* destroy simple class */ /* destroy class */
class_simple_destroy(prev_class); class_destroy(prev_class);
/* Remove platform driver */ /* Remove platform driver */
driver_unregister(&previewer_driver); driver_unregister(&previewer_driver);
......
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