PD Buddy Sink Firmware
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

pdb_dpm.h 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * PD Buddy - USB Power Delivery for everyone
  3. * Copyright (C) 2017 Clayton G. Hobbs <clay@lakeserv.net>
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef PDB_DPM_H
  19. #define PDB_DPM_H
  20. #include <stdbool.h>
  21. /* TODO: improve these includes */
  22. #include "fusb302b.h"
  23. #include "messages.h"
  24. /* Forward declaration of struct pdb_config */
  25. struct pdb_config;
  26. /* DPM callback typedefs */
  27. typedef void (*pdb_dpm_func)(struct pdb_config *);
  28. typedef bool (*pdb_dpm_eval_cap_func)(struct pdb_config *,
  29. const union pd_msg *, union pd_msg *);
  30. typedef void (*pdb_dpm_get_sink_cap_func)(struct pdb_config *, union pd_msg *);
  31. typedef bool (*pdb_dpm_giveback_func)(struct pdb_config *);
  32. typedef bool (*pdb_dpm_tcc_func)(struct pdb_config *, enum fusb_typec_current);
  33. /*
  34. * PD Buddy firmware library device policy manager callback structure
  35. *
  36. * Optional functions may be set to NULL if the associated functionality is not
  37. * required.
  38. */
  39. struct pdb_dpm_callbacks {
  40. pdb_dpm_eval_cap_func evaluate_capability;
  41. pdb_dpm_get_sink_cap_func get_sink_capability;
  42. pdb_dpm_giveback_func giveback_enabled;
  43. pdb_dpm_tcc_func evaluate_typec_current; /* Optional */
  44. pdb_dpm_func pd_start; /* Optional */
  45. /* dpm_sink_standby is called in PE_SNK_Select_Capability to ensure power
  46. * consumption is less than 2.5 W.
  47. * - dpm_transition_standby()
  48. */
  49. /* dpm_output_set is called in five places:
  50. * - PS_RDY received → transition sink power supply to our request
  51. * - This could mean what we wanted, or what we had to settle for, so
  52. * we have to remember.
  53. * - dpm_transition_requested()
  54. * - Protocol error in PE_SNK_Transition_Sink
  55. * - Unnecessary? If we really want to be defensive here, just go to
  56. * default output, right? That's what we'll do shortly afterwards
  57. * anyway.
  58. * - dpm_transition_default()
  59. * - GotoMin received and giveback → transition sink to min power
  60. * - dpm_transition_min()
  61. * - Transition sink power supply to match Type-C Current advertisement
  62. * - dpm_transition_typec() (if I don't like it I can change it)
  63. * - Part of dpm_output_default
  64. * - Obsolete (see below)
  65. */
  66. /* dpm_output_default is only called in PE_SNK_Transition_to_Default.
  67. * Should probably be part of new improved replacement for dpm_output_set.
  68. * - dpm_transition_default()
  69. */
  70. pdb_dpm_func transition_default;
  71. pdb_dpm_func transition_min; /* Optional if no GiveBack */
  72. pdb_dpm_func transition_standby;
  73. pdb_dpm_func transition_requested;
  74. pdb_dpm_func transition_typec; /* Optional */
  75. };
  76. #endif /* PDB_DPM_H */