2 * Support for Medifield PNW Camera Imaging ISP subsystem.
4 * Copyright (c) 2010 Intel Corporation. All Rights Reserved.
6 * Copyright (c) 2010 Silicon Hive www.siliconhive.com.
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License version
10 * 2 as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #ifndef __HMM_BO_DEV_H__
25 #define __HMM_BO_DEV_H__
27 #include <linux/kernel.h>
28 #include <linux/slab.h>
29 #include <linux/list.h>
30 #include <linux/spinlock.h>
31 #include <linux/mutex.h>
32 #include "mmu/isp_mmu.h"
33 #include "hmm/hmm_common.h"
34 #include "hmm/hmm_vm.h"
35 #include "ia_css_types.h"
37 #define check_bodev_null_return(bdev, exp) \
38 check_null_return(bdev, exp, \
39 "NULL hmm_bo_device.\n")
41 #define check_bodev_null_return_void(bdev) \
42 check_null_return_void(bdev, \
43 "NULL hmm_bo_device.\n")
45 #define HMM_BO_DEVICE_INITED 0x1
47 #define HMM_BO_CACHE_SIZE 2
50 struct hmm_buffer_object;
52 struct hmm_bo_device {
53 /* isp_mmu provides lock itself */
56 /* hmm_vm provides lock itself */
57 struct hmm_vm vaddr_space;
59 struct list_head free_bo_list;
60 struct list_head active_bo_list;
62 /* list lock is used to protect both of the buffer object lists */
65 struct ion_client *iclient;
70 int hmm_bo_device_init(struct hmm_bo_device *bdev,
71 struct isp_mmu_client *mmu_driver,
72 unsigned int vaddr_start, unsigned int size);
75 * clean up all hmm_bo_device related things.
77 void hmm_bo_device_exit(struct hmm_bo_device *bdev);
80 * whether the bo device is inited or not.
82 int hmm_bo_device_inited(struct hmm_bo_device *bdev);
85 * find the buffer object with virtual address vaddr.
86 * return NULL if no such buffer object found.
88 struct hmm_buffer_object *hmm_bo_device_search_start(
89 struct hmm_bo_device *bdev, ia_css_ptr vaddr);
92 * find the buffer object with virtual address vaddr.
93 * return NULL if no such buffer object found.
95 struct hmm_buffer_object *hmm_bo_device_search_in_range(
96 struct hmm_bo_device *bdev, ia_css_ptr vaddr);
99 * find the buffer object with kernel virtual address vaddr.
100 * return NULL if no such buffer object found.
102 struct hmm_buffer_object *hmm_bo_device_search_vmap_start(
103 struct hmm_bo_device *bdev, const void *vaddr);
106 * find a buffer object with pgnr pages from free_bo_list and
107 * activate it (remove from free_bo_list and add to
110 * return NULL if no such buffer object found.
112 struct hmm_buffer_object *hmm_bo_device_get_bo(
113 struct hmm_bo_device *bdev, unsigned int pgnr);
116 * destroy all buffer objects in the free_bo_list.
118 void hmm_bo_device_destroy_free_bo_list(struct hmm_bo_device *bdev);
120 * destroy buffer object with start virtual address vaddr.
122 void hmm_bo_device_destroy_free_bo_addr(struct hmm_bo_device *bdev,
125 * destroy all buffer objects with pgnr pages.
127 void hmm_bo_device_destroy_free_bo_size(struct hmm_bo_device *bdev,