ispccdc.h 5.0 KB

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