fimc-isp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. extern int fimc_isp_debug;
  27. #define isp_dbg(level, dev, fmt, arg...) \
  28. v4l2_dbg(level, fimc_isp_debug, dev, fmt, ## arg)
  29. /* FIXME: revisit these constraints */
  30. #define FIMC_ISP_SINK_WIDTH_MIN (16 + 8)
  31. #define FIMC_ISP_SINK_HEIGHT_MIN (12 + 8)
  32. #define FIMC_ISP_SOURCE_WIDTH_MIN 8
  33. #define FIMC_ISP_SOURC_HEIGHT_MIN 8
  34. #define FIMC_ISP_CAC_MARGIN_WIDTH 16
  35. #define FIMC_ISP_CAC_MARGIN_HEIGHT 12
  36. #define FIMC_ISP_SINK_WIDTH_MAX (4000 - 16)
  37. #define FIMC_ISP_SINK_HEIGHT_MAX (4000 + 12)
  38. #define FIMC_ISP_SOURCE_WIDTH_MAX 4000
  39. #define FIMC_ISP_SOURC_HEIGHT_MAX 4000
  40. #define FIMC_ISP_NUM_FORMATS 3
  41. #define FIMC_ISP_REQ_BUFS_MIN 2
  42. #define FIMC_ISP_SD_PAD_SINK 0
  43. #define FIMC_ISP_SD_PAD_SRC_FIFO 1
  44. #define FIMC_ISP_SD_PAD_SRC_DMA 2
  45. #define FIMC_ISP_SD_PADS_NUM 3
  46. #define FIMC_ISP_MAX_PLANES 1
  47. /**
  48. * struct fimc_isp_frame - source/target frame properties
  49. * @width: full image width
  50. * @height: full image height
  51. * @rect: crop/composition rectangle
  52. */
  53. struct fimc_isp_frame {
  54. u16 width;
  55. u16 height;
  56. struct v4l2_rect rect;
  57. };
  58. struct fimc_isp_ctrls {
  59. struct v4l2_ctrl_handler handler;
  60. /* Auto white balance */
  61. struct v4l2_ctrl *auto_wb;
  62. /* Auto ISO control cluster */
  63. struct {
  64. struct v4l2_ctrl *auto_iso;
  65. struct v4l2_ctrl *iso;
  66. };
  67. /* Adjust - contrast */
  68. struct v4l2_ctrl *contrast;
  69. /* Adjust - saturation */
  70. struct v4l2_ctrl *saturation;
  71. /* Adjust - sharpness */
  72. struct v4l2_ctrl *sharpness;
  73. /* Adjust - brightness */
  74. struct v4l2_ctrl *brightness;
  75. /* Adjust - hue */
  76. struct v4l2_ctrl *hue;
  77. /* Auto/manual exposure */
  78. struct v4l2_ctrl *auto_exp;
  79. /* Manual exposure value */
  80. struct v4l2_ctrl *exposure;
  81. /* AE/AWB lock/unlock */
  82. struct v4l2_ctrl *aewb_lock;
  83. /* Exposure metering mode */
  84. struct v4l2_ctrl *exp_metering;
  85. /* AFC */
  86. struct v4l2_ctrl *afc;
  87. /* ISP image effect */
  88. struct v4l2_ctrl *colorfx;
  89. };
  90. /**
  91. * struct fimc_is_video - fimc-is video device structure
  92. * @vdev: video_device structure
  93. * @type: video device type (CAPTURE/OUTPUT)
  94. * @pad: video device media (sink) pad
  95. * @pending_buf_q: pending buffers queue head
  96. * @active_buf_q: a queue head of buffers scheduled in hardware
  97. * @vb_queue: vb2 buffer queue
  98. * @active_buf_count: number of video buffers scheduled in hardware
  99. * @frame_count: counter of frames dequeued to user space
  100. * @reqbufs_count: number of buffers requested with REQBUFS ioctl
  101. * @format: current pixel format
  102. */
  103. struct fimc_is_video {
  104. struct video_device vdev;
  105. enum v4l2_buf_type type;
  106. struct media_pad pad;
  107. struct list_head pending_buf_q;
  108. struct list_head active_buf_q;
  109. struct vb2_queue vb_queue;
  110. unsigned int frame_count;
  111. unsigned int reqbufs_count;
  112. int streaming;
  113. const struct fimc_fmt *format;
  114. };
  115. /**
  116. * struct fimc_isp - FIMC-IS ISP data structure
  117. * @pdev: pointer to FIMC-IS platform device
  118. * @alloc_ctx: videobuf2 memory allocator context
  119. * @subdev: ISP v4l2_subdev
  120. * @subdev_pads: the ISP subdev media pads
  121. * @test_pattern: test pattern controls
  122. * @ctrls: v4l2 controls structure
  123. * @video_lock: mutex serializing video device and the subdev operations
  124. * @cac_margin_x: horizontal CAC margin in pixels
  125. * @cac_margin_y: vertical CAC margin in pixels
  126. * @state: driver state flags
  127. * @video_capture: the ISP block video capture device
  128. */
  129. struct fimc_isp {
  130. struct platform_device *pdev;
  131. struct vb2_alloc_ctx *alloc_ctx;
  132. struct v4l2_subdev subdev;
  133. struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
  134. struct v4l2_mbus_framefmt src_fmt;
  135. struct v4l2_mbus_framefmt sink_fmt;
  136. struct v4l2_ctrl *test_pattern;
  137. struct fimc_isp_ctrls ctrls;
  138. struct mutex video_lock;
  139. struct mutex subdev_lock;
  140. unsigned int cac_margin_x;
  141. unsigned int cac_margin_y;
  142. unsigned long state;
  143. struct fimc_is_video video_capture;
  144. };
  145. #define ctrl_to_fimc_isp(_ctrl) \
  146. container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
  147. struct fimc_is;
  148. int fimc_isp_subdev_create(struct fimc_isp *isp);
  149. void fimc_isp_subdev_destroy(struct fimc_isp *isp);
  150. void fimc_isp_irq_handler(struct fimc_is *is);
  151. int fimc_is_create_controls(struct fimc_isp *isp);
  152. int fimc_is_delete_controls(struct fimc_isp *isp);
  153. const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
  154. const u32 *mbus_code, int index);
  155. #endif /* FIMC_ISP_H_ */