media: adv748x: csi2: Set virtual channel when device is reset
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Sun, 22 Nov 2020 16:36:36 +0000 (17:36 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 3 Dec 2020 06:47:50 +0000 (07:47 +0100)
It's not enough to set the CSI-2 virtual channel for TXA and TXB during
probe: it also needs to be set when the device is reset. Move the virtual
channel selection to adv748x_reset() that is called during probe and
when the device needs to be reset.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/adv748x/adv748x-core.c
drivers/media/i2c/adv748x/adv748x-csi2.c
drivers/media/i2c/adv748x/adv748x.h

index 8676ad2428856dd3633cc6921b41e3b5e6418047..b578a01cfebe72178ae5b8e68b067ef1c7e9c409 100644 (file)
@@ -530,10 +530,14 @@ static int adv748x_reset(struct adv748x_state *state)
        io_write(state, ADV748X_IO_PD, ADV748X_IO_PD_RX_EN);
 
        /* Conditionally enable TXa and TXb. */
-       if (is_tx_enabled(&state->txa))
+       if (is_tx_enabled(&state->txa)) {
                regval |= ADV748X_IO_10_CSI4_EN;
-       if (is_tx_enabled(&state->txb))
+               adv748x_csi2_set_virtual_channel(&state->txa, 0);
+       }
+       if (is_tx_enabled(&state->txb)) {
                regval |= ADV748X_IO_10_CSI1_EN;
+               adv748x_csi2_set_virtual_channel(&state->txb, 0);
+       }
        io_write(state, ADV748X_IO_10, regval);
 
        /* Use vid_std and v_freq as freerun resolution for CP */
index 99bb63d05eef1cd525340ab4f4c4ea50f8bb6b51..fa9278a08fdee3bb85fe0f968a6cc8c759ae191c 100644 (file)
@@ -14,8 +14,7 @@
 
 #include "adv748x.h"
 
-static int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx,
-                                           unsigned int vc)
+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);
 }
@@ -313,9 +312,6 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx)
        if (!is_tx_enabled(tx))
                return 0;
 
-       /* Initialise the virtual channel */
-       adv748x_csi2_set_virtual_channel(tx, 0);
-
        adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops,
                            MEDIA_ENT_F_VID_IF_BRIDGE,
                            is_txa(tx) ? "txa" : "txb");
index 747947ea3e31645156e229bf92c6a0e7c7000b7b..56256c1e8b0d3f015994d266c2c3173780a4c2c6 100644 (file)
@@ -439,6 +439,7 @@ int adv748x_afe_s_input(struct adv748x_afe *afe, unsigned int input);
 
 int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx);
 void adv748x_csi2_cleanup(struct adv748x_csi2 *tx);
+int adv748x_csi2_set_virtual_channel(struct adv748x_csi2 *tx, unsigned int vc);
 int adv748x_csi2_set_pixelrate(struct v4l2_subdev *sd, s64 rate);
 
 int adv748x_hdmi_init(struct adv748x_hdmi *hdmi);