/[openvortex]/alsa/alsa-kernel/core/memalloc.c
ViewVC logotype

Diff of /alsa/alsa-kernel/core/memalloc.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by vizard, Sun Jun 15 21:01:30 2003 UTC revision 1.4 by vizard, Mon Aug 11 00:06:37 2003 UTC
# Line 37  MODULE_DESCRIPTION("Memory allocator for Line 37  MODULE_DESCRIPTION("Memory allocator for
37  MODULE_LICENSE("GPL");  MODULE_LICENSE("GPL");
38    
39    
 /* so far, pre-defined allocation is only for hammerfall cards... */  
 /* #define ENABLE_PREALLOC */  
   
   
 #ifdef ENABLE_PREALLOC  
40  #ifndef SNDRV_CARDS  #ifndef SNDRV_CARDS
41  #define SNDRV_CARDS     8  #define SNDRV_CARDS     8
42  #endif  #endif
43  static int enable[8] = {[0 ... (SNDRV_CARDS-1)] = 1};  static int enable[8] = {[0 ... (SNDRV_CARDS-1)] = 1};
44  MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");  MODULE_PARM(enable, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
45  MODULE_PARM_DESC(enable, "Enable cards to allocate buffers.");  MODULE_PARM_DESC(enable, "Enable cards to allocate buffers.");
 #endif  
46    
47    
48  /*  /*
# Line 154  static int compare_device(const struct s Line 148  static int compare_device(const struct s
148                  return a->dev.flags == b->dev.flags;                  return a->dev.flags == b->dev.flags;
149  #ifdef CONFIG_PCI  #ifdef CONFIG_PCI
150          case SNDRV_DMA_TYPE_PCI:          case SNDRV_DMA_TYPE_PCI:
151            case SNDRV_DMA_TYPE_PCI_SG:
152                  return a->dev.pci == b->dev.pci;                  return a->dev.pci == b->dev.pci;
153  #endif  #endif
154  #ifdef CONFIG_SBUS  #ifdef CONFIG_SBUS
# Line 336  int snd_dma_free_reserved(const struct s Line 331  int snd_dma_free_reserved(const struct s
331   * and replaced with the new one.   * and replaced with the new one.
332   *   *
333   * When NULL buffer pointer or zero buffer size is given, the existing   * When NULL buffer pointer or zero buffer size is given, the existing
334   * release buffer is released and the entry is removed.   * buffer is released and the entry is removed.
335   *   *
336   * Returns zero if successful, or a negative code at error.   * Returns zero if successful, or a negative code at error.
337   */   */
# Line 785  void snd_free_sbus_pages(struct sbus_dev Line 780  void snd_free_sbus_pages(struct sbus_dev
780  #endif /* CONFIG_SBUS */  #endif /* CONFIG_SBUS */
781    
782    
 #ifdef ENABLE_PREALLOC  
783  /*  /*
784   * allocation of buffers for pre-defined devices   * allocation of buffers for pre-defined devices
785   */   */
# Line 823  static struct prealloc_dev prealloc_devi Line 817  static struct prealloc_dev prealloc_devi
817    
818  static void __init preallocate_cards(void)  static void __init preallocate_cards(void)
819  {  {
820          struct pci_dev *pci;          struct pci_dev *pci = NULL;
821          int card;          int card;
822    
823          card = 0;          card = 0;
824    
825          pci_for_each_dev(pci) {          while ((pci = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci)) != NULL) {
826                  struct prealloc_dev *dev;                  struct prealloc_dev *dev;
827                  if (card >= SNDRV_CARDS)                  if (card >= SNDRV_CARDS)
828                          break;                          break;
# Line 861  static void __init preallocate_cards(voi Line 855  static void __init preallocate_cards(voi
855                  }                  }
856          }          }
857  }  }
 #endif  
858    
859    
860  #ifdef CONFIG_PROC_FS  #ifdef CONFIG_PROC_FS
# Line 873  static int snd_mem_proc_read(char *page, Line 866  static int snd_mem_proc_read(char *page,
866  {  {
867          int len = 0;          int len = 0;
868          long pages = snd_allocated_pages >> (PAGE_SHIFT-12);          long pages = snd_allocated_pages >> (PAGE_SHIFT-12);
869            struct list_head *p;
870            struct snd_mem_list *mem;
871            int devno;
872    
873            down(&list_mutex);
874          len += sprintf(page + len, "pages  : %li bytes (%li pages per %likB)\n",          len += sprintf(page + len, "pages  : %li bytes (%li pages per %likB)\n",
875                         pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);                         pages * PAGE_SIZE, pages, PAGE_SIZE / 1024);
876            devno = 0;
877            list_for_each(p, &mem_list_head) {
878                    mem = list_entry(p, struct snd_mem_list, list);
879                    devno++;
880                    len += sprintf(page + len, "buffer %d : ", devno);
881                    if (mem->dev.id == SNDRV_DMA_DEVICE_UNUSED)
882                            len += sprintf(page + len, "UNUSED");
883                    else
884                            len += sprintf(page + len, "ID %08x", mem->dev.id);
885                    len += sprintf(page + len, " : type ");
886                    switch (mem->dev.type) {
887                    case SNDRV_DMA_TYPE_CONTINUOUS:
888                            len += sprintf(page + len, "CONT [%x]", mem->dev.dev.flags);
889                            break;
890    #ifdef CONFIG_PCI
891                    case SNDRV_DMA_TYPE_PCI:
892                    case SNDRV_DMA_TYPE_PCI_SG:
893                            if (mem->dev.dev.pci) {
894                                    len += sprintf(page + len, "PCI [%04x:%04x]",
895                                                   mem->dev.dev.pci->vendor,
896                                                   mem->dev.dev.pci->device);
897                            }
898                            break;
899    #endif
900    #ifdef CONFIG_ISA
901                    case SNDRV_DMA_TYPE_ISA:
902                            len += sprintf(page + len, "ISA [%x]", mem->dev.dev.flags);
903                            break;
904    #endif
905    #ifdef CONFIG_SBUS
906                    case SNDRV_DMA_TYPE_SBUS:
907                            len += sprintf(page + len, "SBUS [%x]", mem->dev.dev.sbus->slot);
908                            break;
909    #endif
910                    default:
911                            len += sprintf(page + len, "UNKNOWN");
912                            break;
913                    }
914                    len += sprintf(page + len, "\n  addr = 0x%lx, size = %d bytes, used = %s\n",
915                                   (unsigned long)mem->buffer.addr, (int)mem->buffer.bytes,
916                                   mem->used ? "yes" : "no");
917            }
918            up(&list_mutex);
919          return len;          return len;
920  }  }
921  #endif /* CONFIG_PROC_FS */  #endif /* CONFIG_PROC_FS */
# Line 886  static int snd_mem_proc_read(char *page, Line 926  static int snd_mem_proc_read(char *page,
926    
927  static int __init snd_mem_init(void)  static int __init snd_mem_init(void)
928  {  {
929    #ifdef CONFIG_PROC_FS
930          create_proc_read_entry("driver/snd-page-alloc", 0, 0, snd_mem_proc_read, NULL);          create_proc_read_entry("driver/snd-page-alloc", 0, 0, snd_mem_proc_read, NULL);
 #ifdef ENABLE_PREALLOC  
         preallocate_cards();  
931  #endif  #endif
932            preallocate_cards();
933          return 0;          return 0;
934  }  }
935    
# Line 906  module_init(snd_mem_init) Line 946  module_init(snd_mem_init)
946  module_exit(snd_mem_exit)  module_exit(snd_mem_exit)
947    
948    
949    #ifndef MODULE
950    
951    /* format is: snd-page-alloc=enable */
952    
953    static int __init snd_mem_setup(char *str)
954    {
955            static unsigned __initdata nr_dev = 0;
956    
957            if (nr_dev >= SNDRV_CARDS)
958                    return 0;
959            (void)(get_option(&str,&enable[nr_dev]) == 2);
960            nr_dev++;
961            return 1;
962    }
963    
964    __setup("snd-page-alloc=", snd_mem_setup);
965    
966    #endif
967    
968  /*  /*
969   * exports   * exports
970   */   */

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26