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