Naveen Ramaraj | 51f5e8b | 2012-04-09 15:58:40 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef _ARCH_ARM_MACH_MSM_OCMEM_H |
| 14 | #define _ARCH_ARM_MACH_MSM_OCMEM_H |
| 15 | |
| 16 | #include <asm/page.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/notifier.h> |
| 19 | |
| 20 | #define OCMEM_MIN_ALLOC SZ_64K |
| 21 | #define OCMEM_MIN_ALIGN SZ_64K |
| 22 | |
| 23 | /* Maximum number of slots in DM */ |
| 24 | #define OCMEM_MAX_CHUNKS 32 |
| 25 | #define MIN_CHUNK_SIZE (SZ_1K/8) |
| 26 | |
| 27 | struct ocmem_buf { |
| 28 | unsigned long addr; |
| 29 | unsigned long len; |
| 30 | }; |
| 31 | |
| 32 | struct ocmem_buf_attr { |
| 33 | unsigned long paddr; |
| 34 | unsigned long len; |
| 35 | }; |
| 36 | |
| 37 | struct ocmem_chunk { |
| 38 | bool ro; |
| 39 | unsigned long ddr_paddr; |
| 40 | unsigned long size; |
| 41 | }; |
| 42 | |
| 43 | struct ocmem_map_list { |
| 44 | int num_chunks; |
| 45 | struct ocmem_chunk chunks[OCMEM_MAX_CHUNKS]; |
| 46 | }; |
| 47 | |
| 48 | /* List of clients that allocate/interact with OCMEM */ |
| 49 | /* Must be in sync with client_names */ |
| 50 | enum ocmem_client { |
| 51 | /* GMEM clients */ |
| 52 | OCMEM_GRAPHICS = 0x0, |
| 53 | /* TCMEM clients */ |
| 54 | OCMEM_VIDEO, |
| 55 | OCMEM_CAMERA, |
| 56 | /* Dummy Clients */ |
| 57 | OCMEM_HP_AUDIO, |
| 58 | OCMEM_VOICE, |
| 59 | /* IMEM Clients */ |
| 60 | OCMEM_LP_AUDIO, |
| 61 | OCMEM_SENSORS, |
| 62 | OCMEM_BLAST, |
| 63 | OCMEM_CLIENT_MAX, |
| 64 | }; |
| 65 | |
| 66 | /** |
| 67 | * List of OCMEM notification events which will be broadcasted |
| 68 | * to clients that optionally register for these notifications |
| 69 | * on a per allocation basis. |
| 70 | **/ |
| 71 | enum ocmem_notif_type { |
| 72 | OCMEM_MAP_DONE = 1, |
| 73 | OCMEM_MAP_FAIL, |
| 74 | OCMEM_UNMAP_DONE, |
| 75 | OCMEM_UNMAP_FAIL, |
| 76 | OCMEM_ALLOC_GROW, |
| 77 | OCMEM_ALLOC_SHRINK, |
| 78 | OCMEM_NOTIF_TYPE_COUNT, |
| 79 | }; |
| 80 | |
| 81 | /* APIS */ |
| 82 | /* Notification APIs */ |
| 83 | void *ocmem_notifier_register(int client_id, struct notifier_block *nb); |
| 84 | |
| 85 | int ocmem_notifier_unregister(void *notif_hndl, struct notifier_block *nb); |
| 86 | |
| 87 | /* Allocation APIs */ |
| 88 | struct ocmem_buf *ocmem_allocate(int client_id, unsigned long size); |
| 89 | |
| 90 | struct ocmem_buf *ocmem_allocate_nb(int client_id, unsigned long size); |
| 91 | |
| 92 | struct ocmem_buf *ocmem_allocate_range(int client_id, unsigned long min, |
| 93 | unsigned long goal, unsigned long step); |
| 94 | |
| 95 | /* Free APIs */ |
| 96 | int ocmem_free(int client_id, struct ocmem_buf *buf); |
| 97 | |
| 98 | /* Dynamic Resize APIs */ |
| 99 | int ocmem_shrink(int client_id, struct ocmem_buf *buf, |
| 100 | unsigned long new_size); |
| 101 | |
| 102 | int ocmem_expand(int client_id, struct ocmem_buf *buf, |
| 103 | unsigned long new_size); |
| 104 | |
| 105 | /* Priority Enforcement APIs */ |
| 106 | int ocmem_evict(int client_id); |
| 107 | |
| 108 | int ocmem_restore(int client_id); |
| 109 | #endif |