|
@@ -1030,7 +1030,7 @@ static struct configfs_item_operations uvcg_frame_item_ops = {
|
|
.store_attribute = uvcg_frame_attr_store,
|
|
.store_attribute = uvcg_frame_attr_store,
|
|
};
|
|
};
|
|
|
|
|
|
-#define UVCG_FRAME_ATTR(cname, aname, conv, str2u, uxx, vnoc, limit) \
|
|
|
|
|
|
+#define UVCG_FRAME_ATTR(cname, aname, to_cpu_endian, to_little_endian, bits) \
|
|
static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\
|
|
static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\
|
|
{ \
|
|
{ \
|
|
struct f_uvc_opts *opts; \
|
|
struct f_uvc_opts *opts; \
|
|
@@ -1044,7 +1044,7 @@ static ssize_t uvcg_frame_##cname##_show(struct uvcg_frame *f, char *page)\
|
|
opts = to_f_uvc_opts(opts_item); \
|
|
opts = to_f_uvc_opts(opts_item); \
|
|
\
|
|
\
|
|
mutex_lock(&opts->lock); \
|
|
mutex_lock(&opts->lock); \
|
|
- result = sprintf(page, "%d\n", conv(f->frame.cname)); \
|
|
|
|
|
|
+ result = sprintf(page, "%d\n", to_cpu_endian(f->frame.cname)); \
|
|
mutex_unlock(&opts->lock); \
|
|
mutex_unlock(&opts->lock); \
|
|
\
|
|
\
|
|
mutex_unlock(su_mutex); \
|
|
mutex_unlock(su_mutex); \
|
|
@@ -1059,7 +1059,11 @@ static ssize_t uvcg_frame_##cname##_store(struct uvcg_frame *f, \
|
|
struct uvcg_format *fmt; \
|
|
struct uvcg_format *fmt; \
|
|
struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
|
|
struct mutex *su_mutex = &f->item.ci_group->cg_subsys->su_mutex;\
|
|
int ret; \
|
|
int ret; \
|
|
- uxx num; \
|
|
|
|
|
|
+ u##bits num; \
|
|
|
|
+ \
|
|
|
|
+ ret = kstrtou##bits(page, 0, &num); \
|
|
|
|
+ if (ret) \
|
|
|
|
+ return ret; \
|
|
\
|
|
\
|
|
mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
|
|
mutex_lock(su_mutex); /* for navigating configfs hierarchy */ \
|
|
\
|
|
\
|
|
@@ -1073,15 +1077,7 @@ static ssize_t uvcg_frame_##cname##_store(struct uvcg_frame *f, \
|
|
goto end; \
|
|
goto end; \
|
|
} \
|
|
} \
|
|
\
|
|
\
|
|
- ret = str2u(page, 0, &num); \
|
|
|
|
- if (ret) \
|
|
|
|
- goto end; \
|
|
|
|
- \
|
|
|
|
- if (num > limit) { \
|
|
|
|
- ret = -EINVAL; \
|
|
|
|
- goto end; \
|
|
|
|
- } \
|
|
|
|
- f->frame.cname = vnoc(num); \
|
|
|
|
|
|
+ f->frame.cname = to_little_endian(num); \
|
|
ret = len; \
|
|
ret = len; \
|
|
end: \
|
|
end: \
|
|
mutex_unlock(&opts->lock); \
|
|
mutex_unlock(&opts->lock); \
|
|
@@ -1095,24 +1091,20 @@ static struct uvcg_frame_attribute \
|
|
uvcg_frame_##cname##_show, \
|
|
uvcg_frame_##cname##_show, \
|
|
uvcg_frame_##cname##_store)
|
|
uvcg_frame_##cname##_store)
|
|
|
|
|
|
-#define identity_conv(x) (x)
|
|
|
|
|
|
+#define noop_conversion(x) (x)
|
|
|
|
|
|
-UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, identity_conv, kstrtou8, u8,
|
|
|
|
- identity_conv, 0xFF);
|
|
|
|
-UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, kstrtou16, u16, cpu_to_le16,
|
|
|
|
- 0xFFFF);
|
|
|
|
-UVCG_FRAME_ATTR(w_height, wHeight, le16_to_cpu, kstrtou16, u16, cpu_to_le16,
|
|
|
|
- 0xFFFF);
|
|
|
|
-UVCG_FRAME_ATTR(dw_min_bit_rate, dwMinBitRate, le32_to_cpu, kstrtou32, u32,
|
|
|
|
- cpu_to_le32, 0xFFFFFFFF);
|
|
|
|
-UVCG_FRAME_ATTR(dw_max_bit_rate, dwMaxBitRate, le32_to_cpu, kstrtou32, u32,
|
|
|
|
- cpu_to_le32, 0xFFFFFFFF);
|
|
|
|
|
|
+UVCG_FRAME_ATTR(bm_capabilities, bmCapabilities, noop_conversion,
|
|
|
|
+ noop_conversion, 8);
|
|
|
|
+UVCG_FRAME_ATTR(w_width, wWidth, le16_to_cpu, cpu_to_le16, 16);
|
|
|
|
+UVCG_FRAME_ATTR(w_height, wHeight, le16_to_cpu, cpu_to_le16, 16);
|
|
|
|
+UVCG_FRAME_ATTR(dw_min_bit_rate, dwMinBitRate, le32_to_cpu, cpu_to_le32, 32);
|
|
|
|
+UVCG_FRAME_ATTR(dw_max_bit_rate, dwMaxBitRate, le32_to_cpu, cpu_to_le32, 32);
|
|
UVCG_FRAME_ATTR(dw_max_video_frame_buffer_size, dwMaxVideoFrameBufferSize,
|
|
UVCG_FRAME_ATTR(dw_max_video_frame_buffer_size, dwMaxVideoFrameBufferSize,
|
|
- le32_to_cpu, kstrtou32, u32, cpu_to_le32, 0xFFFFFFFF);
|
|
|
|
|
|
+ le32_to_cpu, cpu_to_le32, 32);
|
|
UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval,
|
|
UVCG_FRAME_ATTR(dw_default_frame_interval, dwDefaultFrameInterval,
|
|
- le32_to_cpu, kstrtou32, u32, cpu_to_le32, 0xFFFFFFFF);
|
|
|
|
|
|
+ le32_to_cpu, cpu_to_le32, 32);
|
|
|
|
|
|
-#undef identity_conv
|
|
|
|
|
|
+#undef noop_conversion
|
|
|
|
|
|
#undef UVCG_FRAME_ATTR
|
|
#undef UVCG_FRAME_ATTR
|
|
|
|
|