ispccdc.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * ispccdc.h
  3. *
  4. * TI OMAP3 ISP - CCDC module
  5. *
  6. * Copyright (C) 2009-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_CCDC_H
  27. #define OMAP3_ISP_CCDC_H
  28. #include <linux/omap3isp.h>
  29. #include <linux/workqueue.h>
  30. #include "ispvideo.h"
  31. enum ccdc_input_entity {
  32. CCDC_INPUT_NONE,
  33. CCDC_INPUT_PARALLEL,
  34. CCDC_INPUT_CSI2A,
  35. CCDC_INPUT_CCP2B,
  36. CCDC_INPUT_CSI2C
  37. };
  38. #define CCDC_OUTPUT_MEMORY (1 << 0)
  39. #define CCDC_OUTPUT_PREVIEW (1 << 1)
  40. #define CCDC_OUTPUT_RESIZER (1 << 2)
  41. #define OMAP3ISP_CCDC_NEVENTS 16
  42. /*
  43. * struct ispccdc_syncif - Structure for Sync Interface between sensor and CCDC
  44. * @ccdc_mastermode: Master mode. 1 - Master, 0 - Slave.
  45. * @fldstat: Field state. 0 - Odd Field, 1 - Even Field.
  46. * @datsz: Data size.
  47. * @fldmode: 0 - Progressive, 1 - Interlaced.
  48. * @datapol: 0 - Positive, 1 - Negative.
  49. * @fldpol: 0 - Positive, 1 - Negative.
  50. * @hdpol: 0 - Positive, 1 - Negative.
  51. * @vdpol: 0 - Positive, 1 - Negative.
  52. * @fldout: 0 - Input, 1 - Output.
  53. * @hs_width: Width of the Horizontal Sync pulse, used for HS/VS Output.
  54. * @vs_width: Width of the Vertical Sync pulse, used for HS/VS Output.
  55. * @ppln: Number of pixels per line, used for HS/VS Output.
  56. * @hlprf: Number of half lines per frame, used for HS/VS Output.
  57. * @bt_r656_en: 1 - Enable ITU-R BT656 mode, 0 - Sync mode.
  58. */
  59. struct ispccdc_syncif {
  60. u8 ccdc_mastermode;
  61. u8 fldstat;
  62. u8 datsz;
  63. u8 fldmode;
  64. u8 datapol;
  65. u8 fldpol;
  66. u8 hdpol;
  67. u8 vdpol;
  68. u8 fldout;
  69. u8 hs_width;
  70. u8 vs_width;
  71. u8 ppln;
  72. u8 hlprf;
  73. u8 bt_r656_en;
  74. };
  75. /*
  76. * struct ispccdc_vp - Structure for Video Port parameters
  77. * @pixelclk: Input pixel clock in Hz
  78. */
  79. struct ispccdc_vp {
  80. unsigned int pixelclk;
  81. };
  82. enum ispccdc_lsc_state {
  83. LSC_STATE_STOPPED = 0,
  84. LSC_STATE_STOPPING = 1,
  85. LSC_STATE_RUNNING = 2,
  86. LSC_STATE_RECONFIG = 3,
  87. };
  88. struct ispccdc_lsc_config_req {
  89. struct list_head list;
  90. struct omap3isp_ccdc_lsc_config config;
  91. unsigned char enable;
  92. u32 table;
  93. struct iovm_struct *iovm;
  94. };
  95. /*
  96. * ispccdc_lsc - CCDC LSC parameters
  97. * @update_config: Set when user changes config
  98. * @request_enable: Whether LSC is requested to be enabled
  99. * @config: LSC config set by user
  100. * @update_table: Set when user provides a new LSC table to table_new
  101. * @table_new: LSC table set by user, ISP address
  102. * @table_inuse: LSC table currently in use, ISP address
  103. */
  104. struct ispccdc_lsc {
  105. enum ispccdc_lsc_state state;
  106. struct work_struct table_work;
  107. /* LSC queue of configurations */
  108. spinlock_t req_lock;
  109. struct ispccdc_lsc_config_req *request; /* requested configuration */
  110. struct ispccdc_lsc_config_req *active; /* active configuration */
  111. struct list_head free_queue; /* configurations for freeing */
  112. };
  113. #define CCDC_STOP_NOT_REQUESTED 0x00
  114. #define CCDC_STOP_REQUEST 0x01
  115. #define CCDC_STOP_EXECUTED (0x02 | CCDC_STOP_REQUEST)
  116. #define CCDC_STOP_CCDC_FINISHED 0x04
  117. #define CCDC_STOP_LSC_FINISHED 0x08
  118. #define CCDC_STOP_FINISHED \
  119. (CCDC_STOP_EXECUTED | CCDC_STOP_CCDC_FINISHED | CCDC_STOP_LSC_FINISHED)
  120. #define CCDC_EVENT_VD1 0x10
  121. #define CCDC_EVENT_VD0 0x20
  122. #define CCDC_EVENT_LSC_DONE 0x40
  123. /* Sink and source CCDC pads */
  124. #define CCDC_PAD_SINK 0
  125. #define CCDC_PAD_SOURCE_OF 1
  126. #define CCDC_PAD_SOURCE_VP 2
  127. #define CCDC_PADS_NUM 3
  128. /*
  129. * struct isp_ccdc_device - Structure for the CCDC module to store its own
  130. * information
  131. * @subdev: V4L2 subdevice
  132. * @pads: Sink and source media entity pads
  133. * @formats: Active video formats
  134. * @input: Active input
  135. * @output: Active outputs
  136. * @video_out: Output video node
  137. * @alaw: A-law compression enabled (1) or disabled (0)
  138. * @lpf: Low pass filter enabled (1) or disabled (0)
  139. * @obclamp: Optical-black clamp enabled (1) or disabled (0)
  140. * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
  141. * @blcomp: Black level compensation configuration
  142. * @clamp: Optical-black or digital clamp configuration
  143. * @fpc: Faulty pixels correction configuration
  144. * @lsc: Lens shading compensation configuration
  145. * @update: Bitmask of controls to update during the next interrupt
  146. * @shadow_update: Controls update in progress by userspace
  147. * @syncif: Interface synchronization configuration
  148. * @vpcfg: Video port configuration
  149. * @underrun: A buffer underrun occurred and a new buffer has been queued
  150. * @state: Streaming state
  151. * @lock: Serializes shadow_update with interrupt handler
  152. * @wait: Wait queue used to stop the module
  153. * @stopping: Stopping state
  154. * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
  155. */
  156. struct isp_ccdc_device {
  157. struct v4l2_subdev subdev;
  158. struct media_pad pads[CCDC_PADS_NUM];
  159. struct v4l2_mbus_framefmt formats[CCDC_PADS_NUM];
  160. enum ccdc_input_entity input;
  161. unsigned int output;
  162. struct isp_video video_out;
  163. unsigned int alaw:1,
  164. lpf:1,
  165. obclamp:1,
  166. fpc_en:1;
  167. struct omap3isp_ccdc_blcomp blcomp;
  168. struct omap3isp_ccdc_bclamp clamp;
  169. struct omap3isp_ccdc_fpc fpc;
  170. struct ispccdc_lsc lsc;
  171. unsigned int update;
  172. unsigned int shadow_update;
  173. struct ispccdc_syncif syncif;
  174. struct ispccdc_vp vpcfg;
  175. unsigned int underrun:1;
  176. enum isp_pipeline_stream_state state;
  177. spinlock_t lock;
  178. wait_queue_head_t wait;
  179. unsigned int stopping;
  180. struct mutex ioctl_lock;
  181. };
  182. struct isp_device;
  183. int omap3isp_ccdc_init(struct isp_device *isp);
  184. void omap3isp_ccdc_cleanup(struct isp_device *isp);
  185. int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc,
  186. struct v4l2_device *vdev);
  187. void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc);
  188. int omap3isp_ccdc_busy(struct isp_ccdc_device *isp_ccdc);
  189. int omap3isp_ccdc_isr(struct isp_ccdc_device *isp_ccdc, u32 events);
  190. void omap3isp_ccdc_restore_context(struct isp_device *isp);
  191. void omap3isp_ccdc_max_rate(struct isp_ccdc_device *ccdc,
  192. unsigned int *max_rate);
  193. #endif /* OMAP3_ISP_CCDC_H */