forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/i2c/imx214.c
....@@ -872,9 +872,7 @@
872872 struct imx214 *imx214 = to_imx214(sd);
873873 const struct imx214_mode *mode = imx214->cur_mode;
874874
875
- mutex_lock(&imx214->mutex);
876875 fi->interval = mode->max_fps;
877
- mutex_unlock(&imx214->mutex);
878876
879877 return 0;
880878 }
....@@ -1445,9 +1443,7 @@
14451443 if (fie->index >= imx214->cfg_num)
14461444 return -EINVAL;
14471445
1448
- if (fie->code != IMX214_MEDIA_BUS_FMT)
1449
- return -EINVAL;
1450
-
1446
+ fie->code = IMX214_MEDIA_BUS_FMT;
14511447 fie->width = imx214->support_modes[fie->index].width;
14521448 fie->height = imx214->support_modes[fie->index].height;
14531449 fie->interval = imx214->support_modes[fie->index].max_fps;
....@@ -1455,7 +1451,7 @@
14551451 return 0;
14561452 }
14571453
1458
-static int imx214_g_mbus_config(struct v4l2_subdev *sd,
1454
+static int imx214_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad,
14591455 struct v4l2_mbus_config *config)
14601456 {
14611457 struct imx214 *imx214 = to_imx214(sd);
....@@ -1466,10 +1462,40 @@
14661462 V4L2_MBUS_CSI2_CHANNEL_0 |
14671463 V4L2_MBUS_CSI2_CONTINUOUS_CLOCK;
14681464
1469
- config->type = V4L2_MBUS_CSI2;
1465
+ config->type = V4L2_MBUS_CSI2_DPHY;
14701466 config->flags = val;
14711467
14721468 return 0;
1469
+}
1470
+
1471
+#define CROP_START(SRC, DST) (((SRC) - (DST)) / 2 / 4 * 4)
1472
+#define DST_WIDTH_2096 2096
1473
+#define DST_HEIGHT_1560 1560
1474
+
1475
+static int imx214_get_selection(struct v4l2_subdev *sd,
1476
+ struct v4l2_subdev_pad_config *cfg,
1477
+ struct v4l2_subdev_selection *sel)
1478
+{
1479
+ struct imx214 *imx214 = to_imx214(sd);
1480
+
1481
+ if (sel->target == V4L2_SEL_TGT_CROP_BOUNDS) {
1482
+ if (imx214->cur_mode->width == 2104) {
1483
+ sel->r.left = CROP_START(imx214->cur_mode->width, DST_WIDTH_2096);
1484
+ sel->r.width = DST_WIDTH_2096;
1485
+ sel->r.top = CROP_START(imx214->cur_mode->height, DST_HEIGHT_1560);
1486
+ sel->r.height = DST_HEIGHT_1560;
1487
+ } else {
1488
+ sel->r.left = CROP_START(imx214->cur_mode->width,
1489
+ imx214->cur_mode->width);
1490
+ sel->r.width = imx214->cur_mode->width;
1491
+ sel->r.top = CROP_START(imx214->cur_mode->height,
1492
+ imx214->cur_mode->height);
1493
+ sel->r.height = imx214->cur_mode->height;
1494
+ }
1495
+ return 0;
1496
+ }
1497
+
1498
+ return -EINVAL;
14731499 }
14741500
14751501 static const struct dev_pm_ops imx214_pm_ops = {
....@@ -1494,7 +1520,6 @@
14941520 static const struct v4l2_subdev_video_ops imx214_video_ops = {
14951521 .s_stream = imx214_s_stream,
14961522 .g_frame_interval = imx214_g_frame_interval,
1497
- .g_mbus_config = imx214_g_mbus_config,
14981523 };
14991524
15001525 static const struct v4l2_subdev_pad_ops imx214_pad_ops = {
....@@ -1503,6 +1528,8 @@
15031528 .enum_frame_interval = imx214_enum_frame_interval,
15041529 .get_fmt = imx214_get_fmt,
15051530 .set_fmt = imx214_set_fmt,
1531
+ .get_selection = imx214_get_selection,
1532
+ .get_mbus_config = imx214_g_mbus_config,
15061533 };
15071534
15081535 static const struct v4l2_subdev_ops imx214_subdev_ops = {
....@@ -1944,4 +1971,4 @@
19441971 module_exit(sensor_mod_exit);
19451972
19461973 MODULE_DESCRIPTION("Sony imx214 sensor driver");
1947
-MODULE_LICENSE("GPL");
1974
+MODULE_LICENSE("GPL v2");