1 #ifndef CAMERA_SYSRAM_IMP_H
2 #define CAMERA_SYSRAM_IMP_H
3 //-----------------------------------------------------------------------------
4 typedef unsigned long long MUINT64
;
5 typedef long long MINT64
;
6 typedef unsigned long MUINT32
;
8 typedef unsigned char MUINT8
;
13 //-----------------------------------------------------------------------------
14 #define LOG_TAG "SYSRAM"
15 #define LOG_MSG(fmt, arg...) xlog_printk(ANDROID_LOG_VERBOSE, LOG_TAG, "[%s]" fmt "\r\n", __FUNCTION__, ##arg)
16 #define LOG_WRN(fmt, arg...) xlog_printk(ANDROID_LOG_VERBOSE, LOG_TAG, "[%s]WRN(%5d):" fmt "\r\n", __FUNCTION__, __LINE__, ##arg)
17 #define LOG_ERR(fmt, arg...) xlog_printk(ANDROID_LOG_ERROR, LOG_TAG, "[%s]ERR(%5d):" fmt "\r\n", __FUNCTION__, __LINE__, ##arg)
18 #define LOG_DMP(fmt, arg...) xlog_printk(ANDROID_LOG_ERROR, LOG_TAG, "" fmt, ##arg)
19 //-----------------------------------------------------------------------------
20 #define SYSRAM_DEBUG_DEFAULT (0xFFFFFFFF)
21 #define SYSRAM_JIFFIES_MAX (0xFFFFFFFF)
22 #define SYSRAM_PROC_NAME "Default"
23 //-----------------------------------------------------------------------------
24 #define SYSRAM_BASE_PHY_ADDR ((SYSRAM_BASE&0x0FFFFFFF)|0x10000000)
25 #define SYSRAM_BASE_SIZE (81920) //32K+48K
26 #define SYSRAM_BASE_ADDR_BANK_0 (SYSRAM_BASE_PHY_ADDR)
27 #define SYSRAM_BASE_SIZE_BANK_0 (SYSRAM_BASE_SIZE)
29 #define SYSRAM_USER_SIZE_VIDO (SYSRAM_BASE_SIZE)//(78408)//(74496) // Always allocate max SYSRAM size because there is no other user. //78408: Max size used when format is RGB565.
30 #define SYSRAM_USER_SIZE_GDMA (46080)
31 #define SYSRAM_USER_SIZE_SW_FD (0) //TBD
33 #define SYSRAM_MEM_NODE_AMOUNT_PER_POOL (SYSRAM_USER_AMOUNT*2 + 2)
34 //-----------------------------------------------------------------------------
37 pid_t pid
; // thread id
38 pid_t tgid
; // process id
39 char ProcName
[TASK_COMM_LEN
]; // executable name
48 MUINT32 TotalUserCount
;
50 MUINT32 AllocatedSize
[SYSRAM_USER_AMOUNT
];
51 SYSRAM_USER_STRUCT UserInfo
[SYSRAM_USER_AMOUNT
];
52 wait_queue_head_t WaitQueueHead
;
56 struct cdev
* pCharDrv
;
64 char ProcName
[TASK_COMM_LEN
];
75 SYSRAM_MEM_BANK_AMOUNT
,
77 }SYSRAM_MEM_BANK_ENUM
;
79 typedef struct SYSRAM_MEM_NODE
81 SYSRAM_USER_ENUM User
;
85 struct SYSRAM_MEM_NODE
* pNext
;
86 struct SYSRAM_MEM_NODE
* pPrev
;
87 }SYSRAM_MEM_NODE_STRUCT
;
91 SYSRAM_MEM_NODE_STRUCT
* const pMemNode
;
92 MUINT32
const UserAmount
;
97 }SYSRAM_MEM_POOL_STRUCT
;
98 //------------------------------------------------------------------------------
99 static SYSRAM_MEM_NODE_STRUCT SysramMemNodeBank0Tbl
[SYSRAM_MEM_NODE_AMOUNT_PER_POOL
];
100 static SYSRAM_MEM_POOL_STRUCT SysramMemPoolInfo
[SYSRAM_MEM_BANK_AMOUNT
] =
102 [SYSRAM_MEM_BANK_0
] =
104 .pMemNode
= &SysramMemNodeBank0Tbl
[0],
105 .UserAmount
= SYSRAM_MEM_NODE_AMOUNT_PER_POOL
,
106 .Addr
= SYSRAM_BASE_ADDR_BANK_0
,
107 .Size
= SYSRAM_BASE_SIZE_BANK_0
,
113 static inline SYSRAM_MEM_POOL_STRUCT
* SYSRAM_GetMemPoolInfo(SYSRAM_MEM_BANK_ENUM
const MemBankNo
)
115 if(SYSRAM_MEM_BANK_AMOUNT
> MemBankNo
)
117 return &SysramMemPoolInfo
[MemBankNo
];
124 SysramMemBank0UserMask
=
125 (1<<SYSRAM_USER_VIDO
)
126 |(1<<SYSRAM_USER_GDMA
)
127 |(1<<SYSRAM_USER_SW_FD
)
130 (1<<SYSRAM_USER_VIDO
)
131 |(1<<SYSRAM_USER_GDMA
)
132 |(1<<SYSRAM_USER_SW_FD
)
135 static SYSRAM_MEM_BANK_ENUM
SYSRAM_GetMemBankNo(SYSRAM_USER_ENUM
const User
)
137 MUINT32
const UserMask
= (1<<User
);
139 if(UserMask
& SysramMemBank0UserMask
)
141 return SYSRAM_MEM_BANK_0
;
144 return SYSRAM_MEM_BANK_BAD
;
147 static char const*const SysramUserName
[SYSRAM_USER_AMOUNT
] =
149 [SYSRAM_USER_VIDO
] = "VIDO",
150 [SYSRAM_USER_GDMA
] = "GDMA",
151 [SYSRAM_USER_SW_FD
] = "SW FD"
154 static MUINT32
const SysramUserSize
[SYSRAM_USER_AMOUNT
] =
156 [SYSRAM_USER_VIDO
] = (3 + SYSRAM_USER_SIZE_VIDO
) / 4 * 4,
157 [SYSRAM_USER_GDMA
] = (3 + SYSRAM_USER_SIZE_GDMA
) / 4 * 4,
158 [SYSRAM_USER_SW_FD
] = (3 + SYSRAM_USER_SIZE_SW_FD
) / 4 * 4
160 //------------------------------------------------------------------------------