This library enables applications to send and receive MCDI data over rpmsg transport.
This library exposes two types of APIs to applications, these are listed below
- APIs to open and close the file descriptor on the rpmsg end point.
- APIs to encode an MCDI command and decode the MCDI response.
Rpmsg end points shall be created before running the applications using this library. An example application which creates Rpmsg endpoints for all the available CDX devices is provided at MCDI INIT APP.
Following APIs are exposed to applications for opening and closing of file descriptors on rpmsg end points.
- int mcdi_create_device_ep(u16 bus_id, u16 dev_id)
- Finds an rpmsg end point using bus, device ID.
- Opens an file descriptor on the found rpmsg end point in above step and returns the created file descriptor to application.
- void mcdi_destroy_device_ep(int fd)
- closes the given file descriptor.
- Applications should destroy/close the file descriptor opened using mcdi_create_device_ep().
This library also provides two functions for each command, one to encode the MCDI command and another to decode the MCDI response.
There are two options for encode and decode APIs, these are
- APIs with structures as arguments
- Which takes input/output parameters as structures.
- APIs with individual variables as arguments.
- Which takes input/output parameters as individual variables.
Both types of APIs are exposed just as an example in this release and based on MSFT feedback one of these can be removed in future releases.
Refer to doxygen documentation of mcdi_lib.h from MCDI library for extensive details of all the APIs supported by this library.
As an example, encode and decode APIs for version command are given below.
Following are the APIs taking structure as arguments.
int mc_cmd_get_version_ext_enc(void *buf, size_t bufsize, mc_cmd_get_version_ext_enc_t *msg);
int mc_cmd_get_version_v5_dec(void *buf, size_t bufsize, mc_cmd_get_version_v5_dec_t *msg);
Following are the APIs taking variables as arguments.
int mc_cmd_get_version_ext_enc2(void *buf, size_t bufsize, uint32_t ext_flags);
int mc_cmd_get_version_v5_dec2( void *buf, size_t bufsize, ....);
Applications using this library shall follow below steps.
- Open an file descriptor using mcdi_create_device_ep().
- Encode the command using the encode API of the particular command to be tested.
- Send the encoded buffer using the file descriptor opened in above step.
- Receive the MCDI response buffer by reading the file descriptor opened in above step.
- Pass the received buffer on to the decode function of the particular MCDI command to convert the data into application usable format.
- Close the file descriptor using mcdi_destroy_device_ep().
NOTE: Limited testing is performed. This library is for demonstration purpose only and will not be upstreamed.