forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/media/i2c/it6616.c
....@@ -20,6 +20,7 @@
2020 #include <linux/module.h>
2121 #include <linux/of_graph.h>
2222 #include <linux/rk-camera-module.h>
23
+#include <linux/rk_hdmirx_class.h>
2324 #include <linux/slab.h>
2425 #include <linux/timer.h>
2526 #include <linux/v4l2-dv-timings.h>
....@@ -471,7 +472,6 @@
471472 struct regmap *mipi_regmap;
472473 struct regmap *edid_regmap;
473474 u8 attr_hdmi_reg_bank;
474
- struct class *hdmirx_class;
475475 struct device *dev;
476476 struct device *classdev;
477477 struct v4l2_fwnode_bus_mipi_csi2 bus;
....@@ -3519,6 +3519,16 @@
35193519 return 0;
35203520 }
35213521
3522
+static void it6616_detect_hot_plug(struct v4l2_subdev *sd)
3523
+{
3524
+ struct it6616 *it6616 = to_it6616(sd);
3525
+
3526
+ if (it6616->mipi_tx_video_stable && it6616_hdmi_is_5v_on(it6616))
3527
+ v4l2_ctrl_s_ctrl(it6616->detect_tx_5v_ctrl, 1);
3528
+ else
3529
+ v4l2_ctrl_s_ctrl(it6616->detect_tx_5v_ctrl, 0);
3530
+}
3531
+
35223532 static void it6616_work_i2c_poll(struct work_struct *work)
35233533 {
35243534 struct delayed_work *dwork = to_delayed_work(work);
....@@ -3526,8 +3536,8 @@
35263536 struct it6616, work_i2c_poll);
35273537 bool handled;
35283538
3529
- it6616_s_ctrl_detect_tx_5v(&it6616->sd);
35303539 it6616_isr(&it6616->sd, 0, &handled);
3540
+ it6616_detect_hot_plug(&it6616->sd);
35313541 schedule_delayed_work(&it6616->work_i2c_poll,
35323542 msecs_to_jiffies(POLL_INTERVAL_MS));
35333543 }
....@@ -4212,54 +4222,29 @@
42124222 static DEVICE_ATTR_RO(audio_present);
42134223 static DEVICE_ATTR_RO(audio_rate);
42144224
4225
+static struct attribute *it6616_audio_attrs[] = {
4226
+ &dev_attr_audio_rate.attr,
4227
+ &dev_attr_audio_present.attr,
4228
+ NULL
4229
+};
4230
+ATTRIBUTE_GROUPS(it6616_audio);
4231
+
42154232 static int it6616_create_class_attr(struct it6616 *it6616)
42164233 {
4217
- int ret = 0;
4218
-
4219
- it6616->hdmirx_class = class_create(THIS_MODULE, "hdmirx_it6616");
4220
- if (IS_ERR(it6616->hdmirx_class)) {
4221
- ret = -ENOMEM;
4222
- dev_err(it6616->dev, "failed to create hdmirx_it6616 class!\n");
4223
- return ret;
4224
- }
4225
-
4226
- it6616->classdev = device_create(it6616->hdmirx_class, NULL,
4227
- MKDEV(0, 0), NULL, "hdmirx_it6616");
4228
- if (IS_ERR(it6616->classdev)) {
4229
- ret = PTR_ERR(it6616->classdev);
4230
- dev_err(it6616->dev, "Failed to create device\n");
4231
- goto err1;
4232
- }
4233
-
4234
- ret = device_create_file(it6616->classdev,
4235
- &dev_attr_audio_present);
4236
- if (ret) {
4237
- dev_err(it6616->dev, "failed to create attr audio_present!\n");
4238
- goto err1;
4239
- }
4240
-
4241
- ret = device_create_file(it6616->classdev,
4242
- &dev_attr_audio_rate);
4243
- if (ret) {
4244
- dev_err(it6616->dev,
4245
- "failed to create attr audio_rate!\n");
4246
- goto err;
4247
- }
4248
-
4249
- return ret;
4250
-
4251
-err:
4252
- device_remove_file(it6616->classdev, &dev_attr_audio_present);
4253
-err1:
4254
- class_destroy(it6616->hdmirx_class);
4255
- return ret;
4234
+ it6616->classdev = device_create_with_groups(rk_hdmirx_class(),
4235
+ it6616->dev, MKDEV(0, 0),
4236
+ it6616,
4237
+ it6616_audio_groups,
4238
+ "it6616");
4239
+ if (IS_ERR(it6616->classdev))
4240
+ return IS_ERR(it6616->classdev);
4241
+ return 0;
42564242 }
42574243
42584244 static void it6616_remove_class_attr(struct it6616 *it6616)
42594245 {
42604246 device_remove_file(it6616->classdev, &dev_attr_audio_rate);
42614247 device_remove_file(it6616->classdev, &dev_attr_audio_present);
4262
- class_destroy(it6616->hdmirx_class);
42634248 }
42644249
42654250 static int it6616_probe(struct i2c_client *client,