Add the rt linux 4.1.3-rt3 as base
[kvmfornfv.git] / kernel / drivers / media / platform / omap3isp / ispresizer.h
1 /*
2  * ispresizer.h
3  *
4  * TI OMAP3 ISP - Resizer module
5  *
6  * Copyright (C) 2010 Nokia Corporation
7  * Copyright (C) 2009 Texas Instruments, Inc
8  *
9  * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
10  *           Sakari Ailus <sakari.ailus@iki.fi>
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License version 2 as
14  * published by the Free Software Foundation.
15  */
16
17 #ifndef OMAP3_ISP_RESIZER_H
18 #define OMAP3_ISP_RESIZER_H
19
20 #include <linux/spinlock.h>
21 #include <linux/types.h>
22
23 /*
24  * Constants for filter coefficients count
25  */
26 #define COEFF_CNT               32
27
28 /*
29  * struct isprsz_coef - Structure for resizer filter coefficients.
30  * @h_filter_coef_4tap: Horizontal filter coefficients for 8-phase/4-tap
31  *                      mode (.5x-4x)
32  * @v_filter_coef_4tap: Vertical filter coefficients for 8-phase/4-tap
33  *                      mode (.5x-4x)
34  * @h_filter_coef_7tap: Horizontal filter coefficients for 4-phase/7-tap
35  *                      mode (.25x-.5x)
36  * @v_filter_coef_7tap: Vertical filter coefficients for 4-phase/7-tap
37  *                      mode (.25x-.5x)
38  */
39 struct isprsz_coef {
40         u16 h_filter_coef_4tap[32];
41         u16 v_filter_coef_4tap[32];
42         /* Every 8th value is a dummy value in the following arrays: */
43         u16 h_filter_coef_7tap[32];
44         u16 v_filter_coef_7tap[32];
45 };
46
47 /* Chrominance horizontal algorithm */
48 enum resizer_chroma_algo {
49         RSZ_THE_SAME = 0,       /* Chrominance the same as Luminance */
50         RSZ_BILINEAR = 1,       /* Chrominance uses bilinear interpolation */
51 };
52
53 /* Resizer input type select */
54 enum resizer_colors_type {
55         RSZ_YUV422 = 0,         /* YUV422 color is interleaved */
56         RSZ_COLOR8 = 1,         /* Color separate data on 8 bits */
57 };
58
59 /*
60  * Structure for horizontal and vertical resizing value
61  */
62 struct resizer_ratio {
63         u32 horz;
64         u32 vert;
65 };
66
67 /*
68  * Structure for luminance enhancer parameters.
69  */
70 struct resizer_luma_yenh {
71         u8 algo;                /* algorithm select. */
72         u8 gain;                /* maximum gain. */
73         u8 slope;               /* slope. */
74         u8 core;                /* core offset. */
75 };
76
77 enum resizer_input_entity {
78         RESIZER_INPUT_NONE,
79         RESIZER_INPUT_VP,       /* input video port - prev or ccdc */
80         RESIZER_INPUT_MEMORY,
81 };
82
83 /* Sink and source resizer pads */
84 #define RESZ_PAD_SINK                   0
85 #define RESZ_PAD_SOURCE                 1
86 #define RESZ_PADS_NUM                   2
87
88 /*
89  * struct isp_res_device - OMAP3 ISP resizer module
90  * @lock: Protects formats and crop rectangles between set_selection and IRQ
91  * @crop.request: Crop rectangle requested by the user
92  * @crop.active: Active crop rectangle (based on hardware requirements)
93  */
94 struct isp_res_device {
95         struct v4l2_subdev subdev;
96         struct media_pad pads[RESZ_PADS_NUM];
97         struct v4l2_mbus_framefmt formats[RESZ_PADS_NUM];
98
99         enum resizer_input_entity input;
100         struct isp_video video_in;
101         struct isp_video video_out;
102
103         u32 addr_base;   /* stored source buffer address in memory mode */
104         u32 crop_offset; /* additional offset for crop in memory mode */
105         struct resizer_ratio ratio;
106         int pm_state;
107         unsigned int applycrop:1;
108         enum isp_pipeline_stream_state state;
109         wait_queue_head_t wait;
110         atomic_t stopping;
111         spinlock_t lock;
112
113         struct {
114                 struct v4l2_rect request;
115                 struct v4l2_rect active;
116         } crop;
117 };
118
119 struct isp_device;
120
121 int omap3isp_resizer_init(struct isp_device *isp);
122 void omap3isp_resizer_cleanup(struct isp_device *isp);
123
124 int omap3isp_resizer_register_entities(struct isp_res_device *res,
125                                        struct v4l2_device *vdev);
126 void omap3isp_resizer_unregister_entities(struct isp_res_device *res);
127 void omap3isp_resizer_isr_frame_sync(struct isp_res_device *res);
128 void omap3isp_resizer_isr(struct isp_res_device *isp_res);
129
130 void omap3isp_resizer_max_rate(struct isp_res_device *res,
131                                unsigned int *max_rate);
132
133 void omap3isp_resizer_suspend(struct isp_res_device *isp_res);
134
135 void omap3isp_resizer_resume(struct isp_res_device *isp_res);
136
137 int omap3isp_resizer_busy(struct isp_res_device *isp_res);
138
139 #endif  /* OMAP3_ISP_RESIZER_H */