@@ -493,6 +493,9 @@ struct ov5675 {
493
493
494
494
/* Streaming on/off */
495
495
bool streaming ;
496
+
497
+ /* True if the device has been identified */
498
+ bool identified ;
496
499
};
497
500
498
501
static u64 to_pixel_rate (u32 f_index )
@@ -808,12 +811,41 @@ static void ov5675_update_pad_format(const struct ov5675_mode *mode,
808
811
fmt -> field = V4L2_FIELD_NONE ;
809
812
}
810
813
814
+ static int ov5675_identify_module (struct ov5675 * ov5675 )
815
+ {
816
+ struct i2c_client * client = v4l2_get_subdevdata (& ov5675 -> sd );
817
+ int ret ;
818
+ u32 val ;
819
+
820
+ if (ov5675 -> identified )
821
+ return 0 ;
822
+
823
+ ret = ov5675_read_reg (ov5675 , OV5675_REG_CHIP_ID ,
824
+ OV5675_REG_VALUE_24BIT , & val );
825
+ if (ret )
826
+ return ret ;
827
+
828
+ if (val != OV5675_CHIP_ID ) {
829
+ dev_err (& client -> dev , "chip id mismatch: %x!=%x" ,
830
+ OV5675_CHIP_ID , val );
831
+ return - ENXIO ;
832
+ }
833
+
834
+ ov5675 -> identified = true;
835
+
836
+ return 0 ;
837
+ }
838
+
811
839
static int ov5675_start_streaming (struct ov5675 * ov5675 )
812
840
{
813
841
struct i2c_client * client = v4l2_get_subdevdata (& ov5675 -> sd );
814
842
const struct ov5675_reg_list * reg_list ;
815
843
int link_freq_index , ret ;
816
844
845
+ ret = ov5675_identify_module (ov5675 );
846
+ if (ret )
847
+ return ret ;
848
+
817
849
link_freq_index = ov5675 -> cur_mode -> link_freq_index ;
818
850
reg_list = & link_freq_configs [link_freq_index ].reg_list ;
819
851
ret = ov5675_write_reg_list (ov5675 , reg_list );
@@ -1048,26 +1080,6 @@ static const struct v4l2_subdev_internal_ops ov5675_internal_ops = {
1048
1080
.open = ov5675_open ,
1049
1081
};
1050
1082
1051
- static int ov5675_identify_module (struct ov5675 * ov5675 )
1052
- {
1053
- struct i2c_client * client = v4l2_get_subdevdata (& ov5675 -> sd );
1054
- int ret ;
1055
- u32 val ;
1056
-
1057
- ret = ov5675_read_reg (ov5675 , OV5675_REG_CHIP_ID ,
1058
- OV5675_REG_VALUE_24BIT , & val );
1059
- if (ret )
1060
- return ret ;
1061
-
1062
- if (val != OV5675_CHIP_ID ) {
1063
- dev_err (& client -> dev , "chip id mismatch: %x!=%x" ,
1064
- OV5675_CHIP_ID , val );
1065
- return - ENXIO ;
1066
- }
1067
-
1068
- return 0 ;
1069
- }
1070
-
1071
1083
static int ov5675_check_hwcfg (struct device * dev )
1072
1084
{
1073
1085
struct fwnode_handle * ep ;
@@ -1154,6 +1166,7 @@ static int ov5675_remove(struct i2c_client *client)
1154
1166
static int ov5675_probe (struct i2c_client * client )
1155
1167
{
1156
1168
struct ov5675 * ov5675 ;
1169
+ bool full_power ;
1157
1170
int ret ;
1158
1171
1159
1172
ret = ov5675_check_hwcfg (& client -> dev );
@@ -1168,10 +1181,14 @@ static int ov5675_probe(struct i2c_client *client)
1168
1181
return - ENOMEM ;
1169
1182
1170
1183
v4l2_i2c_subdev_init (& ov5675 -> sd , client , & ov5675_subdev_ops );
1171
- ret = ov5675_identify_module (ov5675 );
1172
- if (ret ) {
1173
- dev_err (& client -> dev , "failed to find sensor: %d" , ret );
1174
- return ret ;
1184
+
1185
+ full_power = acpi_dev_state_d0 (& client -> dev );
1186
+ if (full_power ) {
1187
+ ret = ov5675_identify_module (ov5675 );
1188
+ if (ret ) {
1189
+ dev_err (& client -> dev , "failed to find sensor: %d" , ret );
1190
+ return ret ;
1191
+ }
1175
1192
}
1176
1193
1177
1194
mutex_init (& ov5675 -> mutex );
@@ -1204,7 +1221,10 @@ static int ov5675_probe(struct i2c_client *client)
1204
1221
* Device is already turned on by i2c-core with ACPI domain PM.
1205
1222
* Enable runtime PM and turn off the device.
1206
1223
*/
1207
- pm_runtime_set_active (& client -> dev );
1224
+
1225
+ /* Set the device's state to active if it's in D0 state. */
1226
+ if (full_power )
1227
+ pm_runtime_set_active (& client -> dev );
1208
1228
pm_runtime_enable (& client -> dev );
1209
1229
pm_runtime_idle (& client -> dev );
1210
1230
@@ -1241,6 +1261,7 @@ static struct i2c_driver ov5675_i2c_driver = {
1241
1261
},
1242
1262
.probe_new = ov5675_probe ,
1243
1263
.remove = ov5675_remove ,
1264
+ .flags = I2C_DRV_ACPI_WAIVE_D0_PROBE ,
1244
1265
};
1245
1266
1246
1267
module_i2c_driver (ov5675_i2c_driver );
0 commit comments