Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008-2009 Texas Instruments Inc |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef _VPFE_CAPTURE_H |
| 16 | #define _VPFE_CAPTURE_H |
| 17 | |
| 18 | #ifdef __KERNEL__ |
| 19 | |
| 20 | /* Header files */ |
| 21 | #include <media/v4l2-dev.h> |
| 22 | #include <linux/videodev2.h> |
| 23 | #include <linux/clk.h> |
| 24 | #include <linux/i2c.h> |
Lad, Prabhakar | 3bdaa38 | 2014-03-22 08:39:24 -0300 | [diff] [blame] | 25 | #include <media/v4l2-fh.h> |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 26 | #include <media/v4l2-ioctl.h> |
| 27 | #include <media/v4l2-device.h> |
| 28 | #include <media/videobuf-dma-contig.h> |
| 29 | #include <media/davinci/vpfe_types.h> |
| 30 | |
| 31 | #define VPFE_CAPTURE_NUM_DECODERS 5 |
| 32 | |
| 33 | /* Macros */ |
| 34 | #define VPFE_MAJOR_RELEASE 0 |
| 35 | #define VPFE_MINOR_RELEASE 0 |
| 36 | #define VPFE_BUILD 1 |
| 37 | #define VPFE_CAPTURE_VERSION_CODE ((VPFE_MAJOR_RELEASE << 16) | \ |
| 38 | (VPFE_MINOR_RELEASE << 8) | \ |
| 39 | VPFE_BUILD) |
| 40 | |
| 41 | #define CAPTURE_DRV_NAME "vpfe-capture" |
| 42 | |
| 43 | struct vpfe_pixel_format { |
| 44 | struct v4l2_fmtdesc fmtdesc; |
| 45 | /* bytes per pixel */ |
| 46 | int bpp; |
| 47 | }; |
| 48 | |
| 49 | struct vpfe_std_info { |
| 50 | int active_pixels; |
| 51 | int active_lines; |
| 52 | /* current frame format */ |
| 53 | int frame_format; |
| 54 | }; |
| 55 | |
| 56 | struct vpfe_route { |
| 57 | u32 input; |
| 58 | u32 output; |
| 59 | }; |
| 60 | |
| 61 | struct vpfe_subdev_info { |
| 62 | /* Sub device name */ |
| 63 | char name[32]; |
| 64 | /* Sub device group id */ |
| 65 | int grp_id; |
| 66 | /* Number of inputs supported */ |
| 67 | int num_inputs; |
| 68 | /* inputs available at the sub device */ |
| 69 | struct v4l2_input *inputs; |
| 70 | /* Sub dev routing information for each input */ |
| 71 | struct vpfe_route *routes; |
| 72 | /* check if sub dev supports routing */ |
| 73 | int can_route; |
| 74 | /* ccdc bus/interface configuration */ |
| 75 | struct vpfe_hw_if_param ccdc_if_params; |
| 76 | /* i2c subdevice board info */ |
| 77 | struct i2c_board_info board_info; |
| 78 | }; |
| 79 | |
| 80 | struct vpfe_config { |
| 81 | /* Number of sub devices connected to vpfe */ |
| 82 | int num_subdevs; |
Vaibhav Hiremath | e53a70b | 2009-11-09 09:13:20 -0300 | [diff] [blame] | 83 | /* i2c bus adapter no */ |
| 84 | int i2c_adapter_id; |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 85 | /* information about each subdev */ |
| 86 | struct vpfe_subdev_info *sub_devs; |
| 87 | /* evm card info */ |
| 88 | char *card_name; |
| 89 | /* ccdc name */ |
| 90 | char *ccdc; |
| 91 | /* vpfe clock */ |
| 92 | struct clk *vpssclk; |
| 93 | struct clk *slaveclk; |
Vaibhav Hiremath | 085b54a | 2010-03-27 09:37:07 -0300 | [diff] [blame] | 94 | /* Function for Clearing the interrupt */ |
| 95 | void (*clr_intr)(int vdint); |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | struct vpfe_device { |
| 99 | /* V4l2 specific parameters */ |
| 100 | /* Identifies video device for this channel */ |
Lad, Prabhakar | 03c278f | 2015-03-10 14:53:05 -0300 | [diff] [blame] | 101 | struct video_device video_dev; |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 102 | /* sub devices */ |
| 103 | struct v4l2_subdev **sd; |
| 104 | /* vpfe cfg */ |
| 105 | struct vpfe_config *cfg; |
| 106 | /* V4l2 device */ |
| 107 | struct v4l2_device v4l2_dev; |
| 108 | /* parent device */ |
| 109 | struct device *pdev; |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 110 | /* number of open instances of the channel */ |
| 111 | u32 usrs; |
| 112 | /* Indicates id of the field which is being displayed */ |
| 113 | u32 field_id; |
| 114 | /* flag to indicate whether decoder is initialized */ |
| 115 | u8 initialized; |
| 116 | /* current interface type */ |
| 117 | struct vpfe_hw_if_param vpfe_if_params; |
| 118 | /* ptr to currently selected sub device */ |
| 119 | struct vpfe_subdev_info *current_subdev; |
| 120 | /* current input at the sub device */ |
| 121 | int current_input; |
| 122 | /* Keeps track of the information about the standard */ |
| 123 | struct vpfe_std_info std_info; |
| 124 | /* std index into std table */ |
| 125 | int std_index; |
| 126 | /* CCDC IRQs used when CCDC/ISIF output to SDRAM */ |
| 127 | unsigned int ccdc_irq0; |
| 128 | unsigned int ccdc_irq1; |
| 129 | /* number of buffers in fbuffers */ |
| 130 | u32 numbuffers; |
| 131 | /* List of buffer pointers for storing frames */ |
| 132 | u8 *fbuffers[VIDEO_MAX_FRAME]; |
| 133 | /* Pointer pointing to current v4l2_buffer */ |
| 134 | struct videobuf_buffer *cur_frm; |
| 135 | /* Pointer pointing to next v4l2_buffer */ |
| 136 | struct videobuf_buffer *next_frm; |
| 137 | /* |
| 138 | * This field keeps track of type of buffer exchange mechanism |
| 139 | * user has selected |
| 140 | */ |
| 141 | enum v4l2_memory memory; |
| 142 | /* Used to store pixel format */ |
| 143 | struct v4l2_format fmt; |
| 144 | /* |
| 145 | * used when IMP is chained to store the crop window which |
| 146 | * is different from the image window |
| 147 | */ |
| 148 | struct v4l2_rect crop; |
| 149 | /* Buffer queue used in video-buf */ |
| 150 | struct videobuf_queue buffer_queue; |
| 151 | /* Queue of filled frames */ |
| 152 | struct list_head dma_queue; |
| 153 | /* Used in video-buf */ |
| 154 | spinlock_t irqlock; |
| 155 | /* IRQ lock for DMA queue */ |
| 156 | spinlock_t dma_queue_lock; |
| 157 | /* lock used to access this structure */ |
| 158 | struct mutex lock; |
| 159 | /* number of users performing IO */ |
| 160 | u32 io_usrs; |
| 161 | /* Indicates whether streaming started */ |
| 162 | u8 started; |
| 163 | /* |
| 164 | * offset where second field starts from the starting of the |
Daniel Mack | 3ad2f3f | 2010-02-03 08:01:28 +0800 | [diff] [blame] | 165 | * buffer for field separated YCbCr formats |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 166 | */ |
| 167 | u32 field_off; |
| 168 | }; |
| 169 | |
| 170 | /* File handle structure */ |
| 171 | struct vpfe_fh { |
Lad, Prabhakar | 3bdaa38 | 2014-03-22 08:39:24 -0300 | [diff] [blame] | 172 | struct v4l2_fh fh; |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 173 | struct vpfe_device *vpfe_dev; |
| 174 | /* Indicates whether this file handle is doing IO */ |
| 175 | u8 io_allowed; |
Muralidharan Karicheri | 7da8a6c | 2009-07-06 15:04:12 -0300 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | struct vpfe_config_params { |
| 179 | u8 min_numbuffers; |
| 180 | u8 numbuffers; |
| 181 | u32 min_bufsize; |
| 182 | u32 device_bufsize; |
| 183 | }; |
| 184 | |
| 185 | #endif /* End of __KERNEL__ */ |
| 186 | /** |
| 187 | * VPFE_CMD_S_CCDC_RAW_PARAMS - EXPERIMENTAL IOCTL to set raw capture params |
| 188 | * This can be used to configure modules such as defect pixel correction, |
| 189 | * color space conversion, culling etc. This is an experimental ioctl that |
| 190 | * will change in future kernels. So use this ioctl with care ! |
| 191 | * TODO: This is to be split into multiple ioctls and also explore the |
| 192 | * possibility of extending the v4l2 api to include this |
| 193 | **/ |
| 194 | #define VPFE_CMD_S_CCDC_RAW_PARAMS _IOW('V', BASE_VIDIOC_PRIVATE + 1, \ |
| 195 | void *) |
| 196 | #endif /* _DAVINCI_VPFE_H */ |