video_bridge.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Copyright (C) 2015 Google, Inc
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #ifndef __VIDEO_BRIDGE
  7. #define __VIDEO_BRIDGE
  8. #include <asm/gpio.h>
  9. /**
  10. * struct video_bridge_priv - uclass information for video bridges
  11. *
  12. * @sleep: GPIO to assert to power down the bridge
  13. * @reset: GPIO to assert to reset the bridge
  14. * @hotplug: Optional GPIO to check if bridge is connected
  15. */
  16. struct video_bridge_priv {
  17. struct gpio_desc sleep;
  18. struct gpio_desc reset;
  19. struct gpio_desc hotplug;
  20. };
  21. /**
  22. * Operations for video bridges
  23. */
  24. struct video_bridge_ops {
  25. /**
  26. * attach() - attach a video bridge
  27. *
  28. * @return 0 if OK, -ve on error
  29. */
  30. int (*attach)(struct udevice *dev);
  31. /**
  32. * check_attached() - check if a bridge is correctly attached
  33. *
  34. * This method is optional - if not provided then the hotplug GPIO
  35. * will be checked instead.
  36. *
  37. * @dev: Device to check
  38. * @return 0 if attached, -EENOTCONN if not, or other -ve error
  39. */
  40. int (*check_attached)(struct udevice *dev);
  41. /**
  42. * set_backlight() - Set the backlight brightness
  43. *
  44. * @dev: device to adjust
  45. * @percent: brightness percentage (0=off, 100=full brightness)
  46. * @return 0 if OK, -ve on error
  47. */
  48. int (*set_backlight)(struct udevice *dev, int percent);
  49. /**
  50. * read_edid() - Read information from EDID
  51. *
  52. * @dev: Device to read from
  53. * @buf: Buffer to read into
  54. * @buf_size: Buffer size
  55. * @return number of bytes read, <=0 for error
  56. */
  57. int (*read_edid)(struct udevice *dev, u8 *buf, int buf_size);
  58. };
  59. #define video_bridge_get_ops(dev) \
  60. ((struct video_bridge_ops *)(dev)->driver->ops)
  61. /**
  62. * video_bridge_attach() - attach a video bridge
  63. *
  64. * @return 0 if OK, -ve on error
  65. */
  66. int video_bridge_attach(struct udevice *dev);
  67. /**
  68. * video_bridge_set_backlight() - Set the backlight brightness
  69. *
  70. * @percent: brightness percentage (0=off, 100=full brightness)
  71. * @return 0 if OK, -ve on error
  72. */
  73. int video_bridge_set_backlight(struct udevice *dev, int percent);
  74. /**
  75. * video_bridge_set_active() - take the bridge in/out of reset/powerdown
  76. *
  77. * @dev: Device to adjust
  78. * @active: true to power up and reset, false to power down
  79. */
  80. int video_bridge_set_active(struct udevice *dev, bool active);
  81. /**
  82. * check_attached() - check if a bridge is correctly attached
  83. *
  84. * @dev: Device to check
  85. * @return 0 if attached, -EENOTCONN if not, or other -ve error
  86. */
  87. int video_bridge_check_attached(struct udevice *dev);
  88. /**
  89. * video_bridge_read_edid() - Read information from EDID
  90. *
  91. * @dev: Device to read from
  92. * @buf: Buffer to read into
  93. * @buf_size: Buffer size
  94. * @return number of bytes read, <=0 for error
  95. */
  96. int video_bridge_read_edid(struct udevice *dev, u8 *buf, int buf_size);
  97. #endif