summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJungo Lin <jungo.lin@mediatek.com>2019-04-03 17:21:47 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-26 15:37:47 +0000
commit82ac51f46213eb1853db970a3e530e9a8db4d9af (patch)
tree0568ed36120a9bce0687de54a09e95c0f0c63547
parent2348dd0c629d0ee789a71ac55dc0b98d16896b0a (diff)
downloadchrome-ec-82ac51f46213eb1853db970a3e530e9a8db4d9af.tar.gz
mtk_isp: Add the service for isp P1 driver
BRANCH=none BUG=b:139269434 TEST=build kukui_scp pass & camera test pass Change-Id: I0d3927b0ee6cc9fa738a063939bcf3d03170493e Signed-off-by: Jungo Lin <Jungo.Lin@mediatek.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1549814 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Commit-Queue: Nicolas Boichat <drinkcat@chromium.org> Tested-by: Nicolas Boichat <drinkcat@chromium.org>
-rw-r--r--board/kukui_scp/build.mk3
-rw-r--r--board/kukui_scp/ec.tasklist2
-rw-r--r--board/kukui_scp/isp_p1_srv.c83
-rw-r--r--board/kukui_scp/isp_p1_srv.h21
4 files changed, 108 insertions, 1 deletions
diff --git a/board/kukui_scp/build.mk b/board/kukui_scp/build.mk
index 238a657487..37e63282e2 100644
--- a/board/kukui_scp/build.mk
+++ b/board/kukui_scp/build.mk
@@ -11,3 +11,6 @@ CHIP_VARIANT:=mt8183
board-y=board.o
board-$(HAS_TASK_VDEC_SERVICE)+=vdec.o
board-$(HAS_TASK_VENC_SERVICE)+=venc.o
+
+# ISP P1
+board-$(HAS_TASK_ISP_SERVICE)+=isp_p1_srv.o
diff --git a/board/kukui_scp/ec.tasklist b/board/kukui_scp/ec.tasklist
index 6a00ce34c9..c500396468 100644
--- a/board/kukui_scp/ec.tasklist
+++ b/board/kukui_scp/ec.tasklist
@@ -20,5 +20,5 @@
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(ISP_SERVICE, isp_service_task, NULL, 880) \
TASK_ALWAYS(CONSOLE, console_task, NULL, LARGER_TASK_STACK_SIZE)
-
diff --git a/board/kukui_scp/isp_p1_srv.c b/board/kukui_scp/isp_p1_srv.c
new file mode 100644
index 0000000000..92048f98c1
--- /dev/null
+++ b/board/kukui_scp/isp_p1_srv.c
@@ -0,0 +1,83 @@
+/* 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 "dma.h"
+#include "hooks.h"
+#include "isp_p1_srv.h"
+#include "task.h"
+#include "queue.h"
+#include "queue_policies.h"
+#include "util.h"
+
+#define CPRINTS(format, args...) cprints(CC_IPI, format, ##args)
+
+/* Forwad declaration. */
+static struct consumer const event_isp_consumer;
+static void event_isp_written(struct consumer const *consumer, size_t count);
+
+static struct queue const event_isp_queue = QUEUE_DIRECT(8,
+ struct isp_msg, null_producer, event_isp_consumer);
+
+static struct consumer const event_isp_consumer = {
+ .queue = &event_isp_queue,
+ .ops = &((struct consumer_ops const) {
+ .written = event_isp_written,
+ }),
+};
+
+/* Stub functions only provided by private overlays. */
+#ifndef HAVE_PRIVATE_MT8183
+void isp_msg_handler(void *data) {}
+#endif
+
+static void event_isp_written(struct consumer const *consumer, size_t count)
+{
+ task_wake(TASK_ID_ISP_SERVICE);
+}
+
+static void isp_ipi_msg_handler(int id, void *data, uint32_t len)
+{
+ struct isp_msg rsv_msg;
+
+ if (!len)
+ 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_isp_queue, &rsv_msg))
+ CPRINTS("Could not send isp %d to the queue", id);
+}
+DECLARE_IPI(IPI_ISP_CMD, isp_ipi_msg_handler, 0);
+DECLARE_IPI(IPI_ISP_FRAME, isp_ipi_msg_handler, 0);
+
+/* This function renames from isp_service_entry. */
+void isp_service_task(void *u)
+{
+ struct isp_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_isp_queue, &rsv_msg);
+ ipi_enable_irq(SCP_IRQ_IPC0);
+
+ if (!size)
+ task_wait_event(-1);
+ else
+ isp_msg_handler(&rsv_msg);
+ }
+}
diff --git a/board/kukui_scp/isp_p1_srv.h b/board/kukui_scp/isp_p1_srv.h
new file mode 100644
index 0000000000..6e262b55e4
--- /dev/null
+++ b/board/kukui_scp/isp_p1_srv.h
@@ -0,0 +1,21 @@
+/* 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_ISP_P1_SRV_H
+#define __CROS_EC_ISP_P1_SRV_H
+
+#include "chip/mt_scp/ipi_chip.h"
+
+struct isp_msg {
+ unsigned char id;
+ unsigned char msg[140];
+};
+
+BUILD_ASSERT(member_size(struct isp_msg, msg) <= CONFIG_IPC_SHARED_OBJ_BUF_SIZE);
+
+/* Functions provided by private overlay. */
+void isp_msg_handler(void *data);
+
+#endif /* __CROS_EC_ISP_P1_SRV_H */