129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed/*
2e2b94da0a7de2a5cad9ecb90ed3eee5dca219863Saurabh Shah* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*
429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* Redistribution and use in source and binary forms, with or without
529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* modification, are permitted provided that the following conditions are
629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* met:
729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*    * Redistributions of source code must retain the above copyright
829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      notice, this list of conditions and the following disclaimer.
929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*    * Redistributions in binary form must reproduce the above
1029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      copyright notice, this list of conditions and the following
1129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      disclaimer in the documentation and/or other materials provided
1229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      with the distribution.
13d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed*    * Neither the name of The Linux Foundation nor the names of its
1429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      contributors may be used to endorse or promote products derived
1529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*      from this software without specific prior written permission.
1629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*
1729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
1829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
1929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
2029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
2129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
2429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
2629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
2729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed*/
2929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#ifndef OVERLAY_GENERIC_PIPE_H
3129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#define OVERLAY_GENERIC_PIPE_H
3229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include "overlayUtils.h"
3429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include "overlayRotator.h"
3529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#include "overlayCtrlData.h"
3629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmednamespace overlay {
3829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
3929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedclass GenericPipe : utils::NoCopy {
4029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedpublic:
41f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* ctor */
42d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed    explicit GenericPipe(int dpy);
43f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* dtor */
4429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    ~GenericPipe();
45d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed    bool init();
4629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool close();
47f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* Control APIs */
48f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* set source using whf, orient and wait flag */
4936963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    void setSource(const utils::PipeArgs& args);
50f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* set crop a.k.a the region of interest */
5136963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    void setCrop(const utils::Dim& d);
52f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* set orientation*/
5336963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    void setTransform(const utils::eTransform& param);
54f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* set mdp posision using dim */
5536963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    void setPosition(const utils::Dim& dim);
56e2b94da0a7de2a5cad9ecb90ed3eee5dca219863Saurabh Shah    /* set visual param */
57e2b94da0a7de2a5cad9ecb90ed3eee5dca219863Saurabh Shah    bool setVisualParams(const MetaData_t &metadata);
5829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* commit changes to the overlay "set"*/
5929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool commit();
60f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* Data APIs */
6129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* queue buffer to the overlay */
62f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    bool queueBuffer(int fd, uint32_t offset);
6329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* return cached startup args */
6429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    const utils::PipeArgs& getArgs() const;
6529a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* retrieve cached crop data */
6629a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    utils::Dim getCrop() const;
6729a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* is closed */
6829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool isClosed() const;
6929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* is open */
7029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool isOpen() const;
7129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* return Ctrl fd. Used for S3D */
7229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    int getCtrlFd() const;
7329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* dump the state of the object */
7429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    void dump() const;
75f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah    /* Return the dump in the specified buffer */
76f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah    void getDump(char *buf, size_t len);
77f48c59032a351cda58b2057423b2646423acd7c7Saurabh Shah
7829a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmedprivate:
79f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* set Closed pipe */
8029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    bool setClosed();
8129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
82d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed    int mFbNum;
8329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    /* Ctrl/Data aggregator */
8429a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed    CtrlData mCtrlData;
85d551ebe2cb65d9da47d3e25f6004b8870afec8b4Naseer Ahmed    Rotator* mRot;
86f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    //Whether rotator is used for 0-rot or otherwise
87f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    bool mRotUsed;
88d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan    //Whether we will do downscale opt. This is just a request. If the frame is
89d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan    //not a candidate, we might not do it.
90d82ce1da8ebdba46e6d0119fac1aa8d4b9b033b7Ramkumar Radhakrishnan    bool mRotDownscaleOpt;
9136963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    //Whether the source is prerotated.
9236963690317abceae79621f14ba41ff62b3ff489Saurabh Shah    bool mPreRotated;
93f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    /* Pipe open or closed */
94f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    enum ePipeState {
95f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        CLOSED,
96f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed        OPEN
97f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    };
98f48aef64b218d42bd2ede62dcb03a3d7831ebbf9Naseer Ahmed    ePipeState pipeState;
9929a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed};
10029a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
10129a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed} //namespace overlay
10229a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed
10329a26818d7294055539167b2fbfdaa168bcf725cNaseer Ahmed#endif // OVERLAY_GENERIC_PIPE_H
104