blob: 12783fd823f8a8974ba8f787c69a673809096a8d [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;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030084 /* Queue of filled frames */
85 struct list_head dma_queue;
86 /* Used in video-buf */
87 spinlock_t irqlock;
88 /* V4l2 specific parameters */
89 /* Identifies video device for this layer */
90 struct video_device video_dev;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -030091 /* Used to store pixel format */
92 struct v4l2_pix_format pix_fmt;
93 enum v4l2_field buf_field;
94 /* Video layer configuration params */
95 struct display_layer_info layer_info;
96 /* vpbe specific parameters
97 * enable window for display
98 */
99 unsigned char window_enable;
100 /* number of open instances of the layer */
101 unsigned int usrs;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300102 /* Indicates id of the field which is being displayed */
103 unsigned int field_id;
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300104 /* Identifies device object */
105 enum vpbe_display_device_id device_id;
106 /* facilitation of ioctl ops lock by v4l2*/
107 struct mutex opslock;
108 u8 layer_first_int;
109};
110
111/* vpbe device structure */
112struct vpbe_display {
113 /* layer specific parameters */
114 /* lock for isr updates to buf layers*/
115 spinlock_t dma_queue_lock;
116 /* C-Plane offset from start of y-plane */
117 unsigned int cbcr_ofst;
118 struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES];
119 struct vpbe_device *vpbe_dev;
120 struct osd_state *osd_device;
121};
122
Manjunath Hadlia2c25b42011-06-17 04:01:31 -0300123struct buf_config_params {
124 unsigned char min_numbuffers;
125 unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES];
126 unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES];
127 unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES];
128};
129
130#endif /* VPBE_DISPLAY_H */