msm_vidc.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #ifndef _MSM_VIDC_H_
  14. #define _MSM_VIDC_H_
  15. #include <linux/poll.h>
  16. #include <linux/videodev2.h>
  17. #include <linux/types.h>
  18. #include <linux/msm_ion.h>
  19. #include <uapi/media/msm_vidc.h>
  20. #define HAL_BUFFER_MAX 0xd
  21. enum smem_type {
  22. SMEM_ION,
  23. };
  24. enum smem_prop {
  25. SMEM_CACHED,
  26. SMEM_SECURE,
  27. };
  28. /* NOTE: if you change this enum you MUST update the
  29. * "buffer-type-tz-usage-table" for any affected target
  30. * in arch/arm/boot/dts/<arch>.dtsi
  31. */
  32. enum hal_buffer {
  33. HAL_BUFFER_NONE = 0x0,
  34. HAL_BUFFER_INPUT = 0x1,
  35. HAL_BUFFER_OUTPUT = 0x2,
  36. HAL_BUFFER_OUTPUT2 = 0x4,
  37. HAL_BUFFER_EXTRADATA_INPUT = 0x8,
  38. HAL_BUFFER_EXTRADATA_OUTPUT = 0x10,
  39. HAL_BUFFER_EXTRADATA_OUTPUT2 = 0x20,
  40. HAL_BUFFER_INTERNAL_SCRATCH = 0x40,
  41. HAL_BUFFER_INTERNAL_SCRATCH_1 = 0x80,
  42. HAL_BUFFER_INTERNAL_SCRATCH_2 = 0x100,
  43. HAL_BUFFER_INTERNAL_PERSIST = 0x200,
  44. HAL_BUFFER_INTERNAL_PERSIST_1 = 0x400,
  45. HAL_BUFFER_INTERNAL_CMD_QUEUE = 0x800,
  46. HAL_BUFFER_INTERNAL_RECON = 0x1000,
  47. };
  48. struct dma_mapping_info {
  49. struct device *dev;
  50. struct dma_iommu_mapping *mapping;
  51. struct sg_table *table;
  52. struct dma_buf_attachment *attach;
  53. struct dma_buf *buf;
  54. };
  55. struct msm_smem {
  56. u32 refcount;
  57. int fd;
  58. void *dma_buf;
  59. void *handle;
  60. void *kvaddr;
  61. u32 device_addr;
  62. unsigned int offset;
  63. unsigned int size;
  64. unsigned long flags;
  65. enum hal_buffer buffer_type;
  66. struct dma_mapping_info mapping_info;
  67. int mem_type;
  68. void *smem_priv;
  69. };
  70. enum smem_cache_ops {
  71. SMEM_CACHE_CLEAN,
  72. SMEM_CACHE_INVALIDATE,
  73. SMEM_CACHE_CLEAN_INVALIDATE,
  74. };
  75. enum core_id {
  76. MSM_VIDC_CORE_VENUS = 0,
  77. MSM_VIDC_CORE_Q6,
  78. MSM_VIDC_CORES_MAX,
  79. };
  80. enum session_type {
  81. MSM_VIDC_ENCODER = 0,
  82. MSM_VIDC_DECODER,
  83. MSM_VIDC_UNKNOWN,
  84. MSM_VIDC_MAX_DEVICES = MSM_VIDC_UNKNOWN,
  85. };
  86. union msm_v4l2_cmd {
  87. struct v4l2_decoder_cmd dec;
  88. struct v4l2_encoder_cmd enc;
  89. };
  90. void *msm_vidc_open(int core_id, int session_type);
  91. int msm_vidc_close(void *instance);
  92. int msm_vidc_suspend(int core_id);
  93. int msm_vidc_querycap(void *instance, struct v4l2_capability *cap);
  94. int msm_vidc_enum_fmt(void *instance, struct v4l2_fmtdesc *f);
  95. int msm_vidc_s_fmt(void *instance, struct v4l2_format *f);
  96. int msm_vidc_g_fmt(void *instance, struct v4l2_format *f);
  97. int msm_vidc_release_buffers(void *instance, int buffer_type);
  98. int msm_vidc_prepare_buf(void *instance, struct v4l2_buffer *b);
  99. int msm_vidc_s_ctrl(void *instance, struct v4l2_control *a);
  100. int msm_vidc_s_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
  101. int msm_vidc_g_ext_ctrl(void *instance, struct v4l2_ext_controls *a);
  102. int msm_vidc_g_ctrl(void *instance, struct v4l2_control *a);
  103. int msm_vidc_reqbufs(void *instance, struct v4l2_requestbuffers *b);
  104. int msm_vidc_release_buffer(void *instance, int buffer_type,
  105. unsigned int buffer_index);
  106. int msm_vidc_qbuf(void *instance, struct v4l2_buffer *b);
  107. int msm_vidc_dqbuf(void *instance, struct v4l2_buffer *b);
  108. int msm_vidc_streamon(void *instance, enum v4l2_buf_type i);
  109. int msm_vidc_query_ctrl(void *instance, struct v4l2_queryctrl *ctrl);
  110. int msm_vidc_streamoff(void *instance, enum v4l2_buf_type i);
  111. int msm_vidc_comm_cmd(void *instance, union msm_v4l2_cmd *cmd);
  112. int msm_vidc_poll(void *instance, struct file *filp,
  113. struct poll_table_struct *pt);
  114. int msm_vidc_subscribe_event(void *instance,
  115. const struct v4l2_event_subscription *sub);
  116. int msm_vidc_unsubscribe_event(void *instance,
  117. const struct v4l2_event_subscription *sub);
  118. int msm_vidc_dqevent(void *instance, struct v4l2_event *event);
  119. int msm_vidc_g_crop(void *instance, struct v4l2_crop *a);
  120. int msm_vidc_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
  121. #endif