ispstat.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * ispstat.h
  3. *
  4. * TI OMAP3 ISP - Statistics core
  5. *
  6. * Copyright (C) 2010 Nokia Corporation
  7. * Copyright (C) 2009 Texas Instruments, Inc
  8. *
  9. * Contacts: David Cohen <dacohen@gmail.com>
  10. * Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  11. * Sakari Ailus <sakari.ailus@iki.fi>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License version 2 as
  15. * published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful, but
  18. * WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  25. * 02110-1301 USA
  26. */
  27. #ifndef OMAP3_ISP_STAT_H
  28. #define OMAP3_ISP_STAT_H
  29. #include <linux/types.h>
  30. #include <linux/omap3isp.h>
  31. #include <plat/dma.h>
  32. #include <media/v4l2-event.h>
  33. #include "isp.h"
  34. #include "ispvideo.h"
  35. #define STAT_MAX_BUFS 5
  36. #define STAT_NEVENTS 8
  37. #define STAT_BUF_DONE 0 /* Buffer is ready */
  38. #define STAT_NO_BUF 1 /* An error has occurred */
  39. #define STAT_BUF_WAITING_DMA 2 /* Histogram only: DMA is running */
  40. struct ispstat;
  41. struct ispstat_buffer {
  42. unsigned long iommu_addr;
  43. struct iovm_struct *iovm;
  44. void *virt_addr;
  45. dma_addr_t dma_addr;
  46. struct timeval ts;
  47. u32 buf_size;
  48. u32 frame_number;
  49. u16 config_counter;
  50. u8 empty;
  51. };
  52. struct ispstat_ops {
  53. /*
  54. * Validate new params configuration.
  55. * new_conf->buf_size value must be changed to the exact buffer size
  56. * necessary for the new configuration if it's smaller.
  57. */
  58. int (*validate_params)(struct ispstat *stat, void *new_conf);
  59. /*
  60. * Save new params configuration.
  61. * stat->priv->buf_size value must be set to the exact buffer size for
  62. * the new configuration.
  63. * stat->update is set to 1 if new configuration is different than
  64. * current one.
  65. */
  66. void (*set_params)(struct ispstat *stat, void *new_conf);
  67. /* Apply stored configuration. */
  68. void (*setup_regs)(struct ispstat *stat, void *priv);
  69. /* Enable/Disable module. */
  70. void (*enable)(struct ispstat *stat, int enable);
  71. /* Verify is module is busy. */
  72. int (*busy)(struct ispstat *stat);
  73. /* Used for specific operations during generic buf process task. */
  74. int (*buf_process)(struct ispstat *stat);
  75. };
  76. enum ispstat_state_t {
  77. ISPSTAT_DISABLED = 0,
  78. ISPSTAT_DISABLING,
  79. ISPSTAT_ENABLED,
  80. ISPSTAT_ENABLING,
  81. ISPSTAT_SUSPENDED,
  82. };
  83. struct ispstat {
  84. struct v4l2_subdev subdev;
  85. struct media_pad pad; /* sink pad */
  86. /* Control */
  87. unsigned configured:1;
  88. unsigned update:1;
  89. unsigned buf_processing:1;
  90. unsigned sbl_ovl_recover:1;
  91. u8 inc_config;
  92. atomic_t buf_err;
  93. enum ispstat_state_t state; /* enabling/disabling state */
  94. struct omap_dma_channel_params dma_config;
  95. struct isp_device *isp;
  96. void *priv; /* pointer to priv config struct */
  97. void *recover_priv; /* pointer to recover priv configuration */
  98. struct mutex ioctl_lock; /* serialize private ioctl */
  99. const struct ispstat_ops *ops;
  100. /* Buffer */
  101. u8 wait_acc_frames;
  102. u16 config_counter;
  103. u32 frame_number;
  104. u32 buf_size;
  105. u32 buf_alloc_size;
  106. int dma_ch;
  107. unsigned long event_type;
  108. struct ispstat_buffer *buf;
  109. struct ispstat_buffer *active_buf;
  110. struct ispstat_buffer *locked_buf;
  111. };
  112. struct ispstat_generic_config {
  113. /*
  114. * Fields must be in the same order as in:
  115. * - omap3isp_h3a_aewb_config
  116. * - omap3isp_h3a_af_config
  117. * - omap3isp_hist_config
  118. */
  119. u32 buf_size;
  120. u16 config_counter;
  121. };
  122. int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
  123. int omap3isp_stat_request_statistics(struct ispstat *stat,
  124. struct omap3isp_stat_data *data);
  125. int omap3isp_stat_init(struct ispstat *stat, const char *name,
  126. const struct v4l2_subdev_ops *sd_ops);
  127. void omap3isp_stat_cleanup(struct ispstat *stat);
  128. int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
  129. struct v4l2_fh *fh,
  130. struct v4l2_event_subscription *sub);
  131. int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
  132. struct v4l2_fh *fh,
  133. struct v4l2_event_subscription *sub);
  134. int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
  135. int omap3isp_stat_busy(struct ispstat *stat);
  136. int omap3isp_stat_pcr_busy(struct ispstat *stat);
  137. void omap3isp_stat_suspend(struct ispstat *stat);
  138. void omap3isp_stat_resume(struct ispstat *stat);
  139. int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
  140. void omap3isp_stat_sbl_overflow(struct ispstat *stat);
  141. void omap3isp_stat_isr(struct ispstat *stat);
  142. void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
  143. void omap3isp_stat_dma_isr(struct ispstat *stat);
  144. int omap3isp_stat_register_entities(struct ispstat *stat,
  145. struct v4l2_device *vdev);
  146. void omap3isp_stat_unregister_entities(struct ispstat *stat);
  147. #endif /* OMAP3_ISP_STAT_H */