2 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
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.
11 * This file contains the definition of virtual memory management object
21 #define CT_PTP_NUM 4 /* num of device page table pages */
23 #include <linux/mutex.h>
24 #include <linux/list.h>
25 #include <linux/pci.h>
26 #include <sound/memalloc.h>
28 /* The chip can handle the page table of 4k pages
29 * (emu20k1 can handle even 8k pages, but we don't use it right now)
31 #define CT_PAGE_SIZE 4096
32 #define CT_PAGE_SHIFT 12
33 #define CT_PAGE_MASK (~(PAGE_SIZE - 1))
34 #define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)
37 unsigned int addr
; /* starting logical addr of this block */
38 unsigned int size
; /* size of this device virtual mem block */
39 struct list_head list
;
42 struct snd_pcm_substream
;
44 /* Virtual memory management object for card device */
46 struct snd_dma_buffer ptp
[CT_PTP_NUM
]; /* Device page table pages */
47 unsigned int size
; /* Available addr space in bytes */
48 struct list_head unused
; /* List of unused blocks */
49 struct list_head used
; /* List of used blocks */
52 /* Map host addr (kmalloced/vmalloced) to device logical addr. */
53 struct ct_vm_block
*(*map
)(struct ct_vm
*, struct snd_pcm_substream
*,
55 /* Unmap device logical addr area. */
56 void (*unmap
)(struct ct_vm
*, struct ct_vm_block
*block
);
57 dma_addr_t (*get_ptp_phys
)(struct ct_vm
*vm
, int index
);
60 int ct_vm_create(struct ct_vm
**rvm
, struct pci_dev
*pci
);
61 void ct_vm_destroy(struct ct_vm
*vm
);