fimc-isp.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * Samsung EXYNOS4x12 FIMC-IS (Imaging Subsystem) driver
  3. *
  4. * Copyright (C) 2013 Samsung Electronics Co., Ltd.
  5. *
  6. * Authors: Sylwester Nawrocki <s.nawrocki@samsung.com>
  7. * Younghwan Joo <yhwan.joo@samsung.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #ifndef FIMC_ISP_H_
  14. #define FIMC_ISP_H_
  15. #include <linux/io.h>
  16. #include <linux/platform_device.h>
  17. #include <linux/sched.h>
  18. #include <linux/spinlock.h>
  19. #include <linux/types.h>
  20. #include <linux/videodev2.h>
  21. #include <media/media-entity.h>
  22. #include <media/videobuf2-core.h>
  23. #include <media/v4l2-device.h>
  24. #include <media/v4l2-mediabus.h>
  25. #include <media/s5p_fimc.h>
  26. /* FIXME: revisit these constraints */
  27. #define FIMC_ISP_SINK_WIDTH_MIN (16 + 8)
  28. #define FIMC_ISP_SINK_HEIGHT_MIN (12 + 8)
  29. #define FIMC_ISP_SOURCE_WIDTH_MIN 8
  30. #define FIMC_ISP_SOURC_HEIGHT_MIN 8
  31. #define FIMC_ISP_CAC_MARGIN_WIDTH 16
  32. #define FIMC_ISP_CAC_MARGIN_HEIGHT 12
  33. #define FIMC_ISP_SINK_WIDTH_MAX (4000 - 16)
  34. #define FIMC_ISP_SINK_HEIGHT_MAX (4000 + 12)
  35. #define FIMC_ISP_SOURCE_WIDTH_MAX 4000
  36. #define FIMC_ISP_SOURC_HEIGHT_MAX 4000
  37. #define FIMC_ISP_NUM_FORMATS 3
  38. #define FIMC_ISP_REQ_BUFS_MIN 2
  39. #define FIMC_ISP_SD_PAD_SINK 0
  40. #define FIMC_ISP_SD_PAD_SRC_FIFO 1
  41. #define FIMC_ISP_SD_PAD_SRC_DMA 2
  42. #define FIMC_ISP_SD_PADS_NUM 3
  43. #define FIMC_ISP_MAX_PLANES 1
  44. /**
  45. * struct fimc_isp_frame - source/target frame properties
  46. * @width: full image width
  47. * @height: full image height
  48. * @rect: crop/composition rectangle
  49. */
  50. struct fimc_isp_frame {
  51. u16 width;
  52. u16 height;
  53. struct v4l2_rect rect;
  54. };
  55. struct fimc_isp_ctrls {
  56. struct v4l2_ctrl_handler handler;
  57. /* Auto white balance */
  58. struct v4l2_ctrl *auto_wb;
  59. /* Auto ISO control cluster */
  60. struct {
  61. struct v4l2_ctrl *auto_iso;
  62. struct v4l2_ctrl *iso;
  63. };
  64. /* Adjust - contrast */
  65. struct v4l2_ctrl *contrast;
  66. /* Adjust - saturation */
  67. struct v4l2_ctrl *saturation;
  68. /* Adjust - sharpness */
  69. struct v4l2_ctrl *sharpness;
  70. /* Adjust - brightness */
  71. struct v4l2_ctrl *brightness;
  72. /* Adjust - hue */
  73. struct v4l2_ctrl *hue;
  74. /* Auto/manual exposure */
  75. struct v4l2_ctrl *auto_exp;
  76. /* Manual exposure value */
  77. struct v4l2_ctrl *exposure;
  78. /* AE/AWB lock/unlock */
  79. struct v4l2_ctrl *aewb_lock;
  80. /* Exposure metering mode */
  81. struct v4l2_ctrl *exp_metering;
  82. /* AFC */
  83. struct v4l2_ctrl *afc;
  84. /* ISP image effect */
  85. struct v4l2_ctrl *colorfx;
  86. };
  87. /**
  88. * struct fimc_is_video - fimc-is video device structure
  89. * @vdev: video_device structure
  90. * @type: video device type (CAPTURE/OUTPUT)
  91. * @pad: video device media (sink) pad
  92. * @pending_buf_q: pending buffers queue head
  93. * @active_buf_q: a queue head of buffers scheduled in hardware
  94. * @vb_queue: vb2 buffer queue
  95. * @active_buf_count: number of video buffers scheduled in hardware
  96. * @frame_count: counter of frames dequeued to user space
  97. * @reqbufs_count: number of buffers requested with REQBUFS ioctl
  98. * @format: current pixel format
  99. */
  100. struct fimc_is_video {
  101. struct video_device vdev;
  102. enum v4l2_buf_type type;
  103. struct media_pad pad;
  104. struct list_head pending_buf_q;
  105. struct list_head active_buf_q;
  106. struct vb2_queue vb_queue;
  107. unsigned int frame_count;
  108. unsigned int reqbufs_count;
  109. int streaming;
  110. unsigned long payload[FIMC_ISP_MAX_PLANES];
  111. const struct fimc_fmt *format;
  112. };
  113. /**
  114. * struct fimc_isp - FIMC-IS ISP data structure
  115. * @pdev: pointer to FIMC-IS platform device
  116. * @alloc_ctx: videobuf2 memory allocator context
  117. * @subdev: ISP v4l2_subdev
  118. * @subdev_pads: the ISP subdev media pads
  119. * @ctrl_handler: v4l2 controls handler
  120. * @test_pattern: test pattern controls
  121. * @pipeline: video capture pipeline data structure
  122. * @video_lock: mutex serializing video device and the subdev operations
  123. * @fmt: pointer to color format description structure
  124. * @payload: image size in bytes (w x h x bpp)
  125. * @inp_frame: camera input frame structure
  126. * @out_frame: DMA output frame structure
  127. * @source_subdev_grp_id: group id of remote source subdev
  128. * @cac_margin_x: horizontal CAC margin in pixels
  129. * @cac_margin_y: vertical CAC margin in pixels
  130. * @state: driver state flags
  131. * @video_capture: the ISP block video capture device
  132. */
  133. struct fimc_isp {
  134. struct platform_device *pdev;
  135. struct vb2_alloc_ctx *alloc_ctx;
  136. struct v4l2_subdev subdev;
  137. struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
  138. struct v4l2_mbus_framefmt subdev_fmt;
  139. struct v4l2_ctrl *test_pattern;
  140. struct fimc_isp_ctrls ctrls;
  141. struct mutex video_lock;
  142. struct mutex subdev_lock;
  143. struct fimc_isp_frame inp_frame;
  144. struct fimc_isp_frame out_frame;
  145. unsigned int source_subdev_grp_id;
  146. unsigned int cac_margin_x;
  147. unsigned int cac_margin_y;
  148. unsigned long state;
  149. struct fimc_is_video video_capture;
  150. };
  151. #define ctrl_to_fimc_isp(_ctrl) \
  152. container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
  153. struct fimc_is;
  154. int fimc_isp_subdev_create(struct fimc_isp *isp);
  155. void fimc_isp_subdev_destroy(struct fimc_isp *isp);
  156. void fimc_isp_irq_handler(struct fimc_is *is);
  157. int fimc_is_create_controls(struct fimc_isp *isp);
  158. int fimc_is_delete_controls(struct fimc_isp *isp);
  159. const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
  160. const u32 *mbus_code, int index);
  161. #endif /* FIMC_ISP_H_ */