make driver standalone again
[sgx.git] / pvr / module.c
index c79b0d9..df050af 100644 (file)
 #include "proc.h"
 #include "pvrmodule.h"
 #include "private_data.h"
+#include "pvr_events.h"
+
+#ifdef CONFIG_DEBUG_FS
+#include "pvr_debugfs.h"
+#endif
 
 #define DRVNAME                "pvrsrvkm"
 
@@ -71,6 +76,11 @@ static int pvr_open(struct inode unref__ * inode, struct file *filp)
 
        pvr_lock();
 
+       if (pvr_is_disabled()) {
+               ret = -ENODEV;
+               goto err_unlock;
+       }
+
        pid = OSGetCurrentProcessIDKM();
 
        if (PVRSRVProcessConnect(pid) != PVRSRV_OK)
@@ -85,6 +95,7 @@ static int pvr_open(struct inode unref__ * inode, struct file *filp)
 
        priv->ui32OpenPID = pid;
        priv->hBlockAlloc = block_alloc;
+       priv->proc = PVRSRVPerProcessData(pid);
        filp->private_data = priv;
 
        INIT_LIST_HEAD(&priv->event_list);
@@ -106,6 +117,8 @@ static int pvr_release(struct inode unref__ * inode, struct file *filp)
 
        priv = filp->private_data;
 
+       pvr_release_events(priv);
+
        PVRSRVProcessDisconnect(priv->ui32OpenPID);
 
        OSFreeMem(PVRSRV_OS_NON_PAGEABLE_HEAP,
@@ -123,6 +136,8 @@ static const struct file_operations pvr_fops = {
        .open           = pvr_open,
        .release        = pvr_release,
        .mmap           = PVRMMap,
+       .poll           = pvr_poll,
+       .read           = pvr_read,
 };
 
 static void pvr_shutdown(struct platform_device *pdev)
@@ -212,6 +227,21 @@ static struct platform_driver pvr_driver = {
        .shutdown       = pvr_shutdown,
 };
 
+static void pvr_dummy_release(struct device *dev)
+{
+}
+
+static struct sgx_platform_data pvr_pdata;
+
+static struct platform_device pvr_device = {
+       .name           = DRVNAME,
+       .id             = -1,
+       .dev            = {
+               .platform_data  = &pvr_pdata,
+               .release        = pvr_dummy_release,
+       }
+};
+
 static int __init pvr_init(void)
 {
        int error;
@@ -220,12 +250,14 @@ static int __init pvr_init(void)
 
        PVR_TRACE("pvr_init");
 
-       pvr_init_lock();
-
 #ifdef CONFIG_PVR_DEBUG_EXTRA
        PVRDebugSetLevel(debug);
 #endif
 
+#ifdef CONFIG_DEBUG_FS
+       pvr_debugfs_init();
+#endif
+
        error = CreateProcEntries();
        if (error < 0)
                goto err1;
@@ -243,8 +275,17 @@ static int __init pvr_init(void)
        if (error < 0)
                goto err4;
 
+       pvr_pdata.fclock_max = 200000000;
+       error = platform_device_register(&pvr_device);
+       if (error < 0)
+               goto err5;
+
+       pvr_init_events();
+
        return 0;
 
+err5:
+       platform_driver_unregister(&pvr_driver);
 err4:
        PVRMMapCleanup();
        LinuxBridgeDeInit();
@@ -260,13 +301,12 @@ err1:
 
 static void __exit pvr_cleanup(void)
 {
-       struct SYS_DATA *sysdata;
-
        PVR_TRACE("pvr_cleanup");
 
-       SysAcquireData(&sysdata);
+       pvr_exit_events();
 
        platform_driver_unregister(&pvr_driver);
+       platform_device_unregister(&pvr_device);
 
        PVRMMapCleanup();
        LinuxMMCleanup();
@@ -275,6 +315,9 @@ static void __exit pvr_cleanup(void)
 
        PVR_TRACE("pvr_cleanup: unloading");
 
+#ifdef CONFIG_DEBUG_FS
+       pvr_debugfs_cleanup();
+#endif
        pvr_dbg_cleanup();
 }