| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library ddk.protocol.ge2d; |
| using zx; |
| using zircon.device.sysmem; |
| using ddk.protocol.camerahwaccel; |
| |
| enum Ge2dRotation : uint8 { |
| ROTATION_0 = 0; |
| ROTATION_90 = 1; |
| ROTATION_180 = 2; |
| ROTATION_270 = 3; |
| MAX = 4; |
| }; |
| |
| struct CropRectangle { |
| uint32 crop_x; |
| uint32 crop_y; |
| uint32 crop_width; |
| uint32 crop_height; |
| }; |
| |
| struct ResizeInfo { |
| CropRectangle crop; // Initially this will be the same size as the canvas. |
| // Rotation is needed for video playback |
| Ge2dRotation output_rotation; |
| }; |
| |
| struct WaterMarkInfo { |
| // Where to place WaterMark on the input image |
| uint32 loc_x; |
| uint32 loc_y; |
| // Watermark Image Format |
| zircon.device.sysmem.ImageFormat_2 wm_image_format; |
| }; |
| |
| [Layout = "ddk-protocol"] |
| protocol Ge2d { |
| // Registers the buffer collections and configuration which the GE2D will be using |
| // for this task and also the callback functions for a particular task and |
| // returns a task index. |
| // |input_buffer_collection| : Pool of VMOs as input to the GE2D. |
| // |output_buffer_collection| : Pool of VMOs as output to the GE2D. |
| // [info] : Resize Info |
| // [input_image_format] : Input Image format |
| // [output_image_format_table] : Output Image format |
| // [output_image_format_index] : Initialize with this output image format. |
| // |callback| : This function is called when GDC is done processing the task. |
| // @Returns: |task_index| : Task ID for this task. |
| // |
| // The resize task only supports dynamically changing the output resolution |
| // (not the input resolution). Since the input resolution never changes after |
| // Init, we just pass a single input ImageFormat. |
| InitTaskResize(zircon.device.sysmem.BufferCollectionInfo_2 input_buffer_collection, |
| zircon.device.sysmem.BufferCollectionInfo_2 output_buffer_collection, |
| ResizeInfo info, |
| zircon.device.sysmem.ImageFormat_2 image_format, |
| vector<zircon.device.sysmem.ImageFormat_2> output_image_format_table, |
| uint32 output_image_format_index, |
| ddk.protocol.camerahwaccel.HwAccelCallback callback) -> (zx.status s, uint32 task_index); |
| |
| // The WaterMark task only supports changing the Input And Output resolution |
| // together. Moreover this operation changes both the input and output |
| // resolution, setting them to the same new resolution. Therefore we pass |
| // a single ImageFormat table, with a single ImageFormat table index, which |
| // applies to both input and output frames. |
| InitTaskWaterMark(zircon.device.sysmem.BufferCollectionInfo_2 input_buffer_collection, |
| zircon.device.sysmem.BufferCollectionInfo_2 output_buffer_collection, |
| WaterMarkInfo info, |
| handle<vmo> watermark_vmo, |
| vector<zircon.device.sysmem.ImageFormat_2> image_format_table, |
| uint32 image_format_index, |
| ddk.protocol.camerahwaccel.HwAccelCallback callback) -> (zx.status s, uint32 task_index); |
| |
| // De-registers the task. |
| RemoveTask(uint32 task_index); |
| |
| // Processes the frame at |input_buffer_index| within |input_buffer_collection| |
| // in the task corresponding to |task_index| and stores the ouput in the |
| // |output_buffer_collection| after applying the correct configuration. |
| // After processing we call the callback registered for this task with the |
| // output buffer index. |
| ProcessFrame(uint32 task_index, uint32 input_buffer_index) -> (zx.status s); |
| |
| // Releases the frame |buffer_index| from the |output_buffer_collection| to be |
| // used again by GDC driver again later. |
| ReleaseFrame(uint32 task_index, uint32 buffer_index); |
| |
| // Set the output resolution. This call sets the resolution on all the output canvas |
| // ids, for the specified task. This operation is queued to the worker thread to be |
| // performed in sequence. |
| SetOutputResolution(uint32 task_index, uint32 new_output_image_format_index) -> (zx.status s); |
| |
| // Similar to SetOutputResolution, this call sets the input and output resolution on all |
| // input and output canvas ids. |
| SetInputAndOutputResolution(uint32 task_index, |
| uint32 new_image_format_index) -> (zx.status s); |
| |
| // Sets/Changes the crop rectangle (on a Resize Task). Typically called when |
| // the camera controller is notified by Smart Framing to crop and resize. |
| SetCropRectangle(uint32 task_index, CropRectangle crop); |
| }; |