The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | namespace android { |
| 28 | |
| 29 | class SurfaceFlinger; |
| 30 | |
| 31 | class DisplayHardwareBase |
| 32 | { |
| 33 | public: |
| 34 | DisplayHardwareBase( |
| 35 | const sp<SurfaceFlinger>& flinger, |
| 36 | uint32_t displayIndex); |
| 37 | |
| 38 | ~DisplayHardwareBase(); |
| 39 | |
| 40 | // console managment |
| 41 | void releaseScreen() const; |
| 42 | void acquireScreen() const; |
| 43 | bool canDraw() const; |
| 44 | |
| 45 | private: |
| 46 | class DisplayEventThreadBase : public Thread { |
| 47 | protected: |
| 48 | wp<SurfaceFlinger> mFlinger; |
| 49 | public: |
| 50 | DisplayEventThreadBase(const sp<SurfaceFlinger>& flinger); |
| 51 | virtual ~DisplayEventThreadBase(); |
| 52 | virtual void onFirstRef() { |
| 53 | run("DisplayEventThread", PRIORITY_URGENT_DISPLAY); |
| 54 | } |
| 55 | virtual status_t acquireScreen() const { return NO_ERROR; }; |
| 56 | virtual status_t releaseScreen() const { return NO_ERROR; }; |
| 57 | virtual status_t initCheck() const = 0; |
| 58 | }; |
| 59 | |
| 60 | class DisplayEventThread : public DisplayEventThreadBase |
| 61 | { |
| 62 | mutable Barrier mBarrier; |
| 63 | public: |
| 64 | DisplayEventThread(const sp<SurfaceFlinger>& flinger); |
| 65 | virtual ~DisplayEventThread(); |
| 66 | virtual bool threadLoop(); |
| 67 | virtual status_t readyToRun(); |
| 68 | virtual status_t releaseScreen() const; |
| 69 | virtual status_t initCheck() const; |
| 70 | }; |
| 71 | |
| 72 | class ConsoleManagerThread : public DisplayEventThreadBase |
| 73 | { |
| 74 | int consoleFd; |
| 75 | int vt_num; |
| 76 | int prev_vt_num; |
| 77 | vt_mode vm; |
| 78 | static void sigHandler(int sig); |
| 79 | static pid_t sSignalCatcherPid; |
| 80 | public: |
| 81 | ConsoleManagerThread(const sp<SurfaceFlinger>& flinger); |
| 82 | virtual ~ConsoleManagerThread(); |
| 83 | virtual bool threadLoop(); |
| 84 | virtual status_t readyToRun(); |
| 85 | virtual void requestExit(); |
| 86 | virtual status_t releaseScreen() const; |
| 87 | virtual status_t initCheck() const; |
| 88 | }; |
| 89 | |
| 90 | sp<DisplayEventThreadBase> mDisplayEventThread; |
| 91 | mutable int mCanDraw; |
| 92 | }; |
| 93 | |
| 94 | }; // namespace android |
| 95 | |
| 96 | #endif // ANDROID_DISPLAY_HARDWARE_BASE_H |