mod_timer(&timer, jiffies + 10*HZ); /*the interval is 10s*/
#endif
- switch (_IOC_NR(cmd)) {
- case _IOC_NR(HANTRODEC_IOC_CLI):
+ switch (cmd) {
+ case HANTRODEC_IOC_CLI:
{
__u32 id;
__get_user(id, (__u32*)arg);
disable_irq(hantrodec_data.irq[id]);
break;
}
- case _IOC_NR(HANTRODEC_IOC_STI):
+ case HANTRODEC_IOC_STI:
{
__u32 id;
__get_user(id, (__u32*)arg);
enable_irq(hantrodec_data.irq[id]);
break;
}
- case _IOC_NR(HANTRODEC_IOCGHWOFFSET):
+ case HANTRODEC_IOCGHWOFFSET:
{
__u32 id;
__get_user(id, (__u32*)arg);
__put_user(multicorebase[id], (unsigned long *) arg);
break;
}
- case _IOC_NR(HANTRODEC_IOCGHWIOSIZE):
+ case HANTRODEC_IOCGHWIOSIZE:
{
__u32 id;
__u32 io_size;
return 0;
}
- case _IOC_NR(HANTRODEC_IOC_MC_OFFSETS): {
+ case HANTRODEC_IOC_MC_OFFSETS: {
tmp = copy_to_user((u64 *) arg, multicorebase, sizeof(multicorebase));
if (err) {
PDEBUG("copy_to_user failed, returned %li\n", tmp);
}
break;
}
- case _IOC_NR(HANTRODEC_IOC_MC_CORES):
+ case HANTRODEC_IOC_MC_CORES:
__put_user(hantrodec_data.cores, (unsigned int *) arg);
PDEBUG("hantrodec_data.cores=%d\n", hantrodec_data.cores);
break;
- case _IOC_NR(HANTRODEC_IOCS_DEC_PUSH_REG): {
+ case HANTRODEC_IOCS_DEC_PUSH_REG: {
struct core_desc Core;
/* get registers from user space*/
DecFlushRegs(&hantrodec_data, &Core);
break;
}
- case _IOC_NR(HANTRODEC_IOCS_PP_PUSH_REG): {
+ case HANTRODEC_IOCS_PP_PUSH_REG: {
struct core_desc Core;
/* get registers from user space*/
PPFlushRegs(&hantrodec_data, &Core);
break;
}
- case _IOC_NR(HANTRODEC_IOCS_DEC_PULL_REG): {
+ case HANTRODEC_IOCS_DEC_PULL_REG: {
struct core_desc Core;
/* get registers from user space*/
return DecRefreshRegs(&hantrodec_data, &Core);
}
- case _IOC_NR(HANTRODEC_IOCS_PP_PULL_REG): {
+ case HANTRODEC_IOCS_PP_PULL_REG: {
struct core_desc Core;
/* get registers from user space*/
return PPRefreshRegs(&hantrodec_data, &Core);
}
- case _IOC_NR(HANTRODEC_IOCH_DEC_RESERVE): {
+ case HANTRODEC_IOCH_DEC_RESERVE: {
PDEBUG("Reserve DEC Core, format = %li\n", arg);
return ReserveDecoder(&hantrodec_data, filp, arg);
}
- case _IOC_NR(HANTRODEC_IOCT_DEC_RELEASE): {
+ case HANTRODEC_IOCT_DEC_RELEASE: {
if(arg >= hantrodec_data.cores || dec_owner[arg] != filp) {
PDEBUG("bogus DEC release, Core = %li\n", arg);
return -EFAULT;
break;
}
- case _IOC_NR(HANTRODEC_IOCQ_PP_RESERVE):
+ case HANTRODEC_IOCQ_PP_RESERVE:
return ReservePostProcessor(&hantrodec_data, filp);
- case _IOC_NR(HANTRODEC_IOCT_PP_RELEASE): {
+ case HANTRODEC_IOCT_PP_RELEASE: {
if(arg != 0 || pp_owner[arg] != filp) {
PDEBUG("bogus PP release %li\n", arg);
return -EFAULT;
break;
}
- case _IOC_NR(HANTRODEC_IOCX_DEC_WAIT): {
+ case HANTRODEC_IOCX_DEC_WAIT: {
struct core_desc Core;
/* get registers from user space */
return WaitDecReadyAndRefreshRegs(&hantrodec_data, &Core);
}
- case _IOC_NR(HANTRODEC_IOCX_PP_WAIT): {
+ case HANTRODEC_IOCX_PP_WAIT: {
struct core_desc Core;
/* get registers from user space */
return WaitPPReadyAndRefreshRegs(&hantrodec_data, &Core);
}
- case _IOC_NR(HANTRODEC_IOCG_CORE_WAIT): {
+ case HANTRODEC_IOCG_CORE_WAIT: {
int id;
tmp = WaitCoreReady(&hantrodec_data, filp, &id);
__put_user(id, (int *) arg);
return tmp;
}
- case _IOC_NR(HANTRODEC_IOX_ASIC_ID): {
+ case HANTRODEC_IOX_ASIC_ID: {
u32 id;
__get_user(id, (u32*)arg);
__put_user(id, (u32 *) arg);
return 0;
}
- case _IOC_NR(HANTRODEC_IOCG_CORE_ID): {
+ case HANTRODEC_IOCG_CORE_ID: {
PDEBUG("Get DEC Core_id, format = %li\n", arg);
return GetDecCoreID(&hantrodec_data, filp, arg);
}
- case _IOC_NR(HANTRODEC_DEBUG_STATUS): {
+ case HANTRODEC_DEBUG_STATUS: {
printk(KERN_INFO "hantrodec: dec_irq = 0x%08x \n", dec_irq);
printk(KERN_INFO "hantrodec: pp_irq = 0x%08x \n", pp_irq);
return 0;
}
-
-#ifdef CONFIG_COMPAT
-struct core_desc_32 {
- __u32 id; /* id of the Core */
- compat_caddr_t regs; /* pointer to user registers */
- __u32 size; /* size of register space */
-};
-
-static int get_hantro_core_desc32(struct core_desc *kp, struct core_desc_32 __user *up)
-{
- u32 tmp;
- if (!access_ok(VERIFY_READ, up, sizeof(struct core_desc_32)) ||
- get_user(kp->id, &up->id) ||
- get_user(kp->size, &up->size) ||
- get_user(tmp, &up->regs)){
- return -EFAULT;
- }
- kp->regs = (__force u32 *)compat_ptr(tmp);
- return 0;
-}
-
-static int put_hantro_core_desc32(struct core_desc *kp, struct core_desc_32 __user *up)
-{
- u32 tmp = (u32)((unsigned long)kp->regs);
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct core_desc_32)) ||
- put_user(kp->id, &up->id) ||
- put_user(kp->size, &up->size) ||
- put_user(tmp, &up->regs)){
- return -EFAULT;
- }
- return 0;
-}
-static long hantrodec_ioctl32(struct file *filp, unsigned int cmd,unsigned long arg)
-{
-#define HANTRO_IOCTL32(err,filp,cmd, arg) {\
- mm_segment_t old_fs = get_fs(); \
- set_fs(KERNEL_DS); \
- err = hantrodec_ioctl(filp, cmd, arg);\
- if(err) return err;\
- set_fs(old_fs);\
-}
- union {
- struct core_desc kcore;
- unsigned long kux;
- unsigned int kui;
- } karg;
- void __user *up = compat_ptr(arg);
- long err = 0;
-
- switch(_IOC_NR(cmd)){
- case _IOC_NR(HANTRODEC_IOCGHWOFFSET):
- case _IOC_NR(HANTRODEC_IOC_MC_OFFSETS):
- err = get_user(karg.kux, (s32 __user *)up);
- if(err) return err;
- HANTRO_IOCTL32(err,filp,cmd, (unsigned long)&karg);
- err = put_user(((s32)karg.kux), (s32 __user *)up);
- break;
- case _IOC_NR(HANTRODEC_IOCGHWIOSIZE):
- case _IOC_NR(HANTRODEC_IOC_MC_CORES):
- case _IOC_NR(HANTRODEC_IOCG_CORE_WAIT):
- case _IOC_NR(HANTRODEC_IOX_ASIC_ID):
- err = get_user(karg.kui, (s32 __user *)up);
- if(err) return err;
- HANTRO_IOCTL32(err,filp,cmd, (unsigned long)&karg);
- err = put_user(((s32)karg.kui), (s32 __user *)up);
- break;
- case _IOC_NR(HANTRODEC_IOCS_DEC_PUSH_REG):
- case _IOC_NR(HANTRODEC_IOCS_PP_PUSH_REG):
- case _IOC_NR(HANTRODEC_IOCX_DEC_WAIT):
- case _IOC_NR(HANTRODEC_IOCX_PP_WAIT):
- case _IOC_NR(HANTRODEC_IOCS_DEC_PULL_REG):
- case _IOC_NR(HANTRODEC_IOCS_PP_PULL_REG):
- err = get_hantro_core_desc32(&karg.kcore, up);
- if(err) return err;
- HANTRO_IOCTL32(err,filp,cmd, (unsigned long)&karg);
- err = put_hantro_core_desc32(&karg.kcore, up);
- break;
- default:
- err = hantrodec_ioctl(filp, cmd, (unsigned long)up);
- break;
- }
-
- return err;
-}
-
-#endif //ifdef CONFIG_COMPAT
/*------------------------------------------------------------------------------
Function name : hantrodec_open
.unlocked_ioctl = hantrodec_ioctl,
.fasync = NULL,
.mmap = hantro_mmap,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = hantrodec_ioctl32,
-#endif
};
/*------------------------------------------------------------------------------
#include <linux/dma-buf.h>
#include "../ion_priv.h"
-#include <linux/compat.h>
static struct ion_device *idev;
static int num_heaps = 1;
return pdata;
}
-struct ion_phys_data32 {
- __s32 handle; //ion_user_handle_t
- compat_long_t phys;
-};
-
-struct ion_phys_dma_data32 {
- compat_long_t phys;
- __u32 size;
- __u32 dmafd;
-};
-
-struct ion_phys_virt_data32 {
- compat_long_t virt;
- compat_long_t phys;
- __u32 size;
-};
-
-#define ION_IOC_PHYS32 _IOWR(ION_IOC_MAGIC, _IOC_NR(ION_IOC_PHYS), struct ion_phys_data32)
-#define ION_IOC_PHYS_DMA32 _IOWR(ION_IOC_MAGIC, _IOC_NR(ION_IOC_PHYS_DMA), struct ion_phys_dma_data32)
-#define ION_IOC_PHYS_VIRT32 _IOWR(ION_IOC_MAGIC, _IOC_NR(ION_IOC_PHYS_VIRT), struct ion_phys_virt_data32)
-
-static int get_ion_phys_data32(struct ion_phys_data *kp, struct ion_phys_data32 __user *up)
-{
- void __user *up_pln;
- compat_long_t p;
-
- if (!access_ok(VERIFY_READ, up, sizeof(struct ion_phys_data32)) ||
- get_user(kp->handle, &up->handle) ||
- get_user(p, &up->phys))
- return -EFAULT;
- up_pln = compat_ptr(p);
- put_user((unsigned long)up_pln, &kp->phys);
- return 0;
-}
-
-static int put_ion_phys_data32(struct ion_phys_data *kp, struct ion_phys_data32 __user *up)
-{
- u32 tmp = (u32)((unsigned long)kp->phys);
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct ion_phys_data32)) ||
- put_user((s32)kp->handle, &up->handle) ||
- put_user(tmp, &up->phys))
- return -EFAULT;
- return 0;
-}
-
-static int get_ion_phys_dma_data32(struct ion_phys_dma_data *kp, struct ion_phys_dma_data32 __user *up)
-{
- void __user *up_pln;
- compat_long_t p;
-
- if (!access_ok(VERIFY_READ, up, sizeof(struct ion_phys_dma_data32)) ||
- get_user(kp->size, &up->size) ||
- get_user(kp->dmafd, &up->dmafd) ||
- get_user(p, &up->phys))
- return -EFAULT;
- up_pln = compat_ptr(p);
- put_user((unsigned long)up_pln, &kp->phys);
- return 0;
-}
-
-static int put_ion_phys_dma_data32(struct ion_phys_dma_data *kp, struct ion_phys_dma_data32 __user *up)
-{
- u32 tmp = (u32)((unsigned long)kp->phys);
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct ion_phys_dma_data32)) ||
- put_user((s32)kp->size, &up->size) ||
- put_user((s32)kp->dmafd, &up->dmafd) ||
- put_user(tmp, &up->phys))
- return -EFAULT;
- return 0;
-}
-
-static int get_ion_phys_virt_data32(struct ion_phys_virt_data *kp, struct ion_phys_virt_data32 __user *up)
-{
- void __user *up_pln;
- void __user *up_pln2;
- compat_long_t p;
- compat_long_t p2;
-
- if (!access_ok(VERIFY_READ, up, sizeof(struct ion_phys_virt_data32)) ||
- get_user(kp->size, &up->size) ||
- get_user(p, &up->phys) ||
- get_user(p2, &up->virt))
- return -EFAULT;
- up_pln = compat_ptr(p);
- up_pln2 = compat_ptr(p2);
- put_user((unsigned long)up_pln, &kp->phys);
- put_user((unsigned long)up_pln2, &kp->virt);
- return 0;
-}
-
-static int put_ion_phys_virt_data32(struct ion_phys_virt_data *kp, struct ion_phys_virt_data32 __user *up)
-{
- u32 tmp = (u32)((unsigned long)kp->phys);
- u32 tmp2 = (u32)((unsigned long)kp->virt);
- if (!access_ok(VERIFY_WRITE, up, sizeof(struct ion_phys_virt_data32)) ||
- put_user((u32)kp->size, &up->size) ||
- put_user(tmp, &up->phys) ||
- put_user(tmp2, &up->virt))
- return -EFAULT;
- return 0;
-}
-
static long
mxc_custom_ioctl(struct ion_client *client, unsigned int cmd, unsigned long arg)
{
-
switch (cmd) {
case ION_IOC_PHYS:
{
return 0;
}
-static long
-mxc_custom_compat_ioctl(struct ion_client *client, unsigned int cmd, unsigned long arg)
-{
-#define MXC_CUSTOM_IOCTL32(err,client,cmd,arg) {\
- mm_segment_t old_fs = get_fs();\
- set_fs(KERNEL_DS);\
- err = mxc_custom_ioctl(client, cmd, arg);\
- if(err) return err;\
- set_fs(old_fs);\
-}
- union {
- struct ion_phys_data kdata;
- struct ion_phys_dma_data kdmadata;
- struct ion_phys_virt_data kvirtdata;
- } karg;
-
- void __user *up = compat_ptr(arg);
- long err = 0;
-
- switch(cmd){
- case ION_IOC_PHYS32:
- err = get_ion_phys_data32(&karg.kdata, up);
- if(err) return err;
- MXC_CUSTOM_IOCTL32(err,client,ION_IOC_PHYS,(unsigned long)&karg);
- err = put_ion_phys_data32(&karg.kdata, up);
- break;
- case ION_IOC_PHYS_DMA32:
- err = get_ion_phys_dma_data32(&karg.kdmadata, up);
- if(err) return err;
- MXC_CUSTOM_IOCTL32(err,client,ION_IOC_PHYS_DMA,(unsigned long)&karg);
- err = put_ion_phys_dma_data32(&karg.kdmadata, up);
- break;
- case ION_IOC_PHYS_VIRT32:
- err = get_ion_phys_virt_data32(&karg.kvirtdata, up);
- if(err) return err;
- MXC_CUSTOM_IOCTL32(err,client,ION_IOC_PHYS_VIRT,(unsigned long)&karg);
- err = put_ion_phys_virt_data32(&karg.kvirtdata, up);
- break;
- default:
- err = mxc_custom_ioctl(client, cmd, (unsigned long)arg);
- break;
- }
-
- return err;
-}
+
int
mxc_ion_probe(struct platform_device *pdev)
{
heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
- idev = ion_device_create(mxc_custom_compat_ioctl);
+ idev = ion_device_create(mxc_custom_ioctl);
if (IS_ERR_OR_NULL(idev)) {
err = PTR_ERR(idev);
goto err;