csi_ioctl.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /****************************************************************************
  2. *
  3. * The MIT License (MIT)
  4. *
  5. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  22. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  23. * DEALINGS IN THE SOFTWARE.
  24. *
  25. *****************************************************************************
  26. *
  27. * The GPL License (GPL)
  28. *
  29. * Copyright (c) 2020 VeriSilicon Holdings Co., Ltd.
  30. *
  31. * This program is free software; you can redistribute it and/or
  32. * modify it under the terms of the GNU General Public License
  33. * as published by the Free Software Foundation; either version 2
  34. * of the License, or (at your option) any later version.
  35. *
  36. * This program is distributed in the hope that it will be useful,
  37. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. * GNU General Public License for more details.
  40. *
  41. * You should have received a copy of the GNU General Public License
  42. * along with this program;
  43. *
  44. *****************************************************************************
  45. *
  46. * Note: This software is released under dual MIT and GPL licenses. A
  47. * recipient may use this file under the terms of either the MIT license or
  48. * GPL License. If you wish to use only one license not the other, you can
  49. * indicate your decision by deleting one of the above license notices in your
  50. * version of this file.
  51. *
  52. *****************************************************************************/
  53. #ifndef _CSI_IOC_H_
  54. #define _CSI_IOC_H_
  55. #ifndef __KERNEL__
  56. #include <stdint.h>
  57. #endif
  58. #include <linux/ioctl.h>
  59. enum {
  60. VVCSI_IOC_S_RESET = _IO('r', 0),
  61. VVCSI_IOC_S_POWER,
  62. VVCSI_IOC_G_POWER,
  63. VVCSI_IOC_S_CLOCK,
  64. VVCSI_IOC_G_CLOCK,
  65. VVCSI_IOC_S_STREAM,
  66. VVCSI_IOC_G_STREAM,
  67. VVCSI_IOC_S_FMT,
  68. VVCSI_IOC_G_FMT,
  69. VVCSI_IOC_S_VC_SELECT,
  70. VVCSI_IOC_G_VC_SELECT,
  71. VVCSI_IOC_S_LANE_CFG,
  72. VVCSI_IOC_S_BIT_SHIFT,
  73. VVCSI_IOC_MAX,
  74. };
  75. struct csi_vc_select_context {
  76. uint32_t csi_vc_select_mode;
  77. uint32_t vc_channel;
  78. };
  79. struct csi_format_context {
  80. uint32_t format;
  81. uint32_t width;
  82. uint32_t height;
  83. };
  84. struct vvcam_csi_hardware_function_s
  85. {
  86. int (*init)(void* dev);
  87. int (*exit)(void* dev);
  88. int (*reset)(void* dev);
  89. int (*set_power)(void* dev);
  90. int (*get_power)(void* dev);
  91. int (*set_clock)(void* dev);
  92. int (*get_clock)(void* dev);
  93. int (*set_stream_control)(void* dev);
  94. int (*get_stream_control)(void* dev);
  95. int (*set_fmt)(void* dev);
  96. int (*get_fmt)(void* dev);
  97. int (*set_vc_select)(void* dev);
  98. int (*get_vc_select)(void* dev);
  99. int (*set_lane_cfg)(void* dev);
  100. };
  101. struct vvcam_csi_lane_cfg
  102. {
  103. uint32_t mipi_lane_num;
  104. };
  105. #ifdef __KERNEL__
  106. struct vvcam_csi_dev {
  107. void __iomem *base;
  108. char name[16];
  109. int present;
  110. int device_idx;
  111. uint32_t power_status;
  112. uint32_t clock;
  113. uint32_t bit_width;
  114. uint32_t streaming_enable;
  115. struct csi_vc_select_context csi_vc_select;
  116. struct csi_format_context csi_format;
  117. struct vvcam_csi_hardware_function_s csi_hard_func;
  118. struct vvcam_csi_lane_cfg csi_lane_cfg;
  119. void * csi_private;
  120. };
  121. // internal functions
  122. long csi_priv_ioctl(struct vvcam_csi_dev *dev, unsigned int cmd, void __user *args);
  123. #else
  124. //User space connections
  125. #endif
  126. #endif // _CSI_IOC_H_