123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580 |
- #ifndef __DSP_H__
- #define __DSP_H__
- #include <stddef.h>
- #include <stdint.h>
- #include <sys/types.h>
- #include <zephyr/types.h>
- #include <device.h>
- #include <drivers/cfg_drv/dev_config.h>
- #ifdef CONFIG_LOAD_IMAGE_FROM_FS
- #include <fs/fs.h>
- #endif
- #ifdef __cplusplus
- extern "C" {
- #endif
- enum {
- DSP_IMAGE_MAIN = 0,
- DSP_IMAGE_SUB,
- DSP_NUM_IMAGE_TYPES,
- };
- #define DSP_IMAGE_NMLEN (12)
- typedef int (*dsp_acts_irq_callback)(void *cb_data, u32_t cmd, void *param);
- struct dsp_imageinfo {
- const char *name;
- #ifdef CONFIG_LOAD_IMAGE_FROM_FS
- struct fs_file_t filp;
- #else
- const void *ptr;
- #endif
- size_t size;
- uint32_t entry_point;
- };
- struct dsp_bootargs {
- int32_t power_latency;
- uint32_t command_buffer;
- uint32_t debug_buf;
- uint32_t sub_entry_point;
- };
- enum dsp_msg_id {
- DSP_MSG_NULL = 0,
-
- DSP_MSG_REQUEST_BOOTARGS,
-
- DSP_MSG_STATE_CHANGED,
- DSP_MSG_PAGE_MISS,
- DSP_MSG_PAGE_FLUSH,
-
- DSP_MSG_SUSPEND,
- DSP_MSG_RESUME,
-
- DSP_MSG_KICK,
-
- DSP_MSG_USER_DEFINED,
- };
- #define DSP_NEED_SYNC_CLOCK 0x434C4B
- #define DSP_SYNC_CLOCK_NULL 0
- #define DSP_SYNC_CLOCK_START 1
- #define DSP_SYNC_CLOCK_REPLY 2
- #define DSP_SYNC_CLOCK_OFFSET 3
- enum dsp_msg_event {
- DSP_EVENT_NEW_CMD = 0,
- DSP_EVENT_NEW_DATA,
- DSP_EVENT_FENCE_SYNC,
- DSP_EVENT_USER_DEFINED,
- };
- enum dsp_msg_result {
- DSP_NOACK = -2,
- DSP_FAIL = -1,
- DSP_NOTOUCH = 0,
- DSP_INPROGRESS,
- DSP_DONE,
- DSP_REPLY,
- };
- struct dsp_message {
-
- uint16_t id;
-
- int16_t result;
-
- uint32_t owner;
-
- uint32_t param1;
- uint32_t param2;
- };
- enum dsp_cmd_id {
-
- DSP_CMD_NULL = 0,
- DSP_CMD_SET_SESSION = 1,
- DSP_CMD_CONSOLE_DSPLOAD = 0x10,
- DSP_CMD_CONSOLE_MDW,
- DSP_CMD_CONSOLE_MDH,
- DSP_CMD_CONSOLE_MWW,
- DSP_CMD_CONSOLE_MWH,
- DSP_CMD_CONSOLE_RIN,
- DSP_CMD_CONSOLE_ROUT,
- DSP_CMD_CONSOLE_MAX,
- };
- struct dsp_session_id_set {
- uint32_t id;
- uint32_t uuid;
- uint32_t func_allowed;
- };
- struct dsp_command_buffer {
-
- uint16_t cur_seq;
-
- uint16_t alloc_seq;
-
- uint32_t cpu_bufptr;
- uint32_t dsp_bufptr;
- };
- struct dsp_command {
-
- uint16_t id;
-
- uint16_t seq;
-
- uint32_t sem;
-
- uint32_t size;
- uint32_t data[0];
- };
- static inline size_t sizeof_dsp_command(struct dsp_command *command)
- {
- return sizeof(*command) + command->size;
- }
- enum dsp_request_type {
- DSP_REQUEST_TASK_STATE,
- DSP_REQUEST_ERROR_CODE,
- DSP_REQUEST_SESSION_INFO,
- DSP_REQUEST_FUNCTION_INFO,
- DSP_REQUEST_USER_DEFINED,
- };
- enum dsp_task_state {
- DSP_TASK_PRESTART = -1,
- DSP_TASK_STARTED = 0,
- DSP_TASK_PENDING,
- DSP_TASK_RUNNING,
- DSP_TASK_SUSPENDED,
- DSP_TASK_DEAD,
- DSP_TASK_IDLE = DSP_TASK_PENDING,
- DSP_TASK_RESUMED = DSP_TASK_RUNNING,
- };
- enum dsp_error {
- DSP_NO_ERROR = 0,
- DSP_BAD_BOOTARGS,
- DSP_BAD_COMMAND,
- DSP_BAD_SESSION,
- DSP_BAD_FUNCTION,
- DSP_BAD_PARAMETER,
- DSP_ERR_USER_DEFINED,
- };
- struct dsp_request_session {
- uint32_t func_enabled;
- uint32_t func_counter;
- void *info;
- uint32_t func_runnable;
- };
- struct dsp_request_function {
- unsigned int id;
- void *info;
- };
- typedef int (*dsp_api_poweron)(struct device *dev, void *cmdbuf);
- typedef int (*dsp_api_poweroff)(struct device *dev);
- typedef int (*dsp_api_suspend)(struct device *dev);
- typedef int (*dsp_api_resume)(struct device *dev);
- typedef int (*dsp_api_kick)(struct device *dev, uint32_t owner, uint32_t event, uint32_t params);
- typedef int (*dsp_api_request_image)(struct device *dev, const struct dsp_imageinfo *image, int type);
- typedef int (*dsp_api_release_image)(struct device *dev, int type);
- typedef int (*dsp_api_request_mem)(struct device *dev, int type);
- typedef int (*dsp_api_release_mem)(struct device *dev, int type);
- typedef int (*dsp_message_handler)(struct dsp_message *msg);
- typedef int (*dsp_api_register_message_handler)(struct device *dev, dsp_message_handler handler);
- typedef int (*dsp_api_unregister_message_handler)(struct device *dev);
- typedef int (*dsp_api_send_message)(struct device *dev, struct dsp_message *msg);
- typedef int (*dsp_acts_request_userinfo)(struct device *dev, int request, void *info);
- struct dsp_driver_api {
- dsp_api_poweron poweron;
- dsp_api_poweroff poweroff;
- dsp_api_suspend suspend;
- dsp_api_resume resume;
- dsp_api_kick kick;
- dsp_api_register_message_handler register_message_handler;
- dsp_api_unregister_message_handler unregister_message_handler;
- dsp_api_request_image request_image;
- dsp_api_release_image release_image;
- dsp_api_request_mem request_mem;
- dsp_api_release_mem release_mem;
- dsp_api_send_message send_message;
- dsp_acts_request_userinfo request_userinfo;
- };
- static inline int dsp_poweron(struct device *dev, void *cmdbuf)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->poweron(dev, cmdbuf);
- }
- static inline int dsp_poweroff(struct device *dev)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->poweroff(dev);
- }
- static inline int dsp_suspend(struct device *dev)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->suspend(dev);
- }
- static inline int dsp_resume(struct device *dev)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->resume(dev);
- }
- static inline int dsp_kick(struct device *dev, unsigned int owner, unsigned int event, unsigned int params)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->kick(dev, owner, event, params);
- }
- static inline int dsp_request_image(struct device *dev, const struct dsp_imageinfo *image, int type)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->request_image(dev, image, type);
- }
- static inline int dsp_release_image(struct device *dev, int type)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->release_image(dev, type);
- }
- static inline int dsp_request_mem(struct device *dev,int type)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->request_mem(dev, type);
- }
- static inline int dsp_release_mem(struct device *dev, int type)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->release_mem(dev, type);
- }
- static inline int dsp_register_message_handler(struct device *dev, dsp_message_handler handler)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->register_message_handler(dev, handler);
- }
- static inline int dsp_unregister_message_handler(struct device *dev)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->unregister_message_handler(dev);
- }
- static inline int dsp_send_message(struct device *dev, struct dsp_message *msg)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->send_message(dev, msg);
- }
- static inline int dsp_request_userinfo(struct device *dev, int request, void *info)
- {
- const struct dsp_driver_api *api = dev->api;
- return api->request_userinfo(dev, request, info);
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|