media: i2c: adv748x: Fix pixel rate values
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Fri, 11 May 2018 14:04:34 +0000 (10:04 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Fri, 25 May 2018 19:19:38 +0000 (15:19 -0400)
The pixel rate, as reported by the V4L2_CID_PIXEL_RATE control, must
include both horizontal and vertical blanking. Both the AFE and HDMI
receiver program it incorrectly:

- The HDMI receiver goes to the trouble of removing blanking to compute
the rate of active pixels. This is easy to fix by removing the
computation and returning the incoming pixel clock rate directly.

- The AFE performs similar calculation, while it should simply return
the fixed pixel rate for analog sources, mandated by the ADV748x to be
14.3180180 MHz.

[Niklas: Update AFE fixed pixel rate]

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/i2c/adv748x/adv748x-afe.c
drivers/media/i2c/adv748x/adv748x-hdmi.c

index 61514bae7e5ceb423b60e8a3a62c9a7df59a7fb4..edd25e895e5dec3cecb7de0b3afead0e85dcd54d 100644 (file)
@@ -321,17 +321,17 @@ static const struct v4l2_subdev_video_ops adv748x_afe_video_ops = {
 static int adv748x_afe_propagate_pixelrate(struct adv748x_afe *afe)
 {
        struct v4l2_subdev *tx;
-       unsigned int width, height, fps;
 
        tx = adv748x_get_remote_sd(&afe->pads[ADV748X_AFE_SOURCE]);
        if (!tx)
                return -ENOLINK;
 
-       width = 720;
-       height = afe->curr_norm & V4L2_STD_525_60 ? 480 : 576;
-       fps = afe->curr_norm & V4L2_STD_525_60 ? 30 : 25;
-
-       return adv748x_csi2_set_pixelrate(tx, width * height * fps);
+       /*
+        * The ADV748x ADC sampling frequency is twice the externally supplied
+        * clock whose frequency is required to be 28.63636 MHz. It oversamples
+        * with a factor of 4 resulting in a pixel rate of 14.3180180 MHz.
+        */
+       return adv748x_csi2_set_pixelrate(tx, 14318180);
 }
 
 static int adv748x_afe_enum_mbus_code(struct v4l2_subdev *sd,
index 10d229a4f08868f74c714e52251627763f1b2a6d..aecc2a84dfecbec8ccb575090abcef64472a1f6a 100644 (file)
@@ -402,8 +402,6 @@ static int adv748x_hdmi_propagate_pixelrate(struct adv748x_hdmi *hdmi)
 {
        struct v4l2_subdev *tx;
        struct v4l2_dv_timings timings;
-       struct v4l2_bt_timings *bt = &timings.bt;
-       unsigned int fps;
 
        tx = adv748x_get_remote_sd(&hdmi->pads[ADV748X_HDMI_SOURCE]);
        if (!tx)
@@ -411,11 +409,7 @@ static int adv748x_hdmi_propagate_pixelrate(struct adv748x_hdmi *hdmi)
 
        adv748x_hdmi_query_dv_timings(&hdmi->sd, &timings);
 
-       fps = DIV_ROUND_CLOSEST_ULL(bt->pixelclock,
-                                   V4L2_DV_BT_FRAME_WIDTH(bt) *
-                                   V4L2_DV_BT_FRAME_HEIGHT(bt));
-
-       return adv748x_csi2_set_pixelrate(tx, bt->width * bt->height * fps);
+       return adv748x_csi2_set_pixelrate(tx, timings.bt.pixelclock);
 }
 
 static int adv748x_hdmi_enum_mbus_code(struct v4l2_subdev *sd,