ctvmem.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  3. *
  4. * This source file is released under GPL v2 license (no other versions).
  5. * See the COPYING file included in the main directory of this source
  6. * distribution for the license terms and conditions.
  7. *
  8. * @File ctvmem.h
  9. *
  10. * @Brief
  11. * This file contains the definition of virtual memory management object
  12. * for card device.
  13. *
  14. * @Author Liu Chun
  15. * @Date Mar 28 2008
  16. */
  17. #ifndef CTVMEM_H
  18. #define CTVMEM_H
  19. #define CT_PTP_NUM 1 /* num of device page table pages */
  20. #include <linux/mutex.h>
  21. #include <linux/list.h>
  22. /* The chip can handle the page table of 4k pages
  23. * (emu20k1 can handle even 8k pages, but we don't use it right now)
  24. */
  25. #define CT_PAGE_SIZE 4096
  26. #define CT_PAGE_SHIFT 12
  27. #define CT_PAGE_MASK (~(PAGE_SIZE - 1))
  28. #define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)
  29. struct ct_vm_block {
  30. unsigned int addr; /* starting logical addr of this block */
  31. unsigned int size; /* size of this device virtual mem block */
  32. struct list_head list;
  33. };
  34. struct snd_pcm_substream;
  35. /* Virtual memory management object for card device */
  36. struct ct_vm {
  37. void *ptp[CT_PTP_NUM]; /* Device page table pages */
  38. unsigned int size; /* Available addr space in bytes */
  39. struct list_head unused; /* List of unused blocks */
  40. struct list_head used; /* List of used blocks */
  41. struct mutex lock;
  42. /* Map host addr (kmalloced/vmalloced) to device logical addr. */
  43. struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *,
  44. int size);
  45. /* Unmap device logical addr area. */
  46. void (*unmap)(struct ct_vm *, struct ct_vm_block *block);
  47. void *(*get_ptp_virt)(struct ct_vm *vm, int index);
  48. };
  49. int ct_vm_create(struct ct_vm **rvm);
  50. void ct_vm_destroy(struct ct_vm *vm);
  51. #endif /* CTVMEM_H */