summaryrefslogtreecommitdiff
path: root/gxp-client.h
diff options
context:
space:
mode:
Diffstat (limited to 'gxp-client.h')
-rw-r--r--gxp-client.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/gxp-client.h b/gxp-client.h
new file mode 100644
index 0000000..97ba489
--- /dev/null
+++ b/gxp-client.h
@@ -0,0 +1,50 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * GXP client structure.
+ *
+ * Copyright (C) 2022 Google LLC
+ */
+#ifndef __GXP_CLIENT_H__
+#define __GXP_CLIENT_H__
+
+#include <linux/rwsem.h>
+#include <linux/types.h>
+
+#include "gxp-internal.h"
+#include "gxp-vd.h"
+
+/* Holds state belonging to a client */
+struct gxp_client {
+ struct gxp_dev *gxp;
+
+ /*
+ * Protects all state of this client instance.
+ * Any operation that requires a client hold a particular wakelock must
+ * lock this semaphore for reading for the duration of that operation.
+ */
+ struct rw_semaphore semaphore;
+
+ bool has_block_wakelock;
+ bool has_vd_wakelock;
+ /* Value is one of the GXP_POWER_STATE_* values from gxp.h. */
+ uint requested_power_state;
+ /* Value is one of the MEMORY_POWER_STATE_* values from gxp.h. */
+ uint requested_memory_power_state;
+
+ struct gxp_virtual_device *vd;
+ bool tpu_mbx_allocated;
+ struct gxp_tpu_mbx_desc mbx_desc;
+};
+
+/*
+ * Allocates and initializes a client container.
+ */
+struct gxp_client *gxp_client_create(struct gxp_dev *gxp);
+
+/*
+ * Frees up the client container cleaning up any wakelocks, virtual devices, or
+ * TPU mailboxes it holds.
+ */
+void gxp_client_destroy(struct gxp_client *client);
+
+#endif /* __GXP_CLIENT_H__ */