Lines Matching +full:tx +full:- +full:enable

1 // SPDX-License-Identifier: GPL-2.0+
3 * Driver for Analog Devices ADV748X CSI-2 Transmitter
11 #include <media/v4l2-ctrls.h>
12 #include <media/v4l2-device.h>
13 #include <media/v4l2-ioctl.h>
17 int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx, unsigned int vc) in adv748x_csi2_set_virtual_channel() argument
19 return tx_write(tx, ADV748X_CSI_VC_REF, vc << ADV748X_CSI_VC_REF_SHIFT); in adv748x_csi2_set_virtual_channel()
25 * @tx: CSI2 private entity
28 * @src_pad: Pad number of source to link to this @tx
29 * @enable: Link enabled flag
34 static int adv748x_csi2_register_link(struct adv748x_csi2 *tx, in adv748x_csi2_register_link() argument
38 bool enable) in adv748x_csi2_register_link() argument
42 if (!src->v4l2_dev) { in adv748x_csi2_register_link()
48 ret = media_create_pad_link(&src->entity, src_pad, in adv748x_csi2_register_link()
49 &tx->sd.entity, ADV748X_CSI2_SINK, in adv748x_csi2_register_link()
50 enable ? MEDIA_LNK_FL_ENABLED : 0); in adv748x_csi2_register_link()
54 if (enable) in adv748x_csi2_register_link()
55 tx->src = src; in adv748x_csi2_register_link()
60 /* -----------------------------------------------------------------------------
70 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_registered() local
71 struct adv748x_state *state = tx->state; in adv748x_csi2_registered()
74 adv_dbg(state, "Registered %s (%s)", is_txa(tx) ? "TXA":"TXB", in adv748x_csi2_registered()
75 sd->name); in adv748x_csi2_registered()
81 * The HDMI->TXA link is enabled by default, as is the AFE->TXB one. in adv748x_csi2_registered()
84 ret = adv748x_csi2_register_link(tx, sd->v4l2_dev, in adv748x_csi2_registered()
85 &state->afe.sd, in adv748x_csi2_registered()
87 is_txb(tx)); in adv748x_csi2_registered()
92 if (is_txb(tx)) in adv748x_csi2_registered()
93 state->afe.tx = tx; in adv748x_csi2_registered()
97 if (is_txb(tx) || !is_hdmi_enabled(state)) in adv748x_csi2_registered()
100 ret = adv748x_csi2_register_link(tx, sd->v4l2_dev, &state->hdmi.sd, in adv748x_csi2_registered()
106 state->hdmi.tx = tx; in adv748x_csi2_registered()
115 /* -----------------------------------------------------------------------------
119 static int adv748x_csi2_s_stream(struct v4l2_subdev *sd, int enable) in adv748x_csi2_s_stream() argument
121 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_s_stream() local
124 src = adv748x_get_remote_sd(&tx->pads[ADV748X_CSI2_SINK]); in adv748x_csi2_s_stream()
126 return -EPIPE; in adv748x_csi2_s_stream()
128 return v4l2_subdev_call(src, video, s_stream, enable); in adv748x_csi2_s_stream()
135 /* -----------------------------------------------------------------------------
147 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_get_pad_format() local
152 return &tx->format; in adv748x_csi2_get_pad_format()
159 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_get_format() local
160 struct adv748x_state *state = tx->state; in adv748x_csi2_get_format()
163 mbusformat = adv748x_csi2_get_pad_format(sd, sd_state, sdformat->pad, in adv748x_csi2_get_format()
164 sdformat->which); in adv748x_csi2_get_format()
166 return -EINVAL; in adv748x_csi2_get_format()
168 mutex_lock(&state->mutex); in adv748x_csi2_get_format()
170 sdformat->format = *mbusformat; in adv748x_csi2_get_format()
172 mutex_unlock(&state->mutex); in adv748x_csi2_get_format()
181 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_set_format() local
182 struct adv748x_state *state = tx->state; in adv748x_csi2_set_format()
186 mbusformat = adv748x_csi2_get_pad_format(sd, sd_state, sdformat->pad, in adv748x_csi2_set_format()
187 sdformat->which); in adv748x_csi2_set_format()
189 return -EINVAL; in adv748x_csi2_set_format()
191 mutex_lock(&state->mutex); in adv748x_csi2_set_format()
193 if (sdformat->pad == ADV748X_CSI2_SOURCE) { in adv748x_csi2_set_format()
198 sdformat->which); in adv748x_csi2_set_format()
201 ret = -EINVAL; in adv748x_csi2_set_format()
205 sdformat->format = *sink_fmt; in adv748x_csi2_set_format()
208 *mbusformat = sdformat->format; in adv748x_csi2_set_format()
211 mutex_unlock(&state->mutex); in adv748x_csi2_set_format()
219 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_get_mbus_config() local
222 return -EINVAL; in adv748x_csi2_get_mbus_config()
224 config->type = V4L2_MBUS_CSI2_DPHY; in adv748x_csi2_get_mbus_config()
225 config->bus.mipi_csi2.num_data_lanes = tx->active_lanes; in adv748x_csi2_get_mbus_config()
236 /* -----------------------------------------------------------------------------
245 /* -----------------------------------------------------------------------------
251 struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd); in adv748x_csi2_set_pixelrate() local
253 if (!tx->pixel_rate) in adv748x_csi2_set_pixelrate()
254 return -EINVAL; in adv748x_csi2_set_pixelrate()
256 return v4l2_ctrl_s_ctrl_int64(tx->pixel_rate, rate); in adv748x_csi2_set_pixelrate()
261 switch (ctrl->id) { in adv748x_csi2_s_ctrl()
265 return -EINVAL; in adv748x_csi2_s_ctrl()
273 static int adv748x_csi2_init_controls(struct adv748x_csi2 *tx) in adv748x_csi2_init_controls() argument
276 v4l2_ctrl_handler_init(&tx->ctrl_hdl, 1); in adv748x_csi2_init_controls()
278 tx->pixel_rate = v4l2_ctrl_new_std(&tx->ctrl_hdl, in adv748x_csi2_init_controls()
283 tx->sd.ctrl_handler = &tx->ctrl_hdl; in adv748x_csi2_init_controls()
284 if (tx->ctrl_hdl.error) { in adv748x_csi2_init_controls()
285 v4l2_ctrl_handler_free(&tx->ctrl_hdl); in adv748x_csi2_init_controls()
286 return tx->ctrl_hdl.error; in adv748x_csi2_init_controls()
289 return v4l2_ctrl_handler_setup(&tx->ctrl_hdl); in adv748x_csi2_init_controls()
292 int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) in adv748x_csi2_init() argument
296 if (!is_tx_enabled(tx)) in adv748x_csi2_init()
299 adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops, in adv748x_csi2_init()
301 is_txa(tx) ? "txa" : "txb"); in adv748x_csi2_init()
304 tx->sd.fwnode = of_fwnode_handle(state->endpoints[tx->port]); in adv748x_csi2_init()
307 tx->sd.internal_ops = &adv748x_csi2_internal_ops; in adv748x_csi2_init()
309 tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK; in adv748x_csi2_init()
310 tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in adv748x_csi2_init()
312 ret = media_entity_pads_init(&tx->sd.entity, ADV748X_CSI2_NR_PADS, in adv748x_csi2_init()
313 tx->pads); in adv748x_csi2_init()
317 ret = adv748x_csi2_init_controls(tx); in adv748x_csi2_init()
321 ret = v4l2_async_register_subdev(&tx->sd); in adv748x_csi2_init()
328 v4l2_ctrl_handler_free(&tx->ctrl_hdl); in adv748x_csi2_init()
330 media_entity_cleanup(&tx->sd.entity); in adv748x_csi2_init()
335 void adv748x_csi2_cleanup(struct adv748x_csi2 *tx) in adv748x_csi2_cleanup() argument
337 if (!is_tx_enabled(tx)) in adv748x_csi2_cleanup()
340 v4l2_async_unregister_subdev(&tx->sd); in adv748x_csi2_cleanup()
341 media_entity_cleanup(&tx->sd.entity); in adv748x_csi2_cleanup()
342 v4l2_ctrl_handler_free(&tx->ctrl_hdl); in adv748x_csi2_cleanup()