root/drivers/media/platform/am437x/am437x-vpfe.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. ccdc_gamma_width_max_bit
  2. ccdc_data_size_max_bit

   1 /*
   2  * Copyright (C) 2013 - 2014 Texas Instruments, Inc.
   3  *
   4  * Benoit Parrot <bparrot@ti.com>
   5  * Lad, Prabhakar <prabhakar.csengg@gmail.com>
   6  *
   7  * This program is free software; you may redistribute it and/or modify
   8  * it under the terms of the GNU General Public License as published by
   9  * the Free Software Foundation; version 2 of the License.
  10  *
  11  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  12  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  13  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  14  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  15  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  16  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  18  * SOFTWARE.
  19  */
  20 
  21 #ifndef AM437X_VPFE_H
  22 #define AM437X_VPFE_H
  23 
  24 #include <linux/am437x-vpfe.h>
  25 #include <linux/clk.h>
  26 #include <linux/device.h>
  27 #include <linux/io.h>
  28 #include <linux/i2c.h>
  29 #include <linux/videodev2.h>
  30 
  31 #include <media/v4l2-dev.h>
  32 #include <media/v4l2-device.h>
  33 #include <media/v4l2-ioctl.h>
  34 #include <media/videobuf2-v4l2.h>
  35 #include <media/videobuf2-dma-contig.h>
  36 
  37 #include "am437x-vpfe_regs.h"
  38 
  39 enum vpfe_pin_pol {
  40         VPFE_PINPOL_POSITIVE = 0,
  41         VPFE_PINPOL_NEGATIVE,
  42 };
  43 
  44 enum vpfe_hw_if_type {
  45         /* Raw Bayer */
  46         VPFE_RAW_BAYER = 0,
  47         /* BT656 - 8 bit */
  48         VPFE_BT656,
  49         /* BT656 - 10 bit */
  50         VPFE_BT656_10BIT,
  51         /* YCbCr - 8 bit with external sync */
  52         VPFE_YCBCR_SYNC_8,
  53         /* YCbCr - 16 bit with external sync */
  54         VPFE_YCBCR_SYNC_16,
  55 };
  56 
  57 /* interface description */
  58 struct vpfe_hw_if_param {
  59         enum vpfe_hw_if_type if_type;
  60         enum vpfe_pin_pol hdpol;
  61         enum vpfe_pin_pol vdpol;
  62         unsigned int bus_width;
  63 };
  64 
  65 #define VPFE_MAX_SUBDEV         1
  66 #define VPFE_MAX_INPUTS         1
  67 
  68 struct vpfe_std_info {
  69         int active_pixels;
  70         int active_lines;
  71         /* current frame format */
  72         int frame_format;
  73 };
  74 
  75 struct vpfe_route {
  76         u32 input;
  77         u32 output;
  78 };
  79 
  80 struct vpfe_subdev_info {
  81         /* Sub device group id */
  82         int grp_id;
  83         /* inputs available at the sub device */
  84         struct v4l2_input inputs[VPFE_MAX_INPUTS];
  85         /* Sub dev routing information for each input */
  86         struct vpfe_route *routes;
  87         /* check if sub dev supports routing */
  88         int can_route;
  89         /* ccdc bus/interface configuration */
  90         struct vpfe_hw_if_param vpfe_param;
  91         struct v4l2_subdev *sd;
  92 };
  93 
  94 struct vpfe_config {
  95         /* information about each subdev */
  96         struct vpfe_subdev_info sub_devs[VPFE_MAX_SUBDEV];
  97         /* Flat array, arranged in groups */
  98         struct v4l2_async_subdev *asd[VPFE_MAX_SUBDEV];
  99 };
 100 
 101 struct vpfe_cap_buffer {
 102         struct vb2_v4l2_buffer vb;
 103         struct list_head list;
 104 };
 105 
 106 enum ccdc_pixfmt {
 107         CCDC_PIXFMT_RAW = 0,
 108         CCDC_PIXFMT_YCBCR_16BIT,
 109         CCDC_PIXFMT_YCBCR_8BIT,
 110 };
 111 
 112 enum ccdc_frmfmt {
 113         CCDC_FRMFMT_PROGRESSIVE = 0,
 114         CCDC_FRMFMT_INTERLACED,
 115 };
 116 
 117 /* PIXEL ORDER IN MEMORY from LSB to MSB */
 118 /* only applicable for 8-bit input mode  */
 119 enum ccdc_pixorder {
 120         CCDC_PIXORDER_YCBYCR,
 121         CCDC_PIXORDER_CBYCRY,
 122 };
 123 
 124 enum ccdc_buftype {
 125         CCDC_BUFTYPE_FLD_INTERLEAVED,
 126         CCDC_BUFTYPE_FLD_SEPARATED
 127 };
 128 
 129 
 130 /* returns the highest bit used for the gamma */
 131 static inline u8 ccdc_gamma_width_max_bit(enum vpfe_ccdc_gamma_width width)
 132 {
 133         return 15 - width;
 134 }
 135 
 136 /* returns the highest bit used for this data size */
 137 static inline u8 ccdc_data_size_max_bit(enum vpfe_ccdc_data_size sz)
 138 {
 139         return sz == VPFE_CCDC_DATA_8BITS ? 7 : 15 - sz;
 140 }
 141 
 142 /* Structure for CCDC configuration parameters for raw capture mode */
 143 struct ccdc_params_raw {
 144         /* pixel format */
 145         enum ccdc_pixfmt pix_fmt;
 146         /* progressive or interlaced frame */
 147         enum ccdc_frmfmt frm_fmt;
 148         struct v4l2_rect win;
 149         /* Current Format Bytes Per Pixels */
 150         unsigned int bytesperpixel;
 151         /* Current Format Bytes per Lines
 152          * (Aligned to 32 bytes) used for HORZ_INFO
 153          */
 154         unsigned int bytesperline;
 155         /* field id polarity */
 156         enum vpfe_pin_pol fid_pol;
 157         /* vertical sync polarity */
 158         enum vpfe_pin_pol vd_pol;
 159         /* horizontal sync polarity */
 160         enum vpfe_pin_pol hd_pol;
 161         /* interleaved or separated fields */
 162         enum ccdc_buftype buf_type;
 163         /*
 164          * enable to store the image in inverse
 165          * order in memory(bottom to top)
 166          */
 167         unsigned char image_invert_enable;
 168         /* configurable parameters */
 169         struct vpfe_ccdc_config_params_raw config_params;
 170 };
 171 
 172 struct ccdc_params_ycbcr {
 173         /* pixel format */
 174         enum ccdc_pixfmt pix_fmt;
 175         /* progressive or interlaced frame */
 176         enum ccdc_frmfmt frm_fmt;
 177         struct v4l2_rect win;
 178         /* Current Format Bytes Per Pixels */
 179         unsigned int bytesperpixel;
 180         /* Current Format Bytes per Lines
 181          * (Aligned to 32 bytes) used for HORZ_INFO
 182          */
 183         unsigned int bytesperline;
 184         /* field id polarity */
 185         enum vpfe_pin_pol fid_pol;
 186         /* vertical sync polarity */
 187         enum vpfe_pin_pol vd_pol;
 188         /* horizontal sync polarity */
 189         enum vpfe_pin_pol hd_pol;
 190         /* enable BT.656 embedded sync mode */
 191         int bt656_enable;
 192         /* cb:y:cr:y or y:cb:y:cr in memory */
 193         enum ccdc_pixorder pix_order;
 194         /* interleaved or separated fields  */
 195         enum ccdc_buftype buf_type;
 196 };
 197 
 198 /*
 199  * CCDC operational configuration
 200  */
 201 struct ccdc_config {
 202         /* CCDC interface type */
 203         enum vpfe_hw_if_type if_type;
 204         /* Raw Bayer configuration */
 205         struct ccdc_params_raw bayer;
 206         /* YCbCr configuration */
 207         struct ccdc_params_ycbcr ycbcr;
 208         /* ccdc base address */
 209         void __iomem *base_addr;
 210 };
 211 
 212 struct vpfe_ccdc {
 213         struct ccdc_config ccdc_cfg;
 214         u32 ccdc_ctx[VPFE_REG_END / sizeof(u32)];
 215 };
 216 
 217 struct vpfe_device {
 218         /* V4l2 specific parameters */
 219         /* Identifies video device for this channel */
 220         struct video_device video_dev;
 221         /* sub devices */
 222         struct v4l2_subdev **sd;
 223         /* vpfe cfg */
 224         struct vpfe_config *cfg;
 225         /* V4l2 device */
 226         struct v4l2_device v4l2_dev;
 227         /* parent device */
 228         struct device *pdev;
 229         /* subdevice async Notifier */
 230         struct v4l2_async_notifier notifier;
 231         /* Indicates id of the field which is being displayed */
 232         unsigned field;
 233         unsigned sequence;
 234         /* current interface type */
 235         struct vpfe_hw_if_param vpfe_if_params;
 236         /* ptr to currently selected sub device */
 237         struct vpfe_subdev_info *current_subdev;
 238         /* current input at the sub device */
 239         int current_input;
 240         /* Keeps track of the information about the standard */
 241         struct vpfe_std_info std_info;
 242         /* std index into std table */
 243         int std_index;
 244         /* IRQs used when CCDC output to SDRAM */
 245         unsigned int irq;
 246         /* Pointer pointing to current v4l2_buffer */
 247         struct vpfe_cap_buffer *cur_frm;
 248         /* Pointer pointing to next v4l2_buffer */
 249         struct vpfe_cap_buffer *next_frm;
 250         /* Used to store pixel format */
 251         struct v4l2_format fmt;
 252         /* Used to store current bytes per pixel based on current format */
 253         unsigned int bpp;
 254         /*
 255          * used when IMP is chained to store the crop window which
 256          * is different from the image window
 257          */
 258         struct v4l2_rect crop;
 259         /* Buffer queue used in video-buf */
 260         struct vb2_queue buffer_queue;
 261         /* Queue of filled frames */
 262         struct list_head dma_queue;
 263         /* IRQ lock for DMA queue */
 264         spinlock_t dma_queue_lock;
 265         /* lock used to access this structure */
 266         struct mutex lock;
 267         /*
 268          * offset where second field starts from the starting of the
 269          * buffer for field separated YCbCr formats
 270          */
 271         u32 field_off;
 272         struct vpfe_ccdc ccdc;
 273 };
 274 
 275 #endif  /* AM437X_VPFE_H */

/* [<][>][^][v][top][bottom][index][help] */