adf.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2013 Google, Inc.
  3. *
  4. * This software is licensed under the terms of the GNU General Public
  5. * License version 2, as published by the Free Software Foundation, and
  6. * may be copied, distributed, and modified under those terms.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. */
  14. #ifndef __VIDEO_ADF_ADF_H
  15. #define __VIDEO_ADF_ADF_H
  16. #include <linux/idr.h>
  17. #include <linux/list.h>
  18. #include <video/adf.h>
  19. #include "sync.h"
  20. struct adf_event_refcount {
  21. struct rb_node node;
  22. enum adf_event_type type;
  23. int refcount;
  24. };
  25. void adf_buffer_cleanup(struct adf_buffer *buf);
  26. void adf_buffer_mapping_cleanup(struct adf_buffer_mapping *mapping,
  27. struct adf_buffer *buf);
  28. void adf_post_cleanup(struct adf_device *dev, struct adf_pending_post *post);
  29. struct adf_attachment_list *adf_attachment_find(struct list_head *list,
  30. struct adf_overlay_engine *eng, struct adf_interface *intf);
  31. int adf_attachment_validate(struct adf_device *dev,
  32. struct adf_overlay_engine *eng, struct adf_interface *intf);
  33. void adf_attachment_free(struct adf_attachment_list *attachment);
  34. struct adf_event_refcount *adf_obj_find_event_refcount(struct adf_obj *obj,
  35. enum adf_event_type type);
  36. static inline int adf_obj_check_supports_event(struct adf_obj *obj,
  37. enum adf_event_type type)
  38. {
  39. if (!obj->ops || !obj->ops->supports_event)
  40. return -EOPNOTSUPP;
  41. if (!obj->ops->supports_event(obj, type))
  42. return -EINVAL;
  43. return 0;
  44. }
  45. static inline int adf_device_attach_op(struct adf_device *dev,
  46. struct adf_overlay_engine *eng, struct adf_interface *intf)
  47. {
  48. if (!dev->ops->attach)
  49. return 0;
  50. return dev->ops->attach(dev, eng, intf);
  51. }
  52. static inline int adf_device_detach_op(struct adf_device *dev,
  53. struct adf_overlay_engine *eng, struct adf_interface *intf)
  54. {
  55. if (!dev->ops->detach)
  56. return 0;
  57. return dev->ops->detach(dev, eng, intf);
  58. }
  59. #endif /* __VIDEO_ADF_ADF_H */