diff options
author | Manjunath Hadli <manjunath.hadli@ti.com> | 2011-06-17 03:01:31 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-27 16:53:09 -0400 |
commit | a2c25b444e99f2369b29e507568c8703186174d0 (patch) | |
tree | c67e95cb9f0a3b83274b1f0c79c6c25fba3dc687 /include/media | |
parent | 9a78efc8fbd6776cd0f704be9cac7b013f3d3d16 (diff) |
[media] davinci vpbe: V4L2 display driver for DM644X SoC
This is the display driver for Texas Instruments's DM644X family
SoC. This patch contains the main implementation of the driver with the
V4L2 interface. The driver implements the streaming model with
support for both kernel allocated buffers and user pointers. It also
implements all of the necessary IOCTLs necessary and supported by the
video display device.
Signed-off-by: Manjunath Hadli <manjunath.hadli@ti.com>
Acked-by: Muralidharan Karicheri <m-karicheri2@ti.com>
Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'include/media')
-rw-r--r-- | include/media/davinci/vpbe_display.h | 147 | ||||
-rw-r--r-- | include/media/davinci/vpbe_types.h | 91 |
2 files changed, 238 insertions, 0 deletions
diff --git a/include/media/davinci/vpbe_display.h b/include/media/davinci/vpbe_display.h new file mode 100644 index 000000000000..dbf6b37682cd --- /dev/null +++ b/include/media/davinci/vpbe_display.h | |||
@@ -0,0 +1,147 @@ | |||
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> | ||
19 | #include <media/videobuf-dma-contig.h> | ||
20 | #include <media/davinci/vpbe_types.h> | ||
21 | #include <media/davinci/vpbe_osd.h> | ||
22 | #include <media/davinci/vpbe.h> | ||
23 | |||
24 | #define VPBE_DISPLAY_MAX_DEVICES 2 | ||
25 | |||
26 | enum vpbe_display_device_id { | ||
27 | VPBE_DISPLAY_DEVICE_0, | ||
28 | VPBE_DISPLAY_DEVICE_1 | ||
29 | }; | ||
30 | |||
31 | #define VPBE_DISPLAY_DRV_NAME "vpbe-display" | ||
32 | |||
33 | #define VPBE_DISPLAY_MAJOR_RELEASE 1 | ||
34 | #define VPBE_DISPLAY_MINOR_RELEASE 0 | ||
35 | #define VPBE_DISPLAY_BUILD 1 | ||
36 | #define VPBE_DISPLAY_VERSION_CODE ((VPBE_DISPLAY_MAJOR_RELEASE << 16) | \ | ||
37 | (VPBE_DISPLAY_MINOR_RELEASE << 8) | \ | ||
38 | VPBE_DISPLAY_BUILD) | ||
39 | |||
40 | #define VPBE_DISPLAY_VALID_FIELD(field) ((V4L2_FIELD_NONE == field) || \ | ||
41 | (V4L2_FIELD_ANY == field) || (V4L2_FIELD_INTERLACED == field)) | ||
42 | |||
43 | /* Exp ratio numerator and denominator constants */ | ||
44 | #define VPBE_DISPLAY_H_EXP_RATIO_N 9 | ||
45 | #define VPBE_DISPLAY_H_EXP_RATIO_D 8 | ||
46 | #define VPBE_DISPLAY_V_EXP_RATIO_N 6 | ||
47 | #define VPBE_DISPLAY_V_EXP_RATIO_D 5 | ||
48 | |||
49 | /* Zoom multiplication factor */ | ||
50 | #define VPBE_DISPLAY_ZOOM_4X 4 | ||
51 | #define VPBE_DISPLAY_ZOOM_2X 2 | ||
52 | |||
53 | /* Structures */ | ||
54 | struct display_layer_info { | ||
55 | int enable; | ||
56 | /* Layer ID used by Display Manager */ | ||
57 | enum osd_layer id; | ||
58 | struct osd_layer_config config; | ||
59 | enum osd_zoom_factor h_zoom; | ||
60 | enum osd_zoom_factor v_zoom; | ||
61 | enum osd_h_exp_ratio h_exp; | ||
62 | enum osd_v_exp_ratio v_exp; | ||
63 | }; | ||
64 | |||
65 | /* vpbe display object structure */ | ||
66 | struct vpbe_layer { | ||
67 | /* number of buffers in fbuffers */ | ||
68 | unsigned int numbuffers; | ||
69 | /* Pointer to the vpbe_display */ | ||
70 | struct vpbe_display *disp_dev; | ||
71 | /* Pointer pointing to current v4l2_buffer */ | ||
72 | struct videobuf_buffer *cur_frm; | ||
73 | /* Pointer pointing to next v4l2_buffer */ | ||
74 | struct videobuf_buffer *next_frm; | ||
75 | /* videobuf specific parameters | ||
76 | * Buffer queue used in video-buf | ||
77 | */ | ||
78 | struct videobuf_queue buffer_queue; | ||
79 | /* Queue of filled frames */ | ||
80 | struct list_head dma_queue; | ||
81 | /* Used in video-buf */ | ||
82 | spinlock_t irqlock; | ||
83 | /* V4l2 specific parameters */ | ||
84 | /* Identifies video device for this layer */ | ||
85 | struct video_device video_dev; | ||
86 | /* This field keeps track of type of buffer exchange mechanism user | ||
87 | * has selected | ||
88 | */ | ||
89 | enum v4l2_memory memory; | ||
90 | /* Used to keep track of state of the priority */ | ||
91 | struct v4l2_prio_state prio; | ||
92 | /* Used to store pixel format */ | ||
93 | struct v4l2_pix_format pix_fmt; | ||
94 | enum v4l2_field buf_field; | ||
95 | /* Video layer configuration params */ | ||
96 | struct display_layer_info layer_info; | ||
97 | /* vpbe specific parameters | ||
98 | * enable window for display | ||
99 | */ | ||
100 | unsigned char window_enable; | ||
101 | /* number of open instances of the layer */ | ||
102 | unsigned int usrs; | ||
103 | /* number of users performing IO */ | ||
104 | unsigned int io_usrs; | ||
105 | /* Indicates id of the field which is being displayed */ | ||
106 | unsigned int field_id; | ||
107 | /* Indicates whether streaming started */ | ||
108 | unsigned char started; | ||
109 | /* Identifies device object */ | ||
110 | enum vpbe_display_device_id device_id; | ||
111 | /* facilitation of ioctl ops lock by v4l2*/ | ||
112 | struct mutex opslock; | ||
113 | u8 layer_first_int; | ||
114 | }; | ||
115 | |||
116 | /* vpbe device structure */ | ||
117 | struct vpbe_display { | ||
118 | /* layer specific parameters */ | ||
119 | /* lock for isr updates to buf layers*/ | ||
120 | spinlock_t dma_queue_lock; | ||
121 | /* C-Plane offset from start of y-plane */ | ||
122 | unsigned int cbcr_ofst; | ||
123 | struct vpbe_layer *dev[VPBE_DISPLAY_MAX_DEVICES]; | ||
124 | struct vpbe_device *vpbe_dev; | ||
125 | struct osd_state *osd_device; | ||
126 | }; | ||
127 | |||
128 | /* File handle structure */ | ||
129 | struct vpbe_fh { | ||
130 | /* vpbe device structure */ | ||
131 | struct vpbe_display *disp_dev; | ||
132 | /* pointer to layer object for opened device */ | ||
133 | struct vpbe_layer *layer; | ||
134 | /* Indicates whether this file handle is doing IO */ | ||
135 | unsigned char io_allowed; | ||
136 | /* Used to keep track priority of this instance */ | ||
137 | enum v4l2_priority prio; | ||
138 | }; | ||
139 | |||
140 | struct buf_config_params { | ||
141 | unsigned char min_numbuffers; | ||
142 | unsigned char numbuffers[VPBE_DISPLAY_MAX_DEVICES]; | ||
143 | unsigned int min_bufsize[VPBE_DISPLAY_MAX_DEVICES]; | ||
144 | unsigned int layer_bufsize[VPBE_DISPLAY_MAX_DEVICES]; | ||
145 | }; | ||
146 | |||
147 | #endif /* VPBE_DISPLAY_H */ | ||
diff --git a/include/media/davinci/vpbe_types.h b/include/media/davinci/vpbe_types.h new file mode 100644 index 000000000000..727f55170e41 --- /dev/null +++ b/include/media/davinci/vpbe_types.h | |||
@@ -0,0 +1,91 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2010 Texas Instruments Inc | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed in the hope that it will be useful, | ||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program; if not, write to the Free Software | ||
15 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
16 | */ | ||
17 | #ifndef _VPBE_TYPES_H | ||
18 | #define _VPBE_TYPES_H | ||
19 | |||
20 | enum vpbe_version { | ||
21 | VPBE_VERSION_1 = 1, | ||
22 | VPBE_VERSION_2, | ||
23 | VPBE_VERSION_3, | ||
24 | }; | ||
25 | |||
26 | /* vpbe_timing_type - Timing types used in vpbe device */ | ||
27 | enum vpbe_enc_timings_type { | ||
28 | VPBE_ENC_STD = 0x1, | ||
29 | VPBE_ENC_DV_PRESET = 0x2, | ||
30 | VPBE_ENC_CUSTOM_TIMINGS = 0x4, | ||
31 | /* Used when set timings through FB device interface */ | ||
32 | VPBE_ENC_TIMINGS_INVALID = 0x8, | ||
33 | }; | ||
34 | |||
35 | union vpbe_timings { | ||
36 | v4l2_std_id std_id; | ||
37 | unsigned int dv_preset; | ||
38 | }; | ||
39 | |||
40 | /* | ||
41 | * struct vpbe_enc_mode_info | ||
42 | * @name: ptr to name string of the standard, "NTSC", "PAL" etc | ||
43 | * @std: standard or non-standard mode. 1 - standard, 0 - nonstandard | ||
44 | * @interlaced: 1 - interlaced, 0 - non interlaced/progressive | ||
45 | * @xres: x or horizontal resolution of the display | ||
46 | * @yres: y or vertical resolution of the display | ||
47 | * @fps: frame per second | ||
48 | * @left_margin: left margin of the display | ||
49 | * @right_margin: right margin of the display | ||
50 | * @upper_margin: upper margin of the display | ||
51 | * @lower_margin: lower margin of the display | ||
52 | * @hsync_len: h-sync length | ||
53 | * @vsync_len: v-sync length | ||
54 | * @flags: bit field: bit usage is documented below | ||
55 | * | ||
56 | * Description: | ||
57 | * Structure holding timing and resolution information of a standard. | ||
58 | * Used by vpbe_device to set required non-standard timing in the | ||
59 | * venc when lcd controller output is connected to a external encoder. | ||
60 | * A table of timings is maintained in vpbe device to set this in | ||
61 | * venc when external encoder is connected to lcd controller output. | ||
62 | * Encoder may provide a g_dv_timings() API to override these values | ||
63 | * as needed. | ||
64 | * | ||
65 | * Notes | ||
66 | * ------ | ||
67 | * if_type should be used only by encoder manager and encoder. | ||
68 | * flags usage | ||
69 | * b0 (LSB) - hsync polarity, 0 - negative, 1 - positive | ||
70 | * b1 - vsync polarity, 0 - negative, 1 - positive | ||
71 | * b2 - field id polarity, 0 - negative, 1 - positive | ||
72 | */ | ||
73 | struct vpbe_enc_mode_info { | ||
74 | unsigned char *name; | ||
75 | enum vpbe_enc_timings_type timings_type; | ||
76 | union vpbe_timings timings; | ||
77 | unsigned int interlaced; | ||
78 | unsigned int xres; | ||
79 | unsigned int yres; | ||
80 | struct v4l2_fract aspect; | ||
81 | struct v4l2_fract fps; | ||
82 | unsigned int left_margin; | ||
83 | unsigned int right_margin; | ||
84 | unsigned int upper_margin; | ||
85 | unsigned int lower_margin; | ||
86 | unsigned int hsync_len; | ||
87 | unsigned int vsync_len; | ||
88 | unsigned int flags; | ||
89 | }; | ||
90 | |||
91 | #endif | ||