1 /* 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 21 extern "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> 30 #include <videodev2.h> 31 #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) 52 #define MIXER_V_SUBDEV_PAD_SOURCE (3) 53 #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 73 //#define GSC_OUT_DMA_BLOCKING 74 //#define GSC_OUT_DELAYED_STREAMON 75 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 89 struct 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; 98 unsigned int mode_drm; 99 100 int rotation; 101 int flip_horizontal; 102 int flip_vertical; 103 bool csc_range; 104 bool dirty; 105 106 void *addr[NUM_OF_GSC_PLANES]; 107 int acquireFenceFd; 108 int releaseFenceFd; 109 bool stream_on; 110 111 enum v4l2_buf_type buf_type; 112 struct v4l2_format format; 113 struct v4l2_buffer buffer; 114 bool buffer_queued; 115 struct v4l2_plane planes[NUM_OF_GSC_PLANES]; 116 struct v4l2_crop crop; 117 int src_buf_idx; 118 int qbuf_cnt; 119 }; 120 121 struct GSC_HANDLE { 122 int gsc_fd; 123 int gsc_id; 124 struct gsc_info src; 125 struct gsc_info dst; 126 exynos_gsc_img src_img; 127 exynos_gsc_img dst_img; 128 void *op_mutex; 129 void *obj_mutex[NUM_OF_GSC_HW]; 130 void *cur_obj_mutex; 131 bool flag_local_path; 132 bool flag_exclusive_open; 133 struct media_device *media0; 134 struct media_entity *gsc_sd_entity; 135 struct media_entity *gsc_vd_entity; 136 struct media_entity *sink_sd_entity; 137 int gsc_mode; 138 int out_mode; 139 bool allow_drm; 140 bool protection_enabled; 141 }; 142 143 extern int exynos_gsc_out_stop(void *handle); 144 #ifdef __cplusplus 145 } 146 #endif 147 148 #endif //__EXYNOS_MUTEX_H__ 149