1 /* SPDX-License-Identifier: GPL-2.0-only */
5 * TI OMAP3 ISP - CCDC module
7 * Copyright (C) 2009-2010 Nokia Corporation
8 * Copyright (C) 2009 Texas Instruments, Inc.
10 * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
11 * Sakari Ailus <sakari.ailus@iki.fi>
14 #ifndef OMAP3_ISP_CCDC_H
15 #define OMAP3_ISP_CCDC_H
17 #include <linux/omap3isp.h>
18 #include <linux/workqueue.h>
22 enum ccdc_input_entity
{
30 #define CCDC_OUTPUT_MEMORY (1 << 0)
31 #define CCDC_OUTPUT_PREVIEW (1 << 1)
32 #define CCDC_OUTPUT_RESIZER (1 << 2)
34 #define OMAP3ISP_CCDC_NEVENTS 16
42 enum ispccdc_lsc_state
{
43 LSC_STATE_STOPPED
= 0,
44 LSC_STATE_STOPPING
= 1,
45 LSC_STATE_RUNNING
= 2,
46 LSC_STATE_RECONFIG
= 3,
49 struct ispccdc_lsc_config_req
{
50 struct list_head list
;
51 struct omap3isp_ccdc_lsc_config config
;
62 * ispccdc_lsc - CCDC LSC parameters
65 enum ispccdc_lsc_state state
;
66 struct work_struct table_work
;
68 /* LSC queue of configurations */
70 struct ispccdc_lsc_config_req
*request
; /* requested configuration */
71 struct ispccdc_lsc_config_req
*active
; /* active configuration */
72 struct list_head free_queue
; /* configurations for freeing */
75 #define CCDC_STOP_NOT_REQUESTED 0x00
76 #define CCDC_STOP_REQUEST 0x01
77 #define CCDC_STOP_EXECUTED (0x02 | CCDC_STOP_REQUEST)
78 #define CCDC_STOP_CCDC_FINISHED 0x04
79 #define CCDC_STOP_LSC_FINISHED 0x08
80 #define CCDC_STOP_FINISHED \
81 (CCDC_STOP_EXECUTED | CCDC_STOP_CCDC_FINISHED | CCDC_STOP_LSC_FINISHED)
83 #define CCDC_EVENT_VD1 0x10
84 #define CCDC_EVENT_VD0 0x20
85 #define CCDC_EVENT_LSC_DONE 0x40
87 /* Sink and source CCDC pads */
88 #define CCDC_PAD_SINK 0
89 #define CCDC_PAD_SOURCE_OF 1
90 #define CCDC_PAD_SOURCE_VP 2
91 #define CCDC_PADS_NUM 3
93 #define CCDC_FIELD_TOP 1
94 #define CCDC_FIELD_BOTTOM 2
95 #define CCDC_FIELD_BOTH 3
98 * struct isp_ccdc_device - Structure for the CCDC module to store its own
100 * @subdev: V4L2 subdevice
101 * @pads: Sink and source media entity pads
102 * @formats: Active video formats
103 * @crop: Active crop rectangle on the OF source pad
104 * @input: Active input
105 * @output: Active outputs
106 * @video_out: Output video node
107 * @alaw: A-law compression enabled (1) or disabled (0)
108 * @lpf: Low pass filter enabled (1) or disabled (0)
109 * @obclamp: Optical-black clamp enabled (1) or disabled (0)
110 * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
111 * @blcomp: Black level compensation configuration
112 * @clamp: Optical-black or digital clamp configuration
113 * @fpc: Faulty pixels correction configuration
114 * @lsc: Lens shading compensation configuration
115 * @update: Bitmask of controls to update during the next interrupt
116 * @shadow_update: Controls update in progress by userspace
117 * @bt656: Whether the input interface uses BT.656 synchronization
118 * @fields: The fields (CCDC_FIELD_*) stored in the current buffer
119 * @underrun: A buffer underrun occurred and a new buffer has been queued
120 * @state: Streaming state
121 * @lock: Serializes shadow_update with interrupt handler
122 * @wait: Wait queue used to stop the module
123 * @stopping: Stopping state
124 * @running: Is the CCDC hardware running
125 * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
127 struct isp_ccdc_device
{
128 struct v4l2_subdev subdev
;
129 struct media_pad pads
[CCDC_PADS_NUM
];
130 struct v4l2_mbus_framefmt formats
[CCDC_PADS_NUM
];
131 struct v4l2_rect crop
;
133 enum ccdc_input_entity input
;
135 struct isp_video video_out
;
141 struct omap3isp_ccdc_blcomp blcomp
;
142 struct omap3isp_ccdc_bclamp clamp
;
143 struct ispccdc_fpc fpc
;
144 struct ispccdc_lsc lsc
;
146 unsigned int shadow_update
;
151 unsigned int underrun
:1;
152 enum isp_pipeline_stream_state state
;
154 wait_queue_head_t wait
;
155 unsigned int stopping
;
157 struct mutex ioctl_lock
;
162 int omap3isp_ccdc_init(struct isp_device
*isp
);
163 void omap3isp_ccdc_cleanup(struct isp_device
*isp
);
164 int omap3isp_ccdc_register_entities(struct isp_ccdc_device
*ccdc
,
165 struct v4l2_device
*vdev
);
166 void omap3isp_ccdc_unregister_entities(struct isp_ccdc_device
*ccdc
);
168 int omap3isp_ccdc_busy(struct isp_ccdc_device
*isp_ccdc
);
169 int omap3isp_ccdc_isr(struct isp_ccdc_device
*isp_ccdc
, u32 events
);
170 void omap3isp_ccdc_restore_context(struct isp_device
*isp
);
171 void omap3isp_ccdc_max_rate(struct isp_ccdc_device
*ccdc
,
172 unsigned int *max_rate
);
174 #endif /* OMAP3_ISP_CCDC_H */