hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/i2c/adv7842.c
....@@ -1527,6 +1527,7 @@
15271527 v4l2_find_dv_timings_cap(timings, adv7842_get_dv_timings_cap(sd),
15281528 is_digital_input(sd) ? 250000 : 1000000,
15291529 adv7842_check_dv_timings, NULL);
1530
+ timings->bt.flags |= V4L2_DV_FL_CAN_DETECT_REDUCED_FPS;
15301531 }
15311532
15321533 static int adv7842_query_dv_timings(struct v4l2_subdev *sd,
....@@ -1598,6 +1599,14 @@
15981599 bt->il_vbackporch = 0;
15991600 }
16001601 adv7842_fill_optional_dv_timings_fields(sd, timings);
1602
+ if ((timings->bt.flags & V4L2_DV_FL_CAN_REDUCE_FPS) &&
1603
+ freq < bt->pixelclock) {
1604
+ u32 reduced_freq = ((u32)bt->pixelclock / 1001) * 1000;
1605
+ u32 delta_freq = abs(freq - reduced_freq);
1606
+
1607
+ if (delta_freq < ((u32)bt->pixelclock - reduced_freq) / 2)
1608
+ timings->bt.flags |= V4L2_DV_FL_REDUCED_FPS;
1609
+ }
16011610 } else {
16021611 /* find format
16031612 * Since LCVS values are inaccurate [REF_03, p. 339-340],
....@@ -2538,7 +2547,7 @@
25382547 u8 payload_addr;
25392548 };
25402549
2541
-static void log_infoframe(struct v4l2_subdev *sd, struct adv7842_cfg_read_infoframe *cri)
2550
+static void log_infoframe(struct v4l2_subdev *sd, const struct adv7842_cfg_read_infoframe *cri)
25422551 {
25432552 int i;
25442553 u8 buffer[32];
....@@ -2565,7 +2574,7 @@
25652574 for (i = 0; i < len; i++)
25662575 buffer[i + 3] = infoframe_read(sd, cri->payload_addr + i);
25672576
2568
- if (hdmi_infoframe_unpack(&frame, buffer, sizeof(buffer)) < 0) {
2577
+ if (hdmi_infoframe_unpack(&frame, buffer, len + 3) < 0) {
25692578 v4l2_err(sd, "%s: unpack of %s infoframe failed\n", __func__, cri->desc);
25702579 return;
25712580 }
....@@ -2576,7 +2585,7 @@
25762585 static void adv7842_log_infoframes(struct v4l2_subdev *sd)
25772586 {
25782587 int i;
2579
- struct adv7842_cfg_read_infoframe cri[] = {
2588
+ static const struct adv7842_cfg_read_infoframe cri[] = {
25802589 { "AVI", 0x01, 0xe0, 0x00 },
25812590 { "Audio", 0x02, 0xe3, 0x1c },
25822591 { "SDP", 0x04, 0xe6, 0x2a },
....@@ -3093,11 +3102,11 @@
30933102
30943103 io_write(sd, 0x00, 0x01); /* Program SDP 4x1 */
30953104 io_write(sd, 0x01, 0x00); /* Program SDP mode */
3096
- afe_write(sd, 0x80, 0x92); /* SDP Recommeneded Write */
3097
- afe_write(sd, 0x9B, 0x01); /* SDP Recommeneded Write ADV7844ES1 */
3098
- afe_write(sd, 0x9C, 0x60); /* SDP Recommeneded Write ADV7844ES1 */
3099
- afe_write(sd, 0x9E, 0x02); /* SDP Recommeneded Write ADV7844ES1 */
3100
- afe_write(sd, 0xA0, 0x0B); /* SDP Recommeneded Write ADV7844ES1 */
3105
+ afe_write(sd, 0x80, 0x92); /* SDP Recommended Write */
3106
+ afe_write(sd, 0x9B, 0x01); /* SDP Recommended Write ADV7844ES1 */
3107
+ afe_write(sd, 0x9C, 0x60); /* SDP Recommended Write ADV7844ES1 */
3108
+ afe_write(sd, 0x9E, 0x02); /* SDP Recommended Write ADV7844ES1 */
3109
+ afe_write(sd, 0xA0, 0x0B); /* SDP Recommended Write ADV7844ES1 */
31013110 afe_write(sd, 0xC3, 0x02); /* Memory BIST Initialisation */
31023111 io_write(sd, 0x0C, 0x40); /* Power up ADV7844 */
31033112 io_write(sd, 0x15, 0xBA); /* Enable outputs */
....@@ -3342,28 +3351,17 @@
33423351 static void adv7842_unregister_clients(struct v4l2_subdev *sd)
33433352 {
33443353 struct adv7842_state *state = to_state(sd);
3345
- if (state->i2c_avlink)
3346
- i2c_unregister_device(state->i2c_avlink);
3347
- if (state->i2c_cec)
3348
- i2c_unregister_device(state->i2c_cec);
3349
- if (state->i2c_infoframe)
3350
- i2c_unregister_device(state->i2c_infoframe);
3351
- if (state->i2c_sdp_io)
3352
- i2c_unregister_device(state->i2c_sdp_io);
3353
- if (state->i2c_sdp)
3354
- i2c_unregister_device(state->i2c_sdp);
3355
- if (state->i2c_afe)
3356
- i2c_unregister_device(state->i2c_afe);
3357
- if (state->i2c_repeater)
3358
- i2c_unregister_device(state->i2c_repeater);
3359
- if (state->i2c_edid)
3360
- i2c_unregister_device(state->i2c_edid);
3361
- if (state->i2c_hdmi)
3362
- i2c_unregister_device(state->i2c_hdmi);
3363
- if (state->i2c_cp)
3364
- i2c_unregister_device(state->i2c_cp);
3365
- if (state->i2c_vdp)
3366
- i2c_unregister_device(state->i2c_vdp);
3354
+ i2c_unregister_device(state->i2c_avlink);
3355
+ i2c_unregister_device(state->i2c_cec);
3356
+ i2c_unregister_device(state->i2c_infoframe);
3357
+ i2c_unregister_device(state->i2c_sdp_io);
3358
+ i2c_unregister_device(state->i2c_sdp);
3359
+ i2c_unregister_device(state->i2c_afe);
3360
+ i2c_unregister_device(state->i2c_repeater);
3361
+ i2c_unregister_device(state->i2c_edid);
3362
+ i2c_unregister_device(state->i2c_hdmi);
3363
+ i2c_unregister_device(state->i2c_cp);
3364
+ i2c_unregister_device(state->i2c_vdp);
33673365
33683366 state->i2c_avlink = NULL;
33693367 state->i2c_cec = NULL;
....@@ -3391,9 +3389,12 @@
33913389 return NULL;
33923390 }
33933391
3394
- cp = i2c_new_dummy(client->adapter, io_read(sd, io_reg) >> 1);
3395
- if (!cp)
3396
- v4l2_err(sd, "register %s on i2c addr 0x%x failed\n", desc, addr);
3392
+ cp = i2c_new_dummy_device(client->adapter, io_read(sd, io_reg) >> 1);
3393
+ if (IS_ERR(cp)) {
3394
+ v4l2_err(sd, "register %s on i2c addr 0x%x failed with %ld\n",
3395
+ desc, addr, PTR_ERR(cp));
3396
+ cp = NULL;
3397
+ }
33973398
33983399 return cp;
33993400 }