mirror of
https://github.com/torvalds/linux.git
synced 2026-04-19 23:34:00 -04:00
Switch all drivers accessing sub-device state to use the stream-aware
functions. We will soon remove the old ones.
This patch has been generated using the following Coccinelle script:
---------8<------------
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_pad_format(E1, E2, E3)
+ v4l2_subdev_state_get_format(E2, E3)
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_pad_crop(E1, E2, E3)
+ v4l2_subdev_state_get_crop(E2, E3)
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_pad_compose(E1, E2, E3)
+ v4l2_subdev_state_get_compose(E2, E3)
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_try_format(E1, E2, E3)
+ v4l2_subdev_state_get_format(E2, E3)
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_try_crop(E1, E2, E3)
+ v4l2_subdev_state_get_crop(E2, E3)
@@
expression E1, E2, E3;
@@
- v4l2_subdev_get_try_compose(E1, E2, E3)
+ v4l2_subdev_state_get_compose(E2, E3)
---------8<------------
Additionally drivers/media/i2c/s5k5baf.c and
drivers/media/platform/samsung/s3c-camif/camif-capture.c have been
manually changed as Coccinelle didn't. Further local variables have been
removed as they became unused as a result of the other changes.
Also Coccinelle introduced indentation by space in files
drivers/media/i2c/st-mipid02.c and
drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c. This has been also
corrected.
The diff from Coccinelle-generated changes are:
> diff --git b/drivers/media/i2c/imx319.c a/drivers/media/i2c/imx319.c
> index e549692ff478..420984382173 100644
> --- b/drivers/media/i2c/imx319.c
> +++ a/drivers/media/i2c/imx319.c
> @@ -2001,7 +2001,6 @@ static int imx319_do_get_pad_format(struct imx319 *imx319,
> struct v4l2_subdev_format *fmt)
> {
> struct v4l2_mbus_framefmt *framefmt;
> - struct v4l2_subdev *sd = &imx319->sd;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> diff --git b/drivers/media/i2c/imx355.c a/drivers/media/i2c/imx355.c
> index 96bdde685d65..e1b1d2fc79dd 100644
> --- b/drivers/media/i2c/imx355.c
> +++ a/drivers/media/i2c/imx355.c
> @@ -1299,7 +1299,6 @@ static int imx355_do_get_pad_format(struct imx355 *imx355,
> struct v4l2_subdev_format *fmt)
> {
> struct v4l2_mbus_framefmt *framefmt;
> - struct v4l2_subdev *sd = &imx355->sd;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> diff --git b/drivers/media/i2c/ov08x40.c a/drivers/media/i2c/ov08x40.c
> index ca799bbcfdb7..abbb0b774d43 100644
> --- b/drivers/media/i2c/ov08x40.c
> +++ a/drivers/media/i2c/ov08x40.c
> @@ -2774,7 +2774,6 @@ static int ov08x40_do_get_pad_format(struct ov08x40 *ov08x,
> struct v4l2_subdev_format *fmt)
> {
> struct v4l2_mbus_framefmt *framefmt;
> - struct v4l2_subdev *sd = &ov08x->sd;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> diff --git b/drivers/media/i2c/ov13858.c a/drivers/media/i2c/ov13858.c
> index 7816d9787c61..09387e335d80 100644
> --- b/drivers/media/i2c/ov13858.c
> +++ a/drivers/media/i2c/ov13858.c
> @@ -1316,7 +1316,6 @@ static int ov13858_do_get_pad_format(struct ov13858 *ov13858,
> struct v4l2_subdev_format *fmt)
> {
> struct v4l2_mbus_framefmt *framefmt;
> - struct v4l2_subdev *sd = &ov13858->sd;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> diff --git b/drivers/media/i2c/ov13b10.c a/drivers/media/i2c/ov13b10.c
> index 268cd4b03f9c..c06411d5ee2b 100644
> --- b/drivers/media/i2c/ov13b10.c
> +++ a/drivers/media/i2c/ov13b10.c
> @@ -1001,7 +1001,6 @@ static int ov13b10_do_get_pad_format(struct ov13b10 *ov13b,
> struct v4l2_subdev_format *fmt)
> {
> struct v4l2_mbus_framefmt *framefmt;
> - struct v4l2_subdev *sd = &ov13b->sd;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> framefmt = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> diff --git b/drivers/media/i2c/s5c73m3/s5c73m3-core.c a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> index 47605e36bc60..8f9b5713daf7 100644
> --- b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> +++ a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
> @@ -819,7 +819,6 @@ static void s5c73m3_oif_try_format(struct s5c73m3 *state,
> struct v4l2_subdev_format *fmt,
> const struct s5c73m3_frame_size **fs)
> {
> - struct v4l2_subdev *sd = &state->sensor_sd;
> u32 code;
>
> switch (fmt->pad) {
> diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
> index 67da2045f543..03ccfb0e1e11 100644
> --- a/drivers/media/i2c/s5k5baf.c
> +++ b/drivers/media/i2c/s5k5baf.c
> @@ -1472,14 +1472,11 @@ static int s5k5baf_set_selection(struct v4l2_subdev *sd,
>
> if (sel->which == V4L2_SUBDEV_FORMAT_TRY) {
> rects = (struct v4l2_rect * []) {
> - &s5k5baf_cis_rect,
> - v4l2_subdev_get_try_crop(sd, sd_state,
> - PAD_CIS),
> - v4l2_subdev_get_try_compose(sd, sd_state,
> - PAD_CIS),
> - v4l2_subdev_get_try_crop(sd, sd_state,
> - PAD_OUT)
> - };
> + &s5k5baf_cis_rect,
> + v4l2_subdev_state_get_crop(sd_state, PAD_CIS),
> + v4l2_subdev_state_get_compose(sd_state, PAD_CIS),
> + v4l2_subdev_state_get_crop(sd_state, PAD_OUT)
> + };
> s5k5baf_set_rect_and_adjust(rects, rtype, &sel->r);
> return 0;
> }
> diff --git b/drivers/media/platform/samsung/s3c-camif/camif-capture.c a/drivers/media/platform/samsung/s3c-camif/camif-capture.c
> index 295e083f38e8..be58260ea67e 100644
> --- b/drivers/media/platform/samsung/s3c-camif/camif-capture.c
> +++ a/drivers/media/platform/samsung/s3c-camif/camif-capture.c
> @@ -1216,7 +1216,7 @@ static int s3c_camif_subdev_get_fmt(struct v4l2_subdev *sd,
> struct v4l2_mbus_framefmt *mf = &fmt->format;
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> - mf = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
> + mf = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> fmt->format = *mf;
> return 0;
> }
> @@ -1305,7 +1305,7 @@ static int s3c_camif_subdev_set_fmt(struct v4l2_subdev *sd,
> __camif_subdev_try_format(camif, mf, fmt->pad);
>
> if (fmt->which == V4L2_SUBDEV_FORMAT_TRY) {
> - mf = v4l2_subdev_get_try_format(sd, sd_state, fmt->pad);
> + mf = v4l2_subdev_state_get_format(sd_state, fmt->pad);
> *mf = fmt->format;
> mutex_unlock(&camif->lock);
> return 0;
> diff --git b/drivers/media/platform/ti/cal/cal-camerarx.c a/drivers/media/platform/ti/cal/cal-camerarx.c
> index cea454ed9c20..61433744c6c4 100644
> --- b/drivers/media/platform/ti/cal/cal-camerarx.c
> +++ a/drivers/media/platform/ti/cal/cal-camerarx.c
> @@ -621,8 +621,6 @@ static int cal_camerarx_sd_enum_mbus_code(struct v4l2_subdev *sd,
> struct v4l2_subdev_state *state,
> struct v4l2_subdev_mbus_code_enum *code)
> {
> - struct cal_camerarx *phy = to_cal_camerarx(sd);
> -
> /* No transcoding, source and sink codes must match. */
> if (cal_rx_pad_is_source(code->pad)) {
> struct v4l2_mbus_framefmt *fmt;
> diff --git b/drivers/staging/media/imx/imx-ic-prp.c a/drivers/staging/media/imx/imx-ic-prp.c
> index dd558fac6477..61d69f19657e 100644
> --- b/drivers/staging/media/imx/imx-ic-prp.c
> +++ a/drivers/staging/media/imx/imx-ic-prp.c
> @@ -82,8 +82,6 @@ static struct v4l2_mbus_framefmt *
> __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_state *sd_state,
> unsigned int pad, enum v4l2_subdev_format_whence which)
> {
> - struct imx_ic_priv *ic_priv = priv->ic_priv;
> -
> if (which == V4L2_SUBDEV_FORMAT_TRY)
> return v4l2_subdev_state_get_format(sd_state, pad);
> else
> diff --git b/drivers/staging/media/imx/imx-ic-prpencvf.c a/drivers/staging/media/imx/imx-ic-prpencvf.c
> index 02db7dbb884b..ec73c901079e 100644
> --- b/drivers/staging/media/imx/imx-ic-prpencvf.c
> +++ a/drivers/staging/media/imx/imx-ic-prpencvf.c
> @@ -790,8 +790,6 @@ static struct v4l2_mbus_framefmt *
> __prp_get_fmt(struct prp_priv *priv, struct v4l2_subdev_state *sd_state,
> unsigned int pad, enum v4l2_subdev_format_whence which)
> {
> - struct imx_ic_priv *ic_priv = priv->ic_priv;
> -
> if (which == V4L2_SUBDEV_FORMAT_TRY)
> return v4l2_subdev_state_get_format(sd_state, pad);
> else
> diff --git a/drivers/media/i2c/st-mipid02.c b/drivers/media/i2c/st-mipid02.c
> index 9c9361354c00..b08a249b5fdd 100644
> --- a/drivers/media/i2c/st-mipid02.c
> +++ b/drivers/media/i2c/st-mipid02.c
> @@ -751,7 +751,7 @@ static void mipid02_set_fmt_source(struct v4l2_subdev *sd,
> format->format = bridge->fmt;
> else
> format->format = *v4l2_subdev_state_get_format(sd_state,
> - MIPID02_SINK_0);
> + MIPID02_SINK_0);
>
> /* but code may need to be converted */
> format->format.code = serial_to_parallel_code(format->format.code);
> diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> index 117912d3bfbd..96353648c032 100644
> --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-isp.c
> @@ -319,7 +319,7 @@ static void rkisp1_isp_start(struct rkisp1_isp *isp,
> rkisp1_write(rkisp1, RKISP1_CIF_ISP_CTRL, val);
>
> src_fmt = v4l2_subdev_state_get_format(sd_state,
> - RKISP1_ISP_PAD_SOURCE_VIDEO);
> + RKISP1_ISP_PAD_SOURCE_VIDEO);
> src_info = rkisp1_mbus_info_get_by_code(src_fmt->code);
>
> if (src_info->pixel_enc != V4L2_PIXEL_ENC_BAYER)
> @@ -475,9 +475,9 @@ static void rkisp1_isp_set_src_fmt(struct rkisp1_isp *isp,
> sink_fmt = v4l2_subdev_state_get_format(sd_state,
> RKISP1_ISP_PAD_SINK_VIDEO);
> src_fmt = v4l2_subdev_state_get_format(sd_state,
> - RKISP1_ISP_PAD_SOURCE_VIDEO);
> + RKISP1_ISP_PAD_SOURCE_VIDEO);
> src_crop = v4l2_subdev_state_get_crop(sd_state,
> - RKISP1_ISP_PAD_SOURCE_VIDEO);
> + RKISP1_ISP_PAD_SOURCE_VIDEO);
>
> /*
> * Media bus code. The ISP can operate in pass-through mode (Bayer in,
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
349 lines
8.2 KiB
C
349 lines
8.2 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Driver for Analog Devices ADV748X CSI-2 Transmitter
|
|
*
|
|
* Copyright (C) 2017 Renesas Electronics Corp.
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/mutex.h>
|
|
|
|
#include <media/v4l2-ctrls.h>
|
|
#include <media/v4l2-device.h>
|
|
#include <media/v4l2-ioctl.h>
|
|
|
|
#include "adv748x.h"
|
|
|
|
int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx, unsigned int vc)
|
|
{
|
|
return tx_write(tx, ADV748X_CSI_VC_REF, vc << ADV748X_CSI_VC_REF_SHIFT);
|
|
}
|
|
|
|
/**
|
|
* adv748x_csi2_register_link : Register and link internal entities
|
|
*
|
|
* @tx: CSI2 private entity
|
|
* @v4l2_dev: Video registration device
|
|
* @src: Source subdevice to establish link
|
|
* @src_pad: Pad number of source to link to this @tx
|
|
* @enable: Link enabled flag
|
|
*
|
|
* Ensure that the subdevice is registered against the v4l2_device, and link the
|
|
* source pad to the sink pad of the CSI2 bus entity.
|
|
*/
|
|
static int adv748x_csi2_register_link(struct adv748x_csi2 *tx,
|
|
struct v4l2_device *v4l2_dev,
|
|
struct v4l2_subdev *src,
|
|
unsigned int src_pad,
|
|
bool enable)
|
|
{
|
|
int ret;
|
|
|
|
if (!src->v4l2_dev) {
|
|
ret = v4l2_device_register_subdev(v4l2_dev, src);
|
|
if (ret)
|
|
return ret;
|
|
}
|
|
|
|
ret = media_create_pad_link(&src->entity, src_pad,
|
|
&tx->sd.entity, ADV748X_CSI2_SINK,
|
|
enable ? MEDIA_LNK_FL_ENABLED : 0);
|
|
if (ret)
|
|
return ret;
|
|
|
|
if (enable)
|
|
tx->src = src;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* v4l2_subdev_internal_ops
|
|
*
|
|
* We use the internal registered operation to be able to ensure that our
|
|
* incremental subdevices (not connected in the forward path) can be registered
|
|
* against the resulting video path and media device.
|
|
*/
|
|
|
|
static int adv748x_csi2_registered(struct v4l2_subdev *sd)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
struct adv748x_state *state = tx->state;
|
|
int ret;
|
|
|
|
adv_dbg(state, "Registered %s (%s)", is_txa(tx) ? "TXA":"TXB",
|
|
sd->name);
|
|
|
|
/*
|
|
* Link TXA to AFE and HDMI, and TXB to AFE only as TXB cannot output
|
|
* HDMI.
|
|
*
|
|
* The HDMI->TXA link is enabled by default, as is the AFE->TXB one.
|
|
*/
|
|
if (is_afe_enabled(state)) {
|
|
ret = adv748x_csi2_register_link(tx, sd->v4l2_dev,
|
|
&state->afe.sd,
|
|
ADV748X_AFE_SOURCE,
|
|
is_txb(tx));
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* TXB can output AFE signals only. */
|
|
if (is_txb(tx))
|
|
state->afe.tx = tx;
|
|
}
|
|
|
|
/* Register link to HDMI for TXA only. */
|
|
if (is_txb(tx) || !is_hdmi_enabled(state))
|
|
return 0;
|
|
|
|
ret = adv748x_csi2_register_link(tx, sd->v4l2_dev, &state->hdmi.sd,
|
|
ADV748X_HDMI_SOURCE, true);
|
|
if (ret)
|
|
return ret;
|
|
|
|
/* The default HDMI output is TXA. */
|
|
state->hdmi.tx = tx;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct v4l2_subdev_internal_ops adv748x_csi2_internal_ops = {
|
|
.registered = adv748x_csi2_registered,
|
|
};
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* v4l2_subdev_video_ops
|
|
*/
|
|
|
|
static int adv748x_csi2_s_stream(struct v4l2_subdev *sd, int enable)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
struct v4l2_subdev *src;
|
|
|
|
src = adv748x_get_remote_sd(&tx->pads[ADV748X_CSI2_SINK]);
|
|
if (!src)
|
|
return -EPIPE;
|
|
|
|
return v4l2_subdev_call(src, video, s_stream, enable);
|
|
}
|
|
|
|
static const struct v4l2_subdev_video_ops adv748x_csi2_video_ops = {
|
|
.s_stream = adv748x_csi2_s_stream,
|
|
};
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* v4l2_subdev_pad_ops
|
|
*
|
|
* The CSI2 bus pads are ignorant to the data sizes or formats.
|
|
* But we must support setting the pad formats for format propagation.
|
|
*/
|
|
|
|
static struct v4l2_mbus_framefmt *
|
|
adv748x_csi2_get_pad_format(struct v4l2_subdev *sd,
|
|
struct v4l2_subdev_state *sd_state,
|
|
unsigned int pad, u32 which)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
|
|
if (which == V4L2_SUBDEV_FORMAT_TRY)
|
|
return v4l2_subdev_state_get_format(sd_state, pad);
|
|
|
|
return &tx->format;
|
|
}
|
|
|
|
static int adv748x_csi2_get_format(struct v4l2_subdev *sd,
|
|
struct v4l2_subdev_state *sd_state,
|
|
struct v4l2_subdev_format *sdformat)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
struct adv748x_state *state = tx->state;
|
|
struct v4l2_mbus_framefmt *mbusformat;
|
|
|
|
mbusformat = adv748x_csi2_get_pad_format(sd, sd_state, sdformat->pad,
|
|
sdformat->which);
|
|
if (!mbusformat)
|
|
return -EINVAL;
|
|
|
|
mutex_lock(&state->mutex);
|
|
|
|
sdformat->format = *mbusformat;
|
|
|
|
mutex_unlock(&state->mutex);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int adv748x_csi2_set_format(struct v4l2_subdev *sd,
|
|
struct v4l2_subdev_state *sd_state,
|
|
struct v4l2_subdev_format *sdformat)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
struct adv748x_state *state = tx->state;
|
|
struct v4l2_mbus_framefmt *mbusformat;
|
|
int ret = 0;
|
|
|
|
mbusformat = adv748x_csi2_get_pad_format(sd, sd_state, sdformat->pad,
|
|
sdformat->which);
|
|
if (!mbusformat)
|
|
return -EINVAL;
|
|
|
|
mutex_lock(&state->mutex);
|
|
|
|
if (sdformat->pad == ADV748X_CSI2_SOURCE) {
|
|
const struct v4l2_mbus_framefmt *sink_fmt;
|
|
|
|
sink_fmt = adv748x_csi2_get_pad_format(sd, sd_state,
|
|
ADV748X_CSI2_SINK,
|
|
sdformat->which);
|
|
|
|
if (!sink_fmt) {
|
|
ret = -EINVAL;
|
|
goto unlock;
|
|
}
|
|
|
|
sdformat->format = *sink_fmt;
|
|
}
|
|
|
|
*mbusformat = sdformat->format;
|
|
|
|
unlock:
|
|
mutex_unlock(&state->mutex);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static int adv748x_csi2_get_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
|
|
struct v4l2_mbus_config *config)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
|
|
if (pad != ADV748X_CSI2_SOURCE)
|
|
return -EINVAL;
|
|
|
|
config->type = V4L2_MBUS_CSI2_DPHY;
|
|
config->bus.mipi_csi2.num_data_lanes = tx->active_lanes;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct v4l2_subdev_pad_ops adv748x_csi2_pad_ops = {
|
|
.get_fmt = adv748x_csi2_get_format,
|
|
.set_fmt = adv748x_csi2_set_format,
|
|
.get_mbus_config = adv748x_csi2_get_mbus_config,
|
|
};
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* v4l2_subdev_ops
|
|
*/
|
|
|
|
static const struct v4l2_subdev_ops adv748x_csi2_ops = {
|
|
.video = &adv748x_csi2_video_ops,
|
|
.pad = &adv748x_csi2_pad_ops,
|
|
};
|
|
|
|
/* -----------------------------------------------------------------------------
|
|
* Subdev module and controls
|
|
*/
|
|
|
|
int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate)
|
|
{
|
|
struct adv748x_csi2 *tx = adv748x_sd_to_csi2(sd);
|
|
|
|
if (!tx->pixel_rate)
|
|
return -EINVAL;
|
|
|
|
return v4l2_ctrl_s_ctrl_int64(tx->pixel_rate, rate);
|
|
}
|
|
|
|
static int adv748x_csi2_s_ctrl(struct v4l2_ctrl *ctrl)
|
|
{
|
|
switch (ctrl->id) {
|
|
case V4L2_CID_PIXEL_RATE:
|
|
return 0;
|
|
default:
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
static const struct v4l2_ctrl_ops adv748x_csi2_ctrl_ops = {
|
|
.s_ctrl = adv748x_csi2_s_ctrl,
|
|
};
|
|
|
|
static int adv748x_csi2_init_controls(struct adv748x_csi2 *tx)
|
|
{
|
|
|
|
v4l2_ctrl_handler_init(&tx->ctrl_hdl, 1);
|
|
|
|
tx->pixel_rate = v4l2_ctrl_new_std(&tx->ctrl_hdl,
|
|
&adv748x_csi2_ctrl_ops,
|
|
V4L2_CID_PIXEL_RATE, 1, INT_MAX,
|
|
1, 1);
|
|
|
|
tx->sd.ctrl_handler = &tx->ctrl_hdl;
|
|
if (tx->ctrl_hdl.error) {
|
|
v4l2_ctrl_handler_free(&tx->ctrl_hdl);
|
|
return tx->ctrl_hdl.error;
|
|
}
|
|
|
|
return v4l2_ctrl_handler_setup(&tx->ctrl_hdl);
|
|
}
|
|
|
|
int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx)
|
|
{
|
|
int ret;
|
|
|
|
if (!is_tx_enabled(tx))
|
|
return 0;
|
|
|
|
adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops,
|
|
MEDIA_ENT_F_VID_IF_BRIDGE,
|
|
is_txa(tx) ? "txa" : "txb");
|
|
|
|
/* Register internal ops for incremental subdev registration */
|
|
tx->sd.internal_ops = &adv748x_csi2_internal_ops;
|
|
|
|
tx->pads[ADV748X_CSI2_SINK].flags = MEDIA_PAD_FL_SINK;
|
|
tx->pads[ADV748X_CSI2_SOURCE].flags = MEDIA_PAD_FL_SOURCE;
|
|
|
|
ret = media_entity_pads_init(&tx->sd.entity, ADV748X_CSI2_NR_PADS,
|
|
tx->pads);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = v4l2_async_subdev_endpoint_add(&tx->sd,
|
|
of_fwnode_handle(state->endpoints[tx->port]));
|
|
if (ret)
|
|
goto err_free_media;
|
|
|
|
ret = adv748x_csi2_init_controls(tx);
|
|
if (ret)
|
|
goto err_cleanup_subdev;
|
|
|
|
ret = v4l2_async_register_subdev(&tx->sd);
|
|
if (ret)
|
|
goto err_free_ctrl;
|
|
|
|
return 0;
|
|
|
|
err_free_ctrl:
|
|
v4l2_ctrl_handler_free(&tx->ctrl_hdl);
|
|
err_cleanup_subdev:
|
|
v4l2_subdev_cleanup(&tx->sd);
|
|
err_free_media:
|
|
media_entity_cleanup(&tx->sd.entity);
|
|
|
|
return ret;
|
|
}
|
|
|
|
void adv748x_csi2_cleanup(struct adv748x_csi2 *tx)
|
|
{
|
|
if (!is_tx_enabled(tx))
|
|
return;
|
|
|
|
v4l2_async_unregister_subdev(&tx->sd);
|
|
media_entity_cleanup(&tx->sd.entity);
|
|
v4l2_ctrl_handler_free(&tx->ctrl_hdl);
|
|
v4l2_subdev_cleanup(&tx->sd);
|
|
}
|