ispccdc.h 4.8 KB

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