Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 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. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | |
| 19 | #ifndef VPIF_CAPTURE_H |
| 20 | #define VPIF_CAPTURE_H |
| 21 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 22 | /* Header files */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 23 | #include <media/videobuf2-dma-contig.h> |
Lad, Prabhakar | 012eef7 | 2013-04-19 05:53:29 -0300 | [diff] [blame] | 24 | #include <media/v4l2-device.h> |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 25 | |
| 26 | #include "vpif.h" |
| 27 | |
| 28 | /* Macros */ |
Mauro Carvalho Chehab | 64dc3c1 | 2011-06-25 11:28:37 -0300 | [diff] [blame] | 29 | #define VPIF_CAPTURE_VERSION "0.0.2" |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 30 | |
| 31 | #define VPIF_VALID_FIELD(field) (((V4L2_FIELD_ANY == field) || \ |
| 32 | (V4L2_FIELD_NONE == field)) || \ |
| 33 | (((V4L2_FIELD_INTERLACED == field) || \ |
| 34 | (V4L2_FIELD_SEQ_TB == field)) || \ |
| 35 | (V4L2_FIELD_SEQ_BT == field))) |
| 36 | |
| 37 | #define VPIF_CAPTURE_MAX_DEVICES 2 |
| 38 | #define VPIF_VIDEO_INDEX 0 |
| 39 | #define VPIF_NUMBER_OF_OBJECTS 1 |
| 40 | |
| 41 | /* Enumerated data type to give id to each device per channel */ |
| 42 | enum vpif_channel_id { |
| 43 | VPIF_CHANNEL0_VIDEO = 0, |
| 44 | VPIF_CHANNEL1_VIDEO, |
| 45 | }; |
| 46 | |
| 47 | struct video_obj { |
| 48 | enum v4l2_field buf_field; |
| 49 | /* Currently selected or default standard */ |
| 50 | v4l2_std_id stdid; |
Hans Verkuil | 0598c17 | 2012-09-18 07:18:47 -0300 | [diff] [blame] | 51 | struct v4l2_dv_timings dv_timings; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 52 | }; |
| 53 | |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 54 | struct vpif_cap_buffer { |
| 55 | struct vb2_buffer vb; |
| 56 | struct list_head list; |
| 57 | }; |
| 58 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 59 | struct common_obj { |
| 60 | /* Pointer pointing to current v4l2_buffer */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 61 | struct vpif_cap_buffer *cur_frm; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 62 | /* Pointer pointing to current v4l2_buffer */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 63 | struct vpif_cap_buffer *next_frm; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 64 | /* Used to store pixel format */ |
| 65 | struct v4l2_format fmt; |
| 66 | /* Buffer queue used in video-buf */ |
Lad, Prabhakar | 60aa38d | 2012-06-28 09:28:05 -0300 | [diff] [blame] | 67 | struct vb2_queue buffer_queue; |
| 68 | /* allocator-specific contexts for each plane */ |
| 69 | struct vb2_alloc_ctx *alloc_ctx; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 70 | /* Queue of filled frames */ |
| 71 | struct list_head dma_queue; |
| 72 | /* Used in video-buf */ |
| 73 | spinlock_t irqlock; |
| 74 | /* lock used to access this structure */ |
| 75 | struct mutex lock; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 76 | /* Function pointer to set the addresses */ |
| 77 | void (*set_addr) (unsigned long, unsigned long, unsigned long, |
| 78 | unsigned long); |
| 79 | /* offset where Y top starts from the starting of the buffer */ |
| 80 | u32 ytop_off; |
| 81 | /* offset where Y bottom starts from the starting of the buffer */ |
| 82 | u32 ybtm_off; |
| 83 | /* offset where C top starts from the starting of the buffer */ |
| 84 | u32 ctop_off; |
| 85 | /* offset where C bottom starts from the starting of the buffer */ |
| 86 | u32 cbtm_off; |
| 87 | /* Indicates width of the image data */ |
| 88 | u32 width; |
| 89 | /* Indicates height of the image data */ |
| 90 | u32 height; |
| 91 | }; |
| 92 | |
| 93 | struct channel_obj { |
| 94 | /* Identifies video device for this channel */ |
| 95 | struct video_device *video_dev; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 96 | /* Indicates id of the field which is being displayed */ |
| 97 | u32 field_id; |
| 98 | /* flag to indicate whether decoder is initialized */ |
| 99 | u8 initialized; |
| 100 | /* Identifies channel */ |
| 101 | enum vpif_channel_id channel_id; |
Hans Verkuil | 6f47c6c | 2012-09-20 09:06:22 -0300 | [diff] [blame] | 102 | /* Current input */ |
| 103 | u32 input_idx; |
Hans Verkuil | 178cce1 | 2012-09-20 09:06:30 -0300 | [diff] [blame] | 104 | /* subdev corresponding to the current input, may be NULL */ |
| 105 | struct v4l2_subdev *sd; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 106 | /* vpif configuration params */ |
| 107 | struct vpif_params vpifparams; |
| 108 | /* common object array */ |
| 109 | struct common_obj common[VPIF_NUMBER_OF_OBJECTS]; |
| 110 | /* video object */ |
| 111 | struct video_obj video; |
| 112 | }; |
| 113 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 114 | struct vpif_device { |
| 115 | struct v4l2_device v4l2_dev; |
| 116 | struct channel_obj *dev[VPIF_CAPTURE_NUM_CHANNELS]; |
| 117 | struct v4l2_subdev **sd; |
Lad, Prabhakar | 873229e | 2013-06-25 11:17:34 -0300 | [diff] [blame] | 118 | struct v4l2_async_notifier notifier; |
| 119 | struct vpif_capture_config *config; |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 120 | }; |
| 121 | |
Mauro Carvalho Chehab | ea06cc5 | 2014-05-24 16:32:44 -0300 | [diff] [blame] | 122 | struct vpif_config_params { |
| 123 | u8 min_numbuffers; |
| 124 | u8 numbuffers[VPIF_CAPTURE_NUM_CHANNELS]; |
| 125 | s8 device_type; |
| 126 | u32 min_bufsize[VPIF_CAPTURE_NUM_CHANNELS]; |
| 127 | u32 channel_bufsize[VPIF_CAPTURE_NUM_CHANNELS]; |
| 128 | u8 default_device[VPIF_CAPTURE_NUM_CHANNELS]; |
| 129 | u32 video_limit[VPIF_CAPTURE_NUM_CHANNELS]; |
| 130 | u8 max_device_type; |
| 131 | }; |
| 132 | |
Muralidharan Karicheri | 6ffefff | 2009-09-16 14:31:10 -0300 | [diff] [blame] | 133 | #endif /* VPIF_CAPTURE_H */ |