Merge branch 'parisc-4.4-1' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
[linux-2.6-block.git] / include / media / davinci / vpbe_display.h
CommitLineData
a2c25b44
MH
1/*
2 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation version 2.
7 *
8 * This program is distributed WITHOUT ANY WARRANTY of any
9 * kind, whether express or implied; without even the implied warranty
10 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13#ifndef VPBE_DISPLAY_H
14#define VPBE_DISPLAY_H
15
16/* Header files */
17#include <linux/videodev2.h>
18#include <media/v4l2-common.h>
3d7543b9 19#include <media/v4l2-fh.h>
2d700715 20#include <media/videobuf2-v4l2.h>
13fc23d3 21#include <media/videobuf2-dma-contig.h>
a2c25b44
MH
22#include <media/davinci/vpbe_types.h>
23#include <media/davinci/vpbe_osd.h>
24#include <media/davinci/vpbe.h>
25
26#define VPBE_DISPLAY_MAX_DEVICES 2
27
28enum vpbe_display_device_id {
29 VPBE_DISPLAY_DEVICE_0,
30 VPBE_DISPLAY_DEVICE_1
31};
32
33#define VPBE_DISPLAY_DRV_NAME "vpbe-display"
34
35#define VPBE_DISPLAY_MAJOR_RELEASE 1
36#define VPBE_DISPLAY_MINOR_RELEASE 0
37#define VPBE_DISPLAY_BUILD 1
38#define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \
39 (VPBE_DISPLAY_MINOR_RELEASE << 8) | \
40 VPBE_DISPLAY_BUILD)
41
42#define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \
43 (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field))
44
45/* Exp ratio numerator and denominator constants */
46#define VPBE_DISPLAY_H_EXP_RATIO_N 9
47#define VPBE_DISPLAY_H_EXP_RATIO_D 8
48#define VPBE_DISPLAY_V_EXP_RATIO_N 6
49#define VPBE_DISPLAY_V_EXP_RATIO_D 5
50
51/* Zoom multiplication factor */
52#define VPBE_DISPLAY_ZOOM_4X 4
53#define VPBE_DISPLAY_ZOOM_2X 2
54
55/* Structures */
56struct display_layer_info {
57 int enable;
58 /* Layer ID used by Display Manager */
59 enum osd_layer id;
60 struct osd_layer_config config;
61 enum osd_zoom_factor h_zoom;
62 enum osd_zoom_factor v_zoom;
63 enum osd_h_exp_ratio h_exp;
64 enum osd_v_exp_ratio v_exp;
65};
66
13fc23d3 67struct vpbe_disp_buffer {
2d700715 68 struct vb2_v4l2_buffer vb;
13fc23d3
LP
69 struct list_head list;
70};
71
a2c25b44
MH
72/* vpbe display object structure */
73struct vpbe_layer {
a2c25b44
MH
74 /* Pointer to the vpbe_display */
75 struct vpbe_display *disp_dev;
76 /* Pointer pointing to current v4l2_buffer */
13fc23d3 77 struct vpbe_disp_buffer *cur_frm;
a2c25b44 78 /* Pointer pointing to next v4l2_buffer */
13fc23d3 79 struct vpbe_disp_buffer *next_frm;
a2c25b44
MH
80 /* videobuf specific parameters
81 * Buffer queue used in video-buf
82 */
13fc23d3
LP
83 struct vb2_queue buffer_queue;
84 /* allocator-specific contexts for each plane */
85 struct vb2_alloc_ctx *alloc_ctx;
a2c25b44
MH
86 /* Queue of filled frames */
87 struct list_head dma_queue;
88 /* Used in video-buf */
89 spinlock_t irqlock;
90 /* V4l2 specific parameters */
91 /* Identifies video device for this layer */
92 struct video_device video_dev;
a2c25b44
MH
93 /* Used to store pixel format */
94 struct v4l2_pix_format pix_fmt;
95 enum v4l2_field buf_field;
96 /* Video layer configuration params */
97 struct display_layer_info layer_info;
98 /* vpbe specific parameters
99 * enable window for display
100 */
101 unsigned char window_enable;
102 /* number of open instances of the layer */
103 unsigned int usrs;
a2c25b44
MH
104 /* Indicates id of the field which is being displayed */
105 unsigned int field_id;
a2c25b44
MH
106 /* Identifies device object */
107 enum vpbe_display_device_id device_id;
108 /* facilitation of ioctl ops lock by v4l2*/
109 struct mutex opslock;
110 u8 layer_first_int;
111};
112
113/* vpbe device structure */
114struct vpbe_display {
115 /* layer specific parameters */
116 /* lock for isr updates to buf layers*/
117 spinlock_t dma_queue_lock;
118 /* C-Plane offset from start of y-plane */
119 unsigned int cbcr_ofst;
120 struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
121 struct vpbe_device *vpbe_dev;
122 struct osd_state *osd_device;
123};
124
a2c25b44
MH
125struct buf_config_params {
126 unsigned char min_numbuffers;
127 unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
128 unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
129 unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
130};
131
132#endif /* VPBE_DISPLAY_H */