blob: a5a18f74395cdfa80a8f5e56d314f949afcb9f84 [file] [log] [blame]
Chaithrika U Se7332e32009-06-09 05:55:37 -03001/*
Manjunath Hadli0a631722012-04-13 04:44:00 -03002 * VPIF display header file
Chaithrika U Se7332e32009-06-09 05:55:37 -03003 *
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 Se7332e32009-06-09 05:55:37 -030021#include <media/v4l2-common.h>
22#include <media/v4l2-device.h>
Lad, Prabhakar2401dd22012-06-28 09:28:36 -030023#include <media/videobuf2-dma-contig.h>
Manjunath Hadlie13c6922011-11-12 20:36:02 +053024#include <media/davinci/vpif_types.h>
Chaithrika U Se7332e32009-06-09 05:55:37 -030025
26#include "vpif.h"
27
28/* Macros */
Mauro Carvalho Chehab64dc3c12011-06-25 11:28:37 -030029#define VPIF_DISPLAY_VERSION "0.0.2"
Chaithrika U Se7332e32009-06-09 05:55:37 -030030
31#define VPIF_VALID_FIELD(field) \
32 (((V4L2_FIELD_ANY == field) || (V4L2_FIELD_NONE == field)) || \
33 (((V4L2_FIELD_INTERLACED == field) || (V4L2_FIELD_SEQ_TB == field)) || \
34 (V4L2_FIELD_SEQ_BT == field)))
35
36#define VPIF_DISPLAY_MAX_DEVICES (2)
37#define VPIF_SLICED_BUF_SIZE (256)
38#define VPIF_SLICED_MAX_SERVICES (3)
39#define VPIF_VIDEO_INDEX (0)
40#define VPIF_VBI_INDEX (1)
41#define VPIF_HBI_INDEX (2)
42
43/* Setting it to 1 as HBI/VBI support yet to be added , else 3*/
44#define VPIF_NUMOBJECTS (1)
45
46/* Macros */
47#define ISALIGNED(a) (0 == ((a) & 7))
48
49/* enumerated data types */
50/* Enumerated data type to give id to each device per channel */
51enum vpif_channel_id {
52 VPIF_CHANNEL2_VIDEO = 0, /* Channel2 Video */
53 VPIF_CHANNEL3_VIDEO, /* Channel3 Video */
54};
55
56/* structures */
57
58struct video_obj {
59 enum v4l2_field buf_field;
60 u32 latest_only; /* indicate whether to return
61 * most recent displayed frame only */
62 v4l2_std_id stdid; /* Currently selected or default
63 * standard */
Hans Verkuil0598c172012-09-18 07:18:47 -030064 struct v4l2_dv_timings dv_timings;
Chaithrika U Se7332e32009-06-09 05:55:37 -030065};
66
Lad, Prabhakar2401dd22012-06-28 09:28:36 -030067struct vpif_disp_buffer {
68 struct vb2_buffer vb;
69 struct list_head list;
70};
71
Chaithrika U Se7332e32009-06-09 05:55:37 -030072struct common_obj {
73 /* Buffer specific parameters */
74 u8 *fbuffers[VIDEO_MAX_FRAME]; /* List of buffer pointers for
75 * storing frames */
76 u32 numbuffers; /* number of buffers */
Lad, Prabhakar2401dd22012-06-28 09:28:36 -030077 struct vpif_disp_buffer *cur_frm; /* Pointer pointing to current
78 * vb2_buffer */
79 struct vpif_disp_buffer *next_frm; /* Pointer pointing to next
80 * vb2_buffer */
Chaithrika U Se7332e32009-06-09 05:55:37 -030081 enum v4l2_memory memory; /* This field keeps track of
82 * type of buffer exchange
83 * method user has selected */
84 struct v4l2_format fmt; /* Used to store the format */
Lad, Prabhakar2401dd22012-06-28 09:28:36 -030085 struct vb2_queue buffer_queue; /* Buffer queue used in
Chaithrika U Se7332e32009-06-09 05:55:37 -030086 * video-buf */
Lad, Prabhakar2401dd22012-06-28 09:28:36 -030087 /* allocator-specific contexts for each plane */
88 struct vb2_alloc_ctx *alloc_ctx;
89
Chaithrika U Se7332e32009-06-09 05:55:37 -030090 struct list_head dma_queue; /* Queue of filled frames */
91 spinlock_t irqlock; /* Used in video-buf */
92
93 /* channel specific parameters */
94 struct mutex lock; /* lock used to access this
95 * structure */
96 u32 io_usrs; /* number of users performing
97 * IO */
98 u8 started; /* Indicates whether streaming
99 * started */
100 u32 ytop_off; /* offset of Y top from the
101 * starting of the buffer */
102 u32 ybtm_off; /* offset of Y bottom from the
103 * starting of the buffer */
104 u32 ctop_off; /* offset of C top from the
105 * starting of the buffer */
106 u32 cbtm_off; /* offset of C bottom from the
107 * starting of the buffer */
108 /* Function pointer to set the addresses */
109 void (*set_addr) (unsigned long, unsigned long,
110 unsigned long, unsigned long);
111 u32 height;
112 u32 width;
113};
114
115struct channel_obj {
116 /* V4l2 specific parameters */
117 struct video_device *video_dev; /* Identifies video device for
118 * this channel */
119 struct v4l2_prio_state prio; /* Used to keep track of state of
120 * the priority */
121 atomic_t usrs; /* number of open instances of
122 * the channel */
123 u32 field_id; /* Indicates id of the field
124 * which is being displayed */
125 u8 initialized; /* flag to indicate whether
126 * encoder is initialized */
Hans Verkuil311673e2012-09-20 09:06:23 -0300127 u32 output_idx; /* Current output index */
Hans Verkuil882084a2012-09-20 09:06:31 -0300128 struct v4l2_subdev *sd; /* Current output subdev(may be NULL) */
Chaithrika U Se7332e32009-06-09 05:55:37 -0300129
130 enum vpif_channel_id channel_id;/* Identifies channel */
131 struct vpif_params vpifparams;
132 struct common_obj common[VPIF_NUMOBJECTS];
133 struct video_obj video;
Chaithrika U Se7332e32009-06-09 05:55:37 -0300134};
135
136/* File handle structure */
137struct vpif_fh {
138 struct channel_obj *channel; /* pointer to channel object for
139 * opened device */
140 u8 io_allowed[VPIF_NUMOBJECTS]; /* Indicates whether this file handle
141 * is doing IO */
142 enum v4l2_priority prio; /* Used to keep track priority of
143 * this instance */
144 u8 initialized; /* Used to keep track of whether this
145 * file handle has initialized
146 * channel or not */
147};
148
149/* vpif device structure */
150struct vpif_device {
151 struct v4l2_device v4l2_dev;
152 struct channel_obj *dev[VPIF_DISPLAY_NUM_CHANNELS];
153 struct v4l2_subdev **sd;
154
155};
156
157struct vpif_config_params {
158 u32 min_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
159 u32 channel_bufsize[VPIF_DISPLAY_NUM_CHANNELS];
160 u8 numbuffers[VPIF_DISPLAY_NUM_CHANNELS];
Manjunath Hadlifc613d42012-04-13 04:49:10 -0300161 u32 video_limit[VPIF_DISPLAY_NUM_CHANNELS];
Chaithrika U Se7332e32009-06-09 05:55:37 -0300162 u8 min_numbuffers;
163};
164
Chaithrika U Se7332e32009-06-09 05:55:37 -0300165#endif /* DAVINCIHD_DISPLAY_H */