/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.3*4* @File ctvmem.h5*6* @Brief7* This file contains the definition of virtual memory management object8* for card device.9*10* @Author Liu Chun11* @Date Mar 28 200812*/1314#ifndef CTVMEM_H15#define CTVMEM_H1617#define CT_PTP_NUM 4 /* num of device page table pages */1819#include <linux/mutex.h>20#include <linux/list.h>21#include <linux/pci.h>22#include <sound/memalloc.h>2324/* The chip can handle the page table of 4k pages25* (emu20k1 can handle even 8k pages, but we don't use it right now)26*/27#define CT_PAGE_SIZE 409628#define CT_PAGE_SHIFT 1229#define CT_PAGE_MASK (~(PAGE_SIZE - 1))30#define CT_PAGE_ALIGN(addr) ALIGN(addr, CT_PAGE_SIZE)3132struct ct_vm_block {33unsigned int addr; /* starting logical addr of this block */34unsigned int size; /* size of this device virtual mem block */35struct list_head list;36};3738struct snd_pcm_substream;3940/* Virtual memory management object for card device */41struct ct_vm {42struct snd_dma_buffer ptp[CT_PTP_NUM]; /* Device page table pages */43unsigned int size; /* Available addr space in bytes */44struct list_head unused; /* List of unused blocks */45struct list_head used; /* List of used blocks */46struct mutex lock;4748/* Map host addr (kmalloced/vmalloced) to device logical addr. */49struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *,50int size);51/* Unmap device logical addr area. */52void (*unmap)(struct ct_vm *, struct ct_vm_block *block);53dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index);54};5556int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci);57void ct_vm_destroy(struct ct_vm *vm);5859#endif /* CTVMEM_H */606162