forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/usb/gadget/function/uvc_configfs.c
....@@ -7,7 +7,7 @@
77 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
88 * http://www.samsung.com
99 *
10
- * Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
10
+ * Author: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
1111 */
1212
1313 #include <linux/sort.h>
....@@ -1607,10 +1607,6 @@
16071607 if (ret) \
16081608 goto end; \
16091609 \
1610
- if (num > 255) { \
1611
- ret = -EINVAL; \
1612
- goto end; \
1613
- } \
16141610 u->desc.aname = num; \
16151611 ret = len; \
16161612 end: \
....@@ -1804,10 +1800,6 @@
18041800 if (ret) \
18051801 goto end; \
18061802 \
1807
- if (num > 255) { \
1808
- ret = -EINVAL; \
1809
- goto end; \
1810
- } \
18111803 u->desc.aname = num; \
18121804 ret = len; \
18131805 end: \
....@@ -2774,11 +2766,15 @@
27742766 UVCG_OPTS_ATTR(streaming_interval, streaming_interval, 16);
27752767 UVCG_OPTS_ATTR(streaming_maxpacket, streaming_maxpacket, 3072);
27762768 UVCG_OPTS_ATTR(streaming_maxburst, streaming_maxburst, 15);
2777
-UVCG_OPTS_ATTR(uvc_num_request, uvc_num_request, UVC_MAX_NUM_REQUESTS);
27782769 UVCG_OPTS_ATTR(pm_qos_latency, pm_qos_latency, PM_QOS_LATENCY_ANY);
2770
+#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
2771
+UVCG_OPTS_ATTR(uvc_num_request, uvc_num_request, 64);
2772
+UVCG_OPTS_ATTR(uvc_zero_copy, uvc_zero_copy, 1);
2773
+#endif
27792774
27802775 #undef UVCG_OPTS_ATTR
27812776
2777
+#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
27822778 static ssize_t f_uvc_opts_device_name_show(struct config_item *item,
27832779 char *page)
27842780 {
....@@ -2832,15 +2828,62 @@
28322828 return ret;
28332829 }
28342830 UVC_ATTR(f_uvc_opts_, device_name, device_name);
2831
+#endif
2832
+
2833
+#define UVCG_OPTS_STRING_ATTR(cname, aname) \
2834
+static ssize_t f_uvc_opts_string_##cname##_show(struct config_item *item,\
2835
+ char *page) \
2836
+{ \
2837
+ struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2838
+ int result; \
2839
+ \
2840
+ mutex_lock(&opts->lock); \
2841
+ result = snprintf(page, sizeof(opts->aname), "%s", opts->aname);\
2842
+ mutex_unlock(&opts->lock); \
2843
+ \
2844
+ return result; \
2845
+} \
2846
+ \
2847
+static ssize_t f_uvc_opts_string_##cname##_store(struct config_item *item,\
2848
+ const char *page, size_t len) \
2849
+{ \
2850
+ struct f_uvc_opts *opts = to_f_uvc_opts(item); \
2851
+ int size = min(sizeof(opts->aname), len + 1); \
2852
+ int ret = 0; \
2853
+ \
2854
+ mutex_lock(&opts->lock); \
2855
+ if (opts->refcnt) { \
2856
+ ret = -EBUSY; \
2857
+ goto end; \
2858
+ } \
2859
+ \
2860
+ ret = strscpy(opts->aname, page, size); \
2861
+ if (ret == -E2BIG) \
2862
+ ret = size - 1; \
2863
+ \
2864
+end: \
2865
+ mutex_unlock(&opts->lock); \
2866
+ return ret; \
2867
+} \
2868
+ \
2869
+UVC_ATTR(f_uvc_opts_string_, cname, aname)
2870
+
2871
+UVCG_OPTS_STRING_ATTR(function_name, function_name);
2872
+
2873
+#undef UVCG_OPTS_STRING_ATTR
28352874
28362875 static struct configfs_attribute *uvc_attrs[] = {
28372876 &f_uvc_opts_attr_streaming_bulk,
28382877 &f_uvc_opts_attr_streaming_interval,
28392878 &f_uvc_opts_attr_streaming_maxpacket,
28402879 &f_uvc_opts_attr_streaming_maxburst,
2841
- &f_uvc_opts_attr_uvc_num_request,
28422880 &f_uvc_opts_attr_pm_qos_latency,
2881
+#if defined(CONFIG_ARCH_ROCKCHIP) && defined(CONFIG_NO_GKI)
28432882 &f_uvc_opts_attr_device_name,
2883
+ &f_uvc_opts_attr_uvc_num_request,
2884
+ &f_uvc_opts_attr_uvc_zero_copy,
2885
+#endif
2886
+ &f_uvc_opts_string_attr_function_name,
28442887 NULL,
28452888 };
28462889