1/*
2// Copyright (c) 2014 Intel Corporation 
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#include <HwcTrace.h>
18#include <tangier/TngDisplayContext.h>
19#include <tangier/TngPlaneManager.h>
20#include <PlatfBufferManager.h>
21#include <IDisplayDevice.h>
22#include <PrimaryDevice.h>
23#include <ExternalDevice.h>
24#include <VirtualDevice.h>
25#include <Hwcomposer.h>
26#include <PlatFactory.h>
27#include <common/VsyncControl.h>
28#include <common/HdcpControl.h>
29#include <common/BlankControl.h>
30#include <common/PrepareListener.h>
31#include <common/VideoPayloadManager.h>
32
33
34namespace android {
35namespace intel {
36
37PlatFactory::PlatFactory()
38{
39    CTRACE();
40}
41
42PlatFactory::~PlatFactory()
43{
44    CTRACE();
45}
46
47DisplayPlaneManager* PlatFactory::createDisplayPlaneManager()
48{
49    CTRACE();
50    return (new TngPlaneManager());
51}
52
53BufferManager* PlatFactory::createBufferManager()
54{
55    CTRACE();
56    return (new PlatfBufferManager());
57}
58
59IDisplayDevice* PlatFactory::createDisplayDevice(int disp)
60{
61    CTRACE();
62    //when createDisplayDevice is called, Hwcomposer has already finished construction.
63    Hwcomposer &hwc = Hwcomposer::getInstance();
64
65    class PlatDeviceControlFactory: public DeviceControlFactory {
66    public:
67        virtual IVsyncControl* createVsyncControl()       {return new VsyncControl();}
68        virtual IBlankControl* createBlankControl()       {return new BlankControl();}
69        virtual IHdcpControl* createHdcpControl()         {return new HdcpControl();}
70    };
71
72    switch (disp) {
73        case IDisplayDevice::DEVICE_PRIMARY:
74            return new PrimaryDevice(hwc, new PlatDeviceControlFactory());
75        case IDisplayDevice::DEVICE_EXTERNAL:
76            return new ExternalDevice(hwc, new PlatDeviceControlFactory());
77        case IDisplayDevice::DEVICE_VIRTUAL:
78            return new VirtualDevice(hwc);
79        default:
80            ETRACE("invalid display device %d", disp);
81            return NULL;
82    }
83}
84
85IDisplayContext* PlatFactory::createDisplayContext()
86{
87    CTRACE();
88    return new TngDisplayContext();
89}
90
91IVideoPayloadManager *PlatFactory::createVideoPayloadManager()
92{
93    return new VideoPayloadManager();
94}
95
96Hwcomposer* Hwcomposer::createHwcomposer()
97{
98    CTRACE();
99    Hwcomposer *hwc = new Hwcomposer(new PlatFactory());
100    return hwc;
101}
102
103} //namespace intel
104} //namespace android
105