2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <camera_internal.h>
24 #include <camera_private.h>
30 #define LOG_TAG "TIZEN_N_CAMERA"
33 extern int g_mmcam_log_level;
36 int camera_start_evas_rendering(camera_h camera)
38 return _camera_start_evas_rendering(camera);
41 int camera_stop_evas_rendering(camera_h camera, bool keep_screen)
43 return _camera_stop_evas_rendering(camera, keep_screen);
46 int camera_set_ecore_wl_display(camera_h camera, void *ecore_wl_window)
48 return _camera_set_display(camera, MM_DISPLAY_TYPE_OVERLAY_EXT, ecore_wl_window);
52 void camera_create_preview_frame(camera_stream_data_s *stream, int num_buffer_fd,
53 tbm_bo_handle *buffer_bo_handle, tbm_bo_handle *data_bo_handle, camera_preview_data_s *frame)
56 unsigned char *buf_pos = NULL;
58 if (!stream || !buffer_bo_handle || !frame) {
59 CAM_LOG_ERROR("invalid param %p,%p,%p", stream, buffer_bo_handle, frame);
64 if (stream->format == MM_PIXEL_FORMAT_ITLV_JPEG_UYVY)
65 frame->format = MM_PIXEL_FORMAT_UYVY;
67 frame->format = stream->format;
69 frame->width = stream->width;
70 frame->height = stream->height;
71 frame->timestamp = stream->timestamp;
72 frame->num_of_planes = stream->num_planes;
74 if (num_buffer_fd == 0) {
77 if (!data_bo_handle || !data_bo_handle->ptr) {
78 CAM_LOG_ERROR("NULL pointer");
82 buf_pos = data_bo_handle->ptr;
84 if (stream->format == MM_PIXEL_FORMAT_ENCODED_H264) {
85 frame->data.encoded_plane.data = buf_pos;
86 frame->data.encoded_plane.size = stream->data.encoded.length_data;
87 frame->data.encoded_plane.is_delta_frame = (bool)stream->data.encoded.is_delta_frame;
88 total_size = stream->data.encoded.length_data;
89 } else if (stream->format == MM_PIXEL_FORMAT_ENCODED_MJPEG) {
90 frame->data.encoded_plane.data = buf_pos;
91 frame->data.encoded_plane.size = stream->data.encoded.length_data;
92 total_size = stream->data.encoded.length_data;
93 } else if (stream->format == MM_PIXEL_FORMAT_INVZ) {
94 frame->data.depth_plane.data = buf_pos;
95 frame->data.depth_plane.size = stream->data.depth.length_data;
96 total_size = stream->data.depth.length_data;
97 } else if (stream->format == MM_PIXEL_FORMAT_RGBA ||
98 stream->format == MM_PIXEL_FORMAT_ARGB) {
99 frame->data.rgb_plane.data = buf_pos;
100 frame->data.rgb_plane.size = stream->data.rgb.length_data;
101 total_size = stream->data.rgb.length_data;
103 switch (stream->num_planes) {
105 frame->data.single_plane.yuv = buf_pos;
106 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
107 total_size = stream->data.yuv420.length_yuv;
110 frame->data.double_plane.y = buf_pos;
111 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
112 buf_pos += stream->data.yuv420sp.length_y;
113 frame->data.double_plane.uv = buf_pos;
114 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
115 total_size = stream->data.yuv420sp.length_y + \
116 stream->data.yuv420sp.length_uv;
119 frame->data.triple_plane.y = buf_pos;
120 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
121 buf_pos += stream->data.yuv420p.length_y;
122 frame->data.triple_plane.u = buf_pos;
123 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
124 buf_pos += stream->data.yuv420p.length_u;
125 frame->data.triple_plane.v = buf_pos;
126 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
127 total_size = stream->data.yuv420p.length_y + \
128 stream->data.yuv420p.length_u + \
129 stream->data.yuv420p.length_v;
138 switch (stream->num_planes) {
141 frame->data.single_plane.yuv = buffer_bo_handle[0].ptr;
142 frame->data.single_plane.size = stream->data.yuv420.length_yuv;
143 total_size = stream->data.yuv420.length_yuv;
147 frame->data.double_plane.y = buffer_bo_handle[0].ptr;
148 if (stream->num_planes == (unsigned int)num_buffer_fd)
149 frame->data.double_plane.uv = buffer_bo_handle[1].ptr;
151 frame->data.double_plane.uv = buffer_bo_handle[0].ptr + stream->data.yuv420sp.length_y;
152 frame->data.double_plane.y_size = stream->data.yuv420sp.length_y;
153 frame->data.double_plane.uv_size = stream->data.yuv420sp.length_uv;
154 total_size = stream->data.yuv420sp.length_y + \
155 stream->data.yuv420sp.length_uv;
159 frame->data.triple_plane.y = buffer_bo_handle[0].ptr;
160 if (stream->num_planes == (unsigned int)num_buffer_fd) {
161 frame->data.triple_plane.u = buffer_bo_handle[1].ptr;
162 frame->data.triple_plane.v = buffer_bo_handle[2].ptr;
164 frame->data.triple_plane.u = buffer_bo_handle[0].ptr + stream->data.yuv420p.length_y;
165 frame->data.triple_plane.v = buffer_bo_handle[1].ptr + stream->data.yuv420p.length_u;
167 frame->data.triple_plane.y_size = stream->data.yuv420p.length_y;
168 frame->data.triple_plane.u_size = stream->data.yuv420p.length_u;
169 frame->data.triple_plane.v_size = stream->data.yuv420p.length_v;
170 total_size = stream->data.yuv420p.length_y + \
171 stream->data.yuv420p.length_u + \
172 stream->data.yuv420p.length_v;
180 CAM_LOG_DEBUG("format[%d], res[%dx%d], size[%d], plane num[%d]",
181 frame->format, frame->width, frame->height, total_size, frame->num_of_planes);