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