add libtool to tools/
[openwrt.git] / package / fonera-mp3-drv / src / mp3_drv.c
index f2c0dd1..82863ac 100644 (file)
@@ -30,6 +30,8 @@
 #include <linux/timer.h>
 #include <linux/init.h>
 #include <linux/genhd.h>
+#include <linux/device.h> 
+#include <asm-mips/mach-atheros/reset.h>
 
 // do we want debuging info ?
 #if 0
@@ -100,11 +102,12 @@ static DECLARE_COMPLETION(mp3_exit);
 static int mp3_playback_thread(void *data){
        int j;
        unsigned long timeout;
+       unsigned char empty = 0;
        printk("started kthread\n");
        daemonize("kmp3");
        while(mp3_buffering_status != MP3_PLAY_FINISHED){
                if((mp3_buffering_status == MP3_PLAYING) || (mp3_buffering_status == MP3_BUFFER_FINISHED)){
-                       while(VS1011_NEEDS_DATA){
+                       while((VS1011_NEEDS_DATA) && (!empty)){
                                if(mp3_buffer_offset_read == MP3_BUFFER_SIZE){
                                        mp3_buffer_offset_read = 0;
                                }
@@ -114,6 +117,7 @@ static int mp3_playback_thread(void *data){
                                                printk("mp3_drv.ko : finished playing\n");
                                                mp3_buffering_status = MP3_PLAY_FINISHED;
                                        } else {
+                                               empty = 1;
                                                printk("mp3_drv.ko : buffer empty ?\n");
                                                if(mp3_buffering_status != MP3_PLAY_FINISHED){
                                                }
@@ -127,8 +131,9 @@ static int mp3_playback_thread(void *data){
                                }
                        }
                }
+               empty = 0;
                timeout = 1;    
-               timeout = wait_event_interruptible_timeout(wq, (timeout==0), timeout);  
+               timeout = wait_event_interruptible_timeout(wq, (timeout==0), timeout);  
        }
        complete_and_exit(&mp3_exit, 0); 
 }
@@ -271,16 +276,28 @@ struct file_operations modulemp3_fops = {
         release:       module_close
 };
 
+static struct class *mp3_class; 
+
 static int __init mod_init(void){
        printk("mp3_drv.ko : VS1011b Driver\n");
        printk("mp3_drv.ko : Made by John '2B|!2B' Crispin (john@phrozen.org)\n");
        printk("mp3_drv.ko : Starting ...\n");
        
+       printk("disabling atheros reset button irq\n");
+
+       ar531x_disable_reset_button();
+
        if(register_chrdev(DEV_MAJOR, DEV_NAME, &modulemp3_fops)) {
                printk( "mp3_drv.ko : Error whilst opening %s (%d)\n", DEV_NAME, DEV_MAJOR);
                return( -ENODEV );
        }
-       
+
+       printk("mp3_drv.ko : using sysfs to create device nodes\n");
+       mp3_class = class_create(THIS_MODULE, DEV_NAME); 
+       class_device_create(mp3_class, NULL, 
+               MKDEV(DEV_MAJOR, 0), 
+               NULL, DEV_NAME); 
+
        mp3_info[0].is_open = 0;
        printk("mp3_drv.ko : Device %s registered for major ID %d\n", DEV_NAME, DEV_MAJOR);
        crystal_freq = CRYSTAL12288;
This page took 0.024734 seconds and 4 git commands to generate.