Home | History | Annotate | Download | only in default
      1 /*
      2  * Copyright (C) 2017 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_TAG "android.hardware.camera.device (at) 3.3-convert-impl"
     18 #include <log/log.h>
     19 
     20 #include "include/convert.h"
     21 
     22 namespace android {
     23 namespace hardware {
     24 namespace camera {
     25 namespace device {
     26 namespace V3_3 {
     27 namespace implementation {
     28 
     29 using ::android::hardware::graphics::common::V1_0::Dataspace;
     30 using ::android::hardware::graphics::common::V1_0::PixelFormat;
     31 using ::android::hardware::camera::device::V3_2::BufferUsageFlags;
     32 
     33 void convertToHidl(const Camera3Stream* src, HalStream* dst) {
     34     dst->overrideDataSpace = src->data_space;
     35     dst->v3_2.id = src->mId;
     36     dst->v3_2.overrideFormat = (PixelFormat) src->format;
     37     dst->v3_2.maxBuffers = src->max_buffers;
     38     if (src->stream_type == CAMERA3_STREAM_OUTPUT) {
     39         dst->v3_2.consumerUsage = (BufferUsageFlags)0;
     40         dst->v3_2.producerUsage = (BufferUsageFlags)src->usage;
     41     } else if (src->stream_type == CAMERA3_STREAM_INPUT) {
     42         dst->v3_2.producerUsage = (BufferUsageFlags)0;
     43         dst->v3_2.consumerUsage = (BufferUsageFlags)src->usage;
     44     } else {
     45         //Should not reach here per current HIDL spec, but we might end up adding
     46         // bi-directional stream to HIDL.
     47         ALOGW("%s: Stream type %d is not currently supported!",
     48                 __FUNCTION__, src->stream_type);
     49     }
     50 }
     51 
     52 void convertToHidl(const camera3_stream_configuration_t& src, HalStreamConfiguration* dst) {
     53     dst->streams.resize(src.num_streams);
     54     for (uint32_t i = 0; i < src.num_streams; i++) {
     55         convertToHidl(static_cast<Camera3Stream*>(src.streams[i]), &dst->streams[i]);
     56     }
     57     return;
     58 }
     59 
     60 }  // namespace implementation
     61 }  // namespace V3_3
     62 }  // namespace device
     63 }  // namespace camera
     64 }  // namespace hardware
     65 }  // namespace android
     66