123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- #ifndef __ANC_H__
- #define __ANC_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 __cplusplus
- extern "C" {
- #endif
- #define ANC_IMAGE_NMLEN (12)
- enum {
- ANC_STATUS_POWEROFF,
- ANC_STATUS_POWERON,
- ANC_STATUS_SUSPENDED,
- };
- enum {
- ANC_COMMAND_NONE,
- ANC_COMMAND_ANCTDATA,
- ANC_COMMAND_DUMPSTART,
- ANC_COMMAND_DUMPSTOP,
- ANC_COMMAND_SRCHANGE,
- ANC_COMMAND_POWEROFF,
- ANC_COMMAND_MAX,
- };
- struct anc_imageinfo {
- const char *name;
- const void *ptr;
- size_t size;
- uint32_t entry_point;
- };
- struct anc_bootargs {
- uint32_t cmd_buf;
- uint32_t debug_buf;
- uint32_t audsp_buf;
- uint32_t ack_buf;
- };
- typedef int (*anc_api_poweron)(struct device *dev);
- typedef int (*anc_api_poweroff)(struct device *dev);
- typedef int (*anc_api_request_image)(struct device *dev, const struct anc_imageinfo *image);
- typedef int (*anc_api_release_image)(struct device *dev);
- typedef int (*anc_api_request_mem)(struct device *dev, int type);
- typedef int (*anc_api_release_mem)(struct device *dev, int type);
- typedef int (*anc_api_get_status)(struct device *dev);
- typedef int (*anc_api_send_command)(struct device *dev, int type, void *data, int size);
- struct anc_driver_api {
- anc_api_poweron poweron;
- anc_api_poweroff poweroff;
- anc_api_request_image request_image;
- anc_api_release_image release_image;
- anc_api_request_mem request_mem;
- anc_api_release_mem release_mem;
- anc_api_get_status get_status;
- anc_api_send_command send_command;
- };
- static inline int anc_poweron(struct device *dev)
- {
- const struct anc_driver_api *api = dev->api;
- return api->poweron(dev);
- }
- static inline int anc_poweroff(struct device *dev)
- {
- const struct anc_driver_api *api = dev->api;
- return api->poweroff(dev);
- }
- static inline int anc_request_image(struct device *dev, const struct anc_imageinfo *image)
- {
- const struct anc_driver_api *api = dev->api;
- return api->request_image(dev, image);
- }
- static inline int anc_release_image(struct device *dev)
- {
- const struct anc_driver_api *api = dev->api;
- return api->release_image(dev);
- }
- static inline int anc_request_mem(struct device *dev,int type)
- {
- const struct anc_driver_api *api = dev->api;
- return api->request_mem(dev, type);
- }
- static inline int anc_release_mem(struct device *dev, int type)
- {
- const struct anc_driver_api *api = dev->api;
- return api->release_mem(dev, type);
- }
- static inline int anc_get_status(struct device *dev)
- {
- const struct anc_driver_api *api = dev->api;
- return api->get_status(dev);
- }
- static inline int anc_send_command(struct device *dev, int type, void *data, int size)
- {
- const struct anc_driver_api *api = dev->api;
- return api->send_command(dev, type, data, size);
- }
- static inline int anc_fs_change(struct device *dev, uint32_t samplerate, uint32_t dac_digctl)
- {
- uint32_t data[2];
- const struct anc_driver_api *api = dev->api;
- data[0] = samplerate;
- data[1] = dac_digctl;
- return api->send_command(dev, ANC_COMMAND_SRCHANGE, data, 8);
- }
- #ifdef __cplusplus
- }
- #endif
- #endif
|