1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * TI OMAP4 ISS V4L2 Driver - ISP IPIPEIF module
4  *
5  * Copyright (C) 2012 Texas Instruments, Inc.
6  *
7  * Author: Sergio Aguirre <sergio.a.aguirre@gmail.com>
8  */
9 
10 #ifndef OMAP4_ISS_IPIPEIF_H
11 #define OMAP4_ISS_IPIPEIF_H
12 
13 #include "iss_video.h"
14 
15 enum ipipeif_input_entity {
16 	IPIPEIF_INPUT_NONE,
17 	IPIPEIF_INPUT_CSI2A,
18 	IPIPEIF_INPUT_CSI2B
19 };
20 
21 #define IPIPEIF_OUTPUT_MEMORY			BIT(0)
22 #define IPIPEIF_OUTPUT_VP			BIT(1)
23 
24 /* Sink and source IPIPEIF pads */
25 #define IPIPEIF_PAD_SINK			0
26 #define IPIPEIF_PAD_SOURCE_ISIF_SF		1
27 #define IPIPEIF_PAD_SOURCE_VP			2
28 #define IPIPEIF_PADS_NUM			3
29 
30 /*
31  * struct iss_ipipeif_device - Structure for the IPIPEIF module to store its own
32  *			    information
33  * @subdev: V4L2 subdevice
34  * @pads: Sink and source media entity pads
35  * @formats: Active video formats
36  * @input: Active input
37  * @output: Active outputs
38  * @video_out: Output video node
39  * @error: A hardware error occurred during capture
40  * @alaw: A-law compression enabled (1) or disabled (0)
41  * @lpf: Low pass filter enabled (1) or disabled (0)
42  * @obclamp: Optical-black clamp enabled (1) or disabled (0)
43  * @fpc_en: Faulty pixels correction enabled (1) or disabled (0)
44  * @blcomp: Black level compensation configuration
45  * @clamp: Optical-black or digital clamp configuration
46  * @fpc: Faulty pixels correction configuration
47  * @lsc: Lens shading compensation configuration
48  * @update: Bitmask of controls to update during the next interrupt
49  * @shadow_update: Controls update in progress by userspace
50  * @syncif: Interface synchronization configuration
51  * @vpcfg: Video port configuration
52  * @underrun: A buffer underrun occurred and a new buffer has been queued
53  * @state: Streaming state
54  * @lock: Serializes shadow_update with interrupt handler
55  * @wait: Wait queue used to stop the module
56  * @stopping: Stopping state
57  * @ioctl_lock: Serializes ioctl calls and LSC requests freeing
58  */
59 struct iss_ipipeif_device {
60 	struct v4l2_subdev subdev;
61 	struct media_pad pads[IPIPEIF_PADS_NUM];
62 	struct v4l2_mbus_framefmt formats[IPIPEIF_PADS_NUM];
63 
64 	enum ipipeif_input_entity input;
65 	unsigned int output;
66 	struct iss_video video_out;
67 	unsigned int error;
68 
69 	enum iss_pipeline_stream_state state;
70 	wait_queue_head_t wait;
71 	atomic_t stopping;
72 };
73 
74 struct iss_device;
75 
76 int omap4iss_ipipeif_init(struct iss_device *iss);
77 int omap4iss_ipipeif_create_links(struct iss_device *iss);
78 void omap4iss_ipipeif_cleanup(struct iss_device *iss);
79 int omap4iss_ipipeif_register_entities(struct iss_ipipeif_device *ipipeif,
80 				       struct v4l2_device *vdev);
81 void omap4iss_ipipeif_unregister_entities(struct iss_ipipeif_device *ipipeif);
82 
83 int omap4iss_ipipeif_busy(struct iss_ipipeif_device *ipipeif);
84 void omap4iss_ipipeif_isr(struct iss_ipipeif_device *ipipeif, u32 events);
85 void omap4iss_ipipeif_restore_context(struct iss_device *iss);
86 void omap4iss_ipipeif_max_rate(struct iss_ipipeif_device *ipipeif,
87 			       unsigned int *max_rate);
88 
89 #endif	/* OMAP4_ISS_IPIPEIF_H */
90