diff options
author | Yunfei Dong <yunfei.dong@mediatek.com> | 2019-03-29 13:46:39 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-08-26 15:37:45 +0000 |
commit | 991dd9a7258383f56d5ce1fe86a165b7c74213a4 (patch) | |
tree | 8578eda246d6b8edac659898a5534d103bc778a8 | |
parent | 94528b5d7141e88dd295bde47a9caa80022256e0 (diff) | |
download | chrome-ec-991dd9a7258383f56d5ce1fe86a165b7c74213a4.tar.gz |
mtk_vcodec: Add the service for h264 encoder
Fix the service to support h264 encoder.
BRANCH=none
BUG=b:123551776
TEST=build kukui_scp pass.
Change-Id: I2bc424ff577ee12246ffa73e5d73cfde388fe5cf
Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1535474
Commit-Queue: Nicolas Boichat <drinkcat@chromium.org>
Tested-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-by: Yilun Lin <yllin@chromium.org>
-rw-r--r-- | board/kukui_scp/build.mk | 1 | ||||
-rw-r--r-- | board/kukui_scp/ec.tasklist | 1 | ||||
-rw-r--r-- | board/kukui_scp/venc.c | 85 | ||||
-rw-r--r-- | board/kukui_scp/venc.h | 30 |
4 files changed, 117 insertions, 0 deletions
diff --git a/board/kukui_scp/build.mk b/board/kukui_scp/build.mk index 7221dab826..238a657487 100644 --- a/board/kukui_scp/build.mk +++ b/board/kukui_scp/build.mk @@ -10,3 +10,4 @@ CHIP_VARIANT:=mt8183 board-y=board.o board-$(HAS_TASK_VDEC_SERVICE)+=vdec.o +board-$(HAS_TASK_VENC_SERVICE)+=venc.o diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist index 09dd2e4850..6a00ce34c9 100644 --- a/board/kukui_scp/ec.tasklist +++ b/board/kukui_scp/ec.tasklist @@ -19,5 +19,6 @@ UART_TASK \ TASK_ALWAYS(HOSTCMD, host_command_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(VDEC_SERVICE, vdec_service_task, NULL, LARGER_TASK_STACK_SIZE) \ + TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/kukui_scp/venc.c b/board/kukui_scp/venc.c new file mode 100644 index 0000000000..ef1df894a0 --- /dev/null +++ b/board/kukui_scp/venc.c @@ -0,0 +1,85 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#include "chip/mt_scp/ipi_chip.h" +#include "chip/mt_scp/registers.h" +#include "console.h" +#include "hooks.h" +#include "task.h" +#include "util.h" +#include "venc.h" +#include "queue.h" +#include "queue_policies.h" + +#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args) +#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args) + +/* Forwad declaration. */ +static struct consumer const event_venc_consumer; +static void event_venc_written(struct consumer const *consumer, size_t count); + +static struct queue const event_venc_queue = QUEUE_DIRECT(8, + struct venc_msg, null_producer, event_venc_consumer); +static struct consumer const event_venc_consumer = { + .queue = &event_venc_queue, + .ops = &((struct consumer_ops const) { + .written = event_venc_written, + }), +}; + +static venc_msg_handler mtk_venc_msg_handle[VENC_MAX]; + +/* Stub functions only provided by private overlays. */ +#ifndef HAVE_PRIVATE_MT8183 +void venc_h264_msg_handler(void *data) {} +#endif + +static void event_venc_written(struct consumer const *consumer, size_t count) +{ + task_wake(TASK_ID_VENC_SERVICE); +} + +static void venc_h264_ipi_handler(int id, void *data, uint32_t len) +{ + struct venc_msg rsv_msg; + + if (!len) + return; + rsv_msg.type = VENC_H264; + memcpy(rsv_msg.msg, data, MIN(len, sizeof(rsv_msg.msg))); + + /* + * If there is no other IPI handler touch this queue, we don't need to + * interrupt_disable() or task_disable_irq(). + */ + if (!queue_add_unit(&event_venc_queue, &rsv_msg)) + CPRINTS("Could not send venc %d to the queue.", rsv_msg.type); +} +DECLARE_IPI(IPI_VENC_H264, venc_h264_ipi_handler, 0); + +/* This function renames from venc_service_entry. */ +void venc_service_task(void *u) +{ + struct venc_msg rsv_msg; + size_t size; + + mtk_venc_msg_handle[VENC_H264] = venc_h264_msg_handler; + while (1) { + /* + * Queue unit is added in IPI handler, which is in ISR context. + * Disable IRQ to prevent a clobbered queue. + */ + ipi_disable_irq(SCP_IRQ_IPC0); + size = queue_remove_unit(&event_venc_queue, &rsv_msg); + ipi_enable_irq(SCP_IRQ_IPC0); + + if (!size) + task_wait_event(-1); + else if (mtk_venc_msg_handle[rsv_msg.type]) + venc_h264_msg_handler(rsv_msg.msg); + else + CPRINTS("venc handler %d not exists.", rsv_msg.type); + } +} diff --git a/board/kukui_scp/venc.h b/board/kukui_scp/venc.h new file mode 100644 index 0000000000..1172efd1b1 --- /dev/null +++ b/board/kukui_scp/venc.h @@ -0,0 +1,30 @@ +/* Copyright 2018 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef __CROS_EC_SCP_VENC_H +#define __CROS_EC_SCP_VENC_H + +#include "chip/mt_scp/registers.h" +#include "compile_time_macros.h" +#include "queue.h" + +enum venc_type { + VENC_H264, + VENC_MAX, +}; + +typedef void (*venc_msg_handler)(void *msg); + +struct venc_msg { + enum venc_type type; + unsigned char msg[288]; +}; + +BUILD_ASSERT(member_size(struct venc_msg, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE); + +/* Functions provided by private overlay. */ +void venc_h264_msg_handler(void *data); + +#endif /* __CROS_EC_SCP_VENC_H */ |