diff options
-rw-r--r-- | board/kukui_scp/build.mk | 1 | ||||
-rw-r--r-- | board/kukui_scp/ec.tasklist | 1 | ||||
-rw-r--r-- | board/kukui_scp/vdec.c | 89 | ||||
-rw-r--r-- | board/kukui_scp/vdec.h | 33 | ||||
-rw-r--r-- | chip/mt_scp/ipi.c | 2 | ||||
-rw-r--r-- | chip/mt_scp/ipi_chip.h | 7 |
6 files changed, 132 insertions, 1 deletions
diff --git a/board/kukui_scp/build.mk b/board/kukui_scp/build.mk index 64262dfecc..7221dab826 100644 --- a/board/kukui_scp/build.mk +++ b/board/kukui_scp/build.mk @@ -9,3 +9,4 @@ CHIP:=mt_scp CHIP_VARIANT:=mt8183 board-y=board.o +board-$(HAS_TASK_VDEC_SERVICE)+=vdec.o diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist index a0f7029ff4..09dd2e4850 100644 --- a/board/kukui_scp/ec.tasklist +++ b/board/kukui_scp/ec.tasklist @@ -18,5 +18,6 @@ TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \ 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(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) diff --git a/board/kukui_scp/vdec.c b/board/kukui_scp/vdec.c new file mode 100644 index 0000000000..6ab257b08e --- /dev/null +++ b/board/kukui_scp/vdec.c @@ -0,0 +1,89 @@ +/* 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 "vdec.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_vdec_consumer; +static void event_vdec_written(struct consumer const *consumer, size_t count); + +static struct queue const event_vdec_queue = QUEUE_DIRECT(8, + struct vdec_msg, null_producer, event_vdec_consumer); +static struct consumer const event_vdec_consumer = { + .queue = &event_vdec_queue, + .ops = &((struct consumer_ops const) { + .written = event_vdec_written, + }), +}; + +/* Stub functions only provided by private overlays. */ +#ifndef HAVE_PRIVATE_MT8183 +void vdec_h264_service_init(void) {} +void vdec_h264_msg_handler(void *data) {} +#endif + +static vdec_msg_handler mtk_vdec_msg_handle[VDEC_MAX]; + +static void event_vdec_written(struct consumer const *consumer, size_t count) +{ + task_wake(TASK_ID_VDEC_SERVICE); +} + +static void vdec_h264_ipi_handler(int id, void *data, uint32_t len) +{ + struct vdec_msg rsv_msg; + + if (!len) + return; + + rsv_msg.type = VDEC_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_vdec_queue, &rsv_msg)) + CPRINTS("Could not send vdec %d to the queue.", rsv_msg.type); +} +DECLARE_IPI(IPI_VDEC_H264, vdec_h264_ipi_handler, 0); + +/* This function renames from vdec_service_entry. */ +void vdec_service_task(void *u) +{ + struct vdec_msg rsv_msg; + size_t size; + + vdec_h264_service_init(); + mtk_vdec_msg_handle[VDEC_H264] = vdec_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_vdec_queue, &rsv_msg); + ipi_enable_irq(SCP_IRQ_IPC0); + + if (!size) + task_wait_event(-1); + else if (mtk_vdec_msg_handle[rsv_msg.type]) + vdec_h264_msg_handler(rsv_msg.msg); + else + CPRINTS("vdec handler %d not exists.", rsv_msg.type); + } +} diff --git a/board/kukui_scp/vdec.h b/board/kukui_scp/vdec.h new file mode 100644 index 0000000000..6e4c9b40e7 --- /dev/null +++ b/board/kukui_scp/vdec.h @@ -0,0 +1,33 @@ +/* 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_VDEC_H +#define __CROS_EC_SCP_VDEC_H + +#include "chip/mt_scp/registers.h" +#include "compile_time_macros.h" +#include "queue.h" + +enum vdec_type { + VDEC_H264, + VDEC_VP8, + VDEC_VP9, + VDEC_MAX, +}; + +typedef void (*vdec_msg_handler)(void *msg); + +struct vdec_msg { + enum vdec_type type; + unsigned char msg[48]; +}; + +BUILD_ASSERT(member_size(struct vdec_msg, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE); + +/* Functions provided by private overlay. */ +void vdec_h264_service_init(void); +void vdec_h264_msg_handler(void *data); + +#endif /* __CROS_EC_SCP_VDEC_H */ diff --git a/chip/mt_scp/ipi.c b/chip/mt_scp/ipi.c index 544ebb5d75..c8c0c1c74f 100644 --- a/chip/mt_scp/ipi.c +++ b/chip/mt_scp/ipi.c @@ -205,7 +205,7 @@ void ipi_inform_ap(void) scp_run.signaled = 1; strncpy(scp_run.fw_ver, system_get_version(SYSTEM_IMAGE_RW), SCP_FW_VERSION_LEN); - scp_run.dec_capability = 0; + scp_run.dec_capability = VCODEC_CAPABILITY_4K_DISABLED; scp_run.enc_capability = 0; ret = ipi_send(IPI_SCP_INIT, (void *)&scp_run, sizeof(scp_run), 1); diff --git a/chip/mt_scp/ipi_chip.h b/chip/mt_scp/ipi_chip.h index b4178ae7e0..6b9580e112 100644 --- a/chip/mt_scp/ipi_chip.h +++ b/chip/mt_scp/ipi_chip.h @@ -18,6 +18,13 @@ */ #define SCP_FW_VERSION_LEN 32 +/* + * Video decoder supported capability: + * BIT(4): 0 enable 4K + * 1 disable 4K + */ +#define VCODEC_CAPABILITY_4K_DISABLED BIT(4) + #ifndef IPI_SCP_INIT #error If CONFIG_IPI is enabled, IPI_SCP_INIT must be defined. #endif |