blob: e14a9370b67e0fc713d0823b2230935f37982094 [file] [log] [blame]
Manjunath Hadlia2c25b42011-06-17 04:01:31 -03001/*
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>
Lad, Prabhakar3d7543b92014-03-22 07:57:59 -030019#include <media/v4l2-fh.h>
Junghak Sung2d700712015-09-22 10:30:30 -030020#include <media/videobuf2-v4l2.h>
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030021#include <media/videobuf2-dma-contig.h>
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030022#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
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030067struct vpbe_disp_buffer {
Junghak Sung2d700712015-09-22 10:30:30 -030068 struct vb2_v4l2_buffer vb;
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030069 struct list_head list;
70};
71
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030072/* vpbe display object structure */
73struct vpbe_layer {
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030074 /* Pointer to the vpbe_display */
75 struct vpbe_display *disp_dev;
76 /* Pointer pointing to current v4l2_buffer */
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030077 struct vpbe_disp_buffer *cur_frm;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030078 /* Pointer pointing to next v4l2_buffer */
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030079 struct vpbe_disp_buffer *next_frm;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030080 /* videobuf specific parameters
81 * Buffer queue used in video-buf
82 */
Lad, Prabhakar13fc23d32012-10-22 09:27:13 -030083 struct vb2_queue buffer_queue;
84 /* allocator-specific contexts for each plane */
85 struct vb2_alloc_ctx *alloc_ctx;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030086 /* 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;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030093 /* 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;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300104 /* Indicates id of the field which is being displayed */
105 unsigned int field_id;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300106 /* 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
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300125struct 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 */