summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunfei Dong <yunfei.dong@mediatek.corp-partner.google.com>2022-03-02 17:16:37 +0800
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-09-30 14:48:39 +0000
commit6dabc23d23fde76877f4f73e7507f9ad08d6ad5c (patch)
treea4d45b52a647e0bfcbbf8344f9dd15c52bb82d99
parentec167b97e37d26c0decf0830a9aec3789760cd55 (diff)
downloadchrome-ec-6dabc23d23fde76877f4f73e7507f9ad08d6ad5c.tar.gz
mt_scp: Add support for mt8186 decoder
1. Add vdec ipi service interface 2. Add supported capability 3. Add ectasklist for mt8186 lat architecture 4. Separate mt8186 and mt8183 using define 5. Fix venc and mdp build error when add mt8186 driver 6. Fix cros_license_check errors BRANCH=none BUG=b:218771968 TEST=build corsola_scp pass Signed-off-by: kyrie wu <kyrie.wu@mediatek.corp-partner.google.com> Signed-off-by: Mingjia Zhang <mingjia.zhang@mediatek.corp-partner.google.com> Signed-off-by: Yunfei Dong <yunfei.dong@mediatek.corp-partner.google.com> Signed-off-by: Allen-kh Cheng <allen-kh.cheng@mediatek.corp-partner.google.com> Change-Id: I9d458a8c92ee27366ae03c3386d5682f62f5693b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3379786 Reviewed-by: Hsin-Yi Wang <hsinyi@chromium.org> Commit-Queue: Hsin-Yi Wang <hsinyi@chromium.org>
-rw-r--r--board/kukui_scp/board.h4
-rw-r--r--board/kukui_scp/ec.tasklist15
-rw-r--r--board/kukui_scp/mdp_ipi_message.c2
-rw-r--r--board/kukui_scp/vdec.c125
-rw-r--r--board/kukui_scp/vdec.h16
-rw-r--r--board/kukui_scp/venc.c2
-rw-r--r--board/kukui_scp/venc.h4
-rw-r--r--chip/mt_scp/mt818x/build.mk1
-rw-r--r--chip/mt_scp/mt818x/ipi.c5
-rw-r--r--chip/mt_scp/mt818x/memmap.h2
-rw-r--r--chip/mt_scp/mt818x/video.c19
-rw-r--r--chip/mt_scp/mt818x/video.h31
12 files changed, 202 insertions, 24 deletions
diff --git a/board/kukui_scp/board.h b/board/kukui_scp/board.h
index 64104060ab..fb074c59e0 100644
--- a/board/kukui_scp/board.h
+++ b/board/kukui_scp/board.h
@@ -118,7 +118,9 @@
#define IPI_ISP_FRAME 11
#define IPI_FD_CMD 12
#define IPI_HOST_COMMAND 13
-#define IPI_COUNT 14
+#define SCP_IPI_VDEC_LAT 14
+#define SCP_IPI_VDEC_CORE 15
+#define IPI_COUNT 16
#define IPI_NS_SERVICE 0xFF
diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist
index 82bb6db382..179e1b7c7f 100644
--- a/board/kukui_scp/ec.tasklist
+++ b/board/kukui_scp/ec.tasklist
@@ -14,13 +14,24 @@
#define UART_TASK
#endif
+#ifdef HAVE_PRIVATE_MT8183
#define S3_SUSPEND_TASK_LIST \
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(FD_SERVICE, fd_service_task, NULL, 760) \
TASK_ALWAYS(DIP_SERVICE, dip_service_task, NULL, 6400) \
+ TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880) \
TASK_ALWAYS(MDP_SERVICE, mdp_service_task, NULL, 1800) \
- TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880)
+ TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, LARGER_TASK_STACK_SIZE)
+#else
+#define S3_SUSPEND_TASK_LIST \
+ TASK_ALWAYS(VDEC_SERVICE, vdec_service_task, NULL, 4096) \
+ TASK_ALWAYS(VDEC_CORE_SERVICE, vdec_core_service_task, NULL, 4096) \
+ TASK_ALWAYS(MDP_SERVICE, mdp_service_task, NULL, 1800) \
+ TASK_ALWAYS(FD_SERVICE, fd_service_task, NULL, 760) \
+ TASK_ALWAYS(DIP_SERVICE, dip_service_task, NULL, 6400) \
+ TASK_ALWAYS(ISP_SERVICE, isp_service_task, NULL, 880) \
+ TASK_ALWAYS(VENC_SERVICE, venc_service_task, NULL, LARGER_TASK_STACK_SIZE)
+#endif
#define CONFIG_TASK_LIST \
TASK_ALWAYS(HOOKS, hook_task, NULL, LARGER_TASK_STACK_SIZE) \
diff --git a/board/kukui_scp/mdp_ipi_message.c b/board/kukui_scp/mdp_ipi_message.c
index f0bf7f2f92..fd6da65a07 100644
--- a/board/kukui_scp/mdp_ipi_message.c
+++ b/board/kukui_scp/mdp_ipi_message.c
@@ -29,6 +29,7 @@ static struct consumer const event_mdp_consumer = {
/* Stub functions only provided by private overlays. */
#ifndef HAVE_PRIVATE_MT8183
+#ifndef HAVE_PRIVATE_MT8186
void mdp_common_init(void)
{
}
@@ -36,6 +37,7 @@ void mdp_ipi_task_handler(void *pvParameters)
{
}
#endif
+#endif
static void event_mdp_written(struct consumer const *consumer, size_t count)
{
diff --git a/board/kukui_scp/vdec.c b/board/kukui_scp/vdec.c
index 317d83d0d5..fcc327d764 100644
--- a/board/kukui_scp/vdec.c
+++ b/board/kukui_scp/vdec.c
@@ -1,25 +1,30 @@
-/* Copyright 2018 The ChromiumOS Authors
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "console.h"
-#include "hooks.h"
#include "ipi_chip.h"
-#include "queue.h"
#include "queue_policies.h"
#include "registers.h"
#include "task.h"
#include "util.h"
#include "vdec.h"
+#ifdef HAVE_PRIVATE_MT8183
+#include "hooks.h"
+#include "queue.h"
+#else
+#include "link_defs.h"
+#endif
#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args)
#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args)
-/* Forwad declaration. */
+static void event_vdec_written(struct consumer const *consumer, size_t count)
+{
+ task_wake(TASK_ID_VDEC_SERVICE);
+}
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 = {
@@ -29,31 +34,56 @@ static struct consumer const event_vdec_consumer = {
}),
};
-/* Stub functions only provided by private overlays. */
+/*
+ * Only need to separate 8183 and others.
+ * 8183's architecture is different with other platforms.
+ * 8186 and future platform's architecture is the same, won't change anymore.
+ */
#ifndef HAVE_PRIVATE_MT8183
-void vdec_h264_service_init(void)
-{
-}
-void vdec_h264_msg_handler(void *data)
+static void event_vdec_core_written(struct consumer const *consumer,
+ size_t count)
{
+ task_wake(TASK_ID_VDEC_CORE_SERVICE);
}
-#endif
-
+static struct consumer const event_vdec_core_consumer;
+static struct queue const event_vdec_core_queue = QUEUE_DIRECT(
+ 8, struct vdec_msg, null_producer, event_vdec_core_consumer);
+static struct consumer const event_vdec_core_consumer = {
+ .queue = &event_vdec_core_queue,
+ .ops = &((struct consumer_ops const){
+ .written = event_vdec_core_written,
+ }),
+};
+#else
static vdec_msg_handler mtk_vdec_msg_handle[VDEC_MAX];
+#endif
-static void event_vdec_written(struct consumer const *consumer, size_t count)
+/* Stub functions only provided by private overlays. */
+#ifndef HAVE_PRIVATE_MT8183
+#ifndef HAVE_PRIVATE_MT8186
+void vdec_msg_handler(void *data)
+{
+}
+void vdec_core_msg_handler(void *data)
{
- task_wake(TASK_ID_VDEC_SERVICE);
}
+#endif
+#endif
static void vdec_h264_ipi_handler(int id, void *data, uint32_t len)
{
struct vdec_msg rsv_msg;
- if (!len)
+ if (!len) {
+ CPRINTS("len is zero.");
return;
+ }
+#ifdef HAVE_PRIVATE_MT8183
rsv_msg.type = VDEC_H264;
+#else
+ rsv_msg.type = VDEC_LAT;
+#endif
memcpy(rsv_msg.msg, data, MIN(len, sizeof(rsv_msg.msg)));
/*
@@ -63,17 +93,21 @@ static void vdec_h264_ipi_handler(int id, void *data, uint32_t len)
if (!queue_add_unit(&event_vdec_queue, &rsv_msg))
CPRINTS("Could not send vdec %d to the queue.", rsv_msg.type);
}
+#ifdef HAVE_PRIVATE_MT8183
DECLARE_IPI(IPI_VDEC_H264, vdec_h264_ipi_handler, 0);
+#else
+DECLARE_IPI(SCP_IPI_VDEC_LAT, vdec_h264_ipi_handler, 0);
+#endif
-/* This function renames from vdec_service_entry. */
void vdec_service_task(void *u)
{
struct vdec_msg rsv_msg;
size_t size;
+#ifdef HAVE_PRIVATE_MT8183
vdec_h264_service_init();
mtk_vdec_msg_handle[VDEC_H264] = vdec_h264_msg_handler;
-
+#endif
while (1) {
/*
* Queue unit is added in IPI handler, which is in ISR context.
@@ -83,11 +117,62 @@ void vdec_service_task(void *u)
size = queue_remove_unit(&event_vdec_queue, &rsv_msg);
ipi_enable_irq(SCP_IRQ_IPC0);
- if (!size)
+ if (!size) {
task_wait_event(-1);
- else if (mtk_vdec_msg_handle[rsv_msg.type])
+ continue;
+ }
+#ifndef HAVE_PRIVATE_MT8183
+ vdec_msg_handler(rsv_msg.msg);
+#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);
+#endif
}
}
+
+#ifndef HAVE_PRIVATE_MT8183
+static void vdec_h264_ipi_core_handler(int id, void *data, uint32_t len)
+{
+ struct vdec_msg rsv_msg;
+
+ if (!len) {
+ CPRINTS("len is zero.");
+ return;
+ }
+
+ rsv_msg.type = VDEC_CORE;
+ 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_core_queue, &rsv_msg))
+ CPRINTS("Could not send vdec %d to core queue.", rsv_msg.type);
+}
+DECLARE_IPI(SCP_IPI_VDEC_CORE, vdec_h264_ipi_core_handler, 0);
+
+void vdec_core_service_task(void *u)
+{
+ struct vdec_msg rsv_msg;
+ size_t size;
+
+ 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_core_queue, &rsv_msg);
+ ipi_enable_irq(SCP_IRQ_IPC0);
+
+ if (!size) {
+ task_wait_event(-1);
+ continue;
+ }
+ vdec_core_msg_handler(rsv_msg.msg);
+ }
+}
+#endif
diff --git a/board/kukui_scp/vdec.h b/board/kukui_scp/vdec.h
index 9284c28a40..411c1cbd15 100644
--- a/board/kukui_scp/vdec.h
+++ b/board/kukui_scp/vdec.h
@@ -1,4 +1,4 @@
-/* Copyright 2018 The ChromiumOS Authors
+/* Copyright 2022 The ChromiumOS Authors
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
@@ -7,6 +7,8 @@
#define __CROS_EC_SCP_VDEC_H
#include "compile_time_macros.h"
+
+#ifdef HAVE_PRIVATE_MT8183
#include "queue.h"
#include "registers.h"
@@ -18,6 +20,13 @@ enum vdec_type {
};
typedef void (*vdec_msg_handler)(void *msg);
+#else
+enum vdec_type {
+ VDEC_LAT,
+ VDEC_CORE,
+ VDEC_MAX,
+};
+#endif
struct vdec_msg {
enum vdec_type type;
@@ -28,7 +37,12 @@ BUILD_ASSERT(member_size(struct vdec_msg, msg) <=
CONFIG_IPC_SHARED_OBJ_BUF_SIZE);
/* Functions provided by private overlay. */
+#ifdef HAVE_PRIVATE_MT8183
void vdec_h264_service_init(void);
void vdec_h264_msg_handler(void *data);
+#else
+void vdec_core_msg_handler(void *msg);
+void vdec_msg_handler(void *msg);
+#endif
#endif /* __CROS_EC_SCP_VDEC_H */
diff --git a/board/kukui_scp/venc.c b/board/kukui_scp/venc.c
index 1f07a6eea0..ca5fc08429 100644
--- a/board/kukui_scp/venc.c
+++ b/board/kukui_scp/venc.c
@@ -33,10 +33,12 @@ static venc_msg_handler mtk_venc_msg_handle[VENC_MAX];
/* Stub functions only provided by private overlays. */
#ifndef HAVE_PRIVATE_MT8183
+#ifndef HAVE_PRIVATE_MT8186
void venc_h264_msg_handler(void *data)
{
}
#endif
+#endif
static void event_venc_written(struct consumer const *consumer, size_t count)
{
diff --git a/board/kukui_scp/venc.h b/board/kukui_scp/venc.h
index 1fc8421795..dcb74dbd87 100644
--- a/board/kukui_scp/venc.h
+++ b/board/kukui_scp/venc.h
@@ -10,6 +10,10 @@
#include "queue.h"
#include "registers.h"
+#ifdef HAVE_PRIVATE_MT8186
+#include "venc_h264_srv.h"
+#endif
+
enum venc_type {
VENC_H264,
VENC_MAX,
diff --git a/chip/mt_scp/mt818x/build.mk b/chip/mt_scp/mt818x/build.mk
index 39b1bce7dc..c44b2f0ebe 100644
--- a/chip/mt_scp/mt818x/build.mk
+++ b/chip/mt_scp/mt818x/build.mk
@@ -12,6 +12,7 @@ chip-y+=mt818x/gpio.o
chip-y+=mt818x/memmap.o
chip-y+=mt818x/system.o
chip-y+=mt818x/uart.o
+chip-y+=mt818x/video.o
# Optional chip modules
chip-$(CONFIG_AUDIO_CODEC_WOV)+=mt818x/audio_codec_wov.o
diff --git a/chip/mt_scp/mt818x/ipi.c b/chip/mt_scp/mt818x/ipi.c
index 7ae4ed12a0..723137d9c9 100644
--- a/chip/mt_scp/mt818x/ipi.c
+++ b/chip/mt_scp/mt818x/ipi.c
@@ -31,6 +31,7 @@
#include "task.h"
#include "util.h"
#include "hwtimer.h"
+#include "video.h"
#define CPRINTF(format, args...) cprintf(CC_IPI, format, ##args)
#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args)
@@ -246,7 +247,11 @@ void ipi_inform_ap(void)
scp_run.signaled = 1;
strncpy(scp_run.fw_ver, system_get_version(EC_IMAGE_RW),
SCP_FW_VERSION_LEN);
+#ifdef HAVE_PRIVATE_MT8183
scp_run.dec_capability = VCODEC_CAPABILITY_4K_DISABLED;
+#else
+ scp_run.dec_capability = video_get_dec_capability();
+#endif
scp_run.enc_capability = 0;
ret = ipi_send(IPI_SCP_INIT, (void *)&scp_run, sizeof(scp_run), 1);
diff --git a/chip/mt_scp/mt818x/memmap.h b/chip/mt_scp/mt818x/memmap.h
index b89123d57f..a3dee1710a 100644
--- a/chip/mt_scp/mt818x/memmap.h
+++ b/chip/mt_scp/mt818x/memmap.h
@@ -8,6 +8,8 @@
#ifndef __CROS_EC_MEMMAP_H
#define __CROS_EC_MEMMAP_H
+#include "stdint.h"
+
void scp_memmap_init(void);
/**
diff --git a/chip/mt_scp/mt818x/video.c b/chip/mt_scp/mt818x/video.c
new file mode 100644
index 0000000000..10ea586575
--- /dev/null
+++ b/chip/mt_scp/mt818x/video.c
@@ -0,0 +1,19 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+#include "video.h"
+
+uint32_t video_get_enc_capability(void)
+{
+ /* not support 4K */
+ return 0;
+}
+
+uint32_t video_get_dec_capability(void)
+{
+ return VDEC_CAP_MM21 | VDEC_CAP_4K_DISABLED | VDEC_CAP_H264_SLICE |
+ VDEC_CAP_VP8_FRAME | VDEC_CAP_VP9_FRAME;
+}
diff --git a/chip/mt_scp/mt818x/video.h b/chip/mt_scp/mt818x/video.h
new file mode 100644
index 0000000000..feb2215cfd
--- /dev/null
+++ b/chip/mt_scp/mt818x/video.h
@@ -0,0 +1,31 @@
+/* Copyright 2022 The ChromiumOS Authors
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef __CROS_EC_VIDEO_H
+#define __CROS_EC_VIDEO_H
+
+#include "common.h"
+
+/*
+ * Video decoder supported capability
+ */
+#define VDEC_CAP_4K_DISABLED BIT(4)
+#define VDEC_CAP_MM21 BIT(5)
+#define VDEC_CAP_MT21C BIT(6)
+#define VDEC_CAP_H264_SLICE BIT(8)
+#define VDEC_CAP_VP8_FRAME BIT(9)
+#define VDEC_CAP_VP9_FRAME BIT(10)
+#define VDEC_CAP_IRQ_IN_SCP BIT(16)
+
+/*
+ * Video encoder supported capability:
+ * BIT(0): enable 4K
+ */
+#define VENC_CAP_4K BIT(0)
+
+uint32_t video_get_enc_capability(void);
+uint32_t video_get_dec_capability(void);
+
+#endif /* #ifndef __CROS_EC_VIDEO_H */