forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/i2c/ov13858.c
....@@ -7,6 +7,7 @@
77 #include <linux/pm_runtime.h>
88 #include <media/v4l2-ctrls.h>
99 #include <media/v4l2-device.h>
10
+#include <media/v4l2-fwnode.h>
1011
1112 #define OV13858_REG_VALUE_08BIT 1
1213 #define OV13858_REG_VALUE_16BIT 2
....@@ -1224,7 +1225,7 @@
12241225 ov13858->exposure->minimum,
12251226 max, ov13858->exposure->step, max);
12261227 break;
1227
- };
1228
+ }
12281229
12291230 /*
12301231 * Applying V4L2 control value only happens
....@@ -1262,7 +1263,7 @@
12621263 "ctrl(id:0x%x,val:0x%x) is not handled\n",
12631264 ctrl->id, ctrl->val);
12641265 break;
1265
- };
1266
+ }
12661267
12671268 pm_runtime_put(&client->dev);
12681269
....@@ -1589,6 +1590,7 @@
15891590 static int ov13858_init_controls(struct ov13858 *ov13858)
15901591 {
15911592 struct i2c_client *client = v4l2_get_subdevdata(&ov13858->sd);
1593
+ struct v4l2_fwnode_device_properties props;
15921594 struct v4l2_ctrl_handler *ctrl_hdlr;
15931595 s64 exposure_max;
15941596 s64 vblank_def;
....@@ -1600,7 +1602,7 @@
16001602 int ret;
16011603
16021604 ctrl_hdlr = &ov13858->ctrl_handler;
1603
- ret = v4l2_ctrl_handler_init(ctrl_hdlr, 8);
1605
+ ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10);
16041606 if (ret)
16051607 return ret;
16061608
....@@ -1665,6 +1667,15 @@
16651667 __func__, ret);
16661668 goto error;
16671669 }
1670
+
1671
+ ret = v4l2_fwnode_device_parse(&client->dev, &props);
1672
+ if (ret)
1673
+ goto error;
1674
+
1675
+ ret = v4l2_ctrl_new_fwnode_properties(ctrl_hdlr, &ov13858_ctrl_ops,
1676
+ &props);
1677
+ if (ret)
1678
+ goto error;
16681679
16691680 ov13858->sd.ctrl_handler = ctrl_hdlr;
16701681
....@@ -1737,10 +1748,9 @@
17371748 * Device is already turned on by i2c-core with ACPI domain PM.
17381749 * Enable runtime PM and turn off the device.
17391750 */
1740
- pm_runtime_get_noresume(&client->dev);
17411751 pm_runtime_set_active(&client->dev);
17421752 pm_runtime_enable(&client->dev);
1743
- pm_runtime_put(&client->dev);
1753
+ pm_runtime_idle(&client->dev);
17441754
17451755 return 0;
17461756
....@@ -1763,14 +1773,7 @@
17631773 media_entity_cleanup(&sd->entity);
17641774 ov13858_free_controls(ov13858);
17651775
1766
- /*
1767
- * Disable runtime PM but keep the device turned on.
1768
- * i2c-core with ACPI domain PM will turn off the device.
1769
- */
1770
- pm_runtime_get_sync(&client->dev);
17711776 pm_runtime_disable(&client->dev);
1772
- pm_runtime_set_suspended(&client->dev);
1773
- pm_runtime_put_noidle(&client->dev);
17741777
17751778 return 0;
17761779 }