usbd_mtp.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2025, sakumisu
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef USBD_MTP_H
  7. #define USBD_MTP_H
  8. #include "usb_mtp.h"
  9. #include <sys/stat.h>
  10. #include <fcntl.h>
  11. /* gcc toolchain does not implement dirent.h, so we define our own MTP_DIR and mtp_dirent */
  12. typedef void MTP_DIR;
  13. struct mtp_statfs {
  14. size_t f_bsize; /* block size */
  15. size_t f_blocks; /* total data blocks in file system */
  16. size_t f_bfree; /* free blocks in file system */
  17. };
  18. struct mtp_dirent {
  19. uint8_t d_type; /* The type of the file */
  20. uint8_t d_namlen; /* The length of the not including the terminating null file name */
  21. uint16_t d_reclen; /* length of this record */
  22. char d_name[CONFIG_USBDEV_MTP_MAX_PATHNAME]; /* The null-terminated file name */
  23. };
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. struct usbd_interface *usbd_mtp_init_intf(struct usbd_interface *intf,
  28. const uint8_t out_ep,
  29. const uint8_t in_ep,
  30. const uint8_t int_ep);
  31. int usbd_mtp_notify_object_add(const char *path);
  32. int usbd_mtp_notify_object_remove(const char *path);
  33. const char *usbd_mtp_fs_root_path(void);
  34. const char *usbd_mtp_fs_description(void);
  35. int usbd_mtp_mkdir(const char *path);
  36. int usbd_mtp_rmdir(const char *path);
  37. MTP_DIR *usbd_mtp_opendir(const char *name);
  38. int usbd_mtp_closedir(MTP_DIR *d);
  39. struct mtp_dirent *usbd_mtp_readdir(MTP_DIR *d);
  40. int usbd_mtp_statfs(const char *path, struct mtp_statfs *buf);
  41. int usbd_mtp_stat(const char *file, struct stat *buf);
  42. int usbd_mtp_open(const char *path, uint8_t mode);
  43. int usbd_mtp_close(int fd);
  44. int usbd_mtp_read(int fd, void *buf, size_t len);
  45. int usbd_mtp_write(int fd, const void *buf, size_t len);
  46. int usbd_mtp_unlink(const char *path);
  47. #ifdef __cplusplus
  48. }
  49. #endif
  50. #endif /* USBD_MTP_H */