linux/drivers/media/platform/omap3isp/ispccdc.h
<<
>>
Prefs
   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 * This program is distributed in the hope that it will be useful, but
  17 * WITHOUT ANY WARRANTY; without even the implied warranty of
  18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  19 * General Public License for more details.
  20 *
  21 * You should have received a copy of the GNU General Public License
  22 * along with this program; if not, write to the Free Software
  23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  24 * 02110-1301 USA
  25 */
  26
  27#ifndef OMAP3_ISP_CCDC_H
  28#define OMAP3_ISP_CCDC_H
  29
  30#include <linux/omap3isp.h>
  31#include <linux/workqueue.h>
  32
  33#include "ispvideo.h"
  34
  35enum ccdc_input_entity {
  36        CCDC_INPUT_NONE,
  37        CCDC_INPUT_PARALLEL,
  38        CCDC_INPUT_CSI2A,
  39        CCDC_INPUT_CCP2B,
  40        CCDC_INPUT_CSI2C
  41};
  42
  43#define CCDC_OUTPUT_MEMORY      (1 << 0)
  44#define CCDC_OUTPUT_PREVIEW     (1 << 1)
  45#define CCDC_OUTPUT_RESIZER     (1 << 2)
  46
  47#define OMAP3ISP_CCDC_NEVENTS   16
  48
  49struct ispccdc_fpc {
  50        void *addr;
  51        dma_addr_t dma;
  52        unsigned int fpnum;
  53};
  54
  55enum ispccdc_lsc_state {
  56        LSC_STATE_STOPPED = 0,
  57        LSC_STATE_STOPPING = 1,
  58        LSC_STATE_RUNNING = 2,
  59        LSC_STATE_RECONFIG = 3,
  60};
  61
  62struct ispccdc_lsc_config_req {
  63        struct list_head list;
  64        struct omap3isp_ccdc_lsc_config config;
  65        unsigned char enable;
  66
  67        struct {
  68                void *addr;
  69                dma_addr_t dma;
  70                struct sg_table sgt;
  71        } table;
  72};
  73
  74/*
  75 * ispccdc_lsc - CCDC LSC parameters
  76 */
  77struct ispccdc_lsc {
  78        enum ispccdc_lsc_state state;
  79        struct work_struct table_work;
  80
  81        /* LSC queue of configurations */
  82        spinlock_t req_lock;
  83        struct ispccdc_lsc_config_req *request; /* requested configuration */
  84        struct ispccdc_lsc_config_req *active;  /* active configuration */
  85        struct list_head free_queue;    /* configurations for freeing */
  86};
  87
  88#define CCDC_STOP_NOT_REQUESTED         0x00
  89#define CCDC_STOP_REQUEST               0x01
  90#define CCDC_STOP_EXECUTED              (0x02 | CCDC_STOP_REQUEST)
  91#define CCDC_STOP_CCDC_FINISHED         0x04
  92#define CCDC_STOP_LSC_FINISHED          0x08
  93#define CCDC_STOP_FINISHED              \
  94        (CCDC_STOP_EXECUTED | CCDC_STOP_CCDC_FINISHED | CCDC_STOP_LSC_FINISHED)
  95
  96#define CCDC_EVENT_VD1                  0x10
  97#define CCDC_EVENT_VD0                  0x20
  98#define CCDC_EVENT_LSC_DONE             0x40
  99
 100/* Sink and source CCDC pads */
 101#define CCDC_PAD_SINK                   0
 102#define CCDC_PAD_SOURCE_OF              1
 103#define CCDC_PAD_SOURCE_VP              2
 104#define CCDC_PADS_NUM                   3
 105
 106/*
 107 * struct isp_ccdc_device - Structure for the CCDC module to store its own
 108 *                          information
 109 * @subdev: V4L2 subdevice
 110 * @pads: Sink and source media entity pads
 111 * @formats: Active video formats
 112 * @crop: Active crop rectangle on the OF source pad
 113 * @input: Active input
 114 * @output: Active outputs
 115 * @video_out: Output video node
 116 * @alaw: A-law compression enabled (1) or disabled (0)
 117 * @lpf: Low pass filter enabled (1) or disabled (0)
 118 * @obclamp: Optical-black clamp enabled (1) or disabled (0)
 119 * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
 120 * @blcomp: Black level compensation configuration
 121 * @clamp: Optical-black or digital clamp configuration
 122 * @fpc: Faulty pixels correction configuration
 123 * @lsc: Lens shading compensation configuration
 124 * @update: Bitmask of controls to update during the next interrupt
 125 * @shadow_update: Controls update in progress by userspace
 126 * @underrun: A buffer underrun occurred and a new buffer has been queued
 127 * @state: Streaming state
 128 * @lock: Serializes shadow_update with interrupt handler
 129 * @wait: Wait queue used to stop the module
 130 * @stopping: Stopping state
 131 * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
 132 */
 133struct isp_ccdc_device {
 134        struct v4l2_subdev subdev;
 135        struct media_pad pads[CCDC_PADS_NUM];
 136        struct v4l2_mbus_framefmt formats[CCDC_PADS_NUM];
 137        struct v4l2_rect crop;
 138
 139        enum ccdc_input_entity input;
 140        unsigned int output;
 141        struct isp_video video_out;
 142
 143        unsigned int alaw:1,
 144                     lpf:1,
 145                     obclamp:1,
 146                     fpc_en:1;
 147        struct omap3isp_ccdc_blcomp blcomp;
 148        struct omap3isp_ccdc_bclamp clamp;
 149        struct ispccdc_fpc fpc;
 150        struct ispccdc_lsc lsc;
 151        unsigned int update;
 152        unsigned int shadow_update;
 153
 154        unsigned int underrun:1;
 155        enum isp_pipeline_stream_state state;
 156        spinlock_t lock;
 157        wait_queue_head_t wait;
 158        unsigned int stopping;
 159        struct mutex ioctl_lock;
 160};
 161
 162struct isp_device;
 163
 164int omap3isp_ccdc_init(struct isp_device *isp);
 165void omap3isp_ccdc_cleanup(struct isp_device *isp);
 166int omap3isp_ccdc_register_entities(struct isp_ccdc_device *ccdc,
 167        struct v4l2_device *vdev);
 168void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device *ccdc);
 169
 170int omap3isp_ccdc_busy(struct isp_ccdc_device *isp_ccdc);
 171int omap3isp_ccdc_isr(struct isp_ccdc_device *isp_ccdc, u32 events);
 172void omap3isp_ccdc_restore_context(struct isp_device *isp);
 173void omap3isp_ccdc_max_rate(struct isp_ccdc_device *ccdc,
 174        unsigned int *max_rate);
 175
 176#endif  /* OMAP3_ISP_CCDC_H */
 177