engine.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright 2012-15 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #ifndef __DAL_ENGINE_H__
  26. #define __DAL_ENGINE_H__
  27. #include "dc_ddc_types.h"
  28. enum i2caux_transaction_operation {
  29. I2CAUX_TRANSACTION_READ,
  30. I2CAUX_TRANSACTION_WRITE
  31. };
  32. enum i2caux_transaction_address_space {
  33. I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C = 1,
  34. I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD
  35. };
  36. struct i2caux_transaction_payload {
  37. enum i2caux_transaction_address_space address_space;
  38. uint32_t address;
  39. uint32_t length;
  40. uint8_t *data;
  41. };
  42. enum i2caux_transaction_status {
  43. I2CAUX_TRANSACTION_STATUS_UNKNOWN = (-1L),
  44. I2CAUX_TRANSACTION_STATUS_SUCCEEDED,
  45. I2CAUX_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY,
  46. I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT,
  47. I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR,
  48. I2CAUX_TRANSACTION_STATUS_FAILED_NACK,
  49. I2CAUX_TRANSACTION_STATUS_FAILED_INCOMPLETE,
  50. I2CAUX_TRANSACTION_STATUS_FAILED_OPERATION,
  51. I2CAUX_TRANSACTION_STATUS_FAILED_INVALID_OPERATION,
  52. I2CAUX_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW,
  53. I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON
  54. };
  55. struct i2caux_transaction_request {
  56. enum i2caux_transaction_operation operation;
  57. struct i2caux_transaction_payload payload;
  58. enum i2caux_transaction_status status;
  59. };
  60. enum i2caux_engine_type {
  61. I2CAUX_ENGINE_TYPE_UNKNOWN = (-1L),
  62. I2CAUX_ENGINE_TYPE_AUX,
  63. I2CAUX_ENGINE_TYPE_I2C_DDC_HW,
  64. I2CAUX_ENGINE_TYPE_I2C_GENERIC_HW,
  65. I2CAUX_ENGINE_TYPE_I2C_SW
  66. };
  67. enum i2c_default_speed {
  68. I2CAUX_DEFAULT_I2C_HW_SPEED = 50,
  69. I2CAUX_DEFAULT_I2C_SW_SPEED = 50
  70. };
  71. struct engine;
  72. struct engine_funcs {
  73. enum i2caux_engine_type (*get_engine_type)(
  74. const struct engine *engine);
  75. bool (*acquire)(
  76. struct engine *engine,
  77. struct ddc *ddc);
  78. bool (*submit_request)(
  79. struct engine *engine,
  80. struct i2caux_transaction_request *request,
  81. bool middle_of_transaction);
  82. void (*release_engine)(
  83. struct engine *engine);
  84. };
  85. struct engine {
  86. const struct engine_funcs *funcs;
  87. uint32_t inst;
  88. struct ddc *ddc;
  89. struct dc_context *ctx;
  90. };
  91. void dal_i2caux_construct_engine(
  92. struct engine *engine,
  93. struct dc_context *ctx);
  94. void dal_i2caux_destruct_engine(
  95. struct engine *engine);
  96. #endif