diff options
Diffstat (limited to 'board/asurada_scp')
-rw-r--r-- | board/asurada_scp/build.mk | 3 | ||||
-rw-r--r-- | board/asurada_scp/ec.tasklist | 3 | ||||
-rw-r--r-- | board/asurada_scp/mdp.c | 81 | ||||
-rw-r--r-- | board/asurada_scp/mdp.h | 20 |
4 files changed, 106 insertions, 1 deletions
diff --git a/board/asurada_scp/build.mk b/board/asurada_scp/build.mk index 60413bc639..6c52513faa 100644 --- a/board/asurada_scp/build.mk +++ b/board/asurada_scp/build.mk @@ -12,3 +12,6 @@ CHIP_VARIANT:=mt8192 board-y=board.o board-$(HAS_TASK_VDEC_SERVICE)+=vdec.o board-$(HAS_TASK_VENC_SERVICE)+=venc.o + +# MDP3 +board-$(HAS_TASK_MDP_SERVICE)+=mdp.o diff --git a/board/asurada_scp/ec.tasklist b/board/asurada_scp/ec.tasklist index 584093683f..6e2f613c6d 100644 --- a/board/asurada_scp/ec.tasklist +++ b/board/asurada_scp/ec.tasklist @@ -13,4 +13,5 @@ TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE) \ TASK_ALWAYS(VDEC_SERVICE, vdec_service_task, NULL, TRENTA_TASK_STACK_SIZE) \ TASK_ALWAYS(VDEC_CORE_SERVICE, vdec_core_service_task, NULL, TRENTA_TASK_STACK_SIZE) \ - TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, TRENTA_TASK_STACK_SIZE) + TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, TRENTA_TASK_STACK_SIZE) \ + TASK_ALWAYS(MDP_SERVICE, mdp_service_task, NULL, TRENTA_TASK_STACK_SIZE) diff --git a/board/asurada_scp/mdp.c b/board/asurada_scp/mdp.c new file mode 100644 index 0000000000..44b7df714e --- /dev/null +++ b/board/asurada_scp/mdp.c @@ -0,0 +1,81 @@ +/* Copyright 2021 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 "console.h" +#include "ipi_chip.h" +#include "mdp.h" +#include "queue_policies.h" +#include "registers.h" +#include "task.h" +#include "util.h" + +#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args) +#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args) + +static void event_mdp_written(struct consumer const *consumer, size_t count) +{ + task_wake(TASK_ID_MDP_SERVICE); +} +static struct consumer const event_mdp_consumer; +static struct queue const event_mdp_queue = QUEUE_DIRECT(4, + struct mdp_msg_service, null_producer, event_mdp_consumer); +static struct consumer const event_mdp_consumer = { + .queue = &event_mdp_queue, + .ops = &((struct consumer_ops const) { + .written = event_mdp_written, + }), +}; + +/* Stub functions only provided by private overlays. */ +#ifndef HAVE_PRIVATE_MT8192 +void mdp_common_init(void) {} +void mdp_ipi_task_handler(void *pvParameters) {} +#endif + +static void mdp_ipi_handler(int id, void *data, unsigned int len) +{ + struct mdp_msg_service rsv_msg; + + if (!len) { + CPRINTS("len is zero."); + return; + } + + rsv_msg.id = id; + 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_mdp_queue, &rsv_msg)) + CPRINTS("Could not send mdp id: %d to the queue.", id); +} +DECLARE_IPI(SCP_IPI_MDP_INIT, mdp_ipi_handler, 0); +DECLARE_IPI(SCP_IPI_MDP_FRAME, mdp_ipi_handler, 0); +DECLARE_IPI(SCP_IPI_MDP_DEINIT, mdp_ipi_handler, 0); + +void mdp_service_task(void *u) +{ + struct mdp_msg_service rsv_msg; + size_t size; + + mdp_common_init(); + + while (1) { + /* + * Queue unit is added in IPI handler, which is in ISR context. + * Disable IRQ to prevent a clobbered queue. + */ + ipi_disable_irq(); + size = queue_remove_unit(&event_mdp_queue, &rsv_msg); + ipi_enable_irq(); + + if (!size) + task_wait_event(-1); + else + mdp_ipi_task_handler(&rsv_msg); + } +} diff --git a/board/asurada_scp/mdp.h b/board/asurada_scp/mdp.h new file mode 100644 index 0000000000..eea3ffb289 --- /dev/null +++ b/board/asurada_scp/mdp.h @@ -0,0 +1,20 @@ +/* Copyright 2021 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_MDP_H +#define __CROS_EC_SCP_MDP_H + +struct mdp_msg_service { + int id; + unsigned char msg[20]; +}; +BUILD_ASSERT(member_size(struct mdp_msg_service, msg) <= + CONFIG_IPC_SHARED_OBJ_BUF_SIZE); + +/* Functions provided by private overlay. */ +void mdp_common_init(void); +void mdp_ipi_task_handler(void *pvParameters); + +#endif /* __CROS_EC_SCP_MDP_H */ |