brintos

brintos / linux-shallow public Read only

0
0
Text · 1.7 KiB · da54cbc Raw
61 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.4 *5 * @File    ctvmem.h6 *7 * @Brief8 * This file contains the definition of virtual memory management object9 * for card device.10 *11 * @Author Liu Chun12 * @Date Mar 28 200813 */14 15#ifndef CTVMEM_H16#define CTVMEM_H17 18#define CT_PTP_NUM	4	/* num of device page table pages */19 20#include <linux/mutex.h>21#include <linux/list.h>22#include <linux/pci.h>23#include <sound/memalloc.h>24 25/* The chip can handle the page table of 4k pages26 * (emu20k1 can handle even 8k pages, but we don't use it right now)27 */28#define CT_PAGE_SIZE	409629#define CT_PAGE_SHIFT	1230#define CT_PAGE_MASK	(~(PAGE_SIZE - 1))31#define CT_PAGE_ALIGN(addr)	ALIGN(addr, CT_PAGE_SIZE)32 33struct ct_vm_block {34	unsigned int addr;	/* starting logical addr of this block */35	unsigned int size;	/* size of this device virtual mem block */36	struct list_head list;37};38 39struct snd_pcm_substream;40 41/* Virtual memory management object for card device */42struct ct_vm {43	struct snd_dma_buffer ptp[CT_PTP_NUM];	/* Device page table pages */44	unsigned int size;		/* Available addr space in bytes */45	struct list_head unused;	/* List of unused blocks */46	struct list_head used;		/* List of used blocks */47	struct mutex lock;48 49	/* Map host addr (kmalloced/vmalloced) to device logical addr. */50	struct ct_vm_block *(*map)(struct ct_vm *, struct snd_pcm_substream *,51				   int size);52	/* Unmap device logical addr area. */53	void (*unmap)(struct ct_vm *, struct ct_vm_block *block);54	dma_addr_t (*get_ptp_phys)(struct ct_vm *vm, int index);55};56 57int ct_vm_create(struct ct_vm **rvm, struct pci_dev *pci);58void ct_vm_destroy(struct ct_vm *vm);59 60#endif /* CTVMEM_H */61