18a94683196406b83b14218d1beef66067f126a16keunyoung/*
28a94683196406b83b14218d1beef66067f126a16keunyoung * Copyright (C) 2011 The Android Open Source Project
38a94683196406b83b14218d1beef66067f126a16keunyoung *
48a94683196406b83b14218d1beef66067f126a16keunyoung * Licensed under the Apache License, Version 2.0 (the "License");
58a94683196406b83b14218d1beef66067f126a16keunyoung * you may not use this file except in compliance with the License.
68a94683196406b83b14218d1beef66067f126a16keunyoung * You may obtain a copy of the License at
78a94683196406b83b14218d1beef66067f126a16keunyoung *
88a94683196406b83b14218d1beef66067f126a16keunyoung *      http://www.apache.org/licenses/LICENSE-2.0
98a94683196406b83b14218d1beef66067f126a16keunyoung *
108a94683196406b83b14218d1beef66067f126a16keunyoung * Unless required by applicable law or agreed to in writing, software
118a94683196406b83b14218d1beef66067f126a16keunyoung * distributed under the License is distributed on an "AS IS" BASIS,
128a94683196406b83b14218d1beef66067f126a16keunyoung * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138a94683196406b83b14218d1beef66067f126a16keunyoung * See the License for the specific language governing permissions and
148a94683196406b83b14218d1beef66067f126a16keunyoung * limitations under the License.
158a94683196406b83b14218d1beef66067f126a16keunyoung */
168a94683196406b83b14218d1beef66067f126a16keunyoung
178a94683196406b83b14218d1beef66067f126a16keunyoung#ifndef HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H
188a94683196406b83b14218d1beef66067f126a16keunyoung#define HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H
198a94683196406b83b14218d1beef66067f126a16keunyoung
208a94683196406b83b14218d1beef66067f126a16keunyoung/*
218a94683196406b83b14218d1beef66067f126a16keunyoung * Contains common declarations that are used across the camera emulation.
228a94683196406b83b14218d1beef66067f126a16keunyoung */
238a94683196406b83b14218d1beef66067f126a16keunyoung
248a94683196406b83b14218d1beef66067f126a16keunyoung#include <linux/videodev2.h>
258a94683196406b83b14218d1beef66067f126a16keunyoung#include <hardware/camera.h>
268a94683196406b83b14218d1beef66067f126a16keunyoung
278a94683196406b83b14218d1beef66067f126a16keunyoung/* A helper class that tracks a routine execution.
288a94683196406b83b14218d1beef66067f126a16keunyoung * Basically, it dumps an enry message in its constructor, and an exit message
298a94683196406b83b14218d1beef66067f126a16keunyoung * in its destructor. Use LOGRE() macro (declared bellow) to create instances
308a94683196406b83b14218d1beef66067f126a16keunyoung * of this class at the beginning of the tracked routines / methods.
318a94683196406b83b14218d1beef66067f126a16keunyoung */
328a94683196406b83b14218d1beef66067f126a16keunyoungclass HWERoutineTracker {
338a94683196406b83b14218d1beef66067f126a16keunyoungpublic:
348a94683196406b83b14218d1beef66067f126a16keunyoung    /* Constructor that prints an "entry" trace message. */
358a94683196406b83b14218d1beef66067f126a16keunyoung    explicit HWERoutineTracker(const char* name)
368a94683196406b83b14218d1beef66067f126a16keunyoung            : mName(name) {
378a94683196406b83b14218d1beef66067f126a16keunyoung        ALOGV("Entering %s", mName);
388a94683196406b83b14218d1beef66067f126a16keunyoung    }
398a94683196406b83b14218d1beef66067f126a16keunyoung
408a94683196406b83b14218d1beef66067f126a16keunyoung    /* Destructor that prints a "leave" trace message. */
418a94683196406b83b14218d1beef66067f126a16keunyoung    ~HWERoutineTracker() {
428a94683196406b83b14218d1beef66067f126a16keunyoung        ALOGV("Leaving %s", mName);
438a94683196406b83b14218d1beef66067f126a16keunyoung    }
448a94683196406b83b14218d1beef66067f126a16keunyoung
458a94683196406b83b14218d1beef66067f126a16keunyoungprivate:
468a94683196406b83b14218d1beef66067f126a16keunyoung    /* Stores the routine name. */
478a94683196406b83b14218d1beef66067f126a16keunyoung    const char* mName;
488a94683196406b83b14218d1beef66067f126a16keunyoung};
498a94683196406b83b14218d1beef66067f126a16keunyoung
508a94683196406b83b14218d1beef66067f126a16keunyoung/* Logs an execution of a routine / method. */
518a94683196406b83b14218d1beef66067f126a16keunyoung#define LOGRE() HWERoutineTracker hwertracker_##__LINE__(__FUNCTION__)
528a94683196406b83b14218d1beef66067f126a16keunyoung
538a94683196406b83b14218d1beef66067f126a16keunyoung/*
548a94683196406b83b14218d1beef66067f126a16keunyoung * min / max macros
558a94683196406b83b14218d1beef66067f126a16keunyoung */
568a94683196406b83b14218d1beef66067f126a16keunyoung
578a94683196406b83b14218d1beef66067f126a16keunyoung#define min(a,b)    (((a) < (b)) ? (a) : (b))
588a94683196406b83b14218d1beef66067f126a16keunyoung#define max(a,b)    (((a) > (b)) ? (a) : (b))
598a94683196406b83b14218d1beef66067f126a16keunyoung
608a94683196406b83b14218d1beef66067f126a16keunyoung#endif  /* HW_EMULATOR_CAMERA_EMULATED_CAMERA_COMMON_H */
61