1befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed/*
24019c64ad8721cd9f3dc5c4e7be260a5f0706e34Arun Kumar K.R * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
34019c64ad8721cd9f3dc5c4e7be260a5f0706e34Arun Kumar K.R *
4befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * Redistribution and use in source and binary forms, with or without
5befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * modification, are permitted provided that the following conditions are
6befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * met:
7befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *   * Redistributions of source code must retain the above copyright
8befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     notice, this list of conditions and the following disclaimer.
9befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *   * Redistributions in binary form must reproduce the above
10befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     copyright notice, this list of conditions and the following
11befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     disclaimer in the documentation and/or other materials provided
12befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     with the distribution.
134019c64ad8721cd9f3dc5c4e7be260a5f0706e34Arun Kumar K.R *   * Neither the name of The Linux Foundation or the names of its
14befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     contributors may be used to endorse or promote products derived
15befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *     from this software without specific prior written permission.
16befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed *
17befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed */
29befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
30befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#ifndef INCLUDE_LIBQCOM_COMPTYPES
31befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#define INCLUDE_LIBQCOM_COMPTYPES
32befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
33befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#include <stdint.h>
34befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#include <utils/Singleton.h>
35befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#include <cutils/properties.h>
36befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
37befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmedusing namespace android;
380f859f6f0db0e0c05d8c319d8d597ad2731513aeNaseer Ahmednamespace qdutils {
39befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed// Enum containing the supported composition types
40befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmedenum {
41befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    COMPOSITION_TYPE_GPU = 0,
42befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    COMPOSITION_TYPE_MDP = 0x1,
43befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    COMPOSITION_TYPE_C2D = 0x2,
44befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    COMPOSITION_TYPE_CPU = 0x4,
45befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    COMPOSITION_TYPE_DYN = 0x8
46befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed};
47befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
48befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed/* This class caches the composition type
49befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed */
50befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmedclass QCCompositionType : public Singleton <QCCompositionType>
51befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed{
52befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    public:
53befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed        QCCompositionType();
54befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed        ~QCCompositionType() { }
55befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed        int getCompositionType() {return mCompositionType;}
56befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    private:
57befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed        int mCompositionType;
58befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
59befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed};
60befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed
61befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmedinline QCCompositionType::QCCompositionType()
62befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed{
63befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    char property[PROPERTY_VALUE_MAX];
64942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed    mCompositionType = COMPOSITION_TYPE_GPU;
65942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed    if (property_get("debug.composition.type", property, "gpu") > 0) {
66942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed        if ((strncmp(property, "mdp", 3)) == 0) {
67942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed            mCompositionType = COMPOSITION_TYPE_MDP;
68942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed        } else if ((strncmp(property, "c2d", 3)) == 0) {
69942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed            mCompositionType = COMPOSITION_TYPE_C2D;
70942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed        } else if ((strncmp(property, "dyn", 3)) == 0) {
71befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#ifdef USE_MDP3
72942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed            mCompositionType = COMPOSITION_TYPE_DYN | COMPOSITION_TYPE_MDP;
73befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#else
74942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed            mCompositionType = COMPOSITION_TYPE_DYN | COMPOSITION_TYPE_C2D;
75befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#endif
76befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed        }
77befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed    }
78befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed}
79942172924e3f4a1cac77c480e926bd3f43f220dfNaseer Ahmed
800f859f6f0db0e0c05d8c319d8d597ad2731513aeNaseer Ahmed}; //namespace qdutils
81befc466069680cb8a65b1f22ad44723d949128c8Naseer Ahmed#endif //INCLUDE_LIBQCOM_COMPTYPES
82