Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
0004  *
0005  * @File    ctvmem.h
0006  *
0007  * @Brief
0008  * This file contains the definition of virtual memory management object
0009  * for card device.
0010  *
0011  * @Author Liu Chun
0012  * @Date Mar 28 2008
0013  */
0014 
0015 #ifndef CTVMEM_H
0016 #define CTVMEM_H
0017 
0018 #define CT_PTP_NUM  4   /* num of device page table pages */
0019 
0020 #include <linux/mutex.h>
0021 #include <linux/list.h>
0022 #include <linux/pci.h>
0023 #include <sound/memalloc.h>
0024 
0025 /* The chip can handle the page table of 4k pages
0026  * (emu20k1 can handle even 8k pages, but we don't use it right now)
0027  */
0028 #define CT_PAGE_SIZE    4096
0029 #define CT_PAGE_SHIFT   12
0030 #define CT_PAGE_MASK    (~(PAGE_SIZE - 1))
0031 #define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)
0032 
0033 struct ct_vm_block {
0034     unsigned int addr;  /* starting logical addr of this block */
0035     unsigned int size;  /* size of this device virtual mem block */
0036     struct list_head list;
0037 };
0038 
0039 struct snd_pcm_substream;
0040 
0041 /* Virtual memory management object for card device */
0042 struct ct_vm {
0043     struct snd_dma_buffer ptp[CT_PTP_NUM];  /* Device page table pages */
0044     unsigned int size;      /* Available addr space in bytes */
0045     struct list_head unused;    /* List of unused blocks */
0046     struct list_head used;      /* List of used blocks */
0047     struct mutex lock;
0048 
0049     /* Map host addr (kmalloced/vmalloced) to device logical addr. */
0050     struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *,
0051                    int size);
0052     /* Unmap device logical addr area. */
0053     void (*unmap)(struct ct_vm *, struct ct_vm_block *block);
0054     dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index);
0055 };
0056 
0057 int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci);
0058 void ct_vm_destroy(struct ct_vm *vm);
0059 
0060 #endif /* CTVMEM_H */