ispstat.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. #ifndef OMAP3_ISP_STAT_H
  18. #define OMAP3_ISP_STAT_H
  19. #include <linux/types.h>
  20. #include <linux/omap3isp.h>
  21. #include <media/v4l2-event.h>
  22. #include "isp.h"
  23. #include "ispvideo.h"
  24. #define STAT_MAX_BUFS 5
  25. #define STAT_NEVENTS 8
  26. #define STAT_BUF_DONE 0 /* Buffer is ready */
  27. #define STAT_NO_BUF 1 /* An error has occurred */
  28. #define STAT_BUF_WAITING_DMA 2 /* Histogram only: DMA is running */
  29. struct dma_chan;
  30. struct ispstat;
  31. struct ispstat_buffer {
  32. struct sg_table sgt;
  33. void *virt_addr;
  34. dma_addr_t dma_addr;
  35. struct timeval ts;
  36. u32 buf_size;
  37. u32 frame_number;
  38. u16 config_counter;
  39. u8 empty;
  40. };
  41. struct ispstat_ops {
  42. /*
  43. * Validate new params configuration.
  44. * new_conf->buf_size value must be changed to the exact buffer size
  45. * necessary for the new configuration if it's smaller.
  46. */
  47. int (*validate_params)(struct ispstat *stat, void *new_conf);
  48. /*
  49. * Save new params configuration.
  50. * stat->priv->buf_size value must be set to the exact buffer size for
  51. * the new configuration.
  52. * stat->update is set to 1 if new configuration is different than
  53. * current one.
  54. */
  55. void (*set_params)(struct ispstat *stat, void *new_conf);
  56. /* Apply stored configuration. */
  57. void (*setup_regs)(struct ispstat *stat, void *priv);
  58. /* Enable/Disable module. */
  59. void (*enable)(struct ispstat *stat, int enable);
  60. /* Verify is module is busy. */
  61. int (*busy)(struct ispstat *stat);
  62. /* Used for specific operations during generic buf process task. */
  63. int (*buf_process)(struct ispstat *stat);
  64. };
  65. enum ispstat_state_t {
  66. ISPSTAT_DISABLED = 0,
  67. ISPSTAT_DISABLING,
  68. ISPSTAT_ENABLED,
  69. ISPSTAT_ENABLING,
  70. ISPSTAT_SUSPENDED,
  71. };
  72. struct ispstat {
  73. struct v4l2_subdev subdev;
  74. struct media_pad pad; /* sink pad */
  75. /* Control */
  76. unsigned configured:1;
  77. unsigned update:1;
  78. unsigned buf_processing:1;
  79. unsigned sbl_ovl_recover:1;
  80. u8 inc_config;
  81. atomic_t buf_err;
  82. enum ispstat_state_t state; /* enabling/disabling state */
  83. struct isp_device *isp;
  84. void *priv; /* pointer to priv config struct */
  85. void *recover_priv; /* pointer to recover priv configuration */
  86. struct mutex ioctl_lock; /* serialize private ioctl */
  87. const struct ispstat_ops *ops;
  88. /* Buffer */
  89. u8 wait_acc_frames;
  90. u16 config_counter;
  91. u32 frame_number;
  92. u32 buf_size;
  93. u32 buf_alloc_size;
  94. struct dma_chan *dma_ch;
  95. unsigned long event_type;
  96. struct ispstat_buffer *buf;
  97. struct ispstat_buffer *active_buf;
  98. struct ispstat_buffer *locked_buf;
  99. };
  100. struct ispstat_generic_config {
  101. /*
  102. * Fields must be in the same order as in:
  103. * - omap3isp_h3a_aewb_config
  104. * - omap3isp_h3a_af_config
  105. * - omap3isp_hist_config
  106. */
  107. u32 buf_size;
  108. u16 config_counter;
  109. };
  110. int omap3isp_stat_config(struct ispstat *stat, void *new_conf);
  111. int omap3isp_stat_request_statistics(struct ispstat *stat,
  112. struct omap3isp_stat_data *data);
  113. int omap3isp_stat_init(struct ispstat *stat, const char *name,
  114. const struct v4l2_subdev_ops *sd_ops);
  115. void omap3isp_stat_cleanup(struct ispstat *stat);
  116. int omap3isp_stat_subscribe_event(struct v4l2_subdev *subdev,
  117. struct v4l2_fh *fh,
  118. struct v4l2_event_subscription *sub);
  119. int omap3isp_stat_unsubscribe_event(struct v4l2_subdev *subdev,
  120. struct v4l2_fh *fh,
  121. struct v4l2_event_subscription *sub);
  122. int omap3isp_stat_s_stream(struct v4l2_subdev *subdev, int enable);
  123. int omap3isp_stat_busy(struct ispstat *stat);
  124. int omap3isp_stat_pcr_busy(struct ispstat *stat);
  125. void omap3isp_stat_suspend(struct ispstat *stat);
  126. void omap3isp_stat_resume(struct ispstat *stat);
  127. int omap3isp_stat_enable(struct ispstat *stat, u8 enable);
  128. void omap3isp_stat_sbl_overflow(struct ispstat *stat);
  129. void omap3isp_stat_isr(struct ispstat *stat);
  130. void omap3isp_stat_isr_frame_sync(struct ispstat *stat);
  131. void omap3isp_stat_dma_isr(struct ispstat *stat);
  132. int omap3isp_stat_register_entities(struct ispstat *stat,
  133. struct v4l2_device *vdev);
  134. void omap3isp_stat_unregister_entities(struct ispstat *stat);
  135. #endif /* OMAP3_ISP_STAT_H */