blob: 5414542912e2723b39f0ec034293af10ab7c279c [file] [log] [blame]
Laurent Pinchartde1135d2011-02-12 18:05:06 -03001/*
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.
Laurent Pinchartde1135d2011-02-12 18:05:06 -030015 */
16
17#ifndef OMAP3_ISP_RESIZER_H
18#define OMAP3_ISP_RESIZER_H
19
Laurent Pinchartcd73bb62014-07-23 10:30:57 -030020#include <linux/spinlock.h>
Laurent Pinchartde1135d2011-02-12 18:05:06 -030021#include <linux/types.h>
22
23/*
Lad, Prabhakar25aeb412014-02-21 09:07:21 -030024 * Constants for filter coefficients count
Laurent Pinchartde1135d2011-02-12 18:05:06 -030025 */
26#define COEFF_CNT 32
27
28/*
Lad, Prabhakar25aeb412014-02-21 09:07:21 -030029 * struct isprsz_coef - Structure for resizer filter coefficients.
Laurent Pinchartde1135d2011-02-12 18:05:06 -030030 * @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 */
39struct 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 */
48enum 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 */
54enum 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 */
62struct resizer_ratio {
63 u32 horz;
64 u32 vert;
65};
66
67/*
68 * Structure for luminance enhancer parameters.
69 */
70struct resizer_luma_yenh {
71 u8 algo; /* algorithm select. */
72 u8 gain; /* maximum gain. */
73 u8 slope; /* slope. */
74 u8 core; /* core offset. */
75};
76
77enum 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
Laurent Pinchartcd73bb62014-07-23 10:30:57 -030090 * @lock: Protects formats and crop rectangles between set_selection and IRQ
Laurent Pinchartde1135d2011-02-12 18:05:06 -030091 * @crop.request: Crop rectangle requested by the user
92 * @crop.active: Active crop rectangle (based on hardware requirements)
93 */
94struct 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;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300102
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;
Laurent Pinchartcd73bb62014-07-23 10:30:57 -0300111 spinlock_t lock;
Laurent Pinchartde1135d2011-02-12 18:05:06 -0300112
113 struct {
114 struct v4l2_rect request;
115 struct v4l2_rect active;
116 } crop;
117};
118
119struct isp_device;
120
121int omap3isp_resizer_init(struct isp_device *isp);
122void omap3isp_resizer_cleanup(struct isp_device *isp);
123
124int omap3isp_resizer_register_entities(struct isp_res_device *res,
125 struct v4l2_device *vdev);
126void omap3isp_resizer_unregister_entities(struct isp_res_device *res);
127void omap3isp_resizer_isr_frame_sync(struct isp_res_device *res);
128void omap3isp_resizer_isr(struct isp_res_device *isp_res);
129
130void omap3isp_resizer_max_rate(struct isp_res_device *res,
131 unsigned int *max_rate);
132
133void omap3isp_resizer_suspend(struct isp_res_device *isp_res);
134
135void omap3isp_resizer_resume(struct isp_res_device *isp_res);
136
137int omap3isp_resizer_busy(struct isp_res_device *isp_res);
138
139#endif /* OMAP3_ISP_RESIZER_H */