Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 1 | /* |
Manjunath Hadli | 0a63172 | 2012-04-13 04:44:00 -0300 | [diff] [blame] | 2 | * VPIF display header file |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation version 2. |
| 9 | * |
| 10 | * This program is distributed .as is. WITHOUT ANY WARRANTY of any |
| 11 | * kind, whether express or implied; without even the implied warranty |
| 12 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | */ |
| 15 | |
| 16 | #ifndef DAVINCIHD_DISPLAY_H |
| 17 | #define DAVINCIHD_DISPLAY_H |
| 18 | |
| 19 | /* Header files */ |
| 20 | #include <linux/videodev2.h> |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 21 | #include <media/v4l2-common.h> |
| 22 | #include <media/v4l2-device.h> |
| 23 | #include <media/videobuf-core.h> |
Lad, Prabhakar | 2401dd2 | 2012-06-28 09:28:36 -0300 | [diff] [blame] | 24 | #include <media/videobuf2-dma-contig.h> |
Manjunath Hadli | e13c692 | 2011-11-12 20:36:02 +0530 | [diff] [blame] | 25 | #include <media/davinci/vpif_types.h> |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 26 | |
| 27 | #include "vpif.h" |
| 28 | |
| 29 | /* Macros */ |
Mauro Carvalho Chehab | 64dc3c1 | 2011-06-25 11:28:37 -0300 | [diff] [blame] | 30 | #define VPIF_DISPLAY_VERSION "0.0.2" |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 31 | |
| 32 | #define VPIF_VALID_FIELD(field) \ |
| 33 | (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \ |
| 34 | (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \ |
| 35 | (V4L2_FIELD_SEQ_BT == field))) |
| 36 | |
| 37 | #define VPIF_DISPLAY_MAX_DEVICES (2) |
| 38 | #define VPIF_SLICED_BUF_SIZE (256) |
| 39 | #define VPIF_SLICED_MAX_SERVICES (3) |
| 40 | #define VPIF_VIDEO_INDEX (0) |
| 41 | #define VPIF_VBI_INDEX (1) |
| 42 | #define VPIF_HBI_INDEX (2) |
| 43 | |
| 44 | /* Setting it to 1 as HBI/VBI support yet to be added , else 3*/ |
| 45 | #define VPIF_NUMOBJECTS (1) |
| 46 | |
| 47 | /* Macros */ |
| 48 | #define ISALIGNED(a) (0 == ((a) & 7)) |
| 49 | |
| 50 | /* enumerated data types */ |
| 51 | /* Enumerated data type to give id to each device per channel */ |
| 52 | enum vpif_channel_id { |
| 53 | VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */ |
| 54 | VPIF_CHANNEL3_VIDEO, /* Channel3 Video */ |
| 55 | }; |
| 56 | |
| 57 | /* structures */ |
| 58 | |
| 59 | struct video_obj { |
| 60 | enum v4l2_field buf_field; |
| 61 | u32 latest_only; /* indicate whether to return |
| 62 | * most recent displayed frame only */ |
| 63 | v4l2_std_id stdid; /* Currently selected or default |
| 64 | * standard */ |
Hans Verkuil | 0598c17 | 2012-09-18 07:18:47 -0300 | [diff] [blame^] | 65 | struct v4l2_dv_timings dv_timings; |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 66 | u32 output_id; /* Current output id */ |
| 67 | }; |
| 68 | |
| 69 | struct vbi_obj { |
| 70 | int num_services; |
| 71 | struct vpif_vbi_params vbiparams; /* vpif parameters for the raw |
| 72 | * vbi data */ |
| 73 | }; |
| 74 | |
Lad, Prabhakar | 2401dd2 | 2012-06-28 09:28:36 -0300 | [diff] [blame] | 75 | struct vpif_disp_buffer { |
| 76 | struct vb2_buffer vb; |
| 77 | struct list_head list; |
| 78 | }; |
| 79 | |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 80 | struct common_obj { |
| 81 | /* Buffer specific parameters */ |
| 82 | u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for |
| 83 | * storing frames */ |
| 84 | u32 numbuffers; /* number of buffers */ |
Lad, Prabhakar | 2401dd2 | 2012-06-28 09:28:36 -0300 | [diff] [blame] | 85 | struct vpif_disp_buffer *cur_frm; /* Pointer pointing to current |
| 86 | * vb2_buffer */ |
| 87 | struct vpif_disp_buffer *next_frm; /* Pointer pointing to next |
| 88 | * vb2_buffer */ |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 89 | enum v4l2_memory memory; /* This field keeps track of |
| 90 | * type of buffer exchange |
| 91 | * method user has selected */ |
| 92 | struct v4l2_format fmt; /* Used to store the format */ |
Lad, Prabhakar | 2401dd2 | 2012-06-28 09:28:36 -0300 | [diff] [blame] | 93 | struct vb2_queue buffer_queue; /* Buffer queue used in |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 94 | * video-buf */ |
Lad, Prabhakar | 2401dd2 | 2012-06-28 09:28:36 -0300 | [diff] [blame] | 95 | /* allocator-specific contexts for each plane */ |
| 96 | struct vb2_alloc_ctx *alloc_ctx; |
| 97 | |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 98 | struct list_head dma_queue; /* Queue of filled frames */ |
| 99 | spinlock_t irqlock; /* Used in video-buf */ |
| 100 | |
| 101 | /* channel specific parameters */ |
| 102 | struct mutex lock; /* lock used to access this |
| 103 | * structure */ |
| 104 | u32 io_usrs; /* number of users performing |
| 105 | * IO */ |
| 106 | u8 started; /* Indicates whether streaming |
| 107 | * started */ |
| 108 | u32 ytop_off; /* offset of Y top from the |
| 109 | * starting of the buffer */ |
| 110 | u32 ybtm_off; /* offset of Y bottom from the |
| 111 | * starting of the buffer */ |
| 112 | u32 ctop_off; /* offset of C top from the |
| 113 | * starting of the buffer */ |
| 114 | u32 cbtm_off; /* offset of C bottom from the |
| 115 | * starting of the buffer */ |
| 116 | /* Function pointer to set the addresses */ |
| 117 | void (*set_addr) (unsigned long, unsigned long, |
| 118 | unsigned long, unsigned long); |
| 119 | u32 height; |
| 120 | u32 width; |
| 121 | }; |
| 122 | |
| 123 | struct channel_obj { |
| 124 | /* V4l2 specific parameters */ |
| 125 | struct video_device *video_dev; /* Identifies video device for |
| 126 | * this channel */ |
| 127 | struct v4l2_prio_state prio; /* Used to keep track of state of |
| 128 | * the priority */ |
| 129 | atomic_t usrs; /* number of open instances of |
| 130 | * the channel */ |
| 131 | u32 field_id; /* Indicates id of the field |
| 132 | * which is being displayed */ |
| 133 | u8 initialized; /* flag to indicate whether |
| 134 | * encoder is initialized */ |
| 135 | |
| 136 | enum vpif_channel_id channel_id;/* Identifies channel */ |
| 137 | struct vpif_params vpifparams; |
| 138 | struct common_obj common[VPIF_NUMOBJECTS]; |
| 139 | struct video_obj video; |
| 140 | struct vbi_obj vbi; |
| 141 | }; |
| 142 | |
| 143 | /* File handle structure */ |
| 144 | struct vpif_fh { |
| 145 | struct channel_obj *channel; /* pointer to channel object for |
| 146 | * opened device */ |
| 147 | u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle |
| 148 | * is doing IO */ |
| 149 | enum v4l2_priority prio; /* Used to keep track priority of |
| 150 | * this instance */ |
| 151 | u8 initialized; /* Used to keep track of whether this |
| 152 | * file handle has initialized |
| 153 | * channel or not */ |
| 154 | }; |
| 155 | |
| 156 | /* vpif device structure */ |
| 157 | struct vpif_device { |
| 158 | struct v4l2_device v4l2_dev; |
| 159 | struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS]; |
| 160 | struct v4l2_subdev **sd; |
| 161 | |
| 162 | }; |
| 163 | |
| 164 | struct vpif_config_params { |
| 165 | u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS]; |
| 166 | u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS]; |
| 167 | u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS]; |
Manjunath Hadli | fc613d4 | 2012-04-13 04:49:10 -0300 | [diff] [blame] | 168 | u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS]; |
Chaithrika U S | e7332e3 | 2009-06-09 05:55:37 -0300 | [diff] [blame] | 169 | u8 min_numbuffers; |
| 170 | }; |
| 171 | |
| 172 | /* Struct which keeps track of the line numbers for the sliced vbi service */ |
| 173 | struct vpif_service_line { |
| 174 | u16 service_id; |
| 175 | u16 service_line[2]; |
| 176 | u16 enc_service_id; |
| 177 | u8 bytestowrite; |
| 178 | }; |
| 179 | |
| 180 | #endif /* DAVINCIHD_DISPLAY_H */ |