hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/media/i2c/lt6911uxc.c
....@@ -18,6 +18,7 @@
1818 #include <linux/module.h>
1919 #include <linux/of_graph.h>
2020 #include <linux/rk-camera-module.h>
21
+#include <linux/rk_hdmirx_class.h>
2122 #include <linux/slab.h>
2223 #include <linux/timer.h>
2324 #include <linux/v4l2-dv-timings.h>
....@@ -89,6 +90,7 @@
8990 u32 module_index;
9091 u32 csi_lanes_in_use;
9192 u32 audio_sampling_rate;
93
+ struct device *classdev;
9294 };
9395
9496 struct lt6911uxc_mode {
....@@ -1279,6 +1281,34 @@
12791281 }
12801282 #endif
12811283
1284
+static ssize_t audio_rate_show(struct device *dev,
1285
+ struct device_attribute *attr, char *buf)
1286
+{
1287
+ struct lt6911uxc *lt6911uxc = dev_get_drvdata(dev);
1288
+
1289
+ return snprintf(buf, PAGE_SIZE, "%d", lt6911uxc->audio_sampling_rate);
1290
+}
1291
+
1292
+static ssize_t audio_present_show(struct device *dev,
1293
+ struct device_attribute *attr, char *buf)
1294
+{
1295
+ struct lt6911uxc *lt6911uxc = dev_get_drvdata(dev);
1296
+
1297
+ return snprintf(buf, PAGE_SIZE, "%d",
1298
+ tx_5v_power_present(&lt6911uxc->sd) ?
1299
+ lt6911uxc->is_audio_present : 0);
1300
+}
1301
+
1302
+static DEVICE_ATTR_RO(audio_rate);
1303
+static DEVICE_ATTR_RO(audio_present);
1304
+
1305
+static struct attribute *lt6911_attrs[] = {
1306
+ &dev_attr_audio_rate.attr,
1307
+ &dev_attr_audio_present.attr,
1308
+ NULL
1309
+};
1310
+ATTRIBUTE_GROUPS(lt6911);
1311
+
12821312 static int lt6911uxc_probe(struct i2c_client *client,
12831313 const struct i2c_device_id *id)
12841314 {
....@@ -1355,6 +1385,14 @@
13551385 goto err_clean_entity;
13561386 }
13571387
1388
+ lt6911uxc->classdev = device_create_with_groups(rk_hdmirx_class(),
1389
+ dev, MKDEV(0, 0),
1390
+ lt6911uxc,
1391
+ lt6911_groups,
1392
+ "lt6911");
1393
+ if (IS_ERR(lt6911uxc->classdev))
1394
+ goto err_clean_entity;
1395
+
13581396 INIT_DELAYED_WORK(&lt6911uxc->delayed_work_enable_hotplug,
13591397 lt6911uxc_delayed_work_enable_hotplug);
13601398 INIT_DELAYED_WORK(&lt6911uxc->delayed_work_res_change,