summaryrefslogtreecommitdiffstats
path: root/exynos5/hal/libhdmi/SecHdmi/SecGscaler.h
blob: e9867ed0abbf2066517c0ac33ddb079bfd278527 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/*
 * Copyright@ Samsung Electronics Co. LTD
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __SEC_GSC_OUT_H__
#define __SEC_GSC_OUT_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <linux/fb.h>

#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <asm/sizes.h>

#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/poll.h>
#include <sys/mman.h>
#include <hardware/hardware.h>

#include "utils/Timers.h"

#include "s5p_fimc_v4l2.h"
#include "sec_utils_v4l2.h"
#include "media.h"
#include "v4l2-subdev.h"

#include "sec_format.h"

#include "SecBuffer.h"

#define PFX_NODE_MEDIADEV          "/dev/media"
#define PFX_NODE_SUBDEV            "/dev/v4l-subdev"
#define PFX_NODE_VIDEODEV          "/dev/video"
#define PFX_ENTITY_SUBDEV_GSC      "exynos-gsc-sd.%d"
#define PFX_ENTITY_OUTPUTDEV_GSC   "exynos-gsc.%d.output"

#define GSC_SUBDEV_PAD_SINK      (0)
#define GSC_SUBDEV_PAD_SOURCE    (1)
#define GSC_VIDEODEV_PAD_SOURCE  (0)
#define MAX_BUFFERS_GSCALER      (2)
#define MAX_PLANES_GSCALER       (3)

#ifdef __cplusplus
}

class SecGscaler
{
public:
    enum DEV {
        DEV_0 = 0,
        DEV_1,
        DEV_2,
        DEV_3,
        DEV_MAX,
    };

    enum MODE {
        MODE_NONE = 0,
        MODE_SINGLE_BUF,
        MODE_MULTI_BUF,
        MODE_DMA_AUTO,
        MODE_MAX,
    };

private:
    bool                        mFlagCreate;
    int                         mDev;
    int                         mVideoNodeNum;
    int                         mSubdevNodeNum;
    int                         mVideodevFd;
    int                         mMediadevFd;
    int                         mSubdevFd;
    unsigned int                mNumOfBuf;
    unsigned int                mSrcIndex;
    int                         mRotVal;
    bool                        mFlagGlobalAlpha;
    int                         mGlobalAlpha;
    bool                        mFlagLocalAlpha;
    bool                        mFlagColorKey;
    int                         mColorKey;
    bool                        mFlagSetSrcParam;
    bool                        mFlagSetDstParam;
    bool                        mFlagStreamOn;

    s5p_fimc_t                  mS5pFimc;
    SecBuffer                   mSrcBuffer[MAX_BUFFERS_GSCALER];

    __u32                       mSubdevEntity;
    __u32                       mVideodevEntity;
    //struct media_link_desc      mlink_desc;

public:
    SecGscaler();
    virtual ~SecGscaler();

    bool create(enum DEV dev, enum MODE mode, unsigned int numOfBuf);
    bool create(enum DEV dev, unsigned int numOfBuf);

    bool destroy(void);
    bool flagCreate(void);

    int   getFd(void);
    int   getVideodevFd(void);
    bool  openVideodevFd(void);
    bool  closeVideodevFd(void);

    int   getSubdevFd(void);
    __u32 getSubdevEntity(void);
    __u32 getVideodevEntity(void);
    bool  getFlagSteamOn(void);

    SecBuffer * getSrcBufferAddr(int index);

    bool setSrcParams(unsigned int width, unsigned int height,
                      unsigned int cropX, unsigned int cropY,
                      unsigned int *cropWidth, unsigned int *cropHeight,
                      int colorFormat,
                      bool forceChange = true);

    bool getSrcParams(unsigned int *width, unsigned int *height,
                      unsigned int *cropX, unsigned int *cropY,
                      unsigned int *cropWidth, unsigned int *cropHeight,
                      int *v4l2colorFormat);

    bool setSrcAddr(unsigned int YAddr,
                    unsigned int CbAddr = 0,
                    unsigned int CrAddr = 0,
                    int colorFormat = 0);

    bool setDstParams(unsigned int width, unsigned int height,
                      unsigned int cropX, unsigned int cropY,
                      unsigned int *cropWidth, unsigned int *cropHeight,
                      int colorFormat,
                      bool forceChange = true);

    bool getDstParams(unsigned int *width, unsigned int *height,
                      unsigned int *cropX, unsigned int *cropY,
                      unsigned int *cropWidth, unsigned int *cropHeight,
                      int *mbusColorFormat);

    bool setDstAddr(unsigned int YAddr,
                    unsigned int CbAddr = 0,
                    unsigned int CrAddr = 0,
                    int buf_index = 0);

    bool setRotVal(unsigned int rotVal);
    bool setGlobalAlpha(bool enable = true, int alpha = 0xff);
    bool setLocalAlpha(bool enable);
    bool setColorKey(bool enable = true, int colorKey = 0xff);

    bool run(void);
    bool streamOn(void);
    bool streamOff(void);

private:
    bool m_checkSrcSize(unsigned int width, unsigned int height,
                        unsigned int cropX, unsigned int cropY,
                        unsigned int *cropWidth, unsigned int *cropHeight,
                        int colorFormat,
                        bool forceChange = false);

    bool m_checkDstSize(unsigned int width, unsigned int height,
                        unsigned int cropX, unsigned int cropY,
                        unsigned int *cropWidth, unsigned int *cropHeight,
                        int colorFormat,
                        int rotVal,
                        bool forceChange = false);
    int  m_widthOfFimc(int v4l2ColorFormat, int width);
    int  m_heightOfFimc(int v4l2ColorFormat, int height);
    int  m_getYuvBpp(unsigned int fmt);
    int  m_getYuvPlanes(unsigned int fmt);
};
#endif

#endif //__SEC_GSC_OUT_H__