blob: 8e5c49dbc2a6cbcec6791bf9b69e55ae065dceac [file] [log] [blame]
Jiho Chang70007c42012-03-24 06:03:51 +09001/*
2 * Copyright@ Samsung Electronics Co. LTD
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#ifndef EXYNOS_GSC_H_
18#define EXYNOS_GSC_H_
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24//#define LOG_NDEBUG 0
25#define LOG_TAG "libexynosgscaler"
26#include <cutils/log.h>
27
28#include <sys/types.h>
29#include <sys/ioctl.h>
Christopher Ferris0dd00e72013-12-04 14:53:23 -080030#include <linux/videodev2.h>
Jiho Chang70007c42012-03-24 06:03:51 +090031#include <fcntl.h>
32#include <stdbool.h>
33#include <string.h>
34#include <unistd.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <time.h>
38#include <system/graphics.h>
39#include "exynos_gscaler.h"
40
41#include "exynos_format.h"
42#include "ExynosMutex.h"
43#include "exynos_v4l2.h"
44
45//#include "ExynosBuffer.h"
46
47#define NUM_OF_GSC_PLANES (3)
48#define MAX_BUFFERS_GSCALER_OUT (3)
49#define GSCALER_SUBDEV_PAD_SINK (0)
50#define GSCALER_SUBDEV_PAD_SOURCE (1)
51#define MIXER_V_SUBDEV_PAD_SINK (0)
Benoit Gobyaad0a4c2012-08-28 15:17:09 -070052#define MIXER_V_SUBDEV_PAD_SOURCE (3)
Jiho Chang70007c42012-03-24 06:03:51 +090053#define FIMD_SUBDEV_PAD_SINK (0)
54#define MAX_BUFFERS (6)
55
56#define NUM_OF_GSC_HW (4)
57#define NODE_NUM_GSC_0 (23)
58#define NODE_NUM_GSC_1 (26)
59#define NODE_NUM_GSC_2 (29)
60#define NODE_NUM_GSC_3 (32)
61
62#define PFX_NODE_GSC "/dev/video"
63#define PFX_NODE_MEDIADEV "/dev/media"
64#define PFX_MXR_ENTITY "s5p-mixer%d"
65#define PFX_FIMD_ENTITY "s3c-fb-window%d"
66#define PFX_GSC_VIDEODEV_ENTITY "exynos-gsc.%d.output"
67#define PFX_GSC_SUBDEV_ENTITY "exynos-gsc-sd.%d"
68#define PFX_SUB_DEV "/dev/v4l-subdev%d"
69#define GSC_VD_PAD_SOURCE 0
70#define GSC_SD_PAD_SINK 0
71#define GSC_SD_PAD_SOURCE 1
72#define GSC_OUT_PAD_SINK 0
Jiho Change6a06252012-04-26 15:51:38 -070073//#define GSC_OUT_DMA_BLOCKING
74//#define GSC_OUT_DELAYED_STREAMON
Jiho Chang70007c42012-03-24 06:03:51 +090075
76#define GSC_VERSION GSC_EVT1
77
78#if (GSC_VERSION == GSC_EVT0)
79#define GSC_MIN_W_SIZE (64)
80#define GSC_MIN_H_SIZE (32)
81#else
82#define GSC_MIN_W_SIZE (32)
83#define GSC_MIN_H_SIZE (8)
84#endif
85
86#define MAX_GSC_WAITING_TIME_FOR_TRYLOCK (16000) // 16msec
87#define GSC_WAITING_TIME_FOR_TRYLOCK (8000) // 8msec
88
89struct gsc_info {
90 unsigned int width;
91 unsigned int height;
92 unsigned int crop_left;
93 unsigned int crop_top;
94 unsigned int crop_width;
95 unsigned int crop_height;
96 unsigned int v4l2_colorformat;
97 unsigned int cacheable;
Jiho Change6a06252012-04-26 15:51:38 -070098 unsigned int mode_drm;
Jiho Chang70007c42012-03-24 06:03:51 +090099
100 int rotation;
101 int flip_horizontal;
102 int flip_vertical;
Greg Hackmannbcd3f112012-10-11 14:22:43 -0700103 bool csc_range;
Greg Hackmanne2426aa2012-10-03 16:24:35 -0700104 bool dirty;
Jiho Chang70007c42012-03-24 06:03:51 +0900105
106 void *addr[NUM_OF_GSC_PLANES];
Benoit Goby9f6d8282012-10-04 13:25:29 -0700107 int acquireFenceFd;
108 int releaseFenceFd;
Jiho Chang70007c42012-03-24 06:03:51 +0900109 bool stream_on;
110
111 enum v4l2_buf_type buf_type;
112 struct v4l2_format format;
113 struct v4l2_buffer buffer;
Benoit Goby9f6d8282012-10-04 13:25:29 -0700114 bool buffer_queued;
Jiho Chang70007c42012-03-24 06:03:51 +0900115 struct v4l2_plane planes[NUM_OF_GSC_PLANES];
116 struct v4l2_crop crop;
Jiho Chang70007c42012-03-24 06:03:51 +0900117 int src_buf_idx;
118 int qbuf_cnt;
Jiho Chang70007c42012-03-24 06:03:51 +0900119};
120
121struct GSC_HANDLE {
122 int gsc_fd;
Dima Zavin33aa35f2012-10-05 16:04:52 -0700123 int gsc_id;
Jiho Chang70007c42012-03-24 06:03:51 +0900124 struct gsc_info src;
125 struct gsc_info dst;
Jiho Change6a06252012-04-26 15:51:38 -0700126 exynos_gsc_img src_img;
127 exynos_gsc_img dst_img;
Jiho Chang70007c42012-03-24 06:03:51 +0900128 void *op_mutex;
129 void *obj_mutex[NUM_OF_GSC_HW];
130 void *cur_obj_mutex;
Chien-Yu Chend1fb36a2014-11-11 11:46:54 -0800131 bool destroy_cur_obj_mutex;
Jiho Chang70007c42012-03-24 06:03:51 +0900132 bool flag_local_path;
133 bool flag_exclusive_open;
134 struct media_device *media0;
135 struct media_entity *gsc_sd_entity;
136 struct media_entity *gsc_vd_entity;
137 struct media_entity *sink_sd_entity;
138 int gsc_mode;
139 int out_mode;
Dima Zavin33aa35f2012-10-05 16:04:52 -0700140 bool allow_drm;
141 bool protection_enabled;
Jiho Chang70007c42012-03-24 06:03:51 +0900142};
143
Jiho Change6a06252012-04-26 15:51:38 -0700144extern int exynos_gsc_out_stop(void *handle);
Jiho Chang70007c42012-03-24 06:03:51 +0900145#ifdef __cplusplus
146}
147#endif
148
149#endif //__EXYNOS_MUTEX_H__