📄 ipipe_config.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <sys/mman.h>#include <sys/ioctl.h>#include <asm/arch/dm355_ipipe.h>#include "ipipe_example.h"#include "ipipe_config.h"#include "config_table.h"#define MAX_WIDTH (1280 + HCROP)struct ipipe_params params; struct ipipe_buffer t_buff;static int ipipefd = -1;void InitIpipe(int width, int height, struct buffer* ipipebuffer){ struct ipipe_reqbufs reqbufs; int ret; int ipipe_width; ipipe_width = width > MAX_WIDTH ? MAX_WIDTH : width; /* open the IPIPE driver */ ipipefd = open("/dev/dm355_ipipe", O_RDWR); if(ipipefd < 0) { printf("\nError opening device"); exit(0); } ret = ioctl(ipipefd, IPIPE_SET_PARAM,NULL); if (ret < 0) { printf("IPIPE_SET_PARAM fail\n"); exit(0); } ret = ioctl(ipipefd, IPIPE_GET_PARAM, ¶ms); if (ret < 0) { printf("IPIPE_GET_PARAM fail\n"); exit(0); } params.ipipeif_param.hnum = width; params.ipipeif_param.vnum = height; params.ipipeif_param.glob_hor_size = width + 8; params.ipipeif_param.glob_ver_size = height + 10; params.ipipeif_param.adofs = ((width + 31)&(~31))* 2; params.ipipeif_param.gain = 0x200; params.ipipeif_param.clk_div = DIVIDE_FIFTH; params.ipipe_vst = 0; params.ipipe_hst = 0; params.ipipe_vsz = height - 1; params.ipipe_hsz = width - 1; params.rsz_rsc_param[0].rsz_h_dif = 256; params.rsz_rsc_param[0].rsz_v_dif = 256; params.rsz_rsc_param[0].rsz_o_hsz = width; params.rsz_rsc_param[0].rsz_o_vsz = height; params.ext_mem_param[0].rsz_sdr_oft = width*2; params.ext_mem_param[0].rsz_sdr_ptr_e = width; params.prefilter.pre_en = DISABLE; params.false_color_suppresion.fcs_en = DISABLE; params.edge_enhancer.yee_emf = DISABLE; params.rgb2yuv.yuv_adj_ctr = 0x20; params.wb.wb2_dgn = 0x200; params.wb.wb2_wg_r = 0x110; params.wb.wb2_wg_gr = 0xf0; params.wb.wb2_wg_gb = 0xf0; params.wb.wb2_wg_b = 0x130; ret = ioctl(ipipefd, IPIPE_SET_PARAM,¶ms); if (ret < 0) { printf("IPIPE_SET_PARAM fail\n"); exit(0); } reqbufs.buf_type= IPIPE_BUF_OUT; reqbufs.size = height * ((width + 31) & (~31)) * 2; reqbufs.count = 1; ret = ioctl(ipipefd, IPIPE_REQBUF, &reqbufs); if(ret < 0) { printf("\ncannot get the requested buffer"); //goto out; exit(0); } t_buff.index = 0; t_buff.buf_type = IPIPE_BUF_OUT; ret =ioctl(ipipefd, IPIPE_QUERYBUF, &t_buff); if(ret < 0 ) { printf("\ncannot get out buffer address"); //goto out; exit(0); } ipipebuffer->length = t_buff.size; ipipebuffer->start = mmap(NULL, t_buff.size, PROT_READ|PROT_WRITE, MAP_SHARED, ipipefd, t_buff.offset); ipipebuffer->offset = t_buff.offset; if(ipipebuffer->start == MAP_FAILED) { printf("\ncannot mmap buffer"); //goto out; exit(0); }}void DoIPIPING(int width, int height, int offset){ struct ipipe_convert convert; int ret; /* Pass capture buffer directly to ipipeiewer */ convert.in_buff.buf_type = IPIPE_BUF_IN; convert.in_buff.index = -1; convert.in_buff.offset = offset; convert.in_buff.size = width * height * 2; convert.out_buff.index = -1; convert.out_buff.buf_type = IPIPE_BUF_OUT; convert.out_buff.offset = t_buff.offset; convert.out_buff.size = width * height * 2; do{ /* Start ipipe operation */ ret = ioctl(ipipefd, IPIPE_START, &convert); if (ret < 0) { printf("DoIPIPING: Cannot convert "); exit(0); } convert.in_buff.offset += (MAX_WIDTH - HCROP) * 2; convert.out_buff.offset += (MAX_WIDTH - HCROP) * 2; width -= (MAX_WIDTH - HCROP); }while(width > HCROP); }void CloseIpipe(struct buffer* ipipebuffer){ munmap(ipipebuffer->start, ipipebuffer->length); close(ipipefd); ipipefd = -1;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -