/**1* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.2*3* This source file is released under GPL v2 license (no other versions).4* See the COPYING file included in the main directory of this source5* distribution for the license terms and conditions.6*7* @File ctvmem.h8*9* @Brief10* This file contains the definition of virtual memory management object11* for card device.12*13* @Author Liu Chun14* @Date Mar 28 200815*/1617#ifndef CTVMEM_H18#define CTVMEM_H1920#define CT_PTP_NUM 1 /* num of device page table pages */2122#include <linux/mutex.h>23#include <linux/list.h>24#include <linux/pci.h>25#include <sound/memalloc.h>2627/* The chip can handle the page table of 4k pages28* (emu20k1 can handle even 8k pages, but we don't use it right now)29*/30#define CT_PAGE_SIZE 409631#define CT_PAGE_SHIFT 1232#define CT_PAGE_MASK (~(PAGE_SIZE - 1))33#define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)3435struct ct_vm_block {36unsigned int addr; /* starting logical addr of this block */37unsigned int size; /* size of this device virtual mem block */38struct list_head list;39};4041struct snd_pcm_substream;4243/* Virtual memory management object for card device */44struct ct_vm {45struct snd_dma_buffer ptp[CT_PTP_NUM]; /* Device page table pages */46unsigned int size; /* Available addr space in bytes */47struct list_head unused; /* List of unused blocks */48struct list_head used; /* List of used blocks */49struct mutex lock;5051/* Map host addr (kmalloced/vmalloced) to device logical addr. */52struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *,53int size);54/* Unmap device logical addr area. */55void (*unmap)(struct ct_vm *, struct ct_vm_block *block);56dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index);57};5859int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci);60void ct_vm_destroy(struct ct_vm *vm);6162#endif /* CTVMEM_H */636465