Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 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> |
Christopher Ferris | 0dd00e7 | 2013-12-04 14:53:23 -0800 | [diff] [blame] | 30 | #include <linux/videodev2.h> |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 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) |
Benoit Goby | aad0a4c | 2012-08-28 15:17:09 -0700 | [diff] [blame] | 52 | #define MIXER_V_SUBDEV_PAD_SOURCE (3) |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 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 |
Jiho Chang | e6a0625 | 2012-04-26 15:51:38 -0700 | [diff] [blame] | 73 | //#define GSC_OUT_DMA_BLOCKING |
| 74 | //#define GSC_OUT_DELAYED_STREAMON |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 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; |
Jiho Chang | e6a0625 | 2012-04-26 15:51:38 -0700 | [diff] [blame] | 98 | unsigned int mode_drm; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 99 | |
| 100 | int rotation; |
| 101 | int flip_horizontal; |
| 102 | int flip_vertical; |
Greg Hackmann | bcd3f11 | 2012-10-11 14:22:43 -0700 | [diff] [blame] | 103 | bool csc_range; |
Greg Hackmann | e2426aa | 2012-10-03 16:24:35 -0700 | [diff] [blame] | 104 | bool dirty; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 105 | |
| 106 | void *addr[NUM_OF_GSC_PLANES]; |
Benoit Goby | 9f6d828 | 2012-10-04 13:25:29 -0700 | [diff] [blame] | 107 | int acquireFenceFd; |
| 108 | int releaseFenceFd; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 109 | bool stream_on; |
| 110 | |
| 111 | enum v4l2_buf_type buf_type; |
| 112 | struct v4l2_format format; |
| 113 | struct v4l2_buffer buffer; |
Benoit Goby | 9f6d828 | 2012-10-04 13:25:29 -0700 | [diff] [blame] | 114 | bool buffer_queued; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 115 | struct v4l2_plane planes[NUM_OF_GSC_PLANES]; |
| 116 | struct v4l2_crop crop; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 117 | int src_buf_idx; |
| 118 | int qbuf_cnt; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | struct GSC_HANDLE { |
| 122 | int gsc_fd; |
Dima Zavin | 33aa35f | 2012-10-05 16:04:52 -0700 | [diff] [blame] | 123 | int gsc_id; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 124 | struct gsc_info src; |
| 125 | struct gsc_info dst; |
Jiho Chang | e6a0625 | 2012-04-26 15:51:38 -0700 | [diff] [blame] | 126 | exynos_gsc_img src_img; |
| 127 | exynos_gsc_img dst_img; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 128 | void *op_mutex; |
| 129 | void *obj_mutex[NUM_OF_GSC_HW]; |
| 130 | void *cur_obj_mutex; |
Chien-Yu Chen | d1fb36a | 2014-11-11 11:46:54 -0800 | [diff] [blame] | 131 | bool destroy_cur_obj_mutex; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 132 | 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 Zavin | 33aa35f | 2012-10-05 16:04:52 -0700 | [diff] [blame] | 140 | bool allow_drm; |
| 141 | bool protection_enabled; |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 142 | }; |
| 143 | |
Jiho Chang | e6a0625 | 2012-04-26 15:51:38 -0700 | [diff] [blame] | 144 | extern int exynos_gsc_out_stop(void *handle); |
Jiho Chang | 70007c4 | 2012-03-24 06:03:51 +0900 | [diff] [blame] | 145 | #ifdef __cplusplus |
| 146 | } |
| 147 | #endif |
| 148 | |
| 149 | #endif //__EXYNOS_MUTEX_H__ |