1 /* 2 * 3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 /*! 19 * \file exynos_gscaler.h 20 * \brief header file for Gscaler HAL 21 * \author ShinWon Lee (shinwon.lee (at) samsung.com) 22 * \date 2012/01/09 23 * 24 * <b>Revision History: </b> 25 * - 2012/01/09 : ShinWon Lee(shinwon.lee (at) samsung.com) \n 26 * Create 27 * 28 * - 2012/02/07 : ShinWon Lee(shinwon.lee (at) samsung.com) \n 29 * Change file name to exynos_gscaler.h 30 * 31 * - 2012/02/09 : Sangwoo, Parkk(sw5771.park (at) samsung.com) \n 32 * Use Multiple Gscaler by Multiple Process 33 * 34 * - 2012/02/20 : Sangwoo, Park(sw5771.park (at) samsung.com) \n 35 * Add exynos_gsc_set_rotation() API 36 * 37 * - 2012/02/20 : ShinWon Lee(shinwon.lee (at) samsung.com) \n 38 * Add size constrain 39 * 40 */ 41 42 /*! 43 * \defgroup exynos_gscaler 44 * \brief API for gscaler 45 * \addtogroup Exynos 46 */ 47 #include "Exynos_log.h" 48 49 #ifndef EXYNOS_GSCALER_H_ 50 #define EXYNOS_GSCALER_H_ 51 52 #ifdef __cplusplus 53 extern "C" { 54 #endif 55 56 //#define EXYNOS_GSC_TRACE 0 57 #ifdef EXYNOS_GSC_TRACE 58 #define EXYNOS_GSC_LOG_TAG "Exynos_gscaler" 59 #define Exynos_gsc_In() Exynos_Log(EXYNOS_DEV_LOG_DEBUG, EXYNOS_GSC_LOG_TAG, "%s In , Line: %d", __FUNCTION__, __LINE__) 60 #define Exynos_gsc_Out() Exynos_Log(EXYNOS_DEV_LOG_DEBUG, EXYNOS_GSC_LOG_TAG, "%s Out , Line: %d", __FUNCTION__, __LINE__) 61 #else 62 #define Exynos_gsc_In() ((void *)0) 63 #define Exynos_gsc_Out() ((void *)0) 64 #endif 65 66 typedef struct { 67 uint32_t x; 68 uint32_t y; 69 uint32_t w; 70 uint32_t h; 71 uint32_t fw; 72 uint32_t fh; 73 uint32_t format; 74 uint32_t yaddr; 75 uint32_t uaddr; 76 uint32_t vaddr; 77 uint32_t rot; 78 uint32_t cacheable; 79 uint32_t drmMode; 80 uint32_t narrowRgb; 81 int acquireFenceFd; 82 int releaseFenceFd; 83 } exynos_gsc_img; 84 85 /* 86 * Create libgscaler handle. 87 * Gscaler dev_num is dynamically changed. 88 * 89 * \ingroup exynos_gscaler 90 * 91 * \return 92 * libgscaler handle 93 */ 94 void *exynos_gsc_create( 95 void); 96 97 /*! 98 * Create exclusive libgscaler handle. 99 * Other module can't use dev_num of Gscaler. 100 * 101 * \ingroup exynos_gscaler 102 * 103 * \param dev_num 104 * gscaler dev_num[in] 105 * \param gsc_mode 106 *It should be set to GSC_M2M_MODE or GSC_OUTPUT_MODE. 107 * 108 *\param out_mode 109 *It should be set to GSC_OUT_FIMD or GSC_OUT_TV. 110 * 111 * \return 112 * libgscaler handle 113 */ 114 void *exynos_gsc_create_exclusive( 115 int dev_num, 116 int gsc_mode, 117 int out_mode, 118 int allow_drm); 119 120 /*! 121 * Destroy libgscaler handle 122 * 123 * \ingroup exynos_gscaler 124 * 125 * \param handle 126 * libgscaler handle[in] 127 */ 128 void exynos_gsc_destroy( 129 void *handle); 130 131 /*! 132 * Set source format. 133 * 134 * \ingroup exynos_gscaler 135 * 136 * \param handle 137 * libgscaler handle[in] 138 * 139 * \param width 140 * image width[in] 141 * 142 * \param height 143 * image height[in] 144 * 145 * \param crop_left 146 * image left crop size[in] 147 * 148 * \param crop_top 149 * image top crop size[in] 150 * 151 * \param crop_width 152 * cropped image width[in] 153 * 154 * \param crop_height 155 * cropped image height[in] 156 * 157 * \param v4l2_colorformat 158 * color format[in] 159 * 160 * \param cacheable 161 * ccacheable[in] 162 * 163 * \param mode_drm 164 * mode_drm[in] 165 * 166 * \return 167 * error code 168 */ 169 int exynos_gsc_set_src_format( 170 void *handle, 171 unsigned int width, 172 unsigned int height, 173 unsigned int crop_left, 174 unsigned int crop_top, 175 unsigned int crop_width, 176 unsigned int crop_height, 177 unsigned int v4l2_colorformat, 178 unsigned int cacheable, 179 unsigned int mode_drm); 180 181 /*! 182 * Set destination format. 183 * 184 * \ingroup exynos_gscaler 185 * 186 * \param handle 187 * libgscaler handle[in] 188 * 189 * \param width 190 * image width[in] 191 * 192 * \param height 193 * image height[in] 194 * 195 * \param crop_left 196 * image left crop size[in] 197 * 198 * \param crop_top 199 * image top crop size[in] 200 * 201 * \param crop_width 202 * cropped image width[in] 203 * 204 * \param crop_height 205 * cropped image height[in] 206 * 207 * \param v4l2_colorformat 208 * color format[in] 209 * 210 * \param cacheable 211 * ccacheable[in] 212 * 213 * \param mode_drm 214 * mode_drm[in] 215 * 216 * \param narrowRgb 217 * narrow RGB range[in] 218 * 219 * \return 220 * error code 221 */ 222 int exynos_gsc_set_dst_format( 223 void *handle, 224 unsigned int width, 225 unsigned int height, 226 unsigned int crop_left, 227 unsigned int crop_top, 228 unsigned int crop_width, 229 unsigned int crop_height, 230 unsigned int v4l2_colorformat, 231 unsigned int cacheable, 232 unsigned int mode_drm, 233 unsigned int narrowRgb); 234 235 /*! 236 * Set rotation. 237 * 238 * \ingroup exynos_gscaler 239 * 240 * \param handle 241 * libgscaler handle[in] 242 * 243 * \param rotation 244 * image rotation. It should be multiple of 90[in] 245 * 246 * \param flip_horizontal 247 * image flip_horizontal[in] 248 * 249 * \param flip_vertical 250 * image flip_vertical[in] 251 * 252 * \return 253 * error code 254 */ 255 int exynos_gsc_set_rotation( 256 void *handle, 257 int rotation, 258 int flip_horizontal, 259 int flip_vertical); 260 261 /*! 262 * Set source buffer 263 * 264 * \ingroup exynos_gscaler 265 * 266 * \param handle 267 * libgscaler handle[in] 268 * 269 * \param addr 270 * buffer pointer array[in] 271 * 272 * \param acquireFenceFd 273 * acquire fence fd for the buffer or -1[in] 274 * 275 * \return 276 * error code 277 */ 278 int exynos_gsc_set_src_addr( 279 void *handle, 280 void *addr[3], 281 int acquireFenceFd); 282 283 /*! 284 * Set destination buffer 285 * 286 * \param handle 287 * libgscaler handle[in] 288 * 289 * \param addr 290 * buffer pointer array[in] 291 * 292 * \param acquireFenceFd 293 * acquire fence fd for the buffer or -1[in] 294 * 295 * \return 296 * error code 297 */ 298 int exynos_gsc_set_dst_addr( 299 void *handle, 300 void *addr[3], 301 int acquireFenceFd); 302 303 /*! 304 * Convert color space with presetup color format 305 * 306 * \ingroup exynos_gscaler 307 * 308 * \param handle 309 * libgscaler handle[in] 310 * 311 * \return 312 * error code 313 */ 314 int exynos_gsc_convert( 315 void *handle); 316 317 /*! 318 * api for local path gscaler. Not yet support. 319 * 320 * \ingroup exynos_gscaler 321 */ 322 int exynos_gsc_connect( 323 void *handle, 324 void *hw); 325 326 /*! 327 * api for local path gscaler. Not yet support. 328 * 329 * \ingroup exynos_gscaler 330 */ 331 int exynos_gsc_disconnect( 332 void *handle, 333 void *hw); 334 335 /*! 336 * api for reserving a specific gscaler. 337 * This API could be used from any module that 338 *wants to control the gscalar privately. By calling this function any 339 *module can let the libgscaler know that GSC is used privately. 340 * 341 * \ingroup exynos_gsc_reserve 342 */ 343 void *exynos_gsc_reserve 344 (int dev_num); 345 346 347 /*! 348 * api for releasing the gscaler that was reserved with 349 *exynos_gsc_reserve. 350 * \ingroup exynos_gsc_reserve 351 */ 352 void exynos_gsc_release 353 (void *handle); 354 355 356 /* 357 *api for setting the GSC config. 358 It configures the GSC for given config 359 */ 360 int exynos_gsc_config_exclusive( 361 void *handle, 362 exynos_gsc_img *src_img, 363 exynos_gsc_img *dst_img); 364 365 /* 366 *api for GSC-OUT run. 367 It queues the srcBuf to GSC and deques a buf from driver. 368 It should be called after configuring the GSC. 369 */ 370 int exynos_gsc_run_exclusive( 371 void *handle, 372 exynos_gsc_img *src_img, 373 exynos_gsc_img *dst_img); 374 375 /* 376 * Blocks until the current frame is done processing. 377 */ 378 int exynos_gsc_wait_frame_done_exclusive 379 (void *handle); 380 381 /* 382 *api for GSC stop. 383 It stops the GSC OUT streaming. 384 */ 385 int exynos_gsc_stop_exclusive 386 (void *handle); 387 388 enum { 389 GSC_M2M_MODE = 0, 390 GSC_OUTPUT_MODE, 391 GSC_CAPTURE_MODE, 392 GSC_RESERVED_MODE, 393 }; 394 395 /*flag info */ 396 enum { 397 GSC_DUMMY = 0, 398 GSC_OUT_FIMD, 399 GSC_OUT_TV, 400 GSC_RESERVED, 401 }; 402 403 enum { 404 GSC_DONE_CNG_CFG = 0, 405 GSC_NEED_CNG_CFG, 406 }; 407 408 #ifdef __cplusplus 409 } 410 #endif 411 412 #endif /*EXYNOS_GSCALER_H_*/ 413