Merge remote-tracking branch 'drm/drm-next' into drm-misc-next
[sfrench/cifs-2.6.git] / drivers / media / i2c / adv7842.c
index 2cfd03f929b250f41fe1bc42b6ab593860497697..0e6384f2016a60d2df687b6efc16529418c20465 100644 (file)
@@ -786,11 +786,13 @@ static int edid_write_hdmi_segment(struct v4l2_subdev *sd, u8 port)
        /* Disable I2C access to internal EDID ram from HDMI DDC ports */
        rep_write_and_or(sd, 0x77, 0xf3, 0x00);
 
-       if (!state->hdmi_edid.present)
+       if (!state->hdmi_edid.present) {
+               cec_phys_addr_invalidate(state->cec_adap);
                return 0;
+       }
 
-       pa = cec_get_edid_phys_addr(edid, 256, &spa_loc);
-       err = cec_phys_addr_validate(pa, &pa, NULL);
+       pa = v4l2_get_edid_phys_addr(edid, 256, &spa_loc);
+       err = v4l2_phys_addr_validate(pa, &pa, NULL);
        if (err)
                return err;
 
@@ -1525,6 +1527,7 @@ static void adv7842_fill_optional_dv_timings_fields(struct v4l2_subdev *sd,
        v4l2_find_dv_timings_cap(timings, adv7842_get_dv_timings_cap(sd),
                        is_digital_input(sd) ? 250000 : 1000000,
                        adv7842_check_dv_timings, NULL);
+       timings->bt.flags |= V4L2_DV_FL_CAN_DETECT_REDUCED_FPS;
 }
 
 static int adv7842_query_dv_timings(struct v4l2_subdev *sd,
@@ -1596,6 +1599,14 @@ static int adv7842_query_dv_timings(struct v4l2_subdev *sd,
                        bt->il_vbackporch = 0;
                }
                adv7842_fill_optional_dv_timings_fields(sd, timings);
+               if ((timings->bt.flags & V4L2_DV_FL_CAN_REDUCE_FPS) &&
+                   freq < bt->pixelclock) {
+                       u32 reduced_freq = ((u32)bt->pixelclock / 1001) * 1000;
+                       u32 delta_freq = abs(freq - reduced_freq);
+
+                       if (delta_freq < ((u32)bt->pixelclock - reduced_freq) / 2)
+                               timings->bt.flags |= V4L2_DV_FL_REDUCED_FPS;
+               }
        } else {
                /* find format
                 * Since LCVS values are inaccurate [REF_03, p. 339-340],