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

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

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

revision 1.2 by vizard, Sat May 31 02:35:09 2003 UTC revision 1.3 by vizard, Sun Jun 15 21:01:30 2003 UTC
# Line 93  int snd_pcm_info(snd_pcm_substream_t * s Line 93  int snd_pcm_info(snd_pcm_substream_t * s
93          info->device = pcm->device;          info->device = pcm->device;
94          info->stream = substream->stream;          info->stream = substream->stream;
95          info->subdevice = substream->number;          info->subdevice = substream->number;
96          strncpy(info->id, pcm->id, sizeof(info->id)-1);          strlcpy(info->id, pcm->id, sizeof(info->id));
97          strncpy(info->name, pcm->name, sizeof(info->name)-1);          strlcpy(info->name, pcm->name, sizeof(info->name));
98          info->dev_class = pcm->dev_class;          info->dev_class = pcm->dev_class;
99          info->dev_subclass = pcm->dev_subclass;          info->dev_subclass = pcm->dev_subclass;
100          info->subdevices_count = pstr->substream_count;          info->subdevices_count = pstr->substream_count;
101          info->subdevices_avail = pstr->substream_count - pstr->substream_opened;          info->subdevices_avail = pstr->substream_count - pstr->substream_opened;
102          strncpy(info->subname, substream->name, sizeof(info->subname)-1);          strlcpy(info->subname, substream->name, sizeof(info->subname));
103          runtime = substream->runtime;          runtime = substream->runtime;
104          /* AB: FIXME!!! This is definitely nonsense */          /* AB: FIXME!!! This is definitely nonsense */
105          if (runtime) {          if (runtime) {
# Line 1143  static void snd_pcm_change_state(snd_pcm Line 1143  static void snd_pcm_change_state(snd_pcm
1143                  snd_pcm_group_for_each(pos, substream) {                  snd_pcm_group_for_each(pos, substream) {
1144                          s = snd_pcm_group_substream_entry(pos);                          s = snd_pcm_group_substream_entry(pos);
1145                          if (s != substream)                          if (s != substream)
1146                                  spin_lock(&substream->self_group.lock);                                  spin_lock(&s->self_group.lock);
                 }  
                 snd_pcm_group_for_each(pos, substream) {  
                         s = snd_pcm_group_substream_entry(pos);  
1147                          s->runtime->status->state = state;                          s->runtime->status->state = state;
                 }  
                 snd_pcm_group_for_each(pos, substream) {  
                         s = snd_pcm_group_substream_entry(pos);  
1148                          if (s != substream)                          if (s != substream)
1149                                  spin_unlock(&substream->self_group.lock);                                  spin_unlock(&s->self_group.lock);
1150                  }                  }
1151                  spin_unlock(&substream->group->lock);                  spin_unlock(&substream->group->lock);
1152          } else {          } else {
# Line 1517  static int snd_pcm_unlink(snd_pcm_substr Line 1511  static int snd_pcm_unlink(snd_pcm_substr
1511          relink_to_local(substream);          relink_to_local(substream);
1512         _end:         _end:
1513          write_unlock_irq(&snd_pcm_link_rwlock);          write_unlock_irq(&snd_pcm_link_rwlock);
1514          return 0;          return res;
1515  }  }
1516    
1517  static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,  static int snd_pcm_hw_rule_mul(snd_pcm_hw_params_t *params,
# Line 2608  static ssize_t snd_pcm_write(struct file Line 2602  static ssize_t snd_pcm_write(struct file
2602          snd_pcm_runtime_t *runtime;          snd_pcm_runtime_t *runtime;
2603          snd_pcm_sframes_t result;          snd_pcm_sframes_t result;
2604    
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)  
         up(&file->f_dentry->d_inode->i_sem);  
 #endif  
2605          pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end);          pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end);
2606          substream = pcm_file->substream;          substream = pcm_file->substream;
2607          snd_assert(substream != NULL, result = -ENXIO; goto end);          snd_assert(substream != NULL, result = -ENXIO; goto end);
# Line 2628  static ssize_t snd_pcm_write(struct file Line 2619  static ssize_t snd_pcm_write(struct file
2619          if (result > 0)          if (result > 0)
2620                  result = frames_to_bytes(runtime, result);                  result = frames_to_bytes(runtime, result);
2621   end:   end:
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)  
         down(&file->f_dentry->d_inode->i_sem);  
 #endif  
2622          return result;          return result;
2623  }  }
2624    
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)  
2625  static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector,  static ssize_t snd_pcm_readv(struct file *file, const struct iovec *_vector,
2626                               unsigned long count, loff_t * offset)                               unsigned long count, loff_t * offset)
2627    
# Line 2681  static ssize_t snd_pcm_writev(struct fil Line 2668  static ssize_t snd_pcm_writev(struct fil
2668          void **bufs;          void **bufs;
2669          snd_pcm_uframes_t frames;          snd_pcm_uframes_t frames;
2670    
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)  
         up(&file->f_dentry->d_inode->i_sem);  
 #endif  
2671          pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end);          pcm_file = snd_magic_cast(snd_pcm_file_t, file->private_data, result = -ENXIO; goto end);
2672          substream = pcm_file->substream;          substream = pcm_file->substream;
2673          snd_assert(substream != NULL, result = -ENXIO; goto end);          snd_assert(substream != NULL, result = -ENXIO; goto end);
# Line 2708  static ssize_t snd_pcm_writev(struct fil Line 2692  static ssize_t snd_pcm_writev(struct fil
2692                  result = frames_to_bytes(runtime, result);                  result = frames_to_bytes(runtime, result);
2693          kfree(bufs);          kfree(bufs);
2694   end:   end:
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 3, 0)  
         down(&file->f_dentry->d_inode->i_sem);  
 #endif  
2695          return result;          return result;
2696  }  }
 #endif  
2697    
2698  unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait)  unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait)
2699  {  {
# Line 2795  unsigned int snd_pcm_capture_poll(struct Line 2775  unsigned int snd_pcm_capture_poll(struct
2775          return mask;          return mask;
2776  }  }
2777    
 #ifndef VM_RESERVED  
 #ifndef LINUX_2_2  
 static int snd_pcm_mmap_swapout(struct page * page, struct file * file)  
 #else  
 static int snd_pcm_mmap_swapout(struct vm_area_struct * area, struct page * page)  
 #endif  
 {  
         return 0;  
 }  
 #endif  
   
 #ifndef LINUX_2_2  
2778  static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  static struct page * snd_pcm_mmap_status_nopage(struct vm_area_struct *area, unsigned long address, int no_share)
 #else  
 static unsigned long snd_pcm_mmap_status_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  
 #endif  
2779  {  {
2780          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;
2781          snd_pcm_runtime_t *runtime;          snd_pcm_runtime_t *runtime;
# Line 2821  static unsigned long snd_pcm_mmap_status Line 2786  static unsigned long snd_pcm_mmap_status
2786          runtime = substream->runtime;          runtime = substream->runtime;
2787          page = virt_to_page(runtime->status);          page = virt_to_page(runtime->status);
2788          get_page(page);          get_page(page);
 #ifndef LINUX_2_2  
2789          return page;          return page;
 #else  
         return page_address(page);  
 #endif  
2790  }  }
2791    
2792  static struct vm_operations_struct snd_pcm_vm_ops_status =  static struct vm_operations_struct snd_pcm_vm_ops_status =
2793  {  {
2794          .nopage =       snd_pcm_mmap_status_nopage,          .nopage =       snd_pcm_mmap_status_nopage,
 #ifndef VM_RESERVED  
         .swapout =      snd_pcm_mmap_swapout,  
 #endif  
2795  };  };
2796    
2797  int snd_pcm_mmap_status(snd_pcm_substream_t *substream, struct file *file,  int snd_pcm_mmap_status(snd_pcm_substream_t *substream, struct file *file,
# Line 2849  int snd_pcm_mmap_status(snd_pcm_substrea Line 2807  int snd_pcm_mmap_status(snd_pcm_substrea
2807          if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t)))          if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_status_t)))
2808                  return -EINVAL;                  return -EINVAL;
2809          area->vm_ops = &snd_pcm_vm_ops_status;          area->vm_ops = &snd_pcm_vm_ops_status;
 #ifndef LINUX_2_2  
2810          area->vm_private_data = substream;          area->vm_private_data = substream;
 #else  
         area->vm_private_data = (long)substream;          
 #endif  
 #ifdef VM_RESERVED  
2811          area->vm_flags |= VM_RESERVED;          area->vm_flags |= VM_RESERVED;
 #endif  
2812          return 0;          return 0;
2813  }  }
2814    
 #ifndef LINUX_2_2  
2815  static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  static struct page * snd_pcm_mmap_control_nopage(struct vm_area_struct *area, unsigned long address, int no_share)
 #else  
 static unsigned long snd_pcm_mmap_control_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  
 #endif  
2816  {  {
2817          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;
2818          snd_pcm_runtime_t *runtime;          snd_pcm_runtime_t *runtime;
# Line 2875  static unsigned long snd_pcm_mmap_contro Line 2823  static unsigned long snd_pcm_mmap_contro
2823          runtime = substream->runtime;          runtime = substream->runtime;
2824          page = virt_to_page(runtime->control);          page = virt_to_page(runtime->control);
2825          get_page(page);          get_page(page);
 #ifndef LINUX_2_2  
2826          return page;          return page;
 #else  
         return page_address(page);  
 #endif  
2827  }  }
2828    
2829  static struct vm_operations_struct snd_pcm_vm_ops_control =  static struct vm_operations_struct snd_pcm_vm_ops_control =
2830  {  {
2831          .nopage =       snd_pcm_mmap_control_nopage,          .nopage =       snd_pcm_mmap_control_nopage,
 #ifndef VM_RESERVED  
         .swapout =      snd_pcm_mmap_swapout,  
 #endif  
2832  };  };
2833    
2834  static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *file,  static int snd_pcm_mmap_control(snd_pcm_substream_t *substream, struct file *file,
# Line 2903  static int snd_pcm_mmap_control(snd_pcm_ Line 2844  static int snd_pcm_mmap_control(snd_pcm_
2844          if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t)))          if (size != PAGE_ALIGN(sizeof(snd_pcm_mmap_control_t)))
2845                  return -EINVAL;                  return -EINVAL;
2846          area->vm_ops = &snd_pcm_vm_ops_control;          area->vm_ops = &snd_pcm_vm_ops_control;
 #ifndef LINUX_2_2  
2847          area->vm_private_data = substream;          area->vm_private_data = substream;
 #else  
         area->vm_private_data = (long)substream;          
 #endif  
 #ifdef VM_RESERVED  
2848          area->vm_flags |= VM_RESERVED;          area->vm_flags |= VM_RESERVED;
 #endif  
2849          return 0;          return 0;
2850  }  }
2851    
# Line 2926  static void snd_pcm_mmap_data_close(stru Line 2861  static void snd_pcm_mmap_data_close(stru
2861          atomic_dec(&substream->runtime->mmap_count);          atomic_dec(&substream->runtime->mmap_count);
2862  }  }
2863    
 #ifndef LINUX_2_2  
2864  static struct page * snd_pcm_mmap_data_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  static struct page * snd_pcm_mmap_data_nopage(struct vm_area_struct *area, unsigned long address, int no_share)
 #else  
 static unsigned long snd_pcm_mmap_data_nopage(struct vm_area_struct *area, unsigned long address, int no_share)  
 #endif  
2865  {  {
2866          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;          snd_pcm_substream_t *substream = (snd_pcm_substream_t *)area->vm_private_data;
2867          snd_pcm_runtime_t *runtime;          snd_pcm_runtime_t *runtime;
# Line 2942  static unsigned long snd_pcm_mmap_data_n Line 2873  static unsigned long snd_pcm_mmap_data_n
2873          if (substream == NULL)          if (substream == NULL)
2874                  return NOPAGE_OOM;                  return NOPAGE_OOM;
2875          runtime = substream->runtime;          runtime = substream->runtime;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)  
2876          offset = area->vm_pgoff << PAGE_SHIFT;          offset = area->vm_pgoff << PAGE_SHIFT;
 #else  
         offset = area->vm_offset;  
 #endif  
2877          offset += address - area->vm_start;          offset += address - area->vm_start;
2878          snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);          snd_assert((offset % PAGE_SIZE) == 0, return NOPAGE_OOM);
2879          dma_bytes = PAGE_ALIGN(runtime->dma_bytes);          dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
# Line 2961  static unsigned long snd_pcm_mmap_data_n Line 2888  static unsigned long snd_pcm_mmap_data_n
2888                  page = virt_to_page(vaddr);                  page = virt_to_page(vaddr);
2889          }          }
2890          get_page(page);          get_page(page);
 #ifndef LINUX_2_2  
2891          return page;          return page;
 #else  
         return page_address(page);  
 #endif  
2892  }  }
2893    
2894  static struct vm_operations_struct snd_pcm_vm_ops_data =  static struct vm_operations_struct snd_pcm_vm_ops_data =
# Line 2973  static struct vm_operations_struct snd_p Line 2896  static struct vm_operations_struct snd_p
2896          .open =         snd_pcm_mmap_data_open,          .open =         snd_pcm_mmap_data_open,
2897          .close =        snd_pcm_mmap_data_close,          .close =        snd_pcm_mmap_data_close,
2898          .nopage =       snd_pcm_mmap_data_nopage,          .nopage =       snd_pcm_mmap_data_nopage,
 #ifndef VM_RESERVED  
         .swapout =      snd_pcm_mmap_swapout,  
 #endif  
2899  };  };
2900    
2901  int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file,  int snd_pcm_mmap_data(snd_pcm_substream_t *substream, struct file *file,
# Line 3003  int snd_pcm_mmap_data(snd_pcm_substream_ Line 2923  int snd_pcm_mmap_data(snd_pcm_substream_
2923              runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)              runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED)
2924                  return -EINVAL;                  return -EINVAL;
2925          size = area->vm_end - area->vm_start;          size = area->vm_end - area->vm_start;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)  
2926          offset = area->vm_pgoff << PAGE_SHIFT;          offset = area->vm_pgoff << PAGE_SHIFT;
 #else  
         offset = area->vm_offset;  
 #endif  
2927          dma_bytes = PAGE_ALIGN(runtime->dma_bytes);          dma_bytes = PAGE_ALIGN(runtime->dma_bytes);
2928          if ((size_t)size > dma_bytes)          if ((size_t)size > dma_bytes)
2929                  return -EINVAL;                  return -EINVAL;
# Line 3015  int snd_pcm_mmap_data(snd_pcm_substream_ Line 2931  int snd_pcm_mmap_data(snd_pcm_substream_
2931                  return -EINVAL;                  return -EINVAL;
2932    
2933          area->vm_ops = &snd_pcm_vm_ops_data;          area->vm_ops = &snd_pcm_vm_ops_data;
 #ifndef LINUX_2_2  
2934          area->vm_private_data = substream;          area->vm_private_data = substream;
 #else  
         area->vm_private_data = (long)substream;  
 #endif  
 #ifdef VM_RESERVED  
2935          area->vm_flags |= VM_RESERVED;          area->vm_flags |= VM_RESERVED;
 #endif  
2936          atomic_inc(&runtime->mmap_count);          atomic_inc(&runtime->mmap_count);
2937          return 0;          return 0;
2938  }  }
# Line 3037  static int snd_pcm_mmap(struct file *fil Line 2947  static int snd_pcm_mmap(struct file *fil
2947          substream = pcm_file->substream;          substream = pcm_file->substream;
2948          snd_assert(substream != NULL, return -ENXIO);          snd_assert(substream != NULL, return -ENXIO);
2949    
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 25)  
2950          offset = area->vm_pgoff << PAGE_SHIFT;          offset = area->vm_pgoff << PAGE_SHIFT;
 #else  
         offset = area->vm_offset;  
 #endif  
2951          switch (offset) {          switch (offset) {
2952          case SNDRV_PCM_MMAP_OFFSET_STATUS:          case SNDRV_PCM_MMAP_OFFSET_STATUS:
2953                  return snd_pcm_mmap_status(substream, file, area);                  return snd_pcm_mmap_status(substream, file, area);
# Line 3149  static int snd_pcm_hw_params_old_user(sn Line 3055  static int snd_pcm_hw_params_old_user(sn
3055   */   */
3056    
3057  static struct file_operations snd_pcm_f_ops_playback = {  static struct file_operations snd_pcm_f_ops_playback = {
 #ifndef LINUX_2_2  
3058          .owner =        THIS_MODULE,          .owner =        THIS_MODULE,
 #endif  
3059          .write =        snd_pcm_write,          .write =        snd_pcm_write,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)  
3060          .writev =       snd_pcm_writev,          .writev =       snd_pcm_writev,
 #endif  
3061          .open =         snd_pcm_open,          .open =         snd_pcm_open,
3062          .release =      snd_pcm_release,          .release =      snd_pcm_release,
3063          .poll =         snd_pcm_playback_poll,          .poll =         snd_pcm_playback_poll,
# Line 3165  static struct file_operations snd_pcm_f_ Line 3067  static struct file_operations snd_pcm_f_
3067  };  };
3068    
3069  static struct file_operations snd_pcm_f_ops_capture = {  static struct file_operations snd_pcm_f_ops_capture = {
 #ifndef LINUX_2_2  
3070          .owner =        THIS_MODULE,          .owner =        THIS_MODULE,
 #endif  
3071          .read =         snd_pcm_read,          .read =         snd_pcm_read,
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 3, 44)  
3072          .readv =        snd_pcm_readv,          .readv =        snd_pcm_readv,
 #endif  
3073          .open =         snd_pcm_open,          .open =         snd_pcm_open,
3074          .release =      snd_pcm_release,          .release =      snd_pcm_release,
3075          .poll =         snd_pcm_capture_poll,          .poll =         snd_pcm_capture_poll,

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

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