ispccdc.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. enum ispccdc_lsc_state {
  43. LSC_STATE_STOPPED = 0,
  44. LSC_STATE_STOPPING = 1,
  45. LSC_STATE_RUNNING = 2,
  46. LSC_STATE_RECONFIG = 3,
  47. };
  48. struct ispccdc_lsc_config_req {
  49. struct list_head list;
  50. struct omap3isp_ccdc_lsc_config config;
  51. unsigned char enable;
  52. u32 table;
  53. struct iovm_struct *iovm;
  54. };
  55. /*
  56. * ispccdc_lsc - CCDC LSC parameters
  57. * @update_config: Set when user changes config
  58. * @request_enable: Whether LSC is requested to be enabled
  59. * @config: LSC config set by user
  60. * @update_table: Set when user provides a new LSC table to table_new
  61. * @table_new: LSC table set by user, ISP address
  62. * @table_inuse: LSC table currently in use, ISP address
  63. */
  64. struct ispccdc_lsc {
  65. enum ispccdc_lsc_state state;
  66. struct work_struct table_work;
  67. /* LSC queue of configurations */
  68. spinlock_t req_lock;
  69. struct ispccdc_lsc_config_req *request; /* requested configuration */
  70. struct ispccdc_lsc_config_req *active; /* active configuration */
  71. struct list_head free_queue; /* configurations for freeing */
  72. };
  73. #define CCDC_STOP_NOT_REQUESTED 0x00
  74. #define CCDC_STOP_REQUEST 0x01
  75. #define CCDC_STOP_EXECUTED (0x02 | CCDC_STOP_REQUEST)
  76. #define CCDC_STOP_CCDC_FINISHED 0x04
  77. #define CCDC_STOP_LSC_FINISHED 0x08
  78. #define CCDC_STOP_FINISHED \
  79. (CCDC_STOP_EXECUTED | CCDC_STOP_CCDC_FINISHED | CCDC_STOP_LSC_FINISHED)
  80. #define CCDC_EVENT_VD1 0x10
  81. #define CCDC_EVENT_VD0 0x20
  82. #define CCDC_EVENT_LSC_DONE 0x40
  83. /* Sink and source CCDC pads */
  84. #define CCDC_PAD_SINK 0
  85. #define CCDC_PAD_SOURCE_OF 1
  86. #define CCDC_PAD_SOURCE_VP 2
  87. #define CCDC_PADS_NUM 3
  88. /*
  89. * struct isp_ccdc_device - Structure for the CCDC module to store its own
  90. * information
  91. * @subdev: V4L2 subdevice
  92. * @pads: Sink and source media entity pads
  93. * @formats: Active video formats
  94. * @crop: Active crop rectangle on the OF source pad
  95. * @input: Active input
  96. * @output: Active outputs
  97. * @video_out: Output video node
  98. * @alaw: A-law compression enabled (1) or disabled (0)
  99. * @lpf: Low pass filter enabled (1) or disabled (0)
  100. * @obclamp: Optical-black clamp enabled (1) or disabled (0)
  101. * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
  102. * @blcomp: Black level compensation configuration
  103. * @clamp: Optical-black or digital clamp configuration
  104. * @fpc: Faulty pixels correction configuration
  105. * @lsc: Lens shading compensation configuration
  106. * @update: Bitmask of controls to update during the next interrupt
  107. * @shadow_update: Controls update in progress by userspace
  108. * @underrun: A buffer underrun occurred and a new buffer has been queued
  109. * @state: Streaming state
  110. * @lock: Serializes shadow_update with interrupt handler
  111. * @wait: Wait queue used to stop the module
  112. * @stopping: Stopping state
  113. * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
  114. */
  115. struct isp_ccdc_device {
  116. struct v4l2_subdev subdev;
  117. struct media_pad pads[CCDC_PADS_NUM];
  118. struct v4l2_mbus_framefmt formats[CCDC_PADS_NUM];
  119. struct v4l2_rect crop;
  120. enum ccdc_input_entity input;
  121. unsigned int output;
  122. struct isp_video video_out;
  123. unsigned int alaw:1,
  124. lpf:1,
  125. obclamp:1,
  126. fpc_en:1;
  127. struct omap3isp_ccdc_blcomp blcomp;
  128. struct omap3isp_ccdc_bclamp clamp;
  129. struct omap3isp_ccdc_fpc fpc;
  130. struct ispccdc_lsc lsc;
  131. unsigned int update;
  132. unsigned int shadow_update;
  133. unsigned int underrun:1;
  134. enum isp_pipeline_stream_state state;
  135. spinlock_t lock;
  136. wait_queue_head_t wait;
  137. unsigned int stopping;
  138. struct mutex ioctl_lock;
  139. };
  140. struct isp_device;
  141. int omap3isp_ccdc_init(struct isp_device *isp);
  142. void omap3isp_ccdc_cleanup(struct isp_device *isp);
  143. int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc,
  144. struct v4l2_device *vdev);
  145. void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc);
  146. int omap3isp_ccdc_busy(struct isp_ccdc_device *isp_ccdc);
  147. int omap3isp_ccdc_isr(struct isp_ccdc_device *isp_ccdc, u32 events);
  148. void omap3isp_ccdc_restore_context(struct isp_device *isp);
  149. void omap3isp_ccdc_max_rate(struct isp_ccdc_device *ccdc,
  150. unsigned int *max_rate);
  151. #endif /* OMAP3_ISP_CCDC_H */