fimc-isp.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. const struct fimc_fmt *format;
  111. };
  112. /**
  113. * struct fimc_isp - FIMC-IS ISP data structure
  114. * @pdev: pointer to FIMC-IS platform device
  115. * @alloc_ctx: videobuf2 memory allocator context
  116. * @subdev: ISP v4l2_subdev
  117. * @subdev_pads: the ISP subdev media pads
  118. * @test_pattern: test pattern controls
  119. * @ctrls: v4l2 controls structure
  120. * @video_lock: mutex serializing video device and the subdev operations
  121. * @cac_margin_x: horizontal CAC margin in pixels
  122. * @cac_margin_y: vertical CAC margin in pixels
  123. * @state: driver state flags
  124. * @video_capture: the ISP block video capture device
  125. */
  126. struct fimc_isp {
  127. struct platform_device *pdev;
  128. struct vb2_alloc_ctx *alloc_ctx;
  129. struct v4l2_subdev subdev;
  130. struct media_pad subdev_pads[FIMC_ISP_SD_PADS_NUM];
  131. struct v4l2_mbus_framefmt subdev_fmt;
  132. struct v4l2_ctrl *test_pattern;
  133. struct fimc_isp_ctrls ctrls;
  134. struct mutex video_lock;
  135. struct mutex subdev_lock;
  136. unsigned int cac_margin_x;
  137. unsigned int cac_margin_y;
  138. unsigned long state;
  139. struct fimc_is_video video_capture;
  140. };
  141. #define ctrl_to_fimc_isp(_ctrl) \
  142. container_of(ctrl->handler, struct fimc_isp, ctrls.handler)
  143. struct fimc_is;
  144. int fimc_isp_subdev_create(struct fimc_isp *isp);
  145. void fimc_isp_subdev_destroy(struct fimc_isp *isp);
  146. void fimc_isp_irq_handler(struct fimc_is *is);
  147. int fimc_is_create_controls(struct fimc_isp *isp);
  148. int fimc_is_delete_controls(struct fimc_isp *isp);
  149. const struct fimc_fmt *fimc_isp_find_format(const u32 *pixelformat,
  150. const u32 *mbus_code, int index);
  151. #endif /* FIMC_ISP_H_ */