enc-subdev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* Copyright (c) 2012-2013, 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 _WFD_ENC_SUBDEV_
  14. #define _WFD_ENC_SUBDEV_
  15. #include <linux/list.h>
  16. #include <linux/msm_ion.h>
  17. #include <media/v4l2-subdev.h>
  18. #include <media/videobuf2-core.h>
  19. #define VENC_MAGIC_IOCTL 'V'
  20. enum venc_framerate_modes {
  21. VENC_MODE_CFR,
  22. VENC_MODE_VFR,
  23. };
  24. enum venc_event {
  25. VENC_EVENT_HARDWARE_ERROR,
  26. };
  27. struct mem_region {
  28. struct list_head list;
  29. u8 *kvaddr;
  30. u8 *paddr;
  31. u32 size;
  32. u32 offset;
  33. u32 fd;
  34. u32 cookie;
  35. struct ion_handle *ion_handle;
  36. };
  37. /* FIXME: need to come with a less stupid name */
  38. struct mem_region_map {
  39. struct mem_region *mregion;
  40. struct ion_client *ion_client;
  41. uint32_t flags;
  42. void *cookie;
  43. };
  44. struct bufreq {
  45. u32 count;
  46. u32 height;
  47. u32 width;
  48. u32 size;
  49. };
  50. struct venc_buf_info {
  51. u64 timestamp;
  52. struct mem_region *mregion;
  53. };
  54. struct venc_msg_ops {
  55. void *cookie;
  56. void *cbdata;
  57. bool secure;
  58. void (*op_buffer_done)(void *cookie, u32 status,
  59. struct vb2_buffer *buf);
  60. void (*ip_buffer_done)(void *cookie, u32 status,
  61. struct mem_region *mregion);
  62. void (*on_event)(void *cookie, enum venc_event e);
  63. };
  64. static inline bool mem_region_equals(struct mem_region *a,
  65. struct mem_region *b)
  66. {
  67. if (a == b)
  68. return true;
  69. else if (a->fd || b->fd)
  70. return (a->fd == b->fd) &&
  71. (a->offset == b->offset);
  72. else if (a->kvaddr || b->kvaddr)
  73. return a->kvaddr == b->kvaddr;
  74. else if (a->paddr || b->paddr)
  75. return a->paddr == b->paddr;
  76. else
  77. return false;
  78. }
  79. #define OPEN _IOR('V', 1, void *)
  80. #define CLOSE _IO('V', 2)
  81. #define ENCODE_START _IO('V', 3)
  82. #define ENCODE_FRAME _IOW('V', 4, struct venc_buf_info *)
  83. #define PAUSE _IO('V', 5)
  84. #define RESUME _IO('V', 6)
  85. #define FLUSH _IO('V', 7)
  86. #define ENCODE_STOP _IO('V', 8)
  87. #define SET_PROP _IO('V', 9)
  88. #define GET_PROP _IO('V', 10)
  89. #define SET_BUFFER_REQ _IOWR('V', 11, struct v4l2_requestbuffers *)
  90. #define GET_BUFFER_REQ _IOWR('V', 12, struct v4l2_requestbuffers *)
  91. #define ALLOCATE_BUFFER _IO('V', 13)
  92. #define FREE_BUFFER _IO('V', 14)
  93. #define FILL_OUTPUT_BUFFER _IO('V', 15)
  94. #define SET_FORMAT _IOW('V', 16, struct v4l2_format *)
  95. #define SET_FRAMERATE _IOW('V', 17, struct v4l2_fract *)
  96. #define SET_INPUT_BUFFER _IOWR('V', 18, struct mem_region *)
  97. #define SET_OUTPUT_BUFFER _IOWR('V', 19, struct mem_region *)
  98. #define ALLOC_RECON_BUFFERS _IO('V', 20)
  99. #define FREE_OUTPUT_BUFFER _IOWR('V', 21, struct mem_region *)
  100. #define FREE_INPUT_BUFFER _IOWR('V', 22, struct mem_region *)
  101. #define FREE_RECON_BUFFERS _IO('V', 23)
  102. #define ENCODE_FLUSH _IO('V', 24)
  103. #define ENC_MMAP _IOWR('V', 25, struct mem_region_map *)
  104. #define ENC_MUNMAP _IOWR('V', 26, struct mem_region_map *)
  105. #define SET_FRAMERATE_MODE _IO('V', 27)
  106. #define ENC_SECURE _IO('V', 28)
  107. extern int venc_init(struct v4l2_subdev *sd, u32 val);
  108. extern int venc_load_fw(struct v4l2_subdev *sd);
  109. extern long venc_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg);
  110. #endif /* _WFD_ENC_SUBDEV_ */