File Index
Files and directories
Sign in
FILE

camss-csid.h

File preview with syntax highlighting.

linux-6.19.14/drivers/media/platform/qcom/camss/camss-csid.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * camss-csid.h
  4 *
  5 * Qualcomm MSM Camera Subsystem - CSID (CSI Decoder) Module
  6 *
  7 * Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
  8 * Copyright (C) 2015-2018 Linaro Ltd.
  9 */
 10#ifndef QC_MSM_CAMSS_CSID_H
 11#define QC_MSM_CAMSS_CSID_H
 12
 13#include <linux/clk.h>
 14#include <linux/interrupt.h>
 15#include <media/media-entity.h>
 16#include <media/v4l2-ctrls.h>
 17#include <media/v4l2-device.h>
 18#include <media/v4l2-mediabus.h>
 19#include <media/v4l2-subdev.h>
 20
 21#define MSM_CSID_PAD_SINK 0
 22#define MSM_CSID_PAD_FIRST_SRC 1
 23#define MSM_CSID_PADS_NUM 5
 24
 25#define MSM_CSID_PAD_SRC (MSM_CSID_PAD_FIRST_SRC)
 26
 27/* CSID hardware can demultiplex up to 4 outputs */
 28#define MSM_CSID_MAX_SRC_STREAMS	4
 29
 30#define CSID_RESET_TIMEOUT_MS 500
 31
 32enum csid_testgen_mode {
 33	CSID_PAYLOAD_MODE_DISABLED = 0,
 34	CSID_PAYLOAD_MODE_INCREMENTING = 1,
 35	CSID_PAYLOAD_MODE_ALTERNATING_55_AA = 2,
 36	CSID_PAYLOAD_MODE_ALL_ZEROES = 3,
 37	CSID_PAYLOAD_MODE_ALL_ONES = 4,
 38	CSID_PAYLOAD_MODE_RANDOM = 5,
 39	CSID_PAYLOAD_MODE_USER_SPECIFIED = 6,
 40	CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN1 = 6, /* excluding disabled */
 41	CSID_PAYLOAD_MODE_COMPLEX_PATTERN = 7,
 42	CSID_PAYLOAD_MODE_COLOR_BOX = 8,
 43	CSID_PAYLOAD_MODE_COLOR_BARS = 9,
 44	CSID_PAYLOAD_MODE_NUM_SUPPORTED_GEN2 = 9, /* excluding disabled */
 45};
 46
 47struct csid_format_info {
 48	u32 code;
 49	u8 data_type;
 50	u8 decode_format;
 51	u8 bpp;
 52	u8 spp; /* bus samples per pixel */
 53};
 54
 55struct csid_formats {
 56	unsigned int nformats;
 57	const struct csid_format_info *formats;
 58};
 59
 60struct csid_testgen_config {
 61	enum csid_testgen_mode mode;
 62	const char * const*modes;
 63	u8 nmodes;
 64	u8 enabled;
 65};
 66
 67struct csid_phy_config {
 68	u8 csiphy_id;
 69	u8 lane_cnt;
 70	u32 lane_assign;
 71	u32 en_vc;
 72	u8 need_vc_update;
 73};
 74
 75struct csid_device;
 76
 77struct csid_hw_ops {
 78	/*
 79	 * configure_stream - Configures and starts CSID input stream
 80	 * @csid: CSID device
 81	 */
 82	void (*configure_stream)(struct csid_device *csid, u8 enable);
 83
 84	/*
 85	 * configure_testgen_pattern - Validates and configures output pattern mode
 86	 * of test pattern generator
 87	 * @csid: CSID device
 88	 */
 89	int (*configure_testgen_pattern)(struct csid_device *csid, s32 val);
 90
 91	/*
 92	 * hw_version - Read hardware version register from hardware
 93	 * @csid: CSID device
 94	 */
 95	u32 (*hw_version)(struct csid_device *csid);
 96
 97	/*
 98	 * isr - CSID module interrupt service routine
 99	 * @irq: Interrupt line
100	 * @dev: CSID device
101	 *
102	 * Return IRQ_HANDLED on success
103	 */
104	irqreturn_t (*isr)(int irq, void *dev);
105
106	/*
107	 * reset - Trigger reset on CSID module and wait to complete
108	 * @csid: CSID device
109	 *
110	 * Return 0 on success or a negative error code otherwise
111	 */
112	int (*reset)(struct csid_device *csid);
113
114	/*
115	 * src_pad_code - Pick an output/src format based on the input/sink format
116	 * @csid: CSID device
117	 * @sink_code: The sink format of the input
118	 * @match_format_idx: Request preferred index, as defined by subdevice csid_format.
119	 *	Set @match_code to 0 if used.
120	 * @match_code: Request preferred code, set @match_format_idx to 0 if used
121	 *
122	 * Return 0 on failure or src format code otherwise
123	 */
124	u32 (*src_pad_code)(struct csid_device *csid, u32 sink_code,
125			    unsigned int match_format_idx, u32 match_code);
126
127	/*
128	 * subdev_init - Initialize CSID device according for hardware revision
129	 * @csid: CSID device
130	 */
131	void (*subdev_init)(struct csid_device *csid);
132
133	/*
134	 * reg_update - receive message from other sub device
135	 * @csid: CSID device
136	 * @port_id: Port id
137	 * @is_clear: Indicate if it is clearing reg update or setting reg update
138	 */
139	void (*reg_update)(struct csid_device *csid, int port_id, bool is_clear);
140};
141
142struct csid_subdev_resources {
143	bool is_lite;
144	const struct csid_hw_ops *hw_ops;
145	const struct parent_dev_ops *parent_dev_ops;
146	const struct csid_formats *formats;
147};
148
149struct csid_device {
150	struct camss *camss;
151	u8 id;
152	struct v4l2_subdev subdev;
153	struct media_pad pads[MSM_CSID_PADS_NUM];
154	void __iomem *base;
155	u32 irq;
156	char irq_name[30];
157	u32 reg_update;
158	struct camss_clock *clock;
159	int nclocks;
160	struct regulator_bulk_data *supplies;
161	int num_supplies;
162	struct completion reset_complete;
163	struct csid_testgen_config testgen;
164	struct csid_phy_config phy;
165	struct v4l2_mbus_framefmt fmt[MSM_CSID_PADS_NUM];
166	struct v4l2_ctrl_handler ctrls;
167	struct v4l2_ctrl *testgen_mode;
168	const struct csid_subdev_resources *res;
169};
170
171struct camss_subdev_resources;
172
173/*
174 * csid_find_code - Find a format code in an array using array index or format code
175 * @codes: Array of format codes
176 * @ncodes: Length of @code array
177 * @req_format_idx: Request preferred index, as defined by subdevice csid_format.
178 *	Set @match_code to 0 if used.
179 * @match_code: Request preferred code, set @req_format_idx to 0 if used
180 *
181 * Return 0 on failure or format code otherwise
182 */
183u32 csid_find_code(u32 *codes, unsigned int ncode,
184		   unsigned int match_format_idx, u32 match_code);
185
186/*
187 * csid_get_fmt_entry - Find csid_format_info entry with matching format code
188 * @formats: Array of format csid_format_info entries
189 * @nformats: Length of @nformats array
190 * @code: Desired format code
191 *
192 * Return formats[0] on failure to find code
193 */
194const struct csid_format_info *csid_get_fmt_entry(const struct csid_format_info *formats,
195						  unsigned int nformats,
196						  u32 code);
197
198int msm_csid_subdev_init(struct camss *camss, struct csid_device *csid,
199			 const struct camss_subdev_resources *res, u8 id);
200
201int msm_csid_register_entity(struct csid_device *csid,
202			     struct v4l2_device *v4l2_dev);
203
204void msm_csid_unregister_entity(struct csid_device *csid);
205
206void msm_csid_get_csid_id(struct media_entity *entity, u8 *id);
207
208extern const char * const csid_testgen_modes[];
209
210extern const struct csid_formats csid_formats_4_1;
211extern const struct csid_formats csid_formats_4_7;
212extern const struct csid_formats csid_formats_gen2;
213
214extern const struct csid_hw_ops csid_ops_4_1;
215extern const struct csid_hw_ops csid_ops_4_7;
216extern const struct csid_hw_ops csid_ops_340;
217extern const struct csid_hw_ops csid_ops_680;
218extern const struct csid_hw_ops csid_ops_gen2;
219extern const struct csid_hw_ops csid_ops_gen3;
220
221/*
222 * csid_is_lite - Check if CSID is CSID lite.
223 * @csid: CSID Device
224 *
225 * Return whether CSID is CSID lite
226 */
227bool csid_is_lite(struct csid_device *csid);
228
229/*
230 * csid_hw_version - CSID hardware version query
231 * @csid: CSID device
232 *
233 * Return HW version or error
234 */
235u32 csid_hw_version(struct csid_device *csid);
236
237/*
238 * csid_src_pad_code - Pick an output/src format based on the input/sink format
239 * @csid: CSID device
240 * @sink_code: The sink format of the input
241 * @match_format_idx: Request preferred index, as defined by subdevice csid
242 *                    format. Set @match_code to 0 if used.
243 * @match_code: Request preferred code, set @match_format_idx to 0 if used
244 *
245 * Return 0 on failure or src format code otherwise
246 */
247u32 csid_src_pad_code(struct csid_device *csid, u32 sink_code,
248		      unsigned int match_format_idx, u32 match_code);
249
250#endif /* QC_MSM_CAMSS_CSID_H */
~/ Read-only file preview.