ispstat.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 <linux/omap-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. struct sg_table sgt;
  43. void *virt_addr;
  44. dma_addr_t dma_addr;
  45. struct timespec ts;
  46. u32 buf_size;
  47. u32 frame_number;
  48. u16 config_counter;
  49. u8 empty;
  50. };
  51. struct ispstat_ops {
  52. /*
  53. * Validate new params configuration.
  54. * new_conf->buf_size value must be changed to the exact buffer size
  55. * necessary for the new configuration if it's smaller.
  56. */
  57. int (*validate_params)(struct ispstat *stat, void *new_conf);
  58. /*
  59. * Save new params configuration.
  60. * stat->priv->buf_size value must be set to the exact buffer size for
  61. * the new configuration.
  62. * stat->update is set to 1 if new configuration is different than
  63. * current one.
  64. */
  65. void (*set_params)(struct ispstat *stat, void *new_conf);
  66. /* Apply stored configuration. */
  67. void (*setup_regs)(struct ispstat *stat, void *priv);
  68. /* Enable/Disable module. */
  69. void (*enable)(struct ispstat *stat, int enable);
  70. /* Verify is module is busy. */
  71. int (*busy)(struct ispstat *stat);
  72. /* Used for specific operations during generic buf process task. */
  73. int (*buf_process)(struct ispstat *stat);
  74. };
  75. enum ispstat_state_t {
  76. ISPSTAT_DISABLED = 0,
  77. ISPSTAT_DISABLING,
  78. ISPSTAT_ENABLED,
  79. ISPSTAT_ENABLING,
  80. ISPSTAT_SUSPENDED,
  81. };
  82. struct ispstat {
  83. struct v4l2_subdev subdev;
  84. struct media_pad pad; /* sink pad */
  85. /* Control */
  86. unsigned configured:1;
  87. unsigned update:1;
  88. unsigned buf_processing:1;
  89. unsigned sbl_ovl_recover:1;
  90. u8 inc_config;
  91. atomic_t buf_err;
  92. enum ispstat_state_t state; /* enabling/disabling state */
  93. struct omap_dma_channel_params dma_config;
  94. struct isp_device *isp;
  95. void *priv; /* pointer to priv config struct */
  96. void *recover_priv; /* pointer to recover priv configuration */
  97. struct mutex ioctl_lock; /* serialize private ioctl */
  98. const struct ispstat_ops *ops;
  99. /* Buffer */
  100. u8 wait_acc_frames;
  101. u16 config_counter;
  102. u32 frame_number;
  103. u32 buf_size;
  104. u32 buf_alloc_size;
  105. int dma_ch;
  106. unsigned long event_type;
  107. struct ispstat_buffer *buf;
  108. struct ispstat_buffer *active_buf;
  109. struct ispstat_buffer *locked_buf;
  110. };
  111. struct ispstat_generic_config {
  112. /*
  113. * Fields must be in the same order as in:
  114. * - omap3isp_h3a_aewb_config
  115. * - omap3isp_h3a_af_config
  116. * - omap3isp_hist_config
  117. */
  118. u32 buf_size;
  119. u16 config_counter;
  120. };
  121. int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
  122. int omap3isp_stat_request_statistics(struct ispstat *stat,
  123. struct omap3isp_stat_data *data);
  124. int omap3isp_stat_init(struct ispstat *stat, const char *name,
  125. const struct v4l2_subdev_ops *sd_ops);
  126. void omap3isp_stat_cleanup(struct ispstat *stat);
  127. int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
  128. struct v4l2_fh *fh,
  129. struct v4l2_event_subscription *sub);
  130. int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
  131. struct v4l2_fh *fh,
  132. struct v4l2_event_subscription *sub);
  133. int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
  134. int omap3isp_stat_busy(struct ispstat *stat);
  135. int omap3isp_stat_pcr_busy(struct ispstat *stat);
  136. void omap3isp_stat_suspend(struct ispstat *stat);
  137. void omap3isp_stat_resume(struct ispstat *stat);
  138. int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
  139. void omap3isp_stat_sbl_overflow(struct ispstat *stat);
  140. void omap3isp_stat_isr(struct ispstat *stat);
  141. void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
  142. void omap3isp_stat_dma_isr(struct ispstat *stat);
  143. int omap3isp_stat_register_entities(struct ispstat *stat,
  144. struct v4l2_device *vdev);
  145. void omap3isp_stat_unregister_entities(struct ispstat *stat);
  146. #endif /* OMAP3_ISP_STAT_H */