2 Support for Intel Camera Imaging ISP subsystem.
3 Copyright (c) 2010 - 2015, Intel Corporation.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms and conditions of the GNU General Public License,
7 version 2, as published by the Free Software Foundation.
9 This program is distributed in the hope it will be useful, but WITHOUT
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 #include "memory_realloc.h"
15 #include "ia_css_debug.h"
16 #include "ia_css_refcount.h"
17 #include "memory_access.h"
19 static bool realloc_isp_css_mm_buf(
20 hrt_vaddress
*curr_buf
,
25 uint16_t mmgr_attribute
);
28 bool reallocate_buffer(
29 hrt_vaddress
*curr_buf
,
36 uint16_t mmgr_attribute
= MMGR_ATTRIBUTE_DEFAULT
;
38 IA_CSS_ENTER_PRIVATE("void");
40 ret
= realloc_isp_css_mm_buf(curr_buf
,
41 curr_size
, needed_size
, force
, err
, mmgr_attribute
);
43 IA_CSS_LEAVE_PRIVATE("ret=%d", ret
);
47 static bool realloc_isp_css_mm_buf(
48 hrt_vaddress
*curr_buf
,
53 uint16_t mmgr_attribute
)
57 *err
= IA_CSS_SUCCESS
;
58 /* Possible optimization: add a function sh_css_isp_css_mm_realloc()
59 * and implement on top of hmm. */
61 IA_CSS_ENTER_PRIVATE("void");
63 if (ia_css_refcount_is_single(*curr_buf
) && !force
&& *curr_size
>= needed_size
) {
64 IA_CSS_LEAVE_PRIVATE("false");
68 id
= IA_CSS_REFCOUNT_PARAM_BUFFER
;
69 ia_css_refcount_decrement(id
, *curr_buf
);
70 *curr_buf
= ia_css_refcount_increment(id
, mmgr_alloc_attr(needed_size
,
74 *err
= IA_CSS_ERR_CANNOT_ALLOCATE_MEMORY
;
77 *curr_size
= needed_size
;
79 IA_CSS_LEAVE_PRIVATE("true");