Petr Havlena | c928814 | 2012-11-15 14:07:10 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Havlena Petr, <havlenapetr@gmail.com> |
| 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 | #include <stdint.h> |
| 18 | #include <string.h> |
| 19 | #include <errno.h> |
| 20 | #include <fcntl.h> |
| 21 | #include <sys/types.h> |
| 22 | |
| 23 | #include <fimc.h> |
| 24 | |
| 25 | #include "test.h" |
| 26 | |
| 27 | int main(int argc, char** argv) { |
| 28 | int ret; |
| 29 | s5p_fimc_t fimc; |
| 30 | /* fimc src and dest objects */ |
| 31 | sec_img src_img; |
| 32 | sec_img dst_img; |
| 33 | sec_rect src_rect; |
| 34 | sec_rect dst_rect; |
| 35 | unsigned int phyAddr[3]; |
| 36 | |
| 37 | memset(&fimc, 0, sizeof(s5p_fimc_t)); |
| 38 | fimc.dev_fd = -1; |
| 39 | ret = fimc_open(&fimc, "/dev/video2"); |
| 40 | if(ret < 0) { |
| 41 | LOGE("%s:: Can't open fimc dev[%d]", __func__, ret); |
| 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | memset(&src_img, 0, sizeof(src_img)); |
| 46 | memset(&dst_img, 0, sizeof(src_img)); |
| 47 | memset(&src_rect, 0, sizeof(src_rect)); |
| 48 | memset(&dst_rect, 0, sizeof(src_rect)); |
| 49 | memset(&phyAddr, 0, sizeof(int) * sizeof(phyAddr)); |
| 50 | |
| 51 | phyAddr[0] = 0/*srcYAddr*/; |
| 52 | phyAddr[1] = 0/*srcCbAddr*/; |
| 53 | phyAddr[2] = 0/*srcCrAddr*/; |
| 54 | |
| 55 | src_img.w = 600; |
| 56 | src_img.h = 1024; |
| 57 | src_img.format = HAL_PIXEL_FORMAT_YCbCr_420_SP; |
| 58 | src_img.base = 0; |
| 59 | src_img.offset = 0; |
| 60 | src_img.mem_id = 0; |
| 61 | src_img.mem_type = FIMC_MEM_TYPE_PHYS; |
| 62 | src_img.w = (src_img.w + 15) & (~15); |
| 63 | src_img.h = (src_img.h + 1) & (~1) ; |
| 64 | |
| 65 | src_rect.x = 0; |
| 66 | src_rect.y = 0; |
| 67 | src_rect.w = src_img.w; |
| 68 | src_rect.h = src_img.h; |
| 69 | |
| 70 | dst_img.w = 600; |
| 71 | dst_img.h = 1024; |
| 72 | dst_img.format = HAL_PIXEL_FORMAT_YCbCr_420_SP; |
| 73 | dst_img.base = (unsigned int) fimc.out_buf.phys_addr; |
| 74 | dst_img.offset = 0; |
| 75 | dst_img.mem_id = 0; |
| 76 | dst_img.mem_type = FIMC_MEM_TYPE_PHYS; |
| 77 | |
| 78 | dst_rect.x = 0; |
| 79 | dst_rect.y = 0; |
| 80 | dst_rect.w = dst_img.w; |
| 81 | dst_rect.h = dst_img.h; |
| 82 | |
| 83 | LOGI("%s::sr_x %d sr_y %d sr_w %d sr_h %d dr_x %d dr_y %d dr_w %d dr_h %d ", |
| 84 | __func__, src_rect.x, src_rect.y, src_rect.w, src_rect.h, |
| 85 | dst_rect.x, dst_rect.y, dst_rect.w, dst_rect.h); |
| 86 | |
| 87 | for(int i = 0; i < 5 && ret == 0; i++) { |
| 88 | ret = fimc_flush(&fimc, &src_img, &src_rect, &dst_img, &dst_rect, |
| 89 | phyAddr, 0); |
| 90 | if(ret < 0) { |
| 91 | LOGE("%s:: Can't flush to fimc dev[%d]", __func__, ret); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | fimc_close(&fimc); |
| 96 | return ret; |
| 97 | } |