2 * Copyright Samsung Electronics Co.,LTD.
3 * Copyright (C) 2015 The Android Open Source Project
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __HWJPEG_INTERNAL_H__
19 #define __HWJPEG_INTERNAL_H__
22 #error "LOG_TAG is not defined!"
28 #include <cutils/log.h>
31 # define __UNUSED__ __attribute__((__unused__))
37 #define ALOGERR(fmt, args...) ((void)ALOG(LOG_ERROR, LOG_TAG, fmt " [%s]", ##args, strerror(errno)))
40 #define V4L2_CID_JPEG_SEC_COMP_QUALITY (V4L2_CID_JPEG_CLASS_BASE + 20)
41 #define V4L2_CID_JPEG_QTABLES2 (V4L2_CID_JPEG_CLASS_BASE + 22)
42 #define V4L2_CID_JPEG_HWFC_ENABLE (V4L2_CID_JPEG_CLASS_BASE + 25)
44 #define TO_MAIN_SIZE(val) ((val) & 0xFFFF)
45 #define TO_THUMB_SIZE(val) (((val) & 0xFFFF) << 16)
46 #define TO_IMAGE_SIZE(main, thumb) (TO_MAIN_SIZE(main) | TO_THUMB_SIZE(thumb))
48 #define PTR_TO_ULONG(ptr) reinterpret_cast<unsigned long>(ptr)
49 #define PTR_DIFF(ptr1, ptr2) (reinterpret_cast<size_t>(ptr2) - reinterpret_cast<size_t>(ptr1))
51 #define ARRSIZE(v) (sizeof(v) / sizeof(v[0]))
55 static inline T
min(T val1
, T val2
) {
56 return (val1
> val2
) ? val2
: val1
;
62 static inline T
max(T val1
, T val2
) {
63 return (val1
< val2
) ? val2
: val1
;
67 // H/W requires 16-byte alignment
68 #define HW_BASE_ALIGN_BITS 4
69 #define HW_BASE_ALIGN_SIZE (1 << HW_BASE_ALIGN_BITS)
70 #define HW_BASE_ALIGN_MASK ~(HW_BASE_ALIGN_SIZE - 1)
75 CStopWatch(bool start
= false) {
80 unsigned long GetElapsed();
81 unsigned long GetElapsedUpdate();
84 bool WriteToFile(const char *path
, const char *data
, size_t len
);
85 bool WriteToFile(const char *path
, int dmabuf
, size_t len
);
86 #endif //__HWJPEG_INTERNAL_H__