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 <anniedale/AnnPlaneManager.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
34
35namespace android {
36namespace intel {
37
38PlatFactory::PlatFactory()
39{
40    CTRACE();
41}
42
43PlatFactory::~PlatFactory()
44{
45    CTRACE();
46}
47
48DisplayPlaneManager* PlatFactory::createDisplayPlaneManager()
49{
50    CTRACE();
51    return (new AnnPlaneManager());
52}
53
54BufferManager* PlatFactory::createBufferManager()
55{
56    CTRACE();
57    return (new PlatfBufferManager());
58}
59
60IDisplayDevice* PlatFactory::createDisplayDevice(int disp)
61{
62    CTRACE();
63    // when createDisplayDevice is called, Hwcomposer has already finished construction.
64    Hwcomposer &hwc = Hwcomposer::getInstance();
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