| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This source file is released under GPL v2 license (no other versions). | 
					
						
							|  |  |  |  * See the COPYING file included in the main directory of this source | 
					
						
							|  |  |  |  * distribution for the license terms and conditions. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @File    ctvmem.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @Brief | 
					
						
							|  |  |  |  * This file contains the definition of virtual memory management object | 
					
						
							|  |  |  |  * for card device. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * @Author Liu Chun | 
					
						
							|  |  |  |  * @Date Mar 28 2008 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef CTVMEM_H
 | 
					
						
							|  |  |  | #define CTVMEM_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-08-24 00:48:59 +02:00
										 |  |  | #define CT_PTP_NUM	4	/* num of device page table pages */
 | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-02 08:40:51 +02:00
										 |  |  | #include <linux/mutex.h>
 | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | #include <linux/list.h>
 | 
					
						
							| 
									
										
										
										
											2010-02-02 19:58:25 +01:00
										 |  |  | #include <linux/pci.h>
 | 
					
						
							|  |  |  | #include <sound/memalloc.h>
 | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-02 15:04:29 +02:00
										 |  |  | /* The chip can handle the page table of 4k pages
 | 
					
						
							|  |  |  |  * (emu20k1 can handle even 8k pages, but we don't use it right now) | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #define CT_PAGE_SIZE	4096
 | 
					
						
							|  |  |  | #define CT_PAGE_SHIFT	12
 | 
					
						
							|  |  |  | #define CT_PAGE_MASK	(~(PAGE_SIZE - 1))
 | 
					
						
							|  |  |  | #define CT_PAGE_ALIGN(addr)	ALIGN(addr, CT_PAGE_SIZE)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | struct ct_vm_block { | 
					
						
							|  |  |  | 	unsigned int addr;	/* starting logical addr of this block */ | 
					
						
							|  |  |  | 	unsigned int size;	/* size of this device virtual mem block */ | 
					
						
							|  |  |  | 	struct list_head list; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-02 15:26:19 +02:00
										 |  |  | struct snd_pcm_substream; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | /* Virtual memory management object for card device */ | 
					
						
							|  |  |  | struct ct_vm { | 
					
						
							| 
									
										
										
										
											2010-02-02 19:58:25 +01:00
										 |  |  | 	struct snd_dma_buffer ptp[CT_PTP_NUM];	/* Device page table pages */ | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | 	unsigned int size;		/* Available addr space in bytes */ | 
					
						
							|  |  |  | 	struct list_head unused;	/* List of unused blocks */ | 
					
						
							|  |  |  | 	struct list_head used;		/* List of used blocks */ | 
					
						
							| 
									
										
										
										
											2009-06-02 08:40:51 +02:00
										 |  |  | 	struct mutex lock; | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Map host addr (kmalloced/vmalloced) to device logical addr. */ | 
					
						
							| 
									
										
										
										
											2009-06-02 15:26:19 +02:00
										 |  |  | 	struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *, | 
					
						
							|  |  |  | 				   int size); | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | 	/* Unmap device logical addr area. */ | 
					
						
							|  |  |  | 	void (*unmap)(struct ct_vm *, struct ct_vm_block *block); | 
					
						
							| 
									
										
										
										
											2010-02-02 19:58:25 +01:00
										 |  |  | 	dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index); | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-02-02 19:58:25 +01:00
										 |  |  | int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci); | 
					
						
							| 
									
										
										
										
											2009-05-14 08:05:58 +02:00
										 |  |  | void ct_vm_destroy(struct ct_vm *vm); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* CTVMEM_H */
 |