1b166940edca6e312463461438e2aa66e9852c26aBenoit Goby/*
2b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
3b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*
4b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* Redistribution and use in source and binary forms, with or without
5b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* modification, are permitted provided that the following conditions are
6b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* met:
7b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*    * Redistributions of source code must retain the above copyright
8b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      notice, this list of conditions and the following disclaimer.
9b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*    * Redistributions in binary form must reproduce the above
10b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      copyright notice, this list of conditions and the following
11b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      disclaimer in the documentation and/or other materials provided
12b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      with the distribution.
13b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*    * Neither the name of The Linux Foundation nor the names of its
14b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      contributors may be used to endorse or promote products derived
15b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*      from this software without specific prior written permission.
16b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*
17b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27b166940edca6e312463461438e2aa66e9852c26aBenoit Goby* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28b166940edca6e312463461438e2aa66e9852c26aBenoit Goby*/
29b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
30b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#ifndef OVERLAY_GENERIC_PIPE_H
31b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#define OVERLAY_GENERIC_PIPE_H
32b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
33b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#include "overlayUtils.h"
34b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#include "overlayRotator.h"
35b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#include "overlayCtrlData.h"
36b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
37b166940edca6e312463461438e2aa66e9852c26aBenoit Gobynamespace overlay {
38b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
39b166940edca6e312463461438e2aa66e9852c26aBenoit Gobyclass GenericPipe : utils::NoCopy {
40b166940edca6e312463461438e2aa66e9852c26aBenoit Gobypublic:
41b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* ctor */
42b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    explicit GenericPipe(int dpy);
43b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* dtor */
44b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    ~GenericPipe();
45b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool init();
46b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool close();
47b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* Control APIs */
48b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set source using whf, orient and wait flag */
49b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void setSource(const utils::PipeArgs& args);
50b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set crop a.k.a the region of interest */
51b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void setCrop(const utils::Dim& d);
52b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set orientation*/
53b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void setTransform(const utils::eTransform& param);
54b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set mdp posision using dim */
55b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void setPosition(const utils::Dim& dim);
56b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set visual param */
57b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool setVisualParams(const MetaData_t &metadata);
58b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* commit changes to the overlay "set"*/
59b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool commit();
60b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* Data APIs */
61b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* queue buffer to the overlay */
62b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool queueBuffer(int fd, uint32_t offset);
63b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* return cached startup args */
64b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    const utils::PipeArgs& getArgs() const;
65b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* retrieve cached crop data */
66b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    utils::Dim getCrop() const;
67b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* is closed */
68b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool isClosed() const;
69b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* is open */
70b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool isOpen() const;
71b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* return Ctrl fd. Used for S3D */
72b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    int getCtrlFd() const;
73b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* dump the state of the object */
74b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void dump() const;
75b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* Return the dump in the specified buffer */
76b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    void getDump(char *buf, size_t len);
77b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
78b166940edca6e312463461438e2aa66e9852c26aBenoit Gobyprivate:
79b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* set Closed pipe */
80b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool setClosed();
81b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
82b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    int mFbNum;
83b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* Ctrl/Data aggregator */
84b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    CtrlData mCtrlData;
85b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    Rotator* mRot;
86b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    //Whether rotator is used for 0-rot or otherwise
87b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool mRotUsed;
88b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    //Whether we will do downscale opt. This is just a request. If the frame is
89b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    //not a candidate, we might not do it.
90b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool mRotDownscaleOpt;
91b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    //Whether the source is prerotated.
92b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    bool mPreRotated;
93b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    /* Pipe open or closed */
94b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    enum ePipeState {
95b166940edca6e312463461438e2aa66e9852c26aBenoit Goby        CLOSED,
96b166940edca6e312463461438e2aa66e9852c26aBenoit Goby        OPEN
97b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    };
98b166940edca6e312463461438e2aa66e9852c26aBenoit Goby    ePipeState pipeState;
99b166940edca6e312463461438e2aa66e9852c26aBenoit Goby};
100b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
101b166940edca6e312463461438e2aa66e9852c26aBenoit Goby} //namespace overlay
102b166940edca6e312463461438e2aa66e9852c26aBenoit Goby
103b166940edca6e312463461438e2aa66e9852c26aBenoit Goby#endif // OVERLAY_GENERIC_PIPE_H
104