1/* 2 * isppreview.h 3 * 4 * TI OMAP3 ISP - Preview module 5 * 6 * Copyright (C) 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_PREVIEW_H 28#define OMAP3_ISP_PREVIEW_H 29 30#include <linux/omap3isp.h> 31#include <linux/types.h> 32#include <media/v4l2-ctrls.h> 33 34#include "ispvideo.h" 35 36#define ISPPRV_BRIGHT_STEP 0x1 37#define ISPPRV_BRIGHT_DEF 0x0 38#define ISPPRV_BRIGHT_LOW 0x0 39#define ISPPRV_BRIGHT_HIGH 0xFF 40#define ISPPRV_BRIGHT_UNITS 0x1 41 42#define ISPPRV_CONTRAST_STEP 0x1 43#define ISPPRV_CONTRAST_DEF 0x10 44#define ISPPRV_CONTRAST_LOW 0x0 45#define ISPPRV_CONTRAST_HIGH 0xFF 46#define ISPPRV_CONTRAST_UNITS 0x1 47 48/* Additional features not listed in linux/omap3isp.h */ 49#define OMAP3ISP_PREV_CONTRAST (1 << 17) 50#define OMAP3ISP_PREV_BRIGHTNESS (1 << 18) 51#define OMAP3ISP_PREV_FEATURES_END (1 << 19) 52 53enum preview_input_entity { 54 PREVIEW_INPUT_NONE, 55 PREVIEW_INPUT_CCDC, 56 PREVIEW_INPUT_MEMORY, 57}; 58 59#define PREVIEW_OUTPUT_RESIZER (1 << 1) 60#define PREVIEW_OUTPUT_MEMORY (1 << 2) 61 62/* Configure byte layout of YUV image */ 63enum preview_ycpos_mode { 64 YCPOS_YCrYCb = 0, 65 YCPOS_YCbYCr = 1, 66 YCPOS_CbYCrY = 2, 67 YCPOS_CrYCbY = 3 68}; 69 70/* 71 * struct prev_params - Structure for all configuration 72 * @busy: Bitmask of busy parameters (being updated or used) 73 * @update: Bitmask of the parameters to be updated 74 * @features: Set of features enabled. 75 * @cfa: CFA coefficients. 76 * @csup: Chroma suppression coefficients. 77 * @luma: Luma enhancement coefficients. 78 * @nf: Noise filter coefficients. 79 * @dcor: Noise filter coefficients. 80 * @gamma: Gamma coefficients. 81 * @wbal: White Balance parameters. 82 * @blkadj: Black adjustment parameters. 83 * @rgb2rgb: RGB blending parameters. 84 * @csc: Color space conversion (RGB to YCbCr) parameters. 85 * @hmed: Horizontal median filter. 86 * @yclimit: YC limits parameters. 87 * @contrast: Contrast. 88 * @brightness: Brightness. 89 */ 90struct prev_params { 91 u32 busy; 92 u32 update; 93 u32 features; 94 struct omap3isp_prev_cfa cfa; 95 struct omap3isp_prev_csup csup; 96 struct omap3isp_prev_luma luma; 97 struct omap3isp_prev_nf nf; 98 struct omap3isp_prev_dcor dcor; 99 struct omap3isp_prev_gtables gamma; 100 struct omap3isp_prev_wbal wbal; 101 struct omap3isp_prev_blkadj blkadj; 102 struct omap3isp_prev_rgbtorgb rgb2rgb; 103 struct omap3isp_prev_csc csc; 104 struct omap3isp_prev_hmed hmed; 105 struct omap3isp_prev_yclimit yclimit; 106 u8 contrast; 107 u8 brightness; 108}; 109 110/* Sink and source previewer pads */ 111#define PREV_PAD_SINK 0 112#define PREV_PAD_SOURCE 1 113#define PREV_PADS_NUM 2 114 115/* 116 * struct isp_prev_device - Structure for storing ISP Preview module information 117 * @subdev: V4L2 subdevice 118 * @pads: Media entity pads 119 * @formats: Active formats at the subdev pad 120 * @crop: Active crop rectangle 121 * @input: Module currently connected to the input pad 122 * @output: Bitmask of the active output 123 * @video_in: Input video entity 124 * @video_out: Output video entity 125 * @params.params : Active and shadow parameters sets 126 * @params.active: Bitmask of parameters active in set 0 127 * @params.lock: Parameters lock, protects params.active and params.shadow 128 * @underrun: Whether the preview entity has queued buffers on the output 129 * @state: Current preview pipeline state 130 * 131 * This structure is used to store the OMAP ISP Preview module Information. 132 */ 133struct isp_prev_device { 134 struct v4l2_subdev subdev; 135 struct media_pad pads[PREV_PADS_NUM]; 136 struct v4l2_mbus_framefmt formats[PREV_PADS_NUM]; 137 struct v4l2_rect crop; 138 139 struct v4l2_ctrl_handler ctrls; 140 141 enum preview_input_entity input; 142 unsigned int output; 143 struct isp_video video_in; 144 struct isp_video video_out; 145 146 struct { 147 unsigned int cfa_order; 148 struct prev_params params[2]; 149 u32 active; 150 spinlock_t lock; 151 } params; 152 153 enum isp_pipeline_stream_state state; 154 wait_queue_head_t wait; 155 atomic_t stopping; 156}; 157 158struct isp_device; 159 160int omap3isp_preview_init(struct isp_device *isp); 161void omap3isp_preview_cleanup(struct isp_device *isp); 162 163int omap3isp_preview_register_entities(struct isp_prev_device *prv, 164 struct v4l2_device *vdev); 165void omap3isp_preview_unregister_entities(struct isp_prev_device *prv); 166 167void omap3isp_preview_isr_frame_sync(struct isp_prev_device *prev); 168void omap3isp_preview_isr(struct isp_prev_device *prev); 169 170int omap3isp_preview_busy(struct isp_prev_device *isp_prev); 171 172void omap3isp_preview_restore_context(struct isp_device *isp); 173 174#endif /* OMAP3_ISP_PREVIEW_H */ 175