mirror of
https://github.com/sipeed/LicheeRV-Nano-Build.git
synced 2026-09-10 20:59:59 -05:00
Merge branch 'feat_uvc_server_standalone_mode'
1. feat: UvcServer run in standalone mode without uvc-gadget-server.elf. 2. opt: provide 2560x1440.
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,7 @@ supported_formats="yuyv mjpg"
|
|||||||
|
|
||||||
# 支持的分辨率,可以通过修改这个变量自定义支持的分辨率
|
# 支持的分辨率,可以通过修改这个变量自定义支持的分辨率
|
||||||
# Supported resolutions, you can customize the list by modifying this variable
|
# Supported resolutions, you can customize the list by modifying this variable
|
||||||
supported_resolutions="480x320 640x360 640x480 1280x720 1920x1080"
|
supported_resolutions="480x320 640x360 640x480 1280x720 1920x1080 2560x1440"
|
||||||
|
|
||||||
|
|
||||||
parse_uvc_config() {
|
parse_uvc_config() {
|
||||||
@@ -72,26 +72,24 @@ parse_uvc_config() {
|
|||||||
' "$input_file")
|
' "$input_file")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 如果没有解析到任何数据,或者文件不可读取,则返回默认值 / If no data is parsed or file is unreadable, return default values
|
|
||||||
if [ -z "$parsed_data" ]; then
|
|
||||||
echo "Warn: No valid config, using default instead." 1>&2 # 输出到标准错误 / Output to stderr
|
|
||||||
parsed_data="mjpg 640 360"$'\n'"yuyv 640 360"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 确保至少包含 'mjpg' 和 'yuyv' 格式 / Ensure at least one 'mjpg' and 'yuyv' format exists
|
# 确保至少包含 'mjpg' 和 'yuyv' 格式 / Ensure at least one 'mjpg' and 'yuyv' format exists
|
||||||
has_mjpg=$(echo "$parsed_data" | grep -w "mjpg")
|
has_mjpg=$(echo "$parsed_data" | grep -w "mjpg")
|
||||||
has_yuyv=$(echo "$parsed_data" | grep -w "yuyv")
|
has_yuyv=$(echo "$parsed_data" | grep -w "yuyv")
|
||||||
|
|
||||||
if [ -z "$has_mjpg" ]; then
|
if [ -z "$has_mjpg" ]; then
|
||||||
echo "Warn: No 'mjpg' config found, adding default 'mjpg 640 360'." 1>&2
|
default_mjpg=$'\nmjpg 480x320\nmjpg 640x360\nmjpg 640x480\nmjpg 1280x720\nmjpg 1920x1080\nmjpg 2560x1440\n'
|
||||||
parsed_data="$parsed_data"$'\n'"mjpg 640 360"
|
echo "Warn: No 'mjpg' config found, adding default: $default_mjpg" 1>&2
|
||||||
|
parsed_data="$parsed_data""$(echo "$default_mjpg" | sed 's/x/ /g')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$has_yuyv" ]; then
|
if [ -z "$has_yuyv" ]; then
|
||||||
echo "Warn: No 'yuyv' config found, adding default 'yuyv 640 360'." 1>&2
|
default_yuyv=$'\nyuyv 480x320\nyuyv 640x360\nyuyv 640x480\nyuyv 1280x720\nyuyv 1920x1080\nyuyv 2560x1440\n'
|
||||||
parsed_data="$parsed_data"$'\n'"yuyv 640 360"
|
echo "Warn: No 'yuyv' config found, adding default: $default_yuyv" 1>&2
|
||||||
|
parsed_data="$parsed_data""$(echo "$default_yuyv" | sed 's/x/ /g')"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
parsed_data=$(echo "$parsed_data" | sed '/^$/d') # 删除空行
|
||||||
|
|
||||||
echo "$parsed_data" # 返回解析的数据 / Return the parsed data
|
echo "$parsed_data" # 返回解析的数据 / Return the parsed data
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,21 +242,31 @@ case "$1" in
|
|||||||
unmount_uvc_configfs
|
unmount_uvc_configfs
|
||||||
;;
|
;;
|
||||||
"server")
|
"server")
|
||||||
(
|
if [ -z "$(fuser /etc/init.d/uvc-gadget-server.elf)" ]; then
|
||||||
echo "Waiting for UDC start..."
|
(
|
||||||
while [ -z "$(cat /sys/kernel/config/usb_gadget/g0/UDC)" ]; do
|
echo "Waiting for UDC start..."
|
||||||
echo -n "."
|
while [ -z "$(cat /sys/kernel/config/usb_gadget/g0/UDC)" ]; do
|
||||||
sleep 1
|
echo -n "."
|
||||||
done
|
sleep 1
|
||||||
sleep 2 # necessary delay time
|
done
|
||||||
echo -e "\nServer is starting..." # 输出选择了 server 模式 / Output that the server mode is selected
|
sleep 3 # necessary delay time
|
||||||
echo -e "===============================\n\n\n"
|
if [ -z "$(fuser /etc/init.d/uvc-gadget-server.elf)" ]; then
|
||||||
# 在这里添加你希望在 server 模式下执行的其他操作 / Add other operations you want to perform in server mode here
|
echo -e "\nServer is starting..." # 输出选择了 server 模式 / Output that the server mode is selected
|
||||||
/etc/init.d/uvc-gadget-server.elf -u /dev/$(basename /sys/class/udc/*/device/gadget/video4linux/video*) -d -i /bin/cat_224.jpg
|
echo -e "===============================\n\n\n"
|
||||||
) >/tmp/uvc-gadget.log 2>&1 &
|
# 在这里添加你希望在 server 模式下执行的其他操作 / Add other operations you want to perform in server mode here
|
||||||
|
/etc/init.d/uvc-gadget-server.elf -u /dev/$(basename /sys/class/udc/*/device/gadget/video4linux/video*) -d -i /bin/cat_224.jpg
|
||||||
|
else
|
||||||
|
echo -e "\nServer has started..."
|
||||||
|
echo -e "===============================\n\n\n"
|
||||||
|
fi
|
||||||
|
) >/tmp/uvc-gadget.log 2>&1 &
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
"stop_server")
|
||||||
|
fuser -k /etc/init.d/uvc-gadget-server.elf
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $0 {mount <file>|unmount|server}" # 提示正确的使用方式 / Prompt the correct usage
|
echo "Usage: $0 {mount <file>|unmount|server|stop_server}" # 提示正确的使用方式 / Prompt the correct usage
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user