blob: ef2df432ce18575193f205376ff60827e46ac9c3 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_DISPLAY_HARDWARE_BASE_H
18#define ANDROID_DISPLAY_HARDWARE_BASE_H
19
20#include <stdint.h>
21#include <utils/RefBase.h>
22#include <utils/threads.h>
23#include <linux/kd.h>
24#include <linux/vt.h>
25#include "Barrier.h"
26
27namespace android {
28
29class SurfaceFlinger;
30
31class DisplayHardwareBase
32{
33public:
34 DisplayHardwareBase(
35 const sp<SurfaceFlinger>& flinger,
36 uint32_t displayIndex);
37
38 ~DisplayHardwareBase();
39
Mathias Agopianc7d14e22011-08-01 16:32:21 -070040 // console management
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041 void releaseScreen() const;
42 void acquireScreen() const;
Mathias Agopian59119e62010-10-11 12:37:43 -070043 bool isScreenAcquired() const;
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045 bool canDraw() const;
Mathias Agopian59119e62010-10-11 12:37:43 -070046
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047
48private:
49 class DisplayEventThreadBase : public Thread {
50 protected:
51 wp<SurfaceFlinger> mFlinger;
52 public:
53 DisplayEventThreadBase(const sp<SurfaceFlinger>& flinger);
54 virtual ~DisplayEventThreadBase();
55 virtual void onFirstRef() {
56 run("DisplayEventThread", PRIORITY_URGENT_DISPLAY);
57 }
58 virtual status_t acquireScreen() const { return NO_ERROR; };
59 virtual status_t releaseScreen() const { return NO_ERROR; };
60 virtual status_t initCheck() const = 0;
61 };
62
63 class DisplayEventThread : public DisplayEventThreadBase
64 {
65 mutable Barrier mBarrier;
66 public:
67 DisplayEventThread(const sp<SurfaceFlinger>& flinger);
68 virtual ~DisplayEventThread();
69 virtual bool threadLoop();
70 virtual status_t readyToRun();
71 virtual status_t releaseScreen() const;
72 virtual status_t initCheck() const;
73 };
74
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080075 sp<DisplayEventThreadBase> mDisplayEventThread;
Mathias Agopian59119e62010-10-11 12:37:43 -070076 mutable int mScreenAcquired;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077};
78
79}; // namespace android
80
81#endif // ANDROID_DISPLAY_HARDWARE_BASE_H