[gdc][task] Adding necessary functionality to Task class
Test: No functionality changes, just adding helper functions.
Running gdc task-test. Boots up on Sherlock.
See //src/camera/TESTING.md
Change-Id: I94df9e5fb6c11a571463c0b59d6c9fad7885a0c6
diff --git a/src/camera/drivers/hw_accel/gdc/task.cc b/src/camera/drivers/hw_accel/gdc/task.cc
index 85eb3d6..65e3c3d 100644
--- a/src/camera/drivers/hw_accel/gdc/task.cc
+++ b/src/camera/drivers/hw_accel/gdc/task.cc
@@ -14,6 +14,16 @@
namespace gdc {
+// Validates the buffer collection.
+static bool IsBufferCollectionValid(
+ const buffer_collection_info_t* buffer_collection) {
+ return !(buffer_collection == nullptr ||
+ buffer_collection->buffer_count == 0 ||
+ buffer_collection->buffer_count > countof(buffer_collection->vmos) ||
+ buffer_collection->format.image.pixel_format.type !=
+ fuchsia_sysmem_PixelFormatType_NV12);
+}
+
zx_status_t Task::GetInputBufferPhysAddr(uint32_t input_buffer_index,
zx_paddr_t* out) const {
if (input_buffer_index >= input_buffers_.size() || out == nullptr) {
@@ -24,6 +34,15 @@
return ZX_OK;
}
+zx_status_t Task::GetInputBufferPhysSize(uint32_t input_buffer_index,
+ uint64_t* out) const {
+ if (input_buffer_index >= input_buffers_.size() || out == nullptr) {
+ return ZX_ERR_INVALID_ARGS;
+ }
+ *out = input_buffers_[input_buffer_index].region(0).size;
+ return ZX_OK;
+}
+
zx_status_t Task::InitBuffers(
const buffer_collection_info_t* input_buffer_collection,
const buffer_collection_info_t* output_buffer_collection,
@@ -103,18 +122,6 @@
return status;
}
-// Validates the buffer collection.
-bool Task::IsBufferCollectionValid(
- const buffer_collection_info_t* buffer_collection) const {
- if (buffer_collection == nullptr || buffer_collection->buffer_count == 0 ||
- buffer_collection->buffer_count > countof(buffer_collection->vmos) ||
- buffer_collection->format.image.pixel_format.type !=
- fuchsia_sysmem_PixelFormatType_NV12) {
- return false;
- }
- return true;
-}
-
// static
zx_status_t Task::Create(
const buffer_collection_info_t* input_buffer_collection,
@@ -135,8 +142,11 @@
input_buffer_collection, output_buffer_collection, config_vmo, bti);
if (status != ZX_OK) {
FX_LOG(ERROR, "%s: InitBuffers Failed\n", __func__);
+ return status;
}
+ task->input_format_ = input_buffer_collection->format.image;
+ task->output_format_ = output_buffer_collection->format.image;
task->callback_ = callback;
*out = std::move(task);
diff --git a/src/camera/drivers/hw_accel/gdc/task.h b/src/camera/drivers/hw_accel/gdc/task.h
index b58abb1..4c3b10c 100644
--- a/src/camera/drivers/hw_accel/gdc/task.h
+++ b/src/camera/drivers/hw_accel/gdc/task.h
@@ -27,6 +27,11 @@
return config_vmo_pinned_.region(0).phys_addr;
}
+ // Returns the physical address for the config VMO.
+ uint64_t GetConigVmoPhysSize() const {
+ return config_vmo_pinned_.region(0).size;
+ }
+
// Returns the physical address for the input buffer.
// |input_buffer_index| : Index of the input buffer for which the address is
// requested. |out| : Returns the physical address if the index provided is
@@ -34,6 +39,13 @@
zx_status_t GetInputBufferPhysAddr(uint32_t input_buffer_index,
zx_paddr_t* out) const;
+ // Returns the size of the input buffer.
+ // |input_buffer_index| : Index of the input buffer for which the address is
+ // requested. |out| : Returns the size if the index provided is
+ // valid.
+ zx_status_t GetInputBufferPhysSize(uint32_t input_buffer_index,
+ uint64_t* out) const;
+
// Validates input buffer index.
bool IsInputBufferIndexValid(uint32_t input_buffer_index) const {
return input_buffer_index < input_buffers_.size();
@@ -44,6 +56,8 @@
return output_buffers_.LockBufferForWrite();
}
+ image_format_t input_format() { return input_format_; }
+ image_format_t output_format() { return output_format_; }
const gdc_callback_t* callback() { return callback_; }
// Static function to create a task object.
@@ -67,12 +81,11 @@
const buffer_collection_info_t* output_buffer_collection,
const zx::vmo& config_vmo, const zx::bti& bti);
- bool IsBufferCollectionValid(
- const buffer_collection_info_t* buffer_collection) const;
-
fzl::PinnedVmo config_vmo_pinned_;
fzl::VmoPool output_buffers_;
fbl::Array<fzl::PinnedVmo> input_buffers_;
+ image_format_t input_format_;
+ image_format_t output_format_;
const gdc_callback_t* callback_;
};
} // namespace gdc
diff --git a/zircon/system/banjo/zircon.device.sysmem/sysmem.banjo b/zircon/system/banjo/zircon.device.sysmem/sysmem.banjo
index 8bbb6fe..dae8ee1 100644
--- a/zircon/system/banjo/zircon.device.sysmem/sysmem.banjo
+++ b/zircon/system/banjo/zircon.device.sysmem/sysmem.banjo
@@ -8,3 +8,6 @@
struct BufferCollectionInfo {
};
+
+struct ImageFormat {
+};
\ No newline at end of file
diff --git a/zircon/system/public/zircon/device/sysmem.h b/zircon/system/public/zircon/device/sysmem.h
index 7d96b0f..b5a303f 100644
--- a/zircon/system/public/zircon/device/sysmem.h
+++ b/zircon/system/public/zircon/device/sysmem.h
@@ -22,5 +22,6 @@
// TODO(ZX-2677): Deleting this file is blocked by banjo being able to consume
// code generated by fidl.
typedef fuchsia_sysmem_BufferCollectionInfo buffer_collection_info_t;
+typedef fuchsia_sysmem_ImageFormat image_format_t;
-#endif // SYSROOT_ZIRCON_DEVICE_SYSMEM_H_
+#endif // SYSROOT_ZIRCON_DEVICE_SYSMEM_H_