summaryrefslogtreecommitdiff
path: root/v3/fake-pipeline2/ge2d_stream.cpp (plain)
blob: dd8f41bcaaaa1aaebb941a091f5152aa92cb9242
1/*
2 * Copyright (C) 2014 The Android Open Source Project
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//#define LOG_NDEBUG 0
18//#define LOG_NNDEBUG 0
19
20#define LOG_TAG "Camera_Stream"
21#include <hardware/camera3.h>
22#include <DebugUtils.h>
23#include "ge2d_stream.h"
24
25//namespace android {
26
27#ifdef __cplusplus
28//extern "C"{
29#endif
30int cameraConfigureStreams(struct VideoInfo *vinfo, camera3_stream_configuration *streamList) {
31#if 0
32
33 int src_width = vinfo->preview.format.fmt.pix.width;
34 int src_height = vinfo->preview.format.fmt.pix.height;
35 int src_top = 0;
36 int src_left = 0;
37
38 //TODO check the pointers
39 if (vinfo->num_configs == 0) {
40 vinfo->ge2d_config = (config_para_ex_t *) malloc (sizeof(config_para_ex_t)
41 *streamList->num_streams);
42 vinfo->num_configs = streamList->num_streams;
43 } else if (vinfo->num_configs <= streamList->num_streams) {
44 vinfo->ge2d_config = (config_para_ex_t *) realloc (sizeof(config_para_ex_t)
45 *streamList->num_streams);
46 vinfo->num_configs = streamList->num_streams;
47 }
48
49 config_para_ex_t *cfg = vinfo->ge2d_config;
50
51 for (size_t i = 0; i < streamList->num_streams; i++) {
52 camera3_stream_t *newStream = streamList->streams[i];
53
54 /* data operating. */
55 cfg->alu_const_color= 0;//0x000000ff;
56 cfg->bitmask_en = 0;
57 cfg->src1_gb_alpha = 0;//0xff;
58 cfg->dst_xy_swap = 0;
59
60 cfg->src_planes[0].addr = 0
61 cfg->src_planes[0].w = src_width;
62 cfg->src_planes[0].h = src_height;
63 cfg->src_planes[1].addr = 0;
64 cfg->src_planes[1].w = src_width/2;
65 cfg->src_planes[1].h = src_height/2;
66 cfg->src_planes[2].addr = 0;
67 cfg->src_planes[2].w = src_width/2;
68 cfg->src_planes[2].h = src_height/2;
69 //canvas_read(output_para.index&0xff,&cd);
70 cfg->dst_planes[0].addr = 0;//cd.addr;
71 cfg->dst_planes[0].w = newStream->width;
72 cfg->dst_planes[0].h = newStream->height;
73 cfg->src_key.key_enable = 0;
74 cfg->src_key.key_mask = 0;
75 cfg->src_key.key_mode = 0;
76 cfg->src_para.canvas_index=0;//TODO vf->canvas0Addr;
77 cfg->src_para.mem_type = CANVAS_ALLOC;
78 cfg->src_para.format = GE2D_FORMAT_S16_YUV422;
79 //get_input_format(vf);
80 cfg->src_para.fill_color_en = 0;
81 cfg->src_para.fill_mode = 0;
82 cfg->src_para.x_rev = 0;
83 cfg->src_para.y_rev = 0;
84 cfg->src_para.color = 0xffffffff;
85 cfg->src_para.top = 0;
86 cfg->src_para.left = 0;
87 cfg->src_para.width = src_width;
88 cfg->src_para.height = src_height;
89 /* printk("vf_width is %d , vf_height is %d \n",vf->width ,vf->height); */
90 //cfg->dst_para.canvas_index = output_para.index&0xff;
91
92 cfg.dst_para.mem_type = CANVAS_ALLOC;
93 cfg.dst_para.fill_color_en = 0;
94 cfg.dst_para.fill_mode = 0;
95 cfg.dst_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN;
96 cfg.dst_para.x_rev = 0;
97 cfg.dst_para.y_rev = 0;
98 cfg.dst_para.color = 0;
99 cfg.dst_para.top = 0;
100 cfg.dst_para.left = 0;
101 cfg.dst_para.width = newStream->width;
102 cfg.dst_para.height = newStream->height;
103
104 cfg ++;
105 }
106 CAMHAL_LOGDB("numcfgs = %d, num streams=%d\n",
107 vinfo->num_configs, streamList->num_streams);
108#endif
109 return 0;
110}
111
112int fillStream(struct VideoInfo *src, uintptr_t physAddr, const android::StreamBuffer &dst) {
113 /* data operating. */
114 int ge2d_fd;
115 config_para_ex_t cfg;
116 ge2d_para_t para;
117
118 int32_t src_width = src->preview.format.fmt.pix.width;
119 int32_t src_height = src->preview.format.fmt.pix.height;
120
121 ge2d_fd = open("/dev/ge2d", O_RDWR);
122 if (ge2d_fd < 0) {
123 CAMHAL_LOGEA("open ge2d failed\n");
124 return -1;
125 }
126
127 //ioctl(ge2d_fd, GE2D_ANTIFLICKER_ENABLE,0);
128 memset(&cfg, 0, sizeof(cfg));
129 cfg.alu_const_color= 0;
130 cfg.bitmask_en = 0;
131 cfg.src1_gb_alpha = 0; //0xff;
132 cfg.dst_xy_swap = 0;
133
134 cfg.src_planes[0].addr = physAddr;
135 cfg.src_planes[0].w = src_width;
136 cfg.src_planes[0].h = src_height;
137 //NV21, YV12 need to add
138 cfg.src_planes[1].addr = physAddr + src_width *src_height;
139 cfg.src_planes[1].w = src_width;
140 cfg.src_planes[1].h = src_height/2;
141 //cfg.src_planes[2].addr = 0;
142 //cfg.src_planes[2].w = src_width/2;
143 //cfg.src_planes[2].h = src_height/2;
144 //canvas_read(output_para.index&0xff,&cd);
145 cfg.dst_planes[0].addr = dst.share_fd;//cd.addr;
146 cfg.dst_planes[0].w = dst.width;
147 cfg.dst_planes[0].h = dst.height;
148
149 cfg.dst_planes[1].addr = dst.share_fd;//cd.addr;
150 cfg.dst_planes[1].w = dst.width;
151 cfg.dst_planes[1].h = dst.height/2;
152 cfg.src_key.key_enable = 0;
153 cfg.src_key.key_mask = 0;
154 cfg.src_key.key_mode = 0;
155 cfg.src_para.mem_type = CANVAS_ALLOC;
156 cfg.src_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN;
157 cfg.src_para.fill_color_en = 0;
158 cfg.src_para.fill_mode = 0;
159 cfg.src_para.x_rev = 0;
160 cfg.src_para.y_rev = 0;
161 cfg.src_para.color = 0xffffffff;// 0xffff;
162 cfg.src_para.top = 0;
163 cfg.src_para.left = 0;
164 cfg.src_para.width = src_width;
165 cfg.src_para.height = src_height;
166 cfg.src2_para.mem_type = CANVAS_TYPE_INVALID;
167 /* printk("vf_width is %d , vf_height is %d \n",vf.width ,vf.height); */
168 //cfg.dst_para.canvas_index = output_para.index&0xff;
169
170 cfg.dst_para.mem_type = CANVAS_ALLOC;
171 cfg.dst_para.fill_color_en = 0;
172 cfg.dst_para.fill_mode = 0;
173 cfg.dst_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN;
174 cfg.dst_para.x_rev = 0;
175 cfg.dst_para.y_rev = 0;
176 cfg.dst_para.color = 0;
177 cfg.dst_para.top = 0;
178 cfg.dst_para.left = 0;
179 cfg.dst_para.width = dst.width;
180 cfg.dst_para.height = dst.height;
181
182
183 ioctl(ge2d_fd, GE2D_CONFIG_EX, &cfg);
184
185 para.src1_rect.x = 0;
186 para.src1_rect.y = 0;
187 para.src1_rect.w = src_width;
188 para.src1_rect.h = src_height;
189 para.dst_rect.x = 0;
190 para.dst_rect.y = 0;
191 para.dst_rect.w = dst.width;
192 para.dst_rect.h = dst.height;
193 //Y
194 ioctl(ge2d_fd, GE2D_STRETCHBLIT_NOALPHA, &para);
195 //Cb
196 //Cr
197
198 close (ge2d_fd);
199 ge2d_fd = -1;
200
201 return 0;
202}
203#ifdef __cplusplus
204//}
205#endif
206//}// namespace android
207