isppreview.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * isppreview.h
  3. *
  4. * TI OMAP3 ISP - Preview module
  5. *
  6. * Copyright (C) 2010 Nokia Corporation
  7. * Copyright (C) 2009 Texas Instruments, Inc.
  8. *
  9. * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
  10. * Sakari Ailus <sakari.ailus@iki.fi>
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2 as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  24. * 02110-1301 USA
  25. */
  26. #ifndef OMAP3_ISP_PREVIEW_H
  27. #define OMAP3_ISP_PREVIEW_H
  28. #include <linux/omap3isp.h>
  29. #include <linux/types.h>
  30. #include <media/v4l2-ctrls.h>
  31. #include "ispvideo.h"
  32. #define ISPPRV_BRIGHT_STEP 0x1
  33. #define ISPPRV_BRIGHT_DEF 0x0
  34. #define ISPPRV_BRIGHT_LOW 0x0
  35. #define ISPPRV_BRIGHT_HIGH 0xFF
  36. #define ISPPRV_BRIGHT_UNITS 0x1
  37. #define ISPPRV_CONTRAST_STEP 0x1
  38. #define ISPPRV_CONTRAST_DEF 0x10
  39. #define ISPPRV_CONTRAST_LOW 0x0
  40. #define ISPPRV_CONTRAST_HIGH 0xFF
  41. #define ISPPRV_CONTRAST_UNITS 0x1
  42. #define NO_AVE 0x0
  43. #define AVE_2_PIX 0x1
  44. #define AVE_4_PIX 0x2
  45. #define AVE_8_PIX 0x3
  46. /* Features list */
  47. #define PREV_LUMA_ENHANCE OMAP3ISP_PREV_LUMAENH
  48. #define PREV_INVERSE_ALAW OMAP3ISP_PREV_INVALAW
  49. #define PREV_HORZ_MEDIAN_FILTER OMAP3ISP_PREV_HRZ_MED
  50. #define PREV_CFA OMAP3ISP_PREV_CFA
  51. #define PREV_CHROMA_SUPPRESS OMAP3ISP_PREV_CHROMA_SUPP
  52. #define PREV_WB OMAP3ISP_PREV_WB
  53. #define PREV_BLKADJ OMAP3ISP_PREV_BLKADJ
  54. #define PREV_RGB2RGB OMAP3ISP_PREV_RGB2RGB
  55. #define PREV_COLOR_CONV OMAP3ISP_PREV_COLOR_CONV
  56. #define PREV_YCLIMITS OMAP3ISP_PREV_YC_LIMIT
  57. #define PREV_DEFECT_COR OMAP3ISP_PREV_DEFECT_COR
  58. #define PREV_GAMMA_BYPASS OMAP3ISP_PREV_GAMMABYPASS
  59. #define PREV_DARK_FRAME_CAPTURE OMAP3ISP_PREV_DRK_FRM_CAPTURE
  60. #define PREV_DARK_FRAME_SUBTRACT OMAP3ISP_PREV_DRK_FRM_SUBTRACT
  61. #define PREV_LENS_SHADING OMAP3ISP_PREV_LENS_SHADING
  62. #define PREV_NOISE_FILTER OMAP3ISP_PREV_NF
  63. #define PREV_GAMMA OMAP3ISP_PREV_GAMMA
  64. #define PREV_CONTRAST (1 << 17)
  65. #define PREV_BRIGHTNESS (1 << 18)
  66. #define PREV_AVERAGER (1 << 19)
  67. #define PREV_FEATURES_END (1 << 20)
  68. enum preview_input_entity {
  69. PREVIEW_INPUT_NONE,
  70. PREVIEW_INPUT_CCDC,
  71. PREVIEW_INPUT_MEMORY,
  72. };
  73. #define PREVIEW_OUTPUT_RESIZER (1 << 1)
  74. #define PREVIEW_OUTPUT_MEMORY (1 << 2)
  75. /* Configure byte layout of YUV image */
  76. enum preview_ycpos_mode {
  77. YCPOS_YCrYCb = 0,
  78. YCPOS_YCbYCr = 1,
  79. YCPOS_CbYCrY = 2,
  80. YCPOS_CrYCbY = 3
  81. };
  82. /*
  83. * struct prev_params - Structure for all configuration
  84. * @features: Set of features enabled.
  85. * @cfa: CFA coefficients.
  86. * @csup: Chroma suppression coefficients.
  87. * @luma: Luma enhancement coefficients.
  88. * @nf: Noise filter coefficients.
  89. * @dcor: Noise filter coefficients.
  90. * @gamma: Gamma coefficients.
  91. * @wbal: White Balance parameters.
  92. * @blk_adj: Black adjustment parameters.
  93. * @rgb2rgb: RGB blending parameters.
  94. * @rgb2ycbcr: RGB to ycbcr parameters.
  95. * @hmed: Horizontal median filter.
  96. * @yclimit: YC limits parameters.
  97. * @average: Downsampling rate for averager.
  98. * @contrast: Contrast.
  99. * @brightness: Brightness.
  100. */
  101. struct prev_params {
  102. u32 features;
  103. struct omap3isp_prev_cfa cfa;
  104. struct omap3isp_prev_csup csup;
  105. struct omap3isp_prev_luma luma;
  106. struct omap3isp_prev_nf nf;
  107. struct omap3isp_prev_dcor dcor;
  108. struct omap3isp_prev_gtables gamma;
  109. struct omap3isp_prev_wbal wbal;
  110. struct omap3isp_prev_blkadj blk_adj;
  111. struct omap3isp_prev_rgbtorgb rgb2rgb;
  112. struct omap3isp_prev_csc rgb2ycbcr;
  113. struct omap3isp_prev_hmed hmed;
  114. struct omap3isp_prev_yclimit yclimit;
  115. u8 average;
  116. u8 contrast;
  117. u8 brightness;
  118. };
  119. /*
  120. * struct isptables_update - Structure for Table Configuration.
  121. * @update: Specifies which tables should be updated.
  122. * @flag: Specifies which tables should be enabled.
  123. * @nf: Pointer to structure for Noise Filter
  124. * @lsc: Pointer to LSC gain table. (currently not used)
  125. * @gamma: Pointer to gamma correction tables.
  126. * @cfa: Pointer to color filter array configuration.
  127. * @wbal: Pointer to colour and digital gain configuration.
  128. */
  129. struct isptables_update {
  130. u32 update;
  131. u32 flag;
  132. struct omap3isp_prev_nf *nf;
  133. u32 *lsc;
  134. struct omap3isp_prev_gtables *gamma;
  135. struct omap3isp_prev_cfa *cfa;
  136. struct omap3isp_prev_wbal *wbal;
  137. };
  138. /* Sink and source previewer pads */
  139. #define PREV_PAD_SINK 0
  140. #define PREV_PAD_SOURCE 1
  141. #define PREV_PADS_NUM 2
  142. /*
  143. * struct isp_prev_device - Structure for storing ISP Preview module information
  144. * @subdev: V4L2 subdevice
  145. * @pads: Media entity pads
  146. * @formats: Active formats at the subdev pad
  147. * @input: Module currently connected to the input pad
  148. * @output: Bitmask of the active output
  149. * @video_in: Input video entity
  150. * @video_out: Output video entity
  151. * @error: A hardware error occurred during capture
  152. * @params: Module configuration data
  153. * @shadow_update: If set, update the hardware configured in the next interrupt
  154. * @underrun: Whether the preview entity has queued buffers on the output
  155. * @state: Current preview pipeline state
  156. * @lock: Shadow update lock
  157. * @update: Bitmask of the parameters to be updated
  158. *
  159. * This structure is used to store the OMAP ISP Preview module Information.
  160. */
  161. struct isp_prev_device {
  162. struct v4l2_subdev subdev;
  163. struct media_pad pads[PREV_PADS_NUM];
  164. struct v4l2_mbus_framefmt formats[PREV_PADS_NUM];
  165. struct v4l2_ctrl_handler ctrls;
  166. enum preview_input_entity input;
  167. unsigned int output;
  168. struct isp_video video_in;
  169. struct isp_video video_out;
  170. unsigned int error;
  171. struct prev_params params;
  172. unsigned int shadow_update:1;
  173. enum isp_pipeline_stream_state state;
  174. wait_queue_head_t wait;
  175. atomic_t stopping;
  176. spinlock_t lock;
  177. u32 update;
  178. };
  179. struct isp_device;
  180. int omap3isp_preview_init(struct isp_device *isp);
  181. void omap3isp_preview_cleanup(struct isp_device *isp);
  182. int omap3isp_preview_register_entities(struct isp_prev_device *prv,
  183. struct v4l2_device *vdev);
  184. void omap3isp_preview_unregister_entities(struct isp_prev_device *prv);
  185. void omap3isp_preview_isr_frame_sync(struct isp_prev_device *prev);
  186. void omap3isp_preview_isr(struct isp_prev_device *prev);
  187. int omap3isp_preview_busy(struct isp_prev_device *isp_prev);
  188. void omap3isp_preview_restore_context(struct isp_device *isp);
  189. #endif /* OMAP3_ISP_PREVIEW_H */